neo4j-driver-core
Advanced tools
Comparing version 5.10.0 to 5.11.0
@@ -726,3 +726,4 @@ "use strict"; | ||
notificationFilter: notificationFilter, | ||
auth: auth | ||
auth: auth, | ||
log: this._log | ||
}); | ||
@@ -729,0 +730,0 @@ }; |
@@ -775,2 +775,3 @@ "use strict"; | ||
* @param {boolean} [opts.strictStringValidation=false] Enable strict validation generated Integer. | ||
* @param {boolean} [opts.ceilFloat=false] Enable round up float to the nearest Integer. | ||
* @returns {!Integer} | ||
@@ -785,2 +786,5 @@ * @expose | ||
if (typeof val === 'number') { | ||
if (opts.ceilFloat === true) { | ||
val = Math.ceil(val); | ||
} | ||
return Integer.fromNumber(val); | ||
@@ -967,2 +971,3 @@ } | ||
* @param {boolean} [opts.strictStringValidation=false] Enable strict validation generated Integer. | ||
* @param {boolean} [opts.ceilFloat=false] Enable round up float to the nearest Integer. | ||
* @return {Integer} - An object of type Integer. | ||
@@ -969,0 +974,0 @@ */ |
@@ -59,5 +59,5 @@ "use strict"; | ||
*/ | ||
function TxConfig(config) { | ||
function TxConfig(config, log) { | ||
assertValidConfig(config); | ||
this.timeout = extractTimeout(config); | ||
this.timeout = extractTimeout(config, log); | ||
this.metadata = extractMetadata(config); | ||
@@ -86,6 +86,10 @@ } | ||
*/ | ||
function extractTimeout(config) { | ||
function extractTimeout(config, log) { | ||
if (util.isObject(config) && config.timeout != null) { | ||
util.assertNumberOrInteger(config.timeout, 'Transaction timeout'); | ||
var timeout = (0, integer_1.int)(config.timeout); | ||
if (isTimeoutFloat(config) && (log === null || log === void 0 ? void 0 : log.isInfoEnabled()) === true) { | ||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
log === null || log === void 0 ? void 0 : log.info("Transaction timeout expected to be an integer, got: ".concat(config.timeout, ". The value will be rounded up.")); | ||
} | ||
var timeout = (0, integer_1.int)(config.timeout, { ceilFloat: true }); | ||
if (timeout.isNegative()) { | ||
@@ -98,2 +102,5 @@ throw (0, error_1.newError)('Transaction timeout should not be negative'); | ||
} | ||
function isTimeoutFloat(config) { | ||
return typeof config.timeout === 'number' && !Number.isInteger(config.timeout); | ||
} | ||
/** | ||
@@ -100,0 +107,0 @@ * @return {object|null} |
@@ -206,3 +206,3 @@ "use strict"; | ||
* @public | ||
* @returns {PeekableAsyncIterator<Record<RecordShape>, ResultSummary>} The async iterator for the Results | ||
* @returns {PeekableAsyncIterator<Record<R>, ResultSummary>} The async iterator for the Results | ||
*/ | ||
@@ -209,0 +209,0 @@ Result.prototype[Symbol.asyncIterator] = function () { |
@@ -121,3 +121,3 @@ "use strict"; | ||
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, notificationFilter = _a.notificationFilter, auth = _a.auth; | ||
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, log = _a.log; | ||
this._mode = mode; | ||
@@ -162,2 +162,3 @@ this._database = database; | ||
this._notificationFilter = notificationFilter; | ||
this._log = log; | ||
} | ||
@@ -179,3 +180,3 @@ /** | ||
var autoCommitTxConfig = (transactionConfig != null) | ||
? new tx_config_1.TxConfig(transactionConfig) | ||
? new tx_config_1.TxConfig(transactionConfig, this._log) | ||
: tx_config_1.TxConfig.empty(); | ||
@@ -279,3 +280,3 @@ var result = this._run(validatedQuery, params, function (connection) { return __awaiter(_this, void 0, void 0, function () { | ||
if (arg != null) { | ||
txConfig = new tx_config_1.TxConfig(arg); | ||
txConfig = new tx_config_1.TxConfig(arg, this._log); | ||
} | ||
@@ -382,3 +383,3 @@ return this._beginTransaction(this._mode, txConfig); | ||
Session.prototype.readTransaction = function (transactionWork, transactionConfig) { | ||
var config = new tx_config_1.TxConfig(transactionConfig); | ||
var config = new tx_config_1.TxConfig(transactionConfig, this._log); | ||
return this._runTransaction(constants_1.ACCESS_MODE_READ, config, transactionWork); | ||
@@ -404,3 +405,3 @@ }; | ||
Session.prototype.writeTransaction = function (transactionWork, transactionConfig) { | ||
var config = new tx_config_1.TxConfig(transactionConfig); | ||
var config = new tx_config_1.TxConfig(transactionConfig, this._log); | ||
return this._runTransaction(constants_1.ACCESS_MODE_WRITE, config, transactionWork); | ||
@@ -427,3 +428,3 @@ }; | ||
Session.prototype.executeRead = function (transactionWork, transactionConfig) { | ||
var config = new tx_config_1.TxConfig(transactionConfig); | ||
var config = new tx_config_1.TxConfig(transactionConfig, this._log); | ||
return this._executeInTransaction(constants_1.ACCESS_MODE_READ, config, transactionWork); | ||
@@ -446,3 +447,3 @@ }; | ||
Session.prototype.executeWrite = function (transactionWork, transactionConfig) { | ||
var config = new tx_config_1.TxConfig(transactionConfig); | ||
var config = new tx_config_1.TxConfig(transactionConfig, this._log); | ||
return this._executeInTransaction(constants_1.ACCESS_MODE_WRITE, config, transactionWork); | ||
@@ -449,0 +450,0 @@ }; |
{ | ||
"name": "neo4j-driver-core", | ||
"version": "5.10.0", | ||
"version": "5.11.0", | ||
"description": "Internals of neo4j-driver", | ||
@@ -48,3 +48,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "7198b57348b8490e350835f49051b62ac0ae9e95" | ||
"gitHead": "f20b9a86650000e8366b22e57520512909b5089f" | ||
} |
@@ -62,2 +62,3 @@ /** | ||
auth?: AuthToken; | ||
log: Logger; | ||
}) => Session; | ||
@@ -64,0 +65,0 @@ type CreateQueryExecutor = (createSession: (config: { |
@@ -23,3 +23,3 @@ /** | ||
import { StandardDate, NumberOrInteger, Node, isNode, Relationship, isRelationship, UnboundRelationship, isUnboundRelationship, Path, isPath, PathSegment, isPathSegment } from './graph-types'; | ||
import Record from './record'; | ||
import Record, { RecordShape } from './record'; | ||
import { isPoint, Point } from './spatial-types'; | ||
@@ -155,4 +155,4 @@ import ResultSummary, { queryType, ServerInfo, Notification, NotificationPosition, Plan, ProfiledPlan, QueryStatistics, Stats, NotificationSeverityLevel, NotificationCategory, notificationCategory, notificationSeverityLevel } from './result-summary'; | ||
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 = { | ||
eagerResultTransformer<Entries extends RecordShape<PropertyKey, any> = RecordShape<PropertyKey, any>>(): ResultTransformer<EagerResult<Entries>>; | ||
mappedResultTransformer<R = Record<RecordShape<PropertyKey, any>, PropertyKey, RecordShape<PropertyKey, number>>, T = { | ||
records: R[]; | ||
@@ -162,3 +162,3 @@ keys: string[]; | ||
}>(config: { | ||
map?: ((rec: Record<import("./record").Dict<PropertyKey, any>, PropertyKey, import("./record").Dict<PropertyKey, number>>) => R | undefined) | undefined; | ||
map?: ((rec: Record<RecordShape<PropertyKey, any>, PropertyKey, RecordShape<PropertyKey, number>>) => R | undefined) | undefined; | ||
collect?: ((records: R[], summary: ResultSummary<Integer>, keys: string[]) => T) | undefined; | ||
@@ -196,3 +196,3 @@ }): ResultTransformer<T>; | ||
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, Config, SessionConfig, QueryConfig, RoutingControl, ResultTransformer, NotificationCategory, NotificationSeverityLevel, NotificationFilter, NotificationFilterDisabledCategory, NotificationFilterMinimumSeverityLevel }; | ||
export type { StandardDate, NumberOrInteger, NotificationPosition, QueryResult, ResultObserver, TransactionConfig, BookmarkManager, BookmarkManagerConfig, AuthTokenManager, AuthTokenAndExpiration, Config, SessionConfig, QueryConfig, RoutingControl, RecordShape, ResultTransformer, NotificationCategory, NotificationSeverityLevel, NotificationFilter, NotificationFilterDisabledCategory, NotificationFilterMinimumSeverityLevel }; | ||
export default forExport; |
@@ -366,2 +366,3 @@ /** | ||
* @param {boolean} [opts.strictStringValidation=false] Enable strict validation generated Integer. | ||
* @param {boolean} [opts.ceilFloat=false] Enable round up float to the nearest Integer. | ||
* @returns {!Integer} | ||
@@ -372,2 +373,3 @@ * @expose | ||
strictStringValidation?: boolean; | ||
ceilFloat?: boolean; | ||
}): Integer; | ||
@@ -411,2 +413,3 @@ /** | ||
* @param {boolean} [opts.strictStringValidation=false] Enable strict validation generated Integer. | ||
* @param {boolean} [opts.ceilFloat=false] Enable round up float to the nearest Integer. | ||
* @return {Integer} - An object of type Integer. | ||
@@ -413,0 +416,0 @@ */ |
@@ -20,2 +20,3 @@ /** | ||
import Integer from '../integer'; | ||
import { Logger } from './logger'; | ||
/** | ||
@@ -34,3 +35,3 @@ * Internal holder of the transaction configuration. | ||
*/ | ||
constructor(config: any); | ||
constructor(config: any, log?: Logger); | ||
/** | ||
@@ -37,0 +38,0 @@ * Get an empty config object. |
@@ -19,7 +19,7 @@ /** | ||
*/ | ||
type Dict<Key extends PropertyKey = PropertyKey, Value = any> = { | ||
type RecordShape<Key extends PropertyKey = PropertyKey, Value = any> = { | ||
[K in Key]: Value; | ||
}; | ||
type Visitor<Entries extends Dict = Dict, Key extends keyof Entries = keyof Entries> = MapVisitor<void, Entries, Key>; | ||
type MapVisitor<ReturnType, Entries extends Dict = Dict, Key extends keyof Entries = keyof Entries> = (value: Entries[Key], key: Key, record: Record<Entries>) => ReturnType; | ||
type Visitor<Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries> = MapVisitor<void, Entries, Key>; | ||
type MapVisitor<ReturnType, Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries> = (value: Entries[Key], key: Key, record: Record<Entries>) => ReturnType; | ||
/** | ||
@@ -44,3 +44,3 @@ * Records make up the contents of the {@link Result}, and is how you access | ||
*/ | ||
declare class Record<Entries extends Dict = Dict, Key extends keyof Entries = keyof Entries, FieldLookup extends Dict<keyof Entries, number> = Dict<keyof Entries, number>> { | ||
declare class Record<Entries extends RecordShape = RecordShape, Key extends keyof Entries = keyof Entries, FieldLookup extends RecordShape<keyof Entries, number> = RecordShape<keyof Entries, number>> { | ||
keys: Key[]; | ||
@@ -120,2 +120,2 @@ length: number; | ||
export default Record; | ||
export type { Dict }; | ||
export type { RecordShape }; |
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
import Record, { Dict } from './record'; | ||
import Record, { RecordShape } from './record'; | ||
import ResultSummary from './result-summary'; | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
export default class EagerResult<Entries extends Dict = Dict> { | ||
export default class EagerResult<Entries extends RecordShape = RecordShape> { | ||
keys: string[]; | ||
@@ -28,0 +28,0 @@ records: Array<Record<Entries>>; |
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
import Record, { Dict } from './record'; | ||
import Record, { RecordShape } from './record'; | ||
import Result from './result'; | ||
@@ -54,3 +54,3 @@ import EagerResult from './result-eager'; | ||
*/ | ||
eagerResultTransformer<Entries extends Dict = Dict>(): ResultTransformer<EagerResult<Entries>>; | ||
eagerResultTransformer<Entries extends RecordShape = RecordShape>(): ResultTransformer<EagerResult<Entries>>; | ||
/** | ||
@@ -57,0 +57,0 @@ * Creates a {@link ResultTransformer} which maps the {@link Record} in the result and collects it |
@@ -20,3 +20,3 @@ /** | ||
import ResultSummary from './result-summary'; | ||
import Record, { Dict } from './record'; | ||
import Record, { RecordShape } from './record'; | ||
import { Query, PeekableAsyncIterator } from './types'; | ||
@@ -28,4 +28,4 @@ import { observer, connectionHolder } from './internal'; | ||
*/ | ||
interface QueryResult<RecordShape extends Dict = Dict> { | ||
records: Array<Record<RecordShape>>; | ||
interface QueryResult<R extends RecordShape = RecordShape> { | ||
records: Array<Record<R>>; | ||
summary: ResultSummary; | ||
@@ -37,3 +37,3 @@ } | ||
*/ | ||
interface ResultObserver<RecordShape extends Dict = Dict> { | ||
interface ResultObserver<R extends RecordShape = RecordShape> { | ||
/** | ||
@@ -49,3 +49,3 @@ * Receive the keys present on the record whenever this information is available | ||
*/ | ||
onNext?: (record: Record<RecordShape>) => void; | ||
onNext?: (record: Record<R>) => void; | ||
/** | ||
@@ -57,3 +57,3 @@ * Called when the result is fully received | ||
/** | ||
* Called when some error occurs during the result proccess or query execution | ||
* Called when some error occurs during the result processing or query execution | ||
* @param {Error} error The error ocurred | ||
@@ -70,3 +70,3 @@ */ | ||
*/ | ||
declare class Result<RecordShape extends Dict = Dict> implements Promise<QueryResult<RecordShape>> { | ||
declare class Result<R extends RecordShape = RecordShape> implements Promise<QueryResult<R>> { | ||
private readonly _stack; | ||
@@ -128,5 +128,5 @@ private readonly _streamObserverPromise; | ||
* @public | ||
* @returns {PeekableAsyncIterator<Record<RecordShape>, ResultSummary>} The async iterator for the Results | ||
* @returns {PeekableAsyncIterator<Record<R>, ResultSummary>} The async iterator for the Results | ||
*/ | ||
[Symbol.asyncIterator](): PeekableAsyncIterator<Record<RecordShape>, ResultSummary>; | ||
[Symbol.asyncIterator](): PeekableAsyncIterator<Record<R>, ResultSummary>; | ||
/** | ||
@@ -142,3 +142,3 @@ * Waits for all results and calls the passed in function with the results. | ||
*/ | ||
then<TResult1 = QueryResult<RecordShape>, TResult2 = never>(onFulfilled?: ((value: QueryResult<RecordShape>) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>; | ||
then<TResult1 = QueryResult<R>, TResult2 = never>(onFulfilled?: ((value: QueryResult<R>) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>; | ||
/** | ||
@@ -152,3 +152,3 @@ * Catch errors when using promises. | ||
*/ | ||
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<QueryResult<RecordShape> | TResult>; | ||
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<QueryResult<R> | TResult>; | ||
/** | ||
@@ -162,3 +162,3 @@ * Called when finally the result is done | ||
[Symbol.toStringTag]: string; | ||
finally(onfinally?: (() => void) | null): Promise<QueryResult<RecordShape>>; | ||
finally(onfinally?: (() => void) | null): Promise<QueryResult<R>>; | ||
/** | ||
@@ -175,3 +175,3 @@ * Stream records to observer as they come in, this is a more efficient method | ||
*/ | ||
subscribe(observer: ResultObserver<RecordShape>): void; | ||
subscribe(observer: ResultObserver<R>): void; | ||
/** | ||
@@ -178,0 +178,0 @@ * Check if this result is active, i.e., neither a summary nor an error has been received by the result. |
@@ -31,4 +31,5 @@ /** | ||
import BookmarkManager from './bookmark-manager'; | ||
import { Dict } from './record'; | ||
import { RecordShape } from './record'; | ||
import NotificationFilter from './notification-filter'; | ||
import { Logger } from './internal/logger'; | ||
type ConnectionConsumer = (connection: Connection | null) => any | undefined | Promise<any> | Promise<undefined>; | ||
@@ -67,2 +68,3 @@ type TransactionWork<T> = (tx: Transaction) => Promise<T> | T; | ||
private readonly _notificationFilter?; | ||
private readonly _log?; | ||
/** | ||
@@ -83,3 +85,3 @@ * @constructor | ||
*/ | ||
constructor({ mode, connectionProvider, bookmarks, database, config, reactive, fetchSize, impersonatedUser, bookmarkManager, notificationFilter, auth }: { | ||
constructor({ mode, connectionProvider, bookmarks, database, config, reactive, fetchSize, impersonatedUser, bookmarkManager, notificationFilter, auth, log }: { | ||
mode: SessionMode; | ||
@@ -96,2 +98,3 @@ connectionProvider: ConnectionProvider; | ||
auth?: AuthToken; | ||
log: Logger; | ||
}); | ||
@@ -109,3 +112,3 @@ /** | ||
*/ | ||
run<RecordShape extends Dict = Dict>(query: Query, parameters?: any, transactionConfig?: TransactionConfig): Result<RecordShape>; | ||
run<R extends RecordShape = RecordShape>(query: Query, parameters?: any, transactionConfig?: TransactionConfig): Result<R>; | ||
_run(query: Query, parameters: any, customRunner: ConnectionConsumer): Result; | ||
@@ -112,0 +115,0 @@ _acquireConnection(connectionConsumer: ConnectionConsumer): Promise<Connection>; |
@@ -22,3 +22,3 @@ /** | ||
import { Query } from './types'; | ||
import { Dict } from './record'; | ||
import { RecordShape } from './record'; | ||
/** | ||
@@ -49,4 +49,4 @@ * Represents a transaction that is managed by the transaction executor. | ||
*/ | ||
run<RecordShape extends Dict = Dict>(query: Query, parameters?: any): Result<RecordShape>; | ||
run<R extends RecordShape = RecordShape>(query: Query, parameters?: any): Result<R>; | ||
} | ||
export default ManagedTransaction; |
@@ -25,3 +25,3 @@ /** | ||
import { Query } from './types'; | ||
import { Dict } from './record'; | ||
import { RecordShape } from './record'; | ||
import NotificationFilter from './notification-filter'; | ||
@@ -96,3 +96,3 @@ /** | ||
*/ | ||
run<RecordShape extends Dict = Dict>(query: Query, parameters?: any): Result<RecordShape>; | ||
run<R extends RecordShape = RecordShape>(query: Query, parameters?: any): Result<R>; | ||
/** | ||
@@ -99,0 +99,0 @@ * Commits the transaction and returns the result. |
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
652977
15552