implement types and tests

This commit is contained in:
Kyle Buzby
2018-03-11 21:02:53 -05:00
parent 63ca62a96b
commit 45b3a22d74
2 changed files with 1133 additions and 257 deletions
+277 -245
View File
@@ -2,139 +2,140 @@
// Project: https://github.com/postmanlabs/postman-collection
// Definitions by: Kyle Buzby <https://github.com/kbuzby>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="node" />
export class PropertyBase {
constructor(definition: any);
export interface PropertyBaseDefinition {
description?: string | DescriptionDefinition;
}
findInParents(property: string, customizer?: (item: any) => boolean): PropertyBase ;
export class PropertyBase<TDefinition> implements PropertyBaseDefinition {
description?: string | DescriptionDefinition;
findParentContaining(property: any, customizer: (item: any) => boolean): PropertyBase;
constructor(definition?: PropertyBaseDefinition | {info: PropertyBaseDefinition} | string);
findInParents(property: string, customizer?: (item: PropertyBase<PropertyBaseDefinition>) => boolean): PropertyBase<PropertyBaseDefinition> ;
findParentContaining(property: any, customizer: (item: PropertyBase<PropertyBaseDefinition>) => boolean): PropertyBase<PropertyBaseDefinition>;
forEachParent(iterator: (item: any) => void): void;
forEachParent(options: any /* TODO | boolean*/, iterator: (item: any) => void): void;
forEachParent(options: {withRoot: boolean}, iterator: (item: any) => void): void;
meta(): any;
parent(): any;
parent(): PropertyBase<PropertyBaseDefinition> | undefined;
setParent(parent: any): void;
setParent(parent: PropertyBase<PropertyBaseDefinition>): void;
toJSON(): any;
toJSON(): TDefinition;
static propertyIsMeta(value: any, key: any): any;
static propertyIsMeta(_value: any, key: string): boolean;
static propertyUnprefixMeta(value: any, key: any): any;
static propertyUnprefixMeta(_value: any, key: string): string;
static toJSON(obj: any): any;
}
export interface PropertyDefinition {
export interface PropertyDefinition extends PropertyBaseDefinition {
id?: string;
name?: string;
disabled?: boolean;
}
export class Property extends PropertyBase implements PropertyDefinition {
auth: RequestAuth;
export class Property<TDefinition> extends PropertyBase<TDefinition> implements PropertyDefinition {
disabled: boolean;
id: string;
name: string;
constructor(definition?: PropertyDefinition);
constructor(definition?: TDefinition | {info: TDefinition, disabled: boolean});
describe(content: string, type?: string): void;
toObjectResolved(scope: any, overrides: any, options: any): any;
toObjectResolved(scope: {variables: VariableList} | null, overrides: any[], options?: {ignoreOwnVariables: boolean}): TDefinition;
static replaceSubstitutions(str: string, variables: VariableList | VariableList[]): string;
static replaceSubstitutionsIn(obj: any, variables: VariableList[], mutate: boolean): any;
static replaceSubstitutionsIn<T>(obj: T, variables: VariableList[], mutate: boolean): T;
}
export interface CertificateDefinition extends PropertyDefinition {
name?: string;
matches?: any[];
key?: any;
cert?: any;
matches?: string[] | UrlMatchPatternList;
key?: {src?: string} | string;
cert?: {src?: string} | string;
passphrase?: string;
}
export class Certificate extends Property implements CertificateDefinition {
cert: any;
id: string;
key: any;
matches: any[];
name: string;
export class Certificate extends Property<CertificateDefinition> implements CertificateDefinition {
cert: {src?: string};
key: {src?: string};
matches: UrlMatchPatternList;
passphrase: string;
constructor(options: any);
constructor(options: CertificateDefinition);
canApplyTo(url: string | Url): any;
toJSON(): CertificateDefinition;
canApplyTo(url: string | Url): boolean;
update(options: CertificateDefinition): void;
static isCertificate(obj: any): boolean;
}
export class PropertyList<TElement> {
constructor(type: any, parent: any, populate: any);
export class PropertyList<TElement> extends PropertyBase<PropertyBaseDefinition> {
constructor(type: string, parent: any, populate: TElement[]);
add(item: TElement): void;
all(): any;
all(): TElement[];
append(item: TElement): any;
append(item: TElement): void;
assimilate(source: PropertyList<TElement> | any[], prune: boolean): void;
assimilate(source: PropertyList<TElement> | TElement[], prune: boolean): void;
clear(): void;
count(): number;
each(iterator: any, context: any): void;
each(iterator: (item: TElement) => void, context?: any): void;
eachParent(iterator: any, context?: any): void;
eachParent(iterator: (item: any) => void, context?: any): void;
filter(rule: any, context: any): any;
filter(rule: (item: TElement) => boolean, context: any): TElement[];
find(rule: any, context?: any): Item | ItemGroup<TElement>;
find(rule: (item: TElement) => boolean, context: any): TElement;
get(key: /*TODO string |*/ any): TElement;
get(key: string): TElement | undefined;
has(item: string | TElement, value?: any): boolean;
idx(index: number): TElement;
indexOf(item: /*TODO string |*/ any): number;
indexOf(item: string): number;
insert(item: TElement, before: TElement | string): void;
insertAfter(item: TElement, after: TElement | string): any;
insertAfter(item: TElement, after: TElement | string): void;
map(iterator: any, context: any): any;
map(iterator: (item: TElement) => any, context?: any): any;
one(id: string): TElement;
populate(items: any): void;
populate(items: TElement[]): void;
prepend(item: TElement): any;
prepend(item: TElement): void;
remove(predicate: any /*TODO | string | TElement*/, context: any): any;
remove(predicate: ((item: TElement) => boolean) | string | TElement, context: any): void;
repopulate(items: any): void;
toJSON(): any;
toObject(excludeDisabled?: any, caseSensitive?: any, multiValue?: any, sanitizeKeys?: any): any;
toObject(excludeDisabled?: boolean, caseSensitive?: boolean, multiValue?: boolean, sanitizeKeys?: boolean): any;
toString(): string;
upsert(item: TElement): boolean | null;
static isPropertyList(obj: any): any;
static isPropertyList(obj: any): boolean;
}
export class CertificateList extends PropertyList<Certificate> {
@@ -151,17 +152,18 @@ export interface ItemGroupDefinition extends PropertyDefinition {
event?: EventDefinition[];
}
export class ItemGroup<TItem> extends Property {
auth: RequestAuth;
export class ItemGroup<TItem> extends Property<ItemGroupDefinition> {
auth?: RequestAuth;
items: PropertyList<TItem>;
events: EventList;
constructor(definition?: ItemGroupDefinition);
authorizeRequestsUsing(type: any, options: any): void; // TODO add better types for parameters
authorizeRequestsUsing(type: string | RequestAuthDefinition, options?: VariableList): void;
forEachItem(callback: any): any;
forEachItem(callback: (el: TItem) => void): void;
forEachItemGroup(callback: any): void;
forEachItemGroup(callback: (el: ItemGroup<TItem>) => void): void;
oneDeep(idOrName: string): TItem;
@@ -174,25 +176,21 @@ export interface CollectionDefinition extends ItemGroupDefinition {
name?: string;
version?: string;
};
item?: Array<ItemDefinition | ItemGroupDefinition>;
variable?: VariableDefinition;
auth?: RequestAuthDefinition;
event?: EventDefinition[];
version?: string | Version;
}
export class Collection extends ItemGroup<Request> implements CollectionDefinition {
export class Collection extends ItemGroup<Request> {
events: EventList;
variables: VariableList;
version: Version;
version?: Version;
constructor(definition?: CollectionDefinition, environments?: any[]);
syncVariablesFrom(obj: any, track?: boolean): any;
syncVariablesTo(obj?: any): any;
syncVariablesTo(obj: any): any;
toJSON(): any;
toJSON(): CollectionDefinition;
static isCollection(obj: any): boolean;
}
@@ -202,8 +200,8 @@ export interface CookieDefinition {
value?: string;
expires?: string | Date;
maxAge?: number;
domain?: string;
path?: string;
domain: string;
path: string;
secure?: boolean;
httpOnly?: boolean;
hostOnly?: boolean;
@@ -211,67 +209,66 @@ export interface CookieDefinition {
extensions?: Array<{key: string; value: string}>;
}
export class Cookie extends PropertyBase implements CookieDefinition {
export class Cookie extends PropertyBase<CookieDefinition> implements CookieDefinition {
domain: string;
expires: Date | string;
extensions: Array<{key: string; value: string}>;
hostOnly: any;
httpOnly: any;
maxAge: number;
name: string;
expires: Date;
extensions?: Array<{key: string; value: string}>;
hostOnly?: boolean;
httpOnly?: boolean;
maxAge?: number;
path: string;
secure: any;
session: any;
value: string;
secure?: boolean;
session?: boolean;
value?: string;
constructor(options?: CookieDefinition);
update(options: any): void;
update(options: CookieDefinition): void;
valueOf(): string;
static isCookie(obj: any): boolean;
static parse(str: string): any;
static parse(str: string): CookieDefinition;
static splitParam(param: any): any;
static splitParam(param: string): {key: string, value: string | boolean };
}
export class CookieList extends PropertyList<Cookie> {
constructor(parent: any, cookies: any[]);
constructor(parent: any, cookies: Cookie[]);
static isCookieList(obj: any): boolean;
}
export interface DescriptionDefinition {
content: string;
format: string;
type?: string;
}
export class Description implements DescriptionDefinition {
format: string; // TODO huh?
content: string;
type: string;
constructor(definition?: DescriptionDefinition);
constructor(definition?: DescriptionDefinition | string);
toJSON(): any;
toJSON(): DescriptionDefinition;
toString(): string;
update(content: string | DescriptionDefinition, type?: string): void;
update(content: DescriptionDefinition): void;
update(content: string, type?: string): void;
static isDescription(obj: any): boolean;
}
export interface EventDefinition extends PropertyDefinition {
listen: string;
script: string | Script;
listen?: string;
script: string | string[] | ScriptDefinition | Script;
}
export class Event extends Property implements EventDefinition {
listen: string;
script: string;
export class Event extends Property<EventDefinition> implements EventDefinition {
listen?: string;
script: Script;
constructor(definition: EventDefinition);
@@ -279,7 +276,7 @@ export class Event extends Property implements EventDefinition {
}
export class EventList extends PropertyList<Event> {
constructor(parent: any, populate: any[]);
constructor(parent: any, populate: Event[]);
listeners(name: string): Event[];
@@ -289,16 +286,13 @@ export class EventList extends PropertyList<Event> {
}
export interface FormParamDefinition extends PropertyDefinition {
key: string;
value: string;
key?: string;
value?: any;
}
export class FormParam extends Property implements FormParamDefinition {
export class FormParam extends Property<FormParamDefinition> implements FormParamDefinition {
key: string;
value: string;
static _postman_propertyAllowsMultipleValues: boolean;
static _postman_propertyIndex: string;
value: any;
constructor(options: FormParamDefinition);
@@ -310,19 +304,20 @@ export class FormParam extends Property implements FormParamDefinition {
}
export interface HeaderDefinition extends PropertyDefinition {
key: string;
value: string;
key?: string;
value?: string;
system?: boolean;
}
export class Header extends Property implements HeaderDefinition {
export class Header extends Property<HeaderDefinition> implements HeaderDefinition {
key: string;
value: string;
constructor(options: HeaderDefinition | string, name?: string);
constructor(options: string | HeaderDefinition, name?: string)
toString(): string;
update(options: any): void;
update(options: HeaderDefinition): void;
valueOf(): string;
@@ -334,9 +329,9 @@ export class Header extends Property implements HeaderDefinition {
static parseSingle(header: string): HeaderDefinition;
static unparse(headers: HeaderList | any[], separator?: string): string;
static unparse(headers: HeaderList | HeaderDefinition[], separator?: string): string;
static unparseSingle(header: Header): string;
static unparseSingle(header: HeaderDefinition): string;
}
export class HeaderList extends PropertyList<Header> {
@@ -353,35 +348,34 @@ export interface ItemDefinition extends PropertyDefinition {
events?: EventDefinition[];
}
export class Item extends Property implements ItemDefinition {
events: EventDefinition[];
export class Item extends Property<ItemDefinition> {
events: EventList;
request: Request;
responses: ResponseDefinition[];
responses: PropertyList<Response>;
constructor(definition?: ItemDefinition);
authorizeRequestUsing(type: string | RequestAuthDefinition, options?: VariableList): any;
authorizeRequestUsing(type: string | RequestAuthDefinition, options?: VariableList): void;
getAuth(): RequestAuth;
getEvents(name: string): Event[];
getEvents(name?: string): Event[];
static isItem(obj: any): boolean;
}
export interface ProxyConfigDefinition extends PropertyDefinition {
match?: string;
match?: string | {pattern: string} | UrlMatchPattern;
host?: string;
port?: number;
tunnel?: boolean;
disabled?: boolean;
}
export class ProxyConfig extends Property implements ProxyConfigDefinition {
static host: string;
static match: string;
static port: number;
static tunnel: boolean;
export class ProxyConfig extends Property<ProxyConfigDefinition> implements ProxyConfigDefinition {
host: string;
match: UrlMatchPattern;
port: number;
tunnel: boolean;
constructor(options?: ProxyConfigDefinition);
@@ -389,7 +383,7 @@ export class ProxyConfig extends Property implements ProxyConfigDefinition {
getProxyUrl(): string;
test(urlStr?: string): any;
test(urlStr?: string): boolean;
update(options: ProxyConfigDefinition): void;
@@ -401,22 +395,24 @@ export class ProxyConfig extends Property implements ProxyConfigDefinition {
export class ProxyConfigList extends PropertyList<ProxyConfig> {
constructor(parent: any, populate: ProxyConfig[]);
resolve(url?: Url): ProxyConfigDefinition;
resolve(url: string | Url): ProxyConfig;
static isProxyConfigList(obj: any): boolean;
}
export interface QueryParamDefinition extends PropertyDefinition {
key: string;
value: string;
key: string | null;
value: string | null;
system?: boolean;
}
export class QueryParam extends Property implements QueryParamDefinition {
export class QueryParam extends Property<QueryParamDefinition> implements QueryParamDefinition {
static _postman_propertyAllowsMultipleValues: boolean;
static _postman_propertyIndexKey: string;
key: string;
value: string;
key: string | null;
value: string | null;
system?: boolean;
constructor(options: QueryParamDefinition | string);
@@ -424,61 +420,59 @@ export class QueryParam extends Property implements QueryParamDefinition {
update(param: string | {key: string, value?: string}): void;
valueOf(): any;
valueOf(): string;
static parse(query: string): any[];
static parse(query: string): QueryParamDefinition[];
static parseSingle(param: string, idx: number, all: string[]): any;
static parseSingle(param: string, idx: number, all: string[]): QueryParamDefinition;
static unparse(params: any, options?: {encode?: boolean | null, ignoreDisabled?: boolean | null}): string;
static unparse(params: QueryParamDefinition[], options?: {encode?: boolean, ignoreDisabled?: boolean}): string;
static unparseSingle(obj: any, encode: boolean): string;
static unparseSingle(obj: QueryParamDefinition, encode: boolean): string;
}
export interface RequestDefinition extends PropertyDefinition {
url: string | Url;
method: string;
method?: string;
header?: HeaderDefinition;
body?: RequestBody;
auth: RequestAuthDefinition;
proxy: ProxyConfigDefinition;
auth?: RequestAuthDefinition;
proxy?: ProxyConfigDefinition;
certificate?: CertificateDefinition;
}
export class Request extends Property implements RequestDefinition {
auth: RequestAuth;
export class Request extends Property<RequestDefinition> implements RequestDefinition {
auth?: RequestAuth;
body?: RequestBody;
certificate?: Certificate;
headers: HeaderList;
method: string;
proxy: ProxyConfig;
proxy?: ProxyConfig;
url: Url;
constructor(options: RequestDefinition);
constructor(options: RequestDefinition | string);
addHeader(header: Header | HeaderDefinition): void;
addQueryParams(params: string | QueryParam[]): void;
addQueryParams(params: string | QueryParamDefinition[]): void;
authorize(): Request;
authorizeUsing(type: string | RequestAuthDefinition, options?: VariableList): void;
authorizeUsing(type: string | RequestAuthDefinition | null, options?: VariableList): void;
clone(): Request;
forEachHeader(callback: any): void;
forEachHeader(callback: (header: Header, context: Request) => void): void;
getHeaders(options?: {ignoreCase?: boolean, enabled?: boolean}): any;
removeHeader(toRemove: string | Header, options: {ignoreCase: boolean}): any;
removeHeader(toRemove: string | Header, options?: {ignoreCase: boolean}): void;
removeQueryParams(params: string | string[]): void;
removeQueryParams(params: string | string[] | QueryParamDefinition[]): void;
toJSON(): any;
toJSON(): RequestDefinition;
update(options: RequestDefinition): void;
upsertHeader(header: any): void;
upsertHeader(header: HeaderDefinition): void;
static isRequest(obj: any): boolean;
}
@@ -487,10 +481,10 @@ export interface RequestAuthDefinition extends PropertyDefinition {
type?: string;
}
export class RequestAuth extends Property implements RequestAuthDefinition {
export class RequestAuth extends Property<RequestAuthDefinition> implements RequestAuthDefinition {
type: string;
constructor(options: RequestAuthDefinition, parent?: Property | PropertyList<RequestAuth>);
constructor(options: RequestAuthDefinition, parent?: Property<PropertyDefinition> | PropertyList<RequestAuth>);
clear(type: string): void;
@@ -498,67 +492,76 @@ export class RequestAuth extends Property implements RequestAuthDefinition {
parameters(): VariableList;
update(options: /*TODO VariableList | any[] |*/ any, type?: string): void;
update(options: VariableList | Array<{key: string, value: string}> | {key: string, value: string}, type?: string): void;
use(type: string, options: VariableList): void;
use(type: string, options: VariableList | Array<{key: string, value: string}> | {key: string, value: string}): void;
static isValidType(type: any): boolean;
}
export class RequestBody extends PropertyBase {
export interface RequestBodyDefinition extends PropertyBaseDefinition {
mode: string;
raw?: string;
urlencoded?: QueryParamDefinition[] | PropertyList<QueryParam> | string;
file?: string | {src: string};
formdata?: FormParamDefinition[] | PropertyList<FormParam>;
}
export class RequestBody extends PropertyBase<RequestBodyDefinition> implements RequestBodyDefinition {
static MODES: {
raw: string;
formadata: string;
formdata: string;
urlencoded: string;
file: string;
};
file: string;
formdata: PropertyList<FormParam>;
file?: {src: string};
formdata?: PropertyList<FormParam>;
mode: string;
raw: string;
urlencoded: PropertyList<QueryParam>;
raw?: string;
urlencoded?: PropertyList<QueryParam>;
constructor(options: any);
constructor(options: RequestBodyDefinition);
isEmpty(): boolean;
toString(): string;
update(options: any): void;
update(options: RequestBodyDefinition): void;
}
export interface ResponseDefinition extends PropertyDefinition {
code: number;
reason?: string;
header?: HeaderDefinition[];
cookie?: CookieDefinition[];
body?: string;
stream?: Buffer | Uint8Array;
responseTime: number;
originalRequest?: RequestDefinition;
}
export class Response extends Property implements ResponseDefinition {
body: string;
export class Response extends Property<ResponseDefinition> implements ResponseDefinition {
body?: string;
code: number;
cookies: CookieList;
headers: HeaderList;
originalRequest: Request;
originalRequest?: Request;
responseTime: number;
status: string;
reason?: string;
stream?: Buffer | Uint8Array;
responseSize?: number;
constructor(options: ResponseDefinition);
dataURI(): string;
details(): any;
details(): {name: string, detail: string, code: number, standardName: string} | undefined;
encoding(): any;
encoding(): {format: string, source: string};
json(reviver?: any, strict?: boolean): any;
mime(contentType: any, contentDisposition: any): any; // TODO ??
reason(): string;
size(): number;
@@ -566,130 +569,143 @@ export class Response extends Property implements ResponseDefinition {
toJSON(): any;
update(options: any): void;
update(options: ResponseDefinition): void;
static createFromNode(response: any, cookies: any): any;
static createFromNode(response: {
body: string | Buffer | Uint8Array,
headers?: HeaderDefinition[],
statusCode: number,
statusMessage?: string,
elapsedTime: number
}, cookies: CookieDefinition[]): Response;
static isResponse(obj: any): boolean;
static mimeInfo(type: any, disposition: any): any; // TODO ??
}
export class Script extends Property {
exec: string[];
src: Url;
export interface ScriptDefinition extends PropertyDefinition {
type?: string;
src?: string | Url;
exec?: string | string[];
}
export class Script extends Property<ScriptDefinition> implements ScriptDefinition {
exec?: string[];
src?: Url;
type: string;
constructor(options: any);
constructor(options?: ScriptDefinition | string | string[]);
toSource(): string;
toSource(): string | undefined;
update(options?: {type?: string, src?: string, exec?: string | string[]}): void;
update(options: ScriptDefinition | string | string[]): void;
static isScript(obj: any): boolean;
}
export class Url extends PropertyBase {
auth: string;
hash: string;
host: string[];
export interface UrlDefinition extends PropertyBaseDefinition {
auth?: {user: string, password: string};
hash?: string;
host?: string[] | string;
path: string[] | string;
port?: string;
query?: QueryParamDefinition[] | PropertyList<QueryParam> | string;
variable?: VariableDefinition[];
protocol?: string;
}
export class Url extends PropertyBase<UrlDefinition> implements UrlDefinition {
auth?: {user: string, password: string};
hash?: string;
host?: string[];
path: string[];
port: string;
protocol: string;
port?: string;
protocol?: string;
query: PropertyList<QueryParam>;
variables: VariableList;
constructor(options: any /*TODO| string*/);
constructor(options: UrlDefinition | string);
addQueryParams(params: any /*TODO | string*/): void;
addQueryParams(params: QueryParamDefinition[] | string): void;
getHost(): string;
getOAuth1BaseUrl(): any;
getOAuth1BaseUrl(): string;
getPath(options?: {unresolved: boolean}): string;
getPathWithQuery(): any /*TODO | string*/;
getPathWithQuery(): string;
getQueryString(options?: {encode: boolean | null, ignoredDisabled: boolean | null} | null): string;
getQueryString(options?: {encode?: boolean, ignoredDisabled?: boolean}): string;
getRaw(): string;
getRemote(options: {forcePort: boolean}): string;
getRemote(options?: {forcePort: boolean}): string;
removeQueryParams(params: QueryParam[] | string[] | string): void;
removeQueryParams(params: QueryParamDefinition[] | QueryParamDefinition | string[] | string): void;
toString(forceProtocol?: boolean): string;
update(url: /*TODO string |*/ any): void;
update(url: UrlDefinition | string): void;
static isUrl(obj: any): boolean;
static parse(url: string): any;
static parse(url: string): UrlDefinition;
}
/* No documentation for this right now?
export class UrlMatchPattern {
constructor(options: any, ...args: any[]);
pattern?: string;
createMatchPattern(): any;
constructor(options: string | {pattern: string});
getProtocols(): any;
createMatchPattern(): {protocols: string[], host: string, path: RegExp} | undefined;
globPatternToRegexp(pattern: any): any;
getProtocols(): string[];
matchAbsoluteHostPattern(matchRegexObject: any, remote: any): any;
globPatternToRegexp(pattern: string): RegExp;
matchAnyHost(matchRegexObject: any): any;
matchAbsoluteHostPattern(matchRegexObject: {protocols: string[], host: string, path: RegExp}, remote: string): boolean;
matchSuffixHostPattern(matchRegexObject: any, remote: any): any;
matchAnyHost(matchRegexObject: {protocols: string[], host: string, path: RegExp}): boolean;
test(urlStr: any): any;
matchSuffixHostPattern(matchRegexObject: {protocols: string[], host: string, path: RegExp}, remote: string): boolean;
testHost(host: any): any;
test(urlStr: string): boolean;
testPath(path: any): any;
testHost(host: string): boolean;
testProtocol(protocol: any): any;
testPath(path: string): boolean;
toJSON(): any;
testProtocol(protocol: string): boolean;
toString(): any;
toJSON(): {pattern: string};
update(options: any): void;
toString(): string;
update(options: {pattern: string}): void;
static MATCH_ALL_URLS: string;
static PROTOCOL_DELIMITER: string;
}
export class UrlMatchPatternList extends PropertyList<UrlMatchPattern> {
constructor(parent: any, list: any);
constructor(parent: Property<PropertyDefinition>, list: string[]);
test(urlStr: any): any;
}*/
test(urlStr: string): boolean;
}
export interface VariableDefinition extends PropertyDefinition {
value?: any;
type?: VariableTypes;
type?: string;
key?: string;
}
export enum VariableTypes {
string = 'string',
boolean = 'boolean',
number = 'number',
json = 'json',
any = 'any'
}
export class Variable extends Property implements VariableDefinition {
key: string;
type: VariableTypes;
export class Variable extends Property<VariableDefinition> implements VariableDefinition {
key?: string;
type: string;
value: any;
constructor(definition?: VariableDefinition);
constructor(definition?: VariableDefinition | {[index: string]: VariableDefinition});
cast(value: any): any;
@@ -705,39 +721,45 @@ export class Variable extends Property implements VariableDefinition {
update(options: VariableDefinition): void;
valueOf(value?: any): any;
valueOf(value: any): any;
valueType(typeName: string, _noCast: boolean): string;
static isVariable(obj: any): boolean;
static types: {
string: StringConstructor;
boolean: BooleanConstructor;
number: NumberConstructor;
json: {in: (val: any) => string, out: (val: string) => any};
any: {in: <T>(val: T) => T, out: <T>(val: T) => T};
};
}
export class VariableList extends PropertyList<Variable> {
constructor(parent: Property, populate: any);
constructor(parent: Property<PropertyDefinition>, populate: Variable[]);
replace(str: string, overrides?: any): string;
replace(str: string, overrides?: VariableList): string;
substitute(obj: any, overrides?: any[] | null, mutate?: boolean): any;
substitute<T>(obj: T, overrides?: VariableList, mutate?: boolean): T;
syncFromObject(obj: any, track?: boolean, prune?: boolean): any;
syncFromObject(obj: {[key: string]: VariableDefinition}, track?: boolean, prune?: boolean): {created: string[], updated: string[], deleted: string[]} | undefined;
syncToObject(obj?: any): any;
syncToObject(obj?: {[key: string]: VariableDefinition}): {[key: string]: VariableDefinition};
static isVariableList(obj: any): boolean;
}
export interface VariableScopeDefinition extends PropertyDefinition {
id?: string;
name?: string;
values?: VariableDefinition[];
}
export class VariableScope extends Property implements VariableScopeDefinition {
export class VariableScope extends Property<VariableScopeDefinition> implements VariableScopeDefinition {
values?: VariableDefinition[];
constructor(definition: VariableScopeDefinition, layers?: VariableList[]);
constructor(definition: VariableScopeDefinition | VariableList | VariableDefinition[], layers?: VariableList[] | VariableList);
addLayer(list: any): void;
addLayer(list: VariableList): void;
clear(): void;
@@ -745,11 +767,11 @@ export class VariableScope extends Property implements VariableScopeDefinition {
has(variableName: string): boolean;
set(key: string, value: any, type: VariableTypes): void;
set(key: string, value: any, type: string): void;
syncVariablesFrom(obj: any, track: any): any;
syncVariablesFrom(obj: {[key: string]: VariableDefinition}, track?: boolean, prune?: boolean): {created: string[], updated: string[], deleted: string[]} | undefined;
syncVariablesTo(obj: any): any;
syncVariablesTo(obj?: {[key: string]: VariableDefinition}): {[key: string]: VariableDefinition};
toJSON(): any;
@@ -757,23 +779,33 @@ export class VariableScope extends Property implements VariableScopeDefinition {
unset(key: string): void;
variables(): any;
variables(): {[key: string]: VariableDefinition};
static isVariableScope(obj: any): boolean;
}
export class Version extends PropertyBase {
build: string;
major: string;
minor: string;
patch: string;
prerelease: string;
raw: string;
string: string;
export interface VersionDefinition extends PropertyBaseDefinition {
build?: string;
major?: string;
minor?: string;
patch?: string;
prerelease?: string;
raw?: string;
version?: string;
}
constructor(options: any /*TODO | string*/);
export class Version extends PropertyBase<VersionDefinition> implements VersionDefinition {
build?: string;
major?: string;
minor?: string;
patch?: string;
prerelease?: string;
raw?: string;
string?: string;
set(value: any /*TODO | string*/): void;
constructor(options?: VersionDefinition | string);
set(value?: VersionDefinition | string): void;
toString(): string;
}
@@ -1,26 +1,870 @@
import * as pmCollection from 'postman-collection';
// PropertyBaseDefinition tests
const pbDef: pmCollection.PropertyBaseDefinition = {};
pbDef.description; // $ExpectType string | DescriptionDefinition | undefined
// PropertyBase tests
const PropertyBase = pmCollection.PropertyBase;
let pb = new PropertyBase();
pb = new PropertyBase("string definition");
pb = new PropertyBase({description: "string description"});
pb = new PropertyBase({info: {}});
pb = new PropertyBase({info: {description: "string description"}});
pb.description; // $ExpectType string | DescriptionDefinition | undefined
pb.findInParents("string"); // $ExpectType PropertyBase<PropertyBaseDefinition>
pb.findInParents("string", (el) => true); // $ExpectType PropertyBase<PropertyBaseDefinition>
pb.findParentContaining("string", (el) => true); // $ExpectType PropertyBase<PropertyBaseDefinition>
pb.forEachParent((el) => {}); // $ExpectType void
pb.forEachParent({withRoot: true}, (el) => {}); // $ExpectType void
pb.meta(); // $ExpectType any
pb.parent(); // $ExpectType PropertyBase<PropertyBaseDefinition> | undefined
pb.setParent(pb); // $ExpectType void
pb.toJSON(); // $ExpectType {}
PropertyBase.propertyIsMeta(null, "string"); // $ExpectType boolean
PropertyBase.propertyUnprefixMeta(null, "_String"); // $ExpectType string
PropertyBase.toJSON({}); // $ExpectType any
// PropertyDefinition Tests
const propDef: pmCollection.PropertyDefinition = {};
propDef.id; // $ExpectType string | undefined
propDef.name; // $ExpectType string | undefined
propDef.disabled; // $$ExpectType boolean | undefined
propDef.description; // $$ExpectType string | DescriptionDefinition | undefined
// Property Tests
const Property = pmCollection.Property;
let p = new Property();
p = new Property(propDef);
p = new Property({info: propDef, disabled: true});
p.id; // $ExpectType string
p.name; // $ExpectType string
p.disabled; // $ExpectType boolean
p.describe("string"); // $ExpectType void
p.describe("String", "string"); // $ExpectType void
p.toObjectResolved(null, []); // $ExpectType {}
p.toObjectResolved({variables: new pmCollection.VariableList(p, [])}, []); // $ExpectType {}
p.toObjectResolved(null, [], {ignoreOwnVariables: true}); // $ExpectType {}
Property.replaceSubstitutions("string", new pmCollection.VariableList(p, [])); // $ExpectType string
Property.replaceSubstitutionsIn({}, [new pmCollection.VariableList(p, [])], false); // $ExpectType {}
// CertificateDefinition Tests
const certDef: pmCollection.CertificateDefinition = {};
certDef.matches; // $ExpectType string[] | UrlMatchPatternList | undefined
certDef.key; // $ExpectType string | { src?: string | undefined; } | undefined
certDef.cert; // $ExpectType string | { src?: string | undefined; } | undefined
certDef.passphrase; // $ExpectType string | undefined
// Certificate Tests
const certificate = new pmCollection.Certificate({});
certificate.cert; // $ExpectType any
certificate.id; // $ExpectType string
certificate.key; // $ExpectType any
certificate.matches; // $ExpectType any[]
certificate.name; // $ExpectType string
certificate.cert; // $ExpectType { src?: string | undefined; }
certificate.key; // $ExpectType { src?: string | undefined; }
certificate.matches; // $ExpectType UrlMatchPatternList
certificate.passphrase; // $ExpectType string
certificate.auth; // $ExpectType RequestAuth
certificate.disabled; // $ExpectType boolean
certificate.canApplyTo("string"); // $ExpectType any
certificate.canApplyTo(new pmCollection.Url({})); // $ExpectType any
certificate.canApplyTo("string"); // $ExpectType boolean
certificate.canApplyTo(new pmCollection.Url({host: "string", path: "string"})); // $ExpectType boolean
certificate.toJSON(); // $ExpectType CertificateDefinition
certificate.update({}); // $ExpectType void
certificate as pmCollection.Property; // $ExpectType Property
pmCollection.Certificate.isCertificate(certificate); // $ExpectType boolean
// PropertyList Tests
const pList = new pmCollection.PropertyList<pmCollection.Certificate>("Certificate", null, []);
pList.add(certificate); // $ExpectType void
pList.all(); // $ExpectType Certificate[]
pList.append(certificate); // $ExpectType void
pList.assimilate(pList, false); // $ExpectType void
pList.assimilate([certificate], false); // ExpectType void
pList.clear(); // $ExpectType void
pList.count(); // $ExpectType number
pList.each((el: pmCollection.Certificate) => {}); // $ExpectType void
pList.each((el: pmCollection.Certificate) => {}, pList); // $ExpectType void
pList.eachParent((el: any) => {}); // $ExpectType void
pList.eachParent((el: any) => {}, pList); // $ExpectType void
pList.filter((el) => true, pList); // $ExpectType Certificate[]
pList.find((el) => true, pList); // $ExpectType Certificate
pList.get("string"); // $ExpectType Certificate | undefined
pList.has("string"); // $ExpectType boolean
pList.has("string", null); // $ExpectType boolean
pList.has(certificate); // $ExpectType boolean
pList.idx(1); // ExpectType Certificate
pList.indexOf("string"); // ExpectType number
pList.insert(certificate, "string"); // ExpectType void
pList.insert(certificate, certificate); // ExpectType void
pList.insertAfter(certificate, "string"); // ExpectType void
pList.insertAfter(certificate, certificate); // ExpectType void
pList.map((el) => el); // ExpectType any
pList.map((el) => el, pList); // ExpectType any
pList.one("string"); // ExpectType Certificate
pList.populate([]); // ExpectType void
pList.remove((el) => true, pList); // ExpectType void
pList.remove("string", pList); // ExpectType void
pList.remove(certificate, pList); // $ExpectType void
pList.repopulate(null); // $ExpectType void
pList.toJSON(); // $ExpectType any
pList.toObject(true, true, true, true); // $ExpectType any
pList.toString(); // $ExpectType string
pList.upsert(certificate); // $ExpectType boolean | null
pmCollection.PropertyList.isPropertyList(pList); // $ExpectType boolean
// CertificateList Tests
const certList = new pmCollection.CertificateList(null, [pList]);
certList.resolveOne("string"); // $ExpectType CertificateDefinition
pmCollection.CertificateList.isCertificateList(certList); // $ExpectType boolean
// ItemGroupDefinition Tests
const igDef: pmCollection.ItemGroupDefinition = {};
igDef.item; // $ExpectType (ItemGroupDefinition | ItemDefinition)[] | undefined
igDef.auth; // $ExpectType RequestAuthDefinition | undefined
igDef.event; // $ExpectType EventDefinition[] | undefined
// ItemGroup Tests
const ig = new pmCollection.ItemGroup<pmCollection.Certificate>();
ig.auth; // $ExpectType RequestAuth | undefined
ig.items; // $ExpectType PropertyList<Certificate>
ig.events; // $ExpectType EventList
ig.authorizeRequestsUsing("string"); // $ExpectType void
ig.authorizeRequestsUsing({}); // $ExpectType void
ig.authorizeRequestsUsing("string", new pmCollection.VariableList(ig, [])); // $ExpectType void
ig.forEachItem((el) => {}); // $ExpectType void
ig.forEachItemGroup((el) => {}); // $ExpectType void
ig.oneDeep("string"); // $ExpectType Certificate
pmCollection.ItemGroup.isItemGroup(ig); // $ExpectType boolean
// CollectionDefinition Tests
const colDef: pmCollection.CollectionDefinition = {};
colDef.info; // $ExpectType { id?: string | undefined; name?: string | undefined; version?: string | undefined; } | undefined
colDef.variable; // $ExpectType VariableDefinition | undefined
let collection: pmCollection.Collection;
collection = new pmCollection.Collection();
collection = new pmCollection.Collection({});
collection = new pmCollection.Collection({}, []);
collection.events; // $ExpectType EventList
collection.variables; // $ExpectType VariableList
collection.version; // $ExpectType Version | undefined
// TODO update when get to VariableList
collection.syncVariablesFrom({}); // $ExpectType any
// TODO update
collection.syncVariablesFrom({}, true); // ExpectType any
// TODO update
collection.syncVariablesTo({}); // ExpectType any
collection.toJSON(); // $ExpectType CollectionDefinition
pmCollection.Collection.isCollection(collection); // $ExpectType boolean
// CookieDefinition Tests
const cookieDef: pmCollection.CookieDefinition = {
domain: "string",
path: "string"
};
cookieDef.key; // $ExpectType string | undefined
cookieDef.value; // ExpectType string | undefined
cookieDef.expires; // $ExpectType string | Date | undefined
cookieDef.maxAge; // $ExpectType number | undefined
cookieDef.domain; // $ExpectType string
cookieDef.path; // $ExpectType string
cookieDef.secure; // $ExpectType boolean | undefined
cookieDef.httpOnly; // $ExpectType boolean | undefined
cookieDef.hostOnly; // $ExpectType boolean | undefined
cookieDef.session; // $ExpectType boolean | undefined
cookieDef.extensions; // $ExpectType { key: string; value: string; }[] | undefined
// Cookie Tests
let cookie = new pmCollection.Cookie();
cookie = new pmCollection.Cookie(cookieDef);
cookie.domain; // $ExpectType string
cookie.expires; // $ExpectType Date
cookie.extensions; // $ExpectType { key: string; value: string; }[] | undefined
cookie.hostOnly; // $ExpectType boolean | undefined
cookie.httpOnly; // $ExpectType boolean | undefined
cookie.maxAge; // $ExpectType number | undefined
cookie.path; // $ExpectType string
cookie.secure; // $ExpectType boolean | undefined
cookie.session; // $ExpectType boolean | undefined
cookie.value; // $ExpectType string | undefined
cookie.update(cookieDef); // $ExpectType void
cookie.valueOf(); // $ExpectType string
pmCollection.Cookie.isCookie({}); // $ExpectType boolean
pmCollection.Cookie.parse("string"); // $ExpectType CookieDefinition
pmCollection.Cookie.splitParam("string"); // $ExpectType { key: string; value: string | boolean; }
// CookieList Tests
const cookieList = new pmCollection.CookieList(null, [cookie]);
pmCollection.CookieList.isCookieList(cookieList); // $ExpectType boolean
// DescriptionDefinition Tests
const descDef: pmCollection.DescriptionDefinition = {
content: "string",
type: "string"
};
descDef.content; // $ExpectType string
descDef.type; // $ExpectType string | undefined
// Description Tests
let desc = new pmCollection.Description();
desc = new pmCollection.Description("string");
desc = new pmCollection.Description(descDef);
desc.content; // $ExpectType string
desc.type; // $ExpectType string
desc.toJSON(); // $ExpectType DescriptionDefinition
desc.toString(); // $ExpectType string
desc.update("string"); // $ExpectType void
desc.update("string", "string"); // $ExpectType void
desc.update(descDef); // $ExpectType void
pmCollection.Description.isDescription(desc); // $ExpectType boolean
// EventDefinition Tests
const eventDesc: pmCollection.EventDefinition = {
script: "string"
};
eventDesc.listen; // $ExpectType string | undefined
eventDesc.script; // $ExpectType string | string[] | ScriptDefinition | Script
// Event Tests
const event = new pmCollection.Event(eventDesc);
event.listen; // $ExpectType string | undefined
event.script; // $ExpectType Script
event.update(eventDesc); // $ExpectType void
// EventList Tests
const eventList = new pmCollection.EventList(null, [event]);
eventList.listeners("string"); // $ExpectType Event[]
eventList.listenersOwn("string"); // $ExpectType Event[]
pmCollection.EventList.isEventList(eventList); // $ExpectType boolean
// FormParamDefinition Tests
const fpDef: pmCollection.FormParamDefinition = {};
fpDef.key; // $ExpectType string | undefined
fpDef.value; // $ExpectType any
// FormParam Tests
const fp = new pmCollection.FormParam(fpDef);
fp.key; // $ExpectType string
fp.value; // $ExpectType any
fp.toString(); // $ExpectType string
fp.valueOf(); // $ExpectType any
// HeaderDefinition Tests
const headerDef: pmCollection.HeaderDefinition = {
key: "string",
value: "string"
};
headerDef.key; // $ExpectType string | undefined
headerDef.value; // $ExpectType string | undefined
headerDef.system; // $ExpectType boolean | undefined
// Header Tests
let header = new pmCollection.Header("string");
header = new pmCollection.Header("string", "string");
header = new pmCollection.Header(headerDef);
header.key; // $ExpectType string
header.value; // $ExpectType string
header.toString(); // $ExpectType string
header.update(headerDef); // $ExpectType void
header.valueOf(); // $ExpectType string
pmCollection.Header.create("string"); // $ExpectType Header
pmCollection.Header.create("string", "string"); // $ExpectType Header
pmCollection.Header.create(headerDef, "string"); // $ExpectType Header
pmCollection.Header.isHeader(header); // $ExpectType boolean
pmCollection.Header.parse("string"); // $ExpectType HeaderDefinition[]
pmCollection.Header.parseSingle("string"); // $ExpectType HeaderDefinition
pmCollection.Header.unparse(new pmCollection.HeaderList(null, [header])); // $ExpectType string
pmCollection.Header.unparse([headerDef]); // $ExpectType string
pmCollection.Header.unparse([headerDef], "\n"); // $ExpectType string
pmCollection.Header.unparseSingle(headerDef); // $ExpectType string
// HeaderList Tests
const headerList = new pmCollection.HeaderList(null, [header]);
headerList.contentSize(); // $ExpectType number
pmCollection.HeaderList.isHeaderList(headerList); // $ExpectType boolean
// ItemDefinition Tests
const itemDef: pmCollection.ItemDefinition = {};
itemDef.request; // $ExpectType RequestDefinition | undefined
itemDef.responses; // $ExpectType ResponseDefinition[] | undefined
itemDef.events; // $ExpectType EventDefinition[] | undefined
// Item Tests
let item = new pmCollection.Item();
item = new pmCollection.Item(itemDef);
item.events; // $ExpectType EventList
item.request; // $ExpectType Request
item.responses; // $ExpectType PropertyList<Response>
item.authorizeRequestUsing("string"); // $ExpectType void
item.authorizeRequestUsing({}); // $ExpectType void
item.authorizeRequestUsing("string", new pmCollection.VariableList(item, [])); // $ExpectType void
item.getAuth(); // $ExpectType RequestAuth
item.getEvents(); // $ExpectType Event[]
item.getEvents("string"); // $ExpectType Event[]
pmCollection.Item.isItem(item); // $ExpectType boolean
// ProxyConfigDefinition Tests
const proxyConfDef: pmCollection.ProxyConfigDefinition = {};
proxyConfDef.match; // $ExpectType string | { pattern: string; } | UrlMatchPattern | undefined
proxyConfDef.host; // $ExpectType string | undefined
proxyConfDef.port; // $ExpectType number | undefined
proxyConfDef.tunnel; // $ExpectType boolean | undefined
// ProxyConfig Tests
let proxyConf = new pmCollection.ProxyConfig();
proxyConf = new pmCollection.ProxyConfig(proxyConfDef);
proxyConf.host; // $ExpectType string
proxyConf.match; // $ExpectType UrlMatchPattern
proxyConf.port; // $ExpectType number
proxyConf.tunnel; // $ExpectType boolean
proxyConf.getProtocols(); // $ExpectType string[]
proxyConf.getProxyUrl(); // $ExpectType string
proxyConf.test("string"); // $ExpectType boolean
proxyConf.update(proxyConfDef); // $ExpectType void
proxyConf.updateProtocols(["string"]); // $ExpectType void
pmCollection.ProxyConfig.isProxyConfig(proxyConf); // $ExpectType boolean
// ProxyConfigList Tests
const proxyConfigList = new pmCollection.ProxyConfigList(null, [proxyConf]);
proxyConfigList.resolve("string"); // $ExpectType ProxyConfig
proxyConfigList.resolve(new pmCollection.Url({host: "string", path: "string"})); // $ExpectType ProxyConfig
pmCollection.ProxyConfigList.isProxyConfigList(proxyConfigList); // $ExpectType boolean
// QueryParamDefinition Tests
const qpDef: pmCollection.QueryParamDefinition = {
key: null,
value: null
};
qpDef.key; // $ExpectType string | null
qpDef.value; // $ExpectType string | null
qpDef.system; // $ExpectType boolean | undefined
// QueryParam Tests
let qp = new pmCollection.QueryParam("string");
qp = new pmCollection.QueryParam(qpDef);
qp.key; // $ExpectType string | null
qp.value; // $ExpectType string | null
qp.system; // $ExpectType boolean | undefined
qp.toString(); // $ExpectType string
qp.update("string"); // $ExpectType void
qp.update({key: "string"}); // $ExpectType void
qp.update({key: "string", value: "string"}); // $ExpectType void
qp.valueOf(); // $ExpectType string
pmCollection.QueryParam._postman_propertyAllowsMultipleValues; // $ExpectType boolean
pmCollection.QueryParam._postman_propertyIndexKey; // $ExpectType string
pmCollection.QueryParam.parse("string"); // $ExpectType QueryParamDefinition[]
pmCollection.QueryParam.parseSingle("string", 1, ["string"]); // $ExpectType QueryParamDefinition
pmCollection.QueryParam.unparse([qpDef]); // $ExpectType string
pmCollection.QueryParam.unparse([qpDef], {encode: true}); // $ExpectType string
pmCollection.QueryParam.unparse([qpDef], {encode: true, ignoreDisabled: true}); // $ExpectType string
pmCollection.QueryParam.unparseSingle(qpDef, true); // $ExpectType string
// RequestDefinition Tests
const reqDef: pmCollection.RequestDefinition = {
url: "string"
};
reqDef.url; // $ExpectType string | Url
reqDef.method; // $ExpectType string | undefined
reqDef.header; // $ExpectType HeaderDefinition | undefined
reqDef.body; // $ExpectType RequestBody | undefined
reqDef.auth; // $ExpectType RequestAuthDefinition | undefined
reqDef.proxy; // $ExpectType ProxyConfigDefinition | undefined
reqDef.certificate; // $ExpectType CertificateDefinition | undefined
// Request Tests
let req = new pmCollection.Request("string");
req = new pmCollection.Request(reqDef);
req.auth; // $ExpectType RequestAuth | undefined
req.body; // $ExpectType RequestBody | undefined
req.certificate; // $ExpectType Certificate | undefined
req.headers; // $ExpectType HeaderList
req.method; // $ExpectType string
req.proxy; // $ExpectType ProxyConfig | undefined
req.url; // $ExpectType Url
req.update(reqDef); // $ExpectType void
req.authorizeUsing("string"); // $ExpectType void
req.authorizeUsing({}); // $ExpectType void
req.authorizeUsing(null); // $ExpectType void
req.authorizeUsing("string", new pmCollection.VariableList(p, []));
req.getHeaders(); // $ExpectType any
req.getHeaders({ignoreCase: true}); // $ExpectType any
req.getHeaders({enabled: true}); // $ExpectType any
req.getHeaders({ignoreCase: true, enabled: true}); // $ExpectType any
req.forEachHeader((header: pmCollection.Header, context: pmCollection.Request) => {}); // $ExpectType void
req.addHeader(header); // $ExpectType void
req.addHeader(headerDef); // $ExpectType void
req.removeHeader("string"); // $ExpectType void
req.removeHeader(header); // $ExpectType void
req.removeHeader(header, {ignoreCase: true}); // $ExpectType void
req.upsertHeader(headerDef); // $ExpectType void
req.addQueryParams("string"); // $ExpectType void
req.addQueryParams([qpDef]); // $ExpectType void
// TODO check these - they might also need plain qpDef as a parameter
req.removeQueryParams("string"); // $ExpectType void
req.removeQueryParams(["string"]); // $ExpectType void
req.removeQueryParams([qpDef]); // $ExpectType void
req.toJSON(); // $ExpectType RequestDefinition
req.clone(); // $ExpectType Request
pmCollection.Request.isRequest(req); // $ExpectType boolean
// RequestAuthDefinition Tests
const reqAuthDef: pmCollection.RequestAuthDefinition = {};
reqAuthDef.type; // $ExpectType string | undefined
// RequestAuth Tests
let reqAuth = new pmCollection.RequestAuth(reqAuthDef);
reqAuth = new pmCollection.RequestAuth(reqAuthDef, collection);
reqAuth.type; // $ExpectType string
reqAuth.update(new pmCollection.VariableList(collection, [])); // $ExpectType void
reqAuth.update({key: "string", value: "string"}); // $ExpectType void
reqAuth.update([{key: "string", value: "string"}]); // $ExpectType void
reqAuth.update([{key: "string", value: "string"}], "string"); // $ExpectType void
reqAuth.use("string", new pmCollection.VariableList(collection, [])); // $ExpectType void
reqAuth.use("string", {key: "string", value: "string"}); // $ExpectType void
reqAuth.use("string", [{key: "string", value: "string"}]); // $ExpectType void
reqAuth.current(); // $ExpectType any
reqAuth.parameters(); // $ExpectType VariableList
reqAuth.clear("string"); // $ExpectType void
pmCollection.RequestAuth.isValidType(reqAuth); // $ExpectType boolean
// RequestBodyDefinition Tests
const reqBodyDef: pmCollection.RequestBodyDefinition = {mode: 'raw'};
reqBodyDef.mode; // $ExpectType string
reqBodyDef.raw; // $ExpectType string | undefined
reqBodyDef.urlencoded; // $ExpectType string | QueryParamDefinition[] | PropertyList<QueryParam> | undefined
reqBodyDef.file; // $ExpectType string | { src: string; } | undefined
reqBodyDef.formdata; // $ExpectType FormParamDefinition[] | PropertyList<FormParam> | undefined
// RequestBody Tests
const reqBody = new pmCollection.RequestBody(reqBodyDef);
reqBody.file; // $ExpectType { src: string; } | undefined
reqBody.formdata; // $ExpectType PropertyList<FormParam> | undefined
reqBody.mode; // $ExpectType string
reqBody.raw; // $ExpectType string | undefined
reqBody.urlencoded; // $ExpectType PropertyList<QueryParam> | undefined
reqBody.update(reqBodyDef); // $ExpectType void
reqBody.toString(); // $ExpectType string
reqBody.isEmpty(); // $ExpectType boolean
pmCollection.RequestBody.MODES.raw; // $ExpectType string
pmCollection.RequestBody.MODES.formdata; // $ExpectType string
pmCollection.RequestBody.MODES.urlencoded; // $ExpectType string
pmCollection.RequestBody.MODES.file; // $ExpectType string
// ResponseDefinition Tests
const respDef: pmCollection.ResponseDefinition = {code: 200, responseTime: 1};
respDef.code; // $ExpectType number
respDef.header; // $ExpectType HeaderDefinition[] | undefined
respDef.cookie; // $ExpectType CookieDefinition[] | undefined
respDef.body; // $ExpectType string | undefined
respDef.stream; // $ExpectType Buffer | Uint8Array | undefined
respDef.responseTime; // $ExpectType number
respDef.originalRequest; // $ExpectType RequestDefinition | undefined
// Response Tests
const response = new pmCollection.Response(respDef);
response.body; // $ExpectType string | undefined
response.code; // $ExpectType number
response.cookies; // $ExpectType CookieList
response.headers; // $ExpectType HeaderList
response.originalRequest; // $ExpectType Request | undefined
response.responseTime; // $ExpectType number
response.status; // $ExpectType string
response.stream; // $ExpectType Buffer | Uint8Array | undefined
response.responseSize; // $ExpectType number | undefined
response.update(respDef); // $ExpectType void
response.toJSON(); // $ExpectType any
response.reason(); // ExpectType string | undefined
response.details(); // $ExpectType { name: string; detail: string; code: number; standardName: string; } | undefined
response.text(); // $ExpectType string | undefined
response.json(); // $ExpectType any
response.dataURI(); // $ExpectType string
response.size(); // $ExpectType number
response.encoding(); // $ExpectType { format: string; source: string; }
pmCollection.Response.createFromNode({body: "string", statusCode: 200, elapsedTime: 1}, []); // $ExpectType Response
pmCollection.Response.isResponse(response); // $ExpectType boolean
// ScriptDefinition Tests
const scriptDef: pmCollection.ScriptDefinition = {};
scriptDef.type; // $ExpectType string | undefined
scriptDef.src; // $ExpectType string | Url | undefined
scriptDef.exec; // $ExpectType string | string[] | undefined
// Script Tests
let script = new pmCollection.Script();
script = new pmCollection.Script(scriptDef);
script = new pmCollection.Script("string");
script = new pmCollection.Script(["string"]);
script.exec; // $ExpectType string[] | undefined
script.src; // $ExpectType Url | undefined
script.type; // $ExpectType string
script.update(scriptDef); // $ExpectType void
script.update("string"); // $ExpectType void
script.update(["string"]); // $ExpectType void
script.toSource(); // $ExpectType string | undefined
pmCollection.Script.isScript(script); // $ExpectType boolean
// UrlDefinition Tests
let urlDef: pmCollection.UrlDefinition = {
host: "string",
path: "string"
};
urlDef = {
host: ["string"],
path: ["string"]
};
urlDef.auth; // $ExpectType { user: string; password: string; } | undefined
urlDef.hash; // $ExpectType string | undefined
urlDef.host; // $ExpectType string | string[] | undefined
urlDef.path; // $ExpectType string | string[]
urlDef.port; // $ExpectType string | undefined
urlDef.query; // $ExpectType string | QueryParamDefinition[] | PropertyList<QueryParam> | undefined
urlDef.variable; // $ExpectType VariableDefinition[] | undefined
urlDef.protocol; // $ExpectType string | undefined
// Url Tests
let url = new pmCollection.Url(urlDef);
url = new pmCollection.Url("string");
url.auth; // $ExpectType { user: string; password: string; } | undefined
url.hash; // $ExpectType string | undefined
url.host; // $ExpectType string[] | undefined
url.path; // $ExpectType string[]
url.port; // $ExpectType string | undefined
url.protocol; // $ExpectType string | undefined
url.query; // $ExpectType PropertyList<QueryParam>
url.variables; // $ExpectType VariableList
url.addQueryParams("string"); // $ExpectType void
url.addQueryParams([qp, qpDef]); // $ExpectType void
url.removeQueryParams("string"); // $ExpectType void
url.removeQueryParams(["string"]); // $ExpectType void
url.removeQueryParams(qp); // $ExpectType void
url.removeQueryParams([qp]); // $ExpectType void
url.getRaw(); // $ExpectType string
url.toString(); // $ExpectType string
url.toString(false); // $ExpectType string
url.getPath(); // $ExpectType string
url.getPath({unresolved: true}); // $ExpectType string
url.getQueryString(); // $ExpectType string
url.getQueryString({encode: true}); // $ExpectType string
url.getQueryString({ignoredDisabled: true}); // $ExpectType string
url.getQueryString({encode: true, ignoredDisabled: true}); // $ExpectType string
url.getPathWithQuery(); // $ExpectType string
url.getHost(); // $ExpectType string
url.getRemote(); // $ExpectType string
url.getRemote({forcePort: true}); // $ExpectType string
url.getOAuth1BaseUrl(); // $ExpectType string
pmCollection.Url.parse("string"); // $ExpectType UrlDefinition
pmCollection.Url.isUrl(url); // $ExpectType boolean
// UrlMatchPattern Tests
let urlMatch = new pmCollection.UrlMatchPattern("string");
urlMatch = new pmCollection.UrlMatchPattern({pattern: "string"});
urlMatch.pattern; // $ExpectType string | undefined
urlMatch.update({pattern: "string"}); // $ExpectType void
urlMatch.createMatchPattern(); // $ExpectType { protocols: string[]; host: string; path: RegExp; } | undefined
urlMatch.globPatternToRegexp("string"); // $ExpectType RegExp
urlMatch.testProtocol("string"); // $ExpectType boolean
urlMatch.getProtocols(); // $ExpectType string[]
urlMatch.testHost("string"); // $ExpectType boolean
urlMatch.matchAnyHost({protocols: [], host: "string", path: new RegExp('')}); // $ExpectType boolean
urlMatch.matchSuffixHostPattern({protocols: [], host: "string", path: new RegExp('')}, "string"); // $ExpectType boolean
urlMatch.matchAbsoluteHostPattern({protocols: [], host: "string", path: new RegExp('')}, "string"); // $ExpectType boolean
urlMatch.testPath("string"); // $ExpectType boolean
urlMatch.test("string"); // $ExpectType boolean
urlMatch.toString(); // $ExpectType string
urlMatch.toJSON(); // $ExpectType { pattern: string; }
pmCollection.UrlMatchPattern.MATCH_ALL_URLS; // $ExpectType string
pmCollection.UrlMatchPattern.PROTOCOL_DELIMITER; // $ExpectType string
// UrlMatchPatternList Tests
const urlMatchList = new pmCollection.UrlMatchPatternList(collection, []);
urlMatchList.test("string"); // $ExpectType boolean
// VariableDefinition Tests
const varDef: pmCollection.VariableDefinition = {};
varDef.value; // $ExpectType any
varDef.type; // $ExpectType string | undefined
varDef.key; // $ExpectType string | undefined
// Variable Tests
let variable = new pmCollection.Variable(varDef);
variable = new pmCollection.Variable({key: varDef});
variable.key; // $ExpectType string | undefined
variable.type; // $ExpectType string
variable.value; // $ExpectType any
variable.get(); // $ExpectType any
variable.set(null); // $ExpectType void
variable.valueOf(null); // $ExpectType any
variable.toString(); // $ExpectType string
variable.cast({}); // $ExpectType any
variable.castIn({}); // $ExpectType any
variable.castOut({}); // $ExpectType any
variable.valueType("string", true); // $ExpectType string
variable.update(varDef); // $ExpectType void
pmCollection.Variable.isVariable(variable); // $ExpectType boolean
pmCollection.Variable.types.string; // $ExpectType StringConstructor
pmCollection.Variable.types.boolean; // $ExpectType BooleanConstructor
pmCollection.Variable.types.number; // $ExpectType NumberConstructor
pmCollection.Variable.types.json; // $ExpectType { in: (val: any) => string; out: (val: string) => any; }
pmCollection.Variable.types.any; // $ExpectType { in: <T>(val: T) => T; out: <T>(val: T) => T; }
// VariableList Tests
const vList = new pmCollection.VariableList(collection, [variable]);
vList.replace("string"); // $ExpectType string
vList.replace("string", vList); // $ExpectType string
vList.substitute("string"); // $ExpectType "string"
vList.substitute({}, vList); // $ExpectType {}
vList.substitute(null, vList, false); // $ExpectType null
vList.syncFromObject({}); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
vList.syncFromObject({}, false); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
vList.syncFromObject({}, false, false); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
vList.syncToObject(); // $ExpectType { [key: string]: VariableDefinition; }
vList.syncToObject({key: varDef}); // $ExpectType { [key: string]: VariableDefinition; }
pmCollection.VariableList.isVariableList(vList); // $ExpectType boolean
// VariableScopeDefinition Tests
const varScopeDef: pmCollection.VariableScopeDefinition = {};
varScopeDef.values; // $ExpectType VariableDefinition[] | undefined
// VariableScope Tests
let varScope = new pmCollection.VariableScope(varScopeDef, []);
varScope = new pmCollection.VariableScope(vList, []);
varScope = new pmCollection.VariableScope([varDef], []);
varScope = new pmCollection.VariableScope(varScopeDef, [vList]);
varScope.values; // $ExpectType VariableDefinition[] | undefined
varScope.variables(); // ExpectType { [key: string]: VariableDefinition; }
varScope.toObject(false, false); // $ExpectType any
varScope.has("string"); // $ExpectType boolean
varScope.get("string"); // $ExpectType any
varScope.set("string", {}, "any"); // $ExpectType void
varScope.unset("string"); // $ExpectType void
varScope.clear(); // $ExpectType void
varScope.syncVariablesFrom({}); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
varScope.syncVariablesFrom({}, false); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
varScope.syncVariablesFrom({}, false, false); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined
varScope.syncVariablesTo(); // $ExpectType { [key: string]: VariableDefinition; }
varScope.syncVariablesTo({key: varDef}); // $ExpectType { [key: string]: VariableDefinition; }
varScope.toJSON(); // $ExpectType any
varScope.addLayer(vList); // $ExpectType void
pmCollection.VariableScope.isVariableScope(varScope); // $ExpectType boolean
// VersionDefinition Tests
const verDef: pmCollection.VersionDefinition = {};
verDef.build; // $ExpectType string | undefined
verDef.major; // $ExpectType string | undefined
verDef.minor; // $ExpectType string | undefined
verDef.patch; // $ExpectType string | undefined
verDef.prerelease; // $ExpectType string | undefined
verDef.raw; // $ExpectType string | undefined
verDef.version; // $ExpectType string | undefined
// Version Tests
let version = new pmCollection.Version();
version = new pmCollection.Version(verDef);
version = new pmCollection.Version("string");
version.build; // $ExpectType string | undefined
version.major; // $ExpectType string | undefined
version.minor; // $ExpectType string | undefined
version.patch; // $ExpectType string | undefined
version.prerelease; // $ExpectType string | undefined
version.raw; // $ExpectType string | undefined
version.string; // $ExpectType string | undefined
version.set(); // ExpectType void
version.set(verDef); // $ExpectType void
version.set("string"); // $ExpectType void
version.toString(); // $ExpectType string