neo4j-driver
Advanced tools
Comparing version 5.0.0-alpha01 to 5.0.0-alpha02
@@ -70,8 +70,3 @@ "use strict"; | ||
* @public | ||
* @param {Object} param | ||
* @param {string} param.defaultAccessMode=WRITE - The access mode of this session, allowed values are {@link READ} and {@link WRITE}. | ||
* @param {string|string[]} param.bookmarks - The initial reference or references to some previous transactions. Value is optional and | ||
* absence indicates that the bookmarks do not exist or are unknown. | ||
* @param {string} param.database - The database this session will operate on. | ||
* @param {string} param.impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {SessionConfig} config | ||
* @returns {RxSession} new reactive session. | ||
@@ -87,3 +82,4 @@ */ | ||
fetchSize = _ref.fetchSize, | ||
impersonatedUser = _ref.impersonatedUser; | ||
impersonatedUser = _ref.impersonatedUser, | ||
bookmarkManager = _ref.bookmarkManager; | ||
@@ -97,3 +93,4 @@ return new _sessionRx["default"]({ | ||
reactive: false, | ||
fetchSize: validateFetchSizeValue(fetchSize, this._config.fetchSize) | ||
fetchSize: validateFetchSizeValue(fetchSize, this._config.fetchSize), | ||
bookmarkManager: bookmarkManager | ||
}), | ||
@@ -100,0 +97,0 @@ config: this._config |
320
lib/index.js
@@ -8,3 +8,50 @@ "use strict"; | ||
}); | ||
exports.driver = driver; | ||
Object.defineProperty(exports, "Date", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Date; | ||
} | ||
}); | ||
Object.defineProperty(exports, "DateTime", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.DateTime; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Driver", { | ||
enumerable: true, | ||
get: function get() { | ||
return _driver.Driver; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Duration", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Duration; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Integer", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Integer; | ||
} | ||
}); | ||
Object.defineProperty(exports, "LocalDateTime", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.LocalDateTime; | ||
} | ||
}); | ||
Object.defineProperty(exports, "LocalTime", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.LocalTime; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ManagedTransaction", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.ManagedTransaction; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Neo4jError", { | ||
@@ -16,26 +63,156 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "error", { | ||
Object.defineProperty(exports, "Node", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.error; | ||
return _neo4jDriverCore.Node; | ||
} | ||
}); | ||
Object.defineProperty(exports, "int", { | ||
Object.defineProperty(exports, "Notification", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore["int"]; | ||
return _neo4jDriverCore.Notification; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isInt", { | ||
Object.defineProperty(exports, "Path", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.isInt; | ||
return _neo4jDriverCore.Path; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isPoint", { | ||
Object.defineProperty(exports, "PathSegment", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.isPoint; | ||
return _neo4jDriverCore.PathSegment; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Plan", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Plan; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Point", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Point; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ProfiledPlan", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.ProfiledPlan; | ||
} | ||
}); | ||
Object.defineProperty(exports, "QueryStatistics", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.QueryStatistics; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Record", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Record; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Relationship", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Relationship; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Result", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Result; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ResultSummary", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.ResultSummary; | ||
} | ||
}); | ||
Object.defineProperty(exports, "RxManagedTransaction", { | ||
enumerable: true, | ||
get: function get() { | ||
return _transactionManagedRx["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "RxResult", { | ||
enumerable: true, | ||
get: function get() { | ||
return _resultRx["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "RxSession", { | ||
enumerable: true, | ||
get: function get() { | ||
return _sessionRx["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "RxTransaction", { | ||
enumerable: true, | ||
get: function get() { | ||
return _transactionRx["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "ServerInfo", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.ServerInfo; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Session", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Session; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Time", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Time; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Transaction", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.Transaction; | ||
} | ||
}); | ||
Object.defineProperty(exports, "UnboundRelationship", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.UnboundRelationship; | ||
} | ||
}); | ||
Object.defineProperty(exports, "auth", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.auth; | ||
} | ||
}); | ||
Object.defineProperty(exports, "bookmarkManager", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.bookmarkManager; | ||
} | ||
}); | ||
exports["default"] = void 0; | ||
exports.driver = driver; | ||
Object.defineProperty(exports, "error", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.error; | ||
} | ||
}); | ||
exports.hasReachableServer = hasReachableServer; | ||
Object.defineProperty(exports, "int", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore["int"]; | ||
} | ||
}); | ||
exports.integer = void 0; | ||
Object.defineProperty(exports, "isDate", { | ||
@@ -59,2 +236,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "isInt", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.isInt; | ||
} | ||
}); | ||
Object.defineProperty(exports, "isLocalDateTime", { | ||
@@ -72,16 +255,26 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "isTime", { | ||
Object.defineProperty(exports, "isPoint", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.isTime; | ||
return _neo4jDriverCore.isPoint; | ||
} | ||
}); | ||
Object.defineProperty(exports, "auth", { | ||
Object.defineProperty(exports, "isRetryableError", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.auth; | ||
return _neo4jDriverCore.isRetryableError; | ||
} | ||
}); | ||
exports["default"] = exports.temporal = exports.spatial = exports.session = exports.types = exports.logging = exports.integer = void 0; | ||
Object.defineProperty(exports, "isTime", { | ||
enumerable: true, | ||
get: function get() { | ||
return _neo4jDriverCore.isTime; | ||
} | ||
}); | ||
exports.types = exports.temporal = exports.spatial = exports.session = exports.logging = void 0; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _driver = require("./driver"); | ||
@@ -95,2 +288,10 @@ | ||
var _sessionRx = _interopRequireDefault(require("./session-rx")); | ||
var _transactionRx = _interopRequireDefault(require("./transaction-rx")); | ||
var _transactionManagedRx = _interopRequireDefault(require("./transaction-managed-rx")); | ||
var _resultRx = _interopRequireDefault(require("./result-rx")); | ||
/** | ||
@@ -116,3 +317,2 @@ * Copyright (c) "Neo4j" | ||
ENCRYPTION_ON = _internal$util.ENCRYPTION_ON, | ||
ENCRYPTION_OFF = _internal$util.ENCRYPTION_OFF, | ||
assertString = _internal$util.assertString, | ||
@@ -182,3 +382,3 @@ isEmptyObjectOrNull = _internal$util.isEmptyObjectOrNull, | ||
* // Specify the maximum time in milliseconds transactions are allowed to retry via | ||
* // `Session#readTransaction()` and `Session#writeTransaction()` functions. | ||
* // `Session#executeRead()` and `Session#executeWrite()` functions. | ||
* // These functions will retry the given unit of work on `ServiceUnavailable`, `SessionExpired` and transient | ||
@@ -353,3 +553,55 @@ * // errors with exponential backoff using initial delay of 1 second. | ||
} | ||
/** | ||
* Verifies if the driver can reach a server at the given url. | ||
* | ||
* @experimental | ||
* @since 5.0.0 | ||
* @param {string} url The URL for the Neo4j database, for instance "neo4j://localhost" and/or "bolt://localhost" | ||
* @param {object} config Configuration object. See the {@link driver} | ||
* @returns {true} When the server is reachable | ||
* @throws {Error} When the server is not reachable or the url is invalid | ||
*/ | ||
function hasReachableServer(_x, _x2) { | ||
return _hasReachableServer.apply(this, arguments); | ||
} | ||
function _hasReachableServer() { | ||
_hasReachableServer = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(url, config) { | ||
var nonLoggedDriver; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
nonLoggedDriver = driver(url, { | ||
scheme: 'none', | ||
principal: '', | ||
credentials: '' | ||
}, config); | ||
_context.prev = 1; | ||
_context.next = 4; | ||
return nonLoggedDriver.getNegotiatedProtocolVersion(); | ||
case 4: | ||
return _context.abrupt("return", true); | ||
case 5: | ||
_context.prev = 5; | ||
_context.next = 8; | ||
return nonLoggedDriver.close(); | ||
case 8: | ||
return _context.finish(5); | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, null, [[1,, 5, 9]]); | ||
})); | ||
return _hasReachableServer.apply(this, arguments); | ||
} | ||
var USER_AGENT = 'neo4j-javascript/' + _version["default"]; | ||
@@ -364,3 +616,3 @@ /** | ||
console: function (_console) { | ||
function console(_x) { | ||
function console(_x3) { | ||
return _console.apply(this, arguments); | ||
@@ -453,2 +705,3 @@ } | ||
driver: driver, | ||
hasReachableServer: hasReachableServer, | ||
"int": _neo4jDriverCore["int"], | ||
@@ -465,2 +718,3 @@ isInt: _neo4jDriverCore.isInt, | ||
Neo4jError: _neo4jDriverCore.Neo4jError, | ||
isRetryableError: _neo4jDriverCore.isRetryableError, | ||
auth: _neo4jDriverCore.auth, | ||
@@ -472,5 +726,35 @@ logging: logging, | ||
spatial: spatial, | ||
temporal: temporal | ||
temporal: temporal, | ||
Driver: _driver.Driver, | ||
Session: _neo4jDriverCore.Session, | ||
Transaction: _neo4jDriverCore.Transaction, | ||
ManagedTransaction: _neo4jDriverCore.ManagedTransaction, | ||
Result: _neo4jDriverCore.Result, | ||
RxSession: _sessionRx["default"], | ||
RxTransaction: _transactionRx["default"], | ||
RxManagedTransaction: _transactionManagedRx["default"], | ||
RxResult: _resultRx["default"], | ||
ResultSummary: _neo4jDriverCore.ResultSummary, | ||
Plan: _neo4jDriverCore.Plan, | ||
ProfiledPlan: _neo4jDriverCore.ProfiledPlan, | ||
QueryStatistics: _neo4jDriverCore.QueryStatistics, | ||
Notification: _neo4jDriverCore.Notification, | ||
ServerInfo: _neo4jDriverCore.ServerInfo, | ||
Record: _neo4jDriverCore.Record, | ||
Node: _neo4jDriverCore.Node, | ||
Relationship: _neo4jDriverCore.Relationship, | ||
UnboundRelationship: _neo4jDriverCore.UnboundRelationship, | ||
Path: _neo4jDriverCore.Path, | ||
PathSegment: _neo4jDriverCore.PathSegment, | ||
Point: _neo4jDriverCore.Point, | ||
Integer: _neo4jDriverCore.Integer, | ||
Duration: _neo4jDriverCore.Duration, | ||
LocalTime: _neo4jDriverCore.LocalTime, | ||
Time: _neo4jDriverCore.Time, | ||
Date: _neo4jDriverCore.Date, | ||
LocalDateTime: _neo4jDriverCore.LocalDateTime, | ||
DateTime: _neo4jDriverCore.DateTime, | ||
bookmarkManager: _neo4jDriverCore.bookmarkManager | ||
}; | ||
var _default = forExport; | ||
exports["default"] = _default; |
@@ -38,6 +38,5 @@ "use strict"; | ||
*/ | ||
var Logger = _neo4jDriverCore.internal.logger.Logger, | ||
canRetryOn = _neo4jDriverCore.internal.retryStrategy.canRetryOn; | ||
var SERVICE_UNAVAILABLE = _neo4jDriverCore.error.SERVICE_UNAVAILABLE, | ||
SESSION_EXPIRED = _neo4jDriverCore.error.SESSION_EXPIRED; | ||
// eslint-disable-next-line no-unused-vars | ||
var Logger = _neo4jDriverCore.internal.logger.Logger; | ||
var SERVICE_UNAVAILABLE = _neo4jDriverCore.error.SERVICE_UNAVAILABLE; | ||
var DEFAULT_MAX_RETRY_TIME_MS = 30 * 1000; // 30 seconds | ||
@@ -92,5 +91,7 @@ | ||
var delayDuration = _this._initialDelay; | ||
return failedWork.pipe((0, _operators.flatMap)(function (err) { | ||
if (!canRetryOn(err)) { | ||
return (0, _rxjs.throwError)(err); | ||
return failedWork.pipe((0, _operators.mergeMap)(function (err) { | ||
if (!(0, _neo4jDriverCore.isRetriableError)(err)) { | ||
return (0, _rxjs.throwError)(function () { | ||
return err; | ||
}); | ||
} | ||
@@ -104,3 +105,5 @@ | ||
_error.seenErrors = handledExceptions; | ||
return (0, _rxjs.throwError)(_error); | ||
return (0, _rxjs.throwError)(function () { | ||
return _error; | ||
}); | ||
} | ||
@@ -107,0 +110,0 @@ |
@@ -35,3 +35,3 @@ "use strict"; | ||
var assertString = _neo4jDriverCore.internal.util.assertString; | ||
var SERVER_VERSION_REGEX = new RegExp('^(Neo4j/)?(\\d+)\\.(\\d+)(?:\\.)?(\\d*)(\\.|-|\\+)?([0-9A-Za-z-.]*)?$'); | ||
var SERVER_VERSION_REGEX = /^(Neo4j\/)?(\d+)\.(\d+)(?:\.)?(\d*)(\.|-|\+)?([0-9A-Za-z-.]*)?$/; | ||
var NEO4J_IN_DEV_VERSION_STRING = 'Neo4j/dev'; | ||
@@ -45,3 +45,3 @@ | ||
* @param {number} patch the patch version number. | ||
* @param {string} the original version string | ||
* @param {string} [originalVersionString] the original version string | ||
*/ | ||
@@ -48,0 +48,0 @@ function ServerVersion(major, minor, patch, originalVersionString) { |
@@ -42,2 +42,4 @@ "use strict"; | ||
*/ | ||
/* eslint-disable-next-line no-unused-vars */ | ||
var States = { | ||
@@ -57,8 +59,9 @@ READY: 0, | ||
* @param {Observable<Result>} result - An observable of single Result instance to relay requests. | ||
* @param {number} state - The streaming state | ||
*/ | ||
function RxResult(result) { | ||
function RxResult(result, state) { | ||
(0, _classCallCheck2["default"])(this, RxResult); | ||
var replayedResult = result.pipe((0, _operators.publishReplay)(1), (0, _operators.refCount)()); | ||
this._result = replayedResult; | ||
this._keys = replayedResult.pipe((0, _operators.flatMap)(function (r) { | ||
this._keys = replayedResult.pipe((0, _operators.mergeMap)(function (r) { | ||
return (0, _rxjs.from)(r.keys()); | ||
@@ -69,3 +72,3 @@ }), (0, _operators.publishReplay)(1), (0, _operators.refCount)()); | ||
this._summary = new _rxjs.ReplaySubject(); | ||
this._state = States.READY; | ||
this._state = state || States.READY; | ||
} | ||
@@ -103,3 +106,3 @@ /** | ||
var result = this._result.pipe((0, _operators.flatMap)(function (result) { | ||
var result = this._result.pipe((0, _operators.mergeMap)(function (result) { | ||
return new _rxjs.Observable(function (recordsObserver) { | ||
@@ -134,3 +137,3 @@ return _this._startStreaming({ | ||
return this._result.pipe((0, _operators.flatMap)(function (result) { | ||
return this._result.pipe((0, _operators.mergeMap)(function (result) { | ||
return new _rxjs.Observable(function (summaryObserver) { | ||
@@ -232,6 +235,42 @@ return _this2._startStreaming({ | ||
} | ||
/** | ||
* Create a {@link Observable} for the current {@link RxResult} | ||
* | ||
* | ||
* @package | ||
* @experimental | ||
* @since 5.0 | ||
* @return {Observable<RxResult>} | ||
*/ | ||
}, { | ||
key: "_toObservable", | ||
value: function _toObservable() { | ||
var _this3 = this; | ||
function wrap(result) { | ||
return new _rxjs.Observable(function (observer) { | ||
observer.next(result); | ||
observer.complete(); | ||
}); | ||
} | ||
return new _rxjs.Observable(function (observer) { | ||
_this3._result.subscribe({ | ||
complete: function complete() { | ||
return observer.complete(); | ||
}, | ||
next: function next(result) { | ||
return observer.next(new RxResult(wrap(result)), _this3._state); | ||
}, | ||
error: function error(e) { | ||
return observer.error(e); | ||
} | ||
}); | ||
}); | ||
} | ||
}, { | ||
key: "_setupRecordsStream", | ||
value: function _setupRecordsStream(result) { | ||
var _this3 = this; | ||
var _this4 = this; | ||
@@ -249,4 +288,4 @@ if (this._records) { | ||
case 0: | ||
_this3._state = States.COMPLETED; | ||
_context.t0 = _this3._summary; | ||
_this4._state = States.COMPLETED; | ||
_context.t0 = _this4._summary; | ||
_context.next = 4; | ||
@@ -260,3 +299,3 @@ return result.summary(); | ||
_this3._summary.complete(); | ||
_this4._summary.complete(); | ||
@@ -278,5 +317,5 @@ case 7: | ||
error: function error(_error) { | ||
_this3._state = States.COMPLETED; | ||
_this4._state = States.COMPLETED; | ||
_this3._summary.error(_error); | ||
_this4._summary.error(_error); | ||
} | ||
@@ -428,2 +467,5 @@ }, this._controls); | ||
key: "pushing", | ||
get: function get() { | ||
return this._pushing; | ||
}, | ||
set: function set(pushing) { | ||
@@ -497,2 +539,5 @@ this._pushing = pushing; | ||
key: "pusher", | ||
get: function get() { | ||
return this._push; | ||
}, | ||
set: function set(push) { | ||
@@ -499,0 +544,0 @@ this._push = push; |
@@ -24,2 +24,4 @@ "use strict"; | ||
var _transactionManagedRx = _interopRequireDefault(require("./transaction-managed-rx")); | ||
var _retryLogicRx = _interopRequireDefault(require("./internal/retry-logic-rx")); | ||
@@ -45,2 +47,3 @@ | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
var _internal$constants = _neo4jDriverCore.internal.constants, | ||
@@ -116,2 +119,3 @@ ACCESS_MODE_READ = _internal$constants.ACCESS_MODE_READ, | ||
* @public | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeRead} instead. | ||
* @param {function(txc: RxTransaction): Observable} work - A unit of work to be executed. | ||
@@ -131,2 +135,3 @@ * @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver. | ||
* @public | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeWrite} instead. | ||
* @param {function(txc: RxTransaction): Observable} work - A unit of work to be executed. | ||
@@ -143,2 +148,48 @@ * @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver. | ||
/** | ||
* Executes the provided unit of work in a {@link READ} reactive transaction which is created with the provided | ||
* transaction configuration. | ||
* @public | ||
* @param {function(txc: RxManagedTransaction): Observable} work - A unit of work to be executed. | ||
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver. | ||
* @returns {Observable} - A reactive stream returned by the unit of work. | ||
*/ | ||
}, { | ||
key: "executeRead", | ||
value: function executeRead(work, transactionConfig) { | ||
return this._executeInTransaction(ACCESS_MODE_READ, work, transactionConfig); | ||
} | ||
/** | ||
* Executes the provided unit of work in a {@link WRITE} reactive transaction which is created with the provided | ||
* transaction configuration. | ||
* @public | ||
* @param {function(txc: RxManagedTransaction): Observable} work - A unit of work to be executed. | ||
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver. | ||
* @returns {Observable} - A reactive stream returned by the unit of work. | ||
*/ | ||
}, { | ||
key: "executeWrite", | ||
value: function executeWrite(work, transactionConfig) { | ||
return this._executeInTransaction(ACCESS_MODE_WRITE, work, transactionConfig); | ||
} | ||
/** | ||
* @private | ||
* @param {function(txc: RxManagedTransaction): Observable} work | ||
* @param {TransactionConfig} transactionConfig | ||
* @returns {Observable} | ||
*/ | ||
}, { | ||
key: "_executeInTransaction", | ||
value: function _executeInTransaction(accessMode, work, transactionConfig) { | ||
var wrapper = function wrapper(txc) { | ||
return new _transactionManagedRx["default"]({ | ||
run: txc.run.bind(txc) | ||
}); | ||
}; | ||
return this._runTransaction(accessMode, work, transactionConfig, wrapper); | ||
} | ||
/** | ||
* Closes this reactive session. | ||
@@ -216,4 +267,8 @@ * | ||
try { | ||
observer.next(new _transactionRx["default"](_this3._session._beginTransaction(accessMode, txConfig))); | ||
observer.complete(); | ||
_this3._session._beginTransaction(accessMode, txConfig).then(function (tx) { | ||
observer.next(new _transactionRx["default"](tx)); | ||
observer.complete(); | ||
})["catch"](function (err) { | ||
return observer.error(err); | ||
}); | ||
} catch (err) { | ||
@@ -233,2 +288,5 @@ observer.error(err); | ||
value: function _runTransaction(accessMode, work, transactionConfig) { | ||
var transactionWrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (tx) { | ||
return tx; | ||
}; | ||
var txConfig = TxConfig.empty(); | ||
@@ -240,12 +298,16 @@ | ||
return this._retryLogic.retry(this._beginTransaction(accessMode, transactionConfig).pipe((0, _operators.flatMap)(function (txc) { | ||
return this._retryLogic.retry(this._beginTransaction(accessMode, txConfig).pipe((0, _operators.mergeMap)(function (txc) { | ||
return (0, _rxjs.defer)(function () { | ||
try { | ||
return work(txc); | ||
return work(transactionWrapper(txc)); | ||
} catch (err) { | ||
return (0, _rxjs.throwError)(err); | ||
return (0, _rxjs.throwError)(function () { | ||
return err; | ||
}); | ||
} | ||
}).pipe((0, _operators.catchError)(function (err) { | ||
return txc.rollback().pipe((0, _operators.concat)((0, _rxjs.throwError)(err))); | ||
}), (0, _operators.concat)(txc.commit())); | ||
return txc.rollback().pipe((0, _operators.concatWith)((0, _rxjs.throwError)(function () { | ||
return err; | ||
}))); | ||
}), (0, _operators.concatWith)(txc.commit())); | ||
}))); | ||
@@ -252,0 +314,0 @@ } |
@@ -38,2 +38,3 @@ "use strict"; | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
@@ -120,2 +121,12 @@ /** | ||
/** | ||
* Check if this transaction is active, which means commit and rollback did not happen. | ||
* @return {boolean} `true` when not committed and not rolled back, `false` otherwise. | ||
*/ | ||
}, { | ||
key: "isOpen", | ||
value: function isOpen() { | ||
return this._txc.isOpen(); | ||
} | ||
/** | ||
* Closes the transaction | ||
@@ -122,0 +133,0 @@ * |
@@ -34,3 +34,3 @@ "use strict"; | ||
// system to control version names at packaging time. | ||
var _default = '0.0.0-dev'; | ||
var _default = '5.0.0-alpha02'; | ||
exports["default"] = _default; |
{ | ||
"name": "neo4j-driver", | ||
"version": "5.0.0-alpha01", | ||
"version": "5.0.0-alpha02", | ||
"description": "Connect to Neo4j 3.5.0 and up from JavaScript", | ||
@@ -13,3 +13,2 @@ "author": "Neo4j", | ||
"lint": "eslint --fix --ext .js ./", | ||
"format": "prettier-eslint '**/*.js' '**/*.json' '**/*.md' '**/*.ts' '**/*.html' --write", | ||
"test": "gulp test", | ||
@@ -31,13 +30,2 @@ "test::unit": "gulp test-nodejs-unit && gulp run-ts-declaration-tests", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,json,ts,md,html}": [ | ||
"prettier-eslint --write", | ||
"git add" | ||
] | ||
}, | ||
"main": "lib/index.js", | ||
@@ -51,12 +39,12 @@ "browser": { | ||
"devDependencies": { | ||
"@babel/core": "^7.5.5", | ||
"@babel/plugin-transform-runtime": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/register": "^7.5.5", | ||
"@istanbuljs/nyc-config-babel": "^2.1.1", | ||
"async": "^3.2.1", | ||
"babel-eslint": "^10.0.3", | ||
"babel-plugin-istanbul": "^5.2.0", | ||
"@babel/core": "^7.17.8", | ||
"@babel/eslint-parser": "^7.17.0", | ||
"@babel/plugin-transform-runtime": "^7.17.0", | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/register": "^7.17.7", | ||
"@istanbuljs/nyc-config-babel": "^3.0.0", | ||
"async": "^3.2.3", | ||
"babel-plugin-istanbul": "^6.1.1", | ||
"babelify": "^10.0.0", | ||
"browserify": "^16.5.0", | ||
"browserify": "^17.0.0", | ||
"browserify-transform-tools": "^1.7.0", | ||
@@ -66,15 +54,8 @@ "esdoc": "^1.1.0", | ||
"esdoc-standard-plugin": "^1.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-standard": "^14.1.1", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-jasmine": "^2.10.1", | ||
"eslint-plugin-node": "^9.2.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"fancy-log": "^1.3.3", | ||
"fs-extra": "^8.1.0", | ||
"fancy-log": "^2.0.0", | ||
"fs-extra": "^10.0.1", | ||
"gulp": "^4.0.2", | ||
"gulp-babel": "^8.0.0", | ||
"gulp-batch": "^1.0.5", | ||
"gulp-decompress": "^2.0.3", | ||
"gulp-decompress": "^3.0.0", | ||
"gulp-download": "^0.0.1", | ||
@@ -88,37 +69,30 @@ "gulp-file": "^0.4.0", | ||
"gulp-watch": "^5.0.1", | ||
"husky": "^3.1.0", | ||
"istanbul": "^0.4.5", | ||
"jasmine-spec-reporter": "^4.2.1", | ||
"karma": "^4.4.1", | ||
"karma-browserify": "^6.1.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"jasmine-spec-reporter": "^7.0.0", | ||
"karma": "^6.3.17", | ||
"karma-browserify": "^8.1.0", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-edge-launcher": "^0.4.2", | ||
"karma-firefox-launcher": "^1.3.0", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-ie-launcher": "^1.0.0", | ||
"karma-jasmine": "^2.0.1", | ||
"karma-jasmine": "^4.0.2", | ||
"karma-source-map-support": "^1.4.0", | ||
"karma-spec-reporter": "^0.0.32", | ||
"lint-staged": "^9.5.0", | ||
"lodash": "^4.17.20", | ||
"lolex": "^4.2.0", | ||
"minimist": "^1.2.5", | ||
"mustache": "^3.2.1", | ||
"nyc": "^14.1.1", | ||
"prettier-eslint": "^9.0.2", | ||
"prettier-eslint-cli": "^5.0.0", | ||
"run-sequence": "^2.2.1", | ||
"semver": "^6.3.0", | ||
"tmp": "0.1.0", | ||
"typescript": "^3.9.10", | ||
"karma-spec-reporter": "^0.0.33", | ||
"lolex": "^6.0.0", | ||
"minimist": "^1.2.6", | ||
"nyc": "^15.1.0", | ||
"semver": "^7.3.5", | ||
"tmp": "0.2.1", | ||
"typescript": "^4.6.3", | ||
"vinyl-buffer": "^1.0.1", | ||
"vinyl-source-stream": "^2.0.0", | ||
"webpack": "^4.44.2" | ||
"webpack": "^5.70.0" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.5.5", | ||
"neo4j-driver-bolt-connection": "^5.0.0-alpha01", | ||
"neo4j-driver-core": "^5.0.0-alpha01", | ||
"rxjs": "^6.6.3" | ||
"@babel/runtime": "^7.17.8", | ||
"neo4j-driver-bolt-connection": "^5.0.0-alpha02", | ||
"neo4j-driver-core": "^5.0.0-alpha02", | ||
"rxjs": "^7.5.5" | ||
}, | ||
"gitHead": "fd5ab41489e1ac9ca562100a056663f4cadbb7da" | ||
"gitHead": "2876335540807eb84cff3511d316831f66e03995" | ||
} |
@@ -225,3 +225,3 @@ # Neo4j Driver for JavaScript | ||
map(record => record.get('name')), | ||
concat(rxSession.close()) | ||
concatWith(rxSession.close()) | ||
) | ||
@@ -377,4 +377,4 @@ .subscribe({ | ||
.pipe( | ||
flatMap(txc => | ||
concat( | ||
mergeMap(txc => | ||
concatWith( | ||
txc | ||
@@ -402,3 +402,3 @@ .run( | ||
of('committed') | ||
).pipe(catchError(err => txc.rollback().pipe(throwError(err)))) | ||
).pipe(catchError(err => txc.rollback().pipe(throwError(() => err)))) | ||
) | ||
@@ -405,0 +405,0 @@ ) |
@@ -7,5 +7,7 @@ { | ||
"noImplicitReturns": true, | ||
"strictNullChecks": true, | ||
"moduleResolution": "node", | ||
"types": [] | ||
} | ||
}, | ||
"include": ["types/**/*.ts", "test/types/**/*.ts"] | ||
} |
@@ -22,6 +22,5 @@ /** | ||
import { | ||
ServerInfo, | ||
Session, | ||
Driver as CoreDriver, | ||
types | ||
types, | ||
SessionConfig | ||
} from 'neo4j-driver-core' | ||
@@ -40,13 +39,3 @@ | ||
declare interface Driver extends CoreDriver { | ||
rxSession({ | ||
defaultAccessMode, | ||
bookmarks, | ||
database, | ||
fetchSize | ||
}?: { | ||
defaultAccessMode?: SessionMode | ||
bookmarks?: string | string[] | ||
fetchSize?: number | ||
database?: string | ||
}): RxSession | ||
rxSession: (sessionParams?: SessionConfig) => RxSession | ||
} | ||
@@ -53,0 +42,0 @@ |
@@ -22,2 +22,3 @@ /** | ||
Neo4jError, | ||
isRetriableError, | ||
error, | ||
@@ -61,4 +62,9 @@ Integer, | ||
Transaction, | ||
ManagedTransaction, | ||
Session, | ||
ConnectionProvider | ||
ConnectionProvider, | ||
BookmarkManager, | ||
bookmarkManager, | ||
BookmarkManagerConfig, | ||
SessionConfig | ||
} from 'neo4j-driver-core' | ||
@@ -77,2 +83,3 @@ import { | ||
import RxTransaction from './transaction-rx' | ||
import RxManagedTransaction from './transaction-managed-rx' | ||
import RxResult from './result-rx' | ||
@@ -97,3 +104,3 @@ import { Parameters } from './query-runner' | ||
declare function driver( | ||
declare function driver ( | ||
url: string, | ||
@@ -104,11 +111,16 @@ authToken?: AuthToken, | ||
declare function hasReachableServer ( | ||
url: string, | ||
config?: Pick<Config, 'logging'> | ||
): Promise<true> | ||
declare const types: { | ||
Node: Node | ||
Relationship: Relationship | ||
UnboundRelationship: UnboundRelationship | ||
PathSegment: PathSegment | ||
Path: Path | ||
Result: Result | ||
ResultSummary: ResultSummary | ||
Record: Record | ||
Node: typeof Node | ||
Relationship: typeof Relationship | ||
UnboundRelationship: typeof UnboundRelationship | ||
PathSegment: typeof PathSegment | ||
Path: typeof Path | ||
Result: typeof Result | ||
ResultSummary: typeof ResultSummary | ||
Record: typeof Record | ||
Point: typeof Point | ||
@@ -124,2 +136,3 @@ Duration: typeof Duration | ||
RxTransaction: RxTransaction | ||
RxManagedTransaction: RxManagedTransaction | ||
RxResult: RxResult | ||
@@ -163,2 +176,3 @@ } | ||
driver: typeof driver | ||
hasReachableServer: typeof hasReachableServer | ||
int: typeof int | ||
@@ -180,2 +194,3 @@ isInt: typeof isInt | ||
Neo4jError: Neo4jError | ||
isRetriableError: typeof isRetriableError | ||
Node: Node | ||
@@ -200,2 +215,3 @@ Relationship: Relationship | ||
Transaction: Transaction | ||
ManagedTransaction: ManagedTransaction | ||
Point: Point | ||
@@ -211,2 +227,3 @@ isPoint: typeof isPoint | ||
RxTransaction: RxTransaction | ||
RxManagedTransaction: RxManagedTransaction | ||
RxResult: RxResult | ||
@@ -220,2 +237,3 @@ ConnectionProvider: ConnectionProvider | ||
isDateTime: typeof isDateTime | ||
bookmarkManager: typeof bookmarkManager | ||
} | ||
@@ -225,2 +243,3 @@ | ||
driver, | ||
hasReachableServer, | ||
int, | ||
@@ -242,2 +261,3 @@ isInt, | ||
Neo4jError, | ||
isRetriableError, | ||
Node, | ||
@@ -262,2 +282,3 @@ Relationship, | ||
Transaction, | ||
ManagedTransaction, | ||
Point, | ||
@@ -273,2 +294,3 @@ isPoint, | ||
RxTransaction, | ||
RxManagedTransaction, | ||
RxResult, | ||
@@ -281,5 +303,12 @@ ConnectionProvider, | ||
isLocalDateTime, | ||
isDateTime | ||
isDateTime, | ||
bookmarkManager | ||
} | ||
export type { | ||
BookmarkManager, | ||
BookmarkManagerConfig, | ||
SessionConfig | ||
} | ||
export default forExport |
@@ -24,3 +24,3 @@ /** | ||
declare interface QueryRunner { | ||
run(query: string, parameters?: Parameters): Result | ||
run: (query: string, parameters?: Parameters) => Result | ||
} | ||
@@ -27,0 +27,0 @@ |
@@ -23,15 +23,15 @@ /** | ||
declare interface RxResult { | ||
keys(): Observable<string[]> | ||
keys: () => Observable<string[]> | ||
records(): Observable<Record> | ||
records: () => Observable<Record> | ||
consume(): Observable<ResultSummary> | ||
consume: () => Observable<ResultSummary> | ||
pause(): void | ||
pause: () => void | ||
resume(): Promise<void> | ||
resume: () => Promise<void> | ||
push(): Promise<void> | ||
push: () => Promise<void> | ||
} | ||
export default RxResult |
@@ -28,26 +28,41 @@ /** | ||
declare interface RxSession { | ||
run( | ||
run: ( | ||
query: string, | ||
parameters?: Parameters, | ||
config?: TransactionConfig | ||
): RxResult | ||
) => RxResult | ||
beginTransaction(config?: TransactionConfig): Observable<RxTransaction> | ||
beginTransaction: (config?: TransactionConfig) => Observable<RxTransaction> | ||
lastBookmarks(): string[] | ||
lastBookmark(): string[] | ||
lastBookmarks: () => string[] | ||
lastBookmark: () => string[] | ||
/** | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeRead} instead. | ||
*/ | ||
readTransaction: <T>( | ||
work: RxTransactionWork<T>, | ||
config?: TransactionConfig | ||
) => Observable<T> | ||
readTransaction<T>( | ||
/** | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeWrite} instead. | ||
*/ | ||
writeTransaction: <T>( | ||
work: RxTransactionWork<T>, | ||
config?: TransactionConfig | ||
): Observable<T> | ||
) => Observable<T> | ||
writeTransaction<T>( | ||
executeRead: <T>( | ||
work: RxTransactionWork<T>, | ||
config?: TransactionConfig | ||
): Observable<T> | ||
) => Observable<T> | ||
close(): Observable<any> | ||
executeWrite: <T>( | ||
work: RxTransactionWork<T>, | ||
config?: TransactionConfig | ||
) => Observable<T> | ||
close: () => Observable<any> | ||
} | ||
export default RxSession |
@@ -24,11 +24,13 @@ /** | ||
declare interface RxTransaction { | ||
run(query: string, parameters?: Parameters): RxResult | ||
run: (query: string, parameters?: Parameters) => RxResult | ||
commit(): Observable<any> | ||
isOpen: () => boolean | ||
rollback(): Observable<any> | ||
commit: () => Observable<any> | ||
close(): Observable<any> | ||
rollback: () => Observable<any> | ||
close: () => Observable<any> | ||
} | ||
export default RxTransaction |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
2047592
48
30
34302
+ Addedrxjs@7.8.1(transitive)
+ Addedtslib@2.8.0(transitive)
- Removedrxjs@6.6.7(transitive)
- Removedtslib@1.14.1(transitive)
Updated@babel/runtime@^7.17.8
Updatedrxjs@^7.5.5