Changes ts declaration for EventStoreNodeConnection so that it offers all EventEmitter methods.

This commit is contained in:
Ulrikop 2019-02-09 13:16:07 +01:00
parent e9d86a3c4d
commit fcf27fba20
2 changed files with 16 additions and 4 deletions

19
index.d.ts vendored
View File

@ -1,6 +1,9 @@
/// <reference types="node" /> /// <reference types="node" />
/// <reference types="Long" /> /// <reference types="Long" />
import { EventEmitter } from "events";
import { StrictEventEmitter } from "strict-event-emitter-types";
// Expose classes // Expose classes
export class Position { export class Position {
constructor(commitPosition: number|Long, preparePosition: number|Long); constructor(commitPosition: number|Long, preparePosition: number|Long);
@ -305,7 +308,18 @@ export interface EventData {
readonly metadata: Buffer; readonly metadata: Buffer;
} }
export interface EventStoreNodeConnection { interface EventStoreNodeConnectionEvents {
connected: TcpEndPoint;
disconnected: TcpEndPoint;
reconnecting: void;
closed:string;
error: Error;
heartbeatInfo: HeartbeatInfo;
}
type EventStoreNodeConnectionEventEmitter = StrictEventEmitter<EventEmitter, EventStoreNodeConnectionEvents>;
export class EventStoreNodeConnection extends (EventEmitter as { new(): EventStoreNodeConnectionEventEmitter }) {
connect(): Promise<void>; connect(): Promise<void>;
close(): void; close(): void;
// write actions // write actions
@ -332,9 +346,6 @@ export interface EventStoreNodeConnection {
// metadata actions // metadata actions
setStreamMetadataRaw(stream: string, expectedMetastreamVersion: Long|number, metadata: any, userCredentials?: UserCredentials): Promise<WriteResult>; setStreamMetadataRaw(stream: string, expectedMetastreamVersion: Long|number, metadata: any, userCredentials?: UserCredentials): Promise<WriteResult>;
getStreamMetadataRaw(stream: string, userCredentials?: UserCredentials): Promise<RawStreamMetadataResult>; getStreamMetadataRaw(stream: string, userCredentials?: UserCredentials): Promise<RawStreamMetadataResult>;
on(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error" | "heartbeatInfo", listener: (arg: Error | string | TcpEndPoint | HeartbeatInfo) => void): this;
once(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error" | "heartbeatInfo", listener: (arg: Error | string | TcpEndPoint | HeartbeatInfo) => void): this;
} }
// Expose helper functions // Expose helper functions

View File

@ -47,6 +47,7 @@
"dependencies": { "dependencies": {
"@types/long": "^3.0.31", "@types/long": "^3.0.31",
"@types/node": "^6.0.47", "@types/node": "^6.0.47",
"strict-event-emitter-types": "^1.2.0",
"long": "^3.2", "long": "^3.2",
"protobufjs": "^6.7.3", "protobufjs": "^6.7.3",
"uuid": "^3.0.1" "uuid": "^3.0.1"