neo4j-driver-core
Advanced tools
Comparing version 3.4.0-alpha01 to 3.8.0
@@ -58,2 +58,7 @@ "use strict"; | ||
}, | ||
none: function () { | ||
return { | ||
scheme: 'none' | ||
}; | ||
}, | ||
custom: function (principal, credentials, realm, scheme, parameters) { | ||
@@ -60,0 +65,0 @@ var output = { |
@@ -98,3 +98,2 @@ "use strict"; | ||
* @since 5.0 | ||
* @experimental | ||
*/ | ||
@@ -145,3 +144,2 @@ var BookmarkManager = /** @class */ (function () { | ||
* @since 5.0 | ||
* @experimental | ||
* @property {Iterable<string>} [initialBookmarks] Defines the initial set of bookmarks. The key is the database name and the values are the bookmarks. | ||
@@ -155,3 +153,2 @@ * @property {function():Promise<Iterable<string>>} [bookmarksSupplier] Called for supplying extra bookmarks to the BookmarkManager | ||
* @since 5.0 | ||
* @experimental | ||
* @param {BookmarkManagerConfig} [config={}] | ||
@@ -158,0 +155,0 @@ * @returns {BookmarkManager} |
@@ -23,3 +23,3 @@ "use strict"; | ||
/** | ||
* Inteface define a common way to acquire a connection | ||
* Interface define a common way to acquire a connection | ||
* | ||
@@ -46,2 +46,3 @@ * @private | ||
* @property {function (databaseName:string?)} param.onDatabaseNameResolved - Callback called when the database name get resolved | ||
* @returns {Promise<Connection>} | ||
*/ | ||
@@ -79,2 +80,11 @@ ConnectionProvider.prototype.acquireConnection = function (param) { | ||
/** | ||
* This method checks whether the driver session re-auth functionality | ||
* by checking protocol handshake result | ||
* | ||
* @returns {Promise<boolean>} | ||
*/ | ||
ConnectionProvider.prototype.supportsSessionAuth = function () { | ||
throw Error('Not implemented'); | ||
}; | ||
/** | ||
* This method verifies the connectivity of the database by trying to acquire a connection | ||
@@ -93,2 +103,17 @@ * for each server available in the cluster. | ||
/** | ||
* This method verifies the authorization credentials work by trying to acquire a connection | ||
* to one of the servers with the given credentials. | ||
* | ||
* @param {object} param - object parameter | ||
* @property {AuthToken} param.auth - the target auth for the to-be-acquired connection | ||
* @property {string} param.database - the target database for the to-be-acquired connection | ||
* @property {string} param.accessMode - the access mode for the to-be-acquired connection | ||
* | ||
* @returns {Promise<boolean>} promise resolved with true if succeed, false if failed with | ||
* authentication issue and rejected with error if non-authentication error happens. | ||
*/ | ||
ConnectionProvider.prototype.verifyAuthentication = function (param) { | ||
throw Error('Not implemented'); | ||
}; | ||
/** | ||
* Returns the protocol version negotiated via handshake. | ||
@@ -95,0 +120,0 @@ * |
@@ -50,2 +50,12 @@ "use strict"; | ||
}); | ||
Object.defineProperty(Connection.prototype, "authToken", { | ||
/** | ||
* @property {object} authToken The auth registered in the connection | ||
*/ | ||
get: function () { | ||
return {}; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Connection.prototype, "address", { | ||
@@ -71,2 +81,12 @@ /** | ||
}); | ||
Object.defineProperty(Connection.prototype, "supportsReAuth", { | ||
/** | ||
* @property {boolean} supportsReAuth Indicates the connection supports re-auth | ||
*/ | ||
get: function () { | ||
return false; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
@@ -73,0 +93,0 @@ * @returns {boolean} whether this connection is in a working condition |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -6,3 +42,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SessionConfig = exports.WRITE = exports.READ = exports.Driver = void 0; | ||
exports.QueryConfig = exports.SessionConfig = exports.routing = exports.WRITE = exports.READ = exports.Driver = void 0; | ||
var bookmarks_1 = require("./internal/bookmarks"); | ||
@@ -14,2 +50,6 @@ var configured_custom_resolver_1 = __importDefault(require("./internal/resolver/configured-custom-resolver")); | ||
var util_1 = require("./internal/util"); | ||
var bookmark_manager_1 = require("./bookmark-manager"); | ||
var result_transformers_1 = __importDefault(require("./result-transformers")); | ||
var query_executor_1 = __importDefault(require("./internal/query-executor")); | ||
var error_1 = require("./error"); | ||
var DEFAULT_MAX_CONNECTION_LIFETIME = 60 * 60 * 1000; // 1 hour | ||
@@ -110,2 +150,17 @@ /** | ||
/** | ||
* The {@link AuthToken} which will be used for the duration of the session. | ||
* | ||
* By default, the session will use connections authenticated with {@link AuthToken} configured in the | ||
* driver creation. This configuration allows switch user and/or authorization information for the | ||
* session lifetime. | ||
* | ||
* **Warning**: This option is only enable when the driver is connected with Neo4j Database servers | ||
* which supports Bolt 5.1 and onwards. | ||
* | ||
* @type {AuthToken|undefined} | ||
* @experimental Exposed as preview feature. | ||
* @see {@link driver} | ||
*/ | ||
this.auth = undefined; | ||
/** | ||
* The record fetch size of each batch of this session. | ||
@@ -152,3 +207,2 @@ * | ||
* | ||
* @experimental | ||
* @type {BookmarkManager|undefined} | ||
@@ -158,2 +212,65 @@ * @since 5.0 | ||
this.bookmarkManager = undefined; | ||
/** | ||
* Configure filter for {@link Notification} objects returned in {@link ResultSummary#notifications}. | ||
* | ||
* This configuration enables filter notifications by: | ||
* | ||
* * the minimum severity level ({@link NotificationFilterMinimumSeverityLevel}) | ||
* * disabling notification categories ({@link NotificationFilterDisabledCategory}) | ||
* | ||
* | ||
* Disabling notifications can be done by defining the minimum severity level to 'OFF'. | ||
* Default values can be use by omitting the configuration. | ||
* | ||
* @example | ||
* // enabling warning notification, but disabling `HINT` and `DEPRECATION` notifications. | ||
* const session = driver.session({ | ||
* database: 'neo4j', | ||
* notificationFilter: { | ||
* minimumSeverityLevel: neo4j.notificationFilterMinimumSeverityLevel.WARNING, // or 'WARNING | ||
* disabledCategories: [ | ||
* neo4j.notificationFilterDisabledCategory.HINT, // or 'HINT' | ||
* neo4j.notificationFilterDisabledCategory.DEPRECATION // or 'DEPRECATION' | ||
* ] | ||
* } | ||
* }) | ||
* | ||
* @example | ||
* // disabling notifications for a session | ||
* const session = driver.session({ | ||
* database: 'neo4j', | ||
* notificationFilter: { | ||
* minimumSeverityLevel: neo4j.notificationFilterMinimumSeverityLevel.OFF // or 'OFF' | ||
* } | ||
* }) | ||
* | ||
* @example | ||
* // using default values configured in the driver | ||
* const sessionWithDefaultValues = driver.session({ database: 'neo4j' }) | ||
* // or driver.session({ database: 'neo4j', notificationFilter: undefined }) | ||
* | ||
* // using default minimum severity level, but disabling 'HINT' and 'UNRECOGNIZED' | ||
* // notification categories | ||
* const sessionWithDefaultSeverityLevel = driver.session({ | ||
* database: 'neo4j', | ||
* notificationFilter: { | ||
* disabledCategories: [ | ||
* neo4j.notificationFilterDisabledCategory.HINT, // or 'HINT' | ||
* neo4j.notificationFilterDisabledCategory.UNRECOGNIZED // or 'UNRECOGNIZED' | ||
* ] | ||
* } | ||
* }) | ||
* | ||
* // using default disabled categories, but configuring minimum severity level to 'WARNING' | ||
* const sessionWithDefaultSeverityLevel = driver.session({ | ||
* database: 'neo4j', | ||
* notificationFilter: { | ||
* minimumSeverityLevel: neo4j.notificationFilterMinimumSeverityLevel.WARNING // or 'WARNING' | ||
* } | ||
* }) | ||
* | ||
* @type {NotificationFilter|undefined} | ||
* @since 5.7 | ||
*/ | ||
this.notificationFilter = undefined; | ||
} | ||
@@ -163,3 +280,72 @@ return SessionConfig; | ||
exports.SessionConfig = SessionConfig; | ||
var ROUTING_WRITE = 'WRITE'; | ||
var ROUTING_READ = 'READ'; | ||
/** | ||
* @typedef {'WRITE'|'READ'} RoutingControl | ||
*/ | ||
/** | ||
* Constants that represents routing modes. | ||
* | ||
* @example | ||
* driver.executeQuery("<QUERY>", <PARAMETERS>, { routing: neo4j.routing.WRITE }) | ||
*/ | ||
var routing = { | ||
WRITE: ROUTING_WRITE, | ||
READ: ROUTING_READ | ||
}; | ||
exports.routing = routing; | ||
Object.freeze(routing); | ||
/** | ||
* The query configuration | ||
* @interface | ||
*/ | ||
var QueryConfig = /** @class */ (function () { | ||
/** | ||
* @constructor | ||
* @private | ||
*/ | ||
function QueryConfig() { | ||
/** | ||
* Define the type of cluster member the query will be routed to. | ||
* | ||
* @type {RoutingControl} | ||
*/ | ||
this.routing = routing.WRITE; | ||
/** | ||
* Define the transformation will be applied to the Result before return from the | ||
* query method. | ||
* | ||
* @type {ResultTransformer} | ||
* @see {@link resultTransformers} for provided implementations. | ||
*/ | ||
this.resultTransformer = undefined; | ||
/** | ||
* The database this session will operate on. | ||
* | ||
* @type {string|undefined} | ||
*/ | ||
this.database = ''; | ||
/** | ||
* The username which the user wants to impersonate for the duration of the query. | ||
* | ||
* @type {string|undefined} | ||
*/ | ||
this.impersonatedUser = undefined; | ||
/** | ||
* Configure a BookmarkManager for the session to use | ||
* | ||
* A BookmarkManager is a piece of software responsible for keeping casual consistency between different pieces of work by sharing bookmarks | ||
* between the them. | ||
* | ||
* By default, it uses the driver's non mutable driver level bookmark manager. See, {@link Driver.executeQueryBookmarkManager} | ||
* | ||
* Can be set to null to disable causal chaining. | ||
* @type {BookmarkManager|null} | ||
*/ | ||
this.bookmarkManager = undefined; | ||
} | ||
return QueryConfig; | ||
}()); | ||
exports.QueryConfig = QueryConfig; | ||
/** | ||
* A driver maintains one or more {@link Session}s with a remote | ||
@@ -181,8 +367,9 @@ * Neo4j instance. Through the {@link Session}s you can send queries | ||
* @param {Object} config | ||
* @param {function(id: number, config:Object, log:Logger, hostNameResolver: ConfiguredCustomResolver): ConnectionProvider } createConnectonProvider Creates the connection provider | ||
* @param {function(id: number, config:Object, log:Logger, hostNameResolver: ConfiguredCustomResolver): ConnectionProvider } createConnectionProvider Creates the connection provider | ||
* @param {function(args): Session } createSession Creates the a session | ||
*/ | ||
function Driver(meta, config, createConnectonProvider, createSession) { | ||
function Driver(meta, config, createConnectionProvider, createSession, createQueryExecutor) { | ||
if (config === void 0) { config = {}; } | ||
if (createSession === void 0) { createSession = function (args) { return new session_1.default(args); }; } | ||
if (createQueryExecutor === void 0) { createQueryExecutor = function (createQuery) { return new query_executor_1.default(createQuery); }; } | ||
sanitizeConfig(config); | ||
@@ -195,4 +382,6 @@ var log = logger_1.Logger.create(config); | ||
this._log = log; | ||
this._createConnectionProvider = createConnectonProvider; | ||
this._createConnectionProvider = createConnectionProvider; | ||
this._createSession = createSession; | ||
this._defaultExecuteQueryBookmarkManager = (0, bookmark_manager_1.bookmarkManager)(); | ||
this._queryExecutor = createQueryExecutor(this.session.bind(this)); | ||
/** | ||
@@ -206,3 +395,117 @@ * Reference to the connection provider. Initialized lazily by {@link _getOrCreateConnectionProvider}. | ||
} | ||
Object.defineProperty(Driver.prototype, "executeQueryBookmarkManager", { | ||
/** | ||
* The bookmark managed used by {@link Driver.executeQuery} | ||
* | ||
* @type {BookmarkManager} | ||
*/ | ||
get: function () { | ||
return this._defaultExecuteQueryBookmarkManager; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* Executes a query in a retriable context and returns a {@link EagerResult}. | ||
* | ||
* This method is a shortcut for a {@link Session#executeRead} and {@link Session#executeWrite}. | ||
* | ||
* NOTE: Because it is an explicit transaction from the server point of view, Cypher queries using | ||
* "CALL {} IN TRANSACTIONS" or the older "USING PERIODIC COMMIT" construct will not work (call | ||
* {@link Session#run} for these). | ||
* | ||
* @example | ||
* // Run a simple write query | ||
* const { keys, records, summary } = await driver.executeQuery('CREATE (p:Person{ name: $name }) RETURN p', { name: 'Person1'}) | ||
* | ||
* @example | ||
* // Run a read query | ||
* const { keys, records, summary } = await driver.executeQuery( | ||
* 'MATCH (p:Person{ name: $name }) RETURN p', | ||
* { name: 'Person1'}, | ||
* { routing: neo4j.routing.READ}) | ||
* | ||
* @example | ||
* // Run a read query returning a Person Nodes per elementId | ||
* const peopleMappedById = await driver.executeQuery( | ||
* 'MATCH (p:Person{ name: $name }) RETURN p', | ||
* { name: 'Person1'}, | ||
* { | ||
* resultTransformer: neo4j.resultTransformers.mappedResultTransformer({ | ||
* map(record) { | ||
* const p = record.get('p') | ||
* return [p.elementId, p] | ||
* }, | ||
* collect(elementIdPersonPairArray) { | ||
* return new Map(elementIdPersonPairArray) | ||
* } | ||
* }) | ||
* } | ||
* ) | ||
* | ||
* const person = peopleMappedById.get("<ELEMENT_ID>") | ||
* | ||
* @example | ||
* // these lines | ||
* const transformedResult = await driver.executeQuery( | ||
* "<QUERY>", | ||
* <PARAMETERS>, | ||
* { | ||
* routing: neo4j.routing.WRITE, | ||
* resultTransformer: transformer, | ||
* database: "<DATABASE>", | ||
* impersonatedUser: "<USER>", | ||
* bookmarkManager: bookmarkManager | ||
* }) | ||
* // are equivalent to those | ||
* const session = driver.session({ | ||
* database: "<DATABASE>", | ||
* impersonatedUser: "<USER>", | ||
* bookmarkManager: bookmarkManager | ||
* }) | ||
* | ||
* try { | ||
* const transformedResult = await session.executeWrite(tx => { | ||
* const result = tx.run("<QUERY>", <PARAMETERS>) | ||
* return transformer(result) | ||
* }) | ||
* } finally { | ||
* await session.close() | ||
* } | ||
* | ||
* @public | ||
* @param {string | {text: string, parameters?: object}} query - Cypher query to execute | ||
* @param {Object} parameters - Map with parameters to use in the query | ||
* @param {QueryConfig<T>} config - The query configuration | ||
* @returns {Promise<T>} | ||
* | ||
* @see {@link resultTransformers} for provided result transformers. | ||
*/ | ||
Driver.prototype.executeQuery = function (query, parameters, config) { | ||
var _a, _b, _c; | ||
if (config === void 0) { config = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var bookmarkManager, resultTransformer, routingConfig; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
bookmarkManager = config.bookmarkManager === null ? undefined : ((_a = config.bookmarkManager) !== null && _a !== void 0 ? _a : this.executeQueryBookmarkManager); | ||
resultTransformer = ((_b = config.resultTransformer) !== null && _b !== void 0 ? _b : result_transformers_1.default.eagerResultTransformer()); | ||
routingConfig = (_c = config.routing) !== null && _c !== void 0 ? _c : routing.WRITE; | ||
if (routingConfig !== routing.READ && routingConfig !== routing.WRITE) { | ||
throw (0, error_1.newError)("Illegal query routing config: \"".concat(routingConfig, "\"")); | ||
} | ||
return [4 /*yield*/, this._queryExecutor.execute({ | ||
resultTransformer: resultTransformer, | ||
bookmarkManager: bookmarkManager, | ||
routing: routingConfig, | ||
database: config.database, | ||
impersonatedUser: config.impersonatedUser | ||
}, query, parameters)]; | ||
case 1: return [2 /*return*/, _d.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Verifies connectivity of this driver by trying to open a connection with the provided driver options. | ||
@@ -224,2 +527,31 @@ * | ||
/** | ||
* This method verifies the authorization credentials work by trying to acquire a connection | ||
* to one of the servers with the given credentials. | ||
* | ||
* @param {object} param - object parameter | ||
* @property {AuthToken} param.auth - the target auth for the to-be-acquired connection | ||
* @property {string} param.database - the target database for the to-be-acquired connection | ||
* | ||
* @returns {Promise<boolean>} promise resolved with true if succeed, false if failed with | ||
* authentication issue and rejected with error if non-authentication error happens. | ||
*/ | ||
Driver.prototype.verifyAuthentication = function (_a) { | ||
var _b = _a === void 0 ? {} : _a, database = _b.database, auth = _b.auth; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var connectionProvider; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
connectionProvider = this._getOrCreateConnectionProvider(); | ||
return [4 /*yield*/, connectionProvider.verifyAuthentication({ | ||
database: database !== null && database !== void 0 ? database : 'system', | ||
auth: auth, | ||
accessMode: READ | ||
})]; | ||
case 1: return [2 /*return*/, _c.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Get ServerInfo for the giver database. | ||
@@ -273,2 +605,14 @@ * | ||
/** | ||
* Returns whether the driver session re-auth functionality capabilities based on the protocol | ||
* version negotiated via handshake. | ||
* | ||
* Note that this function call _always_ causes a round-trip to the server. | ||
* | ||
* @returns {Promise<boolean>} promise resolved with a boolean or rejected with error. | ||
*/ | ||
Driver.prototype.supportsSessionAuth = function () { | ||
var connectionProvider = this._getOrCreateConnectionProvider(); | ||
return connectionProvider.supportsSessionAuth(); | ||
}; | ||
/** | ||
* Returns the protocol version negotiated via handshake. | ||
@@ -334,3 +678,3 @@ * | ||
Driver.prototype.session = function (_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.defaultAccessMode, defaultAccessMode = _c === void 0 ? WRITE : _c, bookmarkOrBookmarks = _b.bookmarks, _d = _b.database, database = _d === void 0 ? '' : _d, impersonatedUser = _b.impersonatedUser, fetchSize = _b.fetchSize, bookmarkManager = _b.bookmarkManager; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.defaultAccessMode, defaultAccessMode = _c === void 0 ? WRITE : _c, bookmarkOrBookmarks = _b.bookmarks, _d = _b.database, database = _d === void 0 ? '' : _d, impersonatedUser = _b.impersonatedUser, fetchSize = _b.fetchSize, bookmarkManager = _b.bookmarkManager, notificationFilter = _b.notificationFilter, auth = _b.auth; | ||
return this._newSession({ | ||
@@ -344,3 +688,5 @@ defaultAccessMode: defaultAccessMode, | ||
fetchSize: validateFetchSizeValue(fetchSize, this._config.fetchSize), | ||
bookmarkManager: bookmarkManager | ||
bookmarkManager: bookmarkManager, | ||
notificationFilter: notificationFilter, | ||
auth: auth | ||
}); | ||
@@ -363,2 +709,3 @@ }; | ||
* @protected | ||
* @returns {void} | ||
*/ | ||
@@ -372,3 +719,3 @@ Driver.prototype._afterConstruction = function () { | ||
Driver.prototype._newSession = function (_a) { | ||
var defaultAccessMode = _a.defaultAccessMode, bookmarkOrBookmarks = _a.bookmarkOrBookmarks, database = _a.database, reactive = _a.reactive, impersonatedUser = _a.impersonatedUser, fetchSize = _a.fetchSize, bookmarkManager = _a.bookmarkManager; | ||
var defaultAccessMode = _a.defaultAccessMode, bookmarkOrBookmarks = _a.bookmarkOrBookmarks, database = _a.database, reactive = _a.reactive, impersonatedUser = _a.impersonatedUser, fetchSize = _a.fetchSize, bookmarkManager = _a.bookmarkManager, notificationFilter = _a.notificationFilter, auth = _a.auth; | ||
var sessionMode = session_1.default._validateSessionMode(defaultAccessMode); | ||
@@ -388,3 +735,5 @@ var connectionProvider = this._getOrCreateConnectionProvider(); | ||
fetchSize: fetchSize, | ||
bookmarkManager: bookmarkManager | ||
bookmarkManager: bookmarkManager, | ||
notificationFilter: notificationFilter, | ||
auth: auth | ||
}); | ||
@@ -391,0 +740,0 @@ }; |
@@ -47,4 +47,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionPromise = exports.ManagedTransaction = exports.Transaction = exports.Connection = exports.ConnectionProvider = exports.Result = exports.Stats = exports.QueryStatistics = exports.ProfiledPlan = exports.Plan = exports.Notification = exports.ServerInfo = exports.queryType = exports.ResultSummary = exports.Record = exports.isPathSegment = exports.PathSegment = exports.isPath = exports.Path = exports.isUnboundRelationship = exports.UnboundRelationship = exports.isRelationship = exports.Relationship = exports.isNode = exports.Node = exports.Time = exports.LocalTime = exports.LocalDateTime = exports.isTime = exports.isLocalTime = exports.isLocalDateTime = exports.isDuration = exports.isDateTime = exports.isDate = exports.Duration = exports.DateTime = exports.Date = exports.Point = exports.isPoint = exports.internal = exports.toString = exports.toNumber = exports.inSafeRange = exports.isInt = exports.int = exports.Integer = exports.error = exports.isRetriableError = exports.Neo4jError = exports.newError = void 0; | ||
exports.bookmarkManager = exports.auth = exports.json = exports.driver = exports.types = exports.Driver = exports.Session = void 0; | ||
exports.ManagedTransaction = exports.Transaction = exports.Connection = exports.ConnectionProvider = exports.EagerResult = exports.Result = exports.Stats = exports.QueryStatistics = exports.ProfiledPlan = exports.Plan = exports.Notification = exports.ServerInfo = exports.queryType = exports.ResultSummary = exports.Record = exports.isPathSegment = exports.PathSegment = exports.isPath = exports.Path = exports.isUnboundRelationship = exports.UnboundRelationship = exports.isRelationship = exports.Relationship = exports.isNode = exports.Node = exports.Time = exports.LocalTime = exports.LocalDateTime = exports.isTime = exports.isLocalTime = exports.isLocalDateTime = exports.isDuration = exports.isDateTime = exports.isDate = exports.Duration = exports.DateTime = exports.Date = exports.Point = exports.isPoint = exports.internal = exports.toString = exports.toNumber = exports.inSafeRange = exports.isInt = exports.int = exports.Integer = exports.error = exports.isRetriableError = exports.Neo4jError = exports.newError = void 0; | ||
exports.notificationFilterMinimumSeverityLevel = exports.notificationFilterDisabledCategory = exports.notificationSeverityLevel = exports.notificationCategory = exports.resultTransformers = exports.routing = exports.isStaticAuthTokenManger = exports.staticAuthTokenManager = exports.expirationBasedAuthTokenManager = exports.bookmarkManager = exports.auth = exports.json = exports.driver = exports.types = exports.Driver = exports.Session = exports.TransactionPromise = void 0; | ||
var error_1 = require("./error"); | ||
@@ -99,4 +99,11 @@ Object.defineProperty(exports, "newError", { enumerable: true, get: function () { return error_1.newError; } }); | ||
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return result_summary_1.Stats; } }); | ||
Object.defineProperty(exports, "notificationCategory", { enumerable: true, get: function () { return result_summary_1.notificationCategory; } }); | ||
Object.defineProperty(exports, "notificationSeverityLevel", { enumerable: true, get: function () { return result_summary_1.notificationSeverityLevel; } }); | ||
var notification_filter_1 = require("./notification-filter"); | ||
Object.defineProperty(exports, "notificationFilterDisabledCategory", { enumerable: true, get: function () { return notification_filter_1.notificationFilterDisabledCategory; } }); | ||
Object.defineProperty(exports, "notificationFilterMinimumSeverityLevel", { enumerable: true, get: function () { return notification_filter_1.notificationFilterMinimumSeverityLevel; } }); | ||
var result_1 = __importDefault(require("./result")); | ||
exports.Result = result_1.default; | ||
var result_eager_1 = __importDefault(require("./result-eager")); | ||
exports.EagerResult = result_eager_1.default; | ||
var connection_provider_1 = __importDefault(require("./connection-provider")); | ||
@@ -121,2 +128,8 @@ exports.ConnectionProvider = connection_provider_1.default; | ||
Object.defineProperty(exports, "bookmarkManager", { enumerable: true, get: function () { return bookmark_manager_1.bookmarkManager; } }); | ||
var auth_token_manager_1 = require("./auth-token-manager"); | ||
Object.defineProperty(exports, "expirationBasedAuthTokenManager", { enumerable: true, get: function () { return auth_token_manager_1.expirationBasedAuthTokenManager; } }); | ||
Object.defineProperty(exports, "staticAuthTokenManager", { enumerable: true, get: function () { return auth_token_manager_1.staticAuthTokenManager; } }); | ||
Object.defineProperty(exports, "isStaticAuthTokenManger", { enumerable: true, get: function () { return auth_token_manager_1.isStaticAuthTokenManger; } }); | ||
var driver_2 = require("./driver"); | ||
Object.defineProperty(exports, "routing", { enumerable: true, get: function () { return driver_2.routing; } }); | ||
var types = __importStar(require("./types")); | ||
@@ -126,2 +139,4 @@ exports.types = types; | ||
exports.json = json; | ||
var result_transformers_1 = __importDefault(require("./result-transformers")); | ||
exports.resultTransformers = result_transformers_1.default; | ||
var internal = __importStar(require("./internal")); // todo: removed afterwards | ||
@@ -187,2 +202,3 @@ exports.internal = internal; | ||
Result: result_1.default, | ||
EagerResult: result_eager_1.default, | ||
Transaction: transaction_1.default, | ||
@@ -198,4 +214,11 @@ ManagedTransaction: transaction_managed_1.default, | ||
auth: auth_1.default, | ||
bookmarkManager: bookmark_manager_1.bookmarkManager | ||
bookmarkManager: bookmark_manager_1.bookmarkManager, | ||
expirationBasedAuthTokenManager: auth_token_manager_1.expirationBasedAuthTokenManager, | ||
routing: driver_2.routing, | ||
resultTransformers: result_transformers_1.default, | ||
notificationCategory: result_summary_1.notificationCategory, | ||
notificationSeverityLevel: result_summary_1.notificationSeverityLevel, | ||
notificationFilterDisabledCategory: notification_filter_1.notificationFilterDisabledCategory, | ||
notificationFilterMinimumSeverityLevel: notification_filter_1.notificationFilterMinimumSeverityLevel | ||
}; | ||
exports.default = forExport; |
@@ -187,2 +187,16 @@ "use strict"; | ||
/** | ||
* Converts the Integer to it primitive value. | ||
* | ||
* @since 5.4.0 | ||
* @returns {bigint} | ||
* | ||
* @see {@link Integer#toBigInt} | ||
* @see {@link Integer#toInt} | ||
* @see {@link Integer#toNumber} | ||
* @see {@link Integer#toString} | ||
*/ | ||
Integer.prototype.valueOf = function () { | ||
return this.toBigInt(); | ||
}; | ||
/** | ||
* Gets the high 32 bits as a signed integer. | ||
@@ -189,0 +203,0 @@ * @returns {number} Signed high bits |
@@ -93,6 +93,8 @@ "use strict"; | ||
* @property {function():Promise<Bookmarks>} params.getConnectionAcquistionBookmarks - called for getting Bookmarks for acquiring connections | ||
* @property {AuthToken} params.auth - the target auth for the to-be-acquired connection | ||
*/ | ||
function ConnectionHolder(_a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.mode, mode = _c === void 0 ? constants_1.ACCESS_MODE_WRITE : _c, _d = _b.database, database = _d === void 0 ? '' : _d, bookmarks = _b.bookmarks, connectionProvider = _b.connectionProvider, impersonatedUser = _b.impersonatedUser, onDatabaseNameResolved = _b.onDatabaseNameResolved, getConnectionAcquistionBookmarks = _b.getConnectionAcquistionBookmarks; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.mode, mode = _c === void 0 ? constants_1.ACCESS_MODE_WRITE : _c, _d = _b.database, database = _d === void 0 ? '' : _d, bookmarks = _b.bookmarks, connectionProvider = _b.connectionProvider, impersonatedUser = _b.impersonatedUser, onDatabaseNameResolved = _b.onDatabaseNameResolved, getConnectionAcquistionBookmarks = _b.getConnectionAcquistionBookmarks, auth = _b.auth; | ||
this._mode = mode; | ||
this._closed = false; | ||
this._database = database != null ? (0, util_1.assertString)(database, 'database') : ''; | ||
@@ -105,2 +107,3 @@ this._bookmarks = bookmarks !== null && bookmarks !== void 0 ? bookmarks : bookmarks_1.Bookmarks.empty(); | ||
this._onDatabaseNameResolved = onDatabaseNameResolved; | ||
this._auth = auth; | ||
this._getConnectionAcquistionBookmarks = getConnectionAcquistionBookmarks !== null && getConnectionAcquistionBookmarks !== void 0 ? getConnectionAcquistionBookmarks : (function () { return Promise.resolve(bookmarks_1.Bookmarks.empty()); }); | ||
@@ -153,2 +156,3 @@ } | ||
_c.onDatabaseNameResolved = this._onDatabaseNameResolved, | ||
_c.auth = this._auth, | ||
_c)])]; | ||
@@ -184,2 +188,3 @@ case 2: return [2 /*return*/, _d.sent()]; | ||
ConnectionHolder.prototype.close = function (hasTx) { | ||
this._closed = true; | ||
if (this._referenceCount === 0) { | ||
@@ -186,0 +191,0 @@ return this._connectionPromise; |
@@ -21,3 +21,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BOLT_PROTOCOL_V5_0 = exports.BOLT_PROTOCOL_V4_4 = exports.BOLT_PROTOCOL_V4_3 = exports.BOLT_PROTOCOL_V4_2 = exports.BOLT_PROTOCOL_V4_1 = exports.BOLT_PROTOCOL_V4_0 = exports.BOLT_PROTOCOL_V3 = exports.BOLT_PROTOCOL_V2 = exports.BOLT_PROTOCOL_V1 = exports.DEFAULT_POOL_MAX_SIZE = exports.DEFAULT_POOL_ACQUISITION_TIMEOUT = exports.DEFAULT_CONNECTION_TIMEOUT_MILLIS = exports.ACCESS_MODE_WRITE = exports.ACCESS_MODE_READ = exports.FETCH_ALL = void 0; | ||
exports.BOLT_PROTOCOL_V5_2 = exports.BOLT_PROTOCOL_V5_1 = exports.BOLT_PROTOCOL_V5_0 = exports.BOLT_PROTOCOL_V4_4 = exports.BOLT_PROTOCOL_V4_3 = exports.BOLT_PROTOCOL_V4_2 = exports.BOLT_PROTOCOL_V4_1 = exports.BOLT_PROTOCOL_V4_0 = exports.BOLT_PROTOCOL_V3 = exports.BOLT_PROTOCOL_V2 = exports.BOLT_PROTOCOL_V1 = exports.DEFAULT_POOL_MAX_SIZE = exports.DEFAULT_POOL_ACQUISITION_TIMEOUT = exports.DEFAULT_CONNECTION_TIMEOUT_MILLIS = exports.ACCESS_MODE_WRITE = exports.ACCESS_MODE_READ = exports.FETCH_ALL = void 0; | ||
var FETCH_ALL = -1; | ||
@@ -53,1 +53,5 @@ exports.FETCH_ALL = FETCH_ALL; | ||
exports.BOLT_PROTOCOL_V5_0 = BOLT_PROTOCOL_V5_0; | ||
var BOLT_PROTOCOL_V5_1 = 5.1; | ||
exports.BOLT_PROTOCOL_V5_1 = BOLT_PROTOCOL_V5_1; | ||
var BOLT_PROTOCOL_V5_2 = 5.2; | ||
exports.BOLT_PROTOCOL_V5_2 = BOLT_PROTOCOL_V5_2; |
"use strict"; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ENCRYPTION_OFF = exports.ENCRYPTION_ON = exports.validateQueryAndParameters = exports.assertValidDate = exports.assertNumberOrInteger = exports.assertNumber = exports.assertString = exports.assertObject = exports.isString = exports.isObject = exports.isEmptyObjectOrNull = void 0; | ||
exports.ENCRYPTION_OFF = exports.ENCRYPTION_ON = exports.equals = exports.validateQueryAndParameters = exports.assertValidDate = exports.assertNumberOrInteger = exports.assertNumber = exports.assertString = exports.assertObject = exports.isString = exports.isObject = exports.isEmptyObjectOrNull = void 0; | ||
/** | ||
@@ -202,1 +213,41 @@ * Copyright (c) "Neo4j" | ||
exports.isString = isString; | ||
/** | ||
* Verifies if object are the equals | ||
* @param {unknown} a | ||
* @param {unknown} b | ||
* @returns {boolean} | ||
*/ | ||
function equals(a, b) { | ||
var e_1, _a; | ||
if (a === b) { | ||
return true; | ||
} | ||
if (a === null || b === null) { | ||
return false; | ||
} | ||
if (typeof a === 'object' && typeof b === 'object') { | ||
var keysA = Object.keys(a); | ||
var keysB = Object.keys(b); | ||
if (keysA.length !== keysB.length) { | ||
return false; | ||
} | ||
try { | ||
for (var keysA_1 = __values(keysA), keysA_1_1 = keysA_1.next(); !keysA_1_1.done; keysA_1_1 = keysA_1.next()) { | ||
var key = keysA_1_1.value; | ||
if (!equals(a[key], b[key])) { | ||
return false; | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (keysA_1_1 && !keysA_1_1.done && (_a = keysA_1.return)) _a.call(keysA_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
exports.equals = equals; |
@@ -44,3 +44,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Stats = exports.QueryStatistics = exports.ProfiledPlan = exports.Plan = exports.Notification = exports.ServerInfo = exports.queryType = void 0; | ||
exports.notificationCategory = exports.notificationSeverityLevel = exports.Stats = exports.QueryStatistics = exports.ProfiledPlan = exports.Plan = exports.Notification = exports.ServerInfo = exports.queryType = void 0; | ||
var integer_1 = __importStar(require("./integer")); | ||
@@ -379,2 +379,34 @@ /** | ||
/** | ||
* @typedef {'WARNING' | 'INFORMATION' | 'UNKNOWN'} NotificationSeverityLevel | ||
*/ | ||
/** | ||
* Constants that represents the Severity level in the {@link Notification} | ||
*/ | ||
var notificationSeverityLevel = { | ||
WARNING: 'WARNING', | ||
INFORMATION: 'INFORMATION', | ||
UNKNOWN: 'UNKNOWN' | ||
}; | ||
exports.notificationSeverityLevel = notificationSeverityLevel; | ||
Object.freeze(notificationSeverityLevel); | ||
var severityLevels = Object.values(notificationSeverityLevel); | ||
/** | ||
* @typedef {'HINT' | 'UNRECOGNIZED' | 'UNSUPPORTED' |'PERFORMANCE' | 'DEPRECATION' | 'GENERIC' | 'UNKNOWN'} NotificationCategory | ||
*/ | ||
/** | ||
* Constants that represents the Category in the {@link Notification} | ||
*/ | ||
var notificationCategory = { | ||
HINT: 'HINT', | ||
UNRECOGNIZED: 'UNRECOGNIZED', | ||
UNSUPPORTED: 'UNSUPPORTED', | ||
PERFORMANCE: 'PERFORMANCE', | ||
DEPRECATION: 'DEPRECATION', | ||
GENERIC: 'GENERIC', | ||
UNKNOWN: 'UNKNOWN' | ||
}; | ||
exports.notificationCategory = notificationCategory; | ||
Object.freeze(notificationCategory); | ||
var categories = Object.values(notificationCategory); | ||
/** | ||
* Class for Cypher notifications | ||
@@ -390,7 +422,105 @@ * @access public | ||
function Notification(notification) { | ||
/** | ||
* The code | ||
* @type {string} | ||
* @public | ||
*/ | ||
this.code = notification.code; | ||
/** | ||
* The title | ||
* @type {string} | ||
* @public | ||
*/ | ||
this.title = notification.title; | ||
/** | ||
* The description | ||
* @type {string} | ||
* @public | ||
*/ | ||
this.description = notification.description; | ||
/** | ||
* The raw severity | ||
* | ||
* Use {@link Notification#rawSeverityLevel} for the raw value or {@link Notification#severityLevel} for an enumerated value. | ||
* | ||
* @type {string} | ||
* @public | ||
* @deprecated This property will be removed in 6.0. | ||
*/ | ||
this.severity = notification.severity; | ||
/** | ||
* The position which the notification had occur. | ||
* | ||
* @type {NotificationPosition} | ||
* @public | ||
*/ | ||
this.position = Notification._constructPosition(notification.position); | ||
/** | ||
* The severity level | ||
* | ||
* @type {NotificationSeverityLevel} | ||
* @public | ||
* @example | ||
* const { summary } = await session.run("RETURN 1") | ||
* | ||
* for (const notification of summary.notifications) { | ||
* switch(notification.severityLevel) { | ||
* case neo4j.notificationSeverityLevel.INFORMATION: // or simply 'INFORMATION' | ||
* console.info(`${notification.title} - ${notification.description}`) | ||
* break | ||
* case neo4j.notificationSeverityLevel.WARNING: // or simply 'WARNING' | ||
* console.warn(`${notification.title} - ${notification.description}`) | ||
* break | ||
* case neo4j.notificationSeverityLevel.UNKNOWN: // or simply 'UNKNOWN' | ||
* default: | ||
* // the raw info came from the server could be found at notification.rawSeverityLevel | ||
* console.log(`${notification.title} - ${notification.description}`) | ||
* break | ||
* } | ||
* } | ||
*/ | ||
this.severityLevel = severityLevels.includes(notification.severity) | ||
? notification.severity | ||
: notificationSeverityLevel.UNKNOWN; | ||
/** | ||
* The severity level returned by the server without any validation. | ||
* | ||
* @type {string} | ||
* @public | ||
*/ | ||
this.rawSeverityLevel = notification.severity; | ||
/** | ||
* The category | ||
* | ||
* @type {NotificationCategory} | ||
* @public | ||
* @example | ||
* const { summary } = await session.run("RETURN 1") | ||
* | ||
* for (const notification of summary.notifications) { | ||
* switch(notification.category) { | ||
* case neo4j.notificationCategory.QUERY: // or simply 'QUERY' | ||
* console.info(`${notification.title} - ${notification.description}`) | ||
* break | ||
* case neo4j.notificationCategory.PERFORMANCE: // or simply 'PERFORMANCE' | ||
* console.warn(`${notification.title} - ${notification.description}`) | ||
* break | ||
* case neo4j.notificationCategory.UNKNOWN: // or simply 'UNKNOWN' | ||
* default: | ||
* // the raw info came from the server could be found at notification.rawCategory | ||
* console.log(`${notification.title} - ${notification.description}`) | ||
* break | ||
* } | ||
* } | ||
*/ | ||
this.category = categories.includes(notification.category) | ||
? notification.category | ||
: notificationCategory.UNKNOWN; | ||
/** | ||
* The category returned by the server without any validation. | ||
* | ||
* @type {string|undefined} | ||
* @public | ||
*/ | ||
this.rawCategory = notification.category; | ||
} | ||
@@ -397,0 +527,0 @@ Notification._constructPosition = function (pos) { |
@@ -117,5 +117,7 @@ "use strict"; | ||
* @param {string} args.impersonatedUser - The username which the user wants to impersonate for the duration of the session. | ||
* @param {AuthToken} args.auth - the target auth for the to-be-acquired connection | ||
* @param {NotificationFilter} args.notificationFilter - The notification filter used for this session. | ||
*/ | ||
function Session(_a) { | ||
var mode = _a.mode, connectionProvider = _a.connectionProvider, bookmarks = _a.bookmarks, database = _a.database, config = _a.config, reactive = _a.reactive, fetchSize = _a.fetchSize, impersonatedUser = _a.impersonatedUser, bookmarkManager = _a.bookmarkManager; | ||
var mode = _a.mode, connectionProvider = _a.connectionProvider, bookmarks = _a.bookmarks, database = _a.database, config = _a.config, reactive = _a.reactive, fetchSize = _a.fetchSize, impersonatedUser = _a.impersonatedUser, bookmarkManager = _a.bookmarkManager, notificationFilter = _a.notificationFilter, auth = _a.auth; | ||
this._mode = mode; | ||
@@ -129,2 +131,3 @@ this._database = database; | ||
mode: constants_1.ACCESS_MODE_READ, | ||
auth: auth, | ||
database: database, | ||
@@ -139,2 +142,3 @@ bookmarks: bookmarks, | ||
mode: constants_1.ACCESS_MODE_WRITE, | ||
auth: auth, | ||
database: database, | ||
@@ -159,2 +163,3 @@ bookmarks: bookmarks, | ||
this._bookmarkManager = bookmarkManager; | ||
this._notificationFilter = notificationFilter; | ||
} | ||
@@ -197,3 +202,4 @@ /** | ||
lowRecordWatermark: this._lowRecordWatermark, | ||
highRecordWatermark: this._highRecordWatermark | ||
highRecordWatermark: this._highRecordWatermark, | ||
notificationFilter: this._notificationFilter | ||
})]; | ||
@@ -301,3 +307,4 @@ } | ||
lowRecordWatermark: this._lowRecordWatermark, | ||
highRecordWatermark: this._highRecordWatermark | ||
highRecordWatermark: this._highRecordWatermark, | ||
notificationFilter: this._notificationFilter | ||
}); | ||
@@ -326,5 +333,6 @@ tx._begin(function () { return _this._bookmarks(); }, txConfig); | ||
* | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link Session#lastBookmarks} instead. | ||
* @deprecated This method will be removed in version 6.0. Please, use Session#lastBookmarks instead. | ||
* | ||
* @return {string[]} A reference to a previous transaction. | ||
* @see {@link Session#lastBookmarks} | ||
*/ | ||
@@ -367,3 +375,3 @@ Session.prototype.lastBookmark = function () { | ||
* | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link Session#executeRead} instead. | ||
* @deprecated This method will be removed in version 6.0. Please, use Session#executeRead instead. | ||
* | ||
@@ -375,2 +383,3 @@ * @param {function(tx: Transaction): Promise} transactionWork - Callback that executes operations against | ||
* function or commit fails. | ||
* @see {@link Session#executeRead} | ||
*/ | ||
@@ -389,3 +398,3 @@ Session.prototype.readTransaction = function (transactionWork, transactionConfig) { | ||
* | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link Session#executeWrite} instead. | ||
* @deprecated This method will be removed in version 6.0. Please, use Session#executeWrite instead. | ||
* | ||
@@ -397,2 +406,3 @@ * @param {function(tx: Transaction): Promise} transactionWork - Callback that executes operations against | ||
* function or commit fails. | ||
* @see {@link Session#executeWrite} | ||
*/ | ||
@@ -399,0 +409,0 @@ Session.prototype.writeTransaction = function (transactionWork, transactionConfig) { |
@@ -67,13 +67,15 @@ "use strict"; | ||
* @constructor | ||
* @param {ConnectionHolder} connectionHolder - the connection holder to get connection from. | ||
* @param {function()} onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} onConnection - Function to be called when a connection is obtained to ensure the connection | ||
* @param {object} args | ||
* @param {ConnectionHolder} args.connectionHolder - the connection holder to get connection from. | ||
* @param {function()} args.onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} args.onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} args.onConnection - Function to be called when a connection is obtained to ensure the connection | ||
* is not yet released. | ||
* @param {boolean} reactive whether this transaction generates reactive streams | ||
* @param {number} fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {boolean} args.reactive whether this transaction generates reactive streams | ||
* @param {number} args.fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} args.impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {NotificationFilter} args.notificationFilter - The notification filter used for this transaction. | ||
*/ | ||
function TransactionPromise(_b) { | ||
var connectionHolder = _b.connectionHolder, onClose = _b.onClose, onBookmarks = _b.onBookmarks, onConnection = _b.onConnection, reactive = _b.reactive, fetchSize = _b.fetchSize, impersonatedUser = _b.impersonatedUser, highRecordWatermark = _b.highRecordWatermark, lowRecordWatermark = _b.lowRecordWatermark; | ||
var connectionHolder = _b.connectionHolder, onClose = _b.onClose, onBookmarks = _b.onBookmarks, onConnection = _b.onConnection, reactive = _b.reactive, fetchSize = _b.fetchSize, impersonatedUser = _b.impersonatedUser, highRecordWatermark = _b.highRecordWatermark, lowRecordWatermark = _b.lowRecordWatermark, notificationFilter = _b.notificationFilter; | ||
var _this = _super.call(this, { | ||
@@ -88,3 +90,4 @@ connectionHolder: connectionHolder, | ||
highRecordWatermark: highRecordWatermark, | ||
lowRecordWatermark: lowRecordWatermark | ||
lowRecordWatermark: lowRecordWatermark, | ||
notificationFilter: notificationFilter | ||
}) || this; | ||
@@ -91,0 +94,0 @@ _this[_a] = 'TransactionPromise'; |
@@ -76,15 +76,17 @@ "use strict"; | ||
* @constructor | ||
* @param {ConnectionHolder} connectionHolder - the connection holder to get connection from. | ||
* @param {function()} onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} onConnection - Function to be called when a connection is obtained to ensure the conneciton | ||
* @param {object} args | ||
* @param {ConnectionHolder} args.connectionHolder - the connection holder to get connection from. | ||
* @param {function()} args.onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} args.onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} args.onConnection - Function to be called when a connection is obtained to ensure the conneciton | ||
* is not yet released. | ||
* @param {boolean} reactive whether this transaction generates reactive streams | ||
* @param {number} fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {number} highRecordWatermark - The high watermark for the record buffer. | ||
* @param {number} lowRecordWatermark - The low watermark for the record buffer. | ||
* @param {boolean} args.reactive whether this transaction generates reactive streams | ||
* @param {number} args.fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} args.impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {number} args.highRecordWatermark - The high watermark for the record buffer. | ||
* @param {number} args.lowRecordWatermark - The low watermark for the record buffer. | ||
* @param {NotificationFilter} args.notificationFilter - The notification filter used for this transaction. | ||
*/ | ||
function Transaction(_a) { | ||
var connectionHolder = _a.connectionHolder, onClose = _a.onClose, onBookmarks = _a.onBookmarks, onConnection = _a.onConnection, reactive = _a.reactive, fetchSize = _a.fetchSize, impersonatedUser = _a.impersonatedUser, highRecordWatermark = _a.highRecordWatermark, lowRecordWatermark = _a.lowRecordWatermark; | ||
var connectionHolder = _a.connectionHolder, onClose = _a.onClose, onBookmarks = _a.onBookmarks, onConnection = _a.onConnection, reactive = _a.reactive, fetchSize = _a.fetchSize, impersonatedUser = _a.impersonatedUser, highRecordWatermark = _a.highRecordWatermark, lowRecordWatermark = _a.lowRecordWatermark, notificationFilter = _a.notificationFilter; | ||
var _this = this; | ||
@@ -105,2 +107,3 @@ this._connectionHolder = connectionHolder; | ||
this._bookmarks = bookmarks_1.Bookmarks.empty(); | ||
this._notificationFilter = notificationFilter; | ||
this._acceptActive = function () { }; // satisfy DenoJS | ||
@@ -139,2 +142,3 @@ this._activePromise = new Promise(function (resolve, reject) { | ||
impersonatedUser: this._impersonatedUser, | ||
notificationFilter: this._notificationFilter, | ||
beforeError: function (error) { | ||
@@ -141,0 +145,0 @@ if (events != null) { |
{ | ||
"name": "neo4j-driver-core", | ||
"version": "3.4.0-alpha01", | ||
"version": "3.8.0", | ||
"description": "Internals of neo4j-driver", | ||
@@ -41,5 +41,5 @@ "main": "lib/index.js", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
"typescript": "^4.9.5" | ||
}, | ||
"gitHead": "b41b355eeb88c7db83a75f6917a3ba9782637e18" | ||
"gitHead": "a18add07c2b6781554faa343427c4d246a5e6b0c" | ||
} |
@@ -50,4 +50,7 @@ /** | ||
}; | ||
none: () => { | ||
scheme: string; | ||
}; | ||
custom: (principal: string, credentials: string, realm: string, scheme: string, parameters?: object) => any; | ||
}; | ||
export default auth; |
@@ -23,3 +23,2 @@ /** | ||
* @since 5.0 | ||
* @experimental | ||
*/ | ||
@@ -59,3 +58,2 @@ export default class BookmarkManager { | ||
* @since 5.0 | ||
* @experimental | ||
* @property {Iterable<string>} [initialBookmarks] Defines the initial set of bookmarks. The key is the database name and the values are the bookmarks. | ||
@@ -69,3 +67,2 @@ * @property {function():Promise<Iterable<string>>} [bookmarksSupplier] Called for supplying extra bookmarks to the BookmarkManager | ||
* @since 5.0 | ||
* @experimental | ||
* @param {BookmarkManagerConfig} [config={}] | ||
@@ -72,0 +69,0 @@ * @returns {BookmarkManager} |
@@ -22,4 +22,5 @@ /** | ||
import { ServerInfo } from './result-summary'; | ||
import { AuthToken } from './types'; | ||
/** | ||
* Inteface define a common way to acquire a connection | ||
* Interface define a common way to acquire a connection | ||
* | ||
@@ -44,2 +45,3 @@ * @private | ||
* @property {function (databaseName:string?)} param.onDatabaseNameResolved - Callback called when the database name get resolved | ||
* @returns {Promise<Connection>} | ||
*/ | ||
@@ -52,2 +54,3 @@ acquireConnection(param?: { | ||
onDatabaseNameResolved?: (databaseName?: string) => void; | ||
auth?: AuthToken; | ||
}): Promise<Connection>; | ||
@@ -76,2 +79,9 @@ /** | ||
/** | ||
* This method checks whether the driver session re-auth functionality | ||
* by checking protocol handshake result | ||
* | ||
* @returns {Promise<boolean>} | ||
*/ | ||
supportsSessionAuth(): Promise<boolean>; | ||
/** | ||
* This method verifies the connectivity of the database by trying to acquire a connection | ||
@@ -91,2 +101,19 @@ * for each server available in the cluster. | ||
/** | ||
* This method verifies the authorization credentials work by trying to acquire a connection | ||
* to one of the servers with the given credentials. | ||
* | ||
* @param {object} param - object parameter | ||
* @property {AuthToken} param.auth - the target auth for the to-be-acquired connection | ||
* @property {string} param.database - the target database for the to-be-acquired connection | ||
* @property {string} param.accessMode - the access mode for the to-be-acquired connection | ||
* | ||
* @returns {Promise<boolean>} promise resolved with true if succeed, false if failed with | ||
* authentication issue and rejected with error if non-authentication error happens. | ||
*/ | ||
verifyAuthentication(param?: { | ||
auth?: AuthToken; | ||
database?: string; | ||
accessMode?: string; | ||
}): Promise<boolean>; | ||
/** | ||
* Returns the protocol version negotiated via handshake. | ||
@@ -93,0 +120,0 @@ * |
@@ -29,2 +29,6 @@ /** | ||
/** | ||
* @property {object} authToken The auth registered in the connection | ||
*/ | ||
get authToken(): any; | ||
/** | ||
* @property {ServerAddress} the server address this connection is opened against | ||
@@ -38,2 +42,6 @@ */ | ||
/** | ||
* @property {boolean} supportsReAuth Indicates the connection supports re-auth | ||
*/ | ||
get supportsReAuth(): boolean; | ||
/** | ||
* @returns {boolean} whether this connection is in a working condition | ||
@@ -40,0 +48,0 @@ */ |
@@ -25,5 +25,9 @@ /** | ||
import { ServerInfo } from './result-summary'; | ||
import { EncryptionLevel, LoggingConfig, TrustStrategy, SessionMode } from './types'; | ||
import { EncryptionLevel, LoggingConfig, TrustStrategy, SessionMode, Query, AuthToken } from './types'; | ||
import { ServerAddress } from './internal/server-address'; | ||
import BookmarkManager from './bookmark-manager'; | ||
import EagerResult from './result-eager'; | ||
import { ResultTransformer } from './result-transformers'; | ||
import QueryExecutor from './internal/query-executor'; | ||
import NotificationFilter from './notification-filter'; | ||
/** | ||
@@ -57,3 +61,9 @@ * Constant that represents read session access mode. | ||
bookmarkManager?: BookmarkManager; | ||
notificationFilter?: NotificationFilter; | ||
auth?: AuthToken; | ||
}) => Session; | ||
type CreateQueryExecutor = (createSession: (config: { | ||
database?: string; | ||
bookmarkManager?: BookmarkManager; | ||
}) => Session) => QueryExecutor; | ||
interface DriverConfig { | ||
@@ -64,2 +74,3 @@ encrypted?: EncryptionLevel | boolean; | ||
logging?: LoggingConfig; | ||
notificationFilter?: NotificationFilter; | ||
} | ||
@@ -78,2 +89,4 @@ /** | ||
bookmarkManager?: BookmarkManager; | ||
notificationFilter?: NotificationFilter; | ||
auth?: AuthToken; | ||
/** | ||
@@ -85,3 +98,33 @@ * @constructor | ||
} | ||
type RoutingControl = 'WRITE' | 'READ'; | ||
/** | ||
* @typedef {'WRITE'|'READ'} RoutingControl | ||
*/ | ||
/** | ||
* Constants that represents routing modes. | ||
* | ||
* @example | ||
* driver.executeQuery("<QUERY>", <PARAMETERS>, { routing: neo4j.routing.WRITE }) | ||
*/ | ||
declare const routing: { | ||
WRITE: "WRITE"; | ||
READ: "READ"; | ||
}; | ||
/** | ||
* The query configuration | ||
* @interface | ||
*/ | ||
declare class QueryConfig<T = EagerResult> { | ||
routing?: RoutingControl; | ||
database?: string; | ||
impersonatedUser?: string; | ||
bookmarkManager?: BookmarkManager | null; | ||
resultTransformer?: ResultTransformer<T>; | ||
/** | ||
* @constructor | ||
* @private | ||
*/ | ||
private constructor(); | ||
} | ||
/** | ||
* A driver maintains one or more {@link Session}s with a remote | ||
@@ -104,2 +147,4 @@ * Neo4j instance. Through the {@link Session}s you can send queries | ||
private readonly _createSession; | ||
private readonly _defaultExecuteQueryBookmarkManager; | ||
private readonly _queryExecutor; | ||
/** | ||
@@ -111,7 +156,90 @@ * You should not be calling this directly, instead use {@link driver}. | ||
* @param {Object} config | ||
* @param {function(id: number, config:Object, log:Logger, hostNameResolver: ConfiguredCustomResolver): ConnectionProvider } createConnectonProvider Creates the connection provider | ||
* @param {function(id: number, config:Object, log:Logger, hostNameResolver: ConfiguredCustomResolver): ConnectionProvider } createConnectionProvider Creates the connection provider | ||
* @param {function(args): Session } createSession Creates the a session | ||
*/ | ||
constructor(meta: MetaInfo, config: DriverConfig | undefined, createConnectonProvider: CreateConnectionProvider, createSession?: CreateSession); | ||
constructor(meta: MetaInfo, config: DriverConfig | undefined, createConnectionProvider: CreateConnectionProvider, createSession?: CreateSession, createQueryExecutor?: CreateQueryExecutor); | ||
/** | ||
* The bookmark managed used by {@link Driver.executeQuery} | ||
* | ||
* @type {BookmarkManager} | ||
*/ | ||
get executeQueryBookmarkManager(): BookmarkManager; | ||
/** | ||
* Executes a query in a retriable context and returns a {@link EagerResult}. | ||
* | ||
* This method is a shortcut for a {@link Session#executeRead} and {@link Session#executeWrite}. | ||
* | ||
* NOTE: Because it is an explicit transaction from the server point of view, Cypher queries using | ||
* "CALL {} IN TRANSACTIONS" or the older "USING PERIODIC COMMIT" construct will not work (call | ||
* {@link Session#run} for these). | ||
* | ||
* @example | ||
* // Run a simple write query | ||
* const { keys, records, summary } = await driver.executeQuery('CREATE (p:Person{ name: $name }) RETURN p', { name: 'Person1'}) | ||
* | ||
* @example | ||
* // Run a read query | ||
* const { keys, records, summary } = await driver.executeQuery( | ||
* 'MATCH (p:Person{ name: $name }) RETURN p', | ||
* { name: 'Person1'}, | ||
* { routing: neo4j.routing.READ}) | ||
* | ||
* @example | ||
* // Run a read query returning a Person Nodes per elementId | ||
* const peopleMappedById = await driver.executeQuery( | ||
* 'MATCH (p:Person{ name: $name }) RETURN p', | ||
* { name: 'Person1'}, | ||
* { | ||
* resultTransformer: neo4j.resultTransformers.mappedResultTransformer({ | ||
* map(record) { | ||
* const p = record.get('p') | ||
* return [p.elementId, p] | ||
* }, | ||
* collect(elementIdPersonPairArray) { | ||
* return new Map(elementIdPersonPairArray) | ||
* } | ||
* }) | ||
* } | ||
* ) | ||
* | ||
* const person = peopleMappedById.get("<ELEMENT_ID>") | ||
* | ||
* @example | ||
* // these lines | ||
* const transformedResult = await driver.executeQuery( | ||
* "<QUERY>", | ||
* <PARAMETERS>, | ||
* { | ||
* routing: neo4j.routing.WRITE, | ||
* resultTransformer: transformer, | ||
* database: "<DATABASE>", | ||
* impersonatedUser: "<USER>", | ||
* bookmarkManager: bookmarkManager | ||
* }) | ||
* // are equivalent to those | ||
* const session = driver.session({ | ||
* database: "<DATABASE>", | ||
* impersonatedUser: "<USER>", | ||
* bookmarkManager: bookmarkManager | ||
* }) | ||
* | ||
* try { | ||
* const transformedResult = await session.executeWrite(tx => { | ||
* const result = tx.run("<QUERY>", <PARAMETERS>) | ||
* return transformer(result) | ||
* }) | ||
* } finally { | ||
* await session.close() | ||
* } | ||
* | ||
* @public | ||
* @param {string | {text: string, parameters?: object}} query - Cypher query to execute | ||
* @param {Object} parameters - Map with parameters to use in the query | ||
* @param {QueryConfig<T>} config - The query configuration | ||
* @returns {Promise<T>} | ||
* | ||
* @see {@link resultTransformers} for provided result transformers. | ||
*/ | ||
executeQuery<T = EagerResult>(query: Query, parameters?: any, config?: QueryConfig<T>): Promise<T>; | ||
/** | ||
* Verifies connectivity of this driver by trying to open a connection with the provided driver options. | ||
@@ -131,2 +259,17 @@ * | ||
/** | ||
* This method verifies the authorization credentials work by trying to acquire a connection | ||
* to one of the servers with the given credentials. | ||
* | ||
* @param {object} param - object parameter | ||
* @property {AuthToken} param.auth - the target auth for the to-be-acquired connection | ||
* @property {string} param.database - the target database for the to-be-acquired connection | ||
* | ||
* @returns {Promise<boolean>} promise resolved with true if succeed, false if failed with | ||
* authentication issue and rejected with error if non-authentication error happens. | ||
*/ | ||
verifyAuthentication({ database, auth }?: { | ||
auth?: AuthToken; | ||
database?: string; | ||
}): Promise<boolean>; | ||
/** | ||
* Get ServerInfo for the giver database. | ||
@@ -169,2 +312,11 @@ * | ||
/** | ||
* Returns whether the driver session re-auth functionality capabilities based on the protocol | ||
* version negotiated via handshake. | ||
* | ||
* Note that this function call _always_ causes a round-trip to the server. | ||
* | ||
* @returns {Promise<boolean>} promise resolved with a boolean or rejected with error. | ||
*/ | ||
supportsSessionAuth(): Promise<boolean>; | ||
/** | ||
* Returns the protocol version negotiated via handshake. | ||
@@ -218,3 +370,3 @@ * | ||
*/ | ||
session({ defaultAccessMode, bookmarks: bookmarkOrBookmarks, database, impersonatedUser, fetchSize, bookmarkManager }?: SessionConfig): Session; | ||
session({ defaultAccessMode, bookmarks: bookmarkOrBookmarks, database, impersonatedUser, fetchSize, bookmarkManager, notificationFilter, auth }?: SessionConfig): Session; | ||
/** | ||
@@ -229,2 +381,3 @@ * Close all open sessions and other associated resources. You should | ||
* @protected | ||
* @returns {void} | ||
*/ | ||
@@ -235,3 +388,3 @@ _afterConstruction(): void; | ||
*/ | ||
_newSession({ defaultAccessMode, bookmarkOrBookmarks, database, reactive, impersonatedUser, fetchSize, bookmarkManager }: { | ||
_newSession({ defaultAccessMode, bookmarkOrBookmarks, database, reactive, impersonatedUser, fetchSize, bookmarkManager, notificationFilter, auth }: { | ||
defaultAccessMode: SessionMode; | ||
@@ -244,2 +397,4 @@ bookmarkOrBookmarks?: string | string[]; | ||
bookmarkManager?: BookmarkManager; | ||
notificationFilter?: NotificationFilter; | ||
auth?: AuthToken; | ||
}): Session; | ||
@@ -251,3 +406,4 @@ /** | ||
} | ||
export { Driver, READ, WRITE, SessionConfig }; | ||
export { Driver, READ, WRITE, routing, SessionConfig, QueryConfig }; | ||
export type { RoutingControl }; | ||
export default Driver; |
@@ -25,4 +25,6 @@ /** | ||
import { isPoint, Point } from './spatial-types'; | ||
import ResultSummary, { queryType, ServerInfo, Notification, NotificationPosition, Plan, ProfiledPlan, QueryStatistics, Stats } from './result-summary'; | ||
import ResultSummary, { queryType, ServerInfo, Notification, NotificationPosition, Plan, ProfiledPlan, QueryStatistics, Stats, NotificationSeverityLevel, NotificationCategory, notificationCategory, notificationSeverityLevel } from './result-summary'; | ||
import NotificationFilter, { notificationFilterDisabledCategory, NotificationFilterDisabledCategory, notificationFilterMinimumSeverityLevel, NotificationFilterMinimumSeverityLevel } from './notification-filter'; | ||
import Result, { QueryResult, ResultObserver } from './result'; | ||
import EagerResult from './result-eager'; | ||
import ConnectionProvider from './connection-provider'; | ||
@@ -37,5 +39,7 @@ import Connection from './connection'; | ||
import BookmarkManager, { BookmarkManagerConfig, bookmarkManager } from './bookmark-manager'; | ||
import { SessionConfig } from './driver'; | ||
import AuthTokenManager, { expirationBasedAuthTokenManager, staticAuthTokenManager, isStaticAuthTokenManger, AuthTokenAndExpiration } from './auth-token-manager'; | ||
import { SessionConfig, QueryConfig, RoutingControl, routing } from './driver'; | ||
import * as types from './types'; | ||
import * as json from './json'; | ||
import resultTransformers, { ResultTransformer } from './result-transformers'; | ||
import * as internal from './internal'; | ||
@@ -108,2 +112,3 @@ /** | ||
Result: typeof Result; | ||
EagerResult: typeof EagerResult; | ||
Transaction: typeof Transaction; | ||
@@ -139,8 +144,54 @@ ManagedTransaction: typeof ManagedTransaction; | ||
}; | ||
none: () => { | ||
scheme: string; | ||
}; | ||
custom: (principal: string, credentials: string, realm: string, scheme: string, parameters?: object | undefined) => any; | ||
}; | ||
bookmarkManager: typeof bookmarkManager; | ||
expirationBasedAuthTokenManager: typeof expirationBasedAuthTokenManager; | ||
routing: { | ||
WRITE: "WRITE"; | ||
READ: "READ"; | ||
}; | ||
resultTransformers: { | ||
eagerResultTransformer<Entries extends import("./record").Dict<PropertyKey, any> = import("./record").Dict<PropertyKey, any>>(): ResultTransformer<EagerResult<Entries>>; | ||
mappedResultTransformer<R = Record<import("./record").Dict<PropertyKey, any>, PropertyKey, import("./record").Dict<PropertyKey, number>>, T = { | ||
records: R[]; | ||
keys: string[]; | ||
summary: ResultSummary<Integer>; | ||
}>(config: { | ||
map?: ((rec: Record<import("./record").Dict<PropertyKey, any>, PropertyKey, import("./record").Dict<PropertyKey, number>>) => R | undefined) | undefined; | ||
collect?: ((records: R[], summary: ResultSummary<Integer>, keys: string[]) => T) | undefined; | ||
}): ResultTransformer<T>; | ||
}; | ||
notificationCategory: { | ||
UNKNOWN: "UNKNOWN"; | ||
HINT: "HINT"; | ||
UNRECOGNIZED: "UNRECOGNIZED"; | ||
UNSUPPORTED: "UNSUPPORTED"; | ||
PERFORMANCE: "PERFORMANCE"; | ||
DEPRECATION: "DEPRECATION"; | ||
GENERIC: "GENERIC"; | ||
}; | ||
notificationSeverityLevel: { | ||
WARNING: "WARNING"; | ||
INFORMATION: "INFORMATION"; | ||
UNKNOWN: "UNKNOWN"; | ||
}; | ||
notificationFilterDisabledCategory: { | ||
HINT: "HINT"; | ||
UNRECOGNIZED: "UNRECOGNIZED"; | ||
UNSUPPORTED: "UNSUPPORTED"; | ||
PERFORMANCE: "PERFORMANCE"; | ||
DEPRECATION: "DEPRECATION"; | ||
GENERIC: "GENERIC"; | ||
}; | ||
notificationFilterMinimumSeverityLevel: { | ||
WARNING: "WARNING"; | ||
INFORMATION: "INFORMATION"; | ||
OFF: "OFF"; | ||
}; | ||
}; | ||
export { newError, Neo4jError, isRetriableError, error, Integer, int, isInt, inSafeRange, toNumber, toString, internal, isPoint, Point, Date, DateTime, Duration, isDate, isDateTime, isDuration, isLocalDateTime, isLocalTime, isTime, LocalDateTime, LocalTime, Time, Node, isNode, Relationship, isRelationship, UnboundRelationship, isUnboundRelationship, Path, isPath, PathSegment, isPathSegment, Record, ResultSummary, queryType, ServerInfo, Notification, Plan, ProfiledPlan, QueryStatistics, Stats, Result, ConnectionProvider, Connection, Transaction, ManagedTransaction, TransactionPromise, Session, Driver, types, driver, json, auth, bookmarkManager }; | ||
export type { StandardDate, NumberOrInteger, NotificationPosition, QueryResult, ResultObserver, TransactionConfig, BookmarkManager, BookmarkManagerConfig, SessionConfig }; | ||
export { newError, Neo4jError, isRetriableError, error, Integer, int, isInt, inSafeRange, toNumber, toString, internal, isPoint, Point, Date, DateTime, Duration, isDate, isDateTime, isDuration, isLocalDateTime, isLocalTime, isTime, LocalDateTime, LocalTime, Time, Node, isNode, Relationship, isRelationship, UnboundRelationship, isUnboundRelationship, Path, isPath, PathSegment, isPathSegment, Record, ResultSummary, queryType, ServerInfo, Notification, Plan, ProfiledPlan, QueryStatistics, Stats, Result, EagerResult, ConnectionProvider, Connection, Transaction, ManagedTransaction, TransactionPromise, Session, Driver, types, driver, json, auth, bookmarkManager, expirationBasedAuthTokenManager, staticAuthTokenManager, isStaticAuthTokenManger, routing, resultTransformers, notificationCategory, notificationSeverityLevel, notificationFilterDisabledCategory, notificationFilterMinimumSeverityLevel }; | ||
export type { StandardDate, NumberOrInteger, NotificationPosition, QueryResult, ResultObserver, TransactionConfig, BookmarkManager, BookmarkManagerConfig, AuthTokenManager, AuthTokenAndExpiration, SessionConfig, QueryConfig, RoutingControl, ResultTransformer, NotificationCategory, NotificationSeverityLevel, NotificationFilter, NotificationFilterDisabledCategory, NotificationFilterMinimumSeverityLevel }; | ||
export default forExport; |
@@ -72,2 +72,14 @@ /** | ||
/** | ||
* Converts the Integer to it primitive value. | ||
* | ||
* @since 5.4.0 | ||
* @returns {bigint} | ||
* | ||
* @see {@link Integer#toBigInt} | ||
* @see {@link Integer#toInt} | ||
* @see {@link Integer#toNumber} | ||
* @see {@link Integer#toString} | ||
*/ | ||
valueOf(): bigint; | ||
/** | ||
* Gets the high 32 bits as a signed integer. | ||
@@ -74,0 +86,0 @@ * @returns {number} Signed high bits |
@@ -22,2 +22,3 @@ /** | ||
import ConnectionProvider from '../connection-provider'; | ||
import { AuthToken } from '../types'; | ||
/** | ||
@@ -76,2 +77,4 @@ * @private | ||
private readonly _onDatabaseNameResolved?; | ||
private readonly _auth?; | ||
private _closed; | ||
/** | ||
@@ -87,4 +90,5 @@ * @constructor | ||
* @property {function():Promise<Bookmarks>} params.getConnectionAcquistionBookmarks - called for getting Bookmarks for acquiring connections | ||
* @property {AuthToken} params.auth - the target auth for the to-be-acquired connection | ||
*/ | ||
constructor({ mode, database, bookmarks, connectionProvider, impersonatedUser, onDatabaseNameResolved, getConnectionAcquistionBookmarks }?: { | ||
constructor({ mode, database, bookmarks, connectionProvider, impersonatedUser, onDatabaseNameResolved, getConnectionAcquistionBookmarks, auth }?: { | ||
mode?: string; | ||
@@ -97,2 +101,3 @@ database?: string; | ||
getConnectionAcquistionBookmarks?: () => Promise<Bookmarks>; | ||
auth?: AuthToken; | ||
}); | ||
@@ -99,0 +104,0 @@ mode(): string | undefined; |
@@ -34,2 +34,4 @@ /** | ||
declare const BOLT_PROTOCOL_V5_0: number; | ||
export { FETCH_ALL, ACCESS_MODE_READ, ACCESS_MODE_WRITE, DEFAULT_CONNECTION_TIMEOUT_MILLIS, DEFAULT_POOL_ACQUISITION_TIMEOUT, DEFAULT_POOL_MAX_SIZE, BOLT_PROTOCOL_V1, BOLT_PROTOCOL_V2, BOLT_PROTOCOL_V3, BOLT_PROTOCOL_V4_0, BOLT_PROTOCOL_V4_1, BOLT_PROTOCOL_V4_2, BOLT_PROTOCOL_V4_3, BOLT_PROTOCOL_V4_4, BOLT_PROTOCOL_V5_0 }; | ||
declare const BOLT_PROTOCOL_V5_1: number; | ||
declare const BOLT_PROTOCOL_V5_2: number; | ||
export { FETCH_ALL, ACCESS_MODE_READ, ACCESS_MODE_WRITE, DEFAULT_CONNECTION_TIMEOUT_MILLIS, DEFAULT_POOL_ACQUISITION_TIMEOUT, DEFAULT_POOL_MAX_SIZE, BOLT_PROTOCOL_V1, BOLT_PROTOCOL_V2, BOLT_PROTOCOL_V3, BOLT_PROTOCOL_V4_0, BOLT_PROTOCOL_V4_1, BOLT_PROTOCOL_V4_2, BOLT_PROTOCOL_V4_3, BOLT_PROTOCOL_V4_4, BOLT_PROTOCOL_V5_0, BOLT_PROTOCOL_V5_1, BOLT_PROTOCOL_V5_2 }; |
@@ -24,4 +24,4 @@ /** | ||
* Will be called on every record that comes in and transform a raw record | ||
* to a Object. If user-provided observer is present, pass transformed record | ||
* to it's onNext method, otherwise, push to record que. | ||
* to an Object. If user-provided observer is present, pass transformed record | ||
* to its onNext method; otherwise push to record que. | ||
* @param {Array} rawRecord - An array with the raw record | ||
@@ -33,3 +33,3 @@ */ | ||
* If user-provided observer is present, pass the error | ||
* to it's onError method, otherwise set instance variable _error. | ||
* to its onError method, otherwise set instance variable _error. | ||
* @param {Object} error - An error object | ||
@@ -42,3 +42,2 @@ */ | ||
* Interface to observe updates on the Result which is being produced. | ||
* | ||
*/ | ||
@@ -53,3 +52,3 @@ interface ResultObserver { | ||
/** | ||
* Receive the each record present on the {@link @Result} | ||
* Receive each record present on the {@link @Result} | ||
* @param {Record} record The {@link Record} produced | ||
@@ -110,3 +109,3 @@ */ | ||
* @param {function(record: Object)} observer.onNext - Handle records, one by one. | ||
* @param {function(metadata: Object)} observer.onCompleted - Handle stream tail, the metadata. | ||
* @param {function(metadata: Object)} observer.onCompleted - Handle stream tail, the summary. | ||
* @param {function(error: Object)} observer.onError - Handle errors, should always be provided. | ||
@@ -113,0 +112,0 @@ */ |
@@ -80,2 +80,9 @@ import { NumberOrInteger } from '../graph-types'; | ||
declare function isString(str: any): str is string; | ||
export { isEmptyObjectOrNull, isObject, isString, assertObject, assertString, assertNumber, assertNumberOrInteger, assertValidDate, validateQueryAndParameters, ENCRYPTION_ON, ENCRYPTION_OFF }; | ||
/** | ||
* Verifies if object are the equals | ||
* @param {unknown} a | ||
* @param {unknown} b | ||
* @returns {boolean} | ||
*/ | ||
declare function equals(a: unknown, b: unknown): boolean; | ||
export { isEmptyObjectOrNull, isObject, isString, assertObject, assertString, assertNumber, assertNumberOrInteger, assertValidDate, validateQueryAndParameters, equals, ENCRYPTION_ON, ENCRYPTION_OFF }; |
@@ -172,3 +172,23 @@ /** | ||
} | ||
type NotificationSeverityLevel = 'WARNING' | 'INFORMATION' | 'UNKNOWN'; | ||
/** | ||
* @typedef {'WARNING' | 'INFORMATION' | 'UNKNOWN'} NotificationSeverityLevel | ||
*/ | ||
/** | ||
* Constants that represents the Severity level in the {@link Notification} | ||
*/ | ||
declare const notificationSeverityLevel: { | ||
[key in NotificationSeverityLevel]: key; | ||
}; | ||
type NotificationCategory = 'HINT' | 'UNRECOGNIZED' | 'UNSUPPORTED' | 'PERFORMANCE' | 'DEPRECATION' | 'GENERIC' | 'UNKNOWN'; | ||
/** | ||
* @typedef {'HINT' | 'UNRECOGNIZED' | 'UNSUPPORTED' |'PERFORMANCE' | 'DEPRECATION' | 'GENERIC' | 'UNKNOWN'} NotificationCategory | ||
*/ | ||
/** | ||
* Constants that represents the Category in the {@link Notification} | ||
*/ | ||
declare const notificationCategory: { | ||
[key in NotificationCategory]: key; | ||
}; | ||
/** | ||
* Class for Cypher notifications | ||
@@ -183,2 +203,6 @@ * @access public | ||
position: NotificationPosition | {}; | ||
severityLevel: NotificationSeverityLevel; | ||
category: NotificationCategory; | ||
rawSeverityLevel: string; | ||
rawCategory?: string; | ||
/** | ||
@@ -219,4 +243,4 @@ * Create a Notification instance | ||
}; | ||
export { queryType, ServerInfo, Notification, Plan, ProfiledPlan, QueryStatistics, Stats }; | ||
export type { NotificationPosition }; | ||
export { queryType, ServerInfo, Notification, Plan, ProfiledPlan, QueryStatistics, Stats, notificationSeverityLevel, notificationCategory }; | ||
export type { NotificationPosition, NotificationSeverityLevel, NotificationCategory }; | ||
export default ResultSummary; |
@@ -25,3 +25,3 @@ /** | ||
import ConnectionProvider from './connection-provider'; | ||
import { Query, SessionMode } from './types'; | ||
import { AuthToken, Query, SessionMode } from './types'; | ||
import Connection from './connection'; | ||
@@ -33,2 +33,3 @@ import { NumberOrInteger } from './graph-types'; | ||
import { Dict } from './record'; | ||
import NotificationFilter from './notification-filter'; | ||
type ConnectionConsumer = (connection: Connection | null) => any | undefined | Promise<any> | Promise<undefined>; | ||
@@ -66,2 +67,3 @@ type TransactionWork<T> = (tx: Transaction) => Promise<T> | T; | ||
private readonly _bookmarkManager?; | ||
private readonly _notificationFilter?; | ||
/** | ||
@@ -79,4 +81,6 @@ * @constructor | ||
* @param {string} args.impersonatedUser - The username which the user wants to impersonate for the duration of the session. | ||
* @param {AuthToken} args.auth - the target auth for the to-be-acquired connection | ||
* @param {NotificationFilter} args.notificationFilter - The notification filter used for this session. | ||
*/ | ||
constructor({ mode, connectionProvider, bookmarks, database, config, reactive, fetchSize, impersonatedUser, bookmarkManager }: { | ||
constructor({ mode, connectionProvider, bookmarks, database, config, reactive, fetchSize, impersonatedUser, bookmarkManager, notificationFilter, auth }: { | ||
mode: SessionMode; | ||
@@ -91,2 +95,4 @@ connectionProvider: ConnectionProvider; | ||
bookmarkManager?: BookmarkManager; | ||
notificationFilter?: NotificationFilter; | ||
auth?: AuthToken; | ||
}); | ||
@@ -131,5 +137,6 @@ /** | ||
* | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link Session#lastBookmarks} instead. | ||
* @deprecated This method will be removed in version 6.0. Please, use Session#lastBookmarks instead. | ||
* | ||
* @return {string[]} A reference to a previous transaction. | ||
* @see {@link Session#lastBookmarks} | ||
*/ | ||
@@ -152,3 +159,3 @@ lastBookmark(): string[]; | ||
* | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link Session#executeRead} instead. | ||
* @deprecated This method will be removed in version 6.0. Please, use Session#executeRead instead. | ||
* | ||
@@ -160,2 +167,3 @@ * @param {function(tx: Transaction): Promise} transactionWork - Callback that executes operations against | ||
* function or commit fails. | ||
* @see {@link Session#executeRead} | ||
*/ | ||
@@ -171,3 +179,3 @@ readTransaction<T>(transactionWork: TransactionWork<T>, transactionConfig?: TransactionConfig): Promise<T>; | ||
* | ||
* @deprecated This method will be removed in version 6.0. Please, use {@link Session#executeWrite} instead. | ||
* @deprecated This method will be removed in version 6.0. Please, use Session#executeWrite instead. | ||
* | ||
@@ -179,2 +187,3 @@ * @param {function(tx: Transaction): Promise} transactionWork - Callback that executes operations against | ||
* function or commit fails. | ||
* @see {@link Session#executeWrite} | ||
*/ | ||
@@ -181,0 +190,0 @@ writeTransaction<T>(transactionWork: TransactionWork<T>, transactionConfig?: TransactionConfig): Promise<T>; |
@@ -23,2 +23,3 @@ /** | ||
import { TxConfig } from './internal/tx-config'; | ||
import NotificationFilter from './notification-filter'; | ||
/** | ||
@@ -43,12 +44,14 @@ * Represents a {@link Promise<Transaction>} object and a {@link Transaction} object. | ||
* @constructor | ||
* @param {ConnectionHolder} connectionHolder - the connection holder to get connection from. | ||
* @param {function()} onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} onConnection - Function to be called when a connection is obtained to ensure the connection | ||
* @param {object} args | ||
* @param {ConnectionHolder} args.connectionHolder - the connection holder to get connection from. | ||
* @param {function()} args.onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} args.onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} args.onConnection - Function to be called when a connection is obtained to ensure the connection | ||
* is not yet released. | ||
* @param {boolean} reactive whether this transaction generates reactive streams | ||
* @param {number} fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {boolean} args.reactive whether this transaction generates reactive streams | ||
* @param {number} args.fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} args.impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {NotificationFilter} args.notificationFilter - The notification filter used for this transaction. | ||
*/ | ||
constructor({ connectionHolder, onClose, onBookmarks, onConnection, reactive, fetchSize, impersonatedUser, highRecordWatermark, lowRecordWatermark }: { | ||
constructor({ connectionHolder, onClose, onBookmarks, onConnection, reactive, fetchSize, impersonatedUser, highRecordWatermark, lowRecordWatermark, notificationFilter }: { | ||
connectionHolder: ConnectionHolder; | ||
@@ -63,2 +66,3 @@ onClose: () => void; | ||
lowRecordWatermark: number; | ||
notificationFilter?: NotificationFilter; | ||
}); | ||
@@ -65,0 +69,0 @@ /** |
@@ -26,2 +26,3 @@ /** | ||
import { Dict } from './record'; | ||
import NotificationFilter from './notification-filter'; | ||
/** | ||
@@ -49,16 +50,19 @@ * Represents a transaction in the Neo4j database. | ||
private _acceptActive; | ||
private readonly _notificationFilter?; | ||
/** | ||
* @constructor | ||
* @param {ConnectionHolder} connectionHolder - the connection holder to get connection from. | ||
* @param {function()} onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} onConnection - Function to be called when a connection is obtained to ensure the conneciton | ||
* @param {object} args | ||
* @param {ConnectionHolder} args.connectionHolder - the connection holder to get connection from. | ||
* @param {function()} args.onClose - Function to be called when transaction is committed or rolled back. | ||
* @param {function(bookmarks: Bookmarks)} args.onBookmarks callback invoked when new bookmark is produced. | ||
* @param {function()} args.onConnection - Function to be called when a connection is obtained to ensure the conneciton | ||
* is not yet released. | ||
* @param {boolean} reactive whether this transaction generates reactive streams | ||
* @param {number} fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {number} highRecordWatermark - The high watermark for the record buffer. | ||
* @param {number} lowRecordWatermark - The low watermark for the record buffer. | ||
* @param {boolean} args.reactive whether this transaction generates reactive streams | ||
* @param {number} args.fetchSize - the record fetch size in each pulling batch. | ||
* @param {string} args.impersonatedUser - The name of the user which should be impersonated for the duration of the session. | ||
* @param {number} args.highRecordWatermark - The high watermark for the record buffer. | ||
* @param {number} args.lowRecordWatermark - The low watermark for the record buffer. | ||
* @param {NotificationFilter} args.notificationFilter - The notification filter used for this transaction. | ||
*/ | ||
constructor({ connectionHolder, onClose, onBookmarks, onConnection, reactive, fetchSize, impersonatedUser, highRecordWatermark, lowRecordWatermark }: { | ||
constructor({ connectionHolder, onClose, onBookmarks, onConnection, reactive, fetchSize, impersonatedUser, highRecordWatermark, lowRecordWatermark, notificationFilter }: { | ||
connectionHolder: ConnectionHolder; | ||
@@ -73,2 +77,3 @@ onClose: () => void; | ||
lowRecordWatermark: number; | ||
notificationFilter?: NotificationFilter; | ||
}); | ||
@@ -75,0 +80,0 @@ /** |
@@ -40,3 +40,3 @@ /** | ||
scheme: string; | ||
principal: string; | ||
principal?: string; | ||
credentials: string; | ||
@@ -43,0 +43,0 @@ realm?: string; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
626528
90
14949
0