Skip to content

Commit

Permalink
JS driver v1.3.0: Checking in transpiled files for bower
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed May 7, 2017
1 parent 0cef23d commit 1ab1b8b
Show file tree
Hide file tree
Showing 13 changed files with 2,055 additions and 1,329 deletions.
1,465 changes: 884 additions & 581 deletions lib/browser/neo4j-web.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions lib/browser/neo4j-web.min.js

Large diffs are not rendered by default.

1,778 changes: 1,080 additions & 698 deletions lib/browser/neo4j-web.test.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/v1/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var READ = 'READ',
WRITE = 'WRITE';
/**
* A driver maintains one or more {@link Session sessions} with a remote
* Neo4j instance. Through the {@link Session sessions} you can send statements
* A driver maintains one or more {@link Session}s with a remote
* Neo4j instance. Through the {@link Session}s you can send statements
* and retrieve results from the database.
*
* Drivers are reasonably expensive to create - you should strive to keep one
Expand Down Expand Up @@ -161,7 +161,7 @@ var Driver = function () {
* will be pulling a session out of the common pool.
*
* This comes with some responsibility - make sure you always call
* {@link Session#close()} when you are done using a session, and likewise,
* {@link close} when you are done using a session, and likewise,
* make sure you don't close your session before you are done using it. Once
* it is returned to the pool, the session will be reset to a clean state and
* made available for others to use.
Expand Down
9 changes: 9 additions & 0 deletions lib/v1/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
// A common place for constructing error objects, to keep them
// uniform across the driver surface.

/**
* @type {string}
*/
var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
/**
* @type {string}
*/
var SESSION_EXPIRED = 'SessionExpired';
/**
* @type {string}
*/
var PROTOCOL_ERROR = 'ProtocolError';

function newError(message) {
Expand Down
4 changes: 2 additions & 2 deletions lib/v1/graph-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var Node = function () {
/**
* @constructor
* @param {Integer} identity - Unique identity
* @param {Array} labels - Array for all labels
* @param {Array<string>} labels - Array for all labels
* @param {Object} properties - Map with node properties
*/
function Node(identity, labels, properties) {
Expand Down Expand Up @@ -211,7 +211,7 @@ var Path =
* @constructor
* @param {Node} start - start node
* @param {Node} end - end node
* @param {Array} segments - Array of Segments
* @param {Array<PathSegment>} segments - Array of Segments
*/
function Path(start, end, segments) {
(0, _classCallCheck3.default)(this, Path);
Expand Down
38 changes: 31 additions & 7 deletions lib/v1/internal/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ var Connection = function () {
* failing, and the connection getting ejected from the session pool.
*
* @param err an error object, forwarded to all current and future subscribers
* @private
* @protected
*/


Expand All @@ -327,6 +327,12 @@ var Connection = function () {
value: function _handleMessage(msg) {
var _this = this;

if (this._isBroken) {
// ignore all incoming messages when this connection is broken. all previously pending observers failed
// with the fatal error. all future observers will fail with same fatal error.
return;
}

var payload = msg.fields[0];

switch (msg.signature) {
Expand All @@ -339,7 +345,7 @@ var Connection = function () {
try {
this._currentObserver.onCompleted(payload);
} finally {
this._currentObserver = this._pendingObservers.shift();
this._updateCurrentObserver();
}
break;
case FAILURE:
Expand All @@ -348,7 +354,7 @@ var Connection = function () {
this._currentFailure = (0, _error.newError)(payload.message, payload.code);
this._currentObserver.onError(this._currentFailure);
} finally {
this._currentObserver = this._pendingObservers.shift();
this._updateCurrentObserver();
// Things are now broken. Pending observers will get FAILURE messages routed until
// We are done handling this failure.
if (!this._isHandlingFailure) {
Expand All @@ -375,7 +381,7 @@ var Connection = function () {
try {
if (this._currentFailure && this._currentObserver.onError) this._currentObserver.onError(this._currentFailure);else if (this._currentObserver.onError) this._currentObserver.onError(payload);
} finally {
this._currentObserver = this._pendingObservers.shift();
this._updateCurrentObserver();
}
break;
default:
Expand Down Expand Up @@ -533,6 +539,17 @@ var Connection = function () {
return this._state.initializationCompleted();
}

/*
* Pop next pending observer form the list of observers and make it current observer.
* @protected
*/

}, {
key: '_updateCurrentObserver',
value: function _updateCurrentObserver() {
this._currentObserver = this._pendingObservers.shift();
}

/**
* Synchronize - flush all queued outgoing messages and route their responses
* to their respective handlers.
Expand Down Expand Up @@ -604,7 +621,8 @@ var ConnectionState = function () {
}

/**
* Wrap the given observer to track connection's initialization state.
* Wrap the given observer to track connection's initialization state. Connection is closed by the server if
* processing of INIT message fails so returned observer will handle initialization failure as a fatal error.
* @param {StreamObserver} observer the observer used for INIT message.
* @return {StreamObserver} updated observer.
*/
Expand All @@ -627,8 +645,14 @@ var ConnectionState = function () {
_this10._rejectPromise(error);
_this10._rejectPromise = null;
}
if (observer && observer.onError) {
observer.onError(error);

_this10._connection._updateCurrentObserver(); // make sure this same observer will not be called again
try {
if (observer && observer.onError) {
observer.onError(error);
}
} finally {
_this10._connection._handleFatalError(error);
}
},
onCompleted: function onCompleted(metaData) {
Expand Down
11 changes: 8 additions & 3 deletions lib/v1/internal/routing-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var CALL_GET_SERVERS = 'CALL dbms.cluster.routing.getServers';
var GET_ROUTING_TABLE_PARAM = 'context';
var CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable({' + GET_ROUTING_TABLE_PARAM + '})';
var PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound';
var UNAUTHORIZED_CODE = 'Neo.ClientError.Security.Unauthorized';

var RoutingUtil = function () {
function RoutingUtil(routingContext) {
Expand Down Expand Up @@ -84,10 +85,14 @@ var RoutingUtil = function () {
if (error.code === PROCEDURE_NOT_FOUND_CODE) {
// throw when getServers procedure not found because this is clearly a configuration issue
throw (0, _error.newError)('Server ' + routerAddress + ' could not perform routing. ' + 'Make sure you are connecting to a causal cluster', _error.SERVICE_UNAVAILABLE);
} else if (error.code === UNAUTHORIZED_CODE) {
// auth error is a sign of a configuration issue, rediscovery should not proceed
throw error;
} else {
// return nothing when failed to connect because code higher in the callstack is still able to retry with a
// different session towards a different router
return null;
}
// return nothing when failed to connect because code higher in the callstack is still able to retry with a
// different session towards a different router
return null;
});
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion lib/v1/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var Record = function () {
* will get three arguments - the value, the key and this record, in that
* order.
*
* @param visitor
* @param {function(value: Object, key: string, record: Record)} visitor the function to apply to each field.
*/


Expand Down
2 changes: 1 addition & 1 deletion lib/v1/result-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function ProfiledPlan(profile) {
};

/**
* Get statistical information for a {Result}.
* Get statistical information for a {@link Result}.
* @access public
*/

Expand Down
1 change: 1 addition & 0 deletions lib/v1/routing-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

/**
* A driver that supports routing in a core-edge cluster.
* @private
*/
/**
* Copyright (c) 2002-2017 "Neo Technology,","
Expand Down
8 changes: 4 additions & 4 deletions lib/v1/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ var Session = function () {
* While a transaction is open the session cannot be used to run statements outside the transaction.
*
* @param {string} bookmark - a reference to a previous transaction. DEPRECATED: This parameter is deprecated in
* favour of {@link Driver#session(string)} that accepts an initial bookmark. Session will ensure that all nested
* favour of {@link Driver#session} that accepts an initial bookmark. Session will ensure that all nested
* transactions are chained with bookmarks to guarantee causal consistency.
* @returns {Transaction} - New Transaction
*/
Expand Down Expand Up @@ -203,7 +203,7 @@ var Session = function () {
/**
* Return the bookmark received following the last completed {@link Transaction}.
*
* @return a reference to a previous transac'tion
* @return a reference to a previous transaction
*/

}, {
Expand All @@ -213,7 +213,7 @@ var Session = function () {
}

/**
* Execute given unit of work in a {@link Driver#READ} transaction.
* Execute given unit of work in a {@link READ} transaction.
*
* Transaction will automatically be committed unless the given function throws or returns a rejected promise.
* Some failures of the given function or the commit itself will be retried with exponential backoff with initial
Expand All @@ -233,7 +233,7 @@ var Session = function () {
}

/**
* Execute given unit of work in a {@link Driver#WRITE} transaction.
* Execute given unit of work in a {@link WRITE} transaction.
*
* Transaction will automatically be committed unless the given function throws or returns a rejected promise.
* Some failures of the given function or the commit itself will be retried with exponential backoff with initial
Expand Down
28 changes: 15 additions & 13 deletions lib/v1/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var Transaction = function () {

/**
* Run Cypher statement
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
* Could be called with a statement object i.e.: <code>{statement: "MATCH ...", parameters: {param: 1}}</code>
* or with the statement and parameters as separate arguments.
* @param {mixed} statement - Cypher statement to execute
* @param {Object} parameters - Map with parameters to use in statement
Expand Down Expand Up @@ -270,7 +270,7 @@ var _states = {
return observer.onError(error);
});

return newRunResult(observer, statement, parameters, function () {
return _newRunResult(observer, statement, parameters, function () {
return observer.serverMeta();
});
}
Expand All @@ -283,15 +283,15 @@ var _states = {
observer.onError({
error: "Cannot commit statements in this transaction, because previous statements in the " + "transaction has failed and the transaction has been rolled back. Please start a new" + " transaction to run another statement."
});
return { result: newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
},
rollback: function rollback(connectionHolder, observer) {
observer.onError({ error: "Cannot rollback transaction, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
},
run: function run(connectionHolder, observer, statement, parameters) {
observer.onError({ error: "Cannot run statement, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
return newDummyResult(observer, statement, parameters);
return _newDummyResult(observer, statement, parameters);
}
},

Expand All @@ -301,15 +301,15 @@ var _states = {
observer.onError({
error: "Cannot commit statements in this transaction, because commit has already been successfully called on the transaction and transaction has been closed. Please start a new" + " transaction to run another statement."
});
return { result: newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
},
rollback: function rollback(connectionHolder, observer) {
observer.onError({ error: "Cannot rollback transaction, because transaction has already been successfully closed." });
return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
},
run: function run(connectionHolder, observer, statement, parameters) {
observer.onError({ error: "Cannot run statement, because transaction has already been successfully closed." });
return newDummyResult(observer, statement, parameters);
return _newDummyResult(observer, statement, parameters);
}
},

Expand All @@ -319,15 +319,15 @@ var _states = {
observer.onError({
error: "Cannot commit this transaction, because it has already been rolled back."
});
return { result: newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
},
rollback: function rollback(connectionHolder, observer) {
observer.onError({ error: "Cannot rollback transaction, because transaction has already been rolled back." });
return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
},
run: function run(connectionHolder, observer, statement, parameters) {
observer.onError({ error: "Cannot run statement, because transaction has already been rolled back." });
return newDummyResult(observer, statement, parameters);
return _newDummyResult(observer, statement, parameters);
}
}
};
Expand Down Expand Up @@ -357,8 +357,9 @@ function _runPullAll(msg, connectionHolder, observer) {
* @param {object} parameters - the parameters for cypher statement that produced the result.
* @param {function} metadataSupplier - the function that returns a metadata object.
* @return {Result} new result.
* @private
*/
function newRunResult(observer, statement, parameters, metadataSupplier) {
function _newRunResult(observer, statement, parameters, metadataSupplier) {
return new _result2.default(observer, statement, parameters, metadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
}

Expand All @@ -370,8 +371,9 @@ function newRunResult(observer, statement, parameters, metadataSupplier) {
* @param {string} statement - the cypher statement that produced the result.
* @param {object} parameters - the parameters for cypher statement that produced the result.
* @return {Result} new result.
* @private
*/
function newDummyResult(observer, statement, parameters) {
function _newDummyResult(observer, statement, parameters) {
return new _result2.default(observer, statement, parameters, emptyMetadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
}

Expand Down

0 comments on commit 1ab1b8b

Please sign in to comment.