import { SocketOptions } from "./socket"; import { Socket } from "../types/socket"; import { GraphqlStreamClient } from "../types/graphql-stream-client"; export declare const DEFAULT_RESTART_ON_ERROR_DELAY_IN_MS = 2500; /** * The set of options that can be used when constructing a the default * [[StreamClient]] instance through the [[createStreamClient]] factory * method. */ export interface GraphqlStreamClientOptions { /** * The [[Socket]] instance to use, inferred based on the environment when not provided. * * @default `undefined` (Inferred based on runtime environment (Node.js/Browser), see [[createSocket]]) */ socket?: Socket; /** * The [[SocketOptions]] to pass when creating the default [[Socket]] instance. * This field has no effect if you provide yourself a [[StreamClientOptions.socket]] option. * * @default `undefined` (See [[SocketOptions]] for actual defaults this generates) */ socketOptions?: SocketOptions; /** * Determines if all streams should automatically restart when the socket disconnects. The stream * will re-connect at their latest marked value (See [[Stream.mark]]) if present or at current * block if it was never marked. * * @default `true` */ autoRestartStreamsOnReconnect?: boolean; /** * Determines if all streams should automatically restart when the stream receives an `error` * message type from the server. The stream will try to restart automatically at their latest * marked value (See [[Stream.mark]]) if present or at current block if it was never marked. * * @default `true` */ autoRestartStreamsOnError?: boolean; /** * The delay after the the stream receives an error message to wait for before restarting * the stream. As no effect if [[GraphqlStreamClientOptions.autoRestartStreamsOnError]] is sets * to `false`. * * @default `2.5s` (See [[DEFAULT_RESTART_ON_ERROR_DELAY_IN_MS]]) */ restartOnErrorDelayInMs?: number; /** * When sets to `true`, when no more streams are active, the socket is * automatically disconnected and close. This option should be set to * `false` when using `Query` or `Mutation` over WebSocket transport * to avoid opening/closing the WebSocket connection for each operation * or when multiple short lived `Subscription`s are used. * * @default `true` */ autoDisconnectSocket?: boolean; } /** * Create the default [[StreamClient]] concrete implementation. * * @param wsUrl The url used to reach the dfuse Stream API, should **not** contain the `token` query parameter. Passed as * is to created [[Socket]] interface through the [[createSocket]] factory method. This parameter has no effect * if [[StreamClientOptions.socket]] options is used. * @param options The set of options used to construct the default [[StreamClient]] instance. See * [[StreamClientOptions]] for documentation of the options and default values for each of them. */ export declare function createGraphqlStreamClient(wsUrl: string, options?: GraphqlStreamClientOptions): GraphqlStreamClient;