node-nlp
Version:
Library for NLU (Natural Language Understanding) done in Node.js
122 lines • 5.68 kB
TypeScript
import { ServiceClientCredentials } from "./credentials/serviceClientCredentials";
import { HttpClient } from "./httpClient";
import { HttpOperationResponse, RestResponse } from "./httpOperationResponse";
import { HttpPipelineLogger } from "./httpPipelineLogger";
import { OperationArguments } from "./operationArguments";
import { ParameterPath } from "./operationParameter";
import { OperationSpec } from "./operationSpec";
import { DeserializationContentTypes } from "./policies/deserializationPolicy";
import { RequestPolicyFactory } from "./policies/requestPolicy";
import { Mapper, Serializer } from "./serializer";
import { RequestPrepareOptions, WebResource } from "./webResource";
import { OperationResponse } from "./operationResponse";
import { ServiceCallback } from "./util/utils";
/**
* Options to be provided while creating the client.
*/
export interface ServiceClientOptions {
/**
* An array of factories which get called to create the RequestPolicy pipeline
* used to send a HTTP request on the wire.
*/
requestPolicyFactories?: RequestPolicyFactory[];
/**
* The HttpClient that will be used to send HTTP requests.
*/
httpClient?: HttpClient;
/**
* The HttpPipelineLogger that can be used to debug RequestPolicies within the HTTP pipeline.
*/
httpPipelineLogger?: HttpPipelineLogger;
/**
* If set to true, turn off the default retry policy.
*/
noRetryPolicy?: boolean;
/**
* Gets or sets the retry timeout in seconds for AutomaticRPRegistration. Default value is 30.
*/
rpRegistrationRetryTimeout?: number;
/**
* Whether or not to generate a client request ID header for each HTTP request.
*/
generateClientRequestIdHeader?: boolean;
/**
* Whether to include credentials in CORS requests in the browser.
* See https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials for more information.
*/
withCredentials?: boolean;
/**
* If specified, a GenerateRequestIdPolicy will be added to the HTTP pipeline that will add a
* header to all outgoing requests with this header name and a random UUID as the request ID.
*/
clientRequestIdHeaderName?: string;
/**
* The content-types that will be associated with JSON or XML serialization.
*/
deserializationContentTypes?: DeserializationContentTypes;
}
/**
* @class
* Initializes a new instance of the ServiceClient.
*/
export declare class ServiceClient {
/**
* If specified, this is the base URI that requests will be made against for this ServiceClient.
* If it is not specified, then all OperationSpecs must contain a baseUrl property.
*/
protected baseUri?: string;
/**
* The default request content type for the service.
* Used if no requestContentType is present on an OperationSpec.
*/
protected requestContentType?: string;
/**
* The string to be appended to the User-Agent header while sending the request.
* This will be applicable only for node.js environment as the fetch library in browser does not allow setting custom UA.
*/
userAgentInfo: {
value: string[];
};
/**
* The HTTP client that will be used to send requests.
*/
private readonly _httpClient;
private readonly _requestPolicyOptions;
private readonly _requestPolicyFactories;
private readonly _withCredentials;
/**
* The ServiceClient constructor
* @constructor
* @param {ServiceClientCredentials} [credentials] The credentials object used for authentication.
* @param {ServiceClientOptions} [options] The service client options that govern the behavior of the client.
*/
constructor(credentials?: ServiceClientCredentials, options?: ServiceClientOptions);
/**
* Adds custom information to user agent header
* @param {string} additionalUserAgentInfo information to be added to user agent header, as string.
*/
addUserAgentInfo(additionalUserAgentInfo: string): void;
/**
* Send the provided httpRequest.
*/
sendRequest(options: RequestPrepareOptions | WebResource): Promise<HttpOperationResponse>;
/**
* Send an HTTP request that is populated using the provided OperationSpec.
* @param {OperationArguments} operationArguments The arguments that the HTTP request's templated values will be populated from.
* @param {OperationSpec} operationSpec The OperationSpec to use to populate the httpRequest.
* @param {ServiceCallback} callback The callback to call when the response is received.
*/
sendOperationRequest(operationArguments: OperationArguments, operationSpec: OperationSpec, callback?: ServiceCallback<any>): Promise<RestResponse>;
}
export declare function serializeRequestBody(serviceClient: ServiceClient, httpRequest: WebResource, operationArguments: OperationArguments, operationSpec: OperationSpec): void;
export declare type PropertyParent = {
[propertyName: string]: any;
};
/**
* Get the property parent for the property at the provided path when starting with the provided
* parent object.
*/
export declare function getPropertyParent(parent: PropertyParent, propertyPath: string[]): PropertyParent;
export declare function getOperationArgumentValueFromParameterPath(serviceClient: ServiceClient, operationArguments: OperationArguments, parameterPath: ParameterPath, parameterMapper: Mapper, serializer: Serializer): any;
export declare function flattenResponse(_response: HttpOperationResponse, responseSpec: OperationResponse | undefined): RestResponse;
//# sourceMappingURL=serviceClient.d.ts.map