Skip to content

Commit

Permalink
JS driver v1.3.0-beta01: Checking in transpiled files for bower
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed Apr 28, 2017
1 parent fa2ce28 commit 8f9e279
Show file tree
Hide file tree
Showing 20 changed files with 12,215 additions and 4,756 deletions.
2,030 changes: 1,299 additions & 731 deletions lib/browser/neo4j-web.js

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions lib/browser/neo4j-web.min.js

Large diffs are not rendered by default.

13,629 changes: 9,925 additions & 3,704 deletions lib/browser/neo4j-web.test.js

Large diffs are not rendered by default.

40 changes: 33 additions & 7 deletions lib/v1/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ var Driver = function () {
this._token = token;
this._config = config;
this._pool = new _pool2.default(this._createConnection.bind(this), this._destroyConnection.bind(this), Driver._validateConnection.bind(this), config.connectionPoolSize);
this._connectionProvider = this._createConnectionProvider(url, this._pool, this._driverOnErrorCallback.bind(this));

/**
* Reference to the connection provider. Initialized lazily by {@link _getOrCreateConnectionProvider}.
* @type {ConnectionProvider}
* @private
*/
this._connectionProvider = null;
}

/**
Expand All @@ -117,7 +123,7 @@ var Driver = function () {
key: '_createConnection',
value: function _createConnection(url, release) {
var sessionId = this._sessionIdGenerator++;
var conn = (0, _connector.connect)(url, this._config);
var conn = (0, _connector.connect)(url, this._config, this._connectionErrorCode());
var streamObserver = new _ConnectionStreamObserver(this, conn);
conn.initialize(this._userAgent, this._token, streamObserver);
conn._id = sessionId;
Expand Down Expand Up @@ -170,24 +176,43 @@ var Driver = function () {
key: 'session',
value: function session(mode, bookmark) {
var sessionMode = Driver._validateSessionMode(mode);
return this._createSession(sessionMode, this._connectionProvider, bookmark, this._config);
var connectionProvider = this._getOrCreateConnectionProvider();
return this._createSession(sessionMode, connectionProvider, bookmark, this._config);
}
}, {
key: '_createConnectionProvider',


//Extension point
// Extension point
value: function _createConnectionProvider(address, connectionPool, driverOnErrorCallback) {
return new _connectionProviders.DirectConnectionProvider(address, connectionPool, driverOnErrorCallback);
}

//Extension point
// Extension point

}, {
key: '_createSession',
value: function _createSession(mode, connectionProvider, bookmark, config) {
return new _session2.default(mode, connectionProvider, bookmark, config);
}

// Extension point

}, {
key: '_connectionErrorCode',
value: function _connectionErrorCode() {
// connection errors might result in different error codes depending on the driver
return _error.SERVICE_UNAVAILABLE;
}
}, {
key: '_getOrCreateConnectionProvider',
value: function _getOrCreateConnectionProvider() {
if (!this._connectionProvider) {
var driverOnErrorCallback = this._driverOnErrorCallback.bind(this);
this._connectionProvider = this._createConnectionProvider(this._url, this._pool, driverOnErrorCallback);
}
return this._connectionProvider;
}
}, {
key: '_driverOnErrorCallback',
value: function _driverOnErrorCallback(error) {
Expand Down Expand Up @@ -267,8 +292,9 @@ var _ConnectionStreamObserver = function (_StreamObserver) {
if (this._driver.onCompleted) {
this._driver.onCompleted(message);
}
if (this._conn && message && message.server) {
this._conn.setServerVersion(message.server);

if (this._observer && this._observer.onComplete) {
this._observer.onCompleted(message);
}
}
}]);
Expand Down
74 changes: 43 additions & 31 deletions lib/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,51 +33,59 @@ var _version = require('../version');

var _version2 = _interopRequireDefault(_version);

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

var _util = require('./internal/util');

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

/**
* Copyright (c) 2002-2017 "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 auth = {
basic: function basic(username, password) {
var realm = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;

if (realm) {
return { scheme: "basic", principal: username, credentials: password, realm: realm };
return { scheme: 'basic', principal: username, credentials: password, realm: realm };
} else {
return { scheme: "basic", principal: username, credentials: password };
return { scheme: 'basic', principal: username, credentials: password };
}
},
kerberos: function kerberos(base64EncodedTicket) {
return {
scheme: 'kerberos',
principal: '', // This empty string is required for backwards compatibility.
credentials: base64EncodedTicket
};
},
custom: function custom(principal, credentials, realm, scheme) {
var parameters = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;

if (parameters) {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm,
parameters: parameters };
return {
scheme: scheme, principal: principal, credentials: credentials, realm: realm,
parameters: parameters
};
} else {
return { scheme: scheme, principal: principal, credentials: credentials, realm: realm };
}
}
}; /**
* Copyright (c) 2002-2017 "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 USER_AGENT = "neo4j-javascript/" + _version2.default;

/**
Expand Down Expand Up @@ -152,13 +160,17 @@ function driver(url, authToken) {
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

(0, _util.assertString)(url, 'Bolt URL');
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);
var scheme = (0, _util.parseScheme)(url);
var routingContext = (0, _util.parseRoutingContext)(url);
if (scheme === 'bolt+routing://') {
return new _routingDriver2.default((0, _util.parseUrl)(url), routingContext, USER_AGENT, authToken, config);
} else if (scheme === 'bolt://') {
if (!(0, _util.isEmptyObjectOrNull)(routingContext)) {
throw new Error('Parameters are not supported with scheme \'bolt\'. Given URL: \'' + url + '\'');
}
return new _driver.Driver((0, _util.parseUrl)(url), USER_AGENT, authToken, config);
} else {
throw new Error("Unknown scheme: " + scheme);
throw new Error('Unknown scheme: ' + scheme);
}
}

Expand Down
87 changes: 87 additions & 0 deletions lib/v1/internal/ch-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _features = require('./features');

var _features2 = _interopRequireDefault(_features);

var _error = require('../error');

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

/**
* Copyright (c) 2002-2017 "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 ChannelConfig = function () {
function ChannelConfig(host, port, driverConfig, connectionErrorCode) {
(0, _classCallCheck3.default)(this, ChannelConfig);

this.host = host;
this.port = port;
this.encrypted = ChannelConfig._extractEncrypted(driverConfig);
this.trust = ChannelConfig._extractTrust(driverConfig);
this.trustedCertificates = ChannelConfig._extractTrustedCertificates(driverConfig);
this.knownHostsPath = ChannelConfig._extractKnownHostsPath(driverConfig);
this.connectionErrorCode = connectionErrorCode || _error.SERVICE_UNAVAILABLE;
}

(0, _createClass3.default)(ChannelConfig, null, [{
key: '_extractEncrypted',
value: function _extractEncrypted(driverConfig) {
// check if encryption was configured by the user, use explicit null check because we permit boolean value
var encryptionConfigured = driverConfig.encrypted == null;
// default to using encryption if trust-all-certificates is available
return encryptionConfigured ? (0, _features2.default)('trust_all_certificates') : driverConfig.encrypted;
}
}, {
key: '_extractTrust',
value: function _extractTrust(driverConfig) {
if (driverConfig.trust) {
return driverConfig.trust;
}
// default to using TRUST_ALL_CERTIFICATES if it is available
return (0, _features2.default)('trust_all_certificates') ? 'TRUST_ALL_CERTIFICATES' : 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES';
}
}, {
key: '_extractTrustedCertificates',
value: function _extractTrustedCertificates(driverConfig) {
return driverConfig.trustedCertificates || [];
}
}, {
key: '_extractKnownHostsPath',
value: function _extractKnownHostsPath(driverConfig) {
return driverConfig.knownHosts || null;
}
}]);
return ChannelConfig;
}();

exports.default = ChannelConfig;
;
7 changes: 6 additions & 1 deletion lib/v1/internal/ch-dummy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ var observer = {
*/

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

/**
* @constructor
* @param {ChannelConfig} config - configuration for the new channel.
*/
function DummyChannel(config) {
(0, _classCallCheck3.default)(this, DummyChannel);

this.written = [];
Expand Down
Loading

0 comments on commit 8f9e279

Please sign in to comment.