@gatling.io/postman 3.13.104-M6 → 3.13.104-M7
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/package.json +3 -3
- package/jest.config.js +0 -5
- package/src/index.ts +0 -1
- package/src/jvm.ts +0 -7
- package/src/postman/index.ts +0 -114
- package/src/postman/request.ts +0 -104
- package/src/postman/utils.ts +0 -48
- package/src/typings/postman-collection.d.ts +0 -2702
- package/tsconfig.json +0 -22
|
@@ -1,2702 +0,0 @@
|
|
|
1
|
-
// Type definitions for postman-collection 4.4.1
|
|
2
|
-
// Project: https://github.com/postmanlabs/postman-collection
|
|
3
|
-
// Definitions by: PostmanLabs
|
|
4
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
-
// TypeScript Version: 2.4
|
|
6
|
-
/// <reference types="node" />
|
|
7
|
-
|
|
8
|
-
declare module "postman-collection" {
|
|
9
|
-
/**
|
|
10
|
-
* @example
|
|
11
|
-
* Create a new CertificateList
|
|
12
|
-
* var CertificateList = require('postman-collection').CertificateList,
|
|
13
|
-
* certificateList = new CertificateList({}, [
|
|
14
|
-
* {
|
|
15
|
-
* name: 'my certificate for example.com',
|
|
16
|
-
* matches: ['https://example.com/*'],
|
|
17
|
-
* key: { src: '/path/to/key/file' },
|
|
18
|
-
* cert: { src: '/path/to/certificate/file' }
|
|
19
|
-
* },
|
|
20
|
-
* {
|
|
21
|
-
* name: 'my certificate for example2.com',
|
|
22
|
-
* matches: ['https://example2.com/*'],
|
|
23
|
-
* key: { src: '/path/to/key/file' },
|
|
24
|
-
* cert: { src: '/path/to/key/file' }
|
|
25
|
-
* }
|
|
26
|
-
* ]);
|
|
27
|
-
* @param parent - -
|
|
28
|
-
* @param list - The list of certificate representations
|
|
29
|
-
*/
|
|
30
|
-
export class CertificateList extends PropertyList<Certificate> {
|
|
31
|
-
constructor(parent: any, list: any[]);
|
|
32
|
-
/**
|
|
33
|
-
* Matches the given url against the member certificates' allowed matches
|
|
34
|
-
* and returns the certificate that can be used for the url.
|
|
35
|
-
* @param url - The url to find the certificate for
|
|
36
|
-
* @returns The matched certificate
|
|
37
|
-
*/
|
|
38
|
-
resolveOne(url: string): Certificate.definition;
|
|
39
|
-
/**
|
|
40
|
-
* Checks if the given object is a CertificateList
|
|
41
|
-
* @param obj - -
|
|
42
|
-
*/
|
|
43
|
-
static isCertificateList(obj: any): boolean;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export namespace Certificate {
|
|
47
|
-
/**
|
|
48
|
-
* The following is the object representation accepted as param for the Certificate constructor.
|
|
49
|
-
* Also the type of the object returned when Property.toJSON or Property.toObjectResolved is called on a
|
|
50
|
-
* Certificate instance.
|
|
51
|
-
* @example
|
|
52
|
-
* JSON definition of an example certificate object
|
|
53
|
-
* {
|
|
54
|
-
* "name": "My certificate for example.com",
|
|
55
|
-
* "matches": ["https://example.com/*"],
|
|
56
|
-
* "key": { "src": "/path/to/key" },
|
|
57
|
-
* "cert": { "src": "/User/path/to/certificate" },
|
|
58
|
-
* "passphrase": "iampassphrase"
|
|
59
|
-
* }
|
|
60
|
-
* @property [name] - A name for the certificate
|
|
61
|
-
* @property [matches] - A list of match patterns
|
|
62
|
-
* @property [key] - Object with path on the file system for private key file, as src
|
|
63
|
-
* @property [cert] - Object with path on the file system for certificate file, as src
|
|
64
|
-
* @property [passphrase] - The passphrase for the certificate key
|
|
65
|
-
*/
|
|
66
|
-
type definition = {
|
|
67
|
-
name?: string;
|
|
68
|
-
matches?: any[];
|
|
69
|
-
key?: any;
|
|
70
|
-
cert?: any;
|
|
71
|
-
passphrase?: string;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* A Certificate definition that represents the ssl certificate
|
|
77
|
-
* to be used for an url.
|
|
78
|
-
* Properties can then use the `.toObjectResolved` function to procure an object representation of the property with
|
|
79
|
-
* all the variable references replaced by corresponding values.
|
|
80
|
-
* @example
|
|
81
|
-
* Create a new Certificate
|
|
82
|
-
*
|
|
83
|
-
* var Certificate = require('postman-collection').Certificate,
|
|
84
|
-
* certificate = new Certificate({
|
|
85
|
-
* name: 'Certificate for example.com',
|
|
86
|
-
* matches: ['example.com'],
|
|
87
|
-
* key: { src: '/User/path/to/certificate/key' },
|
|
88
|
-
* cert: { src: '/User/path/to/certificate' },
|
|
89
|
-
* passphrase: 'iampassphrase'
|
|
90
|
-
* });
|
|
91
|
-
* @param [options] - Object with matches, key, cert and passphrase
|
|
92
|
-
*/
|
|
93
|
-
export class Certificate extends Property {
|
|
94
|
-
constructor(options?: Certificate.definition);
|
|
95
|
-
/**
|
|
96
|
-
* Updates the certificate with the given properties.
|
|
97
|
-
* @param [options] - Object with matches, key, cert and passphrase
|
|
98
|
-
*/
|
|
99
|
-
update(options?: Certificate.definition): void;
|
|
100
|
-
/**
|
|
101
|
-
* Unique identifier
|
|
102
|
-
*/
|
|
103
|
-
id: string;
|
|
104
|
-
/**
|
|
105
|
-
* Name for user reference
|
|
106
|
-
*/
|
|
107
|
-
name: string;
|
|
108
|
-
/**
|
|
109
|
-
* List of match pattern
|
|
110
|
-
*/
|
|
111
|
-
matches: UrlMatchPatternList;
|
|
112
|
-
/**
|
|
113
|
-
* Private Key
|
|
114
|
-
*/
|
|
115
|
-
key: any;
|
|
116
|
-
/**
|
|
117
|
-
* Certificate
|
|
118
|
-
*/
|
|
119
|
-
cert: any;
|
|
120
|
-
/**
|
|
121
|
-
* PFX or PKCS12 Certificate
|
|
122
|
-
*/
|
|
123
|
-
pfx: any;
|
|
124
|
-
/**
|
|
125
|
-
* passphrase
|
|
126
|
-
*/
|
|
127
|
-
passphrase: any;
|
|
128
|
-
/**
|
|
129
|
-
* Checks if the certificate can be applied to a given url
|
|
130
|
-
* @param url - The url string for which the certificate is checked for match.
|
|
131
|
-
*/
|
|
132
|
-
canApplyTo(url: string | Url): void;
|
|
133
|
-
/**
|
|
134
|
-
* Allows the serialization of a Certificate
|
|
135
|
-
*
|
|
136
|
-
* This is overridden, in order to ensure that certificate contents are not accidentally serialized,
|
|
137
|
-
* which can be a security risk.
|
|
138
|
-
*/
|
|
139
|
-
toJSON(): void;
|
|
140
|
-
/**
|
|
141
|
-
* Checks if the given object is a Certificate
|
|
142
|
-
* @param obj - -
|
|
143
|
-
*/
|
|
144
|
-
static isCertificate(obj: any): boolean;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export namespace Collection {
|
|
148
|
-
/**
|
|
149
|
-
* The following is the object structure accepted as constructor parameter while calling `new Collection(...)`. It is
|
|
150
|
-
* also the structure exported when Property.toJSON or Property.toObjectResolved is called on a
|
|
151
|
-
* collection instance.
|
|
152
|
-
* @example
|
|
153
|
-
* JSON definition of an example collection
|
|
154
|
-
* {
|
|
155
|
-
* "info": {
|
|
156
|
-
* "name": "My Postman Collection",
|
|
157
|
-
* "version": "1.0.0"
|
|
158
|
-
* }
|
|
159
|
-
* "item": [{
|
|
160
|
-
* "request": "{{base-url}}/get"
|
|
161
|
-
* }],
|
|
162
|
-
* "variables": [{
|
|
163
|
-
* "id": "base-url",
|
|
164
|
-
* "value": "https://postman-echo.com"
|
|
165
|
-
* }]
|
|
166
|
-
* }
|
|
167
|
-
* @property [info] - The meta information regarding the collection is provided as the `info` object.
|
|
168
|
-
* @property [info.id] - Every collection is identified by the unique value of this property. It is recommended
|
|
169
|
-
* that you maintain the same id since changing the id usually implies that is a different collection than it was
|
|
170
|
-
* originally.
|
|
171
|
-
* @property [info.name] - A collection's friendly name is defined by this property. You would want to set this
|
|
172
|
-
* field to a value that would allow you to easily identify this collection among a bunch of other collections.
|
|
173
|
-
* @property [info.version] - Postman allows you to version your collections as they grow, and this field holds
|
|
174
|
-
* the version number. While optional, it is recommended that you use this field to its fullest extent.
|
|
175
|
-
* @property [item] - Items are the basic unit for a Postman collection.
|
|
176
|
-
* You can think of them as corresponding to a single API endpoint. Each Item has one request and may have multiple API
|
|
177
|
-
* responses associated with it.
|
|
178
|
-
* @property [variable] - Collection variables allow you to define a set of variables,
|
|
179
|
-
* that are a *part of the collection*, as opposed to environments, which are separate entities.
|
|
180
|
-
* @property [auth] - Collection auth allows you to define an authentication,
|
|
181
|
-
* that *applies to all items* in the collection.
|
|
182
|
-
* @property [event] - Postman allows you to configure scripts to run when specific events
|
|
183
|
-
* occur.
|
|
184
|
-
* @property [version] - Version of the collection expressed in [semver](http://semver.org/)
|
|
185
|
-
* format.
|
|
186
|
-
*/
|
|
187
|
-
type definition = {
|
|
188
|
-
info?: {
|
|
189
|
-
id?: string;
|
|
190
|
-
name?: string;
|
|
191
|
-
version?: string;
|
|
192
|
-
};
|
|
193
|
-
item?: (Item.definition | ItemGroup.definition)[];
|
|
194
|
-
variable?: Variable.definition;
|
|
195
|
-
auth?: RequestAuth.definition;
|
|
196
|
-
event?: Event.definition[];
|
|
197
|
-
version?: string | Version.definition;
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Create or load an instance of [Postman Collection](https://www.getpostman.com/docs/collections) as a JavaScript
|
|
203
|
-
* object that can be manipulated easily.
|
|
204
|
-
*
|
|
205
|
-
* A collection lets you group individual requests together. These requests can be further organized into folders to
|
|
206
|
-
* accurately mirror your API. Requests can also store sample responses when saved in a collection. You can add
|
|
207
|
-
* metadata like name and description too so that all the information that a developer needs to use your API is
|
|
208
|
-
* available easily.
|
|
209
|
-
* @example
|
|
210
|
-
* Load a Collection JSON file from disk
|
|
211
|
-
* var fs = require('fs'), // needed to read JSON file from disk
|
|
212
|
-
* pretty = function (obj) { // function to neatly log the collection object to console
|
|
213
|
-
* return require('util').inspect(obj, {colors: true});
|
|
214
|
-
* },
|
|
215
|
-
* Collection = require('postman-collection').Collection,
|
|
216
|
-
* myCollection;
|
|
217
|
-
*
|
|
218
|
-
* // Load a collection to memory from a JSON file on disk (say, sample-collection.json)
|
|
219
|
-
* myCollection = new Collection(JSON.stringify(fs.readFileSync('sample-collection.json').toString()));
|
|
220
|
-
*
|
|
221
|
-
* // log items at root level of the collection
|
|
222
|
-
* console.log(pretty(myCollection));
|
|
223
|
-
* @example
|
|
224
|
-
* Create a blank collection and write to file
|
|
225
|
-
* var fs = require('fs'),
|
|
226
|
-
* Collection = require('postman-collection').Collection,
|
|
227
|
-
* mycollection;
|
|
228
|
-
*
|
|
229
|
-
* myCollection = new Collection({
|
|
230
|
-
* info: {
|
|
231
|
-
* name: "my Collection"
|
|
232
|
-
* }
|
|
233
|
-
* });
|
|
234
|
-
*
|
|
235
|
-
* // log the collection to console to see its contents
|
|
236
|
-
* fs.writeFileSync('myCollection.postman_collection', JSON.stringify(myCollection, null, 2));
|
|
237
|
-
* @param [definition] - Pass the initial definition of the collection (name, id, etc) as
|
|
238
|
-
* the `definition` parameter. The definition object is structured exactly as the collection format as defined in
|
|
239
|
-
* [https://www.schema.getpostman.com/](https://www.schema.getpostman.com/). This parameter is optional. That
|
|
240
|
-
* implies that you can create an empty instance of collection and add requests and other properties in order to
|
|
241
|
-
* build a new collection.
|
|
242
|
-
* @param [environments] - The collection instance constructor accepts the second parameter as an
|
|
243
|
-
* array of environment objects. Environments objects store variable definitions that are inherited by
|
|
244
|
-
* Collection.variables. These environment variables are usually the ones that are exported from the Postman
|
|
245
|
-
* App to use them with different collections. Refer to Postman
|
|
246
|
-
* [documentation on environment variables](https://www.getpostman.com/docs/environments).
|
|
247
|
-
*/
|
|
248
|
-
export class Collection extends ItemGroup {
|
|
249
|
-
constructor(definition?: Collection.definition, environments?: object[]);
|
|
250
|
-
/**
|
|
251
|
-
* The `variables` property holds a list of variables that are associated with a Collection. These variables
|
|
252
|
-
* are stored within a collection so that they can be re-used and replaced in rest of the collection. For
|
|
253
|
-
* example, if one has a variable named `port` with value `8080`, then one can write a request Url
|
|
254
|
-
* as `http://localhost:{{port}}/my/endpoint` and that will be replaced to form
|
|
255
|
-
* `http://localhost:8080/my/endpoint`. **Collection Variables** are like
|
|
256
|
-
* [environment variables](https://www.getpostman.com/docs/environments), but stored locally within a
|
|
257
|
-
* collection.
|
|
258
|
-
* @example
|
|
259
|
-
* Creating a collection with variables
|
|
260
|
-
* var fs = require('fs'),
|
|
261
|
-
* Collection = require('postman-collection').Collection,
|
|
262
|
-
* mycollection;
|
|
263
|
-
*
|
|
264
|
-
* // Create a new empty collection.
|
|
265
|
-
* myCollection = new Collection();
|
|
266
|
-
*
|
|
267
|
-
* // Add a variable to the collection
|
|
268
|
-
* myCollection.variables.add({
|
|
269
|
-
* id: 'apiBaseUrl',
|
|
270
|
-
* value: 'http://timeapi.org',
|
|
271
|
-
* type: 'string'
|
|
272
|
-
* });
|
|
273
|
-
*
|
|
274
|
-
* //Add a request that uses the variable that we just added.
|
|
275
|
-
* myCollection.items.add({
|
|
276
|
-
* id: 'utc-time-now',
|
|
277
|
-
* name: 'Get the current time in UTC',
|
|
278
|
-
* request: '{{apiBaseUrl}}/utc/now'
|
|
279
|
-
* });
|
|
280
|
-
*/
|
|
281
|
-
variables: VariableList;
|
|
282
|
-
/**
|
|
283
|
-
* The `version` key in collection is used to express the version of the collection. It is useful in either
|
|
284
|
-
* tracking development iteration of an API server or the version of an API itself. It can also be used to
|
|
285
|
-
* represent the number of iterations of the collection as it is updated through its lifetime.
|
|
286
|
-
*
|
|
287
|
-
* Version is expressed in [semver](http://semver.org/) format.
|
|
288
|
-
*/
|
|
289
|
-
version: Version;
|
|
290
|
-
/**
|
|
291
|
-
* Using this function, one can sync the values of collection variables from a reference object.
|
|
292
|
-
* @param obj - -
|
|
293
|
-
* @param [track] - -
|
|
294
|
-
*/
|
|
295
|
-
syncVariablesFrom(obj: any, track?: boolean): any;
|
|
296
|
-
/**
|
|
297
|
-
* Transfer the variables in this scope to an object
|
|
298
|
-
* @param [obj] - -
|
|
299
|
-
*/
|
|
300
|
-
syncVariablesTo(obj?: any): any;
|
|
301
|
-
/**
|
|
302
|
-
* Convert the collection to JSON compatible plain object
|
|
303
|
-
*/
|
|
304
|
-
toJSON(): any;
|
|
305
|
-
/**
|
|
306
|
-
* Check whether an object is an instance of ItemGroup.
|
|
307
|
-
* @param obj - -
|
|
308
|
-
*/
|
|
309
|
-
static isCollection(obj: any): boolean;
|
|
310
|
-
/**
|
|
311
|
-
* In this list, one can define the Scripts to be executed when an event is triggered. Events are
|
|
312
|
-
* triggered before certain actions are taken on a Collection, Request, etc. For example, executing a
|
|
313
|
-
* request causes the `prerequest` and the `test` events to be triggered.
|
|
314
|
-
* @example
|
|
315
|
-
* Executing a common test script for all requests in a collection
|
|
316
|
-
* var fs = require('fs'), // needed to read JSON file from disk
|
|
317
|
-
* Collection = require('postman-collection').Collection,
|
|
318
|
-
* myCollection;
|
|
319
|
-
*
|
|
320
|
-
* // Load a collection to memory from a JSON file on disk (say, sample-collection.json)
|
|
321
|
-
* myCollection = new Collection(JSON.stringify(fs.readFileSync('sample-collection.json').toString()));
|
|
322
|
-
*
|
|
323
|
-
* // Add an event listener to the collection that listens to the `test` event.
|
|
324
|
-
* myCollection.events.add({
|
|
325
|
-
* listen: 'test',
|
|
326
|
-
* script: {
|
|
327
|
-
* exec: 'tests["Status code is 200"] = (responseCode.code === 200)'
|
|
328
|
-
* }
|
|
329
|
-
* });
|
|
330
|
-
*/
|
|
331
|
-
events: EventList;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Contains a list of header elements
|
|
336
|
-
* @param parent - -
|
|
337
|
-
* @param cookies - -
|
|
338
|
-
*/
|
|
339
|
-
export class CookieList extends PropertyList<Cookie> {
|
|
340
|
-
constructor(parent: any, cookies: object[]);
|
|
341
|
-
/**
|
|
342
|
-
* Checks if the given object is a CookieList
|
|
343
|
-
* @param obj - -
|
|
344
|
-
*/
|
|
345
|
-
static isCookieList(obj: any): boolean;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
export namespace Cookie {
|
|
349
|
-
/**
|
|
350
|
-
* The following is the object structure accepted as constructor parameter while calling `new Cookie(...)`. It is
|
|
351
|
-
* also the structure exported when Property.toJSON or Property.toObjectResolved is called on a
|
|
352
|
-
* Cookie instance.
|
|
353
|
-
* @example
|
|
354
|
-
* JSON definition of an example cookie
|
|
355
|
-
* {
|
|
356
|
-
* "key": "my-cookie-name",
|
|
357
|
-
* "expires": "1464769543832",
|
|
358
|
-
* // UNIX timestamp, in *milliseconds*
|
|
359
|
-
* "maxAge": "300",
|
|
360
|
-
* // In seconds. In this case, the Cookie is valid for 5 minutes
|
|
361
|
-
* "domain": "something.example.com",
|
|
362
|
-
* "path": "/",
|
|
363
|
-
* "secure": false,
|
|
364
|
-
* "httpOnly": true,
|
|
365
|
-
* "session": false,
|
|
366
|
-
* "value": "my-cookie-value",
|
|
367
|
-
* "extensions": [{
|
|
368
|
-
* "key": "Priority",
|
|
369
|
-
* "value": "HIGH"
|
|
370
|
-
* }]
|
|
371
|
-
* }
|
|
372
|
-
* @property [key] - The name of the cookie. Some call it the "name".
|
|
373
|
-
* @property [value] - The value stored in the Cookie
|
|
374
|
-
* @property [expires] - Expires sets an expiry date for when a cookie gets deleted. It should either be a
|
|
375
|
-
* date object or timestamp string of date.
|
|
376
|
-
* @property [maxAge] - Max-age sets the time in seconds for when a cookie will be deleted.
|
|
377
|
-
* @property [domain] - Indicates the domain(s) for which the cookie should be sent.
|
|
378
|
-
* @property [path] - Limits the scope of the cookie to a specified path, e.g: "/accounts"
|
|
379
|
-
* @property [secure] - A secure cookie will only be sent to the server when a request is made using SSL and
|
|
380
|
-
* the HTTPS protocol.
|
|
381
|
-
* The idea that the contents of the cookie are of high value and could be potentially damaging to transmit
|
|
382
|
-
* as clear text.
|
|
383
|
-
* @property [httpOnly] - The idea behind HTTP-only cookies is to instruct a browser that a cookie should never
|
|
384
|
-
* be accessible via JavaScript through the document.cookie property. This feature was designed as a security measure
|
|
385
|
-
* to help prevent cross-site scripting (XSS) attacks perpetrated by stealing cookies via JavaScript.
|
|
386
|
-
* @property [hostOnly] - Indicates that this cookie is only valid for the given domain (and not its parent or
|
|
387
|
-
* child domains.)
|
|
388
|
-
* @property [session] - Indicates whether this is a Session Cookie. (A transient cookie, which is deleted at
|
|
389
|
-
* the end of an HTTP session.)
|
|
390
|
-
* @property [extensions] - Any extra attributes that are extensions to the original Cookie specification can be
|
|
391
|
-
* specified here.
|
|
392
|
-
* @property [extensions[].key] - Name of the extension.
|
|
393
|
-
* @property [extensions[].value] - Value of the extension
|
|
394
|
-
*/
|
|
395
|
-
type definition = {
|
|
396
|
-
key?: string;
|
|
397
|
-
value?: string;
|
|
398
|
-
expires?: string;
|
|
399
|
-
maxAge?: number;
|
|
400
|
-
domain?: string;
|
|
401
|
-
path?: string;
|
|
402
|
-
secure?: boolean;
|
|
403
|
-
httpOnly?: boolean;
|
|
404
|
-
hostOnly?: boolean;
|
|
405
|
-
session?: boolean;
|
|
406
|
-
extensions?: {
|
|
407
|
-
key?: string;
|
|
408
|
-
value?: string;
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* A Postman Cookie definition that comprehensively represents an HTTP Cookie.
|
|
415
|
-
* @example
|
|
416
|
-
* Create a new Cookie
|
|
417
|
-
* var Cookie = require('postman-collection').Cookie,
|
|
418
|
-
* myCookie = new Cookie({
|
|
419
|
-
* name: 'my-cookie-name',
|
|
420
|
-
* expires: '1464769543832', // UNIX timestamp, in *milliseconds*
|
|
421
|
-
* maxAge: '300', // In seconds. In this case, the Cookie is valid for 5 minutes
|
|
422
|
-
* domain: 'something.example.com',
|
|
423
|
-
* path: '/',
|
|
424
|
-
* secure: false,
|
|
425
|
-
* httpOnly: true,
|
|
426
|
-
* session: false,
|
|
427
|
-
* value: 'my-cookie-value',
|
|
428
|
-
* extensions: [{
|
|
429
|
-
* key: 'Priority',
|
|
430
|
-
* value: 'HIGH'
|
|
431
|
-
* }]
|
|
432
|
-
* });
|
|
433
|
-
* @example
|
|
434
|
-
* Parse a Cookie Header
|
|
435
|
-
* var Cookie = require('postman-collection').Cookie,
|
|
436
|
-
* rawHeader = 'myCookie=myValue;Path=/;Expires=Sun, 04-Feb-2018 14:18:27 GMT;Secure;HttpOnly;Priority=HIGH'
|
|
437
|
-
* myCookie = new Cookie(rawHeader);
|
|
438
|
-
*
|
|
439
|
-
* console.log(myCookie.toJSON());
|
|
440
|
-
* @param [options] - Pass the initial definition of the Cookie.
|
|
441
|
-
*/
|
|
442
|
-
export class Cookie extends PropertyBase {
|
|
443
|
-
constructor(options?: Cookie.definition);
|
|
444
|
-
/**
|
|
445
|
-
* The name of the cookie.
|
|
446
|
-
*/
|
|
447
|
-
name: string;
|
|
448
|
-
/**
|
|
449
|
-
* Expires sets an expiry date for when a cookie gets deleted. It should either be a date object or
|
|
450
|
-
* timestamp string of date.
|
|
451
|
-
*/
|
|
452
|
-
expires: Date | string;
|
|
453
|
-
/**
|
|
454
|
-
* Max-age sets the time in seconds for when a cookie will be deleted.
|
|
455
|
-
*/
|
|
456
|
-
maxAge: number;
|
|
457
|
-
/**
|
|
458
|
-
* Indicates the domain(s) for which the cookie should be sent.
|
|
459
|
-
*/
|
|
460
|
-
domain: string;
|
|
461
|
-
path: string;
|
|
462
|
-
/**
|
|
463
|
-
* A secure cookie will only be sent to the server when a request is made using SSL and the HTTPS protocol.
|
|
464
|
-
* The idea that the contents of the cookie are of high value and could be potentially damaging to transmit
|
|
465
|
-
* as clear text.
|
|
466
|
-
*/
|
|
467
|
-
secure: boolean;
|
|
468
|
-
/**
|
|
469
|
-
* The idea behind HTTP-only cookies is to instruct a browser that a cookie should never be accessible via
|
|
470
|
-
* JavaScript through the document.cookie property. This feature was designed as a security measure to help
|
|
471
|
-
* prevent cross-site scripting (XSS) attacks perpetrated by stealing cookies via JavaScript.
|
|
472
|
-
*/
|
|
473
|
-
httpOnly: boolean;
|
|
474
|
-
hostOnly: boolean;
|
|
475
|
-
/**
|
|
476
|
-
* Indicates whether this is a Session Cookie.
|
|
477
|
-
*/
|
|
478
|
-
session: boolean;
|
|
479
|
-
value: string;
|
|
480
|
-
/**
|
|
481
|
-
* Any extra parameters that are not strictly a part of the Cookie spec go here.
|
|
482
|
-
*/
|
|
483
|
-
extensions: any[];
|
|
484
|
-
/**
|
|
485
|
-
* Get the value of this cookie.
|
|
486
|
-
*/
|
|
487
|
-
valueOf(): string;
|
|
488
|
-
/**
|
|
489
|
-
* Converts the Cookie to a single Set-Cookie header string.
|
|
490
|
-
*/
|
|
491
|
-
toString(): string;
|
|
492
|
-
/**
|
|
493
|
-
* Check whether an object is an instance of PostmanCookie.
|
|
494
|
-
* @param obj - -
|
|
495
|
-
*/
|
|
496
|
-
static isCookie(obj: any): boolean;
|
|
497
|
-
/**
|
|
498
|
-
* Stringifies an Array or PropertyList of Cookies into a single string.
|
|
499
|
-
* @param cookies - List of cookie definition object
|
|
500
|
-
*/
|
|
501
|
-
static unparse(cookies: Cookie[]): string;
|
|
502
|
-
/**
|
|
503
|
-
* Unparses a single Cookie.
|
|
504
|
-
* @param cookie - Cookie definition object
|
|
505
|
-
*/
|
|
506
|
-
static unparseSingle(cookie: Cookie): string;
|
|
507
|
-
/**
|
|
508
|
-
* Cookie header parser
|
|
509
|
-
* @param str - -
|
|
510
|
-
* @returns A plain cookie options object, use it to create a new Cookie
|
|
511
|
-
*/
|
|
512
|
-
static parse(str: string): any;
|
|
513
|
-
/**
|
|
514
|
-
* Converts the Cookie to a single Set-Cookie header string.
|
|
515
|
-
* @param cookie - Cookie definition object
|
|
516
|
-
*/
|
|
517
|
-
static stringify(cookie: Cookie): string;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
export namespace Description {
|
|
521
|
-
type definition = {
|
|
522
|
-
content: string;
|
|
523
|
-
type: string;
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* This is one of the properties that are (if provided) processed by all other properties. Any property can have an
|
|
529
|
-
* instance of `Description` property assigned to it with the key name `description` and it should be treated as
|
|
530
|
-
* something that "describes" the property within which it belongs. Usually this property is used to generate
|
|
531
|
-
* documentation and other contextual information for a property in a Collection.
|
|
532
|
-
* @example
|
|
533
|
-
* Add a description to an instance of Collection
|
|
534
|
-
* var SDK = require('postman-collection'),
|
|
535
|
-
* Collection = SDK.Collection,
|
|
536
|
-
* Description = SDK.Description,
|
|
537
|
-
* mycollection;
|
|
538
|
-
*
|
|
539
|
-
* // create a blank collection
|
|
540
|
-
* myCollection = new Collection();
|
|
541
|
-
* myCollection.description = new Description({
|
|
542
|
-
* content: '<h1>Hello World</h1><p>I am a Collection</p>',
|
|
543
|
-
* type: 'text/html'
|
|
544
|
-
* });
|
|
545
|
-
*
|
|
546
|
-
* // alternatively, you could also use the `.describe` method of any property to set or update the description of the
|
|
547
|
-
* // property.
|
|
548
|
-
* myCollection.describe('Hey! This is a cool collection.');
|
|
549
|
-
* @param [definition] - The content of the description can be passed as a string when it
|
|
550
|
-
* is in `text/plain` format or otherwise be sent as part of an object adhering to the Description.definition
|
|
551
|
-
* structure having `content` and `type`.
|
|
552
|
-
*/
|
|
553
|
-
export class Description {
|
|
554
|
-
constructor(definition?: Description.definition | string);
|
|
555
|
-
/**
|
|
556
|
-
* Updates the content of this description property.
|
|
557
|
-
* @param content - -
|
|
558
|
-
* @param [type] - -
|
|
559
|
-
*/
|
|
560
|
-
update(content: string | Description.definition, type?: string): void;
|
|
561
|
-
/**
|
|
562
|
-
* The raw content of the description
|
|
563
|
-
*/
|
|
564
|
-
content: string;
|
|
565
|
-
/**
|
|
566
|
-
* The mime-type of the description.
|
|
567
|
-
*/
|
|
568
|
-
type: string;
|
|
569
|
-
/**
|
|
570
|
-
* Returns stringified Description.
|
|
571
|
-
*/
|
|
572
|
-
toString(): string;
|
|
573
|
-
/**
|
|
574
|
-
* Creates a JSON representation of the Description (as a plain Javascript object).
|
|
575
|
-
*/
|
|
576
|
-
toJSON(): any;
|
|
577
|
-
/**
|
|
578
|
-
* Checks whether a property is an instance of Description object.
|
|
579
|
-
* @param obj - -
|
|
580
|
-
*/
|
|
581
|
-
static isDescription(obj: any): boolean;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* A type of PropertyList, EventList handles resolving events from parents. If an ItemGroup contains
|
|
586
|
-
* a set of events, each Item in that group will inherit those events from its parent, and so on.
|
|
587
|
-
* @param parent - -
|
|
588
|
-
* @param populate - -
|
|
589
|
-
*/
|
|
590
|
-
export class EventList extends PropertyList<Event> {
|
|
591
|
-
constructor(parent: any, populate: object[]);
|
|
592
|
-
/**
|
|
593
|
-
* Returns an array of listeners filtered by the listener name
|
|
594
|
-
* @param name - -
|
|
595
|
-
*/
|
|
596
|
-
listeners(name: string): Event[];
|
|
597
|
-
/**
|
|
598
|
-
* Returns all events with specific listeners only within this list. Refer to EventList.listeners for
|
|
599
|
-
* procuring all inherited events
|
|
600
|
-
* @param name - -
|
|
601
|
-
*/
|
|
602
|
-
listenersOwn(name: string): Event[];
|
|
603
|
-
/**
|
|
604
|
-
* Checks if the given object is an EventList.
|
|
605
|
-
* @param obj - -
|
|
606
|
-
*/
|
|
607
|
-
static isEventList(obj: any): boolean;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
export namespace Event {
|
|
611
|
-
/**
|
|
612
|
-
* @example
|
|
613
|
-
* Constructing an event
|
|
614
|
-
* var Event = require('postman-collection').Event,
|
|
615
|
-
* rawEvent = {
|
|
616
|
-
* listen: 'test',
|
|
617
|
-
* script: 'tests["response code is 401"] = responseCode.code === 401'
|
|
618
|
-
* },
|
|
619
|
-
* myEvent;
|
|
620
|
-
* myEvent = new Event(rawEvent);
|
|
621
|
-
* @property listen - The event-name that this script will be called for. Usually either "test" or "prerequest"
|
|
622
|
-
* @property script - A Script instance that will be executed on this event. In case of a
|
|
623
|
-
* string, a new Script is created.
|
|
624
|
-
*/
|
|
625
|
-
type definition = {
|
|
626
|
-
listen: string;
|
|
627
|
-
script: Script | string;
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* A Postman event definition that refers to an event to be listened to and a script reference or definition to be
|
|
633
|
-
* executed.
|
|
634
|
-
* @param definition - Pass the initial definition of the event as the options parameter.
|
|
635
|
-
*/
|
|
636
|
-
export class Event extends Property {
|
|
637
|
-
constructor(definition: Event.definition);
|
|
638
|
-
/**
|
|
639
|
-
* Update an event.
|
|
640
|
-
* @param definition - -
|
|
641
|
-
*/
|
|
642
|
-
update(definition: Event.definition): void;
|
|
643
|
-
/**
|
|
644
|
-
* Name of the event that this instance is intended to listen to.
|
|
645
|
-
*/
|
|
646
|
-
listen: string;
|
|
647
|
-
/**
|
|
648
|
-
* The script that is to be executed when this event is triggered.
|
|
649
|
-
*/
|
|
650
|
-
script: Script;
|
|
651
|
-
/**
|
|
652
|
-
* Check whether an object is an instance of Event.
|
|
653
|
-
* @param obj - -
|
|
654
|
-
*/
|
|
655
|
-
static isEvent(obj: any): boolean;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
export namespace FormParam {
|
|
659
|
-
/**
|
|
660
|
-
* @property key - The name ("key") of the form data parameter.
|
|
661
|
-
* @property value - The value of the parameter.
|
|
662
|
-
*/
|
|
663
|
-
type definition = {
|
|
664
|
-
key: string;
|
|
665
|
-
type: TYPE;
|
|
666
|
-
value?: string;
|
|
667
|
-
src?: string;
|
|
668
|
-
contentType?: string;
|
|
669
|
-
fileName?: string;
|
|
670
|
-
};
|
|
671
|
-
type TYPE = "string" | "file";
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Represents a Form Data parameter, which can exist in request body.
|
|
676
|
-
* @param options - Pass the initial definition of the form data parameter.
|
|
677
|
-
*/
|
|
678
|
-
export class FormParam extends Property {
|
|
679
|
-
constructor(options: any);
|
|
680
|
-
key: string;
|
|
681
|
-
type: FormParam.TYPE;
|
|
682
|
-
value: string;
|
|
683
|
-
src?: string;
|
|
684
|
-
contentType?: string;
|
|
685
|
-
fileName?: string;
|
|
686
|
-
/**
|
|
687
|
-
* Converts the FormParameter to a single param string.
|
|
688
|
-
*/
|
|
689
|
-
toString(): string;
|
|
690
|
-
/**
|
|
691
|
-
* Returns the value of the form parameter (if any).
|
|
692
|
-
*/
|
|
693
|
-
valueOf(): any | string;
|
|
694
|
-
/**
|
|
695
|
-
* Convert the form-param to JSON compatible plain object.
|
|
696
|
-
*/
|
|
697
|
-
toJSON(): any;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/**
|
|
701
|
-
* Contains a list of header elements
|
|
702
|
-
* @param parent - -
|
|
703
|
-
* @param headers - -
|
|
704
|
-
*/
|
|
705
|
-
export class HeaderList extends PropertyList<Header> {
|
|
706
|
-
constructor(parent: any, headers: Header[]);
|
|
707
|
-
/**
|
|
708
|
-
* Gets size of a list of headers excluding standard header prefix.
|
|
709
|
-
*/
|
|
710
|
-
contentSize(): number;
|
|
711
|
-
/**
|
|
712
|
-
* Checks if the given object is a HeaderList
|
|
713
|
-
* @param obj - -
|
|
714
|
-
*/
|
|
715
|
-
static isHeaderList(obj: any): boolean;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
export namespace Header {
|
|
719
|
-
/**
|
|
720
|
-
* @example
|
|
721
|
-
* Create a header
|
|
722
|
-
* var Header = require('postman-collection').Header,
|
|
723
|
-
* header = new Header({
|
|
724
|
-
* key: 'Content-Type',
|
|
725
|
-
* value: 'application/xml'
|
|
726
|
-
* });
|
|
727
|
-
*
|
|
728
|
-
* console.log(header.toString()) // prints the string representation of the Header.
|
|
729
|
-
* @property key - The Header name (e.g: 'Content-Type')
|
|
730
|
-
* @property value - The value of the header.
|
|
731
|
-
*/
|
|
732
|
-
type definition = {
|
|
733
|
-
key: string;
|
|
734
|
-
value: string;
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
/**
|
|
739
|
-
* Represents an HTTP header, for requests or for responses.
|
|
740
|
-
* @example
|
|
741
|
-
* Parse a string of headers into an array of Header objects
|
|
742
|
-
* var Header = require('postman-collection').Header,
|
|
743
|
-
* headerString = 'Content-Type: application/json\nUser-Agent: MyClientLibrary/2.0\n';
|
|
744
|
-
*
|
|
745
|
-
* var rawHeaders = Header.parse(headerString);
|
|
746
|
-
* console.log(rawHeaders); // [{ 'Content-Type': 'application/json', 'User-Agent': 'MyClientLibrary/2.0' }]
|
|
747
|
-
*
|
|
748
|
-
* var headers = rawHeaders.map(function (h) {
|
|
749
|
-
* return new Header(h);
|
|
750
|
-
* });
|
|
751
|
-
*
|
|
752
|
-
* function assert(condition, message) {
|
|
753
|
-
* if (!condition) {
|
|
754
|
-
* message = message || "Assertion failed";
|
|
755
|
-
* if (typeof Error !== "undefined") {
|
|
756
|
-
* throw new Error(message);
|
|
757
|
-
* }
|
|
758
|
-
* throw message; //fallback
|
|
759
|
-
* }
|
|
760
|
-
* else {
|
|
761
|
-
* console.log("Assertion passed");
|
|
762
|
-
* }
|
|
763
|
-
* }
|
|
764
|
-
*
|
|
765
|
-
* assert(headerString.trim() === Header.unparse(headers).trim());
|
|
766
|
-
* @param options - Pass the header definition as an object or the value of the header.
|
|
767
|
-
* If the value is passed as a string, it should either be in `name:value` format or the second "name" parameter
|
|
768
|
-
* should be used to pass the name as string
|
|
769
|
-
* @param [name] - optional override the header name or use when the first parameter is the header value as
|
|
770
|
-
* string.
|
|
771
|
-
*/
|
|
772
|
-
export class Header extends Property {
|
|
773
|
-
constructor(options: Header.definition | string, name?: string);
|
|
774
|
-
/**
|
|
775
|
-
* Converts the header to a single header string.
|
|
776
|
-
*/
|
|
777
|
-
toString(): string;
|
|
778
|
-
/**
|
|
779
|
-
* Return the value of this header.
|
|
780
|
-
*/
|
|
781
|
-
valueOf(): string;
|
|
782
|
-
/**
|
|
783
|
-
* Assigns the given properties to the Header
|
|
784
|
-
* @param options - -
|
|
785
|
-
*/
|
|
786
|
-
update(options: any): void;
|
|
787
|
-
/**
|
|
788
|
-
* The header Key
|
|
789
|
-
*/
|
|
790
|
-
key: string;
|
|
791
|
-
/**
|
|
792
|
-
* The header value
|
|
793
|
-
*/
|
|
794
|
-
value: string;
|
|
795
|
-
/**
|
|
796
|
-
* Parses a multi line header string into an array of Header.definition.
|
|
797
|
-
* @param headerString - -
|
|
798
|
-
*/
|
|
799
|
-
static parse(headerString: string): any[];
|
|
800
|
-
/**
|
|
801
|
-
* Parses a single Header.
|
|
802
|
-
* @param header - -
|
|
803
|
-
*/
|
|
804
|
-
static parseSingle(header: string): any;
|
|
805
|
-
/**
|
|
806
|
-
* Stringifies an Array or PropertyList of Headers into a single string.
|
|
807
|
-
* @param headers - -
|
|
808
|
-
* @param [separator = '\r\n'] - Specify a string for separating each header
|
|
809
|
-
*/
|
|
810
|
-
static unparse(headers: Header[] | PropertyList<Header>, separator?: string): string;
|
|
811
|
-
/**
|
|
812
|
-
* Unparses a single Header.
|
|
813
|
-
* @param header - -
|
|
814
|
-
*/
|
|
815
|
-
static unparseSingle(header: string): string;
|
|
816
|
-
/**
|
|
817
|
-
* Check whether an object is an instance of PostmanHeader.
|
|
818
|
-
* @param obj - -
|
|
819
|
-
*/
|
|
820
|
-
static isHeader(obj: any): boolean;
|
|
821
|
-
/**
|
|
822
|
-
* Create a new header instance
|
|
823
|
-
* @param [value] - Pass the header definition as an object or the value of the header.
|
|
824
|
-
* If the value is passed as a string, it should either be in `name:value` format or the second "name" parameter
|
|
825
|
-
* should be used to pass the name as string
|
|
826
|
-
* @param [name] - optional override the header name or use when the first parameter is the header value as
|
|
827
|
-
* string.
|
|
828
|
-
*/
|
|
829
|
-
static create(value?: Header.definition | string, name?: string): Header;
|
|
830
|
-
/**
|
|
831
|
-
* This (optional) flag denotes whether this property is disabled or not. Usually, this is helpful when a
|
|
832
|
-
* property is part of a PropertyList. For example, in a PropertyList of Headers, the ones
|
|
833
|
-
* that are disabled can be filtered out and not processed.
|
|
834
|
-
*/
|
|
835
|
-
disabled: boolean;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
export namespace ItemGroup {
|
|
839
|
-
/**
|
|
840
|
-
* The following defines the object (or JSON) structure that one can pass to the ItemGroup while creating a new
|
|
841
|
-
* ItemGroup instance. This is also the object structure returned when `.toJSON()` is called on an ItemGroup instance.
|
|
842
|
-
* @example
|
|
843
|
-
* {
|
|
844
|
-
* "name": "Echo Get Requests",
|
|
845
|
-
* "id": "echo-get-requests",
|
|
846
|
-
* "item": [{
|
|
847
|
-
* "request": "https://postman-echo.com/get"
|
|
848
|
-
* }, {
|
|
849
|
-
* "request": "https://postman-echo.com/headers"
|
|
850
|
-
* }],
|
|
851
|
-
* "auth": {
|
|
852
|
-
* "type": "basic",
|
|
853
|
-
* "basic": {
|
|
854
|
-
* "username": "jean",
|
|
855
|
-
* "password": "{{somethingsecret}}"
|
|
856
|
-
* }
|
|
857
|
-
* },
|
|
858
|
-
* "event": [{
|
|
859
|
-
* "listen": "prerequest",
|
|
860
|
-
* "script": {
|
|
861
|
-
* "type": "text/javascript",
|
|
862
|
-
* "exec": "console.log(new Date())"
|
|
863
|
-
* }
|
|
864
|
-
* }]
|
|
865
|
-
* }
|
|
866
|
-
*/
|
|
867
|
-
type definition = {
|
|
868
|
-
item?: (ItemGroup.definition | Item.definition)[];
|
|
869
|
-
auth?: RequestAuth.definition;
|
|
870
|
-
event?: Event.definition[];
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* An ItemGroup represents a composite list of Item or ItemGroup. In terms of Postman App, ItemGroup
|
|
876
|
-
* represents a "Folder". This allows one to group Items into subsets that can have their own meaning. An
|
|
877
|
-
* ItemGroup also allows one to define a subset of common properties to be applied to each Item within it. For
|
|
878
|
-
* example, a `test` event defined on an ItemGroup is executed while testing any Item that belongs to that group.
|
|
879
|
-
* Similarly, ItemGroups can have a common {@RequestAuth} defined so that every Request, when processed,
|
|
880
|
-
* requires to be authenticated using the `auth` defined in the group.
|
|
881
|
-
*
|
|
882
|
-
* Essentially, Collection too is a special type of ItemGroup ;-).
|
|
883
|
-
* @example
|
|
884
|
-
* Add a new ItemGroup to a collection instance
|
|
885
|
-
* var Collection = require('postman-collection').Collection,
|
|
886
|
-
* ItemGroup = require('postman-collection').ItemGroup,
|
|
887
|
-
* myCollection;
|
|
888
|
-
*
|
|
889
|
-
* myCollection = new Collection(); // create an empty collection
|
|
890
|
-
* myCollection.items.add(new ItemGroup({ // add a folder called "blank folder"
|
|
891
|
-
* "name": "This is a blank folder"
|
|
892
|
-
* }));
|
|
893
|
-
* @param [definition] - While creating a new instance of ItemGroup, one can provide the
|
|
894
|
-
* initial configuration of the item group with the requests it contains, the authentication applied to all
|
|
895
|
-
* requests, events that the requests responds to, etc.
|
|
896
|
-
*/
|
|
897
|
-
export class ItemGroup extends Property {
|
|
898
|
-
constructor(definition?: ItemGroup.definition);
|
|
899
|
-
/**
|
|
900
|
-
* This is a PropertyList that holds the list of Items or ItemGroups belonging to a
|
|
901
|
-
* Collection or to an ItemGroup. Operation on an individual item in this list can be
|
|
902
|
-
* performed using various functions available to a PropertyList.
|
|
903
|
-
* @example
|
|
904
|
-
* Fetch empty ItemGroups in a list loaded from a file
|
|
905
|
-
* var fs = require('fs'), // needed to read JSON file from disk
|
|
906
|
-
* Collection = require('postman-collection').Collection,
|
|
907
|
-
* myCollection,
|
|
908
|
-
* emptyGroups;
|
|
909
|
-
* // Load a collection to memory from a JSON file on disk (say, sample-collection.json)
|
|
910
|
-
* myCollection = new Collection(JSON.stringify(fs.readFileSync('sample-collection.json').toString()));
|
|
911
|
-
*
|
|
912
|
-
* // Filter items in Collection root that is an empty ItemGroup
|
|
913
|
-
* emptyGroups = myCollection.items.filter(function (item) {
|
|
914
|
-
* return item && item.items && (item.items.count() === 0);
|
|
915
|
-
* });
|
|
916
|
-
*
|
|
917
|
-
* // Log the emptyGroups array to check it's contents
|
|
918
|
-
* console.log(emptyGroups);
|
|
919
|
-
*/
|
|
920
|
-
items: PropertyList<Item | ItemGroup>;
|
|
921
|
-
/**
|
|
922
|
-
* One can define the default authentication method required for every item that belongs to this list.
|
|
923
|
-
* Individual Requests can override this in their own definitions. More on how to define an
|
|
924
|
-
* authentication method is outlined in the RequestAuth property.
|
|
925
|
-
* @example
|
|
926
|
-
* Define an entire ItemGroup (folder) or Collection to follow Basic Auth
|
|
927
|
-
* var fs = require('fs'),
|
|
928
|
-
* Collection = require('postman-collection').Collection,
|
|
929
|
-
* RequestAuth = require('postman-collection').RequestAuth,
|
|
930
|
-
* mycollection;
|
|
931
|
-
*
|
|
932
|
-
* // Create a collection having two requests
|
|
933
|
-
* myCollection = new Collection();
|
|
934
|
-
* myCollection.items.add([
|
|
935
|
-
* { name: 'GET Request', request: 'https://postman-echo.com/get?auth=basic' },
|
|
936
|
-
* { name: 'PUT Request', request: 'https://postman-echo.com/put?auth=basic' }
|
|
937
|
-
* ]);
|
|
938
|
-
*
|
|
939
|
-
* // Add basic auth to the Collection, to be applied on all requests.
|
|
940
|
-
* myCollection.auth = new RequestAuth({
|
|
941
|
-
* type: 'basic',
|
|
942
|
-
* username: 'postman',
|
|
943
|
-
* password: 'password'
|
|
944
|
-
* });
|
|
945
|
-
*/
|
|
946
|
-
auth: RequestAuth;
|
|
947
|
-
/**
|
|
948
|
-
* Set of configurations used to alter the usual behavior of sending the request.
|
|
949
|
-
* @property disableBodyPruning - Disable body pruning for request methods like GET, HEAD etc.
|
|
950
|
-
*/
|
|
951
|
-
protocolProfileBehavior: {
|
|
952
|
-
disableBodyPruning: boolean;
|
|
953
|
-
};
|
|
954
|
-
/**
|
|
955
|
-
* Finds the first item with the given name or id in the current ItemGroup.
|
|
956
|
-
* @param idOrName - -
|
|
957
|
-
*/
|
|
958
|
-
oneDeep(idOrName: string): void;
|
|
959
|
-
/**
|
|
960
|
-
* Sets authentication method for all the items within this group
|
|
961
|
-
*/
|
|
962
|
-
authorizeRequestsUsing: any;
|
|
963
|
-
/**
|
|
964
|
-
* Check whether an object is an instance of ItemGroup.
|
|
965
|
-
* @param obj - -
|
|
966
|
-
*/
|
|
967
|
-
static isItemGroup(obj: any): boolean;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
export namespace Item {
|
|
971
|
-
/**
|
|
972
|
-
* The following defines the object (or JSON) structure that one can pass to the Item while creating a new Item
|
|
973
|
-
* instance. This is also the object structure returned when `.toJSON()` is called on an Item instance.
|
|
974
|
-
* @example
|
|
975
|
-
* {
|
|
976
|
-
* "name": "Get Headers from Echo",
|
|
977
|
-
* "id": "my-request-1",
|
|
978
|
-
* "description": "Makes a GET call to echo service and returns the client headers that were sent",
|
|
979
|
-
*
|
|
980
|
-
* "request": {
|
|
981
|
-
* "url": "https://postman-echo.com/headers",
|
|
982
|
-
* "method": "GET"
|
|
983
|
-
* }
|
|
984
|
-
* }
|
|
985
|
-
* @property [request] - A request represents an HTTP request. If a string, the string is assumed to
|
|
986
|
-
* be the request URL and the method is assumed to be 'GET'.
|
|
987
|
-
* @property [responses] - Sample responses for this request can be stored along with the
|
|
988
|
-
* item definition.
|
|
989
|
-
* @property [events] - Postman allows you to configure scripts to run when specific events
|
|
990
|
-
* occur. These scripts are stored here, and can be referenced in the collection by their id.
|
|
991
|
-
*/
|
|
992
|
-
type definition = {
|
|
993
|
-
request?: Request.definition;
|
|
994
|
-
responses?: Response.definition[];
|
|
995
|
-
events?: Event.definition[];
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
/**
|
|
1000
|
-
* A Postman Collection Item that holds your request definition, responses and other stuff. An Item essentially is
|
|
1001
|
-
* a HTTP request definition along with the sample responses and test scripts clubbed together. One or more of these
|
|
1002
|
-
* items can be grouped together and placed in an ItemGroup and as such forms a Collection of
|
|
1003
|
-
* requests.
|
|
1004
|
-
* @example
|
|
1005
|
-
* Add a new Item to a folder in a collection instance
|
|
1006
|
-
* var Collection = require('postman-collection').Collection,
|
|
1007
|
-
* Item = require('postman-collection').Item,
|
|
1008
|
-
* myCollection;
|
|
1009
|
-
*
|
|
1010
|
-
* myCollection = new Collection({
|
|
1011
|
-
* "item": [{
|
|
1012
|
-
* "id": "my-folder-1",
|
|
1013
|
-
* "name": "The solo folder in this collection",
|
|
1014
|
-
* "item": [] // blank array indicates this is a folder
|
|
1015
|
-
* }]
|
|
1016
|
-
* }); // create a collection with an empty folder
|
|
1017
|
-
* // add a request to "my-folder-1" that sends a GET request
|
|
1018
|
-
* myCollection.items.one("my-folder-1").items.add(new Item({
|
|
1019
|
-
* "name": "Send a GET request",
|
|
1020
|
-
* "id": "my-get-request",
|
|
1021
|
-
* "request": {
|
|
1022
|
-
* "url": "https://postman-echo.com/get",
|
|
1023
|
-
* "method": "GET"
|
|
1024
|
-
* }
|
|
1025
|
-
* }));
|
|
1026
|
-
* @param [definition] - While creating a new instance of Item, one can provide the initial
|
|
1027
|
-
* configuration of the item with the the request it sends, the expected sample responses, tests, etc
|
|
1028
|
-
*/
|
|
1029
|
-
export class Item extends Property {
|
|
1030
|
-
constructor(definition?: Item.definition);
|
|
1031
|
-
/**
|
|
1032
|
-
* The instance of the Request object inside an Item defines the HTTP request that is supposed to be
|
|
1033
|
-
* sent. It further contains the request method, url, request body, etc.
|
|
1034
|
-
*/
|
|
1035
|
-
request: Request;
|
|
1036
|
-
/**
|
|
1037
|
-
* An Item also contains a list of sample responses that is expected when the request defined in the item is
|
|
1038
|
-
* executed. The sample responses are useful in elaborating API usage and is also useful for other
|
|
1039
|
-
* integrations that use the sample responses to do something - say a mock service.
|
|
1040
|
-
*/
|
|
1041
|
-
responses: PropertyList<Response>;
|
|
1042
|
-
/**
|
|
1043
|
-
* Events are a set of of Scripts that are executed when certain activities are triggered on an
|
|
1044
|
-
* Item. For example, on defining an event that listens to the "test" event, would cause the associated
|
|
1045
|
-
* script of the event to be executed when the test runs.
|
|
1046
|
-
* @example
|
|
1047
|
-
* Add a script to be executed on "prerequest" event
|
|
1048
|
-
* var Collection = require('postman-collection').Collection,
|
|
1049
|
-
* Item = require('postman-collection').Item,
|
|
1050
|
-
* myCollection;
|
|
1051
|
-
*
|
|
1052
|
-
* myCollection = new Collection({
|
|
1053
|
-
* "item": [{
|
|
1054
|
-
* "name": "Send a GET request",
|
|
1055
|
-
* "id": "my-get-request",
|
|
1056
|
-
* "request": {
|
|
1057
|
-
* "url": "https://postman-echo.com/get",
|
|
1058
|
-
* "method": "GET"
|
|
1059
|
-
* }
|
|
1060
|
-
* }]
|
|
1061
|
-
* }); // create a collection with one request
|
|
1062
|
-
*
|
|
1063
|
-
* // add a pre-request script to the event list
|
|
1064
|
-
* myCollection.items.one('my-get-request').events.add({
|
|
1065
|
-
* "listen": "prerequest",
|
|
1066
|
-
* "script": {
|
|
1067
|
-
* "type": "text/javascript",
|
|
1068
|
-
* "exec": "console.log(new Date())"
|
|
1069
|
-
* }
|
|
1070
|
-
* });
|
|
1071
|
-
*/
|
|
1072
|
-
events: EventList;
|
|
1073
|
-
/**
|
|
1074
|
-
* Set of configurations used to alter the usual behavior of sending the request.
|
|
1075
|
-
*/
|
|
1076
|
-
protocolProfileBehavior: any;
|
|
1077
|
-
/**
|
|
1078
|
-
* Fetches applicable AuthType from the current item.
|
|
1079
|
-
*/
|
|
1080
|
-
getAuth(): RequestAuth;
|
|
1081
|
-
/**
|
|
1082
|
-
* Returns Events corresponding to a particular event name. If no name is given, returns all events. This
|
|
1083
|
-
* is useful when you want to trigger all associated scripts for an event.
|
|
1084
|
-
* @example
|
|
1085
|
-
* Get all events for an item and evaluate their scripts
|
|
1086
|
-
* var fs = require('fs'), // needed to read JSON file from disk
|
|
1087
|
-
* Collection = require('postman-collection').Collection,
|
|
1088
|
-
* myCollection;
|
|
1089
|
-
*
|
|
1090
|
-
* // Load a collection to memory from a JSON file on disk (say, sample-collection.json)
|
|
1091
|
-
* myCollection = new Collection(JSON.stringify(fs.readFileSync('sample-collection.json').toString()));
|
|
1092
|
-
*
|
|
1093
|
-
* // assuming the collection has a request called "my-request-1" in root, we get it's test events
|
|
1094
|
-
* myCollection.items.one("my-request-1").getEvents("test").forEach(function (event) {
|
|
1095
|
-
* event.script && eval(event.script.toSource());
|
|
1096
|
-
* });
|
|
1097
|
-
* @param name - one of the available event types such as `test`, `prerequest`, `postrequest`, etc.
|
|
1098
|
-
*/
|
|
1099
|
-
getEvents(name: string): Event[];
|
|
1100
|
-
/**
|
|
1101
|
-
* Sets authentication method for the request within this item
|
|
1102
|
-
* @param type - -
|
|
1103
|
-
* @param [options] - -
|
|
1104
|
-
*/
|
|
1105
|
-
authorizeRequestUsing(type: string | RequestAuth.definition, options?: VariableList): void;
|
|
1106
|
-
/**
|
|
1107
|
-
* Returns the path of the item
|
|
1108
|
-
*/
|
|
1109
|
-
getPath(): string[];
|
|
1110
|
-
/**
|
|
1111
|
-
* Check whether an object is an instance of PostmanItem.
|
|
1112
|
-
* @param obj - -
|
|
1113
|
-
*/
|
|
1114
|
-
static isItem(obj: any): boolean;
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
export namespace MutationTracker {
|
|
1118
|
-
/**
|
|
1119
|
-
* A JSON representation of a mutation on an object. Here objects mean instances of postman-collection classes.
|
|
1120
|
-
* This captures the instruction and the parameters of the instruction so that it can be replayed on a different object.
|
|
1121
|
-
* Mutations can be any change on an object. For example setting a key or unsetting a key.
|
|
1122
|
-
*
|
|
1123
|
-
* For example, the mutation to set `name` on an object to 'Bruce Wayne' would look like ['name', 'Bruce Wayne']. Where
|
|
1124
|
-
* the first item is the key path and second item is the value. To add a property `punchLine` to the object it would be
|
|
1125
|
-
* the same as updating the property i.e. ['punchLine', 'I\'m Batman']. To remove a property `age` the mutation would
|
|
1126
|
-
* look like ['age'].
|
|
1127
|
-
*
|
|
1128
|
-
* This format of representing changes is derived from
|
|
1129
|
-
* http://json-delta.readthedocs.io/en/latest/philosophy.html.
|
|
1130
|
-
*
|
|
1131
|
-
* The `set` and `unset` are primitive instructions and can be derived from the mutation without explicitly stating the
|
|
1132
|
-
* instruction. For more complex mutation the instruction would have to be explicitly stated.
|
|
1133
|
-
*/
|
|
1134
|
-
type mutation = any[];
|
|
1135
|
-
/**
|
|
1136
|
-
* A JSON representation of the MutationTracker.
|
|
1137
|
-
* @property stream - contains the stream mutations tracked
|
|
1138
|
-
* @property compacted - contains a compacted version of the mutations
|
|
1139
|
-
* @property [autoCompact = false] - when set to true, all new mutations would be compacted immediately
|
|
1140
|
-
*/
|
|
1141
|
-
type definition = {
|
|
1142
|
-
stream: any[];
|
|
1143
|
-
compacted: any;
|
|
1144
|
-
autoCompact?: boolean;
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
/**
|
|
1149
|
-
* A MutationTracker allows to record mutations on any of object and store them. This stored mutations can be
|
|
1150
|
-
* transported for reporting or to replay on similar objects.
|
|
1151
|
-
* @param definition - serialized mutation tracker
|
|
1152
|
-
*/
|
|
1153
|
-
export class MutationTracker extends PropertyBase {
|
|
1154
|
-
constructor(definition: MutationTracker.definition);
|
|
1155
|
-
/**
|
|
1156
|
-
* Track a mutation.
|
|
1157
|
-
* @param instruction - the type of mutation
|
|
1158
|
-
* @param payload - mutation parameters
|
|
1159
|
-
*/
|
|
1160
|
-
track(instruction: string, ...payload: any[]): void;
|
|
1161
|
-
/**
|
|
1162
|
-
* Compacts the recorded mutations removing duplicate mutations that apply on the same key path.
|
|
1163
|
-
*/
|
|
1164
|
-
compact(): void;
|
|
1165
|
-
/**
|
|
1166
|
-
* Returns the number of mutations tracked so far.
|
|
1167
|
-
*/
|
|
1168
|
-
count(): number;
|
|
1169
|
-
/**
|
|
1170
|
-
* Applies all the recorded mutations on a target object.
|
|
1171
|
-
* @param target - Target to apply mutations. Must implement `applyMutation`.
|
|
1172
|
-
*/
|
|
1173
|
-
applyOn(target: any): void;
|
|
1174
|
-
/**
|
|
1175
|
-
* Check whether an object is an instance of MutationTracker.
|
|
1176
|
-
* @param obj - -
|
|
1177
|
-
*/
|
|
1178
|
-
static isMutationTracker(obj: any): boolean;
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
export namespace PropertyBase {
|
|
1182
|
-
type definition = {
|
|
1183
|
-
description?: string | Description;
|
|
1184
|
-
};
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* Base of all properties in Postman Collection. It defines the root for all standalone properties for postman
|
|
1189
|
-
* collection.
|
|
1190
|
-
* @param definition - -
|
|
1191
|
-
*/
|
|
1192
|
-
export class PropertyBase {
|
|
1193
|
-
constructor(definition: PropertyBase.definition);
|
|
1194
|
-
/**
|
|
1195
|
-
* Invokes the given iterator for every parent in the parent chain of the given element.
|
|
1196
|
-
* @param options - A set of options for the parent chain traversal.
|
|
1197
|
-
* @param [options.withRoot = false] - Set to true to include the collection object as well.
|
|
1198
|
-
* @param iterator - The function to call for every parent in the ancestry chain.
|
|
1199
|
-
*/
|
|
1200
|
-
forEachParent(
|
|
1201
|
-
options: {
|
|
1202
|
-
withRoot?: boolean;
|
|
1203
|
-
},
|
|
1204
|
-
iterator: (...params: any[]) => any
|
|
1205
|
-
): void;
|
|
1206
|
-
/**
|
|
1207
|
-
* Tries to find the given property locally, and then proceeds to lookup in each parent,
|
|
1208
|
-
* going up the chain as necessary. Lookup will continue until `customizer` returns a truthy value. If used
|
|
1209
|
-
* without a customizer, the lookup will stop at the first parent that contains the property.
|
|
1210
|
-
* @param property - -
|
|
1211
|
-
* @param [customizer] - -
|
|
1212
|
-
*/
|
|
1213
|
-
findInParents(property: string, customizer?: (...params: any[]) => any): any | undefined;
|
|
1214
|
-
/**
|
|
1215
|
-
* Returns the JSON representation of a property, which conforms to the way it is defined in a collection.
|
|
1216
|
-
* You can use this method to get the instantaneous representation of any property, including a Collection.
|
|
1217
|
-
*/
|
|
1218
|
-
toJSON(): void;
|
|
1219
|
-
/**
|
|
1220
|
-
* Returns the meta keys associated with the property
|
|
1221
|
-
*/
|
|
1222
|
-
meta(): any;
|
|
1223
|
-
/**
|
|
1224
|
-
* Returns the parent of item
|
|
1225
|
-
*/
|
|
1226
|
-
parent(): any | undefined;
|
|
1227
|
-
/**
|
|
1228
|
-
* Filter function to check whether a key starts with underscore or not. These usually are the meta properties. It
|
|
1229
|
-
* returns `true` if the criteria is matched.
|
|
1230
|
-
* @param value - -
|
|
1231
|
-
* @param key - -
|
|
1232
|
-
*/
|
|
1233
|
-
static propertyIsMeta(value: any, key: string): boolean;
|
|
1234
|
-
/**
|
|
1235
|
-
* Map function that removes the underscore prefix from an object key.
|
|
1236
|
-
* @param value - -
|
|
1237
|
-
* @param key - -
|
|
1238
|
-
*/
|
|
1239
|
-
static propertyUnprefixMeta(value: any, key: string): string;
|
|
1240
|
-
/**
|
|
1241
|
-
* Static function which allows calling toJSON() on any object.
|
|
1242
|
-
* @param obj - -
|
|
1243
|
-
*/
|
|
1244
|
-
static toJSON(obj: any): any;
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
/**
|
|
1248
|
-
* @param type - -
|
|
1249
|
-
* @param parent - -
|
|
1250
|
-
* @param populate - -
|
|
1251
|
-
*/
|
|
1252
|
-
export class PropertyList<TElement> {
|
|
1253
|
-
constructor(type: any, parent: any, populate: TElement[]);
|
|
1254
|
-
/**
|
|
1255
|
-
* Insert an element at the end of this list. When a reference member specified via second parameter is found, the
|
|
1256
|
-
* member is inserted at an index before the reference member.
|
|
1257
|
-
* @param item - -
|
|
1258
|
-
* @param [before] - -
|
|
1259
|
-
*/
|
|
1260
|
-
insert(item: TElement, before?: TElement | string): void;
|
|
1261
|
-
/**
|
|
1262
|
-
* Insert an element at the end of this list. When a reference member specified via second parameter is found, the
|
|
1263
|
-
* member is inserted at an index after the reference member.
|
|
1264
|
-
* @param item - -
|
|
1265
|
-
* @param [after] - -
|
|
1266
|
-
*/
|
|
1267
|
-
insertAfter(item: TElement, after?: TElement | string): void;
|
|
1268
|
-
/**
|
|
1269
|
-
* Adds or moves an item to the end of this list.
|
|
1270
|
-
* @param item - -
|
|
1271
|
-
*/
|
|
1272
|
-
append(item: TElement): void;
|
|
1273
|
-
/**
|
|
1274
|
-
* Adds or moves an item to the beginning of this list.
|
|
1275
|
-
* @param item - -
|
|
1276
|
-
*/
|
|
1277
|
-
prepend(item: TElement): void;
|
|
1278
|
-
/**
|
|
1279
|
-
* Add an item or item definition to this list.
|
|
1280
|
-
* @param item - -
|
|
1281
|
-
*/
|
|
1282
|
-
add(item: TElement): void;
|
|
1283
|
-
/**
|
|
1284
|
-
* Add an item or update an existing item
|
|
1285
|
-
* @param item - -
|
|
1286
|
-
*/
|
|
1287
|
-
upsert(item: TElement): boolean;
|
|
1288
|
-
/**
|
|
1289
|
-
* Removes all elements from the PropertyList for which the predicate returns truthy.
|
|
1290
|
-
* @param predicate - -
|
|
1291
|
-
* @param context - Optional context to bind the predicate to.
|
|
1292
|
-
*/
|
|
1293
|
-
remove(predicate: ((item: TElement) => boolean) | string | TElement, context?: any): void;
|
|
1294
|
-
/**
|
|
1295
|
-
* Removes all items in the list
|
|
1296
|
-
*/
|
|
1297
|
-
clear(): void;
|
|
1298
|
-
/**
|
|
1299
|
-
* Load one or more items
|
|
1300
|
-
* @param items - -
|
|
1301
|
-
*/
|
|
1302
|
-
populate(items: TElement[]): void;
|
|
1303
|
-
/**
|
|
1304
|
-
* Clears the list and adds new items.
|
|
1305
|
-
* @param items - -
|
|
1306
|
-
*/
|
|
1307
|
-
repopulate(items: TElement[]): void;
|
|
1308
|
-
/**
|
|
1309
|
-
* Add or update values from a source list.
|
|
1310
|
-
* @param source - -
|
|
1311
|
-
* @param [prune = false] - Setting this to `true` will cause the extra items from the list to be deleted
|
|
1312
|
-
*/
|
|
1313
|
-
assimilate(source: PropertyList<TElement> | TElement[], prune?: boolean): void;
|
|
1314
|
-
/**
|
|
1315
|
-
* Returns a map of all items.
|
|
1316
|
-
*/
|
|
1317
|
-
all(): any;
|
|
1318
|
-
/**
|
|
1319
|
-
* Get Item in this list by `ID` reference. If multiple values are allowed, the last value is returned.
|
|
1320
|
-
* @param id - -
|
|
1321
|
-
*/
|
|
1322
|
-
one(id: string): TElement | undefined;
|
|
1323
|
-
/**
|
|
1324
|
-
* Get the value of an item in this list. This is similar to PropertyList.one barring the fact that it
|
|
1325
|
-
* returns the value of the underlying type of the list content instead of the item itself.
|
|
1326
|
-
* @param key - -
|
|
1327
|
-
*/
|
|
1328
|
-
get(key: string): any;
|
|
1329
|
-
/**
|
|
1330
|
-
* Iterate on each item of this list.
|
|
1331
|
-
* @param iterator - -
|
|
1332
|
-
* @param context - -
|
|
1333
|
-
*/
|
|
1334
|
-
each(iterator: (value: TElement, index: number, array: TElement[]) => void): void;
|
|
1335
|
-
/**
|
|
1336
|
-
* @param rule - -
|
|
1337
|
-
* @param context - -
|
|
1338
|
-
*/
|
|
1339
|
-
filter(rule: (item: TElement) => boolean, context?: any): PropertyList<TElement>;
|
|
1340
|
-
/**
|
|
1341
|
-
* Find an item within the item group
|
|
1342
|
-
* @param rule - -
|
|
1343
|
-
* @param [context] - -
|
|
1344
|
-
*/
|
|
1345
|
-
find(rule: (item: TElement) => boolean, context?: any): Item | ItemGroup | undefined;
|
|
1346
|
-
/**
|
|
1347
|
-
* Iterates over the property list.
|
|
1348
|
-
* @param iterator - Function to call on each item.
|
|
1349
|
-
* @param context - Optional context, defaults to the PropertyList itself.
|
|
1350
|
-
*/
|
|
1351
|
-
map(iterator: (item: TElement) => TElement, context?: any): PropertyList<TElement>;
|
|
1352
|
-
/**
|
|
1353
|
-
* Iterates over the property list and accumulates the result.
|
|
1354
|
-
* @param iterator - Function to call on each item.
|
|
1355
|
-
* @param accumulator - Accumulator initial value
|
|
1356
|
-
* @param context - Optional context, defaults to the PropertyList itself.
|
|
1357
|
-
*/
|
|
1358
|
-
reduce(iterator: (...params: any[]) => any, accumulator: any, context?: any): void;
|
|
1359
|
-
/**
|
|
1360
|
-
* Returns the length of the PropertyList
|
|
1361
|
-
*/
|
|
1362
|
-
count(): number;
|
|
1363
|
-
/**
|
|
1364
|
-
* Get a member of this list by it's index
|
|
1365
|
-
* @param index - -
|
|
1366
|
-
*/
|
|
1367
|
-
idx(index: number): TElement | undefined;
|
|
1368
|
-
/**
|
|
1369
|
-
* Find the index of an item in this list
|
|
1370
|
-
* @param item - -
|
|
1371
|
-
*/
|
|
1372
|
-
indexOf(item: string | any): number;
|
|
1373
|
-
/**
|
|
1374
|
-
* Check whether an item exists in this list
|
|
1375
|
-
* @param item - -
|
|
1376
|
-
* @param [value] - -
|
|
1377
|
-
*/
|
|
1378
|
-
has(item: string | TElement, value?: any): boolean;
|
|
1379
|
-
/**
|
|
1380
|
-
* Iterates over all parents of the property list
|
|
1381
|
-
* @param iterator - -
|
|
1382
|
-
* @param [context] - -
|
|
1383
|
-
*/
|
|
1384
|
-
eachParent(iterator: (...params: any[]) => any, context?: any): void;
|
|
1385
|
-
/**
|
|
1386
|
-
* Converts a list of Properties into an object where key is `_postman_propertyIndexKey` and value is determined
|
|
1387
|
-
* by the `valueOf` function
|
|
1388
|
-
* @param [excludeDisabled = false] - When set to true, disabled properties are excluded from the resultant
|
|
1389
|
-
* object.
|
|
1390
|
-
* @param [caseSensitive] - When set to true, properties are treated strictly as per their original
|
|
1391
|
-
* case. The default value for this property also depends on the case insensitivity definition of the current
|
|
1392
|
-
* property.
|
|
1393
|
-
* @param [multiValue = false] - When set to true, only the first value of a multi valued property is
|
|
1394
|
-
* returned.
|
|
1395
|
-
* @param [sanitizeKeys = false] - When set to true, properties with falsy keys are removed.
|
|
1396
|
-
*/
|
|
1397
|
-
toObject(excludeDisabled?: boolean, caseSensitive?: boolean, multiValue?: boolean, sanitizeKeys?: boolean): any;
|
|
1398
|
-
/**
|
|
1399
|
-
* Adds ability to convert a list to a string provided it's underlying format has unparse function defined.
|
|
1400
|
-
*/
|
|
1401
|
-
toString(): string;
|
|
1402
|
-
/**
|
|
1403
|
-
* Checks whether an object is a PropertyList
|
|
1404
|
-
* @param obj - -
|
|
1405
|
-
*/
|
|
1406
|
-
static isPropertyList(obj: any): boolean;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
export namespace Property {
|
|
1410
|
-
/**
|
|
1411
|
-
* @property [id] - A unique string that identifies the property.
|
|
1412
|
-
* @property [name] - A distinctive and human-readable name of the property.
|
|
1413
|
-
* @property [disabled] - Denotes whether the property is disabled or not.
|
|
1414
|
-
* @property [info] - The meta information regarding the Property is provided as the `info` object.
|
|
1415
|
-
* @property [info.id] - If set, this is used instead of the definition root's id.
|
|
1416
|
-
* @property [info.name] - If set, this is used instead of the definition root's name.
|
|
1417
|
-
*/
|
|
1418
|
-
type definition = {
|
|
1419
|
-
id?: string;
|
|
1420
|
-
name?: string;
|
|
1421
|
-
disabled?: boolean;
|
|
1422
|
-
info?: {
|
|
1423
|
-
id?: string;
|
|
1424
|
-
name?: string;
|
|
1425
|
-
};
|
|
1426
|
-
};
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
/**
|
|
1430
|
-
* The Property class forms the base of all postman collection SDK elements. This is to be used only for SDK
|
|
1431
|
-
* development or to extend the SDK with additional functionalities. All SDK classes (constructors) that are
|
|
1432
|
-
* supposed to be identifiable (i.e. ones that can have a `name` and `id`) are derived from this class.
|
|
1433
|
-
*
|
|
1434
|
-
* For more information on what is the structure of the `definition` the function parameter, have a look at
|
|
1435
|
-
* Property.definition.
|
|
1436
|
-
*
|
|
1437
|
-
* > This is intended to be a private class except for those who want to extend the SDK itself and add more
|
|
1438
|
-
* > functionalities.
|
|
1439
|
-
* @param [definition] - Every constructor inherited from `Property` is required to call the
|
|
1440
|
-
* super constructor function. This implies that construction parameters of every inherited member is propagated
|
|
1441
|
-
* to be sent up to this point.
|
|
1442
|
-
*/
|
|
1443
|
-
export class Property extends PropertyBase {
|
|
1444
|
-
constructor(definition?: Property.definition);
|
|
1445
|
-
/**
|
|
1446
|
-
* The `id` of the property is a unique string that identifies this property and can be used to refer to
|
|
1447
|
-
* this property from relevant other places. It is a good practice to define the id or let the system
|
|
1448
|
-
* auto generate a UUID if one is not defined for properties that require an `id`.
|
|
1449
|
-
*/
|
|
1450
|
-
id: string;
|
|
1451
|
-
/**
|
|
1452
|
-
* A property can have a distinctive and human-readable name. This is to be used to display the name of the
|
|
1453
|
-
* property within Postman, Newman or other runtimes that consume collection. In certain cases, the absence
|
|
1454
|
-
* of name might cause the runtime to use the `id` as a fallback.
|
|
1455
|
-
*/
|
|
1456
|
-
name: string;
|
|
1457
|
-
/**
|
|
1458
|
-
* This (optional) flag denotes whether this property is disabled or not. Usually, this is helpful when a
|
|
1459
|
-
* property is part of a PropertyList. For example, in a PropertyList of Headers, the ones
|
|
1460
|
-
* that are disabled can be filtered out and not processed.
|
|
1461
|
-
*/
|
|
1462
|
-
disabled: boolean;
|
|
1463
|
-
/**
|
|
1464
|
-
* This function allows to describe the property for the purpose of detailed identification or documentation
|
|
1465
|
-
* generation. This function sets or updates the `description` child-property of this property.
|
|
1466
|
-
* @example
|
|
1467
|
-
* Add a description to an instance of Collection
|
|
1468
|
-
* var Collection = require('postman-collection').Collection,
|
|
1469
|
-
* mycollection;
|
|
1470
|
-
*
|
|
1471
|
-
* // create a blank collection
|
|
1472
|
-
* myCollection = new Collection();
|
|
1473
|
-
* myCollection.describe('Hey! This is a cool collection.');
|
|
1474
|
-
*
|
|
1475
|
-
* console.log(myCollection.description.toString()); // read the description
|
|
1476
|
-
* @param content - The content of the description can be provided here as a string. Note that it is expected
|
|
1477
|
-
* that if the content is formatted in any other way than simple text, it should be specified in the subsequent
|
|
1478
|
-
* `type` parameter.
|
|
1479
|
-
* @param [type = "text/plain"] - The type of the content.
|
|
1480
|
-
*/
|
|
1481
|
-
describe(content: string, type?: string): void;
|
|
1482
|
-
/**
|
|
1483
|
-
* Returns an object representation of the Property with its variable references substituted.
|
|
1484
|
-
*
|
|
1485
|
-
* @example <caption>Resolve an object using variable definitions from itself and its parents</caption>
|
|
1486
|
-
* property.toObjectResolved();
|
|
1487
|
-
*
|
|
1488
|
-
* @example <caption>Resolve an object using variable definitions on a different object</caption>
|
|
1489
|
-
* property.toObjectResolved(item);
|
|
1490
|
-
*
|
|
1491
|
-
* @example <caption>Resolve an object using variables definitions as a flat list of variables</caption>
|
|
1492
|
-
* property.toObjectResolved(null, [variablesDefinition1, variablesDefinition1], {ignoreOwnVariables: true});
|
|
1493
|
-
*
|
|
1494
|
-
* @private
|
|
1495
|
-
* @draft
|
|
1496
|
-
* @param {?Item|ItemGroup=} [scope] - One can specifically provide an item or group with `.variables`. In
|
|
1497
|
-
* the event one is not provided, the variables are taken from this object or one from the parent tree.
|
|
1498
|
-
* @param {Array<Object>} overrides - additional objects to lookup for variable values
|
|
1499
|
-
* @param {Object} [options] -
|
|
1500
|
-
* @param {Boolean} [options.ignoreOwnVariables] - if set to true, `.variables` on self(or scope)
|
|
1501
|
-
* will not be used for variable resolution. Only variables in `overrides` will be used for resolution.
|
|
1502
|
-
* @returns {Object|undefined}
|
|
1503
|
-
* @throws {Error} If `variables` cannot be resolved up the parent chain.
|
|
1504
|
-
*/
|
|
1505
|
-
toObjectResolved(
|
|
1506
|
-
scope: Item | ItemGroup | null,
|
|
1507
|
-
overrides: object[],
|
|
1508
|
-
options: { ignoreOwnVariables: boolean }
|
|
1509
|
-
): object | undefined;
|
|
1510
|
-
/**
|
|
1511
|
-
* Returns all the substitutions (variables) that are needed (or referenced) in this property (recursively).
|
|
1512
|
-
* @example
|
|
1513
|
-
* // returns ['host', 'path1']
|
|
1514
|
-
* prop.findSubstitutions({request: 'https://{{host}}/{{path1}}-action/'});
|
|
1515
|
-
*/
|
|
1516
|
-
findSubstitutions(): string[];
|
|
1517
|
-
/**
|
|
1518
|
-
* This function accepts a string followed by a number of variable sources as arguments. One or more variable
|
|
1519
|
-
* sources can be provided and it will use the one that has the value in left-to-right order.
|
|
1520
|
-
* @param str - -
|
|
1521
|
-
* @param variables - -
|
|
1522
|
-
*/
|
|
1523
|
-
static replaceSubstitutions(str: string, variables: VariableList | any | (VariableList | object)[]): string;
|
|
1524
|
-
/**
|
|
1525
|
-
* This function accepts an object followed by a number of variable sources as arguments. One or more variable
|
|
1526
|
-
* sources can be provided and it will use the one that has the value in left-to-right order.
|
|
1527
|
-
* @param obj - -
|
|
1528
|
-
* @param variables - -
|
|
1529
|
-
*/
|
|
1530
|
-
static replaceSubstitutionsIn(obj: any, variables: (VariableList | object)[]): any;
|
|
1531
|
-
/**
|
|
1532
|
-
* This function recursively traverses a variable and detects all instances of variable replacements
|
|
1533
|
-
* within the string of the object
|
|
1534
|
-
* @example
|
|
1535
|
-
* // returns ['host', 'path1']
|
|
1536
|
-
* Property.findSubstitutions({request: 'https://{{host}}/{{path1}}-action/'});
|
|
1537
|
-
* @param obj - Any JS variable within which we are trying to discover {{variables}}
|
|
1538
|
-
*/
|
|
1539
|
-
static findSubstitutions(obj: any): string[];
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
/**
|
|
1543
|
-
* @example
|
|
1544
|
-
* Create a new ProxyConfigList
|
|
1545
|
-
* var ProxyConfigList = require('postman-collection').ProxyConfigList,
|
|
1546
|
-
* myProxyConfig = new ProxyConfigList({}, [
|
|
1547
|
-
* {match: 'https://example.com/*', host: 'proxy.com', port: 8080, tunnel: true},
|
|
1548
|
-
* {match: 'http+https://example2.com/*', host: 'proxy2.com'},
|
|
1549
|
-
* ]);
|
|
1550
|
-
* @param parent - -
|
|
1551
|
-
* @param populate - The list of proxy objects
|
|
1552
|
-
*/
|
|
1553
|
-
export class ProxyConfigList extends PropertyList<ProxyConfig> {
|
|
1554
|
-
constructor(parent: any, populate: any[]);
|
|
1555
|
-
/**
|
|
1556
|
-
* Matches and gets the proxy config for the particular url.
|
|
1557
|
-
* @param [url] - The url for which the proxy config needs to be fetched
|
|
1558
|
-
* @returns The matched proxyConfig object
|
|
1559
|
-
*/
|
|
1560
|
-
resolve(url?: URL): ProxyConfig.definition;
|
|
1561
|
-
/**
|
|
1562
|
-
* Checks whether an object is a ProxyConfigList
|
|
1563
|
-
* @param obj - -
|
|
1564
|
-
*/
|
|
1565
|
-
static isProxyConfigList(obj: any): boolean;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
export namespace ProxyConfig {
|
|
1569
|
-
/**
|
|
1570
|
-
* The following is the object structure accepted as constructor parameter while calling `new ProxyConfig(...)`. It is
|
|
1571
|
-
* also the structure exported when Property.toJSON or Property.toObjectResolved is called on a
|
|
1572
|
-
* Proxy instance.
|
|
1573
|
-
* @example
|
|
1574
|
-
* JSON definition of an example proxy object
|
|
1575
|
-
* {
|
|
1576
|
-
* "match": "http+https://example.com/*",
|
|
1577
|
-
* "host": "proxy.com",
|
|
1578
|
-
* "port": "8080",
|
|
1579
|
-
* "tunnel": true,
|
|
1580
|
-
* "disabled": false,
|
|
1581
|
-
* "authenticate": true,
|
|
1582
|
-
* "username": "proxy_username",
|
|
1583
|
-
* "password": "proxy_password"
|
|
1584
|
-
* }
|
|
1585
|
-
* @property [match = 'http+https://*\/*'] - The match for which the proxy needs to be configured.
|
|
1586
|
-
* @property [host = ''] - The proxy server url.
|
|
1587
|
-
* @property [port = 8080] - The proxy server port number.
|
|
1588
|
-
* @property [tunnel = false] - The tunneling option for the proxy request.
|
|
1589
|
-
* @property [disabled = false] - To override the proxy for the particular url, you need to provide true.
|
|
1590
|
-
* @property [authenticate = false] - To enable authentication for the proxy, you need to provide true.
|
|
1591
|
-
* @property [username] - The proxy authentication username
|
|
1592
|
-
* @property [password] - The proxy authentication password
|
|
1593
|
-
*/
|
|
1594
|
-
type definition = {
|
|
1595
|
-
match?: string;
|
|
1596
|
-
host?: string;
|
|
1597
|
-
port?: number;
|
|
1598
|
-
tunnel?: boolean;
|
|
1599
|
-
disabled?: boolean;
|
|
1600
|
-
authenticate?: boolean;
|
|
1601
|
-
username?: string;
|
|
1602
|
-
password?: string;
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
/**
|
|
1607
|
-
* A ProxyConfig definition that represents the proxy configuration for an url match.
|
|
1608
|
-
* Properties can then use the `.toObjectResolved` function to procure an object representation of the property with
|
|
1609
|
-
* all the variable references replaced by corresponding values.
|
|
1610
|
-
* @example
|
|
1611
|
-
* Create a new ProxyConfig
|
|
1612
|
-
* var ProxyConfig = require('postman-collection').ProxyConfig,
|
|
1613
|
-
* myProxyConfig = new ProxyConfig({
|
|
1614
|
-
* host: 'proxy.com',
|
|
1615
|
-
* match: 'http+https://example.com/*',
|
|
1616
|
-
* port: 8080,
|
|
1617
|
-
* tunnel: true,
|
|
1618
|
-
* disabled: false,
|
|
1619
|
-
* authenticate: true,
|
|
1620
|
-
* username: 'proxy_username',
|
|
1621
|
-
* password: 'proxy_password'
|
|
1622
|
-
* });
|
|
1623
|
-
* @param [options] - Specifies object with props matches, server and tunnel.
|
|
1624
|
-
*/
|
|
1625
|
-
export class ProxyConfig extends Property {
|
|
1626
|
-
constructor(options?: ProxyConfig.definition);
|
|
1627
|
-
/**
|
|
1628
|
-
* The proxy server host or ip
|
|
1629
|
-
*/
|
|
1630
|
-
static host: string;
|
|
1631
|
-
/**
|
|
1632
|
-
* The url mach for which the proxy has been associated with.
|
|
1633
|
-
*/
|
|
1634
|
-
static match: string;
|
|
1635
|
-
/**
|
|
1636
|
-
* The proxy server port number
|
|
1637
|
-
*/
|
|
1638
|
-
static port: number;
|
|
1639
|
-
/**
|
|
1640
|
-
* This represents whether the tunneling needs to done while proxying this request.
|
|
1641
|
-
*/
|
|
1642
|
-
static tunnel: boolean;
|
|
1643
|
-
/**
|
|
1644
|
-
* Proxy bypass list
|
|
1645
|
-
*/
|
|
1646
|
-
static bypass: UrlMatchPatternList;
|
|
1647
|
-
/**
|
|
1648
|
-
* Enable proxy authentication
|
|
1649
|
-
*/
|
|
1650
|
-
static authenticate: boolean;
|
|
1651
|
-
/**
|
|
1652
|
-
* Proxy auth username
|
|
1653
|
-
*/
|
|
1654
|
-
static username: string;
|
|
1655
|
-
/**
|
|
1656
|
-
* Proxy auth password
|
|
1657
|
-
*/
|
|
1658
|
-
static password: string;
|
|
1659
|
-
/**
|
|
1660
|
-
* Updates the properties of the proxy object based on the options provided.
|
|
1661
|
-
* @param options - The proxy object structure.
|
|
1662
|
-
*/
|
|
1663
|
-
update(options: ProxyConfig.definition): void;
|
|
1664
|
-
/**
|
|
1665
|
-
* Updates the protocols in the match pattern
|
|
1666
|
-
* @param protocols - The array of protocols
|
|
1667
|
-
*/
|
|
1668
|
-
updateProtocols(protocols: string[]): void;
|
|
1669
|
-
/**
|
|
1670
|
-
* Tests the url string with the match provided.
|
|
1671
|
-
* Follows the https://developer.chrome.com/extensions/match_patterns pattern for pattern validation and matching
|
|
1672
|
-
* @param [urlStr] - The url string for which the proxy match needs to be done.
|
|
1673
|
-
*/
|
|
1674
|
-
test(urlStr?: string): void;
|
|
1675
|
-
/**
|
|
1676
|
-
* Returns the proxy server url.
|
|
1677
|
-
*/
|
|
1678
|
-
getProxyUrl(): string;
|
|
1679
|
-
/**
|
|
1680
|
-
* Returns the protocols supported.
|
|
1681
|
-
*/
|
|
1682
|
-
getProtocols(): string[];
|
|
1683
|
-
/**
|
|
1684
|
-
* Check whether an object is an instance of PostmanItem.
|
|
1685
|
-
* @param obj - -
|
|
1686
|
-
*/
|
|
1687
|
-
static isProxyConfig(obj: any): boolean;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
export namespace QueryParam {
|
|
1691
|
-
/**
|
|
1692
|
-
* @property key - The name ("key") of the query parameter.
|
|
1693
|
-
* @property value - The value of the parameter.
|
|
1694
|
-
*/
|
|
1695
|
-
type definition = {
|
|
1696
|
-
key: string;
|
|
1697
|
-
value: string;
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
/**
|
|
1702
|
-
* Represents a URL query parameter, which can exist in request URL or POST data.
|
|
1703
|
-
* @param options - Pass the initial definition of the query parameter. In case of
|
|
1704
|
-
* string, the query parameter is parsed using QueryParam.parseSingle.
|
|
1705
|
-
*/
|
|
1706
|
-
export class QueryParam extends Property {
|
|
1707
|
-
constructor(options: QueryParam.definition | string);
|
|
1708
|
-
key: string;
|
|
1709
|
-
value: string;
|
|
1710
|
-
/**
|
|
1711
|
-
* Converts the QueryParameter to a single param string.
|
|
1712
|
-
*/
|
|
1713
|
-
toString(): string;
|
|
1714
|
-
/**
|
|
1715
|
-
* Updates the key and value of the query parameter
|
|
1716
|
-
* @param param - -
|
|
1717
|
-
* @param param.key - -
|
|
1718
|
-
* @param [param.value] - -
|
|
1719
|
-
*/
|
|
1720
|
-
update(param: { key: string; value?: string }): void;
|
|
1721
|
-
/**
|
|
1722
|
-
* Declare the list index key, so that property lists of query parameters work correctly
|
|
1723
|
-
*/
|
|
1724
|
-
static _postman_propertyIndexKey: string;
|
|
1725
|
-
/**
|
|
1726
|
-
* Query params can have multiple values, so set this to true.
|
|
1727
|
-
*/
|
|
1728
|
-
static _postman_propertyAllowsMultipleValues: boolean;
|
|
1729
|
-
/**
|
|
1730
|
-
* Parse a query string into an array of objects, where each object contains a key and a value.
|
|
1731
|
-
* @param query - -
|
|
1732
|
-
*/
|
|
1733
|
-
static parse(query: string): any[];
|
|
1734
|
-
/**
|
|
1735
|
-
* Parses a single query parameter.
|
|
1736
|
-
* @param param - -
|
|
1737
|
-
* @param idx - -
|
|
1738
|
-
* @param all - array of all params, in case this is being called while parsing multiple params.
|
|
1739
|
-
*/
|
|
1740
|
-
static parseSingle(param: string, idx: number, all: string[]): any;
|
|
1741
|
-
/**
|
|
1742
|
-
* Create a query string from array of parameters (or object of key-values).
|
|
1743
|
-
* @param params - -
|
|
1744
|
-
*/
|
|
1745
|
-
static unparse(params: any[] | any): string;
|
|
1746
|
-
/**
|
|
1747
|
-
* Takes a query param and converts to string
|
|
1748
|
-
* @param obj - -
|
|
1749
|
-
*/
|
|
1750
|
-
static unparseSingle(obj: any): string;
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
export namespace RequestAuth {
|
|
1754
|
-
/**
|
|
1755
|
-
* This defines the definition of the authentication method to be used.
|
|
1756
|
-
* @example
|
|
1757
|
-
* Sample auth definition for Basic Auth
|
|
1758
|
-
* {
|
|
1759
|
-
* "type": "basic",
|
|
1760
|
-
* "basic": [
|
|
1761
|
-
* { "key": "username", "value": "postman" },
|
|
1762
|
-
* { "key": "password", "value": "secrets" }
|
|
1763
|
-
* ]
|
|
1764
|
-
* }
|
|
1765
|
-
* @property [type] - The Auth type to use. Check the names in AuthTypes
|
|
1766
|
-
*/
|
|
1767
|
-
type definition = {
|
|
1768
|
-
type?: string;
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1772
|
-
/**
|
|
1773
|
-
* A Postman Auth definition that comprehensively represents different types of auth mechanisms available.
|
|
1774
|
-
* @example
|
|
1775
|
-
* Creating a request with two auth data and one selected
|
|
1776
|
-
* var auth = new RequestAuth({
|
|
1777
|
-
* type: 'digest',
|
|
1778
|
-
*
|
|
1779
|
-
* basic: [
|
|
1780
|
-
* { key: "username", value: "postman" },
|
|
1781
|
-
* { key: "password", value: "secrets" }
|
|
1782
|
-
* ],
|
|
1783
|
-
* digest: [
|
|
1784
|
-
* { key: "nonce", value: "aef54cde" },
|
|
1785
|
-
* { key: "realm", value: "items.x" }
|
|
1786
|
-
* ]
|
|
1787
|
-
* });
|
|
1788
|
-
*
|
|
1789
|
-
* // change the selected auth
|
|
1790
|
-
* auth.use('basic');
|
|
1791
|
-
* @param options - Pass the initial definition of the Auth.
|
|
1792
|
-
* @param [parent] - optionally pass the parent of this auth. aides variable resolution.
|
|
1793
|
-
*/
|
|
1794
|
-
export class RequestAuth extends Property {
|
|
1795
|
-
constructor(options: RequestAuth.definition, parent?: Property | PropertyList<RequestAuth>);
|
|
1796
|
-
/**
|
|
1797
|
-
* Update the parameters of a specific authentication type. If none is provided then it uses the one marked as to be
|
|
1798
|
-
* used.
|
|
1799
|
-
* @param options - -
|
|
1800
|
-
* @param [type = this.type] - -
|
|
1801
|
-
*/
|
|
1802
|
-
update(options: VariableList | any[] | any, type?: string): void;
|
|
1803
|
-
/**
|
|
1804
|
-
* Sets the authentication type to be used by this item.
|
|
1805
|
-
* @param type - -
|
|
1806
|
-
* @param options - note that options set here would replace all existing
|
|
1807
|
-
* options for the particular auth
|
|
1808
|
-
*/
|
|
1809
|
-
use(type: string, options: VariableList | any[] | any): void;
|
|
1810
|
-
/**
|
|
1811
|
-
* Returns the parameters of the selected auth type
|
|
1812
|
-
*/
|
|
1813
|
-
parameters(): VariableList;
|
|
1814
|
-
/**
|
|
1815
|
-
* Clears the definition of an auth type.
|
|
1816
|
-
* @param type - -
|
|
1817
|
-
*/
|
|
1818
|
-
clear(type: string): void;
|
|
1819
|
-
/**
|
|
1820
|
-
* Determines whether an authentication type name is valid or not
|
|
1821
|
-
* @param type - -
|
|
1822
|
-
*/
|
|
1823
|
-
static isValidType(type: string): boolean;
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
export namespace RequestBody {
|
|
1827
|
-
type definition = {
|
|
1828
|
-
mode: string;
|
|
1829
|
-
raw: string;
|
|
1830
|
-
file: string;
|
|
1831
|
-
graphql: any;
|
|
1832
|
-
formdata: object[];
|
|
1833
|
-
urlencoded: object[] | string;
|
|
1834
|
-
};
|
|
1835
|
-
type MODE = "file" | "formdata" | "graphql" | "raw" | "urlencoded";
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
/**
|
|
1839
|
-
* RequestBody holds data related to the request body. By default, it provides a nice wrapper for url-encoded,
|
|
1840
|
-
* form-data, and raw types of request bodies.
|
|
1841
|
-
* @param options - -
|
|
1842
|
-
*/
|
|
1843
|
-
export class RequestBody extends PropertyBase {
|
|
1844
|
-
constructor(options: RequestBody.definition);
|
|
1845
|
-
/**
|
|
1846
|
-
* Set the content of this request data
|
|
1847
|
-
* @param options - -
|
|
1848
|
-
*/
|
|
1849
|
-
update(options: any): void;
|
|
1850
|
-
/**
|
|
1851
|
-
* Indicates the type of request data to use.
|
|
1852
|
-
*/
|
|
1853
|
-
mode: RequestBody.MODE;
|
|
1854
|
-
/**
|
|
1855
|
-
* If the request has raw body data associated with it, the data is held in this field.
|
|
1856
|
-
*/
|
|
1857
|
-
raw?: string;
|
|
1858
|
-
/**
|
|
1859
|
-
* Any URL encoded body params go here.
|
|
1860
|
-
*/
|
|
1861
|
-
urlencoded?: PropertyList<QueryParam>;
|
|
1862
|
-
/**
|
|
1863
|
-
* Form data parameters for this request are held in this field.
|
|
1864
|
-
*/
|
|
1865
|
-
formdata?: PropertyList<FormParam>;
|
|
1866
|
-
/**
|
|
1867
|
-
* Holds a reference to a file which should be read as the RequestBody. It can be a file path (when used
|
|
1868
|
-
* with Node) or a unique ID (when used with the browser).
|
|
1869
|
-
*/
|
|
1870
|
-
file?: {
|
|
1871
|
-
src: string;
|
|
1872
|
-
};
|
|
1873
|
-
/**
|
|
1874
|
-
* If the request has raw graphql data associated with it, the data is held in this field.
|
|
1875
|
-
*/
|
|
1876
|
-
graphql?: {
|
|
1877
|
-
query: string;
|
|
1878
|
-
operationName?: string;
|
|
1879
|
-
variables?: string;
|
|
1880
|
-
};
|
|
1881
|
-
/**
|
|
1882
|
-
* If the request has body Options associated with it, the data is held in this field.
|
|
1883
|
-
*/
|
|
1884
|
-
options: any;
|
|
1885
|
-
/**
|
|
1886
|
-
* Indicates whether to include body in request or not.
|
|
1887
|
-
*/
|
|
1888
|
-
disabled?: boolean;
|
|
1889
|
-
/**
|
|
1890
|
-
* Stringifies and returns the request body.
|
|
1891
|
-
*/
|
|
1892
|
-
toString(): any;
|
|
1893
|
-
/**
|
|
1894
|
-
* If the request body is set to a mode, but does not contain data, then we should not be sending it.
|
|
1895
|
-
*/
|
|
1896
|
-
isEmpty(): boolean;
|
|
1897
|
-
/**
|
|
1898
|
-
* Convert the request body to JSON compatible plain object
|
|
1899
|
-
*/
|
|
1900
|
-
toJSON(): any;
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
export namespace Request {
|
|
1904
|
-
/**
|
|
1905
|
-
* @property url - The URL of the request. This can be a Url.definition or a string.
|
|
1906
|
-
* @property method - The request method, e.g: "GET" or "POST".
|
|
1907
|
-
* @property header - The headers that should be sent as a part of this request.
|
|
1908
|
-
* @property body - The request body definition.
|
|
1909
|
-
* @property auth - The authentication/signing information for this request.
|
|
1910
|
-
* @property proxy - The proxy information for this request.
|
|
1911
|
-
* @property certificate - The certificate information for this request.
|
|
1912
|
-
*/
|
|
1913
|
-
type definition = {
|
|
1914
|
-
url: string | Url;
|
|
1915
|
-
method: string;
|
|
1916
|
-
header: Header.definition[];
|
|
1917
|
-
body: RequestBody.definition;
|
|
1918
|
-
auth: RequestAuth.definition;
|
|
1919
|
-
proxy: ProxyConfig.definition;
|
|
1920
|
-
certificate: Certificate.definition;
|
|
1921
|
-
};
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
/**
|
|
1925
|
-
* A Postman HTTP request object.
|
|
1926
|
-
* @param options - -
|
|
1927
|
-
*/
|
|
1928
|
-
export class Request extends Property {
|
|
1929
|
-
constructor(options: Request.definition);
|
|
1930
|
-
url: Url;
|
|
1931
|
-
headers: HeaderList;
|
|
1932
|
-
method: string;
|
|
1933
|
-
/**
|
|
1934
|
-
* Updates the different properties of the request.
|
|
1935
|
-
* @param options - -
|
|
1936
|
-
*/
|
|
1937
|
-
update(options: Request.definition): void;
|
|
1938
|
-
body?: RequestBody;
|
|
1939
|
-
auth?: RequestAuth;
|
|
1940
|
-
proxy?: ProxyConfig;
|
|
1941
|
-
certificate?: Certificate;
|
|
1942
|
-
/**
|
|
1943
|
-
* Sets authentication method for the request
|
|
1944
|
-
* @param type - -
|
|
1945
|
-
* @param [options] - -
|
|
1946
|
-
*/
|
|
1947
|
-
authorizeUsing(type: string | RequestAuth.definition, options?: VariableList): void;
|
|
1948
|
-
/**
|
|
1949
|
-
* Returns an object where the key is a header name and value is the header value.
|
|
1950
|
-
* @param [options] - -
|
|
1951
|
-
* @param options.ignoreCase - When set to "true", will ensure that all the header keys are lower case.
|
|
1952
|
-
* @param options.enabled - Only get the enabled headers
|
|
1953
|
-
* @param options.multiValue - When set to "true", duplicate header values will be stored in an array
|
|
1954
|
-
* @param options.sanitizeKeys - When set to "true", headers with falsy keys are removed
|
|
1955
|
-
*/
|
|
1956
|
-
getHeaders(options?: { ignoreCase: boolean; enabled: boolean; multiValue: boolean; sanitizeKeys: boolean }): any;
|
|
1957
|
-
/**
|
|
1958
|
-
* Calls the given callback on each Header object contained within the request.
|
|
1959
|
-
* @param callback - -
|
|
1960
|
-
*/
|
|
1961
|
-
forEachHeader(callback: (...params: any[]) => any): void;
|
|
1962
|
-
/**
|
|
1963
|
-
* Adds a header to the PropertyList of headers.
|
|
1964
|
-
* @param header - Can be a {Header} object, or a raw header object.
|
|
1965
|
-
*/
|
|
1966
|
-
addHeader(header: Header | any): void;
|
|
1967
|
-
/**
|
|
1968
|
-
* Removes a header from the request.
|
|
1969
|
-
* @param toRemove - A header object to remove, or a string containing the header key.
|
|
1970
|
-
* @param options - -
|
|
1971
|
-
* @param options.ignoreCase - If set to true, ignores case while removing the header.
|
|
1972
|
-
*/
|
|
1973
|
-
removeHeader(
|
|
1974
|
-
toRemove: string | Header,
|
|
1975
|
-
options: {
|
|
1976
|
-
ignoreCase: boolean;
|
|
1977
|
-
}
|
|
1978
|
-
): void;
|
|
1979
|
-
/**
|
|
1980
|
-
* Updates or inserts the given header.
|
|
1981
|
-
* @param header - -
|
|
1982
|
-
*/
|
|
1983
|
-
upsertHeader(header: any): void;
|
|
1984
|
-
/**
|
|
1985
|
-
* Add query parameters to the request.
|
|
1986
|
-
* @param params - -
|
|
1987
|
-
*/
|
|
1988
|
-
addQueryParams(params: QueryParam[] | string): void;
|
|
1989
|
-
/**
|
|
1990
|
-
* Removes parameters passed in params.
|
|
1991
|
-
* @param params - -
|
|
1992
|
-
*/
|
|
1993
|
-
removeQueryParams(params: string | any[]): void;
|
|
1994
|
-
/**
|
|
1995
|
-
* Get the request size by computing the headers and body or using the
|
|
1996
|
-
* actual content length header once the request is sent.
|
|
1997
|
-
*/
|
|
1998
|
-
size(): any;
|
|
1999
|
-
/**
|
|
2000
|
-
* Converts the Request to a plain JavaScript object, which is also how the request is
|
|
2001
|
-
* represented in a collection file.
|
|
2002
|
-
*/
|
|
2003
|
-
toJSON(): any;
|
|
2004
|
-
/**
|
|
2005
|
-
* Creates a clone of this request
|
|
2006
|
-
*/
|
|
2007
|
-
clone(): Request;
|
|
2008
|
-
/**
|
|
2009
|
-
* Check whether an object is an instance of ItemGroup.
|
|
2010
|
-
* @param obj - -
|
|
2011
|
-
*/
|
|
2012
|
-
static isRequest(obj: any): boolean;
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
export namespace Response {
|
|
2016
|
-
/**
|
|
2017
|
-
* @property code - define the response code
|
|
2018
|
-
* @property [reason] - optionally, if the response has a non-standard response code reason, provide it here
|
|
2019
|
-
*/
|
|
2020
|
-
type definition = {
|
|
2021
|
-
code: number;
|
|
2022
|
-
reason?: string;
|
|
2023
|
-
header?: Header.definition[];
|
|
2024
|
-
cookie?: Cookie.definition[];
|
|
2025
|
-
body?: string;
|
|
2026
|
-
stream?: Buffer | ArrayBuffer;
|
|
2027
|
-
responseTime: number;
|
|
2028
|
-
};
|
|
2029
|
-
/**
|
|
2030
|
-
* @property body - size of the response body in bytes
|
|
2031
|
-
* @property header - size of the response header in bytes
|
|
2032
|
-
* @property total - total size of the response body and header in bytes
|
|
2033
|
-
*/
|
|
2034
|
-
type sizeInfo = {
|
|
2035
|
-
body: number;
|
|
2036
|
-
header: number;
|
|
2037
|
-
total: number;
|
|
2038
|
-
};
|
|
2039
|
-
/**
|
|
2040
|
-
* Returns the durations of each request phase in milliseconds
|
|
2041
|
-
* @example
|
|
2042
|
-
* Output
|
|
2043
|
-
* Request.timingPhases(timings);
|
|
2044
|
-
* {
|
|
2045
|
-
* prepare: Number, // duration of request preparation
|
|
2046
|
-
* wait: Number, // duration of socket initialization
|
|
2047
|
-
* dns: Number, // duration of DNS lookup
|
|
2048
|
-
* tcp: Number, // duration of TCP connection
|
|
2049
|
-
* secureHandshake: Number, // duration of secure handshake
|
|
2050
|
-
* firstByte: Number, // duration of HTTP server response
|
|
2051
|
-
* download: Number, // duration of HTTP download
|
|
2052
|
-
* process: Number, // duration of response processing
|
|
2053
|
-
* total: Number // duration entire HTTP round-trip
|
|
2054
|
-
* }
|
|
2055
|
-
* @property start - timestamp of the request sent from the client (in Unix Epoch milliseconds)
|
|
2056
|
-
* @property offset - event timestamps in millisecond resolution relative to start
|
|
2057
|
-
* @property offset.request - timestamp of the start of the request
|
|
2058
|
-
* @property offset.socket - timestamp when the socket is assigned to the request
|
|
2059
|
-
* @property offset.lookup - timestamp when the DNS has been resolved
|
|
2060
|
-
* @property offset.connect - timestamp when the server acknowledges the TCP connection
|
|
2061
|
-
* @property offset.secureConnect - timestamp when secure handshaking process is completed
|
|
2062
|
-
* @property offset.response - timestamp when the first bytes are received from the server
|
|
2063
|
-
* @property offset.end - timestamp when the last bytes of the response are received
|
|
2064
|
-
* @property offset.done - timestamp when the response is received at the client
|
|
2065
|
-
* @param timings - -
|
|
2066
|
-
*/
|
|
2067
|
-
type timings = {
|
|
2068
|
-
start: number;
|
|
2069
|
-
offset: {
|
|
2070
|
-
request: number;
|
|
2071
|
-
socket: number;
|
|
2072
|
-
lookup: number;
|
|
2073
|
-
connect: number;
|
|
2074
|
-
secureConnect: number;
|
|
2075
|
-
response: number;
|
|
2076
|
-
end: number;
|
|
2077
|
-
done: number;
|
|
2078
|
-
};
|
|
2079
|
-
};
|
|
2080
|
-
/**
|
|
2081
|
-
* @property mimeType - sanitized mime type
|
|
2082
|
-
* @property mimeFormat - format for the identified mime type
|
|
2083
|
-
* @property charset - the normalized character set
|
|
2084
|
-
* @property fileExtension - extension identified from the mime type
|
|
2085
|
-
* @property fileName - file name extracted from disposition header
|
|
2086
|
-
* @property contentType - sanitized content-type extracted from header
|
|
2087
|
-
*/
|
|
2088
|
-
type ResponseContentInfo = {
|
|
2089
|
-
mimeType: string;
|
|
2090
|
-
mimeFormat: string;
|
|
2091
|
-
charset: string;
|
|
2092
|
-
fileExtension: string;
|
|
2093
|
-
fileName: string;
|
|
2094
|
-
contentType: string;
|
|
2095
|
-
};
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
/**
|
|
2099
|
-
* Response holds data related to the request body. By default, it provides a nice wrapper for url-encoded,
|
|
2100
|
-
* form-data, and raw types of request bodies.
|
|
2101
|
-
* @param options - -
|
|
2102
|
-
*/
|
|
2103
|
-
export class Response extends Property {
|
|
2104
|
-
constructor(options: Response.definition);
|
|
2105
|
-
originalRequest: Request;
|
|
2106
|
-
status: string;
|
|
2107
|
-
code: number;
|
|
2108
|
-
headers: HeaderList;
|
|
2109
|
-
body: string;
|
|
2110
|
-
cookies: CookieList;
|
|
2111
|
-
/**
|
|
2112
|
-
* Time taken for the request to complete.
|
|
2113
|
-
*/
|
|
2114
|
-
responseTime: number;
|
|
2115
|
-
/**
|
|
2116
|
-
* Convert this response into a JSON serializable object. The _details meta property is omitted.
|
|
2117
|
-
*/
|
|
2118
|
-
toJSON(): any;
|
|
2119
|
-
/**
|
|
2120
|
-
* Get the http response reason phrase based on the current response code.
|
|
2121
|
-
*/
|
|
2122
|
-
reason(): string | undefined;
|
|
2123
|
-
/**
|
|
2124
|
-
* Get the response body as a string/text.
|
|
2125
|
-
*/
|
|
2126
|
-
text(): string | undefined;
|
|
2127
|
-
/**
|
|
2128
|
-
* Get the response body as a JavaScript object. Note that it throws an error if the response is not a valid JSON
|
|
2129
|
-
* @example
|
|
2130
|
-
* // assuming that the response is stored in a collection instance `myCollection`
|
|
2131
|
-
* var response = myCollection.items.one('some request').responses.idx(0),
|
|
2132
|
-
* jsonBody;
|
|
2133
|
-
* try {
|
|
2134
|
-
* jsonBody = response.json();
|
|
2135
|
-
* }
|
|
2136
|
-
* catch (e) {
|
|
2137
|
-
* console.log("There was an error parsing JSON ", e);
|
|
2138
|
-
* }
|
|
2139
|
-
* // log the root-level keys in the response JSON.
|
|
2140
|
-
* console.log('All keys in json response: ' + Object.keys(json));
|
|
2141
|
-
* @param [reviver] - -
|
|
2142
|
-
* @param [strict = false] - Specify whether JSON parsing will be strict. This will fail on comments and BOM
|
|
2143
|
-
*/
|
|
2144
|
-
json(reviver?: (...params: any[]) => any, strict?: boolean): any;
|
|
2145
|
-
/**
|
|
2146
|
-
* Get the JSON from response body that returns JSONP response.
|
|
2147
|
-
* @param [reviver] - -
|
|
2148
|
-
* @param [strict = false] - Specify whether JSON parsing will be strict. This will fail on comments and BOM
|
|
2149
|
-
*/
|
|
2150
|
-
jsonp(reviver?: (...params: any[]) => any, strict?: boolean): void;
|
|
2151
|
-
/**
|
|
2152
|
-
* Extracts mime type, format, charset, extension and filename of the response content
|
|
2153
|
-
* A fallback of default filename is given, if filename is not present in content-disposition header
|
|
2154
|
-
* @returns - contentInfo for the response
|
|
2155
|
-
*/
|
|
2156
|
-
contentInfo(): Response.ResponseContentInfo;
|
|
2157
|
-
/**
|
|
2158
|
-
* Converts the response to a dataURI that can be used for storage or serialisation. The data URI is formed using
|
|
2159
|
-
* the following syntax `data:;baseg4, `.
|
|
2160
|
-
*/
|
|
2161
|
-
dataURI(): string;
|
|
2162
|
-
/**
|
|
2163
|
-
* Get the response size by computing the same from content length header or
|
|
2164
|
-
* using the actual response body.
|
|
2165
|
-
* @returns - Response size object
|
|
2166
|
-
*/
|
|
2167
|
-
size(): Response.sizeInfo;
|
|
2168
|
-
/**
|
|
2169
|
-
* Check whether an object is an instance of ItemGroup.
|
|
2170
|
-
* @param obj - -
|
|
2171
|
-
*/
|
|
2172
|
-
static isResponse(obj: any): boolean;
|
|
2173
|
-
/**
|
|
2174
|
-
* Converts the response object from the request module to the postman responseBody format
|
|
2175
|
-
* @param response - The response object, as received from the request module
|
|
2176
|
-
* @param cookies - -
|
|
2177
|
-
* @returns The transformed responseBody
|
|
2178
|
-
*/
|
|
2179
|
-
static createFromNode(response: any, cookies: any): any;
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
/**
|
|
2183
|
-
* A map of package names to the IDs of the packages
|
|
2184
|
-
*/
|
|
2185
|
-
export type Packages = {
|
|
2186
|
-
[key: string]: { id: string };
|
|
2187
|
-
};
|
|
2188
|
-
|
|
2189
|
-
/**
|
|
2190
|
-
* Postman scripts that are executed upon events on a collection / request such as test and pre request.
|
|
2191
|
-
* @param options - -
|
|
2192
|
-
*/
|
|
2193
|
-
export class Script extends Property {
|
|
2194
|
-
constructor(options: any);
|
|
2195
|
-
/**
|
|
2196
|
-
* Converts the script lines array to a single source string.
|
|
2197
|
-
*/
|
|
2198
|
-
toSource(): string;
|
|
2199
|
-
/**
|
|
2200
|
-
* Updates the properties of a Script.
|
|
2201
|
-
* @param [options] - -
|
|
2202
|
-
* @param [options.type] - Script type
|
|
2203
|
-
* @param [options.src] - Script source url
|
|
2204
|
-
* @param [options.exec] - Script to execute
|
|
2205
|
-
* @param [options.packages] - Packages required by the script
|
|
2206
|
-
*/
|
|
2207
|
-
update(options?: { type?: string; src?: string; exec?: string[] | string; packages?: Packages }): void;
|
|
2208
|
-
type: string;
|
|
2209
|
-
/**
|
|
2210
|
-
* The packages required by the script
|
|
2211
|
-
*/
|
|
2212
|
-
packages: Packages;
|
|
2213
|
-
src: Url;
|
|
2214
|
-
exec: string[];
|
|
2215
|
-
/**
|
|
2216
|
-
* Checks if the script is empty i.e does not have any code to execute.
|
|
2217
|
-
*/
|
|
2218
|
-
isEmpty(): boolean;
|
|
2219
|
-
/**
|
|
2220
|
-
* Check whether an object is an instance of ItemGroup.
|
|
2221
|
-
* @param obj - -
|
|
2222
|
-
*/
|
|
2223
|
-
static isScript(obj: any): boolean;
|
|
2224
|
-
}
|
|
2225
|
-
|
|
2226
|
-
/**
|
|
2227
|
-
* Defines a URL.
|
|
2228
|
-
* @param options - -
|
|
2229
|
-
*/
|
|
2230
|
-
export class Url extends PropertyBase {
|
|
2231
|
-
constructor(options: any | string);
|
|
2232
|
-
/**
|
|
2233
|
-
* Set a URL.
|
|
2234
|
-
* @param url - -
|
|
2235
|
-
*/
|
|
2236
|
-
update(url: string | any): void;
|
|
2237
|
-
auth: any;
|
|
2238
|
-
protocol: string;
|
|
2239
|
-
port: string;
|
|
2240
|
-
path: string[];
|
|
2241
|
-
hash: string;
|
|
2242
|
-
host: string[];
|
|
2243
|
-
query: PropertyList<QueryParam>;
|
|
2244
|
-
variables: VariableList;
|
|
2245
|
-
/**
|
|
2246
|
-
* Add query parameters to the URL.
|
|
2247
|
-
* @param params - Key value pairs to add to the URL.
|
|
2248
|
-
*/
|
|
2249
|
-
addQueryParams(params: any | string): void;
|
|
2250
|
-
/**
|
|
2251
|
-
* Removes query parameters from the URL.
|
|
2252
|
-
* @param params - Params should be an array of strings, or an array of
|
|
2253
|
-
* actual query parameters, or a string containing the parameter key.
|
|
2254
|
-
*/
|
|
2255
|
-
removeQueryParams(params: QueryParam[] | string[] | string): void;
|
|
2256
|
-
/**
|
|
2257
|
-
* Unparses a {PostmanUrl} into a string.
|
|
2258
|
-
* @param [forceProtocol] - Forces the URL to have a protocol
|
|
2259
|
-
*/
|
|
2260
|
-
toString(forceProtocol?: boolean): string;
|
|
2261
|
-
/**
|
|
2262
|
-
* Returns the request path, with a leading '/'.
|
|
2263
|
-
* @param [unresolved = false] - -
|
|
2264
|
-
*/
|
|
2265
|
-
getPath(unresolved?: boolean): string;
|
|
2266
|
-
/**
|
|
2267
|
-
* Returns the stringified query string for this URL.
|
|
2268
|
-
*/
|
|
2269
|
-
getQueryString(): string;
|
|
2270
|
-
/**
|
|
2271
|
-
* Returns the complete path, including the query string.
|
|
2272
|
-
* @example
|
|
2273
|
-
* /something/postman?hi=notbye
|
|
2274
|
-
*/
|
|
2275
|
-
getPathWithQuery(): any | string;
|
|
2276
|
-
/**
|
|
2277
|
-
* Returns the host part of the URL
|
|
2278
|
-
*/
|
|
2279
|
-
getHost(): string;
|
|
2280
|
-
/**
|
|
2281
|
-
* Returns the host *and* port (if any), separated by a ":"
|
|
2282
|
-
* @param [forcePort = false] - forces the port to be added even for the protocol default ones (89, 443)
|
|
2283
|
-
*/
|
|
2284
|
-
getRemote(forcePort?: boolean): string;
|
|
2285
|
-
/**
|
|
2286
|
-
* Parses a string to a PostmanUrl, decomposing the URL into it's constituent parts,
|
|
2287
|
-
* such as path, host, port, etc.
|
|
2288
|
-
* @param url - -
|
|
2289
|
-
*/
|
|
2290
|
-
static parse(url: string): any;
|
|
2291
|
-
/**
|
|
2292
|
-
* Checks whether an object is a Url
|
|
2293
|
-
* @param obj - -
|
|
2294
|
-
*/
|
|
2295
|
-
static isUrl(obj: any): boolean;
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
/**
|
|
2299
|
-
* @param parent - -
|
|
2300
|
-
* @param populate - -
|
|
2301
|
-
*/
|
|
2302
|
-
export class VariableList extends PropertyList<Variable> {
|
|
2303
|
-
constructor(parent: Property, populate: any | any[]);
|
|
2304
|
-
/**
|
|
2305
|
-
* Replaces the variable tokens inside a string with its actual values.
|
|
2306
|
-
* @param str - -
|
|
2307
|
-
* @param [overrides] - additional objects to lookup for variable values
|
|
2308
|
-
*/
|
|
2309
|
-
replace(str: string, overrides?: any): string;
|
|
2310
|
-
/**
|
|
2311
|
-
* Recursively replace strings in an object with instances of variables. Note that it clones the original object. If
|
|
2312
|
-
* the `mutate` param is set to true, then it replaces the same object instead of creating a new one.
|
|
2313
|
-
* @param obj - -
|
|
2314
|
-
* @param [overrides] - additional objects to lookup for variable values
|
|
2315
|
-
* @param [mutate = false] - -
|
|
2316
|
-
*/
|
|
2317
|
-
substitute(obj: any[] | any, overrides?: object[], mutate?: boolean): any[] | any;
|
|
2318
|
-
/**
|
|
2319
|
-
* Using this function, one can sync the values of this variable list from a reference object.
|
|
2320
|
-
* @param obj - -
|
|
2321
|
-
* @param [track] - -
|
|
2322
|
-
* @param [prune = true] - -
|
|
2323
|
-
*/
|
|
2324
|
-
syncFromObject(obj: any, track?: boolean, prune?: boolean): any;
|
|
2325
|
-
/**
|
|
2326
|
-
* Transfer all variables from this list to an object
|
|
2327
|
-
* @param [obj] - -
|
|
2328
|
-
*/
|
|
2329
|
-
syncToObject(obj?: any): any;
|
|
2330
|
-
/**
|
|
2331
|
-
* Checks whether an object is a VariableList
|
|
2332
|
-
* @param obj - -
|
|
2333
|
-
*/
|
|
2334
|
-
static isVariableList(obj: any): boolean;
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
export namespace VariableScope {
|
|
2338
|
-
/**
|
|
2339
|
-
* Environment and Globals of postman is exported and imported in a specified data structure. This data structure can be
|
|
2340
|
-
* passed on to the constructor parameter of VariableScope or VariableList to instantiate an instance of
|
|
2341
|
-
* the same with pre-populated values from arguments.
|
|
2342
|
-
* @example
|
|
2343
|
-
* JSON definition of a VariableScope (environment, globals, etc)
|
|
2344
|
-
* {
|
|
2345
|
-
* "name": "globals",
|
|
2346
|
-
* "values": [{
|
|
2347
|
-
* "key": "var-1",
|
|
2348
|
-
* "value": "value-1"
|
|
2349
|
-
* }, {
|
|
2350
|
-
* "key": "var-2",
|
|
2351
|
-
* "value": "value-2"
|
|
2352
|
-
* }]
|
|
2353
|
-
* }
|
|
2354
|
-
* @property [id] - ID of the scope
|
|
2355
|
-
* @property [name] - A name of the scope
|
|
2356
|
-
* @property [prefix] - A prefix to be used for variable names in this scope
|
|
2357
|
-
* @property [values] - A list of variables defined in an array in form of `{name:String,
|
|
2358
|
-
* value:String}`
|
|
2359
|
-
*/
|
|
2360
|
-
type definition = {
|
|
2361
|
-
id?: string;
|
|
2362
|
-
name?: string;
|
|
2363
|
-
prefix?: string;
|
|
2364
|
-
values?: Variable.definition[];
|
|
2365
|
-
};
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
/**
|
|
2369
|
-
* VariableScope is a representation of a list of variables in Postman, such as the environment variables or the
|
|
2370
|
-
* globals. Using this object, it is easy to perform operations on this list of variables such as get a variable or
|
|
2371
|
-
* set a variable.
|
|
2372
|
-
* @example
|
|
2373
|
-
* Load a environment from file, modify and save back
|
|
2374
|
-
* var fs = require('fs'), // assuming NodeJS
|
|
2375
|
-
* env,
|
|
2376
|
-
* sum;
|
|
2377
|
-
*
|
|
2378
|
-
* // load env from file assuming it has initial data
|
|
2379
|
-
* env = new VariableScope(JSON.parse(fs.readFileSync('./my-postman-environment.postman_environment').toString()));
|
|
2380
|
-
*
|
|
2381
|
-
* // get two variables and add them
|
|
2382
|
-
* sum = env.get('one-var') + env.get('another-var');
|
|
2383
|
-
*
|
|
2384
|
-
* // save it back in environment and write to file
|
|
2385
|
-
* env.set('sum', sum, 'number');
|
|
2386
|
-
* fs.writeFileSync('./sum-of-vars.postman_environment', JSON.stringify(env.toJSON()));
|
|
2387
|
-
* @param definition - The constructor accepts an initial set of values for initialising
|
|
2388
|
-
* the scope
|
|
2389
|
-
* @param [layers] - Additional parent scopes to search for and resolve variables
|
|
2390
|
-
*/
|
|
2391
|
-
export class VariableScope extends Property {
|
|
2392
|
-
constructor(definition: VariableScope.definition, layers?: VariableList[]);
|
|
2393
|
-
/**
|
|
2394
|
-
* Converts a list of Variables into an object where key is `_postman_propertyIndexKey` and value is determined
|
|
2395
|
-
* by the `valueOf` function
|
|
2396
|
-
* @param excludeDisabled - -
|
|
2397
|
-
* @param caseSensitive - -
|
|
2398
|
-
*/
|
|
2399
|
-
toObject(excludeDisabled: boolean, caseSensitive: boolean): any;
|
|
2400
|
-
/**
|
|
2401
|
-
* Determines whether one particular variable is defined in this scope of variables.
|
|
2402
|
-
* @param key - The name of the variable to check
|
|
2403
|
-
* @returns - Returns true if an enabled variable with given key is present in current or parent scopes,
|
|
2404
|
-
* false otherwise
|
|
2405
|
-
*/
|
|
2406
|
-
has(key: string): boolean;
|
|
2407
|
-
/**
|
|
2408
|
-
* Fetches a variable from the current scope or from parent scopes if present.
|
|
2409
|
-
* @param key - The name of the variable to get.
|
|
2410
|
-
* @returns The value of the specified variable across scopes.
|
|
2411
|
-
*/
|
|
2412
|
-
get(key: string): any;
|
|
2413
|
-
/**
|
|
2414
|
-
* Creates a new variable, or updates an existing one.
|
|
2415
|
-
* @param key - The name of the variable to set.
|
|
2416
|
-
* @param value - The value of the variable to be set.
|
|
2417
|
-
* @param [type] - Optionally, the value of the variable can be set to a type
|
|
2418
|
-
*/
|
|
2419
|
-
set(key: string, value: any, type?: Variable.types): void;
|
|
2420
|
-
/**
|
|
2421
|
-
* Removes the variable with the specified name.
|
|
2422
|
-
* @param key - -
|
|
2423
|
-
*/
|
|
2424
|
-
unset(key: string): void;
|
|
2425
|
-
/**
|
|
2426
|
-
* Removes *all* variables from the current scope. This is a destructive action.
|
|
2427
|
-
*/
|
|
2428
|
-
clear(): void;
|
|
2429
|
-
/**
|
|
2430
|
-
* Replace all variable names with their values in the given template.
|
|
2431
|
-
* @param template - A string or an object to replace variables in
|
|
2432
|
-
* @returns The string or object with variables (if any) substituted with their values
|
|
2433
|
-
*/
|
|
2434
|
-
replaceIn(template: string | any): string | any;
|
|
2435
|
-
/**
|
|
2436
|
-
* Enable mutation tracking.
|
|
2437
|
-
* @param [options] - Options for Mutation Tracker. See MutationTracker
|
|
2438
|
-
*/
|
|
2439
|
-
enableTracking(options?: MutationTracker.definition): void;
|
|
2440
|
-
/**
|
|
2441
|
-
* Disable mutation tracking.
|
|
2442
|
-
*/
|
|
2443
|
-
disableTracking(): void;
|
|
2444
|
-
/**
|
|
2445
|
-
* Convert this variable scope into a JSON serialisable object. Useful to transport or store, environment and
|
|
2446
|
-
* globals as a whole.
|
|
2447
|
-
*/
|
|
2448
|
-
toJSON(): any;
|
|
2449
|
-
/**
|
|
2450
|
-
* Check whether an object is an instance of VariableScope.
|
|
2451
|
-
* @param obj - -
|
|
2452
|
-
*/
|
|
2453
|
-
static isVariableScope(obj: any): boolean;
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
export namespace Variable {
|
|
2457
|
-
/**
|
|
2458
|
-
* The object representation of a Variable consists the variable value and type. It also optionally includes the `id`
|
|
2459
|
-
* and a friendly `name` of the variable. The `id` and the `name` of a variable is usually managed and used when a
|
|
2460
|
-
* variable is made part of a VariableList instance.
|
|
2461
|
-
* @example
|
|
2462
|
-
* {
|
|
2463
|
-
* "id": "my-var-1",
|
|
2464
|
-
* "name": "MyFirstVariable",
|
|
2465
|
-
* "value": "Hello World",
|
|
2466
|
-
* "type": "string"
|
|
2467
|
-
* }
|
|
2468
|
-
* @property [value] - The value of the variable that will be stored and will be typecast to the `type`
|
|
2469
|
-
* set in the variable or passed along in this parameter.
|
|
2470
|
-
* @property [type] - The type of this variable from the list of types defined at Variable.types.
|
|
2471
|
-
*/
|
|
2472
|
-
type definition = {
|
|
2473
|
-
value?: any;
|
|
2474
|
-
type?: string;
|
|
2475
|
-
};
|
|
2476
|
-
/**
|
|
2477
|
-
* The possible supported types of a variable is defined here. The keys defined here are the possible values of
|
|
2478
|
-
* Variable.type.
|
|
2479
|
-
*
|
|
2480
|
-
* Additional variable types can be supported by adding the type-casting function to this enumeration.
|
|
2481
|
-
*/
|
|
2482
|
-
enum types {
|
|
2483
|
-
/**
|
|
2484
|
-
* When a variable's `type` is set to "string", it ensures that Variable.get converts the value of the
|
|
2485
|
-
* variable to a string before returning the data.
|
|
2486
|
-
*/
|
|
2487
|
-
string = "String",
|
|
2488
|
-
/**
|
|
2489
|
-
* A boolean type of variable can either be set to `true` or `false`. Any other value set is converted to
|
|
2490
|
-
* Boolean when procured from Variable.get.
|
|
2491
|
-
*/
|
|
2492
|
-
boolean = "Boolean",
|
|
2493
|
-
/**
|
|
2494
|
-
* A "number" type variable ensures that the value is always represented as a number. A non-number type value
|
|
2495
|
-
* is returned as `NaN`.
|
|
2496
|
-
*/
|
|
2497
|
-
number = "Number",
|
|
2498
|
-
/**
|
|
2499
|
-
* A "array" type value stores Array data format
|
|
2500
|
-
*/
|
|
2501
|
-
array = '{"in":"","out":""}',
|
|
2502
|
-
/**
|
|
2503
|
-
* A "object" type value stores Object data format
|
|
2504
|
-
*/
|
|
2505
|
-
object = '{"in":"","out":""}',
|
|
2506
|
-
/**
|
|
2507
|
-
* Free-form type of a value. This is the default for any variable, unless specified otherwise. It ensures that
|
|
2508
|
-
* the variable can store data in any type and no conversion is done while using Variable.get.
|
|
2509
|
-
*/
|
|
2510
|
-
any = '{"in":"","out":""}'
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
|
|
2514
|
-
/**
|
|
2515
|
-
* A variable inside a collection is similar to variables in any programming construct. The variable has an
|
|
2516
|
-
* identifier name (provided by its id) and a value. A variable is optionally accompanied by a variable type. One
|
|
2517
|
-
* or more variables can be associated with a collection and can be referred from anywhere else in the collection
|
|
2518
|
-
* using the double-brace {{variable-id}} format. Properties can then use the `.toObjectResolved` function to
|
|
2519
|
-
* procure an object representation of the property with all variable references replaced by corresponding values.
|
|
2520
|
-
* @param [definition] - Specify the initial value and type of the variable.
|
|
2521
|
-
*/
|
|
2522
|
-
export class Variable extends Property {
|
|
2523
|
-
constructor(definition?: Variable.definition);
|
|
2524
|
-
type: Variable.types;
|
|
2525
|
-
value: any;
|
|
2526
|
-
/**
|
|
2527
|
-
* The name of the variable. This is used for referencing this variable from other locations and scripts
|
|
2528
|
-
*/
|
|
2529
|
-
key: string;
|
|
2530
|
-
/**
|
|
2531
|
-
* Gets the value of the variable.
|
|
2532
|
-
*/
|
|
2533
|
-
get(): Variable.types;
|
|
2534
|
-
/**
|
|
2535
|
-
* Sets the value of the variable.
|
|
2536
|
-
* @param value - -
|
|
2537
|
-
*/
|
|
2538
|
-
set(value: any): void;
|
|
2539
|
-
/**
|
|
2540
|
-
* An alias of this.get and this.set.
|
|
2541
|
-
* @param [value] - -
|
|
2542
|
-
*/
|
|
2543
|
-
valueOf(value?: any): any;
|
|
2544
|
-
/**
|
|
2545
|
-
* Returns the stringified value of the variable.
|
|
2546
|
-
*/
|
|
2547
|
-
toString(): string;
|
|
2548
|
-
/**
|
|
2549
|
-
* Typecasts a value to the Variable.types of this Variable. Returns the value of the variable
|
|
2550
|
-
* converted to the type specified in Variable.type.
|
|
2551
|
-
* @param value - -
|
|
2552
|
-
*/
|
|
2553
|
-
cast(value: any): any;
|
|
2554
|
-
/**
|
|
2555
|
-
* Sets or gets the type of the value.
|
|
2556
|
-
* @param typeName - -
|
|
2557
|
-
* @param _noCast - -
|
|
2558
|
-
* @returns - returns the current type of the variable from the list of Variable.types
|
|
2559
|
-
*/
|
|
2560
|
-
valueType(typeName: string, _noCast: boolean): string;
|
|
2561
|
-
/**
|
|
2562
|
-
* Updates the type and value of a variable from an object or JSON definition of the variable.
|
|
2563
|
-
* @param options - -
|
|
2564
|
-
*/
|
|
2565
|
-
update(options: Variable.definition): void;
|
|
2566
|
-
/**
|
|
2567
|
-
* @param obj - -
|
|
2568
|
-
*/
|
|
2569
|
-
static isVariable(obj: any): boolean;
|
|
2570
|
-
/**
|
|
2571
|
-
* This (optional) flag denotes whether this property is disabled or not. Usually, this is helpful when a
|
|
2572
|
-
* property is part of a PropertyList. For example, in a PropertyList of Headers, the ones
|
|
2573
|
-
* that are disabled can be filtered out and not processed.
|
|
2574
|
-
*/
|
|
2575
|
-
disabled: boolean;
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
export namespace Version {
|
|
2579
|
-
type definition = any | string;
|
|
2580
|
-
}
|
|
2581
|
-
|
|
2582
|
-
/**
|
|
2583
|
-
* Defines a Version.
|
|
2584
|
-
* @param definition - -
|
|
2585
|
-
*/
|
|
2586
|
-
export class Version extends PropertyBase {
|
|
2587
|
-
constructor(definition: Version.definition);
|
|
2588
|
-
/**
|
|
2589
|
-
* Set the version value as string or object with separate components of version
|
|
2590
|
-
* @param value - -
|
|
2591
|
-
*/
|
|
2592
|
-
set(value: any | string): void;
|
|
2593
|
-
/**
|
|
2594
|
-
* The raw URL string. If Version.set is called with a string parameter, the string is saved here
|
|
2595
|
-
* before parsing various Version components.
|
|
2596
|
-
*/
|
|
2597
|
-
raw: string;
|
|
2598
|
-
major: string;
|
|
2599
|
-
minor: string;
|
|
2600
|
-
patch: string;
|
|
2601
|
-
prerelease: string;
|
|
2602
|
-
build: string;
|
|
2603
|
-
string: string;
|
|
2604
|
-
}
|
|
2605
|
-
|
|
2606
|
-
/**
|
|
2607
|
-
* UrlMatchPattern is a list of UrlMatchPatterns.
|
|
2608
|
-
* This allows you to test for any url over a list of match patterns.
|
|
2609
|
-
* @example
|
|
2610
|
-
* An example UrlMatchPatternList
|
|
2611
|
-
* var matchPatternList = new UrlMatchPatternList(['https://*.google.com/*']);
|
|
2612
|
-
* @param parent - -
|
|
2613
|
-
* @param list - -
|
|
2614
|
-
*/
|
|
2615
|
-
export class UrlMatchPatternList extends PropertyList<UrlMatchPattern> {
|
|
2616
|
-
constructor(parent: any, list: string[]);
|
|
2617
|
-
/**
|
|
2618
|
-
* Tests the url string with the match pattern list provided to see if it matches any of it.
|
|
2619
|
-
* Follows the https://developer.chrome.com/extensions/match_patterns pattern for pattern validation and matching
|
|
2620
|
-
* @param [urlStr] - The url string for which the proxy match needs to be done.
|
|
2621
|
-
*/
|
|
2622
|
-
test(urlStr?: string): boolean;
|
|
2623
|
-
}
|
|
2624
|
-
|
|
2625
|
-
export namespace UrlMatchPattern {
|
|
2626
|
-
/**
|
|
2627
|
-
* @property pattern - The url match pattern string
|
|
2628
|
-
*/
|
|
2629
|
-
type definition = {
|
|
2630
|
-
pattern: string;
|
|
2631
|
-
};
|
|
2632
|
-
}
|
|
2633
|
-
|
|
2634
|
-
/**
|
|
2635
|
-
* UrlMatchPattern allows to create rules to define Urls to match for.
|
|
2636
|
-
* It is based on Google's Match Pattern - https://developer.chrome.com/extensions/match_patterns
|
|
2637
|
-
* @example
|
|
2638
|
-
* An example UrlMatchPattern
|
|
2639
|
-
* var matchPattern = new UrlMatchPattern('https://*.google.com/*');
|
|
2640
|
-
* @param options - -
|
|
2641
|
-
*/
|
|
2642
|
-
export class UrlMatchPattern extends Property {
|
|
2643
|
-
constructor(options: UrlMatchPattern.definition);
|
|
2644
|
-
/**
|
|
2645
|
-
* The url match pattern string
|
|
2646
|
-
*/
|
|
2647
|
-
static pattern: string;
|
|
2648
|
-
/**
|
|
2649
|
-
* Assigns the given properties to the UrlMatchPattern.
|
|
2650
|
-
* @param options - -
|
|
2651
|
-
*/
|
|
2652
|
-
update(options: any): void;
|
|
2653
|
-
/**
|
|
2654
|
-
* Tests if the given protocol string, is allowed by the pattern.
|
|
2655
|
-
* @param [protocol] - The protocol to be checked if the pattern allows.
|
|
2656
|
-
*/
|
|
2657
|
-
testProtocol(protocol?: string): boolean;
|
|
2658
|
-
/**
|
|
2659
|
-
* Returns the protocols supported
|
|
2660
|
-
*/
|
|
2661
|
-
getProtocols(): string[];
|
|
2662
|
-
/**
|
|
2663
|
-
* Tests if the given host string, is allowed by the pattern.
|
|
2664
|
-
* @param [host] - The host to be checked if the pattern allows.
|
|
2665
|
-
*/
|
|
2666
|
-
testHost(host?: string): boolean;
|
|
2667
|
-
/**
|
|
2668
|
-
* Tests if the current pattern allows the given port.
|
|
2669
|
-
* @param port - The port to be checked if the pattern allows.
|
|
2670
|
-
* @param protocol - Protocol to refer default port.
|
|
2671
|
-
*/
|
|
2672
|
-
testPort(port: string, protocol: string): boolean;
|
|
2673
|
-
/**
|
|
2674
|
-
* Tests if the current pattern allows the given path.
|
|
2675
|
-
* @param [path] - The path to be checked if the pattern allows.
|
|
2676
|
-
*/
|
|
2677
|
-
testPath(path?: string): boolean;
|
|
2678
|
-
/**
|
|
2679
|
-
* Tests the url string with the match pattern provided.
|
|
2680
|
-
* Follows the https://developer.chrome.com/extensions/match_patterns pattern for pattern validation and matching
|
|
2681
|
-
* @param [urlStr] - The url string for which the proxy match needs to be done.
|
|
2682
|
-
*/
|
|
2683
|
-
test(urlStr?: string): boolean;
|
|
2684
|
-
/**
|
|
2685
|
-
* Returns a string representation of the match pattern
|
|
2686
|
-
* @returns pattern
|
|
2687
|
-
*/
|
|
2688
|
-
toString(): string;
|
|
2689
|
-
/**
|
|
2690
|
-
* Returns the JSON representation.
|
|
2691
|
-
*/
|
|
2692
|
-
toJSON(): any;
|
|
2693
|
-
/**
|
|
2694
|
-
* Multiple protocols in the match pattern should be separated by this string
|
|
2695
|
-
*/
|
|
2696
|
-
static readonly PROTOCOL_DELIMITER: string;
|
|
2697
|
-
/**
|
|
2698
|
-
* String representation for matching all urls -
|
|
2699
|
-
*/
|
|
2700
|
-
static readonly MATCH_ALL_URLS: string;
|
|
2701
|
-
}
|
|
2702
|
-
}
|