node-eventstore-client
Version:
A port of the EventStore .Net ClientAPI to Node.js
324 lines (285 loc) • 20.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: results.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: results.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>var guidParse = require('./common/guid-parse');
var Long = require('long');
var ensure = require('./common/utils/ensure');
/**
* @public
* @param {!number|!Long} commitPosition
* @param {!number|!Long} preparePosition
* @constructor
* @property {!Long} commitPosition
* @property {!Long} preparePosition
*/
function Position(commitPosition, preparePosition) {
ensure.notNull(commitPosition, "commitPosition");
ensure.notNull(preparePosition, "preparePosition");
this.commitPosition = Long.fromValue(commitPosition);
this.preparePosition = Long.fromValue(preparePosition);
Object.freeze(this);
}
Position.prototype.compareTo = function(other) {
if (this.commitPosition.lt(other.commitPosition) || (this.commitPosition.eq(other.commitPosition)&& this.preparePosition.lt(other.preparePosition))) {
return -1;
}
if (this.commitPosition.gt(other.commitPosition) || (this.commitPosition.eq(other.commitPosition) && this.preparePosition.gt(other.preparePosition))) {
return 1;
}
return 0;
};
Position.prototype.toString = function() {
return [this.commitPosition.toString(), this.preparePosition.toString()].join("/");
};
Position.start = new Position(0,0);
Position.end = new Position(-1,-1);
const EventReadStatus = Object.freeze({
Success: 'success',
NotFound: 'notFound',
NoStream: 'noStream',
StreamDeleted: 'streamDeleted'
});
/**
* @param {object} ev
* @constructor
* @property {string} eventStreamId
* @property {string} eventId
* @property {Long} eventNumber
* @property {string} eventType
* @property {Date} created
* @property {number} createdEpoch
* @property {?Buffer} data
* @property {?Buffer} metadata
* @property {boolean} isJson
*/
function RecordedEvent(ev) {
this.eventStreamId = ev.eventStreamId;
this.eventId = guidParse.unparse(ev.eventId);
this.eventNumber = ev.eventNumber;
this.eventType = ev.eventType;
this.created = new Date(ev.createdEpoch ? ev.createdEpoch.toNumber() : 0);
this.createdEpoch = ev.createdEpoch ? ev.createdEpoch.toNumber() : 0;
this.data = ev.data ? ev.data : Buffer.alloc(0);
this.metadata = ev.metadata ? ev.metadata : Buffer.alloc(0);
this.isJson = ev.dataContentType === 1;
Object.freeze(this);
}
/**
* @param {object} ev
* @constructor
* @property {?RecordedEvent} event
* @property {?RecordedEvent} link
* @property {?RecordedEvent} originalEvent
* @property {boolean} isResolved
* @property {?Position} originalPosition
* @property {string} originalStreamId
* @property {Long} originalEventNumber
*/
function ResolvedEvent(ev) {
this.event = ev.event === null ? null : new RecordedEvent(ev.event);
this.link = ev.link === null ? null : new RecordedEvent(ev.link);
this.originalEvent = this.link || this.event;
this.isResolved = this.link !== null && this.event !== null;
this.originalPosition = (ev.commitPosition && ev.preparePosition) ? new Position(ev.commitPosition, ev.preparePosition) : null;
this.originalStreamId = this.originalEvent && this.originalEvent.eventStreamId;
this.originalEventNumber = this.originalEvent && this.originalEvent.eventNumber;
Object.freeze(this);
}
/**
*
* @param {string} status
* @param {string} stream
* @param {Long} eventNumber
* @param {object} event
* @constructor
* @property {string} status
* @property {string} stream
* @property {Long} eventNumber
* @property {ResolvedEvent} event
*/
function EventReadResult(status, stream, eventNumber, event) {
this.status = status;
this.stream = stream;
this.eventNumber = eventNumber;
this.event = status === EventReadStatus.Success ? new ResolvedEvent(event) : null;
Object.freeze(this);
}
/**
* @param {number} nextExpectedVersion
* @param {Position} logPosition
* @constructor
* @property {Long} nextExpectedVersion
* @property {Position} logPosition
*/
function WriteResult(nextExpectedVersion, logPosition) {
this.nextExpectedVersion = nextExpectedVersion;
this.logPosition = logPosition;
Object.freeze(this);
}
/**
* @param {string} status
* @param {string} stream
* @param {Long} fromEventNumber
* @param {string} readDirection
* @param {object[]} events
* @param {Long} nextEventNumber
* @param {Long} lastEventNumber
* @param {boolean} isEndOfStream
* @constructor
* @property {string} status
* @property {string} stream
* @property {Long} fromEventNumber
* @property {string} readDirection
* @property {ResolvedEvent[]} events
* @property {Long} nextEventNumber
* @property {Long} lastEventNumber
* @property {boolean} isEndOfStream
*/
function StreamEventsSlice(
status, stream, fromEventNumber, readDirection, events, nextEventNumber, lastEventNumber, isEndOfStream
) {
this.status = status;
this.stream = stream;
this.fromEventNumber = fromEventNumber;
this.readDirection = readDirection;
this.events = events ? events.map(function(ev) { return new ResolvedEvent(ev); }) : [];
this.nextEventNumber = nextEventNumber;
this.lastEventNumber = lastEventNumber;
this.isEndOfStream = isEndOfStream;
Object.freeze(this);
}
/**
* @param {string} readDirection
* @param {Position} fromPosition
* @param {Position} nextPosition
* @param {ResolvedEvent[]} events
* @constructor
* @property {string} readDirection
* @property {Position} fromPosition
* @property {Position} nextPosition
* @property {ResolvedEvent[]} events
*/
function AllEventsSlice(readDirection, fromPosition, nextPosition, events) {
this.readDirection = readDirection;
this.fromPosition = fromPosition;
this.nextPosition = nextPosition;
this.events = events ? events.map(function(ev){ return new ResolvedEvent(ev); }) : [];
this.isEndOfStream = events === null || events.length === 0;
Object.freeze(this);
}
/**
* @param {Position} logPosition
* @constructor
* @property {Position} logPosition
*/
function DeleteResult(logPosition) {
this.logPosition = logPosition;
Object.freeze(this);
}
/**
* @param {string} stream
* @param {boolean} isStreamDeleted
* @param {Long} metastreamVersion
* @param {object} streamMetadata
* @constructor
* @property {string} stream
* @property {boolean} isStreamDeleted
* @property {Long} metastreamVersion
* @property {object} streamMetadata
*/
function RawStreamMetadataResult(stream, isStreamDeleted, metastreamVersion, streamMetadata) {
ensure.notNullOrEmpty(stream);
this.stream = stream;
this.isStreamDeleted = isStreamDeleted;
this.metastreamVersion = metastreamVersion;
this.streamMetadata = streamMetadata;
Object.freeze(this);
}
const PersistentSubscriptionCreateStatus = Object.freeze({
Success: 'success',
NotFound: 'notFound',
Failure: 'failure'
});
/**
* @param {string} status
* @constructor
* @property {string} status
*/
function PersistentSubscriptionCreateResult(status) {
this.status = status;
Object.freeze(this);
}
const PersistentSubscriptionUpdateStatus = Object.freeze({
Success: 'success',
NotFound: 'notFound',
Failure: 'failure',
AccessDenied: 'accessDenied'
});
/**
* @param {string} status
* @constructor
* @property {string} status
*/
function PersistentSubscriptionUpdateResult(status) {
this.status = status;
Object.freeze(this);
}
const PersistentSubscriptionDeleteStatus = Object.freeze({
Success: 'success',
Failure: 'failure'
});
/**
* @param {string} status
* @constructor
* @property {string} status
*/
function PersistentSubscriptionDeleteResult(status) {
this.status = status;
Object.freeze(this);
}
// Exports Constructors
exports.Position = Position;
exports.ResolvedEvent = ResolvedEvent;
exports.EventReadStatus = EventReadStatus;
exports.EventReadResult = EventReadResult;
exports.WriteResult = WriteResult;
exports.StreamEventsSlice = StreamEventsSlice;
exports.AllEventsSlice = AllEventsSlice;
exports.DeleteResult = DeleteResult;
exports.RawStreamMetadataResult = RawStreamMetadataResult;
exports.PersistentSubscriptionCreateResult = PersistentSubscriptionCreateResult;
exports.PersistentSubscriptionCreateStatus = PersistentSubscriptionCreateStatus;
exports.PersistentSubscriptionUpdateResult = PersistentSubscriptionUpdateResult;
exports.PersistentSubscriptionUpdateStatus = PersistentSubscriptionUpdateStatus;
exports.PersistentSubscriptionDeleteResult = PersistentSubscriptionDeleteResult;
exports.PersistentSubscriptionDeleteStatus = PersistentSubscriptionDeleteStatus;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="EventStore.html">EventStore</a></li><li><a href="EventStore.Client.html">Client</a></li><li><a href="EventStore.Client.Messages.html">Messages</a></li></ul><h3>Classes</h3><ul><li><a href="AllEventsSlice.html">AllEventsSlice</a></li><li><a href="ClusterDiscoverer.html">ClusterDiscoverer</a></li><li><a href="DeleteResult.html">DeleteResult</a></li><li><a href="EventReadResult.html">EventReadResult</a></li><li><a href="EventStore.Client.Messages.CheckpointReached.html">CheckpointReached</a></li><li><a href="EventStore.Client.Messages.ClientIdentified.html">ClientIdentified</a></li><li><a href="EventStore.Client.Messages.ConnectToPersistentSubscription.html">ConnectToPersistentSubscription</a></li><li><a href="EventStore.Client.Messages.CreatePersistentSubscription.html">CreatePersistentSubscription</a></li><li><a href="EventStore.Client.Messages.CreatePersistentSubscriptionCompleted.html">CreatePersistentSubscriptionCompleted</a></li><li><a href="EventStore.Client.Messages.DeletePersistentSubscription.html">DeletePersistentSubscription</a></li><li><a href="EventStore.Client.Messages.DeletePersistentSubscriptionCompleted.html">DeletePersistentSubscriptionCompleted</a></li><li><a href="EventStore.Client.Messages.DeleteStream.html">DeleteStream</a></li><li><a href="EventStore.Client.Messages.DeleteStreamCompleted.html">DeleteStreamCompleted</a></li><li><a href="EventStore.Client.Messages.EventRecord.html">EventRecord</a></li><li><a href="EventStore.Client.Messages.Filter.html">Filter</a></li><li><a href="EventStore.Client.Messages.FilteredReadAllEvents.html">FilteredReadAllEvents</a></li><li><a href="EventStore.Client.Messages.FilteredReadAllEventsCompleted.html">FilteredReadAllEventsCompleted</a></li><li><a href="EventStore.Client.Messages.FilteredSubscribeToStream.html">FilteredSubscribeToStream</a></li><li><a href="EventStore.Client.Messages.IdentifyClient.html">IdentifyClient</a></li><li><a href="EventStore.Client.Messages.NewEvent.html">NewEvent</a></li><li><a href="EventStore.Client.Messages.NotHandled.html">NotHandled</a></li><li><a href="EventStore.Client.Messages.NotHandled.LeaderInfo.html">LeaderInfo</a></li><li><a href="EventStore.Client.Messages.PersistentSubscriptionAckEvents.html">PersistentSubscriptionAckEvents</a></li><li><a href="EventStore.Client.Messages.PersistentSubscriptionConfirmation.html">PersistentSubscriptionConfirmation</a></li><li><a href="EventStore.Client.Messages.PersistentSubscriptionNakEvents.html">PersistentSubscriptionNakEvents</a></li><li><a href="EventStore.Client.Messages.PersistentSubscriptionStreamEventAppeared.html">PersistentSubscriptionStreamEventAppeared</a></li><li><a href="EventStore.Client.Messages.ReadAllEvents.html">ReadAllEvents</a></li><li><a href="EventStore.Client.Messages.ReadAllEventsCompleted.html">ReadAllEventsCompleted</a></li><li><a href="EventStore.Client.Messages.ReadEvent.html">ReadEvent</a></li><li><a href="EventStore.Client.Messages.ReadEventCompleted.html">ReadEventCompleted</a></li><li><a href="EventStore.Client.Messages.ReadStreamEvents.html">ReadStreamEvents</a></li><li><a href="EventStore.Client.Messages.ReadStreamEventsCompleted.html">ReadStreamEventsCompleted</a></li><li><a href="EventStore.Client.Messages.ResolvedEvent.html">ResolvedEvent</a></li><li><a href="EventStore.Client.Messages.ResolvedIndexedEvent.html">ResolvedIndexedEvent</a></li><li><a href="EventStore.Client.Messages.ScavengeDatabase.html">ScavengeDatabase</a></li><li><a href="EventStore.Client.Messages.ScavengeDatabaseResponse.html">ScavengeDatabaseResponse</a></li><li><a href="EventStore.Client.Messages.StreamEventAppeared.html">StreamEventAppeared</a></li><li><a href="EventStore.Client.Messages.SubscribeToStream.html">SubscribeToStream</a></li><li><a href="EventStore.Client.Messages.SubscriptionConfirmation.html">SubscriptionConfirmation</a></li><li><a href="EventStore.Client.Messages.SubscriptionDropped.html">SubscriptionDropped</a></li><li><a href="EventStore.Client.Messages.TransactionCommit.html">TransactionCommit</a></li><li><a href="EventStore.Client.Messages.TransactionCommitCompleted.html">TransactionCommitCompleted</a></li><li><a href="EventStore.Client.Messages.TransactionStart.html">TransactionStart</a></li><li><a href="EventStore.Client.Messages.TransactionStartCompleted.html">TransactionStartCompleted</a></li><li><a href="EventStore.Client.Messages.TransactionWrite.html">TransactionWrite</a></li><li><a href="EventStore.Client.Messages.TransactionWriteCompleted.html">TransactionWriteCompleted</a></li><li><a href="EventStore.Client.Messages.UnsubscribeFromStream.html">UnsubscribeFromStream</a></li><li><a href="EventStore.Client.Messages.UpdatePersistentSubscription.html">UpdatePersistentSubscription</a></li><li><a href="EventStore.Client.Messages.UpdatePersistentSubscriptionCompleted.html">UpdatePersistentSubscriptionCompleted</a></li><li><a href="EventStore.Client.Messages.WriteEvents.html">WriteEvents</a></li><li><a href="EventStore.Client.Messages.WriteEventsCompleted.html">WriteEventsCompleted</a></li><li><a href="EventStoreCatchUpSubscription.html">EventStoreCatchUpSubscription</a></li><li><a href="EventStoreNodeConnection.html">EventStoreNodeConnection</a></li><li><a href="EventStoreTransaction.html">EventStoreTransaction</a></li><li><a href="PersistentSubscriptionCreateResult.html">PersistentSubscriptionCreateResult</a></li><li><a href="PersistentSubscriptionDeleteResult.html">PersistentSubscriptionDeleteResult</a></li><li><a href="PersistentSubscriptionUpdateResult.html">PersistentSubscriptionUpdateResult</a></li><li><a href="Position.html">Position</a></li><li><a href="ProjectionsManager.html">ProjectionsManager</a></li><li><a href="RawStreamMetadataResult.html">RawStreamMetadataResult</a></li><li><a href="RecordedEvent.html">RecordedEvent</a></li><li><a href="ResolvedEvent.html">ResolvedEvent</a></li><li><a href="StreamEventsSlice.html">StreamEventsSlice</a></li><li><a href="UserCredentials.html">UserCredentials</a></li><li><a href="WriteResult.html">WriteResult</a></li></ul><h3>Interfaces</h3><ul><li><a href="EventStore.Client.Messages.ICheckpointReached.html">ICheckpointReached</a></li><li><a href="EventStore.Client.Messages.IClientIdentified.html">IClientIdentified</a></li><li><a href="EventStore.Client.Messages.IConnectToPersistentSubscription.html">IConnectToPersistentSubscription</a></li><li><a href="EventStore.Client.Messages.ICreatePersistentSubscription.html">ICreatePersistentSubscription</a></li><li><a href="EventStore.Client.Messages.ICreatePersistentSubscriptionCompleted.html">ICreatePersistentSubscriptionCompleted</a></li><li><a href="EventStore.Client.Messages.IDeletePersistentSubscription.html">IDeletePersistentSubscription</a></li><li><a href="EventStore.Client.Messages.IDeletePersistentSubscriptionCompleted.html">IDeletePersistentSubscriptionCompleted</a></li><li><a href="EventStore.Client.Messages.IDeleteStream.html">IDeleteStream</a></li><li><a href="EventStore.Client.Messages.IDeleteStreamCompleted.html">IDeleteStreamCompleted</a></li><li><a href="EventStore.Client.Messages.IEventRecord.html">IEventRecord</a></li><li><a href="EventStore.Client.Messages.IFilter.html">IFilter</a></li><li><a href="EventStore.Client.Messages.IFilteredReadAllEvents.html">IFilteredReadAllEvents</a></li><li><a href="EventStore.Client.Messages.IFilteredReadAllEventsCompleted.html">IFilteredReadAllEventsCompleted</a></li><li><a href="EventStore.Client.Messages.IFilteredSubscribeToStream.html">IFilteredSubscribeToStream</a></li><li><a href="EventStore.Client.Messages.IIdentifyClient.html">IIdentifyClient</a></li><li><a href="EventStore.Client.Messages.INewEvent.html">INewEvent</a></li><li><a href="EventStore.Client.Messages.INotHandled.html">INotHandled</a></li><li><a href="EventStore.Client.Messages.IPersistentSubscriptionAckEvents.html">IPersistentSubscriptionAckEvents</a></li><li><a href="EventStore.Client.Messages.IPersistentSubscriptionConfirmation.html">IPersistentSubscriptionConfirmation</a></li><li><a href="EventStore.Client.Messages.IPersistentSubscriptionNakEvents.html">IPersistentSubscriptionNakEvents</a></li><li><a href="EventStore.Client.Messages.IPersistentSubscriptionStreamEventAppeared.html">IPersistentSubscriptionStreamEventAppeared</a></li><li><a href="EventStore.Client.Messages.IReadAllEvents.html">IReadAllEvents</a></li><li><a href="EventStore.Client.Messages.IReadAllEventsCompleted.html">IReadAllEventsCompleted</a></li><li><a href="EventStore.Client.Messages.IReadEvent.html">IReadEvent</a></li><li><a href="EventStore.Client.Messages.IReadEventCompleted.html">IReadEventCompleted</a></li><li><a href="EventStore.Client.Messages.IReadStreamEvents.html">IReadStreamEvents</a></li><li><a href="EventStore.Client.Messages.IReadStreamEventsCompleted.html">IReadStreamEventsCompleted</a></li><li><a href="EventStore.Client.Messages.IResolvedEvent.html">IResolvedEvent</a></li><li><a href="EventStore.Client.Messages.IResolvedIndexedEvent.html">IResolvedIndexedEvent</a></li><li><a href="EventStore.Client.Messages.IScavengeDatabase.html">IScavengeDatabase</a></li><li><a href="EventStore.Client.Messages.IScavengeDatabaseResponse.html">IScavengeDatabaseResponse</a></li><li><a href="EventStore.Client.Messages.IStreamEventAppeared.html">IStreamEventAppeared</a></li><li><a href="EventStore.Client.Messages.ISubscribeToStream.html">ISubscribeToStream</a></li><li><a href="EventStore.Client.Messages.ISubscriptionConfirmation.html">ISubscriptionConfirmation</a></li><li><a href="EventStore.Client.Messages.ISubscriptionDropped.html">ISubscriptionDropped</a></li><li><a href="EventStore.Client.Messages.ITransactionCommit.html">ITransactionCommit</a></li><li><a href="EventStore.Client.Messages.ITransactionCommitCompleted.html">ITransactionCommitCompleted</a></li><li><a href="EventStore.Client.Messages.ITransactionStart.html">ITransactionStart</a></li><li><a href="EventStore.Client.Messages.ITransactionStartCompleted.html">ITransactionStartCompleted</a></li><li><a href="EventStore.Client.Messages.ITransactionWrite.html">ITransactionWrite</a></li><li><a href="EventStore.Client.Messages.ITransactionWriteCompleted.html">ITransactionWriteCompleted</a></li><li><a href="EventStore.Client.Messages.IUnsubscribeFromStream.html">IUnsubscribeFromStream</a></li><li><a href="EventStore.Client.Messages.IUpdatePersistentSubscription.html">IUpdatePersistentSubscription</a></li><li><a href="EventStore.Client.Messages.IUpdatePersistentSubscriptionCompleted.html">IUpdatePersistentSubscriptionCompleted</a></li><li><a href="EventStore.Client.Messages.IWriteEvents.html">IWriteEvents</a></li><li><a href="EventStore.Client.Messages.IWriteEventsCompleted.html">IWriteEventsCompleted</a></li><li><a href="EventStore.Client.Messages.NotHandled.ILeaderInfo.html">ILeaderInfo</a></li></ul><h3>Global</h3><ul><li><a href="global.html#createConnection">createConnection</a></li><li><a href="global.html#createEventData">createEventData</a></li><li><a href="global.html#createJsonEventData">createJsonEventData</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.0</a> on Mon Jan 30 2023 16:18:36 GMT-0500 (Eastern Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>