neo4j-driver 1.3.0-beta01 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27284,8 +27284,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
27284
27284
  var READ = 'READ',
27285
27285
  WRITE = 'WRITE';
27286
27286
  /**
27287
- * A driver maintains one or more {@link Session sessions} with a remote
27288
- * Neo4j instance. Through the {@link Session sessions} you can send statements
27287
+ * A driver maintains one or more {@link Session}s with a remote
27288
+ * Neo4j instance. Through the {@link Session}s you can send statements
27289
27289
  * and retrieve results from the database.
27290
27290
  *
27291
27291
  * Drivers are reasonably expensive to create - you should strive to keep one
@@ -27374,7 +27374,7 @@ var Driver = function () {
27374
27374
  * will be pulling a session out of the common pool.
27375
27375
  *
27376
27376
  * This comes with some responsibility - make sure you always call
27377
- * {@link Session#close()} when you are done using a session, and likewise,
27377
+ * {@link close} when you are done using a session, and likewise,
27378
27378
  * make sure you don't close your session before you are done using it. Once
27379
27379
  * it is returned to the pool, the session will be reset to a clean state and
27380
27380
  * made available for others to use.
@@ -27567,8 +27567,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
27567
27567
  // A common place for constructing error objects, to keep them
27568
27568
  // uniform across the driver surface.
27569
27569
 
27570
+ /**
27571
+ * @type {string}
27572
+ */
27570
27573
  var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
27574
+ /**
27575
+ * @type {string}
27576
+ */
27571
27577
  var SESSION_EXPIRED = 'SessionExpired';
27578
+ /**
27579
+ * @type {string}
27580
+ */
27572
27581
  var PROTOCOL_ERROR = 'ProtocolError';
27573
27582
 
27574
27583
  function newError(message) {
@@ -27654,7 +27663,7 @@ var Node = function () {
27654
27663
  /**
27655
27664
  * @constructor
27656
27665
  * @param {Integer} identity - Unique identity
27657
- * @param {Array} labels - Array for all labels
27666
+ * @param {Array<string>} labels - Array for all labels
27658
27667
  * @param {Object} properties - Map with node properties
27659
27668
  */
27660
27669
  function Node(identity, labels, properties) {
@@ -27816,7 +27825,7 @@ var Path =
27816
27825
  * @constructor
27817
27826
  * @param {Node} start - start node
27818
27827
  * @param {Node} end - end node
27819
- * @param {Array} segments - Array of Segments
27828
+ * @param {Array<PathSegment>} segments - Array of Segments
27820
27829
  */
27821
27830
  function Path(start, end, segments) {
27822
27831
  (0, _classCallCheck3.default)(this, Path);
@@ -31643,7 +31652,7 @@ var Connection = function () {
31643
31652
  * failing, and the connection getting ejected from the session pool.
31644
31653
  *
31645
31654
  * @param err an error object, forwarded to all current and future subscribers
31646
- * @private
31655
+ * @protected
31647
31656
  */
31648
31657
 
31649
31658
 
@@ -31667,6 +31676,12 @@ var Connection = function () {
31667
31676
  value: function _handleMessage(msg) {
31668
31677
  var _this = this;
31669
31678
 
31679
+ if (this._isBroken) {
31680
+ // ignore all incoming messages when this connection is broken. all previously pending observers failed
31681
+ // with the fatal error. all future observers will fail with same fatal error.
31682
+ return;
31683
+ }
31684
+
31670
31685
  var payload = msg.fields[0];
31671
31686
 
31672
31687
  switch (msg.signature) {
@@ -31679,7 +31694,7 @@ var Connection = function () {
31679
31694
  try {
31680
31695
  this._currentObserver.onCompleted(payload);
31681
31696
  } finally {
31682
- this._currentObserver = this._pendingObservers.shift();
31697
+ this._updateCurrentObserver();
31683
31698
  }
31684
31699
  break;
31685
31700
  case FAILURE:
@@ -31688,7 +31703,7 @@ var Connection = function () {
31688
31703
  this._currentFailure = (0, _error.newError)(payload.message, payload.code);
31689
31704
  this._currentObserver.onError(this._currentFailure);
31690
31705
  } finally {
31691
- this._currentObserver = this._pendingObservers.shift();
31706
+ this._updateCurrentObserver();
31692
31707
  // Things are now broken. Pending observers will get FAILURE messages routed until
31693
31708
  // We are done handling this failure.
31694
31709
  if (!this._isHandlingFailure) {
@@ -31715,7 +31730,7 @@ var Connection = function () {
31715
31730
  try {
31716
31731
  if (this._currentFailure && this._currentObserver.onError) this._currentObserver.onError(this._currentFailure);else if (this._currentObserver.onError) this._currentObserver.onError(payload);
31717
31732
  } finally {
31718
- this._currentObserver = this._pendingObservers.shift();
31733
+ this._updateCurrentObserver();
31719
31734
  }
31720
31735
  break;
31721
31736
  default:
@@ -31873,6 +31888,17 @@ var Connection = function () {
31873
31888
  return this._state.initializationCompleted();
31874
31889
  }
31875
31890
 
31891
+ /*
31892
+ * Pop next pending observer form the list of observers and make it current observer.
31893
+ * @protected
31894
+ */
31895
+
31896
+ }, {
31897
+ key: '_updateCurrentObserver',
31898
+ value: function _updateCurrentObserver() {
31899
+ this._currentObserver = this._pendingObservers.shift();
31900
+ }
31901
+
31876
31902
  /**
31877
31903
  * Synchronize - flush all queued outgoing messages and route their responses
31878
31904
  * to their respective handlers.
@@ -31944,7 +31970,8 @@ var ConnectionState = function () {
31944
31970
  }
31945
31971
 
31946
31972
  /**
31947
- * Wrap the given observer to track connection's initialization state.
31973
+ * Wrap the given observer to track connection's initialization state. Connection is closed by the server if
31974
+ * processing of INIT message fails so returned observer will handle initialization failure as a fatal error.
31948
31975
  * @param {StreamObserver} observer the observer used for INIT message.
31949
31976
  * @return {StreamObserver} updated observer.
31950
31977
  */
@@ -31967,8 +31994,14 @@ var ConnectionState = function () {
31967
31994
  _this10._rejectPromise(error);
31968
31995
  _this10._rejectPromise = null;
31969
31996
  }
31970
- if (observer && observer.onError) {
31971
- observer.onError(error);
31997
+
31998
+ _this10._connection._updateCurrentObserver(); // make sure this same observer will not be called again
31999
+ try {
32000
+ if (observer && observer.onError) {
32001
+ observer.onError(error);
32002
+ }
32003
+ } finally {
32004
+ _this10._connection._handleFatalError(error);
31972
32005
  }
31973
32006
  },
31974
32007
  onCompleted: function onCompleted(metaData) {
@@ -33234,6 +33267,7 @@ var CALL_GET_SERVERS = 'CALL dbms.cluster.routing.getServers';
33234
33267
  var GET_ROUTING_TABLE_PARAM = 'context';
33235
33268
  var CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable({' + GET_ROUTING_TABLE_PARAM + '})';
33236
33269
  var PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound';
33270
+ var UNAUTHORIZED_CODE = 'Neo.ClientError.Security.Unauthorized';
33237
33271
 
33238
33272
  var RoutingUtil = function () {
33239
33273
  function RoutingUtil(routingContext) {
@@ -33261,10 +33295,14 @@ var RoutingUtil = function () {
33261
33295
  if (error.code === PROCEDURE_NOT_FOUND_CODE) {
33262
33296
  // throw when getServers procedure not found because this is clearly a configuration issue
33263
33297
  throw (0, _error.newError)('Server ' + routerAddress + ' could not perform routing. ' + 'Make sure you are connecting to a causal cluster', _error.SERVICE_UNAVAILABLE);
33298
+ } else if (error.code === UNAUTHORIZED_CODE) {
33299
+ // auth error is a sign of a configuration issue, rediscovery should not proceed
33300
+ throw error;
33301
+ } else {
33302
+ // return nothing when failed to connect because code higher in the callstack is still able to retry with a
33303
+ // different session towards a different router
33304
+ return null;
33264
33305
  }
33265
- // return nothing when failed to connect because code higher in the callstack is still able to retry with a
33266
- // different session towards a different router
33267
- return null;
33268
33306
  });
33269
33307
  }
33270
33308
  }, {
@@ -34198,7 +34236,7 @@ var Record = function () {
34198
34236
  * will get three arguments - the value, the key and this record, in that
34199
34237
  * order.
34200
34238
  *
34201
- * @param visitor
34239
+ * @param {function(value: Object, key: string, record: Record)} visitor the function to apply to each field.
34202
34240
  */
34203
34241
 
34204
34242
 
@@ -34432,7 +34470,7 @@ function ProfiledPlan(profile) {
34432
34470
  };
34433
34471
 
34434
34472
  /**
34435
- * Get statistical information for a {Result}.
34473
+ * Get statistical information for a {@link Result}.
34436
34474
  * @access public
34437
34475
  */
34438
34476
 
@@ -34900,6 +34938,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
34900
34938
 
34901
34939
  /**
34902
34940
  * A driver that supports routing in a core-edge cluster.
34941
+ * @private
34903
34942
  */
34904
34943
  /**
34905
34944
  * Copyright (c) 2002-2017 "Neo Technology,","
@@ -35185,7 +35224,7 @@ var Session = function () {
35185
35224
  * While a transaction is open the session cannot be used to run statements outside the transaction.
35186
35225
  *
35187
35226
  * @param {string} bookmark - a reference to a previous transaction. DEPRECATED: This parameter is deprecated in
35188
- * favour of {@link Driver#session(string)} that accepts an initial bookmark. Session will ensure that all nested
35227
+ * favour of {@link Driver#session} that accepts an initial bookmark. Session will ensure that all nested
35189
35228
  * transactions are chained with bookmarks to guarantee causal consistency.
35190
35229
  * @returns {Transaction} - New Transaction
35191
35230
  */
@@ -35222,7 +35261,7 @@ var Session = function () {
35222
35261
  /**
35223
35262
  * Return the bookmark received following the last completed {@link Transaction}.
35224
35263
  *
35225
- * @return a reference to a previous transac'tion
35264
+ * @return a reference to a previous transaction
35226
35265
  */
35227
35266
 
35228
35267
  }, {
@@ -35232,7 +35271,7 @@ var Session = function () {
35232
35271
  }
35233
35272
 
35234
35273
  /**
35235
- * Execute given unit of work in a {@link Driver#READ} transaction.
35274
+ * Execute given unit of work in a {@link READ} transaction.
35236
35275
  *
35237
35276
  * Transaction will automatically be committed unless the given function throws or returns a rejected promise.
35238
35277
  * Some failures of the given function or the commit itself will be retried with exponential backoff with initial
@@ -35252,7 +35291,7 @@ var Session = function () {
35252
35291
  }
35253
35292
 
35254
35293
  /**
35255
- * Execute given unit of work in a {@link Driver#WRITE} transaction.
35294
+ * Execute given unit of work in a {@link WRITE} transaction.
35256
35295
  *
35257
35296
  * Transaction will automatically be committed unless the given function throws or returns a rejected promise.
35258
35297
  * Some failures of the given function or the commit itself will be retried with exponential backoff with initial
@@ -35492,7 +35531,7 @@ var Transaction = function () {
35492
35531
 
35493
35532
  /**
35494
35533
  * Run Cypher statement
35495
- * Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
35534
+ * Could be called with a statement object i.e.: <code>{statement: "MATCH ...", parameters: {param: 1}}</code>
35496
35535
  * or with the statement and parameters as separate arguments.
35497
35536
  * @param {mixed} statement - Cypher statement to execute
35498
35537
  * @param {Object} parameters - Map with parameters to use in statement
@@ -35654,7 +35693,7 @@ var _states = {
35654
35693
  return observer.onError(error);
35655
35694
  });
35656
35695
 
35657
- return newRunResult(observer, statement, parameters, function () {
35696
+ return _newRunResult(observer, statement, parameters, function () {
35658
35697
  return observer.serverMeta();
35659
35698
  });
35660
35699
  }
@@ -35667,15 +35706,15 @@ var _states = {
35667
35706
  observer.onError({
35668
35707
  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."
35669
35708
  });
35670
- return { result: newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
35709
+ return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.FAILED };
35671
35710
  },
35672
35711
  rollback: function rollback(connectionHolder, observer) {
35673
35712
  observer.onError({ error: "Cannot rollback transaction, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
35674
- return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
35713
+ return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.FAILED };
35675
35714
  },
35676
35715
  run: function run(connectionHolder, observer, statement, parameters) {
35677
35716
  observer.onError({ error: "Cannot run statement, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
35678
- return newDummyResult(observer, statement, parameters);
35717
+ return _newDummyResult(observer, statement, parameters);
35679
35718
  }
35680
35719
  },
35681
35720
 
@@ -35685,15 +35724,15 @@ var _states = {
35685
35724
  observer.onError({
35686
35725
  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."
35687
35726
  });
35688
- return { result: newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
35727
+ return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.SUCCEEDED };
35689
35728
  },
35690
35729
  rollback: function rollback(connectionHolder, observer) {
35691
35730
  observer.onError({ error: "Cannot rollback transaction, because transaction has already been successfully closed." });
35692
- return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
35731
+ return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
35693
35732
  },
35694
35733
  run: function run(connectionHolder, observer, statement, parameters) {
35695
35734
  observer.onError({ error: "Cannot run statement, because transaction has already been successfully closed." });
35696
- return newDummyResult(observer, statement, parameters);
35735
+ return _newDummyResult(observer, statement, parameters);
35697
35736
  }
35698
35737
  },
35699
35738
 
@@ -35703,15 +35742,15 @@ var _states = {
35703
35742
  observer.onError({
35704
35743
  error: "Cannot commit this transaction, because it has already been rolled back."
35705
35744
  });
35706
- return { result: newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
35745
+ return { result: _newDummyResult(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
35707
35746
  },
35708
35747
  rollback: function rollback(connectionHolder, observer) {
35709
35748
  observer.onError({ error: "Cannot rollback transaction, because transaction has already been rolled back." });
35710
- return { result: newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
35749
+ return { result: _newDummyResult(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
35711
35750
  },
35712
35751
  run: function run(connectionHolder, observer, statement, parameters) {
35713
35752
  observer.onError({ error: "Cannot run statement, because transaction has already been rolled back." });
35714
- return newDummyResult(observer, statement, parameters);
35753
+ return _newDummyResult(observer, statement, parameters);
35715
35754
  }
35716
35755
  }
35717
35756
  };
@@ -35741,8 +35780,9 @@ function _runPullAll(msg, connectionHolder, observer) {
35741
35780
  * @param {object} parameters - the parameters for cypher statement that produced the result.
35742
35781
  * @param {function} metadataSupplier - the function that returns a metadata object.
35743
35782
  * @return {Result} new result.
35783
+ * @private
35744
35784
  */
35745
- function newRunResult(observer, statement, parameters, metadataSupplier) {
35785
+ function _newRunResult(observer, statement, parameters, metadataSupplier) {
35746
35786
  return new _result2.default(observer, statement, parameters, metadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
35747
35787
  }
35748
35788
 
@@ -35754,8 +35794,9 @@ function newRunResult(observer, statement, parameters, metadataSupplier) {
35754
35794
  * @param {string} statement - the cypher statement that produced the result.
35755
35795
  * @param {object} parameters - the parameters for cypher statement that produced the result.
35756
35796
  * @return {Result} new result.
35797
+ * @private
35757
35798
  */
35758
- function newDummyResult(observer, statement, parameters) {
35799
+ function _newDummyResult(observer, statement, parameters) {
35759
35800
  return new _result2.default(observer, statement, parameters, emptyMetadataSupplier, _connectionHolder.EMPTY_CONNECTION_HOLDER);
35760
35801
  }
35761
35802
 
@@ -35797,7 +35838,7 @@ Object.defineProperty(exports, "__esModule", {
35797
35838
  // This is set up this way to keep the version in the code in
35798
35839
  // sync with the npm package version, and to allow the build
35799
35840
  // system to control version names at packaging time.
35800
- exports.default = "1.3.0-beta01";
35841
+ exports.default = "1.3.0";
35801
35842
 
35802
35843
  },{}]},{},[278])(278)
35803
35844
  });