diff --git a/types/postman-collection/index.d.ts b/types/postman-collection/index.d.ts new file mode 100644 index 0000000000..ba8e0e581a --- /dev/null +++ b/types/postman-collection/index.d.ts @@ -0,0 +1,811 @@ +// Type definitions for postman-collection 3.0 +// Project: https://github.com/postmanlabs/postman-collection +// Definitions by: Kyle Buzby +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 +/// + +export interface PropertyBaseDefinition { + description?: string | DescriptionDefinition; +} + +export class PropertyBase implements PropertyBaseDefinition { + description?: string | DescriptionDefinition; + + constructor(definition?: PropertyBaseDefinition | {info: PropertyBaseDefinition} | string); + + findInParents(property: string, customizer?: (item: PropertyBase) => boolean): PropertyBase ; + + findParentContaining(property: any, customizer: (item: PropertyBase) => boolean): PropertyBase; + + forEachParent(iterator: (item: any) => void): void; + forEachParent(options: {withRoot: boolean}, iterator: (item: any) => void): void; + + meta(): any; + + parent(): PropertyBase | undefined; + + setParent(parent: PropertyBase): void; + + toJSON(): TDefinition; + + static propertyIsMeta(_value: any, key: string): boolean; + + static propertyUnprefixMeta(_value: any, key: string): string; + + static toJSON(obj: any): any; +} + +export interface PropertyDefinition extends PropertyBaseDefinition { + id?: string; + name?: string; + disabled?: boolean; +} + +export class Property extends PropertyBase implements PropertyDefinition { + disabled: boolean; + id: string; + name: string; + + constructor(definition?: TDefinition | {info: TDefinition, disabled: boolean}); + + describe(content: string, type?: string): void; + + toObjectResolved(scope: {variables: VariableList} | null, overrides: any[], options?: {ignoreOwnVariables: boolean}): TDefinition; + + static replaceSubstitutions(str: string, variables: VariableList | VariableList[]): string; + + static replaceSubstitutionsIn(obj: T, variables: VariableList[], mutate: boolean): T; +} + +export interface CertificateDefinition extends PropertyDefinition { + matches?: string[] | UrlMatchPatternList; + key?: {src?: string} | string; + cert?: {src?: string} | string; + passphrase?: string; +} + +export class Certificate extends Property implements CertificateDefinition { + cert: {src?: string}; + key: {src?: string}; + matches: UrlMatchPatternList; + passphrase: string; + + constructor(options: CertificateDefinition); + + canApplyTo(url: string | Url): boolean; + + update(options: CertificateDefinition): void; + + static isCertificate(obj: any): boolean; +} + +export class PropertyList extends PropertyBase { + constructor(type: string, parent: any, populate: TElement[]); + + add(item: TElement): void; + + all(): TElement[]; + + append(item: TElement): void; + + assimilate(source: PropertyList | TElement[], prune: boolean): void; + + clear(): void; + + count(): number; + + each(iterator: (item: TElement) => void, context?: any): void; + + eachParent(iterator: (item: any) => void, context?: any): void; + + filter(rule: (item: TElement) => boolean, context: any): TElement[]; + + find(rule: (item: TElement) => boolean, context: any): TElement; + + get(key: string): TElement | undefined; + + has(item: string | TElement, value?: any): boolean; + + idx(index: number): TElement; + + indexOf(item: string): number; + + insert(item: TElement, before: TElement | string): void; + + insertAfter(item: TElement, after: TElement | string): void; + + map(iterator: (item: TElement) => any, context?: any): any; + + one(id: string): TElement; + + populate(items: TElement[]): void; + + prepend(item: TElement): void; + + remove(predicate: ((item: TElement) => boolean) | string | TElement, context: any): void; + + repopulate(items: any): void; + + toJSON(): any; + + toObject(excludeDisabled?: boolean, caseSensitive?: boolean, multiValue?: boolean, sanitizeKeys?: boolean): any; + + toString(): string; + + upsert(item: TElement): boolean | null; + + static isPropertyList(obj: any): boolean; +} + +export class CertificateList extends PropertyList { + constructor(parent: any, list: CertificateDefinition[]); + + resolveOne(url: string): CertificateDefinition; + + static isCertificateList(obj: any): boolean; +} + +export interface ItemGroupDefinition extends PropertyDefinition { + item?: Array; + auth?: RequestAuthDefinition; + event?: EventDefinition[]; +} + +export class ItemGroup extends Property { + auth?: RequestAuth; + items: PropertyList; + events: EventList; + + constructor(definition?: ItemGroupDefinition); + + authorizeRequestsUsing(type: string | RequestAuthDefinition, options?: VariableList): void; + + forEachItem(callback: (el: TItem) => void): void; + + forEachItemGroup(callback: (el: ItemGroup) => void): void; + + oneDeep(idOrName: string): TItem; + + static isItemGroup(obj: any): boolean; +} + +export interface CollectionDefinition extends ItemGroupDefinition { + info?: { + id?: string; + name?: string; + version?: string; + }; + variable?: VariableDefinition; +} + +export class Collection extends ItemGroup { + events: EventList; + variables: VariableList; + version?: Version; + + constructor(definition?: CollectionDefinition, environments?: any[]); + + syncVariablesFrom(obj: {[key: string]: VariableDefinition}, track?: boolean, prune?: boolean): {created: string[], updated: string[], deleted: string[]} | undefined; + + syncVariablesTo(obj?: {[key: string]: VariableDefinition}): {[key: string]: VariableDefinition}; + + toJSON(): CollectionDefinition; + + static isCollection(obj: any): boolean; +} + +export interface CookieDefinition { + key?: string; + value?: string; + expires?: string | Date; + maxAge?: number; + domain: string; + path: string; + secure?: boolean; + httpOnly?: boolean; + hostOnly?: boolean; + session?: boolean; + extensions?: Array<{key: string; value: string}>; +} + +export class Cookie extends PropertyBase implements CookieDefinition { + domain: string; + expires: Date; + extensions?: Array<{key: string; value: string}>; + hostOnly?: boolean; + httpOnly?: boolean; + maxAge?: number; + path: string; + secure?: boolean; + session?: boolean; + value?: string; + + constructor(options?: CookieDefinition); + + update(options: CookieDefinition): void; + + valueOf(): string; + + static isCookie(obj: any): boolean; + + static parse(str: string): CookieDefinition; + + static splitParam(param: string): {key: string, value: string | boolean }; +} + +export class CookieList extends PropertyList { + constructor(parent: any, cookies: Cookie[]); + + static isCookieList(obj: any): boolean; +} + +export interface DescriptionDefinition { + content: string; + type?: string; +} + +export class Description implements DescriptionDefinition { + content: string; + type: string; + + constructor(definition?: DescriptionDefinition | string); + + toJSON(): DescriptionDefinition; + + toString(): string; + + update(content: DescriptionDefinition): void; + update(content: string, type?: string): void; + + static isDescription(obj: any): boolean; +} + +export interface EventDefinition extends PropertyDefinition { + listen?: string; + script: string | string[] | ScriptDefinition | Script; +} + +export class Event extends Property implements EventDefinition { + listen?: string; + script: Script; + + constructor(definition: EventDefinition); + + update(definition: EventDefinition): void; +} + +export class EventList extends PropertyList { + constructor(parent: any, populate: Event[]); + + listeners(name: string): Event[]; + + listenersOwn(name: string): Event[]; + + static isEventList(obj: any): boolean; +} + +export interface FormParamDefinition extends PropertyDefinition { + key?: string; + value?: any; +} + +export class FormParam extends Property implements FormParamDefinition { + key: string; + value: any; + + constructor(options: FormParamDefinition); + + toString(): string; + + valueOf(): any; + + // static parse(): void; // TODO not implemented yet +} + +export interface HeaderDefinition extends PropertyDefinition { + key?: string; + value?: string; + system?: boolean; +} + +export class Header extends Property implements HeaderDefinition { + key: string; + value: string; + + constructor(options: string | HeaderDefinition, name?: string) + + toString(): string; + + update(options: HeaderDefinition): void; + + valueOf(): string; + + static create(value?: HeaderDefinition | string, name?: string): Header; + + static isHeader(obj: any): boolean; + + static parse(headerString: string): HeaderDefinition[]; + + static parseSingle(header: string): HeaderDefinition; + + static unparse(headers: HeaderList | HeaderDefinition[], separator?: string): string; + + static unparseSingle(header: HeaderDefinition): string; +} + +export class HeaderList extends PropertyList
{ + constructor(parent: any, headers: Header[]); + + contentSize(): number; + + static isHeaderList(obj: any): boolean; +} + +export interface ItemDefinition extends PropertyDefinition { + request?: RequestDefinition; + responses?: ResponseDefinition[]; + events?: EventDefinition[]; +} + +export class Item extends Property { + events: EventList; + request: Request; + responses: PropertyList; + + constructor(definition?: ItemDefinition); + + authorizeRequestUsing(type: string | RequestAuthDefinition, options?: VariableList): void; + + getAuth(): RequestAuth; + + getEvents(name?: string): Event[]; + + static isItem(obj: any): boolean; +} + +export interface ProxyConfigDefinition extends PropertyDefinition { + match?: string | {pattern: string} | UrlMatchPattern; + host?: string; + port?: number; + tunnel?: boolean; +} + +export class ProxyConfig extends Property implements ProxyConfigDefinition { + host: string; + match: UrlMatchPattern; + port: number; + tunnel: boolean; + + constructor(options?: ProxyConfigDefinition); + + getProtocols(): string[]; + + getProxyUrl(): string; + + test(urlStr?: string): boolean; + + update(options: ProxyConfigDefinition): void; + + updateProtocols(protocols: string[]): void; + + static isProxyConfig(obj: any): boolean; +} + +export class ProxyConfigList extends PropertyList { + constructor(parent: any, populate: ProxyConfig[]); + + resolve(url: string | Url): ProxyConfig; + + static isProxyConfigList(obj: any): boolean; +} + +export interface QueryParamDefinition extends PropertyDefinition { + key: string | null; + value: string | null; + system?: boolean; +} + +export class QueryParam extends Property implements QueryParamDefinition { + static _postman_propertyAllowsMultipleValues: boolean; + static _postman_propertyIndexKey: string; + + key: string | null; + value: string | null; + system?: boolean; + + constructor(options: QueryParamDefinition | string); + + toString(): string; + + update(param: string | {key: string, value?: string}): void; + + valueOf(): string; + + static parse(query: string): QueryParamDefinition[]; + + static parseSingle(param: string, idx: number, all: string[]): QueryParamDefinition; + + static unparse(params: QueryParamDefinition[], options?: {encode?: boolean, ignoreDisabled?: boolean}): string; + + static unparseSingle(obj: QueryParamDefinition, encode: boolean): string; +} + +export interface RequestDefinition extends PropertyDefinition { + url: string | Url; + method?: string; + header?: HeaderDefinition; + body?: RequestBody; + auth?: RequestAuthDefinition; + proxy?: ProxyConfigDefinition; + certificate?: CertificateDefinition; +} + +export class Request extends Property implements RequestDefinition { + auth?: RequestAuth; + body?: RequestBody; + certificate?: Certificate; + headers: HeaderList; + method: string; + proxy?: ProxyConfig; + url: Url; + + constructor(options: RequestDefinition | string); + + addHeader(header: Header | HeaderDefinition): void; + + addQueryParams(params: string | QueryParamDefinition[]): void; + + authorizeUsing(type: string | RequestAuthDefinition | null, options?: VariableList): void; + + clone(): Request; + + forEachHeader(callback: (header: Header, context: Request) => void): void; + + getHeaders(options?: {ignoreCase?: boolean, enabled?: boolean}): any; + + removeHeader(toRemove: string | Header, options?: {ignoreCase: boolean}): void; + + removeQueryParams(params: string | string[] | QueryParamDefinition[] | QueryParamDefinition): void; + + toJSON(): RequestDefinition; + + update(options: RequestDefinition): void; + + upsertHeader(header: HeaderDefinition): void; + + static isRequest(obj: any): boolean; +} + +export interface RequestAuthDefinition extends PropertyDefinition { + type?: string; +} + +export class RequestAuth extends Property implements RequestAuthDefinition { + type: string; + + constructor(options: RequestAuthDefinition, parent?: Property | PropertyList); + + clear(type: string): void; + + current(): any; + + parameters(): VariableList; + + update(options: VariableList | Array<{key: string, value: string}> | {key: string, value: string}, type?: string): void; + + use(type: string, options: VariableList | Array<{key: string, value: string}> | {key: string, value: string}): void; + + static isValidType(type: any): boolean; +} + +export interface RequestBodyDefinition extends PropertyBaseDefinition { + mode: string; + raw?: string; + urlencoded?: QueryParamDefinition[] | PropertyList | string; + file?: string | {src: string}; + formdata?: FormParamDefinition[] | PropertyList; +} + +export class RequestBody extends PropertyBase implements RequestBodyDefinition { + static MODES: { + raw: string; + formdata: string; + urlencoded: string; + file: string; + }; + + file?: {src: string}; + formdata?: PropertyList; + mode: string; + raw?: string; + urlencoded?: PropertyList; + + constructor(options: RequestBodyDefinition); + + isEmpty(): boolean; + + toString(): string; + + update(options: RequestBodyDefinition): void; +} + +export interface ResponseDefinition extends PropertyDefinition { + code: number; + header?: HeaderDefinition[]; + cookie?: CookieDefinition[]; + body?: string; + stream?: Buffer | Uint8Array; + responseTime: number; + originalRequest?: RequestDefinition; +} + +export class Response extends Property implements ResponseDefinition { + body?: string; + code: number; + cookies: CookieList; + headers: HeaderList; + originalRequest?: Request; + responseTime: number; + status: string; + stream?: Buffer | Uint8Array; + responseSize?: number; + + constructor(options: ResponseDefinition); + + dataURI(): string; + + details(): {name: string, detail: string, code: number, standardName: string} | undefined; + + encoding(): {format: string, source: string}; + + json(reviver?: any, strict?: boolean): any; + + reason(): string; + + size(): number; + + text(): string | undefined; + + toJSON(): any; + + update(options: ResponseDefinition): void; + + static createFromNode(response: { + body: string | Buffer | Uint8Array, + headers?: HeaderDefinition[], + statusCode: number, + statusMessage?: string, + elapsedTime: number + }, cookies: CookieDefinition[]): Response; + + static isResponse(obj: any): boolean; +} + +export interface ScriptDefinition extends PropertyDefinition { + type?: string; + src?: string | Url; + exec?: string | string[]; +} + +export class Script extends Property implements ScriptDefinition { + exec?: string[]; + src?: Url; + type: string; + + constructor(options?: ScriptDefinition | string | string[]); + + toSource(): string | undefined; + + update(options: ScriptDefinition | string | string[]): void; + + static isScript(obj: any): boolean; +} + +export interface UrlDefinition extends PropertyBaseDefinition { + auth?: {user: string, password: string}; + hash?: string; + host?: string[] | string; + path: string[] | string; + port?: string; + query?: QueryParamDefinition[] | PropertyList | string; + variable?: VariableDefinition[]; + protocol?: string; +} + +export class Url extends PropertyBase implements UrlDefinition { + auth?: {user: string, password: string}; + hash?: string; + host?: string[]; + path: string[]; + port?: string; + protocol?: string; + query: PropertyList; + variables: VariableList; + + constructor(options: UrlDefinition | string); + + addQueryParams(params: QueryParamDefinition[] | string): void; + + getHost(): string; + + getOAuth1BaseUrl(): string; + + getPath(options?: {unresolved: boolean}): string; + + getPathWithQuery(): string; + + getQueryString(options?: {encode?: boolean, ignoredDisabled?: boolean}): string; + + getRaw(): string; + + getRemote(options?: {forcePort: boolean}): string; + + removeQueryParams(params: QueryParamDefinition[] | QueryParamDefinition | string[] | string): void; + + toString(forceProtocol?: boolean): string; + + update(url: UrlDefinition | string): void; + + static isUrl(obj: any): boolean; + + static parse(url: string): UrlDefinition; +} + +export class UrlMatchPattern { + pattern?: string; + + constructor(options: string | {pattern: string}); + + createMatchPattern(): {protocols: string[], host: string, path: RegExp} | undefined; + + getProtocols(): string[]; + + globPatternToRegexp(pattern: string): RegExp; + + matchAbsoluteHostPattern(matchRegexObject: {protocols: string[], host: string, path: RegExp}, remote: string): boolean; + + matchAnyHost(matchRegexObject: {protocols: string[], host: string, path: RegExp}): boolean; + + matchSuffixHostPattern(matchRegexObject: {protocols: string[], host: string, path: RegExp}, remote: string): boolean; + + test(urlStr: string): boolean; + + testHost(host: string): boolean; + + testPath(path: string): boolean; + + testProtocol(protocol: string): boolean; + + toJSON(): {pattern: string}; + + toString(): string; + + update(options: {pattern: string}): void; + + static MATCH_ALL_URLS: string; + + static PROTOCOL_DELIMITER: string; +} + +export class UrlMatchPatternList extends PropertyList { + constructor(parent: Property, list: string[]); + + test(urlStr: string): boolean; +} + +export interface VariableDefinition extends PropertyDefinition { + value?: any; + type?: string; + key?: string; +} + +export class Variable extends Property implements VariableDefinition { + key?: string; + type: string; + value: any; + + constructor(definition?: VariableDefinition | {[index: string]: VariableDefinition}); + + cast(value: any): any; + + castIn(value: any): any; + + castOut(value: any): any; + + get(): any; + + set(value: any): void; + + toString(): string; + + update(options: VariableDefinition): void; + + 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: (val: T) => T, out: (val: T) => T}; + }; +} + +export class VariableList extends PropertyList { + constructor(parent: Property, populate: Variable[]); + + replace(str: string, overrides?: VariableList): string; + + substitute(obj: T, overrides?: VariableList, mutate?: boolean): T; + + syncFromObject(obj: {[key: string]: VariableDefinition}, track?: boolean, prune?: boolean): {created: string[], updated: string[], deleted: string[]} | undefined; + + syncToObject(obj?: {[key: string]: VariableDefinition}): {[key: string]: VariableDefinition}; + + static isVariableList(obj: any): boolean; +} + +export interface VariableScopeDefinition extends PropertyDefinition { + values?: VariableDefinition[]; +} + +export class VariableScope extends Property implements VariableScopeDefinition { + values?: VariableDefinition[]; + + constructor(definition: VariableScopeDefinition | VariableList | VariableDefinition[], layers?: VariableList[] | VariableList); + + addLayer(list: VariableList): void; + + clear(): void; + + get(key: string): any; + + has(variableName: string): boolean; + + set(key: string, value: any, type: string): void; + + syncVariablesFrom(obj: {[key: string]: VariableDefinition}, track?: boolean, prune?: boolean): {created: string[], updated: string[], deleted: string[]} | undefined; + + syncVariablesTo(obj?: {[key: string]: VariableDefinition}): {[key: string]: VariableDefinition}; + + toJSON(): any; + + toObject(excludeDisabled: boolean, caseSensitive: boolean): any; + + unset(key: string): void; + + variables(): {[key: string]: VariableDefinition}; + + static isVariableScope(obj: any): boolean; +} + +export interface VersionDefinition extends PropertyBaseDefinition { + build?: string; + major?: string; + minor?: string; + patch?: string; + prerelease?: string; + raw?: string; + version?: string; +} + +export class Version extends PropertyBase implements VersionDefinition { + build?: string; + major?: string; + minor?: string; + patch?: string; + prerelease?: string; + raw?: string; + string?: string; + + constructor(options?: VersionDefinition | string); + + set(value?: VersionDefinition | string): void; + + toString(): string; +} diff --git a/types/postman-collection/postman-collection-tests.ts b/types/postman-collection/postman-collection-tests.ts new file mode 100644 index 0000000000..2574aa5917 --- /dev/null +++ b/types/postman-collection/postman-collection-tests.ts @@ -0,0 +1,869 @@ +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 +pb.findInParents("string", (el) => true); // $ExpectType PropertyBase + +pb.findParentContaining("string", (el) => true); // $ExpectType PropertyBase + +pb.forEachParent((el) => {}); // $ExpectType void +pb.forEachParent({withRoot: true}, (el) => {}); // $ExpectType void + +pb.meta(); // $ExpectType any + +pb.parent(); // $ExpectType PropertyBase | 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 { src?: string | undefined; } +certificate.key; // $ExpectType { src?: string | undefined; } +certificate.matches; // $ExpectType UrlMatchPatternList +certificate.passphrase; // $ExpectType string + +certificate.canApplyTo("string"); // $ExpectType boolean +certificate.canApplyTo(new pmCollection.Url({host: "string", path: "string"})); // $ExpectType boolean + +certificate.update({}); // $ExpectType void + +pmCollection.Certificate.isCertificate(certificate); // $ExpectType boolean + +// PropertyList Tests +const pList = new pmCollection.PropertyList("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(); +ig.auth; // $ExpectType RequestAuth | undefined +ig.items; // $ExpectType PropertyList +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 + +collection.syncVariablesFrom({}); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined +collection.syncVariablesFrom({}, true); // $ExpectType { created: string[]; updated: string[]; deleted: string[]; } | undefined + +collection.syncVariablesTo({}); // ExpectType $ExpectType { [key: string]: VariableDefinition; } + +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 + +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 + +req.removeQueryParams("string"); // $ExpectType void +req.removeQueryParams(["string"]); // $ExpectType void +req.removeQueryParams([qpDef]); // $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 | undefined +reqBodyDef.file; // $ExpectType string | { src: string; } | undefined +reqBodyDef.formdata; // $ExpectType FormParamDefinition[] | PropertyList | undefined + +// RequestBody Tests + +const reqBody = new pmCollection.RequestBody(reqBodyDef); + +reqBody.file; // $ExpectType { src: string; } | undefined +reqBody.formdata; // $ExpectType PropertyList | undefined +reqBody.mode; // $ExpectType string +reqBody.raw; // $ExpectType string | undefined +reqBody.urlencoded; // $ExpectType PropertyList | 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 | 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 +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: (val: T) => T; out: (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 diff --git a/types/postman-collection/tsconfig.json b/types/postman-collection/tsconfig.json new file mode 100644 index 0000000000..9b0b244020 --- /dev/null +++ b/types/postman-collection/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "postman-collection-tests.ts" + ] +} diff --git a/types/postman-collection/tslint.json b/types/postman-collection/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/postman-collection/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }