neo4j-driver 5.10.0 → 5.11.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.
@@ -938,6 +938,7 @@ var Integer = /** @class */ (function () {
938
938
  * @param {!Integer|number|string|bigint|!{low: number, high: number}} val Value
939
939
  * @param {Object} [opts={}] Configuration options
940
940
  * @param {boolean} [opts.strictStringValidation=false] Enable strict validation generated Integer.
941
+ * @param {boolean} [opts.ceilFloat=false] Enable round up float to the nearest Integer.
941
942
  * @returns {!Integer}
942
943
  * @expose
943
944
  */
@@ -947,6 +948,9 @@ var Integer = /** @class */ (function () {
947
948
  return val;
948
949
  }
949
950
  if (typeof val === 'number') {
951
+ if (opts.ceilFloat === true) {
952
+ val = Math.ceil(val);
953
+ }
950
954
  return Integer.fromNumber(val);
951
955
  }
952
956
  if (typeof val === 'string') {
@@ -1128,6 +1132,7 @@ var TWO_PWR_24 = Integer.fromInt(TWO_PWR_24_DBL);
1128
1132
  * @param {Mixed} value - The value to use.
1129
1133
  * @param {Object} [opts={}] Configuration options
1130
1134
  * @param {boolean} [opts.strictStringValidation=false] Enable strict validation generated Integer.
1135
+ * @param {boolean} [opts.ceilFloat=false] Enable round up float to the nearest Integer.
1131
1136
  * @return {Integer} - An object of type Integer.
1132
1137
  */
1133
1138
  var int = Integer.fromValue;
@@ -4903,9 +4908,9 @@ var TxConfig$4 = /** @class */ (function () {
4903
4908
  * @constructor
4904
4909
  * @param {Object} config the raw configuration object.
4905
4910
  */
4906
- function TxConfig(config) {
4911
+ function TxConfig(config, log) {
4907
4912
  assertValidConfig(config);
4908
- this.timeout = extractTimeout(config);
4913
+ this.timeout = extractTimeout(config, log);
4909
4914
  this.metadata = extractMetadata(config);
4910
4915
  }
4911
4916
  /**
@@ -4929,10 +4934,14 @@ var EMPTY_CONFIG = new TxConfig$4({});
4929
4934
  /**
4930
4935
  * @return {Integer|null}
4931
4936
  */
4932
- function extractTimeout(config) {
4937
+ function extractTimeout(config, log) {
4933
4938
  if (util$1.isObject(config) && config.timeout != null) {
4934
4939
  util$1.assertNumberOrInteger(config.timeout, 'Transaction timeout');
4935
- var timeout = (0, integer_1.int)(config.timeout);
4940
+ if (isTimeoutFloat(config) && (log === null || log === void 0 ? void 0 : log.isInfoEnabled()) === true) {
4941
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
4942
+ log === null || log === void 0 ? void 0 : log.info("Transaction timeout expected to be an integer, got: ".concat(config.timeout, ". The value will be rounded up."));
4943
+ }
4944
+ var timeout = (0, integer_1.int)(config.timeout, { ceilFloat: true });
4936
4945
  if (timeout.isNegative()) {
4937
4946
  throw (0, error_1$7.newError)('Transaction timeout should not be negative');
4938
4947
  }
@@ -4940,6 +4949,9 @@ function extractTimeout(config) {
4940
4949
  }
4941
4950
  return null;
4942
4951
  }
4952
+ function isTimeoutFloat(config) {
4953
+ return typeof config.timeout === 'number' && !Number.isInteger(config.timeout);
4954
+ }
4943
4955
  /**
4944
4956
  * @return {object|null}
4945
4957
  */
@@ -6259,7 +6271,7 @@ var Result = /** @class */ (function () {
6259
6271
  * *Should not be combined with {@link Result#subscribe} or ${@link Result#then} functions.*
6260
6272
  *
6261
6273
  * @public
6262
- * @returns {PeekableAsyncIterator<Record<RecordShape>, ResultSummary>} The async iterator for the Results
6274
+ * @returns {PeekableAsyncIterator<Record<R>, ResultSummary>} The async iterator for the Results
6263
6275
  */
6264
6276
  Result.prototype[Symbol.asyncIterator] = function () {
6265
6277
  var _this = this;
@@ -7904,7 +7916,7 @@ var Session = /** @class */ (function () {
7904
7916
  * @param {NotificationFilter} args.notificationFilter - The notification filter used for this session.
7905
7917
  */
7906
7918
  function Session(_a) {
7907
- var mode = _a.mode, connectionProvider = _a.connectionProvider, bookmarks = _a.bookmarks, database = _a.database, config = _a.config, reactive = _a.reactive, fetchSize = _a.fetchSize, impersonatedUser = _a.impersonatedUser, bookmarkManager = _a.bookmarkManager, notificationFilter = _a.notificationFilter, auth = _a.auth;
7919
+ var mode = _a.mode, connectionProvider = _a.connectionProvider, bookmarks = _a.bookmarks, database = _a.database, config = _a.config, reactive = _a.reactive, fetchSize = _a.fetchSize, impersonatedUser = _a.impersonatedUser, bookmarkManager = _a.bookmarkManager, notificationFilter = _a.notificationFilter, auth = _a.auth, log = _a.log;
7908
7920
  this._mode = mode;
7909
7921
  this._database = database;
7910
7922
  this._reactive = reactive;
@@ -7944,6 +7956,7 @@ var Session = /** @class */ (function () {
7944
7956
  this._results = [];
7945
7957
  this._bookmarkManager = bookmarkManager;
7946
7958
  this._notificationFilter = notificationFilter;
7959
+ this._log = log;
7947
7960
  }
7948
7961
  /**
7949
7962
  * Run Cypher query
@@ -7960,7 +7973,7 @@ var Session = /** @class */ (function () {
7960
7973
  var _this = this;
7961
7974
  var _a = (0, util_1$1.validateQueryAndParameters)(query, parameters), validatedQuery = _a.validatedQuery, params = _a.params;
7962
7975
  var autoCommitTxConfig = (transactionConfig != null)
7963
- ? new tx_config_1.TxConfig(transactionConfig)
7976
+ ? new tx_config_1.TxConfig(transactionConfig, this._log)
7964
7977
  : tx_config_1.TxConfig.empty();
7965
7978
  var result = this._run(validatedQuery, params, function (connection) { return __awaiter$d(_this, void 0, void 0, function () {
7966
7979
  var bookmarks;
@@ -8059,7 +8072,7 @@ var Session = /** @class */ (function () {
8059
8072
  var arg = transactionConfig;
8060
8073
  var txConfig = tx_config_1.TxConfig.empty();
8061
8074
  if (arg != null) {
8062
- txConfig = new tx_config_1.TxConfig(arg);
8075
+ txConfig = new tx_config_1.TxConfig(arg, this._log);
8063
8076
  }
8064
8077
  return this._beginTransaction(this._mode, txConfig);
8065
8078
  };
@@ -8161,7 +8174,7 @@ var Session = /** @class */ (function () {
8161
8174
  * @see {@link Session#executeRead}
8162
8175
  */
8163
8176
  Session.prototype.readTransaction = function (transactionWork, transactionConfig) {
8164
- var config = new tx_config_1.TxConfig(transactionConfig);
8177
+ var config = new tx_config_1.TxConfig(transactionConfig, this._log);
8165
8178
  return this._runTransaction(constants_1$1.ACCESS_MODE_READ, config, transactionWork);
8166
8179
  };
8167
8180
  /**
@@ -8182,7 +8195,7 @@ var Session = /** @class */ (function () {
8182
8195
  * @see {@link Session#executeWrite}
8183
8196
  */
8184
8197
  Session.prototype.writeTransaction = function (transactionWork, transactionConfig) {
8185
- var config = new tx_config_1.TxConfig(transactionConfig);
8198
+ var config = new tx_config_1.TxConfig(transactionConfig, this._log);
8186
8199
  return this._runTransaction(constants_1$1.ACCESS_MODE_WRITE, config, transactionWork);
8187
8200
  };
8188
8201
  Session.prototype._runTransaction = function (accessMode, transactionConfig, transactionWork) {
@@ -8204,7 +8217,7 @@ var Session = /** @class */ (function () {
8204
8217
  * function or commit fails.
8205
8218
  */
8206
8219
  Session.prototype.executeRead = function (transactionWork, transactionConfig) {
8207
- var config = new tx_config_1.TxConfig(transactionConfig);
8220
+ var config = new tx_config_1.TxConfig(transactionConfig, this._log);
8208
8221
  return this._executeInTransaction(constants_1$1.ACCESS_MODE_READ, config, transactionWork);
8209
8222
  };
8210
8223
  /**
@@ -8222,7 +8235,7 @@ var Session = /** @class */ (function () {
8222
8235
  * function or commit fails.
8223
8236
  */
8224
8237
  Session.prototype.executeWrite = function (transactionWork, transactionConfig) {
8225
- var config = new tx_config_1.TxConfig(transactionConfig);
8238
+ var config = new tx_config_1.TxConfig(transactionConfig, this._log);
8226
8239
  return this._executeInTransaction(constants_1$1.ACCESS_MODE_WRITE, config, transactionWork);
8227
8240
  };
8228
8241
  /**
@@ -9668,7 +9681,8 @@ var Driver$1 = /** @class */ (function () {
9668
9681
  fetchSize: fetchSize,
9669
9682
  bookmarkManager: bookmarkManager,
9670
9683
  notificationFilter: notificationFilter,
9671
- auth: auth
9684
+ auth: auth,
9685
+ log: this._log
9672
9686
  });
9673
9687
  };
9674
9688
  /**
@@ -19273,9 +19287,10 @@ var RxSession = /** @class */ (function () {
19273
19287
  * @param {Session} param.session - The underlying session instance to relay requests
19274
19288
  */
19275
19289
  function RxSession(_a) {
19276
- var _b = _a === void 0 ? {} : _a, session = _b.session, config = _b.config;
19290
+ var _b = _a === void 0 ? {} : _a, session = _b.session, config = _b.config, log = _b.log;
19277
19291
  this._session = session;
19278
19292
  this._retryLogic = _createRetryLogic(config);
19293
+ this._log = log;
19279
19294
  }
19280
19295
  /**
19281
19296
  * Creates a reactive result that will execute the query with the provided parameters and the provided
@@ -19422,7 +19437,7 @@ var RxSession = /** @class */ (function () {
19422
19437
  var _this = this;
19423
19438
  var txConfig = TxConfig$3.empty();
19424
19439
  if (transactionConfig) {
19425
- txConfig = new TxConfig$3(transactionConfig);
19440
+ txConfig = new TxConfig$3(transactionConfig, this._log);
19426
19441
  }
19427
19442
  return new rxjs_1.Observable(function (observer) {
19428
19443
  try {
@@ -19555,9 +19570,11 @@ var Driver = /** @class */ (function (_super) {
19555
19570
  reactive: false,
19556
19571
  fetchSize: validateFetchSizeValue(fetchSize, this._config.fetchSize),
19557
19572
  bookmarkManager: bookmarkManager,
19558
- notificationFilter: notificationFilter
19573
+ notificationFilter: notificationFilter,
19574
+ log: this._log
19559
19575
  }),
19560
- config: this._config
19576
+ config: this._config,
19577
+ log: this._log
19561
19578
  });
19562
19579
  };
19563
19580
  return Driver;
@@ -19609,7 +19626,7 @@ Object.defineProperty(version$1, "__esModule", { value: true });
19609
19626
  // This is set up this way to keep the version in the code in
19610
19627
  // sync with the npm package version, and to allow the build
19611
19628
  // system to control version names at packaging time.
19612
- version$1.default = '5.10.0';
19629
+ version$1.default = '5.11.0';
19613
19630
 
19614
19631
  var lib = {};
19615
19632
 
@@ -24101,7 +24118,7 @@ function createHandshakeMessage(versions) {
24101
24118
  handshakeBuffer.reset();
24102
24119
  return handshakeBuffer;
24103
24120
  }
24104
- function parseNegotiatedResponse(buffer) {
24121
+ function parseNegotiatedResponse(buffer, log) {
24105
24122
  var h = [
24106
24123
  buffer.readUInt8(),
24107
24124
  buffer.readUInt8(),
@@ -24109,6 +24126,7 @@ function parseNegotiatedResponse(buffer) {
24109
24126
  buffer.readUInt8()
24110
24127
  ];
24111
24128
  if (h[0] === 0x48 && h[1] === 0x54 && h[2] === 0x54 && h[3] === 0x50) {
24129
+ log.error('Handshake failed since server responded with HTTP.');
24112
24130
  throw (0, neo4j_driver_core_1$y.newError)('Server responded HTTP. Make sure you are not trying to connect to the http endpoint ' +
24113
24131
  '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)');
24114
24132
  }
@@ -24140,9 +24158,10 @@ function newHandshakeBuffer() {
24140
24158
  * Shake hands using the channel and return the protocol version
24141
24159
  *
24142
24160
  * @param {Channel} channel the channel use to shake hands
24161
+ * @param {Logger} log the log object
24143
24162
  * @returns {Promise<HandshakeResult>} Promise of protocol version and consumeRemainingBuffer
24144
24163
  */
24145
- function handshake(channel) {
24164
+ function handshake(channel, log) {
24146
24165
  var _this = this;
24147
24166
  return new Promise(function (resolve, reject) {
24148
24167
  var handshakeErrorHandler = function (error) {
@@ -24155,7 +24174,7 @@ function handshake(channel) {
24155
24174
  channel.onmessage = function (buffer) {
24156
24175
  try {
24157
24176
  // read the response buffer and initialize the protocol
24158
- var protocolVersion = parseNegotiatedResponse(buffer);
24177
+ var protocolVersion = parseNegotiatedResponse(buffer, log);
24159
24178
  resolve({
24160
24179
  protocolVersion: protocolVersion,
24161
24180
  consumeRemainingBuffer: function (consumer) {
@@ -31158,7 +31177,7 @@ function createChannelConnection(address, config, errorHandler, log, serversideR
31158
31177
  if (createChannel === void 0) { createChannel = function (channelConfig) { return new channel_1$1.Channel(channelConfig); }; }
31159
31178
  var channelConfig = new channel_1$1.ChannelConfig(address, config, errorHandler.errorCode());
31160
31179
  var channel = createChannel(channelConfig);
31161
- return bolt_1.default.handshake(channel)
31180
+ return bolt_1.default.handshake(channel, log)
31162
31181
  .then(function (_a) {
31163
31182
  var version = _a.protocolVersion, consumeRemainingBuffer = _a.consumeRemainingBuffer;
31164
31183
  var chunker = new channel_1$1.Chunker(channel);