Skip to content

Commit c55eee2

Browse files
author
Neo Technology Build Agent
committed
JS driver v1.1.1: Checking in transpiled files for bower
1 parent f7bbbce commit c55eee2

17 files changed

+28032
-20187
lines changed

lib/browser/neo4j-web.js

Lines changed: 6484 additions & 6119 deletions
Large diffs are not rendered by default.

lib/browser/neo4j-web.min.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/browser/neo4j-web.test.js

Lines changed: 20757 additions & 13556 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/v1/driver.js

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,68 @@
1-
'use strict';
1+
"use strict";
22

33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66
exports.WRITE = exports.READ = exports.Driver = undefined;
77

8-
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
8+
var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
99

1010
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
1111

12-
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
12+
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
1313

1414
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
1515

16-
var _get2 = require('babel-runtime/helpers/get');
16+
var _get2 = require("babel-runtime/helpers/get");
1717

1818
var _get3 = _interopRequireDefault(_get2);
1919

20-
var _inherits2 = require('babel-runtime/helpers/inherits');
20+
var _inherits2 = require("babel-runtime/helpers/inherits");
2121

2222
var _inherits3 = _interopRequireDefault(_inherits2);
2323

24-
var _promise = require('babel-runtime/core-js/promise');
24+
var _promise = require("babel-runtime/core-js/promise");
2525

2626
var _promise2 = _interopRequireDefault(_promise);
2727

28-
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
28+
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
2929

3030
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
3131

32-
var _createClass2 = require('babel-runtime/helpers/createClass');
32+
var _createClass2 = require("babel-runtime/helpers/createClass");
3333

3434
var _createClass3 = _interopRequireDefault(_createClass2);
3535

36-
var _session = require('./session');
36+
var _session = require("./session");
3737

3838
var _session2 = _interopRequireDefault(_session);
3939

40-
var _pool = require('./internal/pool');
40+
var _pool = require("./internal/pool");
4141

4242
var _pool2 = _interopRequireDefault(_pool);
4343

44-
var _integer = require('./integer');
44+
var _connector = require("./internal/connector");
4545

46-
var _integer2 = _interopRequireDefault(_integer);
47-
48-
var _connector = require('./internal/connector');
49-
50-
var _streamObserver = require('./internal/stream-observer');
46+
var _streamObserver = require("./internal/stream-observer");
5147

5248
var _streamObserver2 = _interopRequireDefault(_streamObserver);
5349

54-
var _error = require('./error');
50+
var _error = require("./error");
5551

5652
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5753

54+
var READ = 'READ',
55+
WRITE = 'WRITE';
56+
/**
57+
* A driver maintains one or more {@link Session sessions} with a remote
58+
* Neo4j instance. Through the {@link Session sessions} you can send statements
59+
* and retrieve results from the database.
60+
*
61+
* Drivers are reasonably expensive to create - you should strive to keep one
62+
* driver instance around per Neo4j Instance you connect to.
63+
*
64+
* @access public
65+
*/
5866
/**
5967
* Copyright (c) 2002-2017 "Neo Technology,","
6068
* Network Engine for Objects in Lund AB [http://neotechnology.com]
@@ -74,19 +82,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
7482
* limitations under the License.
7583
*/
7684

77-
var READ = 'READ',
78-
WRITE = 'WRITE';
79-
/**
80-
* A driver maintains one or more {@link Session sessions} with a remote
81-
* Neo4j instance. Through the {@link Session sessions} you can send statements
82-
* and retrieve results from the database.
83-
*
84-
* Drivers are reasonably expensive to create - you should strive to keep one
85-
* driver instance around per Neo4j Instance you connect to.
86-
*
87-
* @access public
88-
*/
89-
9085
var Driver = function () {
9186
/**
9287
* You should not be calling this directly, instead use {@link driver}.
@@ -119,7 +114,7 @@ var Driver = function () {
119114

120115

121116
(0, _createClass3.default)(Driver, [{
122-
key: '_createConnection',
117+
key: "_createConnection",
123118
value: function _createConnection(url, release) {
124119
var sessionId = this._sessionIdGenerator++;
125120
var conn = (0, _connector.connect)(url, this._config);
@@ -141,7 +136,7 @@ var Driver = function () {
141136
**/
142137

143138
}, {
144-
key: '_destroyConnection',
139+
key: "_destroyConnection",
145140

146141

147142
/**
@@ -170,56 +165,62 @@ var Driver = function () {
170165
*/
171166

172167
}, {
173-
key: 'session',
168+
key: "session",
174169
value: function session(mode) {
175170
var _this = this;
176171

177-
var connectionPromise = this._acquireConnection(mode);
172+
var sessionMode = Driver._validateSessionMode(mode);
173+
var connectionPromise = this._acquireConnection(sessionMode);
178174
connectionPromise.catch(function (err) {
179175
if (_this.onError && err.code === _error.SERVICE_UNAVAILABLE) {
180176
_this.onError(err);
181177
} else {
182178
//we don't need to tell the driver about this error
183179
}
184180
});
185-
return this._createSession(connectionPromise, function (cb) {
186-
// This gets called on Session#close(), and is where we return
187-
// the pooled 'connection' instance.
188-
189-
// We don't pool Session instances, to avoid users using the Session
190-
// after they've called close. The `Session` object is just a thin
191-
// wrapper around Connection anyway, so it makes little difference.
181+
return this._createSession(connectionPromise, this._releaseConnection(connectionPromise));
182+
}
192183

193-
// Queue up a 'reset', to ensure the next user gets a clean
194-
// session to work with.
184+
/**
185+
* The returned function gets called on Session#close(), and is where we return the pooled 'connection' instance.
186+
* We don't pool Session instances, to avoid users using the Session after they've called close.
187+
* The `Session` object is just a thin wrapper around Connection anyway, so it makes little difference.
188+
* @param {Promise} connectionPromise - promise resolved with the connection.
189+
* @return {function(callback: function)} - function that releases the connection and then executes an optional callback.
190+
* @protected
191+
*/
195192

193+
}, {
194+
key: "_releaseConnection",
195+
value: function _releaseConnection(connectionPromise) {
196+
return function (userDefinedCallback) {
196197
connectionPromise.then(function (conn) {
198+
// Queue up a 'reset', to ensure the next user gets a clean session to work with.
197199
conn.reset();
198200
conn.sync();
199201

200202
// Return connection to the pool
201203
conn._release();
202-
}).catch(function () {/*ignore errors here*/});
204+
}).catch(function (ignoredError) {});
203205

204-
// Call user callback
205-
if (cb) {
206-
cb();
206+
if (userDefinedCallback) {
207+
userDefinedCallback();
207208
}
208-
});
209+
};
209210
}
211+
}, {
212+
key: "_acquireConnection",
210213

211-
//Extension point
212214

213-
}, {
214-
key: '_acquireConnection',
215+
//Extension point
215216
value: function _acquireConnection(mode) {
216217
return _promise2.default.resolve(this._pool.acquire(this._url));
217218
}
218219

219220
//Extension point
220221

221222
}, {
222-
key: '_createSession',
223+
key: "_createSession",
223224
value: function _createSession(connectionPromise, cb) {
224225
return new _session2.default(connectionPromise, cb);
225226
}
@@ -231,7 +232,7 @@ var Driver = function () {
231232
*/
232233

233234
}, {
234-
key: 'close',
235+
key: "close",
235236
value: function close() {
236237
for (var sessionId in this._openSessions) {
237238
if (this._openSessions.hasOwnProperty(sessionId)) {
@@ -241,10 +242,19 @@ var Driver = function () {
241242
}
242243
}
243244
}], [{
244-
key: '_validateConnection',
245+
key: "_validateConnection",
245246
value: function _validateConnection(conn) {
246247
return conn.isOpen();
247248
}
249+
}, {
250+
key: "_validateSessionMode",
251+
value: function _validateSessionMode(rawMode) {
252+
var mode = rawMode || WRITE;
253+
if (mode !== READ && mode !== WRITE) {
254+
throw (0, _error.newError)('Illegal session mode ' + mode);
255+
}
256+
return mode;
257+
}
248258
}]);
249259
return Driver;
250260
}();
@@ -267,18 +277,18 @@ var _ConnectionStreamObserver = function (_StreamObserver) {
267277
}
268278

269279
(0, _createClass3.default)(_ConnectionStreamObserver, [{
270-
key: 'onError',
280+
key: "onError",
271281
value: function onError(error) {
272282
if (!this._hasFailed) {
273-
(0, _get3.default)(_ConnectionStreamObserver.prototype.__proto__ || (0, _getPrototypeOf2.default)(_ConnectionStreamObserver.prototype), 'onError', this).call(this, error);
283+
(0, _get3.default)(_ConnectionStreamObserver.prototype.__proto__ || (0, _getPrototypeOf2.default)(_ConnectionStreamObserver.prototype), "onError", this).call(this, error);
274284
if (this._driver.onError) {
275285
this._driver.onError(error);
276286
}
277287
this._hasFailed = true;
278288
}
279289
}
280290
}, {
281-
key: 'onCompleted',
291+
key: "onCompleted",
282292
value: function onCompleted(message) {
283293
if (this._driver.onCompleted) {
284294
this._driver.onCompleted(message);

lib/v1/error.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6-
exports.SESSION_EXPIRED = exports.SERVICE_UNAVAILABLE = exports.Neo4jError = exports.newError = undefined;
6+
exports.PROTOCOL_ERROR = exports.SESSION_EXPIRED = exports.SERVICE_UNAVAILABLE = exports.Neo4jError = exports.newError = undefined;
77

88
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
99

@@ -47,6 +47,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
4747

4848
var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
4949
var SESSION_EXPIRED = 'SessionExpired';
50+
var PROTOCOL_ERROR = 'ProtocolError';
51+
5052
function newError(message) {
5153
var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A";
5254

@@ -75,4 +77,5 @@ var Neo4jError = function (_Error) {
7577
exports.newError = newError;
7678
exports.Neo4jError = Neo4jError;
7779
exports.SERVICE_UNAVAILABLE = SERVICE_UNAVAILABLE;
78-
exports.SESSION_EXPIRED = SESSION_EXPIRED;
80+
exports.SESSION_EXPIRED = SESSION_EXPIRED;
81+
exports.PROTOCOL_ERROR = PROTOCOL_ERROR;

lib/v1/index.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,9 @@ var _version2 = _interopRequireDefault(_version);
3535

3636
var _connector = require('./internal/connector');
3737

38-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38+
var _util = require('./internal/util');
3939

40-
/**
41-
* Copyright (c) 2002-2017 "Neo Technology,","
42-
* Network Engine for Objects in Lund AB [http://neotechnology.com]
43-
*
44-
* This file is part of Neo4j.
45-
*
46-
* Licensed under the Apache License, Version 2.0 (the "License");
47-
* you may not use this file except in compliance with the License.
48-
* You may obtain a copy of the License at
49-
*
50-
* http://www.apache.org/licenses/LICENSE-2.0
51-
*
52-
* Unless required by applicable law or agreed to in writing, software
53-
* distributed under the License is distributed on an "AS IS" BASIS,
54-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55-
* See the License for the specific language governing permissions and
56-
* limitations under the License.
57-
*/
40+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5841

5942
var auth = {
6043
basic: function basic(username, password) {
@@ -76,7 +59,25 @@ var auth = {
7659
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
7760
}
7861
}
79-
};
62+
}; /**
63+
* Copyright (c) 2002-2017 "Neo Technology,","
64+
* Network Engine for Objects in Lund AB [http://neotechnology.com]
65+
*
66+
* This file is part of Neo4j.
67+
*
68+
* Licensed under the Apache License, Version 2.0 (the "License");
69+
* you may not use this file except in compliance with the License.
70+
* You may obtain a copy of the License at
71+
*
72+
* http://www.apache.org/licenses/LICENSE-2.0
73+
*
74+
* Unless required by applicable law or agreed to in writing, software
75+
* distributed under the License is distributed on an "AS IS" BASIS,
76+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77+
* See the License for the specific language governing permissions and
78+
* limitations under the License.
79+
*/
80+
8081
var USER_AGENT = "neo4j-javascript/" + _version2.default;
8182

8283
/**
@@ -140,6 +141,7 @@ var USER_AGENT = "neo4j-javascript/" + _version2.default;
140141
function driver(url, authToken) {
141142
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
142143

144+
(0, _util.assertString)(url, 'Bolt URL');
143145
var scheme = (0, _connector.parseScheme)(url);
144146
if (scheme === "bolt+routing://") {
145147
return new _routingDriver2.default((0, _connector.parseUrl)(url), USER_AGENT, authToken, config);
@@ -167,7 +169,8 @@ var session = {
167169
};
168170
var error = {
169171
SERVICE_UNAVAILABLE: _error.SERVICE_UNAVAILABLE,
170-
SESSION_EXPIRED: _error.SESSION_EXPIRED
172+
SESSION_EXPIRED: _error.SESSION_EXPIRED,
173+
PROTOCOL_ERROR: _error.PROTOCOL_ERROR
171174
};
172175
var integer = {
173176
toNumber: _integer.toNumber,

0 commit comments

Comments
 (0)