import { Options as ReconnectingWebsocketOptions } from 'reconnecting-websocket' ; export interface IMessageEvent { data : string ; } export type DispatchListener < T > = ( response : T ) => any ; export type SubscriptionHandler = ( payload : { [ prop ] : any ; } , action : string ) => any ; export type StreamingRequestHandler = ( error : { response_status : number ; data : any ; } | null , payload : { [ prop ] : any ; } | null ) => any ; /**
 * Calls all handlers whose selectors match an incoming payload.
 */ export interface IDispatcher { param selector param handler return listen < S , P extends S > ( selector , handler ) : number ; param selector param handler return once < S , P extends S > ( selector , handler ) : number ; param listenerId return cancel ( listenerId ) : boolean ; param payload return dispatch ( payload ) : number ; } /**
 * If transport available, sends messages immediately. Otherwise, queues
 * messages for sending later.
 */ export interface ISendQueue { param sendNow param canSend initialize ( sendNow , canSend ) : void ; param bytes return send ( bytes ) : number ; param bytes return sendNow ( bytes ) : number ; param bytes return queueMessage ( bytes ) : boolean ; return processQueue ( ) : number ; } export type TransportEvent = 'open' | 'connect' | 'reconnect' | 'message' ; export interface ITransport { return connect ( ) : boolean ; return disconnect ( ) : boolean ; /**
     * Whether the transport is ready to send/receive messages
     */ isConnected ( ) : boolean ; /**
     * Register a callback for a particular event. The Transport must support
     * the following event types:
     *
     *  - "open": when the connection is opened
     *  - "connect": on initial connection
     *  - "reconnect": when the connection is lost, then reestablished
     *  - "message": when a message is received
     */ on ( name , handler ) : any | null ; return send ( bytes ) : number | void ; } /**
 * Serialize/deserialize messages to and from the wire
 */ export interface ISerializer { serialize ( message ) : string ; deserialize ( bytes ) : any ; } export interface ICancelable { return cancel ( ) : Promise < boolean > ; } export type CancelablePromise < T > = ICancelable & Promise < T > ; export type SubscribeOptions = { requestId ? : string ; subscribeAction ? : string ; unsubscribeAction ? : string ; includeCreateEvents ? : boolean ; } ; export type SubscriptionAction = 'create' | 'update' | 'delete' ; /**
 * An API client implementing create, retrieve, update, delete, and subscribe
 * for streams of objects.
 */ export interface IStreamingAPI { /**
     * Initialize connection. Must be called before API.
     */ initialize ( ) : void ; param unsubscribe return close ( unsubscribe ? ) : Promise < any > ; /**
     * The name of the primary key field, used to identify objects for subscriptions.
     *
     * NOTE: this field is used by the default buildSubscribeSelector and buildSubscribePayload
     *       functions. If these are overridden in the DCRFClient options, this pkField value
     *       may not be honoured.
     */ readonly pkField : string ; /**
     * Whether to ensure payloads for delete events of subscribed models include
     * the primary key of the object in [pkField].
     *
     * Because payloads for delete events aren't run through the serializer,
     * delete events *always* use `pk` to identify the object. This may differ
     * from update events, which *are* run through the serializer, leading to
     * more complicated logic within subscription handlers to retrieve the primary
     * key either from `id` or `pk`, depending on whether it's update or delete.
     *
     * Since this can be ugly, setting this option to true (by passing it in options
     * when instantiating the client) will ensure the configured [pkField] is always
     * present in delete event payloads.
     */ readonly ensurePkFieldInDeleteEvents : boolean ; param stream param data param requestId return list ( stream , data ? , requestId ? ) : Promise < object > ; param stream param props param requestId return create ( stream , props , requestId ? ) : Promise < object > ; param stream param pk param data param requestId return retrieve ( stream , pk , data ? , requestId ? ) : Promise < object > ; param stream param pk param props param requestId return update ( stream , pk , props , requestId ? ) : Promise < object > ; param stream param pk param props param requestId return patch ( stream , pk , props , requestId ? ) : Promise < object > ; param stream param pk param data param requestId return delete ( stream , pk , data ? , requestId ? ) : Promise < object | null > ; param stream param pk param callback param options param options . requestId param options . subscribeAction param options . unsubscribeAction param options . includeCreateEvents return subscribe ( stream , pk , callback , options ? ) : CancelablePromise < object | null > ; param stream param pk param callback param requestId return subscribe ( stream , pk , callback , requestId ? ) : CancelablePromise < object | null > ; param stream param args param callback param options param options . requestId param options . subscribeAction param options . unsubscribeAction param options . includeCreateEvents return subscribe ( stream , args , callback , options ? ) : CancelablePromise < object | null > ; param stream param args param callback param requestId return subscribe ( stream , args , callback , requestId ? ) : CancelablePromise < object | null > ; return unsubscribeAll ( ) : Promise < number > ; param stream param payload param requestId return request ( stream , payload , requestId ? ) : Promise < object > ; param stream param payload param callback param requestId return streamingRequest ( stream , payload , callback , requestId ? ) : CancelablePromise < void > ; } param stream param payload param requestId return export type PayloadPreprocessor = ( stream : string , payload : object , requestId : string ) => object | null ; param message return export type MessagePreprocessor = ( message : object ) => object | undefined ; param stream param payload export type MultiplexedMessageBuilder = ( stream : string , payload : object ) => object ; param stream param requestId export type RequestResponseSelectorBuilder = ( stream : string , requestId : string ) => object ; param stream param requestId export type SubscribeCreateSelectorBuilder = ( stream : string , requestId : string ) => object ; param stream param requestId export type SubscribeUpdateSelectorBuilder = ( stream : string , requestId : string ) => object ; param stream param requestId export type SubscribeDeleteSelectorBuilder = ( stream : string , requestId : string ) => object ; param pk param requestId export type SubscribePayloadBuilder = ( action : string , args : object , requestId : string ) => object ; export type UnsubscribePayloadBuilder = ( action : string , args : object , requestId : string ) => object ; export interface IDCRFOptions { dispatcher ? : IDispatcher ; transport ? : ITransport ; queue ? : ISendQueue ; serializer ? : ISerializer ; preprocessPayload ? : PayloadPreprocessor ; preprocessMessage ? : MessagePreprocessor ; pkField ? : string ; ensurePkFieldInDeleteEvents ? : boolean ; buildMultiplexedMessage ? : MultiplexedMessageBuilder ; buildRequestResponseSelector ? : RequestResponseSelectorBuilder ; buildSubscribeCreateSelector ? : SubscribeCreateSelectorBuilder ; buildSubscribeUpdateSelector ? : SubscribeUpdateSelectorBuilder ; buildSubscribeDeleteSelector ? : SubscribeDeleteSelectorBuilder ; buildSubscribePayload ? : SubscribePayloadBuilder ; buildUnsubscribePayload ? : UnsubscribePayloadBuilder ; websocket ? : ReconnectingWebsocketOptions ; }