Completing TypeScript declaration file (only missing persistent subscriptions)
This commit is contained in:
parent
60f1d7252b
commit
9b9e202cec
85
index.d.ts
vendored
85
index.d.ts
vendored
|
@ -13,6 +13,11 @@ export namespace positions {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventData {
|
export interface EventData {
|
||||||
|
readonly eventId: string;
|
||||||
|
readonly type: string;
|
||||||
|
readonly isJson: boolean;
|
||||||
|
readonly data: Buffer;
|
||||||
|
readonly metadata: Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createJsonEventData(eventId: string, event: any, metadata?: any, type?: string): EventData;
|
export function createJsonEventData(eventId: string, event: any, metadata?: any, type?: string): EventData;
|
||||||
|
@ -38,6 +43,9 @@ export interface Logger {
|
||||||
|
|
||||||
export interface UserCredentials {
|
export interface UserCredentials {
|
||||||
new (username: string, password: string);
|
new (username: string, password: string);
|
||||||
|
|
||||||
|
readonly username: string;
|
||||||
|
readonly password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConnectionSettings {
|
export interface ConnectionSettings {
|
||||||
|
@ -109,6 +117,32 @@ export interface StreamEventsSlice {
|
||||||
readonly isEndOfStream: boolean;
|
readonly isEndOfStream: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AllEventsSlice {
|
||||||
|
readonly readDirection: string; // TODO enum
|
||||||
|
readonly fromPosition: Position;
|
||||||
|
readonly nextPosition: Position;
|
||||||
|
readonly events: ResolvedEvent[];
|
||||||
|
readonly isEndOfStream: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteResult {
|
||||||
|
readonly logPosition: Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EventStoreTransaction {
|
||||||
|
readonly transactionId: number;
|
||||||
|
commit(): Promise<WriteResult>;
|
||||||
|
write(eventOrEvents: EventData | EventData[]): Promise<void>;
|
||||||
|
rollback(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EventReadResult {
|
||||||
|
readonly status: string;
|
||||||
|
readonly stream: string;
|
||||||
|
readonly eventNumber: number;
|
||||||
|
readonly event: ResolvedEvent | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface EventStoreSubscription {
|
export interface EventStoreSubscription {
|
||||||
readonly isSubscribedToAll: boolean;
|
readonly isSubscribedToAll: boolean;
|
||||||
readonly streamId: string;
|
readonly streamId: string;
|
||||||
|
@ -119,23 +153,56 @@ export interface EventStoreSubscription {
|
||||||
unsubscribe(): void;
|
unsubscribe(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventAppearedCallback {
|
export interface EventStoreCatchUpSubscription {
|
||||||
(subscription: EventStoreSubscription, event: EventData);
|
start(): void;
|
||||||
|
stop(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubscriptionDroppedCallback {
|
export interface RawStreamMetadataResult {
|
||||||
(subscription: EventStoreSubscription, reason: string, error?: Error);
|
readonly stream: string;
|
||||||
|
readonly isStreamDeleted: boolean;
|
||||||
|
readonly metastreamVersion: number;
|
||||||
|
readonly streamMetadata: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callbacks
|
||||||
|
export interface EventAppearedCallback<TSubscription> {
|
||||||
|
(subscription: TSubscription, event: EventData): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LiveProcessingStartedCallback {
|
||||||
|
(subscription: EventStoreCatchUpSubscription): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SubscriptionDroppedCallback<TSubscription> {
|
||||||
|
(subscription: TSubscription, reason: string, error?: Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventStoreNodeConnection {
|
export interface EventStoreNodeConnection {
|
||||||
connect(): Promise<void>;
|
connect(): Promise<void>;
|
||||||
close(): void;
|
close(): void;
|
||||||
appendToStream(stream: string, expectedVersion: number, events: EventData[], userCredentials?: UserCredentials): Promise<WriteResult>;
|
// write actions
|
||||||
readStreamEventsForward(stream: string, start: number, count: number, resolveLinkTos: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
deleteStream(stream: string, expectedVersion: number, hardDelete?: boolean, userCredentials?: UserCredentials): Promise<DeleteResult>;
|
||||||
subscribeToStream(stream: string, resolveLinkTos: boolean, eventAppeared: EventAppearedCallback, subscriptionDropped?: SubscriptionDroppedCallback, userCredentials?: UserCredentials): Promise<EventStoreSubscription>;
|
appendToStream(stream: string, expectedVersion: number, eventOrEvents: EventData | EventData[], userCredentials?: UserCredentials): Promise<WriteResult>;
|
||||||
|
startTransaction(stream: string, expectedVersion: number, userCredentials?: UserCredentials): Promise<EventStoreTransaction>;
|
||||||
|
continueTransaction(transactionId: number, userCredentials?: UserCredentials): EventStoreTransaction;
|
||||||
|
// read actions
|
||||||
|
readEvent(stream: string, eventNumber: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<EventReadResult>;
|
||||||
|
readStreamEventsForward(stream: string, start: number, count: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
||||||
|
readStreamEventsBackward(stream: string, start: number, count: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<StreamEventsSlice>;
|
||||||
|
readAllEventsForward(position: Position, maxCount: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<AllEventsSlice>;
|
||||||
|
readAllEventsBackward(position: Position, maxCount: number, resolveLinkTos?: boolean, userCredentials?: UserCredentials): Promise<AllEventsSlice>;
|
||||||
|
// subscription actions
|
||||||
|
subscribeToStream(stream: string, resolveLinkTos: boolean, eventAppeared: EventAppearedCallback<EventStoreSubscription>, subscriptionDropped?: SubscriptionDroppedCallback<EventStoreSubscription>, userCredentials?: UserCredentials): Promise<EventStoreSubscription>;
|
||||||
|
subscribeToStreamFrom(stream: string, lastCheckpoint: number | null, resolveLinkTos: boolean, eventAppeared: EventAppearedCallback<EventStoreCatchUpSubscription>, liveProcessingStarted?: LiveProcessingStartedCallback, subscriptionDropped?: SubscriptionDroppedCallback<EventStoreCatchUpSubscription>, userCredentials?: UserCredentials, readBatchSize?: number): EventStoreCatchUpSubscription;
|
||||||
|
subscribeToAll(resolveLinkTos: boolean, eventAppeared: EventAppearedCallback<EventStoreSubscription>, subscriptionDropped?: SubscriptionDroppedCallback<EventStoreSubscription>, userCredentials?: UserCredentials): Promise<EventStoreSubscription>;
|
||||||
|
subscribeToAllFrom(lastCheckpoint: Position | null, resolveLinkTos: boolean, eventAppeared: EventAppearedCallback<EventStoreCatchUpSubscription>, liveProcessingStarted?: LiveProcessingStartedCallback, subscriptionDropped?: SubscriptionDroppedCallback<EventStoreCatchUpSubscription>, userCredentials?: UserCredentials, readBatchSize?: number): EventStoreCatchUpSubscription;
|
||||||
|
// metadata actions
|
||||||
|
setStreamMetadataRaw(stream: string, expectedMetastreamVersion: number, metadata: any, userCredentials?: UserCredentials): Promise<WriteResult>;
|
||||||
|
getStreamMetadataRaw(stream: string, userCredentials?: UserCredentials): Promise<RawStreamMetadataResult>;
|
||||||
|
|
||||||
on(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error", listener: Function): this;
|
on(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error", listener: (arg: Error | string | TcpEndPoint) => void): this;
|
||||||
once(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error", listener: Function): this;
|
once(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error", listener: (arg: Error | string | TcpEndPoint) => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createConnection(settings: ConnectionSettings, endPointOrGossipSeed: string | TcpEndPoint | GossipSeed[], connectionName?: string): EventStoreNodeConnection;
|
export function createConnection(settings: ConnectionSettings, endPointOrGossipSeed: string | TcpEndPoint | GossipSeed[], connectionName?: string): EventStoreNodeConnection;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user