neo4j-driver 5.0.0 → 5.1.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.
package/README.md CHANGED
@@ -8,7 +8,7 @@ Resources to get you started:
8
8
  - [Neo4j Manual](https://neo4j.com/docs/)
9
9
  - [Neo4j Refcard](https://neo4j.com/docs/cypher-refcard/current/)
10
10
 
11
- ## What's New in 5.0
11
+ ## What's New in 5.x
12
12
 
13
13
  - [Changelog](https://github.com/neo4j/neo4j-javascript-driver/wiki/5.0-changelog)
14
14
 
@@ -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
@@ -14184,7 +14193,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
14184
14193
  return result;
14185
14194
  };
14186
14195
  Object.defineProperty(exports, "__esModule", { value: true });
14187
- exports.floorMod = exports.floorDiv = exports.assertValidZoneId = exports.assertValidNanosecond = exports.assertValidSecond = exports.assertValidMinute = exports.assertValidHour = exports.assertValidDay = exports.assertValidMonth = exports.assertValidYear = exports.timeZoneOffsetInSeconds = exports.totalNanoseconds = exports.isoStringToStandardDate = exports.dateToIsoString = exports.timeZoneOffsetToIsoString = exports.timeToIsoString = exports.durationToIsoString = exports.dateToEpochDay = exports.localDateTimeToEpochSecond = exports.localTimeToNanoOfDay = exports.normalizeNanosecondsForDuration = exports.normalizeSecondsForDuration = exports.SECONDS_PER_DAY = exports.DAYS_PER_400_YEAR_CYCLE = exports.DAYS_0000_TO_1970 = exports.NANOS_PER_HOUR = exports.NANOS_PER_MINUTE = exports.NANOS_PER_MILLISECOND = exports.NANOS_PER_SECOND = exports.SECONDS_PER_HOUR = exports.SECONDS_PER_MINUTE = exports.MINUTES_PER_HOUR = exports.NANOSECOND_OF_SECOND_RANGE = exports.SECOND_OF_MINUTE_RANGE = exports.MINUTE_OF_HOUR_RANGE = exports.HOUR_OF_DAY_RANGE = exports.DAY_OF_MONTH_RANGE = exports.MONTH_OF_YEAR_RANGE = exports.YEAR_RANGE = void 0;
14196
+ exports.floorMod = exports.floorDiv = exports.assertValidZoneId = exports.assertValidNanosecond = exports.assertValidSecond = exports.assertValidMinute = exports.assertValidHour = exports.assertValidDay = exports.assertValidMonth = exports.assertValidYear = exports.timeZoneOffsetInSeconds = exports.totalNanoseconds = exports.newDate = exports.toStandardDate = exports.isoStringToStandardDate = exports.dateToIsoString = exports.timeZoneOffsetToIsoString = exports.timeToIsoString = exports.durationToIsoString = exports.dateToEpochDay = exports.localDateTimeToEpochSecond = exports.localTimeToNanoOfDay = exports.normalizeNanosecondsForDuration = exports.normalizeSecondsForDuration = exports.SECONDS_PER_DAY = exports.DAYS_PER_400_YEAR_CYCLE = exports.DAYS_0000_TO_1970 = exports.NANOS_PER_HOUR = exports.NANOS_PER_MINUTE = exports.NANOS_PER_MILLISECOND = exports.NANOS_PER_SECOND = exports.SECONDS_PER_HOUR = exports.SECONDS_PER_MINUTE = exports.MINUTES_PER_HOUR = exports.NANOSECOND_OF_SECOND_RANGE = exports.SECOND_OF_MINUTE_RANGE = exports.MINUTE_OF_HOUR_RANGE = exports.HOUR_OF_DAY_RANGE = exports.DAY_OF_MONTH_RANGE = exports.MONTH_OF_YEAR_RANGE = exports.YEAR_RANGE = void 0;
14188
14197
  var integer_1 = __importStar(require("../integer"));
14189
14198
  var error_1 = require("../error");
14190
14199
  var util_1 = require("./util");
@@ -14387,15 +14396,7 @@ exports.timeZoneOffsetToIsoString = timeZoneOffsetToIsoString;
14387
14396
  * @return {string} ISO string that represents given date.
14388
14397
  */
14389
14398
  function dateToIsoString(year, month, day) {
14390
- year = (0, integer_1.int)(year);
14391
- var isNegative = year.isNegative();
14392
- if (isNegative) {
14393
- year = year.multiply(-1);
14394
- }
14395
- var yearString = formatNumber(year, 4);
14396
- if (isNegative) {
14397
- yearString = '-' + yearString;
14398
- }
14399
+ var yearString = formatYear(year);
14399
14400
  var monthString = formatNumber(month, 2);
14400
14401
  var dayString = formatNumber(day, 2);
14401
14402
  return "".concat(yearString, "-").concat(monthString, "-").concat(dayString);
@@ -14411,6 +14412,25 @@ function isoStringToStandardDate(isoString) {
14411
14412
  return new Date(isoString);
14412
14413
  }
14413
14414
  exports.isoStringToStandardDate = isoStringToStandardDate;
14415
+ /**
14416
+ * Convert the given utc timestamp to a JavaScript Date object
14417
+ *
14418
+ * @param {number} utc Timestamp in UTC
14419
+ * @returns {Date} the date
14420
+ */
14421
+ function toStandardDate(utc) {
14422
+ return new Date(utc);
14423
+ }
14424
+ exports.toStandardDate = toStandardDate;
14425
+ /**
14426
+ * Shortcut for creating a new StandardDate
14427
+ * @param date
14428
+ * @returns {Date} the standard date
14429
+ */
14430
+ function newDate(date) {
14431
+ return new Date(date);
14432
+ }
14433
+ exports.newDate = newDate;
14414
14434
  /**
14415
14435
  * Get the total number of nanoseconds from the milliseconds of the given standard JavaScript date and optional nanosecond part.
14416
14436
  * @param {global.Date} standardDate the standard JavaScript date.
@@ -14436,11 +14456,14 @@ exports.totalNanoseconds = totalNanoseconds;
14436
14456
  * @return {number} the time zone offset in seconds.
14437
14457
  */
14438
14458
  function timeZoneOffsetInSeconds(standardDate) {
14459
+ var secondsPortion = standardDate.getSeconds() >= standardDate.getUTCSeconds()
14460
+ ? standardDate.getSeconds() - standardDate.getUTCSeconds()
14461
+ : standardDate.getSeconds() - standardDate.getUTCSeconds() + 60;
14439
14462
  var offsetInMinutes = standardDate.getTimezoneOffset();
14440
14463
  if (offsetInMinutes === 0) {
14441
- return 0;
14464
+ return 0 + secondsPortion;
14442
14465
  }
14443
- return -1 * offsetInMinutes * exports.SECONDS_PER_MINUTE;
14466
+ return -1 * offsetInMinutes * exports.SECONDS_PER_MINUTE + secondsPortion;
14444
14467
  }
14445
14468
  exports.timeZoneOffsetInSeconds = timeZoneOffsetInSeconds;
14446
14469
  /**
@@ -14634,12 +14657,24 @@ function formatNanosecond(value) {
14634
14657
  value = (0, integer_1.int)(value);
14635
14658
  return value.equals(0) ? '' : '.' + formatNumber(value, 9);
14636
14659
  }
14660
+ /**
14661
+ *
14662
+ * @param {Integer|number|string} year The year to be formatted
14663
+ * @return {string} formatted year
14664
+ */
14665
+ function formatYear(year) {
14666
+ var yearInteger = (0, integer_1.int)(year);
14667
+ if (yearInteger.isNegative() || yearInteger.greaterThan(9999)) {
14668
+ return formatNumber(yearInteger, 6, { usePositiveSign: true });
14669
+ }
14670
+ return formatNumber(yearInteger, 4);
14671
+ }
14637
14672
  /**
14638
14673
  * @param {Integer|number|string} num the number to format.
14639
14674
  * @param {number} [stringLength=undefined] the string length to left-pad to.
14640
14675
  * @return {string} formatted and possibly left-padded number as string.
14641
14676
  */
14642
- function formatNumber(num, stringLength) {
14677
+ function formatNumber(num, stringLength, params) {
14643
14678
  num = (0, integer_1.int)(num);
14644
14679
  var isNegative = num.isNegative();
14645
14680
  if (isNegative) {
@@ -14652,7 +14687,13 @@ function formatNumber(num, stringLength) {
14652
14687
  numString = '0' + numString;
14653
14688
  }
14654
14689
  }
14655
- return isNegative ? '-' + numString : numString;
14690
+ if (isNegative) {
14691
+ return '-' + numString;
14692
+ }
14693
+ else if ((params === null || params === void 0 ? void 0 : params.usePositiveSign) === true) {
14694
+ return '+' + numString;
14695
+ }
14696
+ return numString;
14656
14697
  }
14657
14698
  function add(x, y) {
14658
14699
  if (x instanceof integer_1.default) {
@@ -18174,14 +18215,7 @@ var DateTime = /** @class */ (function () {
18174
18215
  * @throws {Error} If the time zone offset is not defined in the object.
18175
18216
  */
18176
18217
  DateTime.prototype.toStandardDate = function () {
18177
- if (this.timeZoneOffsetSeconds === undefined) {
18178
- throw new Error('Requires DateTime created with time zone offset');
18179
- }
18180
- return util.isoStringToStandardDate(
18181
- // the timezone name should be removed from the
18182
- // string, otherwise the javascript parse doesn't
18183
- // read the datetime correctly
18184
- this.toString().replace(this.timeZoneId != null ? "[".concat(this.timeZoneId, "]") : '', ''));
18218
+ return util.toStandardDate(this._toUTC());
18185
18219
  };
18186
18220
  /**
18187
18221
  * @ignore
@@ -18197,6 +18231,22 @@ var DateTime = /** @class */ (function () {
18197
18231
  : '';
18198
18232
  return localDateTimeStr + timeOffset + timeZoneStr;
18199
18233
  };
18234
+ /**
18235
+ * @private
18236
+ * @returns {number}
18237
+ */
18238
+ DateTime.prototype._toUTC = function () {
18239
+ var _a;
18240
+ if (this.timeZoneOffsetSeconds === undefined) {
18241
+ throw new Error('Requires DateTime created with time zone offset');
18242
+ }
18243
+ var epochSecond = util.localDateTimeToEpochSecond(this.year, this.month, this.day, this.hour, this.minute, this.second, this.nanosecond);
18244
+ var utcSecond = epochSecond.subtract((_a = this.timeZoneOffsetSeconds) !== null && _a !== void 0 ? _a : 0);
18245
+ return (0, integer_1.int)(utcSecond)
18246
+ .multiply(1000)
18247
+ .add((0, integer_1.int)(this.nanosecond).div(1000000))
18248
+ .toNumber();
18249
+ };
18200
18250
  return DateTime;
18201
18251
  }());
18202
18252
  exports.DateTime = DateTime;
@@ -18599,6 +18649,7 @@ var Transaction = /** @class */ (function () {
18599
18649
  this._lowRecordWatermak = lowRecordWatermark;
18600
18650
  this._highRecordWatermark = highRecordWatermark;
18601
18651
  this._bookmarks = bookmarks_1.Bookmarks.empty();
18652
+ this._acceptActive = function () { }; // satisfy DenoJS
18602
18653
  this._activePromise = new Promise(function (resolve, reject) {
18603
18654
  _this._acceptActive = resolve;
18604
18655
  });
@@ -32660,7 +32711,7 @@ exports["default"] = void 0;
32660
32711
  // This is set up this way to keep the version in the code in
32661
32712
  // sync with the npm package version, and to allow the build
32662
32713
  // system to control version names at packaging time.
32663
- var _default = '5.0.0';
32714
+ var _default = '5.1.0';
32664
32715
  exports["default"] = _default;
32665
32716
 
32666
32717
  },{}]},{},[350])(350)