neo4j-driver 4.4.3 → 5.0.0-alpha01
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/browser/neo4j-web.js +2885 -766
- package/lib/browser/neo4j-web.min.js +1 -1
- package/lib/driver.js +1 -1
- package/lib/result-rx.js +323 -31
- package/lib/session-rx.js +23 -4
- package/package.json +4 -4
- package/types/result-rx.d.ts +6 -0
- package/types/session-rx.d.ts +1 -0
package/lib/driver.js
CHANGED
|
@@ -91,7 +91,7 @@ var Driver = /*#__PURE__*/function (_CoreDriver) {
|
|
|
91
91
|
bookmarkOrBookmarks: bookmarks,
|
|
92
92
|
database: database,
|
|
93
93
|
impersonatedUser: impersonatedUser,
|
|
94
|
-
reactive:
|
|
94
|
+
reactive: false,
|
|
95
95
|
fetchSize: validateFetchSizeValue(fetchSize, this._config.fetchSize)
|
|
96
96
|
}),
|
|
97
97
|
config: this._config
|
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"));
|
|
@@ -57,7 +61,8 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
57
61
|
this._keys = replayedResult.pipe((0, _operators.flatMap)(function (r) {
|
|
58
62
|
return (0, _rxjs.from)(r.keys());
|
|
59
63
|
}), (0, _operators.publishReplay)(1), (0, _operators.refCount)());
|
|
60
|
-
this._records =
|
|
64
|
+
this._records = undefined;
|
|
65
|
+
this._controls = new StreamControl();
|
|
61
66
|
this._summary = new _rxjs.ReplaySubject();
|
|
62
67
|
this._state = States.READY;
|
|
63
68
|
}
|
|
@@ -92,7 +97,7 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
92
97
|
value: function records() {
|
|
93
98
|
var _this = this;
|
|
94
99
|
|
|
95
|
-
|
|
100
|
+
var result = this._result.pipe((0, _operators.flatMap)(function (result) {
|
|
96
101
|
return new _rxjs.Observable(function (recordsObserver) {
|
|
97
102
|
return _this._startStreaming({
|
|
98
103
|
result: result,
|
|
@@ -100,6 +105,12 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
100
105
|
});
|
|
101
106
|
});
|
|
102
107
|
}));
|
|
108
|
+
|
|
109
|
+
result.push = function () {
|
|
110
|
+
return _this._push();
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return result;
|
|
103
114
|
}
|
|
104
115
|
/**
|
|
105
116
|
* Returns an observable that exposes a single item of {@link ResultSummary} that is generated by
|
|
@@ -125,11 +136,53 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
125
136
|
});
|
|
126
137
|
}));
|
|
127
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Pauses the automatic streaming of records.
|
|
141
|
+
*
|
|
142
|
+
* This method provides a way of controll the flow of records
|
|
143
|
+
*
|
|
144
|
+
* @experimental
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
}, {
|
|
148
|
+
key: "pause",
|
|
149
|
+
value: function pause() {
|
|
150
|
+
this._controls.pause();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Resumes the automatic streaming of records.
|
|
154
|
+
*
|
|
155
|
+
* This method won't need to be called in normal stream operation. It only applies to the case when the stream is paused.
|
|
156
|
+
*
|
|
157
|
+
* This method is method won't start the consuming records if the ${@link records()} stream didn't get subscribed.
|
|
158
|
+
* @experimental
|
|
159
|
+
* @returns {Promise<void>} - A promise that resolves when the stream is resumed.
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
}, {
|
|
163
|
+
key: "resume",
|
|
164
|
+
value: function resume() {
|
|
165
|
+
return this._controls.resume();
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Pushes the next record to the stream.
|
|
169
|
+
*
|
|
170
|
+
* This method automatic pause the auto-streaming of records and then push next record to the stream.
|
|
171
|
+
*
|
|
172
|
+
* For returning the automatic streaming of records, use {@link resume} method.
|
|
173
|
+
*
|
|
174
|
+
* @experimental
|
|
175
|
+
* @returns {Promise<void>} - A promise that resolves when the push is completed.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
}, {
|
|
179
|
+
key: "push",
|
|
180
|
+
value: function push() {
|
|
181
|
+
return this._controls.push();
|
|
182
|
+
}
|
|
128
183
|
}, {
|
|
129
184
|
key: "_startStreaming",
|
|
130
185
|
value: function _startStreaming() {
|
|
131
|
-
var _this3 = this;
|
|
132
|
-
|
|
133
186
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
134
187
|
result = _ref.result,
|
|
135
188
|
_ref$recordsObserver = _ref.recordsObserver,
|
|
@@ -146,8 +199,12 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
146
199
|
if (this._state < States.STREAMING) {
|
|
147
200
|
this._state = States.STREAMING;
|
|
148
201
|
|
|
202
|
+
this._setupRecordsStream(result);
|
|
203
|
+
|
|
149
204
|
if (recordsObserver) {
|
|
150
205
|
subscriptions.push(this._records.subscribe(recordsObserver));
|
|
206
|
+
} else {
|
|
207
|
+
result._cancel();
|
|
151
208
|
}
|
|
152
209
|
|
|
153
210
|
subscriptions.push({
|
|
@@ -157,32 +214,6 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
157
214
|
}
|
|
158
215
|
}
|
|
159
216
|
});
|
|
160
|
-
|
|
161
|
-
if (this._records.observers.length === 0) {
|
|
162
|
-
result._cancel();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
result.subscribe({
|
|
166
|
-
onNext: function onNext(record) {
|
|
167
|
-
_this3._records.next(record);
|
|
168
|
-
},
|
|
169
|
-
onCompleted: function onCompleted(summary) {
|
|
170
|
-
_this3._records.complete();
|
|
171
|
-
|
|
172
|
-
_this3._summary.next(summary);
|
|
173
|
-
|
|
174
|
-
_this3._summary.complete();
|
|
175
|
-
|
|
176
|
-
_this3._state = States.COMPLETED;
|
|
177
|
-
},
|
|
178
|
-
onError: function onError(err) {
|
|
179
|
-
_this3._records.error(err);
|
|
180
|
-
|
|
181
|
-
_this3._summary.error(err);
|
|
182
|
-
|
|
183
|
-
_this3._state = States.COMPLETED;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
217
|
} else if (recordsObserver) {
|
|
187
218
|
recordsObserver.error((0, _neo4jDriverCore.newError)('Streaming has already started/consumed with a previous records or summary subscription.'));
|
|
188
219
|
}
|
|
@@ -193,8 +224,269 @@ var RxResult = /*#__PURE__*/function () {
|
|
|
193
224
|
});
|
|
194
225
|
};
|
|
195
226
|
}
|
|
227
|
+
}, {
|
|
228
|
+
key: "_setupRecordsStream",
|
|
229
|
+
value: function _setupRecordsStream(result) {
|
|
230
|
+
var _this3 = this;
|
|
231
|
+
|
|
232
|
+
if (this._records) {
|
|
233
|
+
return this._records;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this._records = createFullyControlledSubject(result[Symbol.asyncIterator](), {
|
|
237
|
+
complete: function () {
|
|
238
|
+
var _complete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
239
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
240
|
+
while (1) {
|
|
241
|
+
switch (_context.prev = _context.next) {
|
|
242
|
+
case 0:
|
|
243
|
+
_this3._state = States.COMPLETED;
|
|
244
|
+
_context.t0 = _this3._summary;
|
|
245
|
+
_context.next = 4;
|
|
246
|
+
return result.summary();
|
|
247
|
+
|
|
248
|
+
case 4:
|
|
249
|
+
_context.t1 = _context.sent;
|
|
250
|
+
|
|
251
|
+
_context.t0.next.call(_context.t0, _context.t1);
|
|
252
|
+
|
|
253
|
+
_this3._summary.complete();
|
|
254
|
+
|
|
255
|
+
case 7:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context.stop();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}, _callee);
|
|
261
|
+
}));
|
|
262
|
+
|
|
263
|
+
function complete() {
|
|
264
|
+
return _complete.apply(this, arguments);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return complete;
|
|
268
|
+
}(),
|
|
269
|
+
error: function error(_error) {
|
|
270
|
+
_this3._state = States.COMPLETED;
|
|
271
|
+
|
|
272
|
+
_this3._summary.error(_error);
|
|
273
|
+
}
|
|
274
|
+
}, this._controls);
|
|
275
|
+
return this._records;
|
|
276
|
+
}
|
|
196
277
|
}]);
|
|
197
278
|
return RxResult;
|
|
198
279
|
}();
|
|
199
280
|
|
|
200
|
-
exports["default"] = RxResult;
|
|
281
|
+
exports["default"] = RxResult;
|
|
282
|
+
|
|
283
|
+
function createFullyControlledSubject(iterator, completeObserver) {
|
|
284
|
+
var streamControl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new StreamControl();
|
|
285
|
+
var subject = new _rxjs.Subject();
|
|
286
|
+
|
|
287
|
+
var pushNextValue = /*#__PURE__*/function () {
|
|
288
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(result) {
|
|
289
|
+
var _yield$result, done, value;
|
|
290
|
+
|
|
291
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
292
|
+
while (1) {
|
|
293
|
+
switch (_context3.prev = _context3.next) {
|
|
294
|
+
case 0:
|
|
295
|
+
_context3.prev = 0;
|
|
296
|
+
streamControl.pushing = true;
|
|
297
|
+
_context3.next = 4;
|
|
298
|
+
return result;
|
|
299
|
+
|
|
300
|
+
case 4:
|
|
301
|
+
_yield$result = _context3.sent;
|
|
302
|
+
done = _yield$result.done;
|
|
303
|
+
value = _yield$result.value;
|
|
304
|
+
|
|
305
|
+
if (done) {
|
|
306
|
+
subject.complete();
|
|
307
|
+
completeObserver.complete();
|
|
308
|
+
} else {
|
|
309
|
+
subject.next(value);
|
|
310
|
+
|
|
311
|
+
if (!streamControl.paused) {
|
|
312
|
+
setImmediate( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
313
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
314
|
+
while (1) {
|
|
315
|
+
switch (_context2.prev = _context2.next) {
|
|
316
|
+
case 0:
|
|
317
|
+
_context2.next = 2;
|
|
318
|
+
return pushNextValue(iterator.next());
|
|
319
|
+
|
|
320
|
+
case 2:
|
|
321
|
+
return _context2.abrupt("return", _context2.sent);
|
|
322
|
+
|
|
323
|
+
case 3:
|
|
324
|
+
case "end":
|
|
325
|
+
return _context2.stop();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}, _callee2);
|
|
329
|
+
})));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
_context3.next = 14;
|
|
334
|
+
break;
|
|
335
|
+
|
|
336
|
+
case 10:
|
|
337
|
+
_context3.prev = 10;
|
|
338
|
+
_context3.t0 = _context3["catch"](0);
|
|
339
|
+
subject.error(_context3.t0);
|
|
340
|
+
completeObserver.error(_context3.t0);
|
|
341
|
+
|
|
342
|
+
case 14:
|
|
343
|
+
_context3.prev = 14;
|
|
344
|
+
streamControl.pushing = false;
|
|
345
|
+
return _context3.finish(14);
|
|
346
|
+
|
|
347
|
+
case 17:
|
|
348
|
+
case "end":
|
|
349
|
+
return _context3.stop();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}, _callee3, null, [[0, 10, 14, 17]]);
|
|
353
|
+
}));
|
|
354
|
+
|
|
355
|
+
return function pushNextValue(_x) {
|
|
356
|
+
return _ref2.apply(this, arguments);
|
|
357
|
+
};
|
|
358
|
+
}();
|
|
359
|
+
|
|
360
|
+
function push(_x2) {
|
|
361
|
+
return _push.apply(this, arguments);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function _push() {
|
|
365
|
+
_push = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(value) {
|
|
366
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
367
|
+
while (1) {
|
|
368
|
+
switch (_context4.prev = _context4.next) {
|
|
369
|
+
case 0:
|
|
370
|
+
_context4.next = 2;
|
|
371
|
+
return pushNextValue(iterator.next(value));
|
|
372
|
+
|
|
373
|
+
case 2:
|
|
374
|
+
case "end":
|
|
375
|
+
return _context4.stop();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}, _callee4);
|
|
379
|
+
}));
|
|
380
|
+
return _push.apply(this, arguments);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
streamControl.pusher = push;
|
|
384
|
+
push();
|
|
385
|
+
return subject;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
var StreamControl = /*#__PURE__*/function () {
|
|
389
|
+
function StreamControl() {
|
|
390
|
+
var push = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
391
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
392
|
+
while (1) {
|
|
393
|
+
switch (_context5.prev = _context5.next) {
|
|
394
|
+
case 0:
|
|
395
|
+
case "end":
|
|
396
|
+
return _context5.stop();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}, _callee5);
|
|
400
|
+
}));
|
|
401
|
+
(0, _classCallCheck2["default"])(this, StreamControl);
|
|
402
|
+
this._paused = false;
|
|
403
|
+
this._pushing = false;
|
|
404
|
+
this._push = push;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
(0, _createClass2["default"])(StreamControl, [{
|
|
408
|
+
key: "pause",
|
|
409
|
+
value: function pause() {
|
|
410
|
+
this._paused = true;
|
|
411
|
+
}
|
|
412
|
+
}, {
|
|
413
|
+
key: "paused",
|
|
414
|
+
get: function get() {
|
|
415
|
+
return this._paused;
|
|
416
|
+
}
|
|
417
|
+
}, {
|
|
418
|
+
key: "pushing",
|
|
419
|
+
set: function set(pushing) {
|
|
420
|
+
this._pushing = pushing;
|
|
421
|
+
}
|
|
422
|
+
}, {
|
|
423
|
+
key: "resume",
|
|
424
|
+
value: function () {
|
|
425
|
+
var _resume = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
426
|
+
var wasPaused;
|
|
427
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
428
|
+
while (1) {
|
|
429
|
+
switch (_context6.prev = _context6.next) {
|
|
430
|
+
case 0:
|
|
431
|
+
wasPaused = this._paused;
|
|
432
|
+
this._paused = false;
|
|
433
|
+
|
|
434
|
+
if (!(wasPaused && !this._pushing)) {
|
|
435
|
+
_context6.next = 5;
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
_context6.next = 5;
|
|
440
|
+
return this._push();
|
|
441
|
+
|
|
442
|
+
case 5:
|
|
443
|
+
case "end":
|
|
444
|
+
return _context6.stop();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}, _callee6, this);
|
|
448
|
+
}));
|
|
449
|
+
|
|
450
|
+
function resume() {
|
|
451
|
+
return _resume.apply(this, arguments);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return resume;
|
|
455
|
+
}()
|
|
456
|
+
}, {
|
|
457
|
+
key: "push",
|
|
458
|
+
value: function () {
|
|
459
|
+
var _push2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
460
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
461
|
+
while (1) {
|
|
462
|
+
switch (_context7.prev = _context7.next) {
|
|
463
|
+
case 0:
|
|
464
|
+
this.pause();
|
|
465
|
+
_context7.next = 3;
|
|
466
|
+
return this._push();
|
|
467
|
+
|
|
468
|
+
case 3:
|
|
469
|
+
return _context7.abrupt("return", _context7.sent);
|
|
470
|
+
|
|
471
|
+
case 4:
|
|
472
|
+
case "end":
|
|
473
|
+
return _context7.stop();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}, _callee7, this);
|
|
477
|
+
}));
|
|
478
|
+
|
|
479
|
+
function push() {
|
|
480
|
+
return _push2.apply(this, arguments);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return push;
|
|
484
|
+
}()
|
|
485
|
+
}, {
|
|
486
|
+
key: "pusher",
|
|
487
|
+
set: function set(push) {
|
|
488
|
+
this._push = push;
|
|
489
|
+
}
|
|
490
|
+
}]);
|
|
491
|
+
return StreamControl;
|
|
492
|
+
}();
|
package/lib/session-rx.js
CHANGED
|
@@ -156,21 +156,40 @@ var RxSession = /*#__PURE__*/function () {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
-
* Returns the
|
|
159
|
+
* Returns the bookmarks received following the last successfully completed query, which is executed
|
|
160
160
|
* either in an {@link RxTransaction} obtained from this session instance or directly through one of
|
|
161
161
|
* the {@link RxSession#run} method of this session instance.
|
|
162
162
|
*
|
|
163
|
-
* If no
|
|
163
|
+
* If no bookmarks were received or if this transaction was rolled back, the bookmarks value will not be
|
|
164
164
|
* changed.
|
|
165
165
|
*
|
|
166
|
+
* @deprecated This method will be removed in 6.0 version. Please, use {@link RxSession#lastBookmarks} instead.
|
|
167
|
+
*
|
|
166
168
|
* @public
|
|
167
|
-
* @returns {string}
|
|
169
|
+
* @returns {string[]}
|
|
168
170
|
*/
|
|
169
171
|
|
|
170
172
|
}, {
|
|
171
173
|
key: "lastBookmark",
|
|
172
174
|
value: function lastBookmark() {
|
|
173
|
-
return this.
|
|
175
|
+
return this.lastBookmarks();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns the bookmarks received following the last successfully completed query, which is executed
|
|
179
|
+
* either in an {@link RxTransaction} obtained from this session instance or directly through one of
|
|
180
|
+
* the {@link RxSession#run} method of this session instance.
|
|
181
|
+
*
|
|
182
|
+
* If no bookmarks were received or if this transaction was rolled back, the bookmarks value will not be
|
|
183
|
+
* changed.
|
|
184
|
+
*
|
|
185
|
+
* @public
|
|
186
|
+
* @returns {string[]}
|
|
187
|
+
*/
|
|
188
|
+
|
|
189
|
+
}, {
|
|
190
|
+
key: "lastBookmarks",
|
|
191
|
+
value: function lastBookmarks() {
|
|
192
|
+
return this._session.lastBookmarks();
|
|
174
193
|
}
|
|
175
194
|
/**
|
|
176
195
|
* @private
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo4j-driver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha01",
|
|
4
4
|
"description": "Connect to Neo4j 3.5.0 and up from JavaScript",
|
|
5
5
|
"author": "Neo4j",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -111,9 +111,9 @@
|
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@babel/runtime": "^7.5.5",
|
|
114
|
-
"neo4j-driver-bolt-connection": "^
|
|
115
|
-
"neo4j-driver-core": "^
|
|
114
|
+
"neo4j-driver-bolt-connection": "^5.0.0-alpha01",
|
|
115
|
+
"neo4j-driver-core": "^5.0.0-alpha01",
|
|
116
116
|
"rxjs": "^6.6.3"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "fd5ab41489e1ac9ca562100a056663f4cadbb7da"
|
|
119
119
|
}
|
package/types/result-rx.d.ts
CHANGED