/*! * 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 { AuthProvider } from '../auth/auth-provider'; import { ThingsHandle } from './handles/things.interfaces'; import { FeaturesHandle } from './handles/features.interfaces'; import { MessagesHandle } from './handles/messages'; import { PoliciesHandle } from './handles/policies'; import { SearchHandle } from './handles/search'; import { EventsHandle } from './handles/events'; import { CommandsHandle } from './handles/commands'; import { ApiVersion } from '../model/ditto-protocol'; export { AbstractBuilder, AuthenticationStep, BuildStep, CustomBuilderContext, CustomCommandsHandleStep, CustomEventsHandleStep, CustomFeaturesHandleStep, CustomMessagesHandleStep, CustomPoliciesHandleStep, CustomSearchHandleStep, CustomThingsHandleStep, EnvironmentStep, ProtocolStep }; /** * Default interface for builder steps. */ interface BuildStep { } /** * Interface to choose which protocol to use. * @param - type of build steps. */ interface ProtocolStep extends BuildStep { /** * Use with TLS (e.g. wss:// or https://). */ withTls(): EnvironmentStep; /** * Use without TLS (e.g. ws:// or http://). */ withoutTls(): EnvironmentStep; } /** * Interface to select an Environment to use for requests. * @param - type of API 1 Build steps. * @param - type of API 2 Build steps. */ interface EnvironmentStep extends BuildStep { /** * Sets a custom path for the api endpoint (optional step) * * @param path custom ditto api path, e.g. /custom - will be used instead of the default /api */ withCustomPath(path: string): EnvironmentStep; /** * Sets a custom domain to use for requests. * * @param domain - The domain where Ditto is hosted, e.g. ditto.eclipse.org, localhost:8080, ... * @returns The next step to take */ withDomain(domain: string): AuthenticationStep; } /** * Interface to select the authentication type and credentials to use for requests. * @param - type of API 2 Build steps. */ interface AuthenticationStep extends BuildStep { /** * Sets the auth providers for the client. * * @param authProvider The authentication to use. * @param additionalAuthProviders Additional auth providers to use. */ withAuthProvider(authProvider: AuthProvider, ...additionalAuthProviders: AuthProvider[]): U; } /** * Custom builder context can be used when providing custom handles. The will be called with the given custom context. */ interface CustomBuilderContext { } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomThingsHandleStep extends BuildStep { /** * Use a custom things handle. * @param factory - factory for building the custom things handle. */ withCustomThingsHandle(factory: (requestSenderBuilder: R, customBuilderContext?: CustomBuilderContext) => H): this; } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomFeaturesHandleStep extends BuildStep { /** * Use a custom features handle. * @param factory - factory for building the custom features handle. */ withCustomFeaturesHandle(factory: (requestSenderBuilder: R, thingId: string, customBuilderContext?: CustomBuilderContext) => H): this; } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomMessagesHandleStep extends BuildStep { /** * Use a custom messages handle. * @param factory - factory for building the custom handle. */ withCustomMessagesHandle(factory: (requestSenderBuilder: R, customBuilderContext?: CustomBuilderContext) => H): this; } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomEventsHandleStep extends BuildStep { /** * Use a custom events handle. * @param factory - factory for building the custom handle. */ withCustomEventsHandle(factory: (requestSenderBuilder: R, customBuilderContext?: CustomBuilderContext) => H): this; } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomCommandsHandleStep extends BuildStep { /** * Use a custom commands handle. * @param factory - factory for building the custom handle. */ withCustomCommandsHandle(factory: (requestSenderBuilder: R, customBuilderContext?: CustomBuilderContext) => H): this; } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomPoliciesHandleStep extends BuildStep { /** * Use a custom policies handle. * @param factory - factory for building the custom handle. */ withCustomPoliciesHandle(factory: (requestSenderBuilder: R, customBuilderContext?: CustomBuilderContext) => H): this; } /** * @param - Type of the request sender builder. * @param - Type of the handle. */ interface CustomSearchHandleStep extends BuildStep { /** * Use a custom search handle. * @param factory - factory for building the custom handle. */ withCustomSearchHandle(factory: (requestSenderBuilder: R, customBuilderContext?: CustomBuilderContext) => H): this; } /** * Abstract implementation of the relevant builder steps that are probably the same for all builder implementations. */ declare abstract class AbstractBuilder implements ProtocolStep, EnvironmentStep, AuthenticationStep { protected domain: string; protected customPath?: string; protected apiVersion: ApiVersion; protected authProviders: AuthProvider[]; protected tls: boolean; withTls(): EnvironmentStep; withoutTls(): EnvironmentStep; withCustomPath(path: string): EnvironmentStep; withDomain(url: string): AuthenticationStep; withAuthProvider(authProvider: AuthProvider, ...additionalAuthProviders: AuthProvider[]): U; abstract finalize(): U; } //# sourceMappingURL=builder-steps.d.ts.map