neo4j-driver 5.0.0 → 5.0.2

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.
@@ -2426,13 +2426,15 @@ function getTimeInZoneId(timeZoneId, epochSecond, nano) {
2426
2426
  hour12: false,
2427
2427
  era: 'narrow'
2428
2428
  });
2429
- var l = (0, temporal_factory_1.epochSecondAndNanoToLocalDateTime)(epochSecond, nano);
2430
- var utc = Date.UTC((0, neo4j_driver_core_1.int)(l.year).toNumber(), (0, neo4j_driver_core_1.int)(l.month).toNumber() - 1, (0, neo4j_driver_core_1.int)(l.day).toNumber(), (0, neo4j_driver_core_1.int)(l.hour).toNumber(), (0, neo4j_driver_core_1.int)(l.minute).toNumber(), (0, neo4j_driver_core_1.int)(l.second).toNumber());
2429
+ var utc = (0, neo4j_driver_core_1.int)(epochSecond)
2430
+ .multiply(1000)
2431
+ .add((0, neo4j_driver_core_1.int)(nano).div(1000000))
2432
+ .toNumber();
2431
2433
  var formattedUtcParts = formatter.formatToParts(utc);
2432
2434
  var localDateTime = formattedUtcParts.reduce(function (obj, currentValue) {
2433
2435
  if (currentValue.type === 'era') {
2434
2436
  obj.adjustEra =
2435
- currentValue.value.toLocaleUpperCase() === 'B'
2437
+ currentValue.value.toUpperCase() === 'B'
2436
2438
  ? function (year) { return year.subtract(1).negate(); } // 1BC equals to year 0 in astronomical year numbering
2437
2439
  : functional_1.identity;
2438
2440
  }
@@ -3153,7 +3155,8 @@ var ResponseHandler = /** @class */ (function () {
3153
3155
  this._log.debug("S: FAILURE ".concat(neo4j_driver_core_1.json.stringify(msg)));
3154
3156
  }
3155
3157
  try {
3156
- var error = (0, neo4j_driver_core_1.newError)(payload.message, payload.code);
3158
+ var standardizedCode = _standardizeCode(payload.code);
3159
+ var error = (0, neo4j_driver_core_1.newError)(payload.message, standardizedCode);
3157
3160
  this._currentFailure = this._observer.onErrorApplyTransformation(error);
3158
3161
  this._currentObserver.onError(this._currentFailure);
3159
3162
  }
@@ -3225,6 +3228,24 @@ var ResponseHandler = /** @class */ (function () {
3225
3228
  return ResponseHandler;
3226
3229
  }());
3227
3230
  exports.default = ResponseHandler;
3231
+ /**
3232
+ * Standardize error classification that are different between 5.x and previous versions.
3233
+ *
3234
+ * The transient error were clean-up for being retrieable and because of this
3235
+ * `Terminated` and `LockClientStopped` were reclassified as `ClientError`.
3236
+ *
3237
+ * @param {string} code
3238
+ * @returns {string} the standardized error code
3239
+ */
3240
+ function _standardizeCode(code) {
3241
+ if (code === 'Neo.TransientError.Transaction.Terminated') {
3242
+ return 'Neo.ClientError.Transaction.Terminated';
3243
+ }
3244
+ else if (code === 'Neo.TransientError.Transaction.LockClientStopped') {
3245
+ return 'Neo.ClientError.Transaction.LockClientStopped';
3246
+ }
3247
+ return code;
3248
+ }
3228
3249
 
3229
3250
  },{"neo4j-driver-core":75}],26:[function(require,module,exports){
3230
3251
  "use strict";
@@ -9565,28 +9586,27 @@ var Pool = /** @class */ (function () {
9565
9586
  };
9566
9587
  Pool.prototype._purgeKey = function (key) {
9567
9588
  return __awaiter(this, void 0, void 0, function () {
9568
- var pool, resource;
9589
+ var pool, destructionList, resource;
9569
9590
  return __generator(this, function (_a) {
9570
9591
  switch (_a.label) {
9571
9592
  case 0:
9572
9593
  pool = this._pools[key];
9573
- if (!pool) return [3 /*break*/, 4];
9574
- _a.label = 1;
9575
- case 1:
9576
- if (!pool.length) return [3 /*break*/, 3];
9577
- resource = pool.pop();
9578
- if (this._removeIdleObserver) {
9579
- this._removeIdleObserver(resource);
9594
+ destructionList = [];
9595
+ if (!pool) return [3 /*break*/, 2];
9596
+ while (pool.length) {
9597
+ resource = pool.pop();
9598
+ if (this._removeIdleObserver) {
9599
+ this._removeIdleObserver(resource);
9600
+ }
9601
+ destructionList.push(this._destroy(resource));
9580
9602
  }
9581
- return [4 /*yield*/, this._destroy(resource)];
9582
- case 2:
9583
- _a.sent();
9584
- return [3 /*break*/, 1];
9585
- case 3:
9586
9603
  pool.close();
9587
9604
  delete this._pools[key];
9588
- _a.label = 4;
9589
- case 4: return [2 /*return*/];
9605
+ return [4 /*yield*/, Promise.all(destructionList)];
9606
+ case 1:
9607
+ _a.sent();
9608
+ _a.label = 2;
9609
+ case 2: return [2 /*return*/];
9590
9610
  }
9591
9611
  });
9592
9612
  });
@@ -11341,26 +11361,15 @@ function _isRetriableCode(code) {
11341
11361
  return code === SERVICE_UNAVAILABLE ||
11342
11362
  code === SESSION_EXPIRED ||
11343
11363
  _isAuthorizationExpired(code) ||
11344
- _isRetriableTransientError(code);
11364
+ _isTransientError(code);
11345
11365
  }
11346
11366
  /**
11347
11367
  * @private
11348
11368
  * @param {string} code the error to check
11349
11369
  * @return {boolean} true if the error is a transient error
11350
11370
  */
11351
- function _isRetriableTransientError(code) {
11352
- // Retries should not happen when transaction was explicitly terminated by the user.
11353
- // Termination of transaction might result in two different error codes depending on where it was
11354
- // terminated. These are really client errors but classification on the server is not entirely correct and
11355
- // they are classified as transient.
11356
- if ((code === null || code === void 0 ? void 0 : code.includes('TransientError')) === true) {
11357
- if (code === 'Neo.TransientError.Transaction.Terminated' ||
11358
- code === 'Neo.TransientError.Transaction.LockClientStopped') {
11359
- return false;
11360
- }
11361
- return true;
11362
- }
11363
- return false;
11371
+ function _isTransientError(code) {
11372
+ return (code === null || code === void 0 ? void 0 : code.includes('TransientError')) === true;
11364
11373
  }
11365
11374
  /**
11366
11375
  * @private
@@ -32660,7 +32669,7 @@ exports["default"] = void 0;
32660
32669
  // This is set up this way to keep the version in the code in
32661
32670
  // sync with the npm package version, and to allow the build
32662
32671
  // system to control version names at packaging time.
32663
- var _default = '5.0.0';
32672
+ var _default = '5.0.2';
32664
32673
  exports["default"] = _default;
32665
32674
 
32666
32675
  },{}]},{},[350])(350)