neo4j-driver 5.3.0 → 5.4.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/lib/session-rx.js CHANGED
@@ -1,30 +1,8 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _rxjs = require("rxjs");
15
-
16
- var _operators = require("rxjs/operators");
17
-
18
- var _resultRx = _interopRequireDefault(require("./result-rx"));
19
-
20
- var _neo4jDriverCore = require("neo4j-driver-core");
21
-
22
- var _transactionRx = _interopRequireDefault(require("./transaction-rx"));
23
-
24
- var _transactionManagedRx = _interopRequireDefault(require("./transaction-managed-rx"));
25
-
26
- var _retryLogicRx = _interopRequireDefault(require("./internal/retry-logic-rx"));
27
-
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
28
6
  /**
29
7
  * Copyright (c) "Neo4j"
30
8
  * Neo4j Sweden AB [http://neo4j.com]
@@ -43,60 +21,54 @@ var _retryLogicRx = _interopRequireDefault(require("./internal/retry-logic-rx"))
43
21
  * See the License for the specific language governing permissions and
44
22
  * limitations under the License.
45
23
  */
24
+ var rxjs_1 = require("rxjs");
25
+ var operators_1 = require("rxjs/operators");
26
+ var result_rx_1 = __importDefault(require("./result-rx"));
46
27
  // eslint-disable-next-line no-unused-vars
47
- var _internal$constants = _neo4jDriverCore.internal.constants,
48
- ACCESS_MODE_READ = _internal$constants.ACCESS_MODE_READ,
49
- ACCESS_MODE_WRITE = _internal$constants.ACCESS_MODE_WRITE,
50
- TxConfig = _neo4jDriverCore.internal.txConfig.TxConfig;
28
+ var neo4j_driver_core_1 = require("neo4j-driver-core");
29
+ var transaction_rx_1 = __importDefault(require("./transaction-rx"));
30
+ var transaction_managed_rx_1 = __importDefault(require("./transaction-managed-rx"));
31
+ var retry_logic_rx_1 = __importDefault(require("./internal/retry-logic-rx"));
32
+ var _a = neo4j_driver_core_1.internal.constants, ACCESS_MODE_READ = _a.ACCESS_MODE_READ, ACCESS_MODE_WRITE = _a.ACCESS_MODE_WRITE, TxConfig = neo4j_driver_core_1.internal.txConfig.TxConfig;
51
33
  /**
52
34
  * A Reactive session, which provides the same functionality as {@link Session} but through a Reactive API.
53
35
  */
54
-
55
- var RxSession = /*#__PURE__*/function () {
56
- /**
57
- * Constructs a reactive session with given default session instance and provided driver configuration.
58
- *
59
- * @protected
60
- * @param {Object} param - Object parameter
61
- * @param {Session} param.session - The underlying session instance to relay requests
62
- */
63
- function RxSession() {
64
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
65
- session = _ref.session,
66
- config = _ref.config;
67
-
68
- (0, _classCallCheck2["default"])(this, RxSession);
69
- this._session = session;
70
- this._retryLogic = _createRetryLogic(config);
71
- }
72
- /**
73
- * Creates a reactive result that will execute the query with the provided parameters and the provided
74
- * transaction configuration that applies to the underlying auto-commit transaction.
75
- *
76
- * @public
77
- * @param {string} query - Query to be executed.
78
- * @param {Object} parameters - Parameter values to use in query execution.
79
- * @param {TransactionConfig} transactionConfig - Configuration for the new auto-commit transaction.
80
- * @returns {RxResult} - A reactive result
81
- */
82
-
83
-
84
- (0, _createClass2["default"])(RxSession, [{
85
- key: "run",
86
- value: function run(query, parameters, transactionConfig) {
87
- var _this = this;
88
-
89
- return new _resultRx["default"](new _rxjs.Observable(function (observer) {
90
- try {
91
- observer.next(_this._session.run(query, parameters, transactionConfig));
92
- observer.complete();
93
- } catch (err) {
94
- observer.error(err);
95
- }
96
-
97
- return function () {};
98
- }));
36
+ var RxSession = /** @class */ (function () {
37
+ /**
38
+ * Constructs a reactive session with given default session instance and provided driver configuration.
39
+ *
40
+ * @protected
41
+ * @param {Object} param - Object parameter
42
+ * @param {Session} param.session - The underlying session instance to relay requests
43
+ */
44
+ function RxSession(_a) {
45
+ var _b = _a === void 0 ? {} : _a, session = _b.session, config = _b.config;
46
+ this._session = session;
47
+ this._retryLogic = _createRetryLogic(config);
99
48
  }
49
+ /**
50
+ * Creates a reactive result that will execute the query with the provided parameters and the provided
51
+ * transaction configuration that applies to the underlying auto-commit transaction.
52
+ *
53
+ * @public
54
+ * @param {string} query - Query to be executed.
55
+ * @param {Object} parameters - Parameter values to use in query execution.
56
+ * @param {TransactionConfig} transactionConfig - Configuration for the new auto-commit transaction.
57
+ * @returns {RxResult} - A reactive result
58
+ */
59
+ RxSession.prototype.run = function (query, parameters, transactionConfig) {
60
+ var _this = this;
61
+ return new result_rx_1.default(new rxjs_1.Observable(function (observer) {
62
+ try {
63
+ observer.next(_this._session.run(query, parameters, transactionConfig));
64
+ observer.complete();
65
+ }
66
+ catch (err) {
67
+ observer.error(err);
68
+ }
69
+ return function () { };
70
+ }));
71
+ };
100
72
  /**
101
73
  * Starts a new explicit transaction with the provided transaction configuration.
102
74
  *
@@ -104,12 +76,9 @@ var RxSession = /*#__PURE__*/function () {
104
76
  * @param {TransactionConfig} transactionConfig - Configuration for the new transaction.
105
77
  * @returns {Observable<RxTransaction>} - A reactive stream that will generate at most **one** RxTransaction instance.
106
78
  */
107
-
108
- }, {
109
- key: "beginTransaction",
110
- value: function beginTransaction(transactionConfig) {
111
- return this._beginTransaction(this._session._mode, transactionConfig);
112
- }
79
+ RxSession.prototype.beginTransaction = function (transactionConfig) {
80
+ return this._beginTransaction(this._session._mode, transactionConfig);
81
+ };
113
82
  /**
114
83
  * Executes the provided unit of work in a {@link READ} reactive transaction which is created with the provided
115
84
  * transaction configuration.
@@ -119,12 +88,9 @@ var RxSession = /*#__PURE__*/function () {
119
88
  * @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
120
89
  * @returns {Observable} - A reactive stream returned by the unit of work.
121
90
  */
122
-
123
- }, {
124
- key: "readTransaction",
125
- value: function readTransaction(work, transactionConfig) {
126
- return this._runTransaction(ACCESS_MODE_READ, work, transactionConfig);
127
- }
91
+ RxSession.prototype.readTransaction = function (work, transactionConfig) {
92
+ return this._runTransaction(ACCESS_MODE_READ, work, transactionConfig);
93
+ };
128
94
  /**
129
95
  * Executes the provided unit of work in a {@link WRITE} reactive transaction which is created with the provided
130
96
  * transaction configuration.
@@ -134,12 +100,9 @@ var RxSession = /*#__PURE__*/function () {
134
100
  * @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
135
101
  * @returns {Observable} - A reactive stream returned by the unit of work.
136
102
  */
137
-
138
- }, {
139
- key: "writeTransaction",
140
- value: function writeTransaction(work, transactionConfig) {
141
- return this._runTransaction(ACCESS_MODE_WRITE, work, transactionConfig);
142
- }
103
+ RxSession.prototype.writeTransaction = function (work, transactionConfig) {
104
+ return this._runTransaction(ACCESS_MODE_WRITE, work, transactionConfig);
105
+ };
143
106
  /**
144
107
  * Executes the provided unit of work in a {@link READ} reactive transaction which is created with the provided
145
108
  * transaction configuration.
@@ -148,12 +111,9 @@ var RxSession = /*#__PURE__*/function () {
148
111
  * @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
149
112
  * @returns {Observable} - A reactive stream returned by the unit of work.
150
113
  */
151
-
152
- }, {
153
- key: "executeRead",
154
- value: function executeRead(work, transactionConfig) {
155
- return this._executeInTransaction(ACCESS_MODE_READ, work, transactionConfig);
156
- }
114
+ RxSession.prototype.executeRead = function (work, transactionConfig) {
115
+ return this._executeInTransaction(ACCESS_MODE_READ, work, transactionConfig);
116
+ };
157
117
  /**
158
118
  * Executes the provided unit of work in a {@link WRITE} reactive transaction which is created with the provided
159
119
  * transaction configuration.
@@ -162,50 +122,38 @@ var RxSession = /*#__PURE__*/function () {
162
122
  * @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
163
123
  * @returns {Observable} - A reactive stream returned by the unit of work.
164
124
  */
165
-
166
- }, {
167
- key: "executeWrite",
168
- value: function executeWrite(work, transactionConfig) {
169
- return this._executeInTransaction(ACCESS_MODE_WRITE, work, transactionConfig);
170
- }
125
+ RxSession.prototype.executeWrite = function (work, transactionConfig) {
126
+ return this._executeInTransaction(ACCESS_MODE_WRITE, work, transactionConfig);
127
+ };
171
128
  /**
172
129
  * @private
173
130
  * @param {function(txc: RxManagedTransaction): Observable} work
174
131
  * @param {TransactionConfig} transactionConfig
175
132
  * @returns {Observable}
176
133
  */
177
-
178
- }, {
179
- key: "_executeInTransaction",
180
- value: function _executeInTransaction(accessMode, work, transactionConfig) {
181
- var wrapper = function wrapper(txc) {
182
- return new _transactionManagedRx["default"]({
183
- run: txc.run.bind(txc)
184
- });
185
- };
186
-
187
- return this._runTransaction(accessMode, work, transactionConfig, wrapper);
188
- }
134
+ RxSession.prototype._executeInTransaction = function (accessMode, work, transactionConfig) {
135
+ var wrapper = function (txc) { return new transaction_managed_rx_1.default({
136
+ run: txc.run.bind(txc)
137
+ }); };
138
+ return this._runTransaction(accessMode, work, transactionConfig, wrapper);
139
+ };
189
140
  /**
190
141
  * Closes this reactive session.
191
142
  *
192
143
  * @public
193
144
  * @returns {Observable} - An empty reactive stream
194
145
  */
195
-
196
- }, {
197
- key: "close",
198
- value: function close() {
199
- var _this2 = this;
200
-
201
- return new _rxjs.Observable(function (observer) {
202
- _this2._session.close().then(function () {
203
- observer.complete();
204
- })["catch"](function (err) {
205
- return observer.error(err);
146
+ RxSession.prototype.close = function () {
147
+ var _this = this;
148
+ return new rxjs_1.Observable(function (observer) {
149
+ _this._session
150
+ .close()
151
+ .then(function () {
152
+ observer.complete();
153
+ })
154
+ .catch(function (err) { return observer.error(err); });
206
155
  });
207
- });
208
- }
156
+ };
209
157
  /**
210
158
  * Returns the bookmarks received following the last successfully completed query, which is executed
211
159
  * either in an {@link RxTransaction} obtained from this session instance or directly through one of
@@ -219,12 +167,9 @@ var RxSession = /*#__PURE__*/function () {
219
167
  * @public
220
168
  * @returns {string[]}
221
169
  */
222
-
223
- }, {
224
- key: "lastBookmark",
225
- value: function lastBookmark() {
226
- return this.lastBookmarks();
227
- }
170
+ RxSession.prototype.lastBookmark = function () {
171
+ return this.lastBookmarks();
172
+ };
228
173
  /**
229
174
  * Returns the bookmarks received following the last successfully completed query, which is executed
230
175
  * either in an {@link RxTransaction} obtained from this session instance or directly through one of
@@ -236,83 +181,59 @@ var RxSession = /*#__PURE__*/function () {
236
181
  * @public
237
182
  * @returns {string[]}
238
183
  */
239
-
240
- }, {
241
- key: "lastBookmarks",
242
- value: function lastBookmarks() {
243
- return this._session.lastBookmarks();
244
- }
184
+ RxSession.prototype.lastBookmarks = function () {
185
+ return this._session.lastBookmarks();
186
+ };
245
187
  /**
246
188
  * @private
247
189
  */
248
-
249
- }, {
250
- key: "_beginTransaction",
251
- value: function _beginTransaction(accessMode, transactionConfig) {
252
- var _this3 = this;
253
-
254
- var txConfig = TxConfig.empty();
255
-
256
- if (transactionConfig) {
257
- txConfig = new TxConfig(transactionConfig);
258
- }
259
-
260
- return new _rxjs.Observable(function (observer) {
261
- try {
262
- _this3._session._beginTransaction(accessMode, txConfig).then(function (tx) {
263
- observer.next(new _transactionRx["default"](tx));
264
- observer.complete();
265
- })["catch"](function (err) {
266
- return observer.error(err);
267
- });
268
- } catch (err) {
269
- observer.error(err);
190
+ RxSession.prototype._beginTransaction = function (accessMode, transactionConfig) {
191
+ var _this = this;
192
+ var txConfig = TxConfig.empty();
193
+ if (transactionConfig) {
194
+ txConfig = new TxConfig(transactionConfig);
270
195
  }
271
-
272
- return function () {};
273
- });
274
- }
196
+ return new rxjs_1.Observable(function (observer) {
197
+ try {
198
+ _this._session._beginTransaction(accessMode, txConfig)
199
+ .then(function (tx) {
200
+ observer.next(new transaction_rx_1.default(tx));
201
+ observer.complete();
202
+ })
203
+ .catch(function (err) { return observer.error(err); });
204
+ }
205
+ catch (err) {
206
+ observer.error(err);
207
+ }
208
+ return function () { };
209
+ });
210
+ };
275
211
  /**
276
212
  * @private
277
213
  */
278
-
279
- }, {
280
- key: "_runTransaction",
281
- value: function _runTransaction(accessMode, work, transactionConfig) {
282
- var transactionWrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (tx) {
283
- return tx;
284
- };
285
- var txConfig = TxConfig.empty();
286
-
287
- if (transactionConfig) {
288
- txConfig = new TxConfig(transactionConfig);
289
- }
290
-
291
- return this._retryLogic.retry(this._beginTransaction(accessMode, txConfig).pipe((0, _operators.mergeMap)(function (txc) {
292
- return (0, _rxjs.defer)(function () {
293
- try {
294
- return work(transactionWrapper(txc));
295
- } catch (err) {
296
- return (0, _rxjs.throwError)(function () {
297
- return err;
298
- });
299
- }
300
- }).pipe((0, _operators.catchError)(function (err) {
301
- return txc.rollback().pipe((0, _operators.concatWith)((0, _rxjs.throwError)(function () {
302
- return err;
303
- })));
304
- }), (0, _operators.concatWith)(txc.commit()));
305
- })));
306
- }
307
- }]);
308
- return RxSession;
309
- }();
310
-
311
- exports["default"] = RxSession;
312
-
214
+ RxSession.prototype._runTransaction = function (accessMode, work, transactionConfig, transactionWrapper) {
215
+ if (transactionWrapper === void 0) { transactionWrapper = function (tx) { return tx; }; }
216
+ var txConfig = TxConfig.empty();
217
+ if (transactionConfig) {
218
+ txConfig = new TxConfig(transactionConfig);
219
+ }
220
+ return this._retryLogic.retry(this._beginTransaction(accessMode, txConfig).pipe((0, operators_1.mergeMap)(function (txc) {
221
+ return (0, rxjs_1.defer)(function () {
222
+ try {
223
+ return work(transactionWrapper(txc));
224
+ }
225
+ catch (err) {
226
+ return (0, rxjs_1.throwError)(function () { return err; });
227
+ }
228
+ }).pipe((0, operators_1.catchError)(function (err) { return txc.rollback().pipe((0, operators_1.concatWith)((0, rxjs_1.throwError)(function () { return err; }))); }), (0, operators_1.concatWith)(txc.commit()));
229
+ })));
230
+ };
231
+ return RxSession;
232
+ }());
233
+ exports.default = RxSession;
313
234
  function _createRetryLogic(config) {
314
- var maxRetryTimeout = config && config.maxTransactionRetryTime ? config.maxTransactionRetryTime : null;
315
- return new _retryLogicRx["default"]({
316
- maxRetryTimeout: maxRetryTimeout
317
- });
235
+ var maxRetryTimeout = config && config.maxTransactionRetryTime
236
+ ? config.maxTransactionRetryTime
237
+ : null;
238
+ return new retry_logic_rx_1.default({ maxRetryTimeout: maxRetryTimeout });
318
239
  }
@@ -1,20 +1,8 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _resultRx = _interopRequireDefault(require("./result-rx"));
15
-
16
- var _transactionRx = _interopRequireDefault(require("./transaction-rx"));
17
-
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
18
6
  /**
19
7
  * Copyright (c) "Neo4j"
20
8
  * Neo4j Sweden AB [http://neo4j.com]
@@ -34,32 +22,32 @@ var _transactionRx = _interopRequireDefault(require("./transaction-rx"));
34
22
  * limitations under the License.
35
23
  */
36
24
  // eslint-disable-next-line no-unused-vars
25
+ var result_rx_1 = __importDefault(require("./result-rx"));
37
26
  // eslint-disable-next-line no-unused-vars
38
-
27
+ var transaction_rx_1 = __importDefault(require("./transaction-rx"));
39
28
  /**
40
29
  * Represents a rx transaction that is managed by the transaction executor.
41
30
  *
42
31
  * @public
43
32
  */
44
- var RxManagedTransaction = /*#__PURE__*/function () {
45
- /**
46
- * @private
47
- */
48
- function RxManagedTransaction(_ref) {
49
- var run = _ref.run;
50
- (0, _classCallCheck2["default"])(this, RxManagedTransaction);
51
- this._run = run;
52
- }
53
- /**
54
- * @private
55
- * @param {RxTransaction} txc - The transaction to be wrapped
56
- * @returns {RxManagedTransaction} The managed transaction
57
- */
58
-
59
-
60
- (0, _createClass2["default"])(RxManagedTransaction, [{
61
- key: "run",
62
- value:
33
+ var RxManagedTransaction = /** @class */ (function () {
34
+ /**
35
+ * @private
36
+ */
37
+ function RxManagedTransaction(_a) {
38
+ var run = _a.run;
39
+ this._run = run;
40
+ }
41
+ /**
42
+ * @private
43
+ * @param {RxTransaction} txc - The transaction to be wrapped
44
+ * @returns {RxManagedTransaction} The managed transaction
45
+ */
46
+ RxManagedTransaction.fromTransaction = function (txc) {
47
+ return new RxManagedTransaction({
48
+ run: txc.run.bind(txc)
49
+ });
50
+ };
63
51
  /**
64
52
  * Creates a reactive result that will execute the query in this transaction, with the provided parameters.
65
53
  *
@@ -68,19 +56,9 @@ var RxManagedTransaction = /*#__PURE__*/function () {
68
56
  * @param {Object} parameters - Parameter values to use in query execution.
69
57
  * @returns {RxResult} - A reactive result
70
58
  */
71
- function run(query, parameters) {
72
- return this._run(query, parameters);
73
- }
74
- }], [{
75
- key: "fromTransaction",
76
- value: function fromTransaction(txc) {
77
- return new RxManagedTransaction({
78
- run: txc.run.bind(txc)
79
- });
80
- }
81
- }]);
82
- return RxManagedTransaction;
83
- }();
84
-
85
- var _default = RxManagedTransaction;
86
- exports["default"] = _default;
59
+ RxManagedTransaction.prototype.run = function (query, parameters) {
60
+ return this._run(query, parameters);
61
+ };
62
+ return RxManagedTransaction;
63
+ }());
64
+ exports.default = RxManagedTransaction;