Socket
Socket
Sign inDemoInstall

neo4j-driver

Package Overview
Dependencies
Maintainers
2
Versions
162
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo4j-driver - npm Package Compare versions

Comparing version 1.1.0-M02 to 1.1.0-M03

.babelrc

35

lib/external/es6-promise.js

@@ -0,1 +1,5 @@

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/*!

@@ -9,8 +13,7 @@ * @overview es6-promise - a tiny implementation of Promises/A+.

'use strict';
(function () {
"use strict";
function lib$es6$promise$utils$$objectOrFunction(x) {
return typeof x === 'function' || typeof x === 'object' && x !== null;
return typeof x === 'function' || (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null;
}

@@ -23,3 +26,3 @@

function lib$es6$promise$utils$$isMaybeThenable(x) {
return typeof x === 'object' && x !== null;
return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null;
}

@@ -29,3 +32,3 @@

if (!Array.isArray) {
lib$es6$promise$utils$$_isArray = function (x) {
lib$es6$promise$utils$$_isArray = function lib$es6$promise$utils$$_isArray(x) {
return Object.prototype.toString.call(x) === '[object Array]';

@@ -39,3 +42,3 @@ };

var lib$es6$promise$asap$$len = 0;
var lib$es6$promise$asap$$toString = ({}).toString;
var lib$es6$promise$asap$$toString = {}.toString;
var lib$es6$promise$asap$$vertxNext;

@@ -71,3 +74,3 @@ var lib$es6$promise$asap$$customSchedulerFn;

var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';

@@ -380,10 +383,10 @@ // test for web worker but not in IE10

} else if (hasCallback && succeeded) {
lib$es6$promise$$internal$$resolve(promise, value);
} else if (failed) {
lib$es6$promise$$internal$$reject(promise, error);
} else if (settled === lib$es6$promise$$internal$$FULFILLED) {
lib$es6$promise$$internal$$fulfill(promise, value);
} else if (settled === lib$es6$promise$$internal$$REJECTED) {
lib$es6$promise$$internal$$reject(promise, value);
}
lib$es6$promise$$internal$$resolve(promise, value);
} else if (failed) {
lib$es6$promise$$internal$$reject(promise, error);
} else if (settled === lib$es6$promise$$internal$$FULFILLED) {
lib$es6$promise$$internal$$fulfill(promise, value);
} else if (settled === lib$es6$promise$$internal$$REJECTED) {
lib$es6$promise$$internal$$reject(promise, value);
}
}

@@ -537,3 +540,3 @@

if (object && typeof object === 'object' && object.constructor === Constructor) {
if (object && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object.constructor === Constructor) {
return object;

@@ -540,0 +543,0 @@ }

@@ -1,35 +0,33 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.v1 = undefined;
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
var _index = require('./v1/index');
var _v1Index = require('./v1/index');
var v1 = _interopRequireWildcard(_index);
var v1 = _interopRequireWildcard(_v1Index);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
exports['default'] = {
v1: v1
};
module.exports = exports['default'];
exports.v1 = v1; /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
exports.default = v1;

@@ -1,50 +0,61 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WRITE = exports.READ = exports.Driver = undefined;
var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x5 = parent; _x6 = property; _x7 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _session = require('./session');
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _session2 = _interopRequireDefault(_session);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _pool = require('./internal/pool');
var _session = require('./session');
var _pool2 = _interopRequireDefault(_pool);
var _session2 = _interopRequireDefault(_session);
var _integer = require('./integer');
var _internalPool = require('./internal/pool');
var _integer2 = _interopRequireDefault(_integer);
var _internalConnector = require("./internal/connector");
var _connector = require('./internal/connector');
var _internalStreamObserver = require('./internal/stream-observer');
var _streamObserver = require('./internal/stream-observer');
var _internalStreamObserver2 = _interopRequireDefault(_internalStreamObserver);
var _streamObserver2 = _interopRequireDefault(_streamObserver);
var _version = require('../version');
var _error = require('./error');
require('babel-polyfill');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var READ = 'READ',
WRITE = 'WRITE';
/**

@@ -61,3 +72,3 @@ * A driver maintains one or more {@link Session sessions} with a remote

var Driver = (function () {
var Driver = function () {
/**

@@ -72,7 +83,6 @@ * You should not be calling this directly, instead use {@link driver}.

*/
function Driver(url) {
var userAgent = arguments.length <= 1 || arguments[1] === undefined ? 'neo4j-javascript/0.0' : arguments[1];
var token = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var config = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var userAgent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'neo4j-javascript/0.0';
var token = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

@@ -87,7 +97,5 @@ _classCallCheck(this, Driver);

this._config = config;
this._pool = new _internalPool.Pool(this._createConnection.bind(this), this._destroyConnection.bind(this), this._validateConnection.bind(this), config.connectionPoolSize);
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
}
/** Internal stream observer used for connection state */
/**

@@ -99,12 +107,15 @@ * Create a new connection instance.

_createClass(Driver, [{
key: '_createConnection',
value: function _createConnection(release) {
value: function _createConnection(url, release) {
var _this = this;
var sessionId = this._sessionIdGenerator++;
var streamObserver = new _ConnectionStreamObserver(this);
var conn = (0, _internalConnector.connect)(this._url, this._config);
var conn = (0, _connector.connect)(url, this._config);
conn.initialize(this._userAgent, this._token, streamObserver);
conn._id = sessionId;
conn._release = function () {
return release(conn);
return release(_this._url, conn);
};

@@ -121,8 +132,7 @@

**/
}, {
key: '_validateConnection',
value: function _validateConnection(conn) {
return conn.isOpen();
}
key: '_destroyConnection',
/**

@@ -133,4 +143,2 @@ * Dispose of a live session, closing any associated resources.

*/
}, {
key: '_destroyConnection',
value: function _destroyConnection(conn) {

@@ -152,9 +160,20 @@ delete this._openSessions[conn._id];

*
* @param {String} mode of session - optional
* @return {Session} new session.
*/
}, {
key: 'session',
value: function session() {
var conn = this._pool.acquire();
return new _session2['default'](conn, function (cb) {
value: function session(mode) {
var _this2 = this;
var connectionPromise = this._acquireConnection(mode);
connectionPromise.catch(function (err) {
if (_this2.onError && err.code === _error.SERVICE_UNAVAILABLE) {
_this2.onError(err);
} else {
//we don't need to tell the driver about this error
}
});
return this._createSession(connectionPromise, function (cb) {
// This gets called on Session#close(), and is where we return

@@ -169,8 +188,11 @@ // the pooled 'connection' instance.

// session to work with.
conn.reset();
conn.sync();
// Return connection to the pool
conn._release();
connectionPromise.then(function (conn) {
conn.reset();
conn.sync();
// Return connection to the pool
conn._release();
}).catch(function () {/*ignore errors here*/});
// Call user callback

@@ -183,2 +205,18 @@ if (cb) {

//Extension point
}, {
key: '_acquireConnection',
value: function _acquireConnection(mode) {
return Promise.resolve(this._pool.acquire(this._url));
}
//Extension point
}, {
key: '_createSession',
value: function _createSession(connectionPromise, cb) {
return new _session2.default(connectionPromise, cb);
}
/**

@@ -189,2 +227,3 @@ * Close all open sessions and other associated resources. You should

*/
}, {

@@ -197,10 +236,19 @@ key: 'close',

}
this._pool.purgeAll();
}
}
}], [{
key: '_validateConnection',
value: function _validateConnection(conn) {
return conn.isOpen();
}
}]);
return Driver;
})();
}();
var _ConnectionStreamObserver = (function (_StreamObserver) {
/** Internal stream observer used for connection state */
var _ConnectionStreamObserver = function (_StreamObserver) {
_inherits(_ConnectionStreamObserver, _StreamObserver);

@@ -211,5 +259,7 @@

_get(Object.getPrototypeOf(_ConnectionStreamObserver.prototype), 'constructor', this).call(this);
this._driver = driver;
this._hasFailed = false;
var _this3 = _possibleConstructorReturn(this, (_ConnectionStreamObserver.__proto__ || Object.getPrototypeOf(_ConnectionStreamObserver)).call(this));
_this3._driver = driver;
_this3._hasFailed = false;
return _this3;
}

@@ -221,3 +271,3 @@

if (!this._hasFailed) {
_get(Object.getPrototypeOf(_ConnectionStreamObserver.prototype), 'onError', this).call(this, error);
_get(_ConnectionStreamObserver.prototype.__proto__ || Object.getPrototypeOf(_ConnectionStreamObserver.prototype), 'onError', this).call(this, error);
if (this._driver.onError) {

@@ -239,70 +289,7 @@ this._driver.onError(error);

return _ConnectionStreamObserver;
})(_internalStreamObserver2['default']);
}(_streamObserver2.default);
var USER_AGENT = "neo4j-javascript/" + _version.VERSION;
/**
* Construct a new Neo4j Driver. This is your main entry point for this
* library.
*
* ## Configuration
*
* This function optionally takes a configuration argument. Available configuration
* options are as follows:
*
* {
* // Encryption level: one of ENCRYPTION_ON, ENCRYPTION_OFF or ENCRYPTION_NON_LOCAL.
* // ENCRYPTION_NON_LOCAL is on by default in modern NodeJS installs,
* // but off by default in the Web Bundle and old (<=1.0.0) NodeJS installs
* // due to technical limitations on those platforms.
* encrypted: ENCRYPTION_ON|ENCRYPTION_OFF|ENCRYPTION_NON_LOCAL
*
* // Trust strategy to use if encryption is enabled. There is no mode to disable
* // trust other than disabling encryption altogether. The reason for
* // this is that if you don't know who you are talking to, it is easy for an
* // attacker to hijack your encrypted connection, rendering encryption pointless.
* //
* // TRUST_ON_FIRST_USE is the default for modern NodeJS deployments, and works
* // similarly to how `ssl` works - the first time we connect to a new host,
* // we remember the certificate they use. If the certificate ever changes, we
* // assume it is an attempt to hijack the connection and require manual intervention.
* // This means that by default, connections "just work" while still giving you
* // good encrypted protection.
* //
* // TRUST_CUSTOM_CA_SIGNED_CERTIFICATES is the classic approach to trust verification -
* // whenever we establish an encrypted connection, we ensure the host is using
* // an encryption certificate that is in, or is signed by, a certificate listed
* // as trusted. In the web bundle, this list of trusted certificates is maintained
* // by the web browser. In NodeJS, you configure the list with the next config option.
* //
* // TRUST_SYSTEM_CA_SIGNED_CERTIFICATES meand that you trust whatever certificates
* // are in the default certificate chain of th
* trust: "TRUST_ON_FIRST_USE" | "TRUST_SIGNED_CERTIFICATES" | TRUST_CUSTOM_CA_SIGNED_CERTIFICATES | TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
*
* // List of one or more paths to trusted encryption certificates. This only
* // works in the NodeJS bundle, and only matters if you use "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES".
* // The certificate files should be in regular X.509 PEM format.
* // For instance, ['./trusted.pem']
* trustedCertificates: [],
*
* // Path to a file where the driver saves hosts it has seen in the past, this is
* // very similar to the ssl tool's known_hosts file. Each time we connect to a
* // new host, a hash of their certificate is stored along with the domain name and
* // port, and this is then used to verify the host certificate does not change.
* // This setting has no effect unless TRUST_ON_FIRST_USE is enabled.
* knownHosts:"~/.neo4j/known_hosts",
* }
*
* @param {string} url The URL for the Neo4j database, for instance "bolt://localhost"
* @param {Map<String,String>} authToken Authentication credentials. See {@link auth} for helpers.
* @param {Object} config Configuration object. See the configuration section above for details.
* @returns {Driver}
*/
function driver(url, authToken) {
var config = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
return new Driver(url, USER_AGENT, authToken, config);
}
exports.Driver = Driver;
exports.driver = driver;
exports.READ = READ;
exports.WRITE = WRITE;
exports.default = Driver;

@@ -0,1 +1,13 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -23,18 +35,8 @@ * Copyright (c) 2002-2016 "Neo Technology,"

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var SERVICE_UNAVAILABLE = 'ServiceUnavailable';
var SESSION_EXPIRED = 'SessionExpired';
function newError(message) {
var code = arguments.length <= 1 || arguments[1] === undefined ? "N/A" : arguments[1];
var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A";
// TODO: Idea is that we can check the cod here and throw sub-classes
// TODO: Idea is that we can check the code here and throw sub-classes
// of Neo4jError as appropriate

@@ -44,19 +46,23 @@ return new Neo4jError(message, code);

var Neo4jError = (function (_Error) {
var Neo4jError = function (_Error) {
_inherits(Neo4jError, _Error);
function Neo4jError(message) {
var code = arguments.length <= 1 || arguments[1] === undefined ? "N/A" : arguments[1];
var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "N/A";
_classCallCheck(this, Neo4jError);
_get(Object.getPrototypeOf(Neo4jError.prototype), "constructor", this).call(this, message);
this.message = message;
this.code = code;
var _this = _possibleConstructorReturn(this, (Neo4jError.__proto__ || Object.getPrototypeOf(Neo4jError)).call(this, message));
_this.message = message;
_this.code = code;
return _this;
}
return Neo4jError;
})(Error);
}(Error);
exports.newError = newError;
exports.Neo4jError = Neo4jError;
exports.Neo4jError = Neo4jError;
exports.SERVICE_UNAVAILABLE = SERVICE_UNAVAILABLE;
exports.SESSION_EXPIRED = SESSION_EXPIRED;

@@ -0,1 +1,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -23,13 +33,3 @@ * Copyright (c) 2002-2016 "Neo Technology,"

*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Node = (function () {
var Node = function () {
/**

@@ -41,3 +41,2 @@ * @constructor

*/
function Node(identity, labels, properties) {

@@ -51,6 +50,2 @@ _classCallCheck(this, Node);

/**
* Class for Relationship Type.
*/
_createClass(Node, [{

@@ -66,5 +61,5 @@ key: "toString",

s += " {";
for (var i = 0; i < keys.length; i++) {
if (i > 0) s += ",";
s += keys[i] + ":" + JSON.stringify(this.properties[keys[i]]);
for (var _i = 0; _i < keys.length; _i++) {
if (_i > 0) s += ",";
s += keys[_i] + ":" + JSON.stringify(this.properties[keys[_i]]);
}

@@ -79,5 +74,10 @@ s += "}";

return Node;
})();
}();
var Relationship = (function () {
/**
* Class for Relationship Type.
*/
var Relationship = function () {
/**

@@ -91,3 +91,2 @@ * @constructor

*/
function Relationship(identity, start, end, type, properties) {

@@ -103,7 +102,2 @@ _classCallCheck(this, Relationship);

/**
* Class for UnboundRelationship Type.
* @access private
*/
_createClass(Relationship, [{

@@ -128,5 +122,11 @@ key: "toString",

return Relationship;
})();
}();
var UnboundRelationship = (function () {
/**
* Class for UnboundRelationship Type.
* @access private
*/
var UnboundRelationship = function () {
/**

@@ -138,3 +138,2 @@ * @constructor

*/
function UnboundRelationship(identity, type, properties) {

@@ -149,6 +148,2 @@ _classCallCheck(this, UnboundRelationship);

/**
* Class for PathSegment Type.
*/
/**
* Bind relationship

@@ -160,2 +155,3 @@ * @param {string} start - Indentity of start node

_createClass(UnboundRelationship, [{

@@ -185,4 +181,9 @@ key: "bind",

return UnboundRelationship;
})();
}();
/**
* Class for PathSegment Type.
*/
var PathSegment =

@@ -201,3 +202,3 @@ /**

this.end = end;
}
};

@@ -207,4 +208,4 @@ /**

*/
;
var Path =

@@ -226,9 +227,6 @@ /**

exports["default"] = {
Node: Node,
Relationship: Relationship,
UnboundRelationship: UnboundRelationship,
Path: Path,
PathSegment: PathSegment
};
module.exports = exports["default"];
exports.Node = Node;
exports.Relationship = Relationship;
exports.UnboundRelationship = UnboundRelationship;
exports.Path = Path;
exports.PathSegment = PathSegment;

@@ -0,1 +1,40 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.error = exports.session = exports.types = exports.auth = exports.Neo4jError = exports.integer = exports.isInt = exports.int = exports.driver = undefined;
var _integer = require('./integer');
var _graphTypes = require('./graph-types');
var _error = require('./error');
var _result = require('./result');
var _result2 = _interopRequireDefault(_result);
var _resultSummary = require('./result-summary');
var _resultSummary2 = _interopRequireDefault(_resultSummary);
var _record = require('./record');
var _record2 = _interopRequireDefault(_record);
var _driver = require('./driver');
var _routingDriver = require('./routing-driver');
var _routingDriver2 = _interopRequireDefault(_routingDriver);
var _version = require('../version');
var _version2 = _interopRequireDefault(_version);
var _connector = require('./internal/connector');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -20,65 +59,142 @@ * Copyright (c) 2002-2016 "Neo Technology,"

'use strict';
var auth = {
basic: function basic(username, password) {
var realm = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
Object.defineProperty(exports, '__esModule', {
value: true
});
if (realm) {
return { scheme: "basic", principal: username, credentials: password, realm: realm };
} else {
return { scheme: "basic", principal: username, credentials: password };
}
},
custom: function custom(principal, credentials, realm, scheme) {
var parameters = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
if (parameters) {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm,
parameters: parameters };
} else {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
}
}
};
var USER_AGENT = "neo4j-javascript/" + _version2.default;
var _integer = require('./integer');
/**
* Construct a new Neo4j Driver. This is your main entry point for this
* library.
*
* ## Configuration
*
* This function optionally takes a configuration argument. Available configuration
* options are as follows:
*
* {
* // Encryption level: one of ENCRYPTION_ON, ENCRYPTION_OFF or ENCRYPTION_NON_LOCAL.
* // ENCRYPTION_NON_LOCAL is on by default in modern NodeJS installs,
* // but off by default in the Web Bundle and old (<=1.0.0) NodeJS installs
* // due to technical limitations on those platforms.
* encrypted: ENCRYPTION_ON|ENCRYPTION_OFF|ENCRYPTION_NON_LOCAL
*
* // Trust strategy to use if encryption is enabled. There is no mode to disable
* // trust other than disabling encryption altogether. The reason for
* // this is that if you don't know who you are talking to, it is easy for an
* // attacker to hijack your encrypted connection, rendering encryption pointless.
* //
* // TRUST_ON_FIRST_USE is the default for modern NodeJS deployments, and works
* // similarly to how `ssl` works - the first time we connect to a new host,
* // we remember the certificate they use. If the certificate ever changes, we
* // assume it is an attempt to hijack the connection and require manual intervention.
* // This means that by default, connections "just work" while still giving you
* // good encrypted protection.
* //
* // TRUST_CUSTOM_CA_SIGNED_CERTIFICATES is the classic approach to trust verification -
* // whenever we establish an encrypted connection, we ensure the host is using
* // an encryption certificate that is in, or is signed by, a certificate listed
* // as trusted. In the web bundle, this list of trusted certificates is maintained
* // by the web browser. In NodeJS, you configure the list with the next config option.
* //
* // TRUST_SYSTEM_CA_SIGNED_CERTIFICATES meand that you trust whatever certificates
* // are in the default certificate chain of th
* trust: "TRUST_ON_FIRST_USE" | "TRUST_SIGNED_CERTIFICATES" | TRUST_CUSTOM_CA_SIGNED_CERTIFICATES |
* TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
*
* // List of one or more paths to trusted encryption certificates. This only
* // works in the NodeJS bundle, and only matters if you use "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES".
* // The certificate files should be in regular X.509 PEM format.
* // For instance, ['./trusted.pem']
* trustedCertificates: [],
*
* // Path to a file where the driver saves hosts it has seen in the past, this is
* // very similar to the ssl tool's known_hosts file. Each time we connect to a
* // new host, a hash of their certificate is stored along with the domain name and
* // port, and this is then used to verify the host certificate does not change.
* // This setting has no effect unless TRUST_ON_FIRST_USE is enabled.
* knownHosts:"~/.neo4j/known_hosts",
* }
*
* @param {string} url The URL for the Neo4j database, for instance "bolt://localhost"
* @param {Map<String,String>} authToken Authentication credentials. See {@link auth} for helpers.
* @param {Object} config Configuration object. See the configuration section above for details.
* @returns {Driver}
*/
function driver(url, authToken) {
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _driver = require('./driver');
var scheme = (0, _connector.parseScheme)(url);
if (scheme === "bolt+routing://") {
return new _routingDriver2.default((0, _connector.parseUrl)(url), USER_AGENT, authToken, config);
} else if (scheme === "bolt://") {
return new _driver.Driver((0, _connector.parseUrl)(url), USER_AGENT, authToken, config);
} else {
throw new Error("Unknown scheme: " + scheme);
}
}
var _graphTypes = require('./graph-types');
var types = {
Node: _graphTypes.Node,
Relationship: _graphTypes.Relationship,
UnboundRelationship: _graphTypes.UnboundRelationship,
PathSegment: _graphTypes.PathSegment,
Path: _graphTypes.Path,
Result: _result2.default,
ResultSummary: _resultSummary2.default,
Record: _record2.default
};
var _error = require('./error');
var session = {
READ: _driver.READ,
WRITE: _driver.WRITE
};
var error = {
SERVICE_UNAVAILABLE: _error.SERVICE_UNAVAILABLE,
SESSION_EXPIRED: _error.SESSION_EXPIRED
};
var integer = {
toNumber: _integer.toNumber,
toString: _integer.toString,
inSafeRange: _integer.inSafeRange
};
var _result = require('./result');
var _result2 = _interopRequireDefault(_result);
var _resultSummary = require('./result-summary');
var _resultSummary2 = _interopRequireDefault(_resultSummary);
var _record = require('./record');
exports['default'] = {
driver: _driver.driver,
var forExport = {
driver: driver,
int: _integer.int,
isInt: _integer.isInt,
integer: integer,
Neo4jError: _error.Neo4jError,
auth: {
basic: function basic(username, password) {
var realm = arguments.length <= 2 || arguments[2] === undefined ? undefined : arguments[2];
auth: auth,
types: types,
session: session,
error: error
};
if (realm) {
return { scheme: "basic", principal: username, credentials: password, realm: realm };
} else {
return { scheme: "basic", principal: username, credentials: password };
}
},
custom: function custom(principal, credentials, realm, scheme) {
var parameters = arguments.length <= 4 || arguments[4] === undefined ? undefined : arguments[4];
if (parameters) {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm,
parameters: parameters };
} else {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
}
}
},
types: {
Node: _graphTypes.Node,
Relationship: _graphTypes.Relationship,
UnboundRelationship: _graphTypes.UnboundRelationship,
PathSegment: _graphTypes.PathSegment,
Path: _graphTypes.Path,
Result: _result2['default'],
ResultSummary: _resultSummary2['default'],
Record: _record.Record
}
};
module.exports = exports['default'];
exports.driver = driver;
exports.int = _integer.int;
exports.isInt = _integer.isInt;
exports.integer = integer;
exports.Neo4jError = _error.Neo4jError;
exports.auth = auth;
exports.types = types;
exports.session = session;
exports.error = error;
exports.default = forExport;

@@ -1,36 +0,35 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// 64-bit Integer library, originally from Long.js by dcodeIO
// https://github.com/dcodeIO/Long.js
// License Apache 2
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toString = exports.toNumber = exports.inSafeRange = exports.isInt = exports.int = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
// 64-bit Integer library, originally from Long.js by dcodeIO
// https://github.com/dcodeIO/Long.js
// License Apache 2
var _error = require("./error");
var _error = require('./error');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -45,5 +44,6 @@ * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.

* @constructor
*
* @deprecated This class will be removed or made internal in a future version of the driver.
*/
var Integer = (function () {
var Integer = function () {
function Integer(low, high) {

@@ -67,10 +67,2 @@ _classCallCheck(this, Integer);

/**
* An indicator used to reliably determine if an object is a Integer or not.
* @type {boolean}
* @const
* @expose
* @private
*/
// The internal representation of an Integer is the two given signed, 32-bit values.

@@ -93,9 +85,15 @@ // We use 32-bit pieces because these are the size of integers on which

/**
* Converts the Integer to an exact javascript Number, assuming it is a 32 bit integer.
* @returns {number}
* @expose
*/
_createClass(Integer, [{
key: 'inSafeRange',
value: function inSafeRange() {
return this.greaterThanOrEqual(Integer.MIN_SAFE_VALUE) && this.lessThanOrEqual(Integer.MAX_SAFE_VALUE);
}
/**
* Converts the Integer to an exact javascript Number, assuming it is a 32 bit integer.
* @returns {number}
* @expose
*/
}, {
key: 'toInt',

@@ -108,2 +106,3 @@ value: function toInt() {

/**

@@ -126,2 +125,3 @@ * Converts the Integer to a the nearest floating-point representation of this value (double, 53 bit mantissa).

*/
}, {

@@ -156,4 +156,5 @@ key: 'toString',

if (rem.isZero()) return digits + result;else {
while (digits.length < 6) digits = '0' + digits;
result = '' + digits + result;
while (digits.length < 6) {
digits = '0' + digits;
}result = '' + digits + result;
}

@@ -168,2 +169,3 @@ }

*/
}, {

@@ -180,2 +182,3 @@ key: 'getHighBits',

*/
}, {

@@ -192,2 +195,3 @@ key: 'getLowBits',

*/
}, {

@@ -198,4 +202,5 @@ key: 'getNumBitsAbs',

var val = this.high != 0 ? this.high : this.low;
for (var bit = 31; bit > 0; bit--) if ((val & 1 << bit) != 0) break;
return this.high != 0 ? bit + 33 : bit + 1;
for (var bit = 31; bit > 0; bit--) {
if ((val & 1 << bit) != 0) break;
}return this.high != 0 ? bit + 33 : bit + 1;
}

@@ -208,2 +213,3 @@

*/
}, {

@@ -220,2 +226,3 @@ key: 'isZero',

*/
}, {

@@ -232,2 +239,3 @@ key: 'isNegative',

*/
}, {

@@ -244,2 +252,3 @@ key: 'isPositive',

*/
}, {

@@ -256,2 +265,3 @@ key: 'isOdd',

*/
}, {

@@ -265,2 +275,3 @@ key: 'isEven',

/**

@@ -283,2 +294,3 @@ * Tests if this Integer's value equals the specified's.

*/
}, {

@@ -296,2 +308,3 @@ key: 'notEquals',

*/
}, {

@@ -309,2 +322,3 @@ key: 'lessThan',

*/
}, {

@@ -322,2 +336,3 @@ key: 'lessThanOrEqual',

*/
}, {

@@ -335,2 +350,3 @@ key: 'greaterThan',

*/
}, {

@@ -349,2 +365,3 @@ key: 'greaterThanOrEqual',

*/
}, {

@@ -368,2 +385,3 @@ key: 'compare',

*/
}, {

@@ -382,2 +400,3 @@ key: 'negate',

*/
}, {

@@ -424,2 +443,3 @@ key: 'add',

*/
}, {

@@ -438,2 +458,3 @@ key: 'subtract',

*/
}, {

@@ -497,2 +518,3 @@ key: 'multiply',

/**

@@ -546,2 +568,3 @@ * Returns this Integer divided by the specified.

// Decrease the approximation until it is smaller than the remainder. Note

@@ -573,2 +596,3 @@ // that if it is too large, the product overflows and is negative.

*/
}, {

@@ -586,2 +610,3 @@ key: 'modulo',

*/
}, {

@@ -599,2 +624,3 @@ key: 'not',

*/
}, {

@@ -613,2 +639,3 @@ key: 'and',

*/
}, {

@@ -627,2 +654,3 @@ key: 'or',

*/
}, {

@@ -641,2 +669,3 @@ key: 'xor',

*/
}, {

@@ -655,2 +684,3 @@ key: 'shiftLeft',

*/
}, {

@@ -665,4 +695,13 @@ key: 'shiftRight',

return Integer;
})();
}();
/**
* An indicator used to reliably determine if an object is a Integer or not.
* @type {boolean}
* @const
* @expose
* @private
*/
Integer.__isInteger__;

@@ -794,2 +833,37 @@

/**
* Converts the specified value to a number.
* @access private
* @param {!Integer|number|string|!{low: number, high: number}} val Value
* @returns {number}
* @expose
*/
Integer.toNumber = function (val) {
return Integer.fromValue(val).toNumber();
};
/**
* Converts the specified value to a string.
* @access private
* @param {!Integer|number|string|!{low: number, high: number}} val Value
* @param {number} radix optional radix for string conversion, defaults to 10
* @returns {String}
* @expose
*/
Integer.toString = function (val, radix) {
return Integer.fromValue(val).toString(radix);
};
/**
* Checks if the given value is in the safe range in order to be converted to a native number
* @access private
* @param {!Integer|number|string|!{low: number, high: number}} val Value
* @param {number} radix optional radix for string conversion, defaults to 10
* @returns {boolean}
* @expose
*/
Integer.inSafeRange = function (val) {
return Integer.fromValue(val).inSafeRange();
};
/**
* @type {number}

@@ -878,2 +952,16 @@ * @const

/**
* Minimum safe value.
* @type {!Integer}
* @expose
*/
Integer.MIN_SAFE_VALUE = Integer.fromBits(0x1 | 0, 0xFFFFFFFFFFE00000 | 0);
/**
* Maximum safe value.
* @type {!Integer}
* @expose
*/
Integer.MAX_SAFE_VALUE = Integer.fromBits(0xFFFFFFFF | 0, 0x1FFFFF | 0);
/**
* Cast value to Integer type.

@@ -889,3 +977,3 @@ * @access public

* @access public
* @param {Mixed} value - The varaible to check.
* @param {Mixed} value - The variable to check.
* @return {Boolean} - Is it of the Integer type?

@@ -895,7 +983,32 @@ */

exports['default'] = {
Integer: Integer,
int: int,
isInt: isInt
};
module.exports = exports['default'];
/**
* Check if a variable can be safely converted to a number
* @access public
* @param {Mixed} value - The variable to check
* @return {Boolean} - true if it is safe to call toNumber on variable otherwise false
*/
var inSafeRange = Integer.inSafeRange;
/**
* Converts a variable to a number
* @access public
* @param {Mixed} value - The variable to convert
* @return {number} - the variable as a number
*/
var toNumber = Integer.toNumber;
/**
* Converts the integer to a string representation
* @access public
* @param {Mixed} value - The variable to convert
* @param {number} radix - radix to use in string conversion, defaults to 10
* @return {String} - returns a string representation of the integer
*/
var toString = Integer.toString;
exports.int = int;
exports.isInt = isInt;
exports.inSafeRange = inSafeRange;
exports.toNumber = toNumber;
exports.toString = toString;
exports.default = Integer;

@@ -1,20 +0,27 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.alloc = exports.NodeBuffer = exports.CombinedBuffer = exports.SliceBuffer = exports.HeapBuffer = exports.BaseBuffer = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** This module defines a common API for dealing with binary data that

@@ -25,12 +32,6 @@ * works for both browsers (via ArrayBuffer/DataView) and for NodeJS

"use strict";
var _error = require("./../error");
Object.defineProperty(exports, "__esModule", {
value: true
});
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -40,4 +41,2 @@

var _error = require('./../error');
var _node = require("buffer");

@@ -54,3 +53,3 @@ /**

var BaseBuffer = (function () {
var BaseBuffer = function () {
/**

@@ -61,3 +60,2 @@ * Create a instance with the injected size.

*/
function BaseBuffer(size) {

@@ -68,3 +66,3 @@ _classCallCheck(this, BaseBuffer);

this.length = size;
// Calling these out - this is the required
// Calling these out - this is the required
// methods a subclass needs to implement

@@ -81,10 +79,6 @@ var getUInt8 = null;

/**
* Basic buffer implementation that should work in most any modern JS env.
* @access private
*/
/**
* @param p
*/
_createClass(BaseBuffer, [{

@@ -99,2 +93,3 @@ key: "getInt16",

*/
}, {

@@ -109,2 +104,3 @@ key: "getUInt16",

*/
}, {

@@ -119,2 +115,3 @@ key: "getInt32",

*/
}, {

@@ -129,2 +126,3 @@ key: "getUInt32",

*/
}, {

@@ -142,2 +140,3 @@ key: "getInt64",

*/
}, {

@@ -153,2 +152,3 @@ key: "getSlice",

*/
}, {

@@ -165,2 +165,3 @@ key: "putInt16",

*/
}, {

@@ -177,2 +178,3 @@ key: "putUInt16",

*/
}, {

@@ -191,2 +193,3 @@ key: "putInt32",

*/
}, {

@@ -205,2 +208,3 @@ key: "putUInt32",

*/
}, {

@@ -223,2 +227,3 @@ key: "putInt64",

*/
}, {

@@ -235,2 +240,3 @@ key: "putBytes",

*/
}, {

@@ -245,2 +251,3 @@ key: "readUInt8",

*/
}, {

@@ -255,2 +262,3 @@ key: "readInt8",

*/
}, {

@@ -265,2 +273,3 @@ key: "readUInt16",

*/
}, {

@@ -275,2 +284,3 @@ key: "readUInt32",

*/
}, {

@@ -285,2 +295,3 @@ key: "readInt16",

*/
}, {

@@ -295,2 +306,3 @@ key: "readInt32",

*/
}, {

@@ -305,2 +317,3 @@ key: "readInt64",

*/
}, {

@@ -316,2 +329,3 @@ key: "readFloat64",

*/
}, {

@@ -327,2 +341,3 @@ key: "writeUInt8",

*/
}, {

@@ -338,2 +353,3 @@ key: "writeInt8",

*/
}, {

@@ -349,2 +365,3 @@ key: "writeInt16",

*/
}, {

@@ -360,2 +377,3 @@ key: "writeInt32",

*/
}, {

@@ -371,2 +389,3 @@ key: "writeUInt32",

*/
}, {

@@ -382,2 +401,3 @@ key: "writeInt64",

*/
}, {

@@ -393,2 +413,3 @@ key: "writeFloat64",

*/
}, {

@@ -405,2 +426,3 @@ key: "writeBytes",

*/
}, {

@@ -422,2 +444,3 @@ key: "readSlice",

*/
}, {

@@ -432,2 +455,3 @@ key: "remaining",

*/
}, {

@@ -442,2 +466,3 @@ key: "hasRemaining",

*/
}, {

@@ -453,2 +478,3 @@ key: "reset",

*/
}, {

@@ -464,2 +490,3 @@ key: "toString",

*/
}, {

@@ -482,5 +509,11 @@ key: "toHex",

return BaseBuffer;
})();
}();
var HeapBuffer = (function (_BaseBuffer) {
/**
* Basic buffer implementation that should work in most any modern JS env.
* @access private
*/
var HeapBuffer = function (_BaseBuffer) {
_inherits(HeapBuffer, _BaseBuffer);

@@ -492,12 +525,10 @@

var buffer = arg instanceof ArrayBuffer ? arg : new ArrayBuffer(arg);
_get(Object.getPrototypeOf(HeapBuffer.prototype), "constructor", this).call(this, buffer.byteLength);
this._buffer = buffer;
this._view = new DataView(this._buffer);
var _this = _possibleConstructorReturn(this, (HeapBuffer.__proto__ || Object.getPrototypeOf(HeapBuffer)).call(this, buffer.byteLength));
_this._buffer = buffer;
_this._view = new DataView(_this._buffer);
return _this;
}
/**
* Represents a view as slice of another buffer.
* @access private
*/
_createClass(HeapBuffer, [{

@@ -554,2 +585,3 @@ key: "putUInt8",

*/
}, {

@@ -563,5 +595,11 @@ key: "readView",

return HeapBuffer;
})(BaseBuffer);
}(BaseBuffer);
var SliceBuffer = (function (_BaseBuffer2) {
/**
* Represents a view as slice of another buffer.
* @access private
*/
var SliceBuffer = function (_BaseBuffer2) {
_inherits(SliceBuffer, _BaseBuffer2);

@@ -572,12 +610,9 @@

_get(Object.getPrototypeOf(SliceBuffer.prototype), "constructor", this).call(this, length);
this._start = start;
this._inner = inner;
var _this2 = _possibleConstructorReturn(this, (SliceBuffer.__proto__ || Object.getPrototypeOf(SliceBuffer)).call(this, length));
_this2._start = start;
_this2._inner = inner;
return _this2;
}
/**
* Buffer that combines multiple buffers, exposing them as one single buffer.
* @access private
*/
_createClass(SliceBuffer, [{

@@ -616,5 +651,11 @@ key: "putUInt8",

return SliceBuffer;
})(BaseBuffer);
}(BaseBuffer);
var CombinedBuffer = (function (_BaseBuffer3) {
/**
* Buffer that combines multiple buffers, exposing them as one single buffer.
* @access private
*/
var CombinedBuffer = function (_BaseBuffer3) {
_inherits(CombinedBuffer, _BaseBuffer3);

@@ -629,11 +670,9 @@

}
_get(Object.getPrototypeOf(CombinedBuffer.prototype), "constructor", this).call(this, length);
this._buffers = buffers;
var _this3 = _possibleConstructorReturn(this, (CombinedBuffer.__proto__ || Object.getPrototypeOf(CombinedBuffer)).call(this, length));
_this3._buffers = buffers;
return _this3;
}
/**
* Buffer used in a Node.js environment
* @access private
*/
_createClass(CombinedBuffer, [{

@@ -681,5 +720,11 @@ key: "getUInt8",

return CombinedBuffer;
})(BaseBuffer);
}(BaseBuffer);
var NodeBuffer = (function (_BaseBuffer4) {
/**
* Buffer used in a Node.js environment
* @access private
*/
var NodeBuffer = function (_BaseBuffer4) {
_inherits(NodeBuffer, _BaseBuffer4);

@@ -691,8 +736,9 @@

var buffer = arg instanceof _node.Buffer ? arg : new _node.Buffer(arg);
_get(Object.getPrototypeOf(NodeBuffer.prototype), "constructor", this).call(this, buffer.length);
this._buffer = buffer;
var _this4 = _possibleConstructorReturn(this, (NodeBuffer.__proto__ || Object.getPrototypeOf(NodeBuffer)).call(this, buffer.length));
_this4._buffer = buffer;
return _this4;
}
// Use HeapBuffer by default, unless Buffer API is available, see below
_createClass(NodeBuffer, [{

@@ -747,4 +793,7 @@ key: "getUInt8",

return NodeBuffer;
})(BaseBuffer);
}(BaseBuffer);
// Use HeapBuffer by default, unless Buffer API is available, see below
var _DefaultBuffer = HeapBuffer;

@@ -768,10 +817,7 @@ try {

exports["default"] = {
BaseBuffer: BaseBuffer,
HeapBuffer: HeapBuffer,
SliceBuffer: SliceBuffer,
CombinedBuffer: CombinedBuffer,
NodeBuffer: NodeBuffer,
alloc: alloc
};
module.exports = exports["default"];
exports.BaseBuffer = BaseBuffer;
exports.HeapBuffer = HeapBuffer;
exports.SliceBuffer = SliceBuffer;
exports.CombinedBuffer = CombinedBuffer;
exports.NodeBuffer = NodeBuffer;
exports.alloc = alloc;

@@ -1,20 +0,1 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";

@@ -25,9 +6,27 @@

});
exports.observer = exports.channel = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var _buf = require("./buf");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _buf = require('./buf');
var observer = {

@@ -40,3 +39,3 @@ instance: null,

var DummyChannel = (function () {
var DummyChannel = function () {
function DummyChannel(opts) {

@@ -76,8 +75,7 @@ _classCallCheck(this, DummyChannel);

return DummyChannel;
})();
}();
exports["default"] = {
channel: DummyChannel,
observer: observer
};
module.exports = exports["default"];
var channel = DummyChannel;
exports.channel = channel;
exports.observer = observer;

@@ -1,32 +0,26 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _net = require('net');

@@ -56,2 +50,6 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _CONNECTION_IDGEN = 0;

@@ -70,7 +68,7 @@

try {
_fs2['default'].mkdirSync(pathToCreate);
_fs2.default.mkdirSync(pathToCreate);
} catch (e) {
if (e.code === 'ENOENT') {
// Create parent dir
mkFullPath(_path2['default'].dirname(pathToCreate));
mkFullPath(_path2.default.dirname(pathToCreate));
// And now try again

@@ -89,3 +87,3 @@ mkFullPath(pathToCreate);

try {
_fs2['default'].accessSync(knownHostsPath);
_fs2.default.accessSync(knownHostsPath);
} catch (e) {

@@ -96,3 +94,3 @@ return cb(null);

require('readline').createInterface({
input: _fs2['default'].createReadStream(knownHostsPath)
input: _fs2.default.createReadStream(knownHostsPath)
}).on('line', function (line) {

@@ -124,8 +122,8 @@ if (!found && line.startsWith(serverId)) {

try {
_fs2['default'].accessSync(knownHostsPath);
_fs2.default.accessSync(knownHostsPath);
} catch (_) {
mkFullPath(_path2['default'].dirname(knownHostsPath));
mkFullPath(_path2.default.dirname(knownHostsPath));
}
_fs2['default'].appendFile(knownHostsPath, serverId + " " + fingerprint + _os.EOL, "utf8", function (err) {
_fs2.default.appendFile(knownHostsPath, serverId + " " + fingerprint + _os.EOL, "utf8", function (err) {
delete _lockFingerprintFromAppending[serverId];

@@ -144,3 +142,3 @@ if (err) {

TRUST_SIGNED_CERTIFICATES: function TRUST_SIGNED_CERTIFICATES(opts, onSuccess, onFailure) {
console.log("`TRUST_SIGNED_CERTIFICATES` has been deprecated as option and will be removed in a future version of " + "the driver. Pleas use `TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` instead.");
console.log("`TRUST_SIGNED_CERTIFICATES` has been deprecated as option and will be removed in a future version of " + "the driver. Please use `TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` instead.");
return TrustStrategy.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES(opts, onSuccess, onFailure);

@@ -156,3 +154,3 @@ },

ca: opts.trustedCertificates.map(function (f) {
return _fs2['default'].readFileSync(f);
return _fs2.default.readFileSync(f);
}),

@@ -164,3 +162,3 @@ // Because we manually check for this in the connect callback, to give

var socket = _tls2['default'].connect(opts.port, opts.host, tlsOpts, function () {
var socket = _tls2.default.connect(opts.port, opts.host, tlsOpts, function () {
if (!socket.authorized) {

@@ -182,3 +180,3 @@ onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));

};
var socket = _tls2['default'].connect(opts.port, opts.host, tlsOpts, function () {
var socket = _tls2.default.connect(opts.port, opts.host, tlsOpts, function () {
if (!socket.authorized) {

@@ -199,3 +197,3 @@ onFailure((0, _error.newError)("Server certificate is not trusted. If you trust the database you are connecting to, use " + "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES and add" + " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" + " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " + " is a security measure to protect against man-in-the-middle attacks. If you are just trying " + " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=\"" + _util.ENCRYPTION_OFF + "\"`" + " in the driver options. Socket responded with: " + socket.authorizationError));

var socket = _tls2['default'].connect(opts.port, opts.host, tlsOpts, function () {
var socket = _tls2.default.connect(opts.port, opts.host, tlsOpts, function () {
var serverCert = socket.getPeerCertificate( /*raw=*/true);

@@ -213,3 +211,3 @@

var serverFingerprint = require('crypto').createHash('sha512').update(serverCert.raw).digest("hex");
var knownHostsPath = opts.knownHosts || _path2['default'].join(userHome(), ".neo4j", "known_hosts");
var knownHostsPath = opts.knownHosts || _path2.default.join(userHome(), ".neo4j", "known_hosts");
var serverId = opts.host + ":" + opts.port;

@@ -238,9 +236,9 @@

function connect(opts, onSuccess) {
var onFailure = arguments.length <= 2 || arguments[2] === undefined ? function () {
var onFailure = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
return null;
} : arguments[2];
};
//still allow boolean for backwards compatibility
if (opts.encrypted === false || opts.encrypted === _util.ENCRYPTION_OFF || opts.encrypted === _util.ENCRYPTION_NON_LOCAL && (0, _util.isLocalHost)(opts.host)) {
var conn = _net2['default'].connect(opts.port, opts.host, onSuccess);
var conn = _net2.default.connect(opts.port, opts.host, onSuccess);
conn.on('error', onFailure);

@@ -261,3 +259,3 @@ return conn;

var NodeChannel = (function () {
var NodeChannel = function () {

@@ -270,3 +268,2 @@ /**

*/
function NodeChannel(opts) {

@@ -283,2 +280,3 @@ _classCallCheck(this, NodeChannel);

this._handleConnectionError = this._handleConnectionError.bind(this);
this._handleConnectionTerminated = this._handleConnectionTerminated.bind(this);

@@ -312,5 +310,6 @@ this._encrypted = opts.encrypted;

value: function _handleConnectionError(err) {
this._error = err;
var msg = err.message || 'Failed to connect to server';
this._error = (0, _error.newError)(msg, _error.SESSION_EXPIRED);
if (this.onerror) {
this.onerror(err);
this.onerror(this._error);
}

@@ -321,3 +320,3 @@ }

value: function _handleConnectionTerminated() {
this._error = new Error('Connection was closed by server');
this._error = (0, _error.newError)('Connection was closed by server', _error.SESSION_EXPIRED);
if (this.onerror) {

@@ -337,2 +336,3 @@ this.onerror(this._error);

*/
}, {

@@ -357,8 +357,9 @@ key: 'write',

*/
}, {
key: 'close',
value: function close() {
var cb = arguments.length <= 0 || arguments[0] === undefined ? function () {
var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
return null;
} : arguments[0];
};

@@ -377,3 +378,3 @@ this._open = false;

return NodeChannel;
})();
}();

@@ -389,3 +390,2 @@ var _nodeChannelModule = { channel: NodeChannel, available: true };

exports['default'] = _nodeChannelModule;
module.exports = exports['default'];
exports.default = _nodeChannelModule;

@@ -1,20 +0,1 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";

@@ -26,14 +7,35 @@

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _log = require("./log");
var _log2 = _interopRequireDefault(_log);
var _buf = require("./buf");
var _error = require('./../error');
var _error = require("./../error");
var _util = require('./util');
var _util = require("./util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -43,5 +45,4 @@ * Create a new WebSocketChannel to be used in web browsers.

*/
var WebSocketChannel = function () {
var WebSocketChannel = (function () {
/**

@@ -53,3 +54,2 @@ * Create new instance

*/
function WebSocketChannel(opts) {

@@ -127,2 +127,3 @@ _classCallCheck(this, WebSocketChannel);

*/
}, {

@@ -146,8 +147,9 @@ key: "write",

*/
}, {
key: "close",
value: function close() {
var cb = arguments.length <= 0 || arguments[0] === undefined ? function () {
var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
return null;
} : arguments[0];
};

@@ -161,3 +163,3 @@ this._open = false;

return WebSocketChannel;
})();
}();

@@ -167,3 +169,2 @@ var available = typeof WebSocket !== 'undefined';

exports["default"] = _websocketChannelModule;
module.exports = exports["default"];
exports.default = _websocketChannelModule;

@@ -1,40 +0,35 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Dechunker = exports.Chunker = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _buf = require('./buf');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var _buf = require('./buf');
var _buf2 = _interopRequireDefault(_buf);
var _CHUNK_HEADER_SIZE = 2,

@@ -49,4 +44,4 @@ _MESSAGE_BOUNDARY = 0x00,

var Chunker = (function (_buf$BaseBuffer) {
_inherits(Chunker, _buf$BaseBuffer);
var Chunker = function (_BaseBuffer) {
_inherits(Chunker, _BaseBuffer);

@@ -56,16 +51,12 @@ function Chunker(channel, bufferSize) {

_get(Object.getPrototypeOf(Chunker.prototype), 'constructor', this).call(this, 0);
this._bufferSize = bufferSize || _DEFAULT_BUFFER_SIZE;
this._ch = channel;
this._buffer = _buf2['default'].alloc(this._bufferSize);
this._currentChunkStart = 0;
this._chunkOpen = false;
var _this = _possibleConstructorReturn(this, (Chunker.__proto__ || Object.getPrototypeOf(Chunker)).call(this, 0));
_this._bufferSize = bufferSize || _DEFAULT_BUFFER_SIZE;
_this._ch = channel;
_this._buffer = (0, _buf.alloc)(_this._bufferSize);
_this._currentChunkStart = 0;
_this._chunkOpen = false;
return _this;
}
/**
* Combines chunks until a complete message is gathered up, and then forwards that
* message to an 'onmessage' listener.
* @access private
*/
_createClass(Chunker, [{

@@ -119,3 +110,3 @@ key: 'putUInt8',

// Alloc a new output buffer. We assume we're using NodeJS's buffer pooling under the hood here!
this._buffer = _buf2['default'].alloc(this._bufferSize);
this._buffer = (0, _buf.alloc)(this._bufferSize);
this._chunkOpen = false;

@@ -131,2 +122,3 @@ }

*/
}, {

@@ -147,2 +139,3 @@ key: 'messageBoundary',

/** Ensure at least the given size is available for writing */
}, {

@@ -174,5 +167,12 @@ key: '_ensure',

return Chunker;
})(_buf2['default'].BaseBuffer);
}(_buf.BaseBuffer);
var Dechunker = (function () {
/**
* Combines chunks until a complete message is gathered up, and then forwards that
* message to an 'onmessage' listener.
* @access private
*/
var Dechunker = function () {
function Dechunker() {

@@ -223,2 +223,3 @@ _classCallCheck(this, Dechunker);

/** Called when a complete chunk header has been recieved */

@@ -231,7 +232,7 @@

// Message boundary
var message = undefined;
var message = void 0;
if (this._currentMessage.length == 1) {
message = this._currentMessage[0];
} else {
message = new _buf2['default'].CombinedBuffer(this._currentMessage);
message = new _buf.CombinedBuffer(this._currentMessage);
}

@@ -256,8 +257,5 @@ this._currentMessage = [];

return Dechunker;
})();
}();
exports['default'] = {
Chunker: Chunker,
Dechunker: Dechunker
};
module.exports = exports['default'];
exports.Chunker = Chunker;
exports.Dechunker = Dechunker;

@@ -1,20 +0,1 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";

@@ -25,9 +6,23 @@

});
exports.Connection = exports.parseUrl = exports.parseScheme = exports.connect = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _chWebsocket = require("./ch-websocket");

@@ -43,4 +38,2 @@

var _chunking2 = _interopRequireDefault(_chunking);
var _features = require("./features");

@@ -52,21 +45,21 @@

var _packstream2 = _interopRequireDefault(_packstream);
var _buf = require("./buf");
var _graphTypes = require('../graph-types');
var _graphTypes = require("../graph-types");
var _graphTypes2 = _interopRequireDefault(_graphTypes);
var _integer = require("../integer");
var _integer = require('../integer');
var _error = require("./../error");
var _error = require('./../error');
var _util = require("./util");
var _util = require('./util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Channel = undefined;
if (_chWebsocket2["default"].available) {
Channel = _chWebsocket2["default"].channel;
} else if (_chNode2["default"].available) {
Channel = _chNode2["default"].channel;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Channel = void 0;
if (_chWebsocket2.default.available) {
Channel = _chWebsocket2.default.channel;
} else if (_chNode2.default.available) {
Channel = _chNode2.default.channel;
} else {

@@ -106,5 +99,6 @@ throw (0, _error.newError)("Fatal: No compatible transport available. Need to run on a platform with the WebSocket API.");

//sent before version negotiation
MAGIC_PREAMBLE = 0x6060B017;
MAGIC_PREAMBLE = 0x6060B017,
DEBUG = false;
var URLREGEX = new RegExp(["[^/]+//", // scheme
var URLREGEX = new RegExp(["([^/]+//)?", // scheme
"(([^:/?#]*)", // hostname

@@ -114,10 +108,33 @@ "(?::([0-9]+))?)", // port (optional)

function host(url) {
function parseScheme(url) {
var scheme = url.match(URLREGEX)[1] || '';
return scheme.toLowerCase();
}
function parseUrl(url) {
return url.match(URLREGEX)[2];
}
function port(url) {
function parseHost(url) {
return url.match(URLREGEX)[3];
}
function parsePort(url) {
return url.match(URLREGEX)[4];
}
/**
* Very rudimentary log handling, should probably be replaced by something proper at some point.
* @param actor the part that sent the message, 'S' for server and 'C' for client
* @param msg the bolt message
*/
function log(actor, msg) {
if (DEBUG) {
for (var i = 2; i < arguments.length; i++) {
msg += " " + JSON.stringify(arguments[i]);
}
console.log(actor + ":" + msg);
}
}
function NO_OP() {}

@@ -134,3 +151,3 @@

node: function node(unpacker, buf) {
return new _graphTypes2["default"].Node(unpacker.unpack(buf), // Identity
return new _graphTypes.Node(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Labels

@@ -141,3 +158,3 @@ unpacker.unpack(buf) // Properties

rel: function rel(unpacker, buf) {
return new _graphTypes2["default"].Relationship(unpacker.unpack(buf), // Identity
return new _graphTypes.Relationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Start Node Identity

@@ -150,3 +167,3 @@ unpacker.unpack(buf), // End Node Identity

unboundRel: function unboundRel(unpacker, buf) {
return new _graphTypes2["default"].UnboundRelationship(unpacker.unpack(buf), // Identity
return new _graphTypes.UnboundRelationship(unpacker.unpack(buf), // Identity
unpacker.unpack(buf), // Type

@@ -166,6 +183,6 @@ unpacker.unpack(buf) // Properties

nextNode = nodes[sequence[i + 1]],
rel = undefined;
rel = void 0;
if (relIndex > 0) {
rel = rels[relIndex - 1];
if (rel instanceof _graphTypes2["default"].UnboundRelationship) {
if (rel instanceof _graphTypes.UnboundRelationship) {
// To avoid duplication, relationships in a path do not contain

@@ -179,3 +196,3 @@ // information about their start and end nodes, that's instead

rel = rels[-relIndex - 1];
if (rel instanceof _graphTypes2["default"].UnboundRelationship) {
if (rel instanceof _graphTypes.UnboundRelationship) {
// See above

@@ -186,6 +203,6 @@ rels[-relIndex - 1] = rel = rel.bind(nextNode.identity, prevNode.identity);

// Done hydrating one path segment.
segments.push(new _graphTypes2["default"].PathSegment(prevNode, rel, nextNode));
segments.push(new _graphTypes.PathSegment(prevNode, rel, nextNode));
prevNode = nextNode;
}
return new _graphTypes2["default"].Path(nodes[0], nodes[nodes.length - 1], segments);
return new _graphTypes.Path(nodes[0], nodes[nodes.length - 1], segments);
}

@@ -208,3 +225,3 @@ };

var Connection = (function () {
var Connection = function () {

@@ -215,5 +232,5 @@ /**

* callback property
* @param url - url to connect to
*/
function Connection(channel) {
function Connection(channel, url) {
_classCallCheck(this, Connection);

@@ -226,9 +243,10 @@

*/
this.url = url;
this._pendingObservers = [];
this._currentObserver = undefined;
this._ch = channel;
this._dechunker = new _chunking2["default"].Dechunker();
this._chunker = new _chunking2["default"].Chunker(channel);
this._packer = new _packstream2["default"].Packer(this._chunker);
this._unpacker = new _packstream2["default"].Unpacker();
this._dechunker = new _chunking.Dechunker();
this._chunker = new _chunking.Chunker(channel);
this._packer = new _packstream.Packer(this._chunker);
this._unpacker = new _packstream.Unpacker();
this._isHandlingFailure = false;

@@ -298,10 +316,2 @@

/**
* Crete new connection to the provided url.
* @access private
* @param {string} url - 'neo4j'-prefixed URL to Neo4j Bolt endpoint
* @param {object} config
* @return {Connection} - New connection
*/
/**
* "Fatal" means the connection is dead. Only call this if something

@@ -315,2 +325,3 @@ * happens that cannot be recovered from. This will lead to all subscribers

_createClass(Connection, [{

@@ -338,5 +349,7 @@ key: "_handleFatalError",

case RECORD:
log("S", "RECORD", msg.fields[0]);
this._currentObserver.onNext(msg.fields[0]);
break;
case SUCCESS:
log("S", "SUCCESS", msg.fields[0]);
try {

@@ -349,2 +362,3 @@ this._currentObserver.onCompleted(msg.fields[0]);

case FAILURE:
log("S", "FAILURE", msg);
try {

@@ -379,2 +393,3 @@ this._currentObserver.onError(msg);

case IGNORED:
log("S", "IGNORED");
try {

@@ -392,2 +407,3 @@ if (this._errorMsg && this._currentObserver.onError) this._currentObserver.onError(this._errorMsg);else if (this._currentObserver.onError) this._currentObserver.onError(msg);

/** Queue an INIT-message to be sent to the database */
}, {

@@ -398,2 +414,3 @@ key: "initialize",

log("C", "INIT", clientName, token);
this._queueObserver(observer);

@@ -408,2 +425,3 @@ this._packer.packStruct(INIT, [this._packable(clientName), this._packable(token)], function (err) {

/** Queue a RUN-message to be sent to the database */
}, {

@@ -414,2 +432,3 @@ key: "run",

log("C", "RUN", statement, params);
this._queueObserver(observer);

@@ -423,2 +442,3 @@ this._packer.packStruct(RUN, [this._packable(statement), this._packable(params)], function (err) {

/** Queue a PULL_ALL-message to be sent to the database */
}, {

@@ -429,2 +449,3 @@ key: "pullAll",

log("C", "PULL_ALL");
this._queueObserver(observer);

@@ -438,2 +459,3 @@ this._packer.packStruct(PULL_ALL, [], function (err) {

/** Queue a DISCARD_ALL-message to be sent to the database */
}, {

@@ -444,2 +466,3 @@ key: "discardAll",

log("C", "DISCARD_ALL");
this._queueObserver(observer);

@@ -453,2 +476,3 @@ this._packer.packStruct(DISCARD_ALL, [], function (err) {

/** Queue a RESET-message to be sent to the database */
}, {

@@ -459,2 +483,3 @@ key: "reset",

log("C", "RESET");
this._isHandlingFailure = true;

@@ -480,2 +505,3 @@ var self = this;

/** Queue a ACK_FAILURE-message to be sent to the database */
}, {

@@ -486,2 +512,3 @@ key: "_ackFailure",

log("C", "ACK_FAILURE");
this._queueObserver(observer);

@@ -517,2 +544,3 @@ this._packer.packStruct(ACK_FAILURE, [], function (err) {

*/
}, {

@@ -525,2 +553,3 @@ key: "sync",

/** Check if this connection is in working condition */
}, {

@@ -541,2 +570,3 @@ key: "isOpen",

*/
}, {

@@ -559,24 +589,32 @@ key: "close",

return Connection;
})();
}();
/**
* Crete new connection to the provided url.
* @access private
* @param {string} url - 'neo4j'-prefixed URL to Neo4j Bolt endpoint
* @param {object} config
* @return {Connection} - New connection
*/
function connect(url) {
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var Ch = config.channel || Channel;
return new Connection(new Ch({
host: host(url),
port: port(url) || 7687,
host: parseHost(url),
port: parsePort(url) || 7687,
// Default to using ENCRYPTION_NON_LOCAL if trust-on-first-use is available
encrypted: (0, _util.shouldEncrypt)(config.encrypted, (0, _features2["default"])("trust_on_first_use") ? _util.ENCRYPTION_NON_LOCAL : _util.ENCRYPTION_OFF, host(url)),
encrypted: (0, _util.shouldEncrypt)(config.encrypted, (0, _features2.default)("trust_on_first_use") ? _util.ENCRYPTION_NON_LOCAL : _util.ENCRYPTION_OFF, parseHost(url)),
// Default to using TRUST_ON_FIRST_USE if it is available
trust: config.trust || ((0, _features2["default"])("trust_on_first_use") ? "TRUST_ON_FIRST_USE" : "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES"),
trust: config.trust || ((0, _features2.default)("trust_on_first_use") ? "TRUST_ON_FIRST_USE" : "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES"),
trustedCertificates: config.trustedCertificates || [],
knownHosts: config.knownHosts
}));
}), url);
}
exports["default"] = {
connect: connect,
Connection: Connection
};
module.exports = exports["default"];
exports.connect = connect;
exports.parseScheme = parseScheme;
exports.parseUrl = parseUrl;
exports.Connection = Connection;

@@ -0,1 +1,6 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**

@@ -23,7 +28,2 @@ * Copyright (c) 2002-2016 "Neo Technology,"

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var FEATURES = {

@@ -47,3 +47,2 @@ trust_on_first_use: function trust_on_first_use() {

exports['default'] = hasFeature;
module.exports = exports['default'];
exports.default = hasFeature;

@@ -0,1 +1,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**

@@ -20,12 +25,6 @@ * Copyright (c) 2002-2016 "Neo Technology,"

"use strict";
function debug(val) {
console.log(val);
}
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = {
"debug": function debug(val) {
console.log(val);
}
};
module.exports = exports["default"];
exports.default = debug;

@@ -1,20 +0,1 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";

@@ -25,21 +6,45 @@

});
exports.Structure = exports.Unpacker = exports.Packer = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _log = require("./log");
var _log2 = _interopRequireDefault(_log);
var _buf = require("./buf");
var _utf8 = require("./utf8");
var _utf = require("./utf8");
var _utf82 = _interopRequireDefault(_utf8);
var _utf2 = _interopRequireDefault(_utf);
var _integer = require("../integer");
var _error = require('./../error');
var _integer2 = _interopRequireDefault(_integer);
var _error = require("./../error");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var MAX_CHUNK_SIZE = 16383,

@@ -75,7 +80,6 @@ TINY_STRING = 0x80,

var Structure = (function () {
var Structure = function () {
/**
* Create new instance
*/
function Structure(signature, fields) {

@@ -88,7 +92,2 @@ _classCallCheck(this, Structure);

/**
* Class to pack
* @access private
*/
_createClass(Structure, [{

@@ -109,5 +108,11 @@ key: "toString",

return Structure;
})();
}();
var Packer = (function () {
/**
* Class to pack
* @access private
*/
var Packer = function () {
function Packer(channel) {

@@ -120,7 +125,2 @@ _classCallCheck(this, Packer);

/**
* Class to unpack
* @access private
*/
/**
* Creates a packable function out of the provided value

@@ -132,2 +132,3 @@ * @param x the value to pack

_createClass(Packer, [{

@@ -158,3 +159,3 @@ key: "packable",

};
} else if (x instanceof _integer.Integer) {
} else if (x instanceof _integer2.default) {
return function () {

@@ -178,3 +179,3 @@ return _this.packInteger(x);

};
} else if (typeof x == "object") {
} else if ((typeof x === "undefined" ? "undefined" : _typeof(x)) == "object") {
return function () {

@@ -213,2 +214,3 @@ var keys = Object.keys(x);

*/
}, {

@@ -255,3 +257,3 @@ key: "packStruct",

value: function packString(x, onError) {
var bytes = _utf82["default"].encode(x);
var bytes = _utf2.default.encode(x);
var size = bytes.length;

@@ -346,5 +348,11 @@ if (size < 0x10) {

return Packer;
})();
}();
var Unpacker = (function () {
/**
* Class to unpack
* @access private
*/
var Unpacker = function () {
function Unpacker() {

@@ -419,9 +427,9 @@ _classCallCheck(this, Unpacker);

var low = buffer.readInt32();
return new _integer.Integer(low, high);
return new _integer2.default(low, high);
} else if (marker == STRING_8) {
return _utf82["default"].decode(buffer, buffer.readUInt8());
return _utf2.default.decode(buffer, buffer.readUInt8());
} else if (marker == STRING_16) {
return _utf82["default"].decode(buffer, buffer.readUInt16());
return _utf2.default.decode(buffer, buffer.readUInt16());
} else if (marker == STRING_32) {
return _utf82["default"].decode(buffer, buffer.readUInt32());
return _utf2.default.decode(buffer, buffer.readUInt32());
} else if (marker == LIST_8) {

@@ -447,3 +455,3 @@ return this.unpackList(buffer.readUInt8(), buffer);

if (markerHigh == 0x80) {
return _utf82["default"].decode(buffer, markerLow);
return _utf2.default.decode(buffer, markerLow);
} else if (markerHigh == 0x90) {

@@ -462,9 +470,6 @@ return this.unpackList(markerLow, buffer);

return Unpacker;
})();
}();
exports["default"] = {
Packer: Packer,
Unpacker: Unpacker,
Structure: Structure
};
module.exports = exports["default"];
exports.Packer = Packer;
exports.Unpacker = Unpacker;
exports.Structure = Structure;

@@ -0,1 +1,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -20,13 +30,3 @@ * Copyright (c) 2002-2016 "Neo Technology,"

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Pool = (function () {
var Pool = function () {
/**

@@ -44,11 +44,10 @@ * @param create an allocation function that creates a new resource. It's given

*/
function Pool(create) {
var destroy = arguments.length <= 1 || arguments[1] === undefined ? function () {
var destroy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
return true;
} : arguments[1];
var validate = arguments.length <= 2 || arguments[2] === undefined ? function () {
};
var validate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
return true;
} : arguments[2];
var maxIdle = arguments.length <= 3 || arguments[3] === undefined ? 50 : arguments[3];
};
var maxIdle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 50;

@@ -61,3 +60,3 @@ _classCallCheck(this, Pool);

this._maxIdle = maxIdle;
this._pool = [];
this._pools = {};
this._release = this._release.bind(this);

@@ -68,21 +67,58 @@ }

key: "acquire",
value: function acquire() {
var resource = undefined;
while (this._pool.length) {
resource = this._pool.pop();
value: function acquire(key) {
var resource = void 0;
var pool = this._pools[key];
if (!pool) {
pool = [];
this._pools[key] = pool;
}
while (pool.length) {
resource = pool.pop();
if (this._validate(resource)) {
return resource;
} else {
this._destroy(resource);
}
}
return this._create(this._release);
return this._create(key, this._release);
}
}, {
key: "purge",
value: function purge(key) {
var resource = void 0;
var pool = this._pools[key] || [];
while (pool.length) {
resource = pool.pop();
this._destroy(resource);
}
delete this._pools[key];
}
}, {
key: "purgeAll",
value: function purgeAll() {
for (var key in this._pools.keys) {
if (this._pools.hasOwnPropertykey) {
this.purge(key);
}
}
}
}, {
key: "has",
value: function has(key) {
return key in this._pools;
}
}, {
key: "_release",
value: function _release(resource) {
if (this._pool.length >= this._maxIdle || !this._validate(resource)) {
value: function _release(key, resource) {
var pool = this._pools[key];
if (!pool) {
//key has been purged, don't put it back
return;
}
if (pool.length >= this._maxIdle || !this._validate(resource)) {
this._destroy(resource);
} else {
this._pool.push(resource);
pool.push(resource);
}

@@ -93,7 +129,4 @@ }

return Pool;
})();
}();
exports["default"] = {
Pool: Pool
};
module.exports = exports["default"];
exports.default = Pool;

@@ -1,20 +0,1 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";

@@ -26,8 +7,29 @@

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var _record = require("../record");
var _record2 = _interopRequireDefault(_record);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _record = require("../record");
/**

@@ -43,9 +45,12 @@ * Handles a RUN/PULL_ALL, or RUN/DISCARD_ALL requests, maps the responses

*/
var StreamObserver = (function () {
var StreamObserver = function () {
/**
* @constructor
* @param errorTransformer optional callback to be used for adding additional logic on error
*/
function StreamObserver() {
var errorTransformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (err) {
return err;
};
function StreamObserver() {
_classCallCheck(this, StreamObserver);

@@ -59,2 +64,3 @@

this._hasFailed = false;
this._errorTransformer = errorTransformer;
}

@@ -69,6 +75,7 @@

_createClass(StreamObserver, [{
key: "onNext",
value: function onNext(rawRecord) {
var record = new _record.Record(this._fieldKeys, rawRecord, this._fieldLookup);
var record = new _record2.default(this._fieldKeys, rawRecord, this._fieldLookup);
if (this._observer) {

@@ -105,2 +112,7 @@ this._observer.onNext(record);

}
}, {
key: "resolveConnection",
value: function resolveConnection(conn) {
this._conn = conn;
}

@@ -113,5 +125,7 @@ /**

*/
}, {
key: "onError",
value: function onError(error) {
var transformedError = this._errorTransformer(error, this._conn);
if (this._hasFailed) {

@@ -123,8 +137,8 @@ return;

if (this._observer.onError) {
this._observer.onError(error);
this._observer.onError(transformedError);
} else {
console.log(error);
console.log(transformedError);
}
} else {
this._error = error;
this._error = transformedError;
}

@@ -140,2 +154,3 @@ }

*/
}, {

@@ -161,5 +176,4 @@ key: "subscribe",

return StreamObserver;
})();
}();
exports["default"] = StreamObserver;
module.exports = exports["default"];
exports.default = StreamObserver;

@@ -1,35 +0,9 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This module defines a cross-platform UTF-8 encoder and decoder that works
// with the Buffer API defined in buf.js
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _buf = require('./buf');
var _buf = require("./buf");
var _buf2 = _interopRequireDefault(_buf);
var _string_decoder = require('string_decoder');

@@ -39,4 +13,24 @@

var platformObj = {};
var platformObj = {}; /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This module defines a cross-platform UTF-8 encoder and decoder that works
// with the Buffer API defined in buf.js
try {

@@ -51,6 +45,6 @@ (function () {

"encode": function encode(str) {
return new _buf2['default'].NodeBuffer(new node.Buffer(str, "UTF-8"));
return new _buf.NodeBuffer(new node.Buffer(str, "UTF-8"));
},
"decode": function decode(buffer, length) {
if (buffer instanceof _buf2['default'].NodeBuffer) {
if (buffer instanceof _buf.NodeBuffer) {
var start = buffer.position,

@@ -60,3 +54,3 @@ end = start + length;

return buffer._buffer.toString('utf8', start, end);
} else if (buffer instanceof _buf2['default'].CombinedBuffer) {
} else if (buffer instanceof _buf.CombinedBuffer) {
var out = streamDecodeCombinedBuffer(buffer, length, function (partBuffer) {

@@ -87,11 +81,11 @@ return decoder.write(partBuffer._buffer);

"encode": function encode(str) {
return new _buf2['default'].HeapBuffer(encoder.encode(str).buffer);
return new _buf.HeapBuffer(encoder.encode(str).buffer);
},
"decode": function decode(buffer, length) {
if (buffer instanceof _buf2['default'].HeapBuffer) {
if (buffer instanceof _buf.HeapBuffer) {
return decoder.decode(buffer.readView(Math.min(length, buffer.length - buffer.position)));
} else {
// Decoding combined buffer is complicated. For simplicity, for now,
// Decoding combined buffer is complicated. For simplicity, for now,
// we simply copy the combined buffer into a regular buffer and decode that.
var tmpBuf = _buf2['default'].alloc(length);
var tmpBuf = (0, _buf.alloc)(length);
for (var i = 0; i < length; i++) {

@@ -132,3 +126,2 @@ tmpBuf.writeUInt8(buffer.readUInt8());

exports['default'] = platformObj;
module.exports = exports['default'];
exports.default = platformObj;

@@ -0,1 +1,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**

@@ -20,7 +25,2 @@ * Copyright (c) 2002-2016 "Neo Technology,"

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var LOCALHOST_MATCHER = /^(localhost|127(\.\d+){3})$/i;

@@ -44,20 +44,7 @@ var ENCRYPTION_ON = "ENCRYPTION_ON";

*/
function shouldEncrypt(_x, _x2, _x3) {
var _again = true;
_function: while (_again) {
var encryption = _x,
encryptionDefault = _x2,
host = _x3;
_again = false;
if (encryption === ENCRYPTION_ON || encryption === true) return true;
if (encryption === ENCRYPTION_OFF || encryption === false) return false;
if (encryption === ENCRYPTION_NON_LOCAL) return !isLocalHost(host);
_x = encryptionDefault;
_x2 = ENCRYPTION_OFF;
_x3 = host;
_again = true;
continue _function;
}
function shouldEncrypt(encryption, encryptionDefault, host) {
if (encryption === ENCRYPTION_ON || encryption === true) return true;
if (encryption === ENCRYPTION_OFF || encryption === false) return false;
if (encryption === ENCRYPTION_NON_LOCAL) return !isLocalHost(host);
return shouldEncrypt(encryptionDefault, ENCRYPTION_OFF, host);
}

@@ -64,0 +51,0 @@

@@ -1,20 +0,1 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";

@@ -26,8 +7,25 @@

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var _error = require("./error");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _error = require("./error");
function generateFieldLookup(keys) {

@@ -61,3 +59,3 @@ var lookup = {};

var Record = (function () {
var Record = function () {
/**

@@ -74,5 +72,4 @@ * Create a new record object.

*/
function Record(keys, fields) {
var fieldLookup = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];
var fieldLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;

@@ -95,2 +92,3 @@ _classCallCheck(this, Record);

_createClass(Record, [{

@@ -109,2 +107,3 @@ key: "forEach",

*/
}, {

@@ -127,6 +126,7 @@ key: "toObject",

*/
}, {
key: "get",
value: function get(key) {
var index = undefined;
var index = void 0;
if (!(typeof key === "number")) {

@@ -154,2 +154,3 @@ index = this._fieldLookup[key];

*/
}, {

@@ -169,4 +170,4 @@ key: "has",

return Record;
})();
}();
exports.Record = Record;
exports.default = Record;

@@ -1,32 +0,31 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.statementType = undefined;
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _integer = require('./integer');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -36,4 +35,3 @@ * A ResultSummary instance contains structured metadata for a {Result}.

*/
var ResultSummary = (function () {
var ResultSummary = function () {
/**

@@ -45,3 +43,2 @@ * @constructor

*/
function ResultSummary(statement, parameters, metadata) {

@@ -63,7 +60,2 @@ _classCallCheck(this, ResultSummary);

/**
* Class for execution plan received by prepending Cypher with EXPLAIN.
* @access public
*/
_createClass(ResultSummary, [{

@@ -84,2 +76,3 @@ key: '_buildNotifications',

*/
}, {

@@ -95,2 +88,3 @@ key: 'hasPlan',

*/
}, {

@@ -104,4 +98,10 @@ key: 'hasProfile',

return ResultSummary;
})();
}();
/**
* Class for execution plan received by prepending Cypher with EXPLAIN.
* @access public
*/
var Plan =

@@ -122,3 +122,3 @@ /**

}) : [];
}
};

@@ -129,4 +129,4 @@ /**

*/
;
var ProfiledPlan =

@@ -149,3 +149,3 @@ /**

}) : [];
}
};

@@ -156,5 +156,5 @@ /**

*/
;
var StatementStatistics = (function () {
var StatementStatistics = function () {
/**

@@ -165,3 +165,2 @@ * Structurize the statistics

*/
function StatementStatistics(statistics) {

@@ -194,7 +193,2 @@ var _this = this;

/**
* Class for Cypher notifications
* @access public
*/
/**
* Did the database get updated?

@@ -204,2 +198,3 @@ * @return {boolean}

_createClass(StatementStatistics, [{

@@ -218,2 +213,3 @@ key: 'containsUpdates',

*/
}, {

@@ -228,2 +224,3 @@ key: 'nodesCreated',

*/
}, {

@@ -238,2 +235,3 @@ key: 'nodesDeleted',

*/
}, {

@@ -248,2 +246,3 @@ key: 'relationshipsCreated',

*/
}, {

@@ -258,2 +257,3 @@ key: 'relationshipsDeleted',

*/
}, {

@@ -268,2 +268,3 @@ key: 'propertiesSet',

*/
}, {

@@ -278,2 +279,3 @@ key: 'labelsAdded',

*/
}, {

@@ -288,2 +290,3 @@ key: 'labelsRemoved',

*/
}, {

@@ -298,2 +301,3 @@ key: 'indexesAdded',

*/
}, {

@@ -308,2 +312,3 @@ key: 'indexesRemoved',

*/
}, {

@@ -318,2 +323,3 @@ key: 'constraintsAdded',

*/
}, {

@@ -327,5 +333,11 @@ key: 'constraintsRemoved',

return StatementStatistics;
})();
}();
var Notification = (function () {
/**
* Class for Cypher notifications
* @access public
*/
var Notification = function () {
/**

@@ -336,3 +348,2 @@ * Create a Notification instance

*/
function Notification(notification) {

@@ -363,3 +374,3 @@ _classCallCheck(this, Notification);

return Notification;
})();
}();

@@ -373,6 +384,3 @@ var statementType = {

exports['default'] = {
ResultSummary: ResultSummary,
statementType: statementType
};
module.exports = exports['default'];
exports.statementType = statementType;
exports.default = ResultSummary;

@@ -1,38 +0,39 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
// Ensure Promise is available
var _resultSummary = require('./result-summary');
// Ensure Promise is available
var _resultSummary = require("./result-summary");
var _externalEs6Promise = require('../external/es6-promise');
var _resultSummary2 = _interopRequireDefault(_resultSummary);
(0, _externalEs6Promise.polyfill)();
require("babel-polyfill");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -42,4 +43,3 @@ * A stream of {@link Record} representing the result of a statement.

*/
var Result = (function () {
var Result = function () {
/**

@@ -54,3 +54,2 @@ * Inject the observer to be used.

*/
function Result(streamObserver, statement, parameters, metaSupplier) {

@@ -74,4 +73,5 @@ _classCallCheck(this, Result);

_createClass(Result, [{
key: '_createPromise',
key: "_createPromise",
value: function _createPromise() {

@@ -107,4 +107,5 @@ if (this._p) {

*/
}, {
key: 'then',
key: "then",
value: function then(onFulfilled, onRejected) {

@@ -121,7 +122,8 @@ this._createPromise();

*/
}, {
key: 'catch',
key: "catch",
value: function _catch(onRejected) {
this._createPromise();
return this._p['catch'](onRejected);
return this._p.catch(onRejected);
}

@@ -139,4 +141,5 @@

*/
}, {
key: 'subscribe',
key: "subscribe",
value: function subscribe(observer) {

@@ -155,3 +158,3 @@ var _this = this;

}
var sum = new _resultSummary.ResultSummary(_this._statement, _this._parameters, metadata);
var sum = new _resultSummary2.default(_this._statement, _this._parameters, metadata);
onCompletedOriginal.call(observer, sum);

@@ -168,5 +171,4 @@ };

return Result;
})();
}();
exports['default'] = Result;
module.exports = exports['default'];
exports.default = Result;

@@ -1,40 +0,34 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _streamObserver = require('./internal/stream-observer');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _streamObserver2 = _interopRequireDefault(_streamObserver);
var _internalStreamObserver = require('./internal/stream-observer');
var _internalStreamObserver2 = _interopRequireDefault(_internalStreamObserver);
var _result = require('./result');

@@ -48,6 +42,16 @@

var _integer = require("./integer");
var _integer = require('./integer');
var _error = require("./error");
var _integer2 = _interopRequireDefault(_integer);
var _error = require('./error');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -59,13 +63,12 @@ * A Session instance is used for handling the connection and

var Session = (function () {
var Session = function () {
/**
* @constructor
* @param {Connection} conn - A connection to use
* @param {Promise.<Connection>} connectionPromise - Promise of a connection to use
* @param {function()} onClose - Function to be called on connection close
*/
function Session(conn, onClose) {
function Session(connectionPromise, onClose) {
_classCallCheck(this, Session);
this._conn = conn;
this._connectionPromise = connectionPromise;
this._onClose = onClose;

@@ -75,36 +78,35 @@ this._hasTx = false;

/** Internal stream observer used for transactional results*/
/**
* Run Cypher statement
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
* or with the statement and parameters as separate arguments.
* @param {mixed} statement - Cypher statement to execute
* @param {Object} parameters - Map with parameters to use in statement
* @return {Result} - New Result
*/
_createClass(Session, [{
key: 'isEncrypted',
value: function isEncrypted() {
return this._conn.isEncrypted();
}
/**
* Run Cypher statement
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
* or with the statement and parameters as separate arguments.
* @param {mixed} statement - Cypher statement to execute
* @param {Object} parameters - Map with parameters to use in statement
* @return {Result} - New Result
*/
}, {
key: 'run',
value: function run(statement) {
var parameters = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (typeof statement === 'object' && statement.text) {
if ((typeof statement === 'undefined' ? 'undefined' : _typeof(statement)) === 'object' && statement.text) {
parameters = statement.parameters || {};
statement = statement.text;
}
var streamObserver = new _RunObserver();
var streamObserver = new _RunObserver(this._onRunFailure());
if (!this._hasTx) {
this._conn.run(statement, parameters, streamObserver);
this._conn.pullAll(streamObserver);
this._conn.sync();
this._connectionPromise.then(function (conn) {
streamObserver.resolveConnection(conn);
conn.run(statement, parameters, streamObserver);
conn.pullAll(streamObserver);
conn.sync();
}).catch(function (err) {
return streamObserver.onError(err);
});
} else {
streamObserver.onError((0, _error.newError)("Statements cannot be run directly on a " + "session with an open transaction; either run from within the " + "transaction or use a different session."));
}
return new _result2['default'](streamObserver, statement, parameters, function () {
return new _result2.default(streamObserver, statement, parameters, function () {
return streamObserver.meta();

@@ -122,16 +124,24 @@ });

*/
}, {
key: 'beginTransaction',
value: function beginTransaction() {
value: function beginTransaction(bookmark) {
var _this = this;
if (this._hasTx) {
throw new _error.newError("You cannot begin a transaction on a session with an " + "open transaction; either run from within the transaction or use a " + "different session.");
throw (0, _error.newError)("You cannot begin a transaction on a session with an " + "open transaction; either run from within the transaction or use a " + "different session.");
}
this._hasTx = true;
return new _transaction2['default'](this._conn, function () {
return new _transaction2.default(this._connectionPromise, function () {
_this._hasTx = false;
}, this._onRunFailure(), bookmark, function (bookmark) {
_this._lastBookmark = bookmark;
});
}
}, {
key: 'lastBookmark',
value: function lastBookmark() {
return this._lastBookmark;
}

@@ -143,8 +153,9 @@ /**

*/
}, {
key: 'close',
value: function close() {
var cb = arguments.length <= 0 || arguments[0] === undefined ? function () {
var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
return null;
} : arguments[0];
};

@@ -161,15 +172,30 @@ if (this._onClose) {

}
//Can be overridden to add error callback on RUN
}, {
key: '_onRunFailure',
value: function _onRunFailure() {
return function (err) {
return err;
};
}
}]);
return Session;
})();
}();
var _RunObserver = (function (_StreamObserver) {
/** Internal stream observer used for transactional results*/
var _RunObserver = function (_StreamObserver) {
_inherits(_RunObserver, _StreamObserver);
function _RunObserver() {
function _RunObserver(onError) {
_classCallCheck(this, _RunObserver);
_get(Object.getPrototypeOf(_RunObserver.prototype), 'constructor', this).call(this);
this._meta = {};
var _this2 = _possibleConstructorReturn(this, (_RunObserver.__proto__ || Object.getPrototypeOf(_RunObserver)).call(this, onError));
_this2._meta = {};
return _this2;
}

@@ -180,3 +206,3 @@

value: function onCompleted(meta) {
_get(Object.getPrototypeOf(_RunObserver.prototype), 'onCompleted', this).call(this, meta);
_get(_RunObserver.prototype.__proto__ || Object.getPrototypeOf(_RunObserver.prototype), 'onCompleted', this).call(this, meta);
for (var key in meta) {

@@ -196,5 +222,4 @@ if (meta.hasOwnProperty(key)) {

return _RunObserver;
})(_internalStreamObserver2['default']);
}(_streamObserver2.default);
exports['default'] = Session;
module.exports = exports['default'];
exports.default = Session;

@@ -1,39 +0,35 @@

/**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _streamObserver = require('./internal/stream-observer');
var _internalStreamObserver = require('./internal/stream-observer');
var _streamObserver2 = _interopRequireDefault(_streamObserver);
var _internalStreamObserver2 = _interopRequireDefault(_internalStreamObserver);
var _result = require('./result');

@@ -43,2 +39,10 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -49,27 +53,35 @@ * Represents a transaction in the Neo4j database.

*/
var Transaction = (function () {
var Transaction = function () {
/**
* @constructor
* @param {Connection} conn - A connection to use
* @param {Promise} connectionPromise - A connection to use
* @param {function()} onClose - Function to be called when transaction is committed or rolled back.
* @param errorTransformer callback use to transform error
* @param bookmark optional bookmark
*/
function Transaction(conn, onClose) {
function Transaction(connectionPromise, onClose, errorTransformer, bookmark, onBookmark) {
_classCallCheck(this, Transaction);
this._conn = conn;
this._connectionPromise = connectionPromise;
var streamObserver = new _TransactionStreamObserver(this);
this._conn.run("BEGIN", {}, streamObserver);
this._conn.discardAll(streamObserver);
var params = {};
if (bookmark) {
params = { bookmark: bookmark };
}
this._connectionPromise.then(function (conn) {
streamObserver.resolveConnection(conn);
conn.run("BEGIN", params, streamObserver);
conn.discardAll(streamObserver);
}).catch(streamObserver.onError);
this._state = _states.ACTIVE;
this._onClose = onClose;
this._errorTransformer = errorTransformer;
this._onBookmark = onBookmark || function () {};
}
/** Internal stream observer used for transactional results*/
/**
* Run Cypher statement
* Could be called with a statement object i.e.: {statement: "MATCH ...", parameters: {param: 1}}
* or with the statem ent and parameters as separate arguments.
* or with the statement and parameters as separate arguments.
* @param {mixed} statement - Cypher statement to execute

@@ -80,10 +92,11 @@ * @param {Object} parameters - Map with parameters to use in statement

_createClass(Transaction, [{
key: 'run',
value: function run(statement, parameters) {
if (typeof statement === 'object' && statement.text) {
if ((typeof statement === 'undefined' ? 'undefined' : _typeof(statement)) === 'object' && statement.text) {
parameters = statement.parameters || {};
statement = statement.text;
}
return this._state.run(this._conn, new _TransactionStreamObserver(this), statement, parameters);
return this._state.run(this._connectionPromise, new _TransactionStreamObserver(this), statement, parameters);
}

@@ -98,6 +111,7 @@

*/
}, {
key: 'commit',
value: function commit() {
var committed = this._state.commit(this._conn, new _TransactionStreamObserver(this));
var committed = this._state.commit(this._connectionPromise, new _TransactionStreamObserver(this));
this._state = committed.state;

@@ -116,6 +130,7 @@ //clean up

*/
}, {
key: 'rollback',
value: function rollback() {
var committed = this._state.rollback(this._conn, new _TransactionStreamObserver(this));
var committed = this._state.rollback(this._connectionPromise, new _TransactionStreamObserver(this));
this._state = committed.state;

@@ -135,5 +150,8 @@ //clean up

return Transaction;
})();
}();
var _TransactionStreamObserver = (function (_StreamObserver) {
/** Internal stream observer used for transactional results*/
var _TransactionStreamObserver = function (_StreamObserver) {
_inherits(_TransactionStreamObserver, _StreamObserver);

@@ -144,10 +162,12 @@

_get(Object.getPrototypeOf(_TransactionStreamObserver.prototype), 'constructor', this).call(this);
this._tx = tx;
var _this = _possibleConstructorReturn(this, (_TransactionStreamObserver.__proto__ || Object.getPrototypeOf(_TransactionStreamObserver)).call(this, tx._errorTransformer || function (err) {
return err;
}));
_this._tx = tx;
//this is to to avoid multiple calls to onError caused by IGNORED
this._hasFailed = false;
_this._hasFailed = false;
return _this;
}
/** internal state machine of the transaction*/
_createClass(_TransactionStreamObserver, [{

@@ -158,26 +178,42 @@ key: 'onError',

this._tx._onError();
_get(Object.getPrototypeOf(_TransactionStreamObserver.prototype), 'onError', this).call(this, error);
_get(_TransactionStreamObserver.prototype.__proto__ || Object.getPrototypeOf(_TransactionStreamObserver.prototype), 'onError', this).call(this, error);
this._hasFailed = true;
}
}
}, {
key: 'onCompleted',
value: function onCompleted(meta) {
_get(_TransactionStreamObserver.prototype.__proto__ || Object.getPrototypeOf(_TransactionStreamObserver.prototype), 'onCompleted', this).call(this, meta);
var bookmark = meta.bookmark;
if (bookmark) {
this._tx._onBookmark(bookmark);
}
}
}]);
return _TransactionStreamObserver;
})(_internalStreamObserver2['default']);
}(_streamObserver2.default);
/** internal state machine of the transaction*/
var _states = {
//The transaction is running with no explicit success or failure marked
ACTIVE: {
commit: function commit(conn, observer) {
return { result: _runDiscardAll("COMMIT", conn, observer),
commit: function commit(connectionPromise, observer) {
return { result: _runDiscardAll("COMMIT", connectionPromise, observer),
state: _states.SUCCEEDED };
},
rollback: function rollback(conn, observer) {
return { result: _runDiscardAll("ROLLBACK", conn, observer), state: _states.ROLLED_BACK };
rollback: function rollback(connectionPromise, observer) {
return { result: _runDiscardAll("ROLLBACK", connectionPromise, observer), state: _states.ROLLED_BACK };
},
run: function run(conn, observer, statement, parameters) {
conn.run(statement, parameters || {}, observer);
conn.pullAll(observer);
conn.sync();
return new _result2['default'](observer, statement, parameters);
run: function run(connectionPromise, observer, statement, parameters) {
connectionPromise.then(function (conn) {
observer.resolveConnection(conn);
conn.run(statement, parameters || {}, observer);
conn.pullAll(observer);
conn.sync();
}).catch(observer.onError);
return new _result2.default(observer, statement, parameters);
}

@@ -193,11 +229,11 @@ },

});
return { result: new _result2['default'](observer, "COMMIT", {}), state: _states.FAILED };
return { result: new _result2.default(observer, "COMMIT", {}), state: _states.FAILED };
},
rollback: function rollback(conn, observer) {
observer.onError({ error: "Cannot rollback transaction, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
return { result: new _result2['default'](observer, "ROLLBACK", {}), state: _states.FAILED };
return { result: new _result2.default(observer, "ROLLBACK", {}), state: _states.FAILED };
},
run: function run(conn, observer, statement, parameters) {
observer.onError({ error: "Cannot run statement, because previous statements in the " + "transaction has failed and the transaction has already been rolled back." });
return new _result2['default'](observer, statement, parameters);
return new _result2.default(observer, statement, parameters);
}

@@ -212,11 +248,11 @@ },

});
return { result: new _result2['default'](observer, "COMMIT", {}), state: _states.SUCCEEDED };
return { result: new _result2.default(observer, "COMMIT", {}), state: _states.SUCCEEDED };
},
rollback: function rollback(conn, observer) {
observer.onError({ error: "Cannot rollback transaction, because transaction has already been successfully closed." });
return { result: new _result2['default'](observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
return { result: new _result2.default(observer, "ROLLBACK", {}), state: _states.SUCCEEDED };
},
run: function run(conn, observer, statement, parameters) {
observer.onError({ error: "Cannot run statement, because transaction has already been successfully closed." });
return new _result2['default'](observer, statement, parameters);
return new _result2.default(observer, statement, parameters);
}

@@ -231,11 +267,11 @@ },

});
return { result: new _result2['default'](observer, "COMMIT", {}), state: _states.ROLLED_BACK };
return { result: new _result2.default(observer, "COMMIT", {}), state: _states.ROLLED_BACK };
},
rollback: function rollback(conn, observer) {
observer.onError({ error: "Cannot rollback transaction, because transaction has already been rolled back." });
return { result: new _result2['default'](observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
return { result: new _result2.default(observer, "ROLLBACK", {}), state: _states.ROLLED_BACK };
},
run: function run(conn, observer, statement, parameters) {
observer.onError({ error: "Cannot run statement, because transaction has already been rolled back." });
return new _result2['default'](observer, statement, parameters);
return new _result2.default(observer, statement, parameters);
}

@@ -245,10 +281,13 @@ }

function _runDiscardAll(msg, conn, observer) {
conn.run(msg, {}, observer);
conn.discardAll(observer);
conn.sync();
return new _result2['default'](observer, msg, {});
function _runDiscardAll(msg, connectionPromise, observer) {
connectionPromise.then(function (conn) {
observer.resolveConnection(conn);
conn.run(msg, {}, observer);
conn.discardAll(observer);
conn.sync();
}).catch(observer.onError);
return new _result2.default(observer, msg, {});
}
exports['default'] = Transaction;
module.exports = exports['default'];
exports.default = Transaction;

@@ -0,1 +1,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**

@@ -27,8 +32,2 @@ * Copyright (c) 2002-2016 "Neo Technology,"

// system to control version names at packaging time.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = { VERSION: "0.0.0-dev" };
module.exports = exports["default"];
exports.default = { VERSION: "0.0.0-dev" };
{
"name": "neo4j-driver",
"version": "1.1.0-M02",
"version": "1.1.0-M03",
"description": "Connect to Neo4j 3.1.0 and up from JavaScript",

@@ -13,2 +13,3 @@ "author": "Neo Technology Inc.",

"test": "gulp test",
"boltkit": "gulp test-boltkit",
"build": "gulp all",

@@ -22,5 +23,8 @@ "start-neo4j": "gulp start-neo4j",

"devDependencies": {
"babel": "^5.8.23",
"babelify": "^6.3.0",
"browserify": "^11.0.0",
"babel-core": "^6.17.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.16.0",
"babel-preset-stage-3": "^6.17.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0",
"esdoc": "^0.4.0",

@@ -30,3 +34,3 @@ "esdoc-importpath-plugin": "0.0.1",

"gulp": "^3.9.1",
"gulp-babel": "^5.2.1",
"gulp-babel": "^6.1.2",
"gulp-batch": "^1.0.5",

@@ -33,0 +37,0 @@ "gulp-concat": "^2.6.0",

@@ -141,4 +141,4 @@ # Neo4j Driver for Javascript

However, Javascript can only safely represent integers between `-(2`<sup>`53`</sup>` - 1)` and `(2`<sup>`53`</sup>` - 1)`.
In order to support the full Neo4j type system, the driver includes an explicit Integer types.
Any time the driver recieves an Integer value from Neo4j, it will be represented with the Integer type by the driver.
In order to support the full Neo4j type system, the driver will not automatically convert to javascript integers.
Any time the driver receives an integer value from Neo4j, it will be represented with an internal integer type by the driver.

@@ -162,17 +162,20 @@ ### Write integers

### Read integers
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert Integer instances to JavaScript numbers if you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size:
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber`, and `neo4j.integer.toString`.
```javascript
var aSmallInteger = neo4j.int(123);
var aNumber = aSmallInteger.toNumber();
if (neo4j.integer.inSafeRange(aSmallInteger)) {
var aNumber = aSmallInteger.toNumber();
}
```
If you will be handling integers larger than that, you can use the Integer instances directly, or convert them to strings:
If you will be handling integers larger than that, you can should convert them to strings:
```javascript
var aLargerInteger = neo4j.int("9223372036854775807");
var integerAsString = aLargerInteger.toString();
if (!neo4j.integer.inSafeRange(aSmallInteger)) {
var integerAsString = aLargerInteger.toString();
}
```
To help you work with Integers, the Integer class exposes a large set of arithmetic methods.
Refer to the [Integer API docs](http://neo4j.com/docs/api/javascript-driver/current/class/src/v1/integer.js~Integer.html) for details.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc