Expose Position, publish version 0.0.27
This commit is contained in:
parent
212dd10ce2
commit
34e928c440
179
index.d.ts
vendored
179
index.d.ts
vendored
|
@ -1,37 +1,32 @@
|
||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
/// <reference types="Long" />
|
/// <reference types="Long" />
|
||||||
|
|
||||||
export namespace expectedVersion {
|
export class Position {
|
||||||
const any: number;
|
constructor(commitPosition: number|Long, preparePosition: number|Long);
|
||||||
const noStream: number;
|
|
||||||
const emptyStream: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Position {
|
|
||||||
readonly commitPosition: Long;
|
readonly commitPosition: Long;
|
||||||
readonly preparePosition: Long;
|
readonly preparePosition: Long;
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace positions {
|
// Expose classes
|
||||||
const start: Position;
|
|
||||||
const end: Position;
|
export class UserCredentials {
|
||||||
|
constructor(username: string, password: string);
|
||||||
|
readonly username: string;
|
||||||
|
readonly password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventData {
|
export class PersistentSubscriptionSettings {
|
||||||
readonly eventId: string;
|
constructor(resolveLinkTos: boolean, startFrom: number, extraStatistics: boolean, messageTimeout: number,
|
||||||
readonly type: string;
|
maxRetryCount: number, liveBufferSize: number, readBatchSize: number, historyBufferSize: number,
|
||||||
readonly isJson: boolean;
|
checkPointAfter: number, minCheckPointCount: number, maxCheckPointCount: number,
|
||||||
readonly data: Buffer;
|
maxSubscriberCount: number, namedConsumerStrategy: string)
|
||||||
readonly metadata: Buffer;
|
static create();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createJsonEventData(eventId: string, event: any, metadata?: any, type?: string): EventData;
|
export namespace SystemConsumerStrategies {
|
||||||
|
const DispatchToSingle: string;
|
||||||
export function createEventData(eventId: string, type: string, isJson: boolean, data: Buffer, metadata?: Buffer): EventData;
|
const RoundRobin: string;
|
||||||
|
const Pinned: string
|
||||||
export interface TcpEndPoint {
|
|
||||||
port: number;
|
|
||||||
host: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GossipSeed {
|
export class GossipSeed {
|
||||||
|
@ -40,50 +35,71 @@ export class GossipSeed {
|
||||||
readonly hostHeader: string;
|
readonly hostHeader: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose errors
|
||||||
|
export class WrongExpectedVersionError {
|
||||||
|
readonly name: string;
|
||||||
|
readonly action: string;
|
||||||
|
readonly message: string;
|
||||||
|
readonly stream?: string;
|
||||||
|
readonly expectedVersion?: number;
|
||||||
|
readonly transactionId?: Long;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class StreamDeletedError {
|
||||||
|
readonly message: string;
|
||||||
|
readonly stream?: string;
|
||||||
|
readonly transactionId?: Long;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AccessDeniedError {
|
||||||
|
readonly name: string;
|
||||||
|
readonly action: string;
|
||||||
|
readonly message: string;
|
||||||
|
readonly stream?: string;
|
||||||
|
readonly transactionId?: Long;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expose enums/constants
|
||||||
|
|
||||||
|
export namespace expectedVersion {
|
||||||
|
const any: number;
|
||||||
|
const noStream: number;
|
||||||
|
const emptyStream: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace positions {
|
||||||
|
const start: Position;
|
||||||
|
const end: Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
// systemMetadata
|
||||||
|
// eventReadStatus
|
||||||
|
// sliceReadStatus
|
||||||
|
|
||||||
|
// Expose loggers
|
||||||
|
|
||||||
export interface Logger {
|
export interface Logger {
|
||||||
debug(fmt: string, ...args: any[]): void;
|
debug(fmt: string, ...args: any[]): void;
|
||||||
info(fmt: string, ...args: any[]): void;
|
info(fmt: string, ...args: any[]): void;
|
||||||
error(fmt: string, ...args: any[]): void;
|
error(fmt: string, ...args: any[]): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UserCredentials {
|
export class NoOpLogger implements Logger {
|
||||||
constructor(username: string, password: string);
|
constructor()
|
||||||
readonly username: string;
|
debug(fmt: string, ...args: any[]): void;
|
||||||
readonly password: string;
|
info(fmt: string, ...args: any[]): void;
|
||||||
|
error(fmt: string, ...args: any[]): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConnectionSettings {
|
export class FileLogger implements Logger {
|
||||||
log?: Logger,
|
constructor(filePath: string, append: boolean);
|
||||||
verboseLogging?: boolean,
|
debug(fmt: string, ...args: any[]): void;
|
||||||
|
info(fmt: string, ...args: any[]): void;
|
||||||
maxQueueSize?: number,
|
error(fmt: string, ...args: any[]): void;
|
||||||
maxConcurrentItems?: number,
|
|
||||||
maxRetries?: number,
|
|
||||||
maxReconnections?: number,
|
|
||||||
|
|
||||||
requireMaster?: boolean,
|
|
||||||
|
|
||||||
reconnectionDelay?: number,
|
|
||||||
operationTimeout?: number,
|
|
||||||
operationTimeoutCheckPeriod?: number,
|
|
||||||
|
|
||||||
defaultUserCredentials?: UserCredentials,
|
|
||||||
useSslConnection?: boolean,
|
|
||||||
targetHost?: TcpEndPoint,
|
|
||||||
validateServer?: boolean,
|
|
||||||
|
|
||||||
failOnNoServerResponse?: boolean,
|
|
||||||
heartbeatInterval?: number,
|
|
||||||
heartbeatTimeout?: number,
|
|
||||||
clientConnectionTimeout?: number,
|
|
||||||
|
|
||||||
// Cluster Settings
|
|
||||||
clusterDns?: string,
|
|
||||||
maxDiscoverAttempts?: number,
|
|
||||||
externalGossipPort?: number,
|
|
||||||
gossipTimeout?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
export interface WriteResult {
|
export interface WriteResult {
|
||||||
readonly nextExpectedVersion: number;
|
readonly nextExpectedVersion: number;
|
||||||
readonly logPosition: Position;
|
readonly logPosition: Position;
|
||||||
|
@ -182,6 +198,19 @@ export interface SubscriptionDroppedCallback<TSubscription> {
|
||||||
(subscription: TSubscription, reason: string, error?: Error): void;
|
(subscription: TSubscription, reason: string, error?: Error): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TcpEndPoint {
|
||||||
|
port: number;
|
||||||
|
host: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EventData {
|
||||||
|
readonly eventId: string;
|
||||||
|
readonly type: string;
|
||||||
|
readonly isJson: boolean;
|
||||||
|
readonly data: Buffer;
|
||||||
|
readonly metadata: Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
export interface EventStoreNodeConnection {
|
export interface EventStoreNodeConnection {
|
||||||
connect(): Promise<void>;
|
connect(): Promise<void>;
|
||||||
close(): void;
|
close(): void;
|
||||||
|
@ -209,4 +238,40 @@ export interface EventStoreNodeConnection {
|
||||||
once(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error", listener: (arg: Error | string | TcpEndPoint) => void): this;
|
once(event: "connected" | "disconnected" | "reconnecting" | "closed" | "error", listener: (arg: Error | string | TcpEndPoint) => void): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose helper functions
|
||||||
|
|
||||||
|
export interface ConnectionSettings {
|
||||||
|
log?: Logger,
|
||||||
|
verboseLogging?: boolean,
|
||||||
|
|
||||||
|
maxQueueSize?: number,
|
||||||
|
maxConcurrentItems?: number,
|
||||||
|
maxRetries?: number,
|
||||||
|
maxReconnections?: number,
|
||||||
|
|
||||||
|
requireMaster?: boolean,
|
||||||
|
|
||||||
|
reconnectionDelay?: number,
|
||||||
|
operationTimeout?: number,
|
||||||
|
operationTimeoutCheckPeriod?: number,
|
||||||
|
|
||||||
|
defaultUserCredentials?: UserCredentials,
|
||||||
|
useSslConnection?: boolean,
|
||||||
|
targetHost?: TcpEndPoint,
|
||||||
|
validateServer?: boolean,
|
||||||
|
|
||||||
|
failOnNoServerResponse?: boolean,
|
||||||
|
heartbeatInterval?: number,
|
||||||
|
heartbeatTimeout?: number,
|
||||||
|
clientConnectionTimeout?: number,
|
||||||
|
|
||||||
|
// Cluster Settings
|
||||||
|
clusterDns?: string,
|
||||||
|
maxDiscoverAttempts?: number,
|
||||||
|
externalGossipPort?: number,
|
||||||
|
gossipTimeout?: number
|
||||||
|
}
|
||||||
|
|
||||||
export function createConnection(settings: ConnectionSettings, endPointOrGossipSeed: string | TcpEndPoint | GossipSeed[], connectionName?: string): EventStoreNodeConnection;
|
export function createConnection(settings: ConnectionSettings, endPointOrGossipSeed: string | TcpEndPoint | GossipSeed[], connectionName?: string): EventStoreNodeConnection;
|
||||||
|
export function createJsonEventData(eventId: string, event: any, metadata?: any, type?: string): EventData;
|
||||||
|
export function createEventData(eventId: string, type: string, isJson: boolean, data: Buffer, metadata?: Buffer): EventData;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "eventstore-node",
|
"name": "eventstore-node",
|
||||||
"version": "0.0.26",
|
"version": "0.0.27",
|
||||||
"description": "A port of the EventStore .Net ClientAPI to Node.js",
|
"description": "A port of the EventStore .Net ClientAPI to Node.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
|
|
|
@ -20,13 +20,13 @@ const positions = {
|
||||||
* @param {string} [type] Event type
|
* @param {string} [type] Event type
|
||||||
* @returns {EventData}
|
* @returns {EventData}
|
||||||
*/
|
*/
|
||||||
module.exports.createJsonEventData = function (eventId, event, metadata, type) {
|
function createJsonEventData(eventId, event, metadata, type) {
|
||||||
if (!event || typeof event !== 'object') throw new TypeError("data must be an object.");
|
if (!event || typeof event !== 'object') throw new TypeError("data must be an object.");
|
||||||
|
|
||||||
var eventBuf = new Buffer(JSON.stringify(event));
|
var eventBuf = new Buffer(JSON.stringify(event));
|
||||||
var metaBuf = metadata ? new Buffer(JSON.stringify(metadata)) : null;
|
var metaBuf = metadata ? new Buffer(JSON.stringify(metadata)) : null;
|
||||||
return new EventData(eventId, type || event.constructor.name, true, eventBuf, metaBuf);
|
return new EventData(eventId, type || event.constructor.name, true, eventBuf, metaBuf);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an EventData object from event/metadata buffer(s)
|
* Create an EventData object from event/metadata buffer(s)
|
||||||
|
@ -38,17 +38,17 @@ module.exports.createJsonEventData = function (eventId, event, metadata, type) {
|
||||||
* @param {Buffer} [metadata] Metadata buffer
|
* @param {Buffer} [metadata] Metadata buffer
|
||||||
* @returns {EventData}
|
* @returns {EventData}
|
||||||
*/
|
*/
|
||||||
module.exports.createEventData = function (eventId, type, isJson, data, metadata) {
|
function createEventData(eventId, type, isJson, data, metadata) {
|
||||||
return new EventData(eventId, type, isJson, data, metadata);
|
return new EventData(eventId, type, isJson, data, metadata);
|
||||||
};
|
}
|
||||||
|
|
||||||
// Expose classes
|
// Expose classes
|
||||||
module.exports.EventStoreConnection = require('./eventStoreConnection');
|
module.exports.Position = results.Position;
|
||||||
module.exports.UserCredentials = require('./systemData/userCredentials');
|
module.exports.UserCredentials = require('./systemData/userCredentials');
|
||||||
module.exports.EventData = EventData;
|
|
||||||
module.exports.PersistentSubscriptionSettings = require('./persistentSubscriptionSettings');
|
module.exports.PersistentSubscriptionSettings = require('./persistentSubscriptionSettings');
|
||||||
module.exports.SystemConsumerStrategies = require('./systemConsumerStrategies');
|
module.exports.SystemConsumerStrategies = require('./systemConsumerStrategies');
|
||||||
module.exports.GossipSeed = require('./gossipSeed');
|
module.exports.GossipSeed = require('./gossipSeed');
|
||||||
|
module.exports.EventStoreConnection = require('./eventStoreConnection');
|
||||||
// Expose errors
|
// Expose errors
|
||||||
module.exports.WrongExpectedVersionError = require('./errors/wrongExpectedVersionError');
|
module.exports.WrongExpectedVersionError = require('./errors/wrongExpectedVersionError');
|
||||||
module.exports.StreamDeletedError = require('./errors/streamDeletedError');
|
module.exports.StreamDeletedError = require('./errors/streamDeletedError');
|
||||||
|
@ -63,4 +63,6 @@ module.exports.sliceReadStatus = require('./sliceReadStatus');
|
||||||
module.exports.NoopLogger = require('./common/log/noopLogger');
|
module.exports.NoopLogger = require('./common/log/noopLogger');
|
||||||
module.exports.FileLogger = require('./common/log/fileLogger');
|
module.exports.FileLogger = require('./common/log/fileLogger');
|
||||||
// Expose Helper functions
|
// Expose Helper functions
|
||||||
module.exports.createConnection = module.exports.EventStoreConnection.create;
|
module.exports.createConnection = require('./eventStoreConnection').create;
|
||||||
|
module.exports.createJsonEventData = createJsonEventData;
|
||||||
|
module.exports.createEventData = createEventData;
|
||||||
|
|
|
@ -21,6 +21,8 @@ function PersistentSubscriptionSettings(
|
||||||
this.namedConsumerStrategy = namedConsumerStrategy;
|
this.namedConsumerStrategy = namedConsumerStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.create = function() {
|
PersistentSubscriptionSettings.create = function() {
|
||||||
return new PersistentSubscriptionSettings(false, -1, false, 30000, 500, 500, 10, 20, 2000, 10, 1000, 0, SystemConsumerStrategies.RoundRobin);
|
return new PersistentSubscriptionSettings(false, -1, false, 30000, 500, 500, 10, 20, 2000, 10, 1000, 0, SystemConsumerStrategies.RoundRobin);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports = PersistentSubscriptionSettings;
|
Loading…
Reference in New Issue
Block a user