@eclipse-ditto/ditto-javascript-client-dom
Version:
DOM implementation of Eclipse Ditto JavaScript API to be used in browsers.
79 lines • 4.28 kB
TypeScript
/*!
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
import { HttpThingsHandle } from './handles/things.interfaces';
import { HttpRequester, HttpRequestSenderBuilder } from './request-factory/http-request-sender';
import { DefaultDittoHttpClient, DittoHttpClient } from './ditto-client-http';
import { HttpMessagesHandle } from './handles/messages-http';
import { PoliciesHandle } from './handles/policies';
import { SearchHandle } from './handles/search';
import { FeaturesHandle } from './handles/features.interfaces';
import { AuthProvider } from '../auth/auth-provider';
import { ApiVersion } from '../model/ditto-protocol';
import { AbstractBuilder, AuthenticationStep, BuildStep, CustomBuilderContext, CustomFeaturesHandleStep, CustomMessagesHandleStep, CustomPoliciesHandleStep, CustomSearchHandleStep, CustomThingsHandleStep, EnvironmentStep, ProtocolStep } from './builder-steps';
export interface HttpBuilderInitialStep extends ProtocolStep<HttpClientBuildStep> {
}
export interface HttpBuildStep<C extends DittoHttpClient> extends BuildStep {
/**
* Sets the request timeout in milliseconds.
*
* This is important because by default HTTP requests have no timeout
* and may hang indefinitely waiting for a response.
*
* @param timeout - The timeout in milliseconds to use.
*/
withTimeout(timeout: number): this;
/**
* Builds a DittoClient for the selected API.
*
* @returns The DittoClient
*/
build(): C;
}
/**
* Build step for adding custom handles.
* @param <H> - Type of the things handle.
* @param <C> - Type of the client.
*/
export interface HttpCustomHandlesBuildStep<H extends HttpThingsHandle, C extends DittoHttpClient> extends HttpBuildStep<C>, BuildStep, CustomThingsHandleStep<HttpRequestSenderBuilder, H>, CustomFeaturesHandleStep<HttpRequestSenderBuilder, FeaturesHandle>, CustomMessagesHandleStep<HttpRequestSenderBuilder, HttpMessagesHandle>, CustomPoliciesHandleStep<HttpRequestSenderBuilder, PoliciesHandle>, CustomSearchHandleStep<HttpRequestSenderBuilder, SearchHandle> {
}
/**
* Interface to build the Context.
*/
export interface HttpClientBuildStep extends HttpCustomHandlesBuildStep<HttpThingsHandle, DittoHttpClient> {
}
/**
* Implementation of all the methods to build a Context.
*/
export declare class HttpClientBuilder extends AbstractBuilder<HttpClientBuildStep> implements HttpBuilderInitialStep, EnvironmentStep<HttpClientBuildStep>, AuthenticationStep<HttpClientBuildStep>, HttpClientBuildStep {
private readonly requester;
private customHandles;
private timeout?;
private constructor();
/**
* Build a new HttpClientBuilder.
*
* @param requester - The requester to use.
*/
static newBuilder(requester: HttpRequester): HttpBuilderInitialStep;
finalize(): HttpClientBuildStep;
withTimeout(timeout: number): this;
build(): DefaultDittoHttpClient;
buildClient(tls: boolean, domain: string, apiVersion: ApiVersion, authProviders: AuthProvider[]): DefaultDittoHttpClient;
private buildUrl;
withCustomThingsHandle(factory: (requestSenderBuilder: HttpRequestSenderBuilder, customBuilderContext?: CustomBuilderContext) => HttpThingsHandle): this;
withCustomFeaturesHandle(factory: (requestSenderBuilder: HttpRequestSenderBuilder, thingId: string, customBuilderContext?: CustomBuilderContext) => FeaturesHandle): this;
withCustomMessagesHandle(factory: (requestSenderBuilder: HttpRequestSenderBuilder, customBuilderContext?: CustomBuilderContext) => HttpMessagesHandle): this;
withCustomPoliciesHandle(factory: (requestSenderBuilder: HttpRequestSenderBuilder, customBuilderContext?: CustomBuilderContext) => PoliciesHandle): this;
withCustomSearchHandle(factory: (requestSenderBuilder: HttpRequestSenderBuilder, customBuilderContext?: CustomBuilderContext) => SearchHandle): this;
}
//# sourceMappingURL=http-client-builder.d.ts.map