neo4j-driver 4.4.6 → 5.0.0-alpha02
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 +4 -4
- package/lib/browser/neo4j-web.js +22691 -20423
- package/lib/browser/neo4j-web.min.js +1 -1
- package/lib/driver.js +6 -9
- package/lib/index.js +171 -82
- package/lib/internal/retry-logic-rx.js +11 -8
- package/lib/internal/server-version.js +1 -1
- package/lib/result-rx.js +371 -34
- package/lib/session-rx.js +92 -11
- package/lib/transaction-managed-rx.js +86 -0
- package/lib/transaction-rx.js +11 -0
- package/lib/version.js +1 -1
- package/package.json +32 -58
- package/tsconfig.json +3 -1
- package/types/driver.d.ts +3 -14
- package/types/index.d.ts +32 -3
- package/types/query-runner.d.ts +1 -1
- package/types/result-rx.d.ts +9 -3
- package/types/session-rx.d.ts +25 -9
- package/types/transaction-managed-rx.d.ts +26 -0
- package/types/transaction-rx.d.ts +6 -4
- package/.eslintrc.json +0 -21
package/lib/result-rx.js
CHANGED
|
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
10
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
15
|
|
|
12
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -35,6 +39,8 @@ var _operators = require("rxjs/operators");
|
|
|
35
39
|
* See the License for the specific language governing permissions and
|
|
36
40
|
* limitations under the License.
|
|
37
41
|
*/
|
|
42
|
+
|
|
43
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
38
44
|
var States = {
|
|
39
45
|
READY: 0,
|
|
40
46
|
STREAMING: 1,
|
|
@@ -49,17 +55,19 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
49
55
|
* @constructor
|
|
50
56
|
* @protected
|
|
51
57
|
* @param {Observable<Result>} result - An observable of single Result instance to relay requests.
|
|
58
|
+
* @param {number} state - The streaming state
|
|
52
59
|
*/
|
|
53
|
-
function RxResult(result) {
|
|
60
|
+
function RxResult(result, state) {
|
|
54
61
|
(0, _classCallCheck2["default"])(this, RxResult);
|
|
55
62
|
var replayedResult = result.pipe((0, _operators.publishReplay)(1), (0, _operators.refCount)());
|
|
56
63
|
this._result = replayedResult;
|
|
57
|
-
this._keys = replayedResult.pipe((0, _operators.
|
|
64
|
+
this._keys = replayedResult.pipe((0, _operators.mergeMap)(function (r) {
|
|
58
65
|
return (0, _rxjs.from)(r.keys());
|
|
59
66
|
}), (0, _operators.publishReplay)(1), (0, _operators.refCount)());
|
|
60
|
-
this._records =
|
|
67
|
+
this._records = undefined;
|
|
68
|
+
this._controls = new StreamControl();
|
|
61
69
|
this._summary = new _rxjs.ReplaySubject();
|
|
62
|
-
this._state = States.READY;
|
|
70
|
+
this._state = state || States.READY;
|
|
63
71
|
}
|
|
64
72
|
/**
|
|
65
73
|
* Returns an observable that exposes a single item containing field names
|
|
@@ -92,7 +100,7 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
92
100
|
value: function records() {
|
|
93
101
|
var _this = this;
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+
var result = this._result.pipe((0, _operators.mergeMap)(function (result) {
|
|
96
104
|
return new _rxjs.Observable(function (recordsObserver) {
|
|
97
105
|
return _this._startStreaming({
|
|
98
106
|
result: result,
|
|
@@ -100,6 +108,12 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
100
108
|
});
|
|
101
109
|
});
|
|
102
110
|
}));
|
|
111
|
+
|
|
112
|
+
result.push = function () {
|
|
113
|
+
return _this._push();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return result;
|
|
103
117
|
}
|
|
104
118
|
/**
|
|
105
119
|
* Returns an observable that exposes a single item of {@link ResultSummary} that is generated by
|
|
@@ -116,7 +130,7 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
116
130
|
value: function consume() {
|
|
117
131
|
var _this2 = this;
|
|
118
132
|
|
|
119
|
-
return this._result.pipe((0, _operators.
|
|
133
|
+
return this._result.pipe((0, _operators.mergeMap)(function (result) {
|
|
120
134
|
return new _rxjs.Observable(function (summaryObserver) {
|
|
121
135
|
return _this2._startStreaming({
|
|
122
136
|
result: result,
|
|
@@ -125,11 +139,53 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
125
139
|
});
|
|
126
140
|
}));
|
|
127
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Pauses the automatic streaming of records.
|
|
144
|
+
*
|
|
145
|
+
* This method provides a way of controll the flow of records
|
|
146
|
+
*
|
|
147
|
+
* @experimental
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
}, {
|
|
151
|
+
key: "pause",
|
|
152
|
+
value: function pause() {
|
|
153
|
+
this._controls.pause();
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Resumes the automatic streaming of records.
|
|
157
|
+
*
|
|
158
|
+
* This method won't need to be called in normal stream operation. It only applies to the case when the stream is paused.
|
|
159
|
+
*
|
|
160
|
+
* This method is method won't start the consuming records if the ${@link records()} stream didn't get subscribed.
|
|
161
|
+
* @experimental
|
|
162
|
+
* @returns {Promise<void>} - A promise that resolves when the stream is resumed.
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
}, {
|
|
166
|
+
key: "resume",
|
|
167
|
+
value: function resume() {
|
|
168
|
+
return this._controls.resume();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Pushes the next record to the stream.
|
|
172
|
+
*
|
|
173
|
+
* This method automatic pause the auto-streaming of records and then push next record to the stream.
|
|
174
|
+
*
|
|
175
|
+
* For returning the automatic streaming of records, use {@link resume} method.
|
|
176
|
+
*
|
|
177
|
+
* @experimental
|
|
178
|
+
* @returns {Promise<void>} - A promise that resolves when the push is completed.
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
}, {
|
|
182
|
+
key: "push",
|
|
183
|
+
value: function push() {
|
|
184
|
+
return this._controls.push();
|
|
185
|
+
}
|
|
128
186
|
}, {
|
|
129
187
|
key: "_startStreaming",
|
|
130
188
|
value: function _startStreaming() {
|
|
131
|
-
var _this3 = this;
|
|
132
|
-
|
|
133
189
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
134
190
|
result = _ref.result,
|
|
135
191
|
_ref$recordsObserver = _ref.recordsObserver,
|
|
@@ -146,8 +202,12 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
146
202
|
if (this._state < States.STREAMING) {
|
|
147
203
|
this._state = States.STREAMING;
|
|
148
204
|
|
|
205
|
+
this._setupRecordsStream(result);
|
|
206
|
+
|
|
149
207
|
if (recordsObserver) {
|
|
150
208
|
subscriptions.push(this._records.subscribe(recordsObserver));
|
|
209
|
+
} else {
|
|
210
|
+
result._cancel();
|
|
151
211
|
}
|
|
152
212
|
|
|
153
213
|
subscriptions.push({
|
|
@@ -157,44 +217,321 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
157
217
|
}
|
|
158
218
|
}
|
|
159
219
|
});
|
|
220
|
+
} else if (recordsObserver) {
|
|
221
|
+
recordsObserver.error((0, _neo4jDriverCore.newError)('Streaming has already started/consumed with a previous records or summary subscription.'));
|
|
222
|
+
}
|
|
160
223
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
224
|
+
return function () {
|
|
225
|
+
subscriptions.forEach(function (s) {
|
|
226
|
+
return s.unsubscribe();
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create a {@link Observable} for the current {@link RxResult}
|
|
232
|
+
*
|
|
233
|
+
*
|
|
234
|
+
* @package
|
|
235
|
+
* @experimental
|
|
236
|
+
* @since 5.0
|
|
237
|
+
* @return {Observable<RxResult>}
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
}, {
|
|
241
|
+
key: "_toObservable",
|
|
242
|
+
value: function _toObservable() {
|
|
243
|
+
var _this3 = this;
|
|
244
|
+
|
|
245
|
+
function wrap(result) {
|
|
246
|
+
return new _rxjs.Observable(function (observer) {
|
|
247
|
+
observer.next(result);
|
|
248
|
+
observer.complete();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
164
251
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
252
|
+
return new _rxjs.Observable(function (observer) {
|
|
253
|
+
_this3._result.subscribe({
|
|
254
|
+
complete: function complete() {
|
|
255
|
+
return observer.complete();
|
|
256
|
+
},
|
|
257
|
+
next: function next(result) {
|
|
258
|
+
return observer.next(new RxResult(wrap(result)), _this3._state);
|
|
168
259
|
},
|
|
169
|
-
|
|
170
|
-
|
|
260
|
+
error: function error(e) {
|
|
261
|
+
return observer.error(e);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "_setupRecordsStream",
|
|
268
|
+
value: function _setupRecordsStream(result) {
|
|
269
|
+
var _this4 = this;
|
|
171
270
|
|
|
172
|
-
|
|
271
|
+
if (this._records) {
|
|
272
|
+
return this._records;
|
|
273
|
+
}
|
|
173
274
|
|
|
174
|
-
|
|
275
|
+
this._records = createFullyControlledSubject(result[Symbol.asyncIterator](), {
|
|
276
|
+
complete: function () {
|
|
277
|
+
var _complete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
278
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
279
|
+
while (1) {
|
|
280
|
+
switch (_context.prev = _context.next) {
|
|
281
|
+
case 0:
|
|
282
|
+
_this4._state = States.COMPLETED;
|
|
283
|
+
_context.t0 = _this4._summary;
|
|
284
|
+
_context.next = 4;
|
|
285
|
+
return result.summary();
|
|
175
286
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
onError: function onError(err) {
|
|
179
|
-
_this3._records.error(err);
|
|
287
|
+
case 4:
|
|
288
|
+
_context.t1 = _context.sent;
|
|
180
289
|
|
|
181
|
-
|
|
290
|
+
_context.t0.next.call(_context.t0, _context.t1);
|
|
182
291
|
|
|
183
|
-
|
|
292
|
+
_this4._summary.complete();
|
|
293
|
+
|
|
294
|
+
case 7:
|
|
295
|
+
case "end":
|
|
296
|
+
return _context.stop();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}, _callee);
|
|
300
|
+
}));
|
|
301
|
+
|
|
302
|
+
function complete() {
|
|
303
|
+
return _complete.apply(this, arguments);
|
|
184
304
|
}
|
|
185
|
-
});
|
|
186
|
-
} else if (recordsObserver) {
|
|
187
|
-
recordsObserver.error((0, _neo4jDriverCore.newError)('Streaming has already started/consumed with a previous records or summary subscription.'));
|
|
188
|
-
}
|
|
189
305
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
306
|
+
return complete;
|
|
307
|
+
}(),
|
|
308
|
+
error: function error(_error) {
|
|
309
|
+
_this4._state = States.COMPLETED;
|
|
310
|
+
|
|
311
|
+
_this4._summary.error(_error);
|
|
312
|
+
}
|
|
313
|
+
}, this._controls);
|
|
314
|
+
return this._records;
|
|
195
315
|
}
|
|
196
316
|
}]);
|
|
197
317
|
return RxResult;
|
|
198
318
|
}();
|
|
199
319
|
|
|
200
|
-
exports["default"] = RxResult;
|
|
320
|
+
exports["default"] = RxResult;
|
|
321
|
+
|
|
322
|
+
function createFullyControlledSubject(iterator, completeObserver) {
|
|
323
|
+
var streamControl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new StreamControl();
|
|
324
|
+
var subject = new _rxjs.Subject();
|
|
325
|
+
|
|
326
|
+
var pushNextValue = /*#__PURE__*/function () {
|
|
327
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(result) {
|
|
328
|
+
var _yield$result, done, value;
|
|
329
|
+
|
|
330
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
331
|
+
while (1) {
|
|
332
|
+
switch (_context3.prev = _context3.next) {
|
|
333
|
+
case 0:
|
|
334
|
+
_context3.prev = 0;
|
|
335
|
+
streamControl.pushing = true;
|
|
336
|
+
_context3.next = 4;
|
|
337
|
+
return result;
|
|
338
|
+
|
|
339
|
+
case 4:
|
|
340
|
+
_yield$result = _context3.sent;
|
|
341
|
+
done = _yield$result.done;
|
|
342
|
+
value = _yield$result.value;
|
|
343
|
+
|
|
344
|
+
if (done) {
|
|
345
|
+
subject.complete();
|
|
346
|
+
completeObserver.complete();
|
|
347
|
+
} else {
|
|
348
|
+
subject.next(value);
|
|
349
|
+
|
|
350
|
+
if (!streamControl.paused) {
|
|
351
|
+
setImmediate( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
352
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
353
|
+
while (1) {
|
|
354
|
+
switch (_context2.prev = _context2.next) {
|
|
355
|
+
case 0:
|
|
356
|
+
_context2.next = 2;
|
|
357
|
+
return pushNextValue(iterator.next());
|
|
358
|
+
|
|
359
|
+
case 2:
|
|
360
|
+
return _context2.abrupt("return", _context2.sent);
|
|
361
|
+
|
|
362
|
+
case 3:
|
|
363
|
+
case "end":
|
|
364
|
+
return _context2.stop();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}, _callee2);
|
|
368
|
+
})));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
_context3.next = 14;
|
|
373
|
+
break;
|
|
374
|
+
|
|
375
|
+
case 10:
|
|
376
|
+
_context3.prev = 10;
|
|
377
|
+
_context3.t0 = _context3["catch"](0);
|
|
378
|
+
subject.error(_context3.t0);
|
|
379
|
+
completeObserver.error(_context3.t0);
|
|
380
|
+
|
|
381
|
+
case 14:
|
|
382
|
+
_context3.prev = 14;
|
|
383
|
+
streamControl.pushing = false;
|
|
384
|
+
return _context3.finish(14);
|
|
385
|
+
|
|
386
|
+
case 17:
|
|
387
|
+
case "end":
|
|
388
|
+
return _context3.stop();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}, _callee3, null, [[0, 10, 14, 17]]);
|
|
392
|
+
}));
|
|
393
|
+
|
|
394
|
+
return function pushNextValue(_x) {
|
|
395
|
+
return _ref2.apply(this, arguments);
|
|
396
|
+
};
|
|
397
|
+
}();
|
|
398
|
+
|
|
399
|
+
function push(_x2) {
|
|
400
|
+
return _push.apply(this, arguments);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function _push() {
|
|
404
|
+
_push = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(value) {
|
|
405
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
406
|
+
while (1) {
|
|
407
|
+
switch (_context4.prev = _context4.next) {
|
|
408
|
+
case 0:
|
|
409
|
+
_context4.next = 2;
|
|
410
|
+
return pushNextValue(iterator.next(value));
|
|
411
|
+
|
|
412
|
+
case 2:
|
|
413
|
+
case "end":
|
|
414
|
+
return _context4.stop();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}, _callee4);
|
|
418
|
+
}));
|
|
419
|
+
return _push.apply(this, arguments);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
streamControl.pusher = push;
|
|
423
|
+
push();
|
|
424
|
+
return subject;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
var StreamControl = /*#__PURE__*/function () {
|
|
428
|
+
function StreamControl() {
|
|
429
|
+
var push = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
430
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
431
|
+
while (1) {
|
|
432
|
+
switch (_context5.prev = _context5.next) {
|
|
433
|
+
case 0:
|
|
434
|
+
case "end":
|
|
435
|
+
return _context5.stop();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}, _callee5);
|
|
439
|
+
}));
|
|
440
|
+
(0, _classCallCheck2["default"])(this, StreamControl);
|
|
441
|
+
this._paused = false;
|
|
442
|
+
this._pushing = false;
|
|
443
|
+
this._push = push;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
(0, _createClass2["default"])(StreamControl, [{
|
|
447
|
+
key: "pause",
|
|
448
|
+
value: function pause() {
|
|
449
|
+
this._paused = true;
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
key: "paused",
|
|
453
|
+
get: function get() {
|
|
454
|
+
return this._paused;
|
|
455
|
+
}
|
|
456
|
+
}, {
|
|
457
|
+
key: "pushing",
|
|
458
|
+
get: function get() {
|
|
459
|
+
return this._pushing;
|
|
460
|
+
},
|
|
461
|
+
set: function set(pushing) {
|
|
462
|
+
this._pushing = pushing;
|
|
463
|
+
}
|
|
464
|
+
}, {
|
|
465
|
+
key: "resume",
|
|
466
|
+
value: function () {
|
|
467
|
+
var _resume = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
468
|
+
var wasPaused;
|
|
469
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
470
|
+
while (1) {
|
|
471
|
+
switch (_context6.prev = _context6.next) {
|
|
472
|
+
case 0:
|
|
473
|
+
wasPaused = this._paused;
|
|
474
|
+
this._paused = false;
|
|
475
|
+
|
|
476
|
+
if (!(wasPaused && !this._pushing)) {
|
|
477
|
+
_context6.next = 5;
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
_context6.next = 5;
|
|
482
|
+
return this._push();
|
|
483
|
+
|
|
484
|
+
case 5:
|
|
485
|
+
case "end":
|
|
486
|
+
return _context6.stop();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}, _callee6, this);
|
|
490
|
+
}));
|
|
491
|
+
|
|
492
|
+
function resume() {
|
|
493
|
+
return _resume.apply(this, arguments);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return resume;
|
|
497
|
+
}()
|
|
498
|
+
}, {
|
|
499
|
+
key: "push",
|
|
500
|
+
value: function () {
|
|
501
|
+
var _push2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
502
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
503
|
+
while (1) {
|
|
504
|
+
switch (_context7.prev = _context7.next) {
|
|
505
|
+
case 0:
|
|
506
|
+
this.pause();
|
|
507
|
+
_context7.next = 3;
|
|
508
|
+
return this._push();
|
|
509
|
+
|
|
510
|
+
case 3:
|
|
511
|
+
return _context7.abrupt("return", _context7.sent);
|
|
512
|
+
|
|
513
|
+
case 4:
|
|
514
|
+
case "end":
|
|
515
|
+
return _context7.stop();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}, _callee7, this);
|
|
519
|
+
}));
|
|
520
|
+
|
|
521
|
+
function push() {
|
|
522
|
+
return _push2.apply(this, arguments);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return push;
|
|
526
|
+
}()
|
|
527
|
+
}, {
|
|
528
|
+
key: "pusher",
|
|
529
|
+
get: function get() {
|
|
530
|
+
return this._push;
|
|
531
|
+
},
|
|
532
|
+
set: function set(push) {
|
|
533
|
+
this._push = push;
|
|
534
|
+
}
|
|
535
|
+
}]);
|
|
536
|
+
return StreamControl;
|
|
537
|
+
}();
|
package/lib/session-rx.js
CHANGED
|
@@ -21,6 +21,8 @@ var _neo4jDriverCore = require("neo4j-driver-core");
|
|
|
21
21
|
|
|
22
22
|
var _transactionRx = _interopRequireDefault(require("./transaction-rx"));
|
|
23
23
|
|
|
24
|
+
var _transactionManagedRx = _interopRequireDefault(require("./transaction-managed-rx"));
|
|
25
|
+
|
|
24
26
|
var _retryLogicRx = _interopRequireDefault(require("./internal/retry-logic-rx"));
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -41,6 +43,7 @@ var _retryLogicRx = _interopRequireDefault(require("./internal/retry-logic-rx"))
|
|
|
41
43
|
* See the License for the specific language governing permissions and
|
|
42
44
|
* limitations under the License.
|
|
43
45
|
*/
|
|
46
|
+
// eslint-disable-next-line no-unused-vars
|
|
44
47
|
var _internal$constants = _neo4jDriverCore.internal.constants,
|
|
45
48
|
ACCESS_MODE_READ = _internal$constants.ACCESS_MODE_READ,
|
|
46
49
|
ACCESS_MODE_WRITE = _internal$constants.ACCESS_MODE_WRITE,
|
|
@@ -111,6 +114,7 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
111
114
|
* Executes the provided unit of work in a {@link READ} reactive transaction which is created with the provided
|
|
112
115
|
* transaction configuration.
|
|
113
116
|
* @public
|
|
117
|
+
* @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeRead} instead.
|
|
114
118
|
* @param {function(txc: RxTransaction): Observable} work - A unit of work to be executed.
|
|
115
119
|
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
|
|
116
120
|
* @returns {Observable} - A reactive stream returned by the unit of work.
|
|
@@ -125,6 +129,7 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
125
129
|
* Executes the provided unit of work in a {@link WRITE} reactive transaction which is created with the provided
|
|
126
130
|
* transaction configuration.
|
|
127
131
|
* @public
|
|
132
|
+
* @deprecated This method will be removed in version 6.0. Please, use {@link RxSession#executeWrite} instead.
|
|
128
133
|
* @param {function(txc: RxTransaction): Observable} work - A unit of work to be executed.
|
|
129
134
|
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
|
|
130
135
|
* @returns {Observable} - A reactive stream returned by the unit of work.
|
|
@@ -135,6 +140,52 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
135
140
|
value: function writeTransaction(work, transactionConfig) {
|
|
136
141
|
return this._runTransaction(ACCESS_MODE_WRITE, work, transactionConfig);
|
|
137
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Executes the provided unit of work in a {@link READ} reactive transaction which is created with the provided
|
|
145
|
+
* transaction configuration.
|
|
146
|
+
* @public
|
|
147
|
+
* @param {function(txc: RxManagedTransaction): Observable} work - A unit of work to be executed.
|
|
148
|
+
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
|
|
149
|
+
* @returns {Observable} - A reactive stream returned by the unit of work.
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
}, {
|
|
153
|
+
key: "executeRead",
|
|
154
|
+
value: function executeRead(work, transactionConfig) {
|
|
155
|
+
return this._executeInTransaction(ACCESS_MODE_READ, work, transactionConfig);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Executes the provided unit of work in a {@link WRITE} reactive transaction which is created with the provided
|
|
159
|
+
* transaction configuration.
|
|
160
|
+
* @public
|
|
161
|
+
* @param {function(txc: RxManagedTransaction): Observable} work - A unit of work to be executed.
|
|
162
|
+
* @param {TransactionConfig} transactionConfig - Configuration for the enclosing transaction created by the driver.
|
|
163
|
+
* @returns {Observable} - A reactive stream returned by the unit of work.
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
}, {
|
|
167
|
+
key: "executeWrite",
|
|
168
|
+
value: function executeWrite(work, transactionConfig) {
|
|
169
|
+
return this._executeInTransaction(ACCESS_MODE_WRITE, work, transactionConfig);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @private
|
|
173
|
+
* @param {function(txc: RxManagedTransaction): Observable} work
|
|
174
|
+
* @param {TransactionConfig} transactionConfig
|
|
175
|
+
* @returns {Observable}
|
|
176
|
+
*/
|
|
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
|
+
}
|
|
138
189
|
/**
|
|
139
190
|
* Closes this reactive session.
|
|
140
191
|
*
|
|
@@ -156,21 +207,40 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
156
207
|
});
|
|
157
208
|
}
|
|
158
209
|
/**
|
|
159
|
-
* Returns the
|
|
210
|
+
* Returns the bookmarks received following the last successfully completed query, which is executed
|
|
160
211
|
* either in an {@link RxTransaction} obtained from this session instance or directly through one of
|
|
161
212
|
* the {@link RxSession#run} method of this session instance.
|
|
162
213
|
*
|
|
163
|
-
* If no
|
|
214
|
+
* If no bookmarks were received or if this transaction was rolled back, the bookmarks value will not be
|
|
164
215
|
* changed.
|
|
165
216
|
*
|
|
217
|
+
* @deprecated This method will be removed in 6.0 version. Please, use {@link RxSession#lastBookmarks} instead.
|
|
218
|
+
*
|
|
166
219
|
* @public
|
|
167
|
-
* @returns {string}
|
|
220
|
+
* @returns {string[]}
|
|
168
221
|
*/
|
|
169
222
|
|
|
170
223
|
}, {
|
|
171
224
|
key: "lastBookmark",
|
|
172
225
|
value: function lastBookmark() {
|
|
173
|
-
return this.
|
|
226
|
+
return this.lastBookmarks();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Returns the bookmarks received following the last successfully completed query, which is executed
|
|
230
|
+
* either in an {@link RxTransaction} obtained from this session instance or directly through one of
|
|
231
|
+
* the {@link RxSession#run} method of this session instance.
|
|
232
|
+
*
|
|
233
|
+
* If no bookmarks were received or if this transaction was rolled back, the bookmarks value will not be
|
|
234
|
+
* changed.
|
|
235
|
+
*
|
|
236
|
+
* @public
|
|
237
|
+
* @returns {string[]}
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
}, {
|
|
241
|
+
key: "lastBookmarks",
|
|
242
|
+
value: function lastBookmarks() {
|
|
243
|
+
return this._session.lastBookmarks();
|
|
174
244
|
}
|
|
175
245
|
/**
|
|
176
246
|
* @private
|
|
@@ -189,8 +259,12 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
189
259
|
|
|
190
260
|
return new _rxjs.Observable(function (observer) {
|
|
191
261
|
try {
|
|
192
|
-
|
|
193
|
-
|
|
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
|
+
});
|
|
194
268
|
} catch (err) {
|
|
195
269
|
observer.error(err);
|
|
196
270
|
}
|
|
@@ -205,22 +279,29 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
205
279
|
}, {
|
|
206
280
|
key: "_runTransaction",
|
|
207
281
|
value: function _runTransaction(accessMode, work, transactionConfig) {
|
|
282
|
+
var transactionWrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (tx) {
|
|
283
|
+
return tx;
|
|
284
|
+
};
|
|
208
285
|
var txConfig = TxConfig.empty();
|
|
209
286
|
|
|
210
287
|
if (transactionConfig) {
|
|
211
288
|
txConfig = new TxConfig(transactionConfig);
|
|
212
289
|
}
|
|
213
290
|
|
|
214
|
-
return this._retryLogic.retry(this._beginTransaction(accessMode,
|
|
291
|
+
return this._retryLogic.retry(this._beginTransaction(accessMode, txConfig).pipe((0, _operators.mergeMap)(function (txc) {
|
|
215
292
|
return (0, _rxjs.defer)(function () {
|
|
216
293
|
try {
|
|
217
|
-
return work(txc);
|
|
294
|
+
return work(transactionWrapper(txc));
|
|
218
295
|
} catch (err) {
|
|
219
|
-
return (0, _rxjs.throwError)(
|
|
296
|
+
return (0, _rxjs.throwError)(function () {
|
|
297
|
+
return err;
|
|
298
|
+
});
|
|
220
299
|
}
|
|
221
300
|
}).pipe((0, _operators.catchError)(function (err) {
|
|
222
|
-
return txc.rollback().pipe((0, _operators.
|
|
223
|
-
|
|
301
|
+
return txc.rollback().pipe((0, _operators.concatWith)((0, _rxjs.throwError)(function () {
|
|
302
|
+
return err;
|
|
303
|
+
})));
|
|
304
|
+
}), (0, _operators.concatWith)(txc.commit()));
|
|
224
305
|
})));
|
|
225
306
|
}
|
|
226
307
|
}]);
|