Skip to content

Commit 1ab1b8b

Browse files
committed
JS driver v1.3.0: Checking in transpiled files for bower
1 parent 0cef23d commit 1ab1b8b

13 files changed

+2055
-1329
lines changed

lib/browser/neo4j-web.js

Lines changed: 884 additions & 581 deletions
Large diffs are not rendered by default.

lib/browser/neo4j-web.min.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/browser/neo4j-web.test.js

Lines changed: 1080 additions & 698 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/v1/driver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
7171
var READ = 'READ',
7272
WRITE = 'WRITE';
7373
/**
74-
* A driver maintains one or more {@link Session sessions} with a remote
75-
* Neo4j instance. Through the {@link Session sessions} you can send statements
74+
* A driver maintains one or more {@link Session}s with a remote
75+
* Neo4j instance. Through the {@link Session}s you can send statements
7676
* and retrieve results from the database.
7777
*
7878
* Drivers are reasonably expensive to create - you should strive to keep one
@@ -161,7 +161,7 @@ var Driver = function () {
161161
* will be pulling a session out of the common pool.
162162
*
163163
* This comes with some responsibility - make sure you always call
164-
* {@link Session#close()} when you are done using a session, and likewise,
164+
* {@link close} when you are done using a session, and likewise,
165165
* make sure you don't close your session before you are done using it. Once
166166
* it is returned to the pool, the session will be reset to a clean state and
167167
* made available for others to use.

lib/v1/error.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
4545
// A common place for constructing error objects, to keep them
4646
// uniform across the driver surface.
4747

48+
/**
49+
* @type {string}
50+
*/
4851
var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
52+
/**
53+
* @type {string}
54+
*/
4955
var SESSION_EXPIRED = 'SessionExpired';
56+
/**
57+
* @type {string}
58+
*/
5059
var PROTOCOL_ERROR = 'ProtocolError';
5160

5261
function newError(message) {

lib/v1/graph-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var Node = function () {
4949
/**
5050
* @constructor
5151
* @param {Integer} identity - Unique identity
52-
* @param {Array} labels - Array for all labels
52+
* @param {Array<string>} labels - Array for all labels
5353
* @param {Object} properties - Map with node properties
5454
*/
5555
function Node(identity, labels, properties) {
@@ -211,7 +211,7 @@ var Path =
211211
* @constructor
212212
* @param {Node} start - start node
213213
* @param {Node} end - end node
214-
* @param {Array} segments - Array of Segments
214+
* @param {Array<PathSegment>} segments - Array of Segments
215215
*/
216216
function Path(start, end, segments) {
217217
(0, _classCallCheck3.default)(this, Path);

lib/v1/internal/connector.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ var Connection = function () {
303303
* failing, and the connection getting ejected from the session pool.
304304
*
305305
* @param err an error object, forwarded to all current and future subscribers
306-
* @private
306+
* @protected
307307
*/
308308

309309

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

330+
if (this._isBroken) {
331+
// ignore all incoming messages when this connection is broken. all previously pending observers failed
332+
// with the fatal error. all future observers will fail with same fatal error.
333+
return;
334+
}
335+
330336
var payload = msg.fields[0];
331337

332338
switch (msg.signature) {
@@ -339,7 +345,7 @@ var Connection = function () {
339345
try {
340346
this._currentObserver.onCompleted(payload);
341347
} finally {
342-
this._currentObserver = this._pendingObservers.shift();
348+
this._updateCurrentObserver();
343349
}
344350
break;
345351
case FAILURE:
@@ -348,7 +354,7 @@ var Connection = function () {
348354
this._currentFailure = (0, _error.newError)(payload.message, payload.code);
349355
this._currentObserver.onError(this._currentFailure);
350356
} finally {
351-
this._currentObserver = this._pendingObservers.shift();
357+
this._updateCurrentObserver();
352358
// Things are now broken. Pending observers will get FAILURE messages routed until
353359
// We are done handling this failure.
354360
if (!this._isHandlingFailure) {
@@ -375,7 +381,7 @@ var Connection = function () {
375381
try {
376382
if (this._currentFailure && this._currentObserver.onError) this._currentObserver.onError(this._currentFailure);else if (this._currentObserver.onError) this._currentObserver.onError(payload);
377383
} finally {
378-
this._currentObserver = this._pendingObservers.shift();
384+
this._updateCurrentObserver();
379385
}
380386
break;
381387
default:
@@ -533,6 +539,17 @@ var Connection = function () {
533539
return this._state.initializationCompleted();
534540
}
535541

542+
/*
543+
* Pop next pending observer form the list of observers and make it current observer.
544+
* @protected
545+
*/
546+
547+
}, {
548+
key: '_updateCurrentObserver',
549+
value: function _updateCurrentObserver() {
550+
this._currentObserver = this._pendingObservers.shift();
551+
}
552+
536553
/**
537554
* Synchronize - flush all queued outgoing messages and route their responses
538555
* to their respective handlers.
@@ -604,7 +621,8 @@ var ConnectionState = function () {
604621
}
605622

606623
/**
607-
* Wrap the given observer to track connection's initialization state.
624+
* Wrap the given observer to track connection's initialization state. Connection is closed by the server if
625+
* processing of INIT message fails so returned observer will handle initialization failure as a fatal error.
608626
* @param {StreamObserver} observer the observer used for INIT message.
609627
* @return {StreamObserver} updated observer.
610628
*/
@@ -627,8 +645,14 @@ var ConnectionState = function () {
627645
_this10._rejectPromise(error);
628646
_this10._rejectPromise = null;
629647
}
630-
if (observer && observer.onError) {
631-
observer.onError(error);
648+
649+
_this10._connection._updateCurrentObserver(); // make sure this same observer will not be called again
650+
try {
651+
if (observer && observer.onError) {
652+
observer.onError(error);
653+
}
654+
} finally {
655+
_this10._connection._handleFatalError(error);
632656
}
633657
},
634658
onCompleted: function onCompleted(metaData) {

lib/v1/internal/routing-util.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var CALL_GET_SERVERS = 'CALL dbms.cluster.routing.getServers';
5757
var GET_ROUTING_TABLE_PARAM = 'context';
5858
var CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable({' + GET_ROUTING_TABLE_PARAM + '})';
5959
var PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound';
60+
var UNAUTHORIZED_CODE = 'Neo.ClientError.Security.Unauthorized';
6061

6162
var RoutingUtil = function () {
6263
function RoutingUtil(routingContext) {
@@ -84,10 +85,14 @@ var RoutingUtil = function () {
8485
if (error.code === PROCEDURE_NOT_FOUND_CODE) {
8586
// throw when getServers procedure not found because this is clearly a configuration issue
8687
throw (0, _error.newError)('Server ' + routerAddress + ' could not perform routing. ' + 'Make sure you are connecting to a causal cluster', _error.SERVICE_UNAVAILABLE);
88+
} else if (error.code === UNAUTHORIZED_CODE) {
89+
// auth error is a sign of a configuration issue, rediscovery should not proceed
90+
throw error;
91+
} else {
92+
// return nothing when failed to connect because code higher in the callstack is still able to retry with a
93+
// different session towards a different router
94+
return null;
8795
}
88-
// return nothing when failed to connect because code higher in the callstack is still able to retry with a
89-
// different session towards a different router
90-
return null;
9196
});
9297
}
9398
}, {

lib/v1/record.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var Record = function () {
8989
* will get three arguments - the value, the key and this record, in that
9090
* order.
9191
*
92-
* @param visitor
92+
* @param {function(value: Object, key: string, record: Record)} visitor the function to apply to each field.
9393
*/
9494

9595

lib/v1/result-summary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function ProfiledPlan(profile) {
151151
};
152152

153153
/**
154-
* Get statistical information for a {Result}.
154+
* Get statistical information for a {@link Result}.
155155
* @access public
156156
*/
157157

lib/v1/routing-driver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
3838

3939
/**
4040
* A driver that supports routing in a core-edge cluster.
41+
* @private
4142
*/
4243
/**
4344
* Copyright (c) 2002-2017 "Neo Technology,","

lib/v1/session.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ var Session = function () {
166166
* While a transaction is open the session cannot be used to run statements outside the transaction.
167167
*
168168
* @param {string} bookmark - a reference to a previous transaction. DEPRECATED: This parameter is deprecated in
169-
* favour of {@link Driver#session(string)} that accepts an initial bookmark. Session will ensure that all nested
169+
* favour of {@link Driver#session} that accepts an initial bookmark. Session will ensure that all nested
170170
* transactions are chained with bookmarks to guarantee causal consistency.
171171
* @returns {Transaction} - New Transaction
172172
*/
@@ -203,7 +203,7 @@ var Session = function () {
203203
/**
204204
* Return the bookmark received following the last completed {@link Transaction}.
205205
*
206-
* @return a reference to a previous transac'tion
206+
* @return a reference to a previous transaction
207207
*/
208208

209209
}, {
@@ -213,7 +213,7 @@ var Session = function () {
213213
}
214214

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

235235
/**
236-
* Execute given unit of work in a {@link Driver#WRITE} transaction.
236+
* Execute given unit of work in a {@link WRITE} transaction.
237237
*
238238
* Transaction will automatically be committed unless the given function throws or returns a rejected promise.
239239
* Some failures of the given function or the commit itself will be retried with exponential backoff with initial

lib/v1/transaction.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var Transaction = function () {
108108

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

273-
return newRunResult(observer, statement, parameters, function () {
273+
return _newRunResult(observer, statement, parameters, function () {
274274
return observer.serverMeta();
275275
});
276276
}
@@ -283,15 +283,15 @@ var _states = {
283283
observer.onError({
284284
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."
285285
});
286-
return { result: newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
286+
return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
287287
},
288288
rollback: function rollback(connectionHolder, observer) {
289289
observer.onError({ error: "Cannot rollback transaction, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
290-
return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
290+
return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
291291
},
292292
run: function run(connectionHolder, observer, statement, parameters) {
293293
observer.onError({ error: "Cannot run statement, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
294-
return newDummyResult(observer, statement, parameters);
294+
return _newDummyResult(observer, statement, parameters);
295295
}
296296
},
297297

@@ -301,15 +301,15 @@ var _states = {
301301
observer.onError({
302302
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."
303303
});
304-
return { result: newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
304+
return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
305305
},
306306
rollback: function rollback(connectionHolder, observer) {
307307
observer.onError({ error: "Cannot rollback transaction, because transaction has already been successfully closed." });
308-
return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
308+
return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
309309
},
310310
run: function run(connectionHolder, observer, statement, parameters) {
311311
observer.onError({ error: "Cannot run statement, because transaction has already been successfully closed." });
312-
return newDummyResult(observer, statement, parameters);
312+
return _newDummyResult(observer, statement, parameters);
313313
}
314314
},
315315

@@ -319,15 +319,15 @@ var _states = {
319319
observer.onError({
320320
error: "Cannot commit this transaction, because it has already been rolled back."
321321
});
322-
return { result: newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
322+
return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
323323
},
324324
rollback: function rollback(connectionHolder, observer) {
325325
observer.onError({ error: "Cannot rollback transaction, because transaction has already been rolled back." });
326-
return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
326+
return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
327327
},
328328
run: function run(connectionHolder, observer, statement, parameters) {
329329
observer.onError({ error: "Cannot run statement, because transaction has already been rolled back." });
330-
return newDummyResult(observer, statement, parameters);
330+
return _newDummyResult(observer, statement, parameters);
331331
}
332332
}
333333
};
@@ -357,8 +357,9 @@ function _runPullAll(msg, connectionHolder, observer) {
357357
* @param {object} parameters - the parameters for cypher statement that produced the result.
358358
* @param {function} metadataSupplier - the function that returns a metadata object.
359359
* @return {Result} new result.
360+
* @private
360361
*/
361-
function newRunResult(observer, statement, parameters, metadataSupplier) {
362+
function _newRunResult(observer, statement, parameters, metadataSupplier) {
362363
return new _result2.default(observer, statement, parameters, metadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
363364
}
364365

@@ -370,8 +371,9 @@ function newRunResult(observer, statement, parameters, metadataSupplier) {
370371
* @param {string} statement - the cypher statement that produced the result.
371372
* @param {object} parameters - the parameters for cypher statement that produced the result.
372373
* @return {Result} new result.
374+
* @private
373375
*/
374-
function newDummyResult(observer, statement, parameters) {
376+
function _newDummyResult(observer, statement, parameters) {
375377
return new _result2.default(observer, statement, parameters, emptyMetadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
376378
}
377379

0 commit comments

Comments
 (0)