Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bolt-connection/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = {
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: 'node'
testEnvironment: 'node',

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
Expand Down Expand Up @@ -172,9 +172,9 @@ module.exports = {
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: {
// "^.+\\.(ts|tsx)$": "ts-jest"
// }
transform: {
'^.+\\.(ts|tsx|js)$': 'ts-jest'
}
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
Expand Down
1 change: 1 addition & 0 deletions bolt-connection/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions bolt-connection/src/bolt/bolt-protocol-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@ export default class BoltProtocol {
* @constructor
* @param {Object} server the server informatio.
* @param {Chunker} chunker the chunker.
* @param {boolean} disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
* @param {Object} packstreamConfig Packstream configuration
* @param {boolean} packstreamConfig.disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
* @param {boolean} packstreamConfig.useBigInt if this connection should convert all received integers to native BigInt numbers.
* @param {CreateResponseHandler} createResponseHandler Function which creates the response handler
* @param {Logger} log the logger
* @param {OnProtocolError} onProtocolError handles protocol errors
*/
constructor (
server,
chunker,
disableLosslessIntegers,
{ disableLosslessIntegers, useBigInt } = {},
createResponseHandler = () => null,
log,
onProtocolError
) {
this._server = server || {}
this._chunker = chunker
this._packer = this._createPacker(chunker)
this._unpacker = this._createUnpacker(disableLosslessIntegers)
this._unpacker = this._createUnpacker(disableLosslessIntegers, useBigInt)
this._responseHandler = createResponseHandler(this)
this._log = log
this._onProtocolError = onProtocolError
Expand Down Expand Up @@ -317,8 +319,8 @@ export default class BoltProtocol {
return new v1.Packer(chunker)
}

_createUnpacker (disableLosslessIntegers) {
return new v1.Unpacker(disableLosslessIntegers)
_createUnpacker (disableLosslessIntegers, useBigInt) {
return new v1.Unpacker(disableLosslessIntegers, useBigInt)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions bolt-connection/src/bolt/bolt-protocol-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default class BoltProtocol extends BoltProtocolV1 {
return new v2.Packer(chunker)
}

_createUnpacker (disableLosslessIntegers) {
return new v2.Unpacker(disableLosslessIntegers)
_createUnpacker (disableLosslessIntegers, useBigInt) {
return new v2.Unpacker(disableLosslessIntegers, useBigInt)
}

get version () {
Expand Down
8 changes: 5 additions & 3 deletions bolt-connection/src/bolt/bolt-protocol-v4x1.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default class BoltProtocol extends BoltProtocolV4 {
* @constructor
* @param {Object} server the server informatio.
* @param {Chunker} chunker the chunker.
* @param {boolean} disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
* @param {Object} packstreamConfig Packstream configuration
* @param {boolean} packstreamConfig.disableLosslessIntegers if this connection should convert all received integers to native JS numbers.
* @param {boolean} packstreamConfig.useBigInt if this connection should convert all received integers to native BigInt numbers.
* @param {CreateResponseHandler} createResponseHandler Function which creates the response handler
* @param {Logger} log the logger
* @param {Object} serversideRouting
Expand All @@ -39,7 +41,7 @@ export default class BoltProtocol extends BoltProtocolV4 {
constructor (
server,
chunker,
disableLosslessIntegers,
packstreamConfig,
createResponseHandler = () => null,
log,
onProtocolError,
Expand All @@ -48,7 +50,7 @@ export default class BoltProtocol extends BoltProtocolV4 {
super(
server,
chunker,
disableLosslessIntegers,
packstreamConfig,
createResponseHandler,
log,
onProtocolError
Expand Down
20 changes: 11 additions & 9 deletions bolt-connection/src/bolt/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import ResponseHandler from './response-handler'
* @param {Logger} config.log The logger
* @param {ResponseHandler~Observer} config.observer Observer
* @param {boolean} config.disableLosslessIntegers Disable the lossless integers
* @param {boolean} packstreamConfig.useBigInt if this connection should convert all received integers to native BigInt numbers.
* @param {boolean} config.serversideRouting It's using server side routing
*/
export default function create ({
Expand All @@ -47,6 +48,7 @@ export default function create ({
dechunker,
channel,
disableLosslessIntegers,
useBigInt,
serversideRouting,
server, // server info
log,
Expand Down Expand Up @@ -77,7 +79,7 @@ export default function create ({
version,
server,
chunker,
disableLosslessIntegers,
{ disableLosslessIntegers, useBigInt },
serversideRouting,
createResponseHandler,
observer.onProtocolError.bind(observer),
Expand All @@ -89,7 +91,7 @@ function createProtocol (
version,
server,
chunker,
disableLosslessIntegers,
packingConfig,
serversideRouting,
createResponseHandler,
onProtocolError,
Expand All @@ -100,7 +102,7 @@ function createProtocol (
return new BoltProtocolV1(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError
Expand All @@ -109,7 +111,7 @@ function createProtocol (
return new BoltProtocolV2(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError
Expand All @@ -118,7 +120,7 @@ function createProtocol (
return new BoltProtocolV3(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError
Expand All @@ -127,7 +129,7 @@ function createProtocol (
return new BoltProtocolV4x0(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError
Expand All @@ -136,7 +138,7 @@ function createProtocol (
return new BoltProtocolV4x1(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError,
Expand All @@ -146,7 +148,7 @@ function createProtocol (
return new BoltProtocolV4x2(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError,
Expand All @@ -156,7 +158,7 @@ function createProtocol (
return new BoltProtocolV4x3(
server,
chunker,
disableLosslessIntegers,
packingConfig,
createResponseHandler,
log,
onProtocolError,
Expand Down
18 changes: 9 additions & 9 deletions bolt-connection/src/bolt/request-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

import { int, internal } from 'neo4j-driver-core'
import { int, internal, json } from 'neo4j-driver-core'

const {
constants: { ACCESS_MODE_READ, FETCH_ALL },
Expand Down Expand Up @@ -79,7 +79,7 @@ export default class RequestMessage {
return new RequestMessage(
RUN,
[query, parameters],
() => `RUN ${query} ${JSON.stringify(parameters)}`
() => `RUN ${query} ${json.stringify(parameters)}`
)
}

Expand Down Expand Up @@ -131,7 +131,7 @@ export default class RequestMessage {
return new RequestMessage(
BEGIN,
[metadata],
() => `BEGIN ${JSON.stringify(metadata)}`
() => `BEGIN ${json.stringify(metadata)}`
)
}

Expand Down Expand Up @@ -171,7 +171,7 @@ export default class RequestMessage {
RUN,
[query, parameters, metadata],
() =>
`RUN ${query} ${JSON.stringify(parameters)} ${JSON.stringify(metadata)}`
`RUN ${query} ${json.stringify(parameters)} ${json.stringify(metadata)}`
)
}

Expand All @@ -191,13 +191,13 @@ export default class RequestMessage {
*/
static pull ({ stmtId = NO_STATEMENT_ID, n = FETCH_ALL } = {}) {
const metadata = buildStreamMetadata(
stmtId || NO_STATEMENT_ID,
stmtId === null || stmtId === undefined ? NO_STATEMENT_ID : stmtId,
n || FETCH_ALL
)
return new RequestMessage(
PULL,
[metadata],
() => `PULL ${JSON.stringify(metadata)}`
() => `PULL ${json.stringify(metadata)}`
)
}

Expand All @@ -209,13 +209,13 @@ export default class RequestMessage {
*/
static discard ({ stmtId = NO_STATEMENT_ID, n = FETCH_ALL } = {}) {
const metadata = buildStreamMetadata(
stmtId || NO_STATEMENT_ID,
stmtId === null || stmtId === undefined ? NO_STATEMENT_ID : stmtId,
n || FETCH_ALL
)
return new RequestMessage(
DISCARD,
[metadata],
() => `DISCARD ${JSON.stringify(metadata)}`
() => `DISCARD ${json.stringify(metadata)}`
)
}

Expand All @@ -230,7 +230,7 @@ export default class RequestMessage {
return new RequestMessage(
ROUTE,
[routingContext, databaseName],
() => `ROUTE ${JSON.stringify(routingContext)} ${databaseName}`
() => `ROUTE ${json.stringify(routingContext)} ${databaseName}`
)
}
}
Expand Down
10 changes: 5 additions & 5 deletions bolt-connection/src/bolt/response-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { newError } from 'neo4j-driver-core'
import { newError, json } from 'neo4j-driver-core'

// Signature bytes for each response message type
const SUCCESS = 0x70 // 0111 0000 // SUCCESS <metadata>
Expand Down Expand Up @@ -92,13 +92,13 @@ export default class ResponseHandler {
switch (msg.signature) {
case RECORD:
if (this._log.isDebugEnabled()) {
this._log.debug(`${this} S: RECORD ${JSON.stringify(msg)}`)
this._log.debug(`${this} S: RECORD ${json.stringify(msg)}`)
}
this._currentObserver.onNext(payload)
break
case SUCCESS:
if (this._log.isDebugEnabled()) {
this._log.debug(`${this} S: SUCCESS ${JSON.stringify(msg)}`)
this._log.debug(`${this} S: SUCCESS ${json.stringify(msg)}`)
}
try {
const metadata = this._transformMetadata(payload)
Expand All @@ -109,7 +109,7 @@ export default class ResponseHandler {
break
case FAILURE:
if (this._log.isDebugEnabled()) {
this._log.debug(`${this} S: FAILURE ${JSON.stringify(msg)}`)
this._log.debug(`${this} S: FAILURE ${json.stringify(msg)}`)
}
try {
const error = newError(payload.message, payload.code)
Expand All @@ -125,7 +125,7 @@ export default class ResponseHandler {
break
case IGNORED:
if (this._log.isDebugEnabled()) {
this._log.debug(`${this} S: IGNORED ${JSON.stringify(msg)}`)
this._log.debug(`${this} S: IGNORED ${json.stringify(msg)}`)
}
try {
if (this._currentFailure && this._currentObserver.onError) {
Expand Down
12 changes: 6 additions & 6 deletions bolt-connection/src/bolt/stream-observers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { newError, error, Integer, Record } from 'neo4j-driver-core'
import { newError, error, Integer, Record, json } from 'neo4j-driver-core'
import { ALL } from './request-message'
import RawRoutingTable from './routing-table-raw'

Expand Down Expand Up @@ -268,7 +268,7 @@ class ResultStreamObserver extends StreamObserver {

// Extract server generated query id for use in requestMore and discard
// functions
if (meta.qid) {
if (meta.qid !== null && meta.qid !== undefined) {
this._queryId = meta.qid

// remove qid from metadata object
Expand Down Expand Up @@ -392,7 +392,7 @@ class LoginObserver extends StreamObserver {

onNext (record) {
this.onError(
newError('Received RECORD when initializing ' + JSON.stringify(record))
newError('Received RECORD when initializing ' + json.stringify(record))
)
}

Expand Down Expand Up @@ -429,7 +429,7 @@ class ResetObserver extends StreamObserver {
this.onError(
newError(
'Received RECORD when resetting: received record is: ' +
JSON.stringify(record),
json.stringify(record),
PROTOCOL_ERROR
)
)
Expand Down Expand Up @@ -500,7 +500,7 @@ class ProcedureRouteObserver extends StreamObserver {
'Illegal response from router. Received ' +
this._records.length +
' records but expected only one.\n' +
JSON.stringify(this._records),
json.stringify(this._records),
PROTOCOL_ERROR
)
)
Expand Down Expand Up @@ -533,7 +533,7 @@ class RouteObserver extends StreamObserver {
this.onError(
newError(
'Received RECORD when resetting: received record is: ' +
JSON.stringify(record),
json.stringify(record),
PROTOCOL_ERROR
)
)
Expand Down
Loading