1 | import { HttpOperationResponse } from "../httpOperationResponse";
|
2 | import { RestError } from "../restError";
|
3 | import { WebResourceLike } from "../webResource";
|
4 | /**
|
5 | * A constant that indicates whether the environment is node.js or browser based.
|
6 | */
|
7 | export declare const isNode: boolean;
|
8 | /**
|
9 | * Checks if a parsed URL is HTTPS
|
10 | *
|
11 | * @param {object} urlToCheck The url to check
|
12 | * @return {boolean} True if the URL is HTTPS; false otherwise.
|
13 | */
|
14 | export declare function urlIsHTTPS(urlToCheck: {
|
15 | protocol: string;
|
16 | }): boolean;
|
17 | /**
|
18 | * Encodes an URI.
|
19 | *
|
20 | * @param {string} uri The URI to be encoded.
|
21 | * @return {string} The encoded URI.
|
22 | */
|
23 | export declare function encodeUri(uri: string): string;
|
24 | /**
|
25 | * Returns a stripped version of the Http Response which only contains body,
|
26 | * headers and the status.
|
27 | *
|
28 | * @param {HttpOperationResponse} response The Http Response
|
29 | *
|
30 | * @return {object} The stripped version of Http Response.
|
31 | */
|
32 | export declare function stripResponse(response: HttpOperationResponse): any;
|
33 | /**
|
34 | * Returns a stripped version of the Http Request that does not contain the
|
35 | * Authorization header.
|
36 | *
|
37 | * @param {WebResource} request The Http Request object
|
38 | *
|
39 | * @return {WebResource} The stripped version of Http Request.
|
40 | */
|
41 | export declare function stripRequest(request: WebResourceLike): WebResourceLike;
|
42 | /**
|
43 | * Validates the given uuid as a string
|
44 | *
|
45 | * @param {string} uuid The uuid as a string that needs to be validated
|
46 | *
|
47 | * @return {boolean} True if the uuid is valid; false otherwise.
|
48 | */
|
49 | export declare function isValidUuid(uuid: string): boolean;
|
50 | /**
|
51 | * Provides an array of values of an object. For example
|
52 | * for a given object { "a": "foo", "b": "bar" }, the method returns ["foo", "bar"].
|
53 | *
|
54 | * @param {object} obj An object whose properties need to be enumerated so that it"s values can be provided as an array
|
55 | *
|
56 | * @return {any[]} An array of values of the given object.
|
57 | */
|
58 | export declare function objectValues(obj: {
|
59 | [key: string]: any;
|
60 | }): any[];
|
61 | /**
|
62 | * Generated UUID
|
63 | *
|
64 | * @return {string} RFC4122 v4 UUID.
|
65 | */
|
66 | export declare function generateUuid(): string;
|
67 | /**
|
68 | * Executes an array of promises sequentially. Inspiration of this method is here:
|
69 | * https://pouchdb.com/2015/05/18/we-have-a-problem-with-promises.html. An awesome blog on promises!
|
70 | *
|
71 | * @param {Array} promiseFactories An array of promise factories(A function that return a promise)
|
72 | *
|
73 | * @param {any} [kickstart] Input to the first promise that is used to kickstart the promise chain.
|
74 | * If not provided then the promise chain starts with undefined.
|
75 | *
|
76 | * @return A chain of resolved or rejected promises
|
77 | */
|
78 | export declare function executePromisesSequentially(promiseFactories: Array<any>, kickstart: any): Promise<any>;
|
79 | /**
|
80 | * Merges source object into the target object
|
81 | * @param {object} source The object that needs to be merged
|
82 | *
|
83 | * @param {object} target The object to be merged into
|
84 | *
|
85 | * @returns {object} Returns the merged target object.
|
86 | */
|
87 | export declare function mergeObjects(source: {
|
88 | [key: string]: any;
|
89 | }, target: {
|
90 | [key: string]: any;
|
91 | }): {
|
92 | [key: string]: any;
|
93 | };
|
94 | /**
|
95 | * A wrapper for setTimeout that resolves a promise after t milliseconds.
|
96 | * @param {number} t The number of milliseconds to be delayed.
|
97 | * @param {T} value The value to be resolved with after a timeout of t milliseconds.
|
98 | * @returns {Promise<T>} Resolved promise
|
99 | */
|
100 | export declare function delay<T>(t: number, value?: T): Promise<T>;
|
101 | /**
|
102 | * Service callback that is returned for REST requests initiated by the service client.
|
103 | */
|
104 | export interface ServiceCallback<TResult> {
|
105 | /**
|
106 | * A method that will be invoked as a callback to a service function.
|
107 | * @param {Error | RestError | null} err The error occurred if any, while executing the request; otherwise null.
|
108 | * @param {TResult} [result] The deserialized response body if an error did not occur.
|
109 | * @param {WebResourceLike} [request] The raw/actual request sent to the server if an error did not occur.
|
110 | * @param {HttpOperationResponse} [response] The raw/actual response from the server if an error did not occur.
|
111 | */
|
112 | (err: Error | RestError | null, result?: TResult, request?: WebResourceLike, response?: HttpOperationResponse): void;
|
113 | }
|
114 | /**
|
115 | * Converts a Promise to a callback.
|
116 | * @param {Promise<any>} promise The Promise to be converted to a callback
|
117 | * @returns {Function} A function that takes the callback (cb: Function): void
|
118 | * @deprecated generated code should instead depend on responseToBody
|
119 | */
|
120 | export declare function promiseToCallback(promise: Promise<any>): Function;
|
121 | /**
|
122 | * Converts a Promise to a service callback.
|
123 | * @param {Promise<HttpOperationResponse>} promise - The Promise of HttpOperationResponse to be converted to a service callback
|
124 | * @returns {Function} A function that takes the service callback (cb: ServiceCallback<T>): void
|
125 | */
|
126 | export declare function promiseToServiceCallback<T>(promise: Promise<HttpOperationResponse>): Function;
|
127 | export declare function prepareXMLRootList(obj: any, elementName: string): {
|
128 | [x: string]: any;
|
129 | };
|
130 | /**
|
131 | * Applies the properties on the prototype of sourceCtors to the prototype of targetCtor
|
132 | * @param {object} targetCtor The target object on which the properties need to be applied.
|
133 | * @param {Array<object>} sourceCtors An array of source objects from which the properties need to be taken.
|
134 | */
|
135 | export declare function applyMixins(targetCtor: any, sourceCtors: any[]): void;
|
136 | /**
|
137 | * Indicates whether the given string is in ISO 8601 format.
|
138 | * @param {string} value The value to be validated for ISO 8601 duration format.
|
139 | * @return {boolean} `true` if valid, `false` otherwise.
|
140 | */
|
141 | export declare function isDuration(value: string): boolean;
|
142 | /**
|
143 | * Replace all of the instances of searchValue in value with the provided replaceValue.
|
144 | * @param {string | undefined} value The value to search and replace in.
|
145 | * @param {string} searchValue The value to search for in the value argument.
|
146 | * @param {string} replaceValue The value to replace searchValue with in the value argument.
|
147 | * @returns {string | undefined} The value where each instance of searchValue was replaced with replacedValue.
|
148 | */
|
149 | export declare function replaceAll(value: string | undefined, searchValue: string, replaceValue: string): string | undefined;
|
150 | /**
|
151 | * Determines whether the given enity is a basic/primitive type
|
152 | * (string, number, boolean, null, undefined).
|
153 | * @param value Any entity
|
154 | * @return boolean - true is it is primitive type, false otherwise.
|
155 | */
|
156 | export declare function isPrimitiveType(value: any): boolean;
|
157 | //# sourceMappingURL=utils.d.ts.map |
\ | No newline at end of file |