From d8b24774f5c028839abb03811723994e3293ba6d Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Thu, 21 Aug 2025 09:54:49 +0200 Subject: [PATCH 1/9] stringify bolt protocol version --- .../src/bolt/bolt-protocol-v1.js | 2 +- packages/bolt-connection/src/bolt/create.js | 42 ++++---- .../bolt-connection/src/bolt/handshake.js | 9 +- .../src/bolt/protocol-version.js | 48 ++++++++++ .../connection-provider-direct.js | 8 +- .../connection-provider-routing.js | 10 +- packages/bolt-connection/src/index.js | 1 + .../test/bolt/bolt-protocol-v1.test.js | 2 +- .../test/bolt/bolt-protocol-v2.test.js | 2 +- .../test/bolt/bolt-protocol-v3.test.js | 2 +- .../test/bolt/bolt-protocol-v4x0.test.js | 2 +- .../test/bolt/bolt-protocol-v4x3.test.js | 2 +- .../test/bolt/bolt-protocol-v4x4.test.js | 2 +- .../test/bolt/bolt-protocol-v5x0.test.js | 2 +- .../test/bolt/bolt-protocol-v5x1.test.js | 2 +- .../test/bolt/bolt-protocol-v5x2.test.js | 2 +- .../test/bolt/bolt-protocol-v5x3.test.js | 2 +- .../test/bolt/bolt-protocol-v5x4.test.js | 2 +- .../test/bolt/bolt-protocol-v5x5.test.js | 2 +- .../test/bolt/bolt-protocol-v5x6.test.js | 2 +- .../test/bolt/bolt-protocol-v5x7.test.js | 2 +- .../test/bolt/bolt-protocol-v5x8.test.js | 2 +- .../test/bolt/bolt-protocol-v6x0.test.js | 2 +- .../bolt-connection/test/bolt/index.test.js | 50 +++++----- .../connection-provider-direct.test.js | 2 +- .../connection-provider-routing.test.js | 23 ++--- packages/core/src/connection.ts | 2 +- packages/core/src/internal/constants.ts | 36 +++---- packages/core/src/result-summary.ts | 12 +-- packages/core/test/utils/connection.fake.ts | 6 +- packages/neo4j-driver-deno/deno.lock | 96 +++++++++++++++++++ .../bolt-connection/bolt/bolt-protocol-v1.js | 2 +- .../lib/bolt-connection/bolt/create.js | 42 ++++---- .../lib/bolt-connection/bolt/handshake.js | 9 +- .../bolt-connection/bolt/protocol-version.js | 48 ++++++++++ .../connection-provider-direct.js | 8 +- .../connection-provider-routing.js | 10 +- .../lib/bolt-connection/index.js | 1 + .../neo4j-driver-deno/lib/core/connection.ts | 2 +- .../lib/core/internal/constants.ts | 36 +++---- .../lib/core/result-summary.ts | 12 +-- packages/neo4j-driver/test/driver.test.js | 2 +- packages/neo4j-driver/test/examples.test.js | 8 +- .../test/internal/connection-channel.test.js | 2 +- .../neo4j-driver/test/rx/navigation.test.js | 42 ++++---- .../test/rx/nested-statements.test.js | 4 +- packages/neo4j-driver/test/rx/session.test.js | 24 ++--- packages/neo4j-driver/test/rx/summary.test.js | 32 +++---- .../neo4j-driver/test/rx/transaction.test.js | 46 ++++----- .../neo4j-driver/test/spatial-types.test.js | 2 +- .../neo4j-driver/test/temporal-types.test.js | 2 +- .../neo4j-driver/test/vector-type.test.js | 2 +- 52 files changed, 463 insertions(+), 252 deletions(-) create mode 100644 packages/bolt-connection/src/bolt/protocol-version.js create mode 100644 packages/neo4j-driver-deno/deno.lock create mode 100644 packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js diff --git a/packages/bolt-connection/src/bolt/bolt-protocol-v1.js b/packages/bolt-connection/src/bolt/bolt-protocol-v1.js index d04b33b4e..41db11658 100644 --- a/packages/bolt-connection/src/bolt/bolt-protocol-v1.js +++ b/packages/bolt-connection/src/bolt/bolt-protocol-v1.js @@ -100,7 +100,7 @@ export default class BoltProtocol { } /** - * Returns the numerical version identifier for this protocol + * Returns the stringified version identifier for this protocol */ get version () { return BOLT_PROTOCOL_V1 diff --git a/packages/bolt-connection/src/bolt/create.js b/packages/bolt-connection/src/bolt/create.js index 18891e197..c6e5df0b8 100644 --- a/packages/bolt-connection/src/bolt/create.js +++ b/packages/bolt-connection/src/bolt/create.js @@ -37,6 +37,7 @@ import BoltProtocolV6x0 from './bolt-protocol-v6x0' // eslint-disable-next-line no-unused-vars import { Chunker, Dechunker } from '../channel' import ResponseHandler from './response-handler' +import { ProtocolVersion } from './protocol-version' /** * Creates a protocol with a given version @@ -112,8 +113,11 @@ function createProtocol ( onProtocolError, log ) { - switch (version) { - case 1: + if (!(version instanceof ProtocolVersion) || version === undefined || version === null) { + throw newError('Unknown Bolt protocol version: ' + version) + } + switch (version.toString()) { + case '1.0': return new BoltProtocolV1( server, chunker, @@ -122,7 +126,7 @@ function createProtocol ( log, onProtocolError ) - case 2: + case '2.0': return new BoltProtocolV2( server, chunker, @@ -131,7 +135,7 @@ function createProtocol ( log, onProtocolError ) - case 3: + case '3.0': return new BoltProtocolV3( server, chunker, @@ -140,7 +144,7 @@ function createProtocol ( log, onProtocolError ) - case 4.0: + case '4.0': return new BoltProtocolV4x0( server, chunker, @@ -149,7 +153,7 @@ function createProtocol ( log, onProtocolError ) - case 4.1: + case '4.1': return new BoltProtocolV4x1( server, chunker, @@ -159,7 +163,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.2: + case '4.2': return new BoltProtocolV4x2( server, chunker, @@ -169,7 +173,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.3: + case '4.3': return new BoltProtocolV4x3( server, chunker, @@ -179,7 +183,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.4: + case '4.4': return new BoltProtocolV4x4( server, chunker, @@ -189,7 +193,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.0: + case '5.0': return new BoltProtocolV5x0( server, chunker, @@ -199,7 +203,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.1: + case '5.1': return new BoltProtocolV5x1( server, chunker, @@ -209,7 +213,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.2: + case '5.2': return new BoltProtocolV5x2( server, chunker, @@ -219,7 +223,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.3: + case '5.3': return new BoltProtocolV5x3(server, chunker, packingConfig, @@ -227,7 +231,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.4: + case '5.4': return new BoltProtocolV5x4(server, chunker, packingConfig, @@ -235,7 +239,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.5: + case '5.5': return new BoltProtocolV5x5(server, chunker, packingConfig, @@ -243,7 +247,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.6: + case '5.6': return new BoltProtocolV5x6(server, chunker, packingConfig, @@ -251,7 +255,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.7: + case '5.7': return new BoltProtocolV5x7(server, chunker, packingConfig, @@ -259,7 +263,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.8: + case '5.8': return new BoltProtocolV5x8(server, chunker, packingConfig, @@ -267,7 +271,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 6.0: + case '6.0': return new BoltProtocolV6x0(server, chunker, packingConfig, diff --git a/packages/bolt-connection/src/bolt/handshake.js b/packages/bolt-connection/src/bolt/handshake.js index 4354654cf..3decb7e54 100644 --- a/packages/bolt-connection/src/bolt/handshake.js +++ b/packages/bolt-connection/src/bolt/handshake.js @@ -17,6 +17,7 @@ import { alloc } from '../channel' import { newError } from 'neo4j-driver-core' +import { ProtocolVersion } from './protocol-version' const BOLT_MAGIC_PREAMBLE = 0x6060b017 const AVAILABLE_BOLT_PROTOCOLS = ['6.0', '5.8', '5.7', '5.6', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '3.0'] // bolt protocols the client will accept, ordered by preference @@ -69,7 +70,7 @@ function parseNegotiatedResponse (buffer, log) { '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)' ) } - return Number(h[3] + '.' + h[2]) + return new ProtocolVersion(h[3], h[2]) } function handshakeNegotiationV2 (channel, buffer, log) { @@ -112,7 +113,7 @@ function handshakeNegotiationV2 (channel, buffer, log) { selectionBuffer.writeVarInt(capabilites) channel.write(selectionBuffer) resolve({ - protocolVersion: Number(major + '.' + minor), + protocolVersion: new ProtocolVersion(major, minor), capabilites, consumeRemainingBuffer: consumer => { if (buffer.hasRemaining()) { @@ -146,7 +147,7 @@ function newHandshakeBuffer () { */ /** * @typedef HandshakeResult - * @property {number} protocolVersion The protocol version negotiated in the handshake + * @property {ProtocolVersion} protocolVersion The protocol version negotiated in the handshake * @property {number} capabilites A bitmask representing the capabilities negotiated in the handshake * @property {function(BufferConsumerCallback)} consumeRemainingBuffer A function to consume the remaining buffer if it exists */ @@ -160,7 +161,7 @@ function newHandshakeBuffer () { */ export default function handshake (channel, log) { return initialHandshake(channel, log).then((result) => { - if (result.protocolVersion === 255.1) { + if (result.protocolVersion.equalTo(new ProtocolVersion(255, 1))) { return handshakeNegotiationV2(channel, result.buffer, log) } else { return result diff --git a/packages/bolt-connection/src/bolt/protocol-version.js b/packages/bolt-connection/src/bolt/protocol-version.js new file mode 100644 index 000000000..4e41d43b9 --- /dev/null +++ b/packages/bolt-connection/src/bolt/protocol-version.js @@ -0,0 +1,48 @@ +export class ProtocolVersion { + constructor (major, minor) { + this.major = major + this.minor = minor + } + + getMajor () { + return this.major + } + + getMinor () { + return this.major + } + + isLessThan (other) { + if (this.major < other.major) { + return true + } else if (this.major === other.major && this.minor < other.minor) { + return true + } + return false + } + + isGreaterThan (other) { + if (this.major > other.major) { + return true + } else if (this.major === other.major && this.minor > other.minor) { + return true + } + return false + } + + isGreaterOrEqualTo (other) { + return !this.isLessThan(other) + } + + isLessOrEqualTo (other) { + return !this.isGreaterThan(other) + } + + equalTo (other) { + return this.major === other.major && this.minor === other.minor + } + + toString () { + return this.major.toString() + '.' + this.minor.toString() + } +} diff --git a/packages/bolt-connection/src/connection-provider/connection-provider-direct.js b/packages/bolt-connection/src/connection-provider/connection-provider-direct.js index 565955a2e..6c18130f3 100644 --- a/packages/bolt-connection/src/connection-provider/connection-provider-direct.js +++ b/packages/bolt-connection/src/connection-provider/connection-provider-direct.js @@ -91,7 +91,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.toString() >= BOLT_PROTOCOL_V4_0 ) } @@ -104,19 +104,19 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.toString() >= BOLT_PROTOCOL_V3 ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.toString() >= BOLT_PROTOCOL_V4_4 ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.toString() >= BOLT_PROTOCOL_V5_1 ) } diff --git a/packages/bolt-connection/src/connection-provider/connection-provider-routing.js b/packages/bolt-connection/src/connection-provider/connection-provider-routing.js index e69ce764b..e87fec6a2 100644 --- a/packages/bolt-connection/src/connection-provider/connection-provider-routing.js +++ b/packages/bolt-connection/src/connection-provider/connection-provider-routing.js @@ -260,25 +260,25 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.toString() >= BOLT_PROTOCOL_V4_0 ) } async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.toString() >= BOLT_PROTOCOL_V3 ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.toString() >= BOLT_PROTOCOL_V4_4 ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.toString() >= BOLT_PROTOCOL_V5_1 ) } @@ -611,7 +611,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider const connectionProvider = new SingleConnectionProvider(delegateConnection) const protocolVersion = connection.protocol().version - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return [new Session({ mode: WRITE, bookmarks: Bookmarks.empty(), diff --git a/packages/bolt-connection/src/index.js b/packages/bolt-connection/src/index.js index d27358e1f..d8fcd1669 100644 --- a/packages/bolt-connection/src/index.js +++ b/packages/bolt-connection/src/index.js @@ -20,5 +20,6 @@ export * as bolt from './bolt' export * as buf from './buf' export * as channel from './channel' export * as packstream from './packstream' +export * from './bolt/protocol-version' export * from './connection-provider' diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js index 26742391a..7b5ada8ed 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js @@ -224,7 +224,7 @@ describe('#unit BoltProtocolV1', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV1(null, null, false) - expect(protocol.version).toBe(1) + expect(protocol.version).toBe('1.0') }) describe('Bolt V3', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js index f5f415cb6..efd040079 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js @@ -69,7 +69,7 @@ describe('#unit BoltProtocolV2', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV2(null, null, false) - expect(protocol.version).toBe(2) + expect(protocol.version).toBe('2.0') }) describe('unpacker configuration', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js index 2dbfd57e5..bfeb83117 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js @@ -202,7 +202,7 @@ describe('#unit BoltProtocolV3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV3(null, null, false) - expect(protocol.version).toBe(3) + expect(protocol.version).toBe('3.0') }) it('should request the routing table from the correct procedure', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js index a3390252e..0da093061 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js @@ -149,7 +149,7 @@ describe('#unit BoltProtocolV4x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x0(null, null, false) - expect(protocol.version).toBe(4) + expect(protocol.version).toBe('4.0') }) it('should request the routing table from the correct procedure', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js index 9770453e0..768411c03 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js @@ -169,7 +169,7 @@ describe('#unit BoltProtocolV4x3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x3(null, null, false) - expect(protocol.version).toBe(4.3) + expect(protocol.version).toBe('4.3') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js index 8351774d7..2b6148700 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js @@ -243,7 +243,7 @@ describe('#unit BoltProtocolV4x4', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x4(null, null, false) - expect(protocol.version).toBe(4.4) + expect(protocol.version).toBe('4.4') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js index a9849e7d6..05cf0b304 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js @@ -243,7 +243,7 @@ describe('#unit BoltProtocolV5x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x0(null, null, false) - expect(protocol.version).toBe(5.0) + expect(protocol.version).toBe('5.0') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js index 3d6663852..e5ecc9c83 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js @@ -243,7 +243,7 @@ describe('#unit BoltProtocolV5x1', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x1(null, null, false) - expect(protocol.version).toBe(5.1) + expect(protocol.version).toBe('5.1') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js index ab1a210c5..ab7e3b088 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js @@ -243,7 +243,7 @@ describe('#unit BoltProtocolV5x2', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x2(null, null, false) - expect(protocol.version).toBe(5.2) + expect(protocol.version).toBe('5.2') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js index bd27bb2f7..a22899efc 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js @@ -243,7 +243,7 @@ describe('#unit BoltProtocolV5x3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x3(null, null, false) - expect(protocol.version).toBe(5.3) + expect(protocol.version).toBe('5.3') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js index 1ccbc0cd9..24e65b988 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js @@ -245,7 +245,7 @@ describe('#unit BoltProtocolV5x4', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x4(null, null, false) - expect(protocol.version).toBe(5.4) + expect(protocol.version).toBe('5.4') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js index 8e3cea85c..c1523be5b 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js @@ -245,7 +245,7 @@ describe('#unit BoltProtocolV5x5', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x5(null, null, false) - expect(protocol.version).toBe(5.5) + expect(protocol.version).toBe('5.5') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js index 5fb60fa71..181c7f7ef 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js @@ -245,7 +245,7 @@ describe('#unit BoltProtocolV5x6', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x6(null, null, false) - expect(protocol.version).toBe(5.6) + expect(protocol.version).toBe('5.6') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js index a1c3cbb49..fbc4666be 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js @@ -254,7 +254,7 @@ describe('#unit BoltProtocolV5x7', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x7(null, null, false) - expect(protocol.version).toBe(5.7) + expect(protocol.version).toBe('5.7') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js index cd96faddf..f4eae35af 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js @@ -254,7 +254,7 @@ describe('#unit BoltProtocolV5x8', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x8(null, null, false) - expect(protocol.version).toBe(5.8) + expect(protocol.version).toBe('5.8') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js index a0440d01b..90e890e02 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js @@ -256,7 +256,7 @@ describe('#unit BoltProtocolV6x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV6x0(null, null, false) - expect(protocol.version).toBe(6.0) + expect(protocol.version).toBe('6.0') }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/index.test.js b/packages/bolt-connection/test/bolt/index.test.js index 6fb17e146..1529a38f4 100644 --- a/packages/bolt-connection/test/bolt/index.test.js +++ b/packages/bolt-connection/test/bolt/index.test.js @@ -35,6 +35,9 @@ import BoltProtocolV5x3 from '../../src/bolt/bolt-protocol-v5x3' import BoltProtocolV5x4 from '../../src/bolt/bolt-protocol-v5x4' import BoltProtocolV5x5 from '../../src/bolt/bolt-protocol-v5x5' import BoltProtocolV5x6 from '../../src/bolt/bolt-protocol-v5x6' +import BoltProtocolV5x7 from '../../src/bolt/bolt-protocol-v5x7' +import BoltProtocolV5x8 from '../../src/bolt/bolt-protocol-v5x8' +import BoltProtocolV6x0 from '../../src/bolt/bolt-protocol-v6x0' const { logger: { Logger } @@ -60,28 +63,28 @@ describe('#unit Bolt', () => { it('should handle a successful handshake without remaining buffer', done => { const { channel, handshakePromise } = subject() - const expectedProtocolVersion = 4.3 + const expectedProtocolVersion = '4.3' handshakePromise .then(({ protocolVersion, consumeRemainingBuffer }) => { - expect(protocolVersion).toEqual(expectedProtocolVersion) + expect(protocolVersion).toEqual({ major: 4, minor: 3 }) consumeRemainingBuffer(() => done.fail('Should not have remaining buffer') ) done() }) - .catch(e => done.fail(e)) + .catch(e => { throw e }) channel.onmessage(packedHandshakeMessage(expectedProtocolVersion)) }) it('should handle a successful handshake with remaining buffer', done => { const { channel, handshakePromise } = subject() - const expectedProtocolVersion = 4.3 + const expectedProtocolVersion = '4.3' const expectedExtraBuffer = createExtraBuffer() handshakePromise .then(({ protocolVersion, consumeRemainingBuffer }) => { - expect(protocolVersion).toEqual(expectedProtocolVersion) + expect(protocolVersion).toEqual({ major: 4, minor: 3 }) let consumeRemainingBufferCalled = false consumeRemainingBuffer(buffer => { consumeRemainingBufferCalled = true @@ -90,7 +93,7 @@ describe('#unit Bolt', () => { expect(consumeRemainingBufferCalled).toBeTruthy() done() }) - .catch(e => done.fail(e)) + .catch(e => { throw e }) channel.onmessage( packedHandshakeMessage(expectedProtocolVersion, expectedExtraBuffer) @@ -129,7 +132,7 @@ describe('#unit Bolt', () => { it('should not log error if the server responds with a valid protocol version', async () => { const { channel, handshakePromise, log } = subject() - const expectedProtocolVersion = 4.3 + const expectedProtocolVersion = '4.3' const logErrorSpy = jest.spyOn(log, 'error') channel.onmessage(packedHandshakeMessage(expectedProtocolVersion)) @@ -380,21 +383,24 @@ describe('#unit Bolt', () => { } const availableProtocols = [ - v(1, BoltProtocolV1), - v(2, BoltProtocolV2), - v(3, BoltProtocolV3), - v(4.0, BoltProtocolV4x0), - v(4.1, BoltProtocolV4x1), - v(4.2, BoltProtocolV4x2), - v(4.3, BoltProtocolV4x3), - v(4.4, BoltProtocolV4x4), - v(5.0, BoltProtocolV5x0), - v(5.1, BoltProtocolV5x1), - v(5.2, BoltProtocolV5x2), - v(5.3, BoltProtocolV5x3), - v(5.4, BoltProtocolV5x4), - v(5.5, BoltProtocolV5x5), - v(5.6, BoltProtocolV5x6) + v('1.0', BoltProtocolV1), + v('2.0', BoltProtocolV2), + v('3.0', BoltProtocolV3), + v('4.0', BoltProtocolV4x0), + v('4.1', BoltProtocolV4x1), + v('4.2', BoltProtocolV4x2), + v('4.3', BoltProtocolV4x3), + v('4.4', BoltProtocolV4x4), + v('5.0', BoltProtocolV5x0), + v('5.1', BoltProtocolV5x1), + v('5.2', BoltProtocolV5x2), + v('5.3', BoltProtocolV5x3), + v('5.4', BoltProtocolV5x4), + v('5.5', BoltProtocolV5x5), + v('5.6', BoltProtocolV5x6), + v('5.7', BoltProtocolV5x7), + v('5.8', BoltProtocolV5x8), + v('6.0', BoltProtocolV6x0) ] availableProtocols.forEach(lambda) diff --git a/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js b/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js index 2ac4c4dc3..3cfecf72a 100644 --- a/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js +++ b/packages/bolt-connection/test/connection-provider/connection-provider-direct.test.js @@ -719,7 +719,7 @@ describe('.verifyConnectivityAndGetServerInfo()', () => { }) function setup ({ releaseMock } = {}) { - const protocolVersion = 4.4 + const protocolVersion = '4.4' const resetAndFlush = jest.fn(() => Promise.resolve()) const server = { address: 'localhost:123', version: 'neo4j/1234' } const seenConnections = [] diff --git a/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js b/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js index 84bda4bc0..5ec6eac6b 100644 --- a/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js +++ b/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js @@ -45,14 +45,15 @@ const READ = 'READ' const WRITE = 'WRITE' describe.each([ - 3, - 4.0, - 4.1, - 4.2, - 4.3, - 4.4, - 5.0, - 5.1 + '3.0', + '4.0', + '4.1', + '4.2', + '4.3', + '4.4', + '5.0', + '5.1', + '6.0' ])('#unit RoutingConnectionProvider (PROTOCOL_VERSION=%d)', (PROTOCOL_VERSION) => { const server0 = ServerAddress.fromUrl('server0') const server1 = ServerAddress.fromUrl('server1') @@ -3043,7 +3044,7 @@ describe.each([ [server3, server4], [server5, server6] ) - const protocolVersion = 4.4 + const protocolVersion = '4.4' const server = { address: 'localhost:123', version: 'neo4j/1234' } const seenConnectionsPerAddress = new Map() @@ -3120,7 +3121,7 @@ describe.each([ const pool = newPool({ create: (address, release) => { if (i++ % 2 === 0) { - return new FakeConnection(address, release, 'version', 4.4, {}) + return new FakeConnection(address, release, 'version', '4.4', {}) } throw error } @@ -3134,7 +3135,7 @@ describe.each([ ) const serverInfo = await connectionProvider.verifyConnectivityAndGetServerInfo({ database, accessMode }) - expect(serverInfo).toEqual(new ServerInfo({}, 4.4)) + expect(serverInfo).toEqual(new ServerInfo({}, '4.4')) }) }) diff --git a/packages/core/src/connection.ts b/packages/core/src/connection.ts index f24d035dd..2b03a4bd5 100644 --- a/packages/core/src/connection.ts +++ b/packages/core/src/connection.ts @@ -131,7 +131,7 @@ class Connection { * * @returns {number} */ - getProtocolVersion (): number { + getProtocolVersion (): string { throw new Error('Not implemented') } diff --git a/packages/core/src/internal/constants.ts b/packages/core/src/internal/constants.ts index 7403677c3..2bf8aeb4c 100644 --- a/packages/core/src/internal/constants.ts +++ b/packages/core/src/internal/constants.ts @@ -23,24 +23,24 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default const ACCESS_MODE_READ: 'READ' = 'READ' const ACCESS_MODE_WRITE: 'WRITE' = 'WRITE' -const BOLT_PROTOCOL_V1: number = 1 -const BOLT_PROTOCOL_V2: number = 2 -const BOLT_PROTOCOL_V3: number = 3 -const BOLT_PROTOCOL_V4_0: number = 4.0 -const BOLT_PROTOCOL_V4_1: number = 4.1 -const BOLT_PROTOCOL_V4_2: number = 4.2 -const BOLT_PROTOCOL_V4_3: number = 4.3 -const BOLT_PROTOCOL_V4_4: number = 4.4 -const BOLT_PROTOCOL_V5_0: number = 5.0 -const BOLT_PROTOCOL_V5_1: number = 5.1 -const BOLT_PROTOCOL_V5_2: number = 5.2 -const BOLT_PROTOCOL_V5_3: number = 5.3 -const BOLT_PROTOCOL_V5_4: number = 5.4 -const BOLT_PROTOCOL_V5_5: number = 5.5 -const BOLT_PROTOCOL_V5_6: number = 5.6 -const BOLT_PROTOCOL_V5_7: number = 5.7 -const BOLT_PROTOCOL_V5_8: number = 5.8 -const BOLT_PROTOCOL_V6_0: number = 6.0 +const BOLT_PROTOCOL_V1: string = '1.0' +const BOLT_PROTOCOL_V2: string = '2.0' +const BOLT_PROTOCOL_V3: string = '3.0' +const BOLT_PROTOCOL_V4_0: string = '4.0' +const BOLT_PROTOCOL_V4_1: string = '4.1' +const BOLT_PROTOCOL_V4_2: string = '4.2' +const BOLT_PROTOCOL_V4_3: string = '4.3' +const BOLT_PROTOCOL_V4_4: string = '4.4' +const BOLT_PROTOCOL_V5_0: string = '5.0' +const BOLT_PROTOCOL_V5_1: string = '5.1' +const BOLT_PROTOCOL_V5_2: string = '5.2' +const BOLT_PROTOCOL_V5_3: string = '5.3' +const BOLT_PROTOCOL_V5_4: string = '5.4' +const BOLT_PROTOCOL_V5_5: string = '5.5' +const BOLT_PROTOCOL_V5_6: string = '5.6' +const BOLT_PROTOCOL_V5_7: string = '5.7' +const BOLT_PROTOCOL_V5_8: string = '5.8' +const BOLT_PROTOCOL_V6_0: string = '6.0' const TELEMETRY_APIS = { MANAGED_TRANSACTION: 0, diff --git a/packages/core/src/result-summary.ts b/packages/core/src/result-summary.ts index 8ffdc8b45..8bbc77792 100644 --- a/packages/core/src/result-summary.ts +++ b/packages/core/src/result-summary.ts @@ -42,13 +42,13 @@ class ResultSummary { * @param {string} query - The query this summary is for * @param {Object} parameters - Parameters for the query * @param {Object} metadata - Query metadata - * @param {number|undefined} protocolVersion - Bolt Protocol Version + * @param {string|undefined} protocolVersion - Bolt Protocol Version */ constructor ( query: string, parameters: { [key: string]: any }, metadata: any, - protocolVersion?: number + protocolVersion?: string ) { /** * The query and parameters this summary is for. @@ -434,7 +434,7 @@ class QueryStatistics { */ class ServerInfo { address?: string - protocolVersion?: number + protocolVersion?: string agent?: string /** @@ -442,9 +442,9 @@ class ServerInfo { * @constructor * @param {Object} serverMeta - Object with serverMeta data * @param {Object} connectionInfo - Bolt connection info - * @param {number} protocolVersion - Bolt Protocol Version + * @param {string} protocolVersion - Bolt Protocol Version */ - constructor (serverMeta?: any, protocolVersion?: number) { + constructor (serverMeta?: any, protocolVersion?: string) { if (serverMeta != null) { /** * The server adress @@ -463,7 +463,7 @@ class ServerInfo { /** * The protocol version used by the connection - * @type {number} + * @type {string} * @public */ this.protocolVersion = protocolVersion diff --git a/packages/core/test/utils/connection.fake.ts b/packages/core/test/utils/connection.fake.ts index 6153c3d0c..a96830a92 100644 --- a/packages/core/test/utils/connection.fake.ts +++ b/packages/core/test/utils/connection.fake.ts @@ -38,7 +38,7 @@ export default class FakeConnection extends Connection { public seenParameters: any[] public seenProtocolOptions: any[] private readonly _server: any - public protocolVersion: number + public protocolVersion: string public protocolErrorsHandled: number public seenProtocolErrors: string[] public seenRequestRoutingInformation: any[] @@ -61,7 +61,7 @@ export default class FakeConnection extends Connection { this.seenParameters = [] this.seenProtocolOptions = [] this._server = {} - this.protocolVersion = 1 + this.protocolVersion = '1.0' this.protocolErrorsHandled = 0 this.seenProtocolErrors = [] this.seenRequestRoutingInformation = [] @@ -119,7 +119,7 @@ export default class FakeConnection extends Connection { return mockResultStreamObserver('ROLLBACK', {}) } - getProtocolVersion (): number { + getProtocolVersion (): string { return this.protocolVersion } diff --git a/packages/neo4j-driver-deno/deno.lock b/packages/neo4j-driver-deno/deno.lock new file mode 100644 index 000000000..5b9ec739b --- /dev/null +++ b/packages/neo4j-driver-deno/deno.lock @@ -0,0 +1,96 @@ +{ + "version": "5", + "remote": { + "https://deno.land/std@0.119.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", + "https://deno.land/std@0.119.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", + "https://deno.land/std@0.119.0/async/deadline.ts": "1d6ac7aeaee22f75eb86e4e105d6161118aad7b41ae2dd14f4cfd3bf97472b93", + "https://deno.land/std@0.119.0/async/debounce.ts": "b2f693e4baa16b62793fd618de6c003b63228db50ecfe3bd51fc5f6dc0bc264b", + "https://deno.land/std@0.119.0/async/deferred.ts": "ab60d46ba561abb3b13c0c8085d05797a384b9f182935f051dc67136817acdee", + "https://deno.land/std@0.119.0/async/delay.ts": "f2d8ccaa8ebc26594bd8b0989edfd8a96257a714c1dee2fb54d986e5bdd840ac", + "https://deno.land/std@0.119.0/async/mod.ts": "78425176fabea7bd1046ce3819fd69ce40da85c83e0f174d17e8e224a91f7d10", + "https://deno.land/std@0.119.0/async/mux_async_iterator.ts": "62abff3af9ff619e8f2adc96fc70d4ca020fa48a50c23c13f12d02ed2b760dbe", + "https://deno.land/std@0.119.0/async/pool.ts": "353ce4f91865da203a097aa6f33de8966340c91b6f4a055611c8c5d534afd12f", + "https://deno.land/std@0.119.0/async/tee.ts": "3e9f2ef6b36e55188de16a667c702ace4ad0cf84e3720379160e062bf27348ad", + "https://deno.land/std@0.119.0/bytes/bytes_list.ts": "3bff6a09c72b2e0b1e92e29bd3b135053894196cca07a2bba842901073efe5cb", + "https://deno.land/std@0.119.0/bytes/equals.ts": "69f55fdbd45c71f920c1a621e6c0865dc780cd8ae34e0f5e55a9497b70c31c1b", + "https://deno.land/std@0.119.0/bytes/mod.ts": "fedb80b8da2e7ad8dd251148e65f92a04c73d6c5a430b7d197dc39588c8dda6f", + "https://deno.land/std@0.119.0/encoding/base64.ts": "0b58bd6477214838bf711eef43eac21e47ba9e5c81b2ce185fe25d9ecab3ebb3", + "https://deno.land/std@0.119.0/encoding/base64url.ts": "a5c3f71c99a397f9c6da7701e7cae4c031700ae180ba68a0fc9ff9baca71e4ac", + "https://deno.land/std@0.119.0/flags/mod.ts": "5bd80147c97e481efcc4c041096c6c1a1393248e2849ccd571269d62c2634cbe", + "https://deno.land/std@0.119.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621", + "https://deno.land/std@0.119.0/fmt/printf.ts": "419510e0a3f7c8d680fbf6472d5a11e372854f1c2b32fca5fdb513575c485068", + "https://deno.land/std@0.119.0/fs/_util.ts": "f2ce811350236ea8c28450ed822a5f42a0892316515b1cd61321dec13569c56b", + "https://deno.land/std@0.119.0/fs/empty_dir.ts": "5f08b263dd064dc7917c4bbeb13de0f5505a664b9cdfe312fa86e7518cfaeb84", + "https://deno.land/std@0.119.0/fs/ensure_dir.ts": "b7c103dc41a3d1dbbb522bf183c519c37065fdc234831a4a0f7d671b1ed5fea7", + "https://deno.land/std@0.119.0/fs/ensure_file.ts": "c06031af24368e80c330897e4b8e9109efc8602ffabc8f3e2306be07529e1d13", + "https://deno.land/std@0.119.0/fs/ensure_link.ts": "26e54363508b822afd87a3f6e873bbbcd6b5993dd638f8170758c16262a75065", + "https://deno.land/std@0.119.0/fs/ensure_symlink.ts": "c07b6d19ef58b6f5c671ffa942e7f9be50315f4f78e2f9f511626fd2e13beccc", + "https://deno.land/std@0.119.0/fs/eol.ts": "afaebaaac36f48c423b920c836551997715672b80a0fee9aa7667c181a94f2df", + "https://deno.land/std@0.119.0/fs/exists.ts": "c3c3335a212bd945bb75df379096ab57fb6c86598fa273dfb24da3b3939a951e", + "https://deno.land/std@0.119.0/fs/expand_glob.ts": "f6f64ef54addcc84c9012d6dfcf66d39ecc2565e40c4d2b7644d585fe4d12a04", + "https://deno.land/std@0.119.0/fs/mod.ts": "2bf5468fc950479b2a791cceae3d6fe3f32e573243b004d1f8e0a3df92211680", + "https://deno.land/std@0.119.0/fs/move.ts": "4623058e39bbbeb3ad30aeff9c974c55d2d574ad7c480295c12b04c244686a99", + "https://deno.land/std@0.119.0/fs/walk.ts": "31464d75099aa3fc7764212576a8772dfabb2692783e6eabb910f874a26eac54", + "https://deno.land/std@0.119.0/io/buffer.ts": "8f10342821b81990acf859cdccb4e4031c7c9187a0ffc3ed6b356ee29ecc6681", + "https://deno.land/std@0.119.0/log/handlers.ts": "bb0685d4124c7401efbacd9e019c0c1abd2dfb381b939601338b158d2b327cb7", + "https://deno.land/std@0.119.0/log/levels.ts": "088a883039ece5fa0da5f74bc7688654045ea7cb01bf200b438191a28d728eae", + "https://deno.land/std@0.119.0/log/logger.ts": "6b2dd8cbe6f407100b9becfe61595d7681f8ce3692412fad843de84d617a038e", + "https://deno.land/std@0.119.0/log/mod.ts": "9393719dafdb360620ea9222c0ce0db35a0ebb0d49ea6d5c30406f332d2be334", + "https://deno.land/std@0.119.0/node/_buffer.js": "a43c35f89ef15c2107cba863d2cd0bd573e829a2a3b80167033da9b96066ce51", + "https://deno.land/std@0.119.0/node/_core.ts": "8b105f152c9f8990f7558b0a0a514d4f3ab90a85c09ca60e489ca92ed5271f75", + "https://deno.land/std@0.119.0/node/_errors.ts": "bf047995427fc15a27a182ee13021e94315fa758c1cc7c3576374876ab9f952a", + "https://deno.land/std@0.119.0/node/_fixed_queue.ts": "ac68975e5663ea9cf2e465e91a7600fa3d5dc1a2f556cf80fd1ee25b37dbcedf", + "https://deno.land/std@0.119.0/node/_next_tick.ts": "9b0bde39bfad9774be73b0fe9e77df757e147e2fc04784d51fe777d36d142260", + "https://deno.land/std@0.119.0/node/_process/process.ts": "828b67fa5858e30901e11a84968b2732057cd0bea34afcf49f617498040e7dbe", + "https://deno.land/std@0.119.0/node/_util/_debuglog.ts": "b46f7b640bad2afb8adf2b3560e6969071f9de0721dcec9e3530465ab5ec6c40", + "https://deno.land/std@0.119.0/node/_util/_util_callbackify.ts": "a89ade5b5d989f9eb9261cd8179a5f8a1579c6a898549fab304200a85ee520b0", + "https://deno.land/std@0.119.0/node/_util/_util_promisify.ts": "6d8d88fd81763f1074c84f4494484f9dd86182dfe46b63fe5aadd6448b767896", + "https://deno.land/std@0.119.0/node/_utils.ts": "42e5b28e1740ba0be9b4ace2c9adb95317d9cadb099418c51ed34cd6a301cae3", + "https://deno.land/std@0.119.0/node/buffer.ts": "cf37645cd1fc08f1afa02532dc6682cefd8cabbf44812aa9a4916e79bdd1cd11", + "https://deno.land/std@0.119.0/node/internal/buffer.js": "21f4bfea78679e18bfebeb1d9ece1a94d337d282a2a68d43ab5ff655c2d33e56", + "https://deno.land/std@0.119.0/node/internal/idna.ts": "6d7cce3e569fd1d9e558d63ab522700e57b998597196a4746436a62f3f8b1c7f", + "https://deno.land/std@0.119.0/node/internal/querystring.ts": "1fdee1158205dd220c3711cce2e994bd0848abc7518d245856d142b08a266a07", + "https://deno.land/std@0.119.0/node/internal/util.js": "11ef4e4724a4d40f1f5ed4a54e42cee3c3af0f75dcea33ac063747a6e3b9a582", + "https://deno.land/std@0.119.0/node/internal/util/comparisons.ts": "9e6979948221ee00a105355d8a9afe47fa059a331351cbb2e11fa8e2f50749d4", + "https://deno.land/std@0.119.0/node/internal/util/inspect.js": "2b50eb7e8b1d5a73a933f56a361262cf2f23429a8e1ca6ee47db04229bf12208", + "https://deno.land/std@0.119.0/node/internal/util/types.ts": "31745332605771b59701baebf1655f389202b10bb787afb78e66c92486bc0332", + "https://deno.land/std@0.119.0/node/internal/validators.js": "16b58d8ac8505897422d4ad273652a8cb36c470f470df9677700cc3b78c24c19", + "https://deno.land/std@0.119.0/node/internal_binding/_libuv_winerror.ts": "689b8fa52dafb7a1b55f3ffceca5905f77fb2720a8b9f77c921cd598e3ef3757", + "https://deno.land/std@0.119.0/node/internal_binding/_node.ts": "c257e872993334cfab1eaab8212d422b24f7388281f73c7bbdd9bbf1bb2a7841", + "https://deno.land/std@0.119.0/node/internal_binding/_utils.ts": "ee6830db046e829b5c4d6df1de21f1a3d6464469a2fe303b32bc44bb171c2eeb", + "https://deno.land/std@0.119.0/node/internal_binding/_winerror.ts": "27e4a7d78ae31e7b07faafd25fe46fa367271aec0a49f3be067f7ec160396a38", + "https://deno.land/std@0.119.0/node/internal_binding/buffer.ts": "f92daf02083bdaf0006a06fa1f26a26436f4b7b0c5d000aff7d01da3d1aa42a5", + "https://deno.land/std@0.119.0/node/internal_binding/constants.ts": "91c9274c8891f93262032129348b25f170162cb126dc424ec7ce8a2172812657", + "https://deno.land/std@0.119.0/node/internal_binding/string_decoder.ts": "6aca87fb018705e34c39d6f67d610b14c8ca04a47ca58f0d1fc8d5f9281e6b7b", + "https://deno.land/std@0.119.0/node/internal_binding/types.ts": "80621e22989a1431068bc3b7f59cab3afb42cfb4d4cd273e61fa2d11ab3abab6", + "https://deno.land/std@0.119.0/node/internal_binding/util.ts": "446b4d704f4d588df98db9c6f9c7465c08a23f20f781ba55bcc246fb260012af", + "https://deno.land/std@0.119.0/node/internal_binding/uv.ts": "3b722cd20508d54e4d790c825b23510a5fa4313ad42bfb8904704a738df32325", + "https://deno.land/std@0.119.0/node/path.ts": "86b262d6957fba13d4f3d58a92ced49de4f40169d06542326b5547ff97257f0d", + "https://deno.land/std@0.119.0/node/querystring.ts": "4f436efdd97659fe567c00f1cff233d4f5b67002ef388951db052dfe7c3de114", + "https://deno.land/std@0.119.0/node/string_decoder.ts": "e97d4988a3490fd572fc23e64b3a33dabc4ac76c1fb82665f34dc8956d57a658", + "https://deno.land/std@0.119.0/node/url.ts": "c58bd8adfde3833026c1c3c8f55cd14e37f9f1e4dd6b7b99c5feb4ace710e9b4", + "https://deno.land/std@0.119.0/node/util.ts": "3be88d5d1c908f279bf7fecd77ff3933e048aa50205029fdd69280f67aea5901", + "https://deno.land/std@0.119.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", + "https://deno.land/std@0.119.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", + "https://deno.land/std@0.119.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", + "https://deno.land/std@0.119.0/path/common.ts": "f41a38a0719a1e85aa11c6ba3bea5e37c15dd009d705bd8873f94c833568cbc4", + "https://deno.land/std@0.119.0/path/glob.ts": "ea87985765b977cc284b92771003b2070c440e0807c90e1eb0ff3e095911a820", + "https://deno.land/std@0.119.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", + "https://deno.land/std@0.119.0/path/posix.ts": "34349174b9cd121625a2810837a82dd8b986bbaaad5ade690d1de75bbb4555b2", + "https://deno.land/std@0.119.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", + "https://deno.land/std@0.119.0/path/win32.ts": "11549e8c6df8307a8efcfa47ad7b2a75da743eac7d4c89c9723a944661c8bd2e", + "https://deno.land/std@0.119.0/streams/conversion.ts": "7ff9af42540063fa72003ab31a377ba9dde8532d43b16329b933c37a6d7aac5f", + "https://deno.land/std@0.119.0/testing/_diff.ts": "e6a10d2aca8d6c27a9c5b8a2dbbf64353874730af539707b5b39d4128140642d", + "https://deno.land/std@0.119.0/testing/asserts.ts": "e8bd3ff280731e2d2b48c67d6ed97ce2c0b717601ccb38816aff89edce71680d", + "https://deno.land/std@0.157.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", + "https://deno.land/std@0.157.0/bytes/bytes_list.ts": "aba5e2369e77d426b10af1de0dcc4531acecec27f9b9056f4f7bfbf8ac147ab4", + "https://deno.land/std@0.157.0/bytes/equals.ts": "3c3558c3ae85526f84510aa2b48ab2ad7bdd899e2e0f5b7a8ffc85acb3a6043a", + "https://deno.land/std@0.157.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf", + "https://deno.land/std@0.157.0/io/buffer.ts": "fae02290f52301c4e0188670e730cd902f9307fb732d79c4aa14ebdc82497289", + "https://deno.land/std@0.157.0/streams/conversion.ts": "fc4eb76a14148c43f0b85e903a5a1526391aa40ed9434dc21e34f88304eb823e", + "https://deno.land/std@0.182.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e", + "https://deno.land/std@0.182.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea", + "https://deno.land/std@0.182.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", + "https://deno.land/std@0.182.0/testing/asserts.ts": "e16d98b4d73ffc4ed498d717307a12500ae4f2cbe668f1a215632d19fcffc22f" + } +} diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js index a83f32f5a..ae6cb1b63 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/bolt-protocol-v1.js @@ -100,7 +100,7 @@ export default class BoltProtocol { } /** - * Returns the numerical version identifier for this protocol + * Returns the stringified version identifier for this protocol */ get version () { return BOLT_PROTOCOL_V1 diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js index cea9b1dd4..58cc1b211 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js @@ -37,6 +37,7 @@ import BoltProtocolV6x0 from './bolt-protocol-v6x0.js' // eslint-disable-next-line no-unused-vars import { Chunker, Dechunker } from '../channel/index.js' import ResponseHandler from './response-handler.js' +import { ProtocolVersion } from './protocol-version.js' /** * Creates a protocol with a given version @@ -112,8 +113,11 @@ function createProtocol ( onProtocolError, log ) { - switch (version) { - case 1: + if (!(version instanceof ProtocolVersion) || version === undefined || version === null) { + throw newError('Unknown Bolt protocol version: ' + version) + } + switch (version.toString()) { + case '1.0': return new BoltProtocolV1( server, chunker, @@ -122,7 +126,7 @@ function createProtocol ( log, onProtocolError ) - case 2: + case '2.0': return new BoltProtocolV2( server, chunker, @@ -131,7 +135,7 @@ function createProtocol ( log, onProtocolError ) - case 3: + case '3.0': return new BoltProtocolV3( server, chunker, @@ -140,7 +144,7 @@ function createProtocol ( log, onProtocolError ) - case 4.0: + case '4.0': return new BoltProtocolV4x0( server, chunker, @@ -149,7 +153,7 @@ function createProtocol ( log, onProtocolError ) - case 4.1: + case '4.1': return new BoltProtocolV4x1( server, chunker, @@ -159,7 +163,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.2: + case '4.2': return new BoltProtocolV4x2( server, chunker, @@ -169,7 +173,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.3: + case '4.3': return new BoltProtocolV4x3( server, chunker, @@ -179,7 +183,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 4.4: + case '4.4': return new BoltProtocolV4x4( server, chunker, @@ -189,7 +193,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.0: + case '5.0': return new BoltProtocolV5x0( server, chunker, @@ -199,7 +203,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.1: + case '5.1': return new BoltProtocolV5x1( server, chunker, @@ -209,7 +213,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.2: + case '5.2': return new BoltProtocolV5x2( server, chunker, @@ -219,7 +223,7 @@ function createProtocol ( onProtocolError, serversideRouting ) - case 5.3: + case '5.3': return new BoltProtocolV5x3(server, chunker, packingConfig, @@ -227,7 +231,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.4: + case '5.4': return new BoltProtocolV5x4(server, chunker, packingConfig, @@ -235,7 +239,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.5: + case '5.5': return new BoltProtocolV5x5(server, chunker, packingConfig, @@ -243,7 +247,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.6: + case '5.6': return new BoltProtocolV5x6(server, chunker, packingConfig, @@ -251,7 +255,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.7: + case '5.7': return new BoltProtocolV5x7(server, chunker, packingConfig, @@ -259,7 +263,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 5.8: + case '5.8': return new BoltProtocolV5x8(server, chunker, packingConfig, @@ -267,7 +271,7 @@ function createProtocol ( log, onProtocolError, serversideRouting) - case 6.0: + case '6.0': return new BoltProtocolV6x0(server, chunker, packingConfig, diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js index adcf1624f..9ad9d02a1 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js @@ -17,6 +17,7 @@ import { alloc } from '../channel/index.js' import { newError } from '../../core/index.ts' +import { ProtocolVersion } from './protocol-version.js' const BOLT_MAGIC_PREAMBLE = 0x6060b017 const AVAILABLE_BOLT_PROTOCOLS = ['6.0', '5.8', '5.7', '5.6', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '3.0'] // bolt protocols the client will accept, ordered by preference @@ -69,7 +70,7 @@ function parseNegotiatedResponse (buffer, log) { '(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)' ) } - return Number(h[3] + '.' + h[2]) + return new ProtocolVersion(h[3], h[2]) } function handshakeNegotiationV2 (channel, buffer, log) { @@ -112,7 +113,7 @@ function handshakeNegotiationV2 (channel, buffer, log) { selectionBuffer.writeVarInt(capabilites) channel.write(selectionBuffer) resolve({ - protocolVersion: Number(major + '.' + minor), + protocolVersion: new ProtocolVersion(major, minor), capabilites, consumeRemainingBuffer: consumer => { if (buffer.hasRemaining()) { @@ -146,7 +147,7 @@ function newHandshakeBuffer () { */ /** * @typedef HandshakeResult - * @property {number} protocolVersion The protocol version negotiated in the handshake + * @property {ProtocolVersion} protocolVersion The protocol version negotiated in the handshake * @property {number} capabilites A bitmask representing the capabilities negotiated in the handshake * @property {function(BufferConsumerCallback)} consumeRemainingBuffer A function to consume the remaining buffer if it exists */ @@ -160,7 +161,7 @@ function newHandshakeBuffer () { */ export default function handshake (channel, log) { return initialHandshake(channel, log).then((result) => { - if (result.protocolVersion === 255.1) { + if (result.protocolVersion.equalTo(new ProtocolVersion(255, 1))) { return handshakeNegotiationV2(channel, result.buffer, log) } else { return result diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js new file mode 100644 index 000000000..4e41d43b9 --- /dev/null +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js @@ -0,0 +1,48 @@ +export class ProtocolVersion { + constructor (major, minor) { + this.major = major + this.minor = minor + } + + getMajor () { + return this.major + } + + getMinor () { + return this.major + } + + isLessThan (other) { + if (this.major < other.major) { + return true + } else if (this.major === other.major && this.minor < other.minor) { + return true + } + return false + } + + isGreaterThan (other) { + if (this.major > other.major) { + return true + } else if (this.major === other.major && this.minor > other.minor) { + return true + } + return false + } + + isGreaterOrEqualTo (other) { + return !this.isLessThan(other) + } + + isLessOrEqualTo (other) { + return !this.isGreaterThan(other) + } + + equalTo (other) { + return this.major === other.major && this.minor === other.minor + } + + toString () { + return this.major.toString() + '.' + this.minor.toString() + } +} diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js index 94d864865..fa2e10bf1 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js @@ -91,7 +91,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.toString() >= BOLT_PROTOCOL_V4_0 ) } @@ -104,19 +104,19 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.toString() >= BOLT_PROTOCOL_V3 ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.toString() >= BOLT_PROTOCOL_V4_4 ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.toString() >= BOLT_PROTOCOL_V5_1 ) } diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js index 1fc1e8639..3089b524e 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js @@ -260,25 +260,25 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider async supportsMultiDb () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_0 + version => version.toString() >= BOLT_PROTOCOL_V4_0 ) } async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V3 + version => version.toString() >= BOLT_PROTOCOL_V3 ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V4_4 + version => version.toString() >= BOLT_PROTOCOL_V4_4 ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version >= BOLT_PROTOCOL_V5_1 + version => version.toString() >= BOLT_PROTOCOL_V5_1 ) } @@ -611,7 +611,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider const connectionProvider = new SingleConnectionProvider(delegateConnection) const protocolVersion = connection.protocol().version - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return [new Session({ mode: WRITE, bookmarks: Bookmarks.empty(), diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/index.js b/packages/neo4j-driver-deno/lib/bolt-connection/index.js index fbb9783a5..3fdcba96a 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/index.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/index.js @@ -20,5 +20,6 @@ export * as bolt from './bolt/index.js' export * as buf from './buf/index.js' export * as channel from './channel/index.js' export * as packstream from './packstream/index.js' +export * from './bolt/protocol-version.js' export * from './connection-provider/index.js' diff --git a/packages/neo4j-driver-deno/lib/core/connection.ts b/packages/neo4j-driver-deno/lib/core/connection.ts index b45e746ca..fa0f20521 100644 --- a/packages/neo4j-driver-deno/lib/core/connection.ts +++ b/packages/neo4j-driver-deno/lib/core/connection.ts @@ -131,7 +131,7 @@ class Connection { * * @returns {number} */ - getProtocolVersion (): number { + getProtocolVersion (): string { throw new Error('Not implemented') } diff --git a/packages/neo4j-driver-deno/lib/core/internal/constants.ts b/packages/neo4j-driver-deno/lib/core/internal/constants.ts index 7403677c3..33de40970 100644 --- a/packages/neo4j-driver-deno/lib/core/internal/constants.ts +++ b/packages/neo4j-driver-deno/lib/core/internal/constants.ts @@ -23,24 +23,24 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default const ACCESS_MODE_READ: 'READ' = 'READ' const ACCESS_MODE_WRITE: 'WRITE' = 'WRITE' -const BOLT_PROTOCOL_V1: number = 1 -const BOLT_PROTOCOL_V2: number = 2 -const BOLT_PROTOCOL_V3: number = 3 -const BOLT_PROTOCOL_V4_0: number = 4.0 -const BOLT_PROTOCOL_V4_1: number = 4.1 -const BOLT_PROTOCOL_V4_2: number = 4.2 -const BOLT_PROTOCOL_V4_3: number = 4.3 -const BOLT_PROTOCOL_V4_4: number = 4.4 -const BOLT_PROTOCOL_V5_0: number = 5.0 -const BOLT_PROTOCOL_V5_1: number = 5.1 -const BOLT_PROTOCOL_V5_2: number = 5.2 -const BOLT_PROTOCOL_V5_3: number = 5.3 -const BOLT_PROTOCOL_V5_4: number = 5.4 -const BOLT_PROTOCOL_V5_5: number = 5.5 -const BOLT_PROTOCOL_V5_6: number = 5.6 -const BOLT_PROTOCOL_V5_7: number = 5.7 -const BOLT_PROTOCOL_V5_8: number = 5.8 -const BOLT_PROTOCOL_V6_0: number = 6.0 +const BOLT_PROTOCOL_V1: string = "1.0" +const BOLT_PROTOCOL_V2: string = "2.0" +const BOLT_PROTOCOL_V3: string = "3.0" +const BOLT_PROTOCOL_V4_0: string = "4.0" +const BOLT_PROTOCOL_V4_1: string = "4.1" +const BOLT_PROTOCOL_V4_2: string = "4.2" +const BOLT_PROTOCOL_V4_3: string = "4.3" +const BOLT_PROTOCOL_V4_4: string = "4.4" +const BOLT_PROTOCOL_V5_0: string = "5.0" +const BOLT_PROTOCOL_V5_1: string = "5.1" +const BOLT_PROTOCOL_V5_2: string = "5.2" +const BOLT_PROTOCOL_V5_3: string = "5.3" +const BOLT_PROTOCOL_V5_4: string = "5.4" +const BOLT_PROTOCOL_V5_5: string = "5.5" +const BOLT_PROTOCOL_V5_6: string = "5.6" +const BOLT_PROTOCOL_V5_7: string = "5.7" +const BOLT_PROTOCOL_V5_8: string = "5.8" +const BOLT_PROTOCOL_V6_0: string = "6.0" const TELEMETRY_APIS = { MANAGED_TRANSACTION: 0, diff --git a/packages/neo4j-driver-deno/lib/core/result-summary.ts b/packages/neo4j-driver-deno/lib/core/result-summary.ts index 2a1bedc1e..7889e8b51 100644 --- a/packages/neo4j-driver-deno/lib/core/result-summary.ts +++ b/packages/neo4j-driver-deno/lib/core/result-summary.ts @@ -42,13 +42,13 @@ class ResultSummary { * @param {string} query - The query this summary is for * @param {Object} parameters - Parameters for the query * @param {Object} metadata - Query metadata - * @param {number|undefined} protocolVersion - Bolt Protocol Version + * @param {string|undefined} protocolVersion - Bolt Protocol Version */ constructor ( query: string, parameters: { [key: string]: any }, metadata: any, - protocolVersion?: number + protocolVersion?: string ) { /** * The query and parameters this summary is for. @@ -434,7 +434,7 @@ class QueryStatistics { */ class ServerInfo { address?: string - protocolVersion?: number + protocolVersion?: string agent?: string /** @@ -442,9 +442,9 @@ class ServerInfo { * @constructor * @param {Object} serverMeta - Object with serverMeta data * @param {Object} connectionInfo - Bolt connection info - * @param {number} protocolVersion - Bolt Protocol Version + * @param {string} protocolVersion - Bolt Protocol Version */ - constructor (serverMeta?: any, protocolVersion?: number) { + constructor (serverMeta?: any, protocolVersion?: string) { if (serverMeta != null) { /** * The server adress @@ -463,7 +463,7 @@ class ServerInfo { /** * The protocol version used by the connection - * @type {number} + * @type {string} * @public */ this.protocolVersion = protocolVersion diff --git a/packages/neo4j-driver/test/driver.test.js b/packages/neo4j-driver/test/driver.test.js index 7332de92b..8a35f5611 100644 --- a/packages/neo4j-driver/test/driver.test.js +++ b/packages/neo4j-driver/test/driver.test.js @@ -591,7 +591,7 @@ describe('#integration driver', () => { `neo4j://${sharedNeo4j.hostnameWithBoltPort}`, sharedNeo4j.authToken ) - if (protocolVersion >= 5.8) { + if (protocolVersion.isGreaterOrEqualTo({ major: 4, minor: 0 })) { try { const session1 = driver.session(auth) await session1.run('CREATE () RETURN 42') diff --git a/packages/neo4j-driver/test/examples.test.js b/packages/neo4j-driver/test/examples.test.js index cfec25faf..864e59534 100644 --- a/packages/neo4j-driver/test/examples.test.js +++ b/packages/neo4j-driver/test/examples.test.js @@ -118,7 +118,7 @@ describe('#integration examples', () => { }, 60000) it('rx autocommit transaction example', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -617,7 +617,7 @@ describe('#integration examples', () => { }) it('rx result consume example', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -795,7 +795,7 @@ describe('#integration examples', () => { }, 60000) it('rx transaction function example', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -898,7 +898,7 @@ describe('#integration examples', () => { }, 60000) it('use another database example', async () => { - if (protocolVersion < 4.0 || edition !== 'enterprise') { + if (protocolVersion.isLessThan({ major: 4, minor: 0 } || edition !== 'enterprise')) { return } diff --git a/packages/neo4j-driver/test/internal/connection-channel.test.js b/packages/neo4j-driver/test/internal/connection-channel.test.js index 7e42a8c6a..b3bd61aa7 100644 --- a/packages/neo4j-driver/test/internal/connection-channel.test.js +++ b/packages/neo4j-driver/test/internal/connection-channel.test.js @@ -428,7 +428,7 @@ describe('#integration ChannelConnection', () => { expect(messages[0].signature).toEqual(0x01) // first message is either INIT or HELLO const protocolVersion = connection.protocol().version - if (protocolVersion >= 3) { + if (protocolVersion.isLessThan({ major: 3, minor: 0 })) { expect(messages[messages.length - 1].signature).toEqual(0x02) // last message is GOODBYE in V3 } }) diff --git a/packages/neo4j-driver/test/rx/navigation.test.js b/packages/neo4j-driver/test/rx/navigation.test.js index e8f0a7d6d..9252378f2 100644 --- a/packages/neo4j-driver/test/rx/navigation.test.js +++ b/packages/neo4j-driver/test/rx/navigation.test.js @@ -380,7 +380,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeys (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -401,7 +401,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -415,7 +415,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeysAndRecords (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -432,7 +432,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnRecordsAndSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -449,7 +449,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeysRecordsAndSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -470,7 +470,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -495,7 +495,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -515,7 +515,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -532,7 +532,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnKeysMultipleTimes (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -551,7 +551,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnSummaryMultipleTimes (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -570,7 +570,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnRecordsOnlyOnce (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -596,7 +596,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -619,7 +619,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -636,7 +636,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -651,7 +651,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldFailOnKeysWhenRunFails (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -674,7 +674,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -693,7 +693,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldFailOnRecordsWhenRunFails (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -716,7 +716,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -742,7 +742,7 @@ describe('#integration-rx navigation', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldFailOnSummaryWhenRunFails (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -765,7 +765,7 @@ describe('#integration-rx navigation', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -800,7 +800,7 @@ describe('#integration-rx navigation', () => { selectObservable, closeFunc ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/nested-statements.test.js b/packages/neo4j-driver/test/rx/nested-statements.test.js index 08de9eecd..2ba854eff 100644 --- a/packages/neo4j-driver/test/rx/nested-statements.test.js +++ b/packages/neo4j-driver/test/rx/nested-statements.test.js @@ -56,7 +56,7 @@ describe('#integration-rx transaction', () => { it('should handle nested queries within one transaction', async () => { const size = 1024 - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -93,7 +93,7 @@ describe('#integration-rx transaction', () => { it('should give proper error when nesting queries within one session', async () => { const size = 1024 - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/session.test.js b/packages/neo4j-driver/test/rx/session.test.js index d74915711..1c5fbdd4e 100644 --- a/packages/neo4j-driver/test/rx/session.test.js +++ b/packages/neo4j-driver/test/rx/session.test.js @@ -56,7 +56,7 @@ describe('#integration rx-session', () => { }) it('should be able to run a simple query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -80,7 +80,7 @@ describe('#integration rx-session', () => { }, 60000) it('should be able to reuse session after failure', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -109,7 +109,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transactions without retries', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -131,7 +131,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on reactive failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -158,7 +158,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on synchronous failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -185,7 +185,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail on transactions that cannot be retried', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -208,7 +208,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail even after a transient error', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -239,7 +239,7 @@ describe('#integration rx-session', () => { describe('.executeWrite()', () => { it('should run transactions without retries', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -261,7 +261,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on reactive failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -288,7 +288,7 @@ describe('#integration rx-session', () => { }, 60000) it('should run transaction with retries on synchronous failures', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -315,7 +315,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail on transactions that cannot be retried', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -338,7 +338,7 @@ describe('#integration rx-session', () => { }, 60000) it('should fail even after a transient error', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/summary.test.js b/packages/neo4j-driver/test/rx/summary.test.js index 0c9b6d7a9..228c5ebeb 100644 --- a/packages/neo4j-driver/test/rx/summary.test.js +++ b/packages/neo4j-driver/test/rx/summary.test.js @@ -260,7 +260,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnNonNullSummary (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -277,7 +277,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnSummaryWithQueryText (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -295,7 +295,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -314,7 +314,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -333,7 +333,7 @@ describe('#integration-rx summary', () => { session, useTransaction = false ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -370,7 +370,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -402,7 +402,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -440,7 +440,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -472,7 +472,7 @@ describe('#integration-rx summary', () => { driver, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -513,7 +513,7 @@ describe('#integration-rx summary', () => { protocolVersion, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -544,7 +544,7 @@ describe('#integration-rx summary', () => { driver, runnable ) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -582,7 +582,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldNotReturnPlanAndProfile (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -602,7 +602,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnPlanButNoProfile (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -623,7 +623,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnPlanAndProfile (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -645,7 +645,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldNotReturnNotification (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -663,7 +663,7 @@ describe('#integration-rx summary', () => { * @param {RxSession|RxTransaction} runnable */ async function shouldReturnNotification (protocolVersion, runnable) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/rx/transaction.test.js b/packages/neo4j-driver/test/rx/transaction.test.js index 1aaf44ab3..cc28f94e0 100644 --- a/packages/neo4j-driver/test/rx/transaction.test.js +++ b/packages/neo4j-driver/test/rx/transaction.test.js @@ -55,7 +55,7 @@ describe('#integration-rx transaction', () => { }) it('should commit an empty transaction', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -72,7 +72,7 @@ describe('#integration-rx transaction', () => { }) it('should rollback an empty transaction', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -89,7 +89,7 @@ describe('#integration-rx transaction', () => { }) it('should run query and commit', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -118,7 +118,7 @@ describe('#integration-rx transaction', () => { }) it('should run query and rollback', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -147,7 +147,7 @@ describe('#integration-rx transaction', () => { }) it('should run query and close', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -200,7 +200,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to commit after a failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -224,7 +224,7 @@ describe('#integration-rx transaction', () => { }) it('should succeed to rollback after a failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -240,7 +240,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to commit after successful and failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -266,7 +266,7 @@ describe('#integration-rx transaction', () => { }) it('should succeed to rollback after successful and failed query', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -284,7 +284,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to run another query after a failed one', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -309,7 +309,7 @@ describe('#integration-rx transaction', () => { }) it('should not allow commit after commit', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -334,7 +334,7 @@ describe('#integration-rx transaction', () => { }) it('should not allow rollback after rollback', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -359,7 +359,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to rollback after commit', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -384,7 +384,7 @@ describe('#integration-rx transaction', () => { }) it('should fail to commit after rollback', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -417,7 +417,7 @@ describe('#integration-rx transaction', () => { }) it('should update bookmarks', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -441,7 +441,7 @@ describe('#integration-rx transaction', () => { }) it('should propagate failures from queries', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -473,7 +473,7 @@ describe('#integration-rx transaction', () => { }) it('should not run until subscribed', async () => { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -517,7 +517,7 @@ describe('#integration-rx transaction', () => { it('should not propagate run failure from summary', async () => { pending('behaviour difference across drivers') - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -539,7 +539,7 @@ describe('#integration-rx transaction', () => { }) async function verifyNoFailureIfNotExecuted (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -551,7 +551,7 @@ describe('#integration-rx transaction', () => { } async function verifyFailToRunQueryAfterTxcIsComplete (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -576,7 +576,7 @@ describe('#integration-rx transaction', () => { } async function verifyCanRunMultipleQueries (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -600,7 +600,7 @@ describe('#integration-rx transaction', () => { } async function verifyCanRunMultipleQueriesWithoutWaiting (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } @@ -626,7 +626,7 @@ describe('#integration-rx transaction', () => { } async function verifyCanRunMultipleQueriesWithoutStreaming (commit) { - if (protocolVersion < 4.0) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 })) { return } diff --git a/packages/neo4j-driver/test/spatial-types.test.js b/packages/neo4j-driver/test/spatial-types.test.js index 94d1be2b4..5a1e766d8 100644 --- a/packages/neo4j-driver/test/spatial-types.test.js +++ b/packages/neo4j-driver/test/spatial-types.test.js @@ -309,7 +309,7 @@ describe('#integration spatial-types', () => { } function neo4jDoesNotSupportPoints (done) { - if (protocolVersion < 2) { + if (protocolVersion.isLessThan({ major: 2, minor: 0 })) { done() return true } diff --git a/packages/neo4j-driver/test/temporal-types.test.js b/packages/neo4j-driver/test/temporal-types.test.js index 9d43932b3..bbb1f933f 100644 --- a/packages/neo4j-driver/test/temporal-types.test.js +++ b/packages/neo4j-driver/test/temporal-types.test.js @@ -1466,7 +1466,7 @@ describe('#integration temporal-types', () => { } function neo4jDoesNotSupportTemporalTypes () { - if (protocolVersion < 2) { + if (protocolVersion.isLessThan({ major: 2, minor: 0 })) { return true } return false diff --git a/packages/neo4j-driver/test/vector-type.test.js b/packages/neo4j-driver/test/vector-type.test.js index 713022291..b318aaa51 100644 --- a/packages/neo4j-driver/test/vector-type.test.js +++ b/packages/neo4j-driver/test/vector-type.test.js @@ -47,7 +47,7 @@ describe('#integration vector type', () => { }) it('write and read vectors', async () => { - if (protocolVersion >= 6.0 && edition === 'enterprise') { + if (protocolVersion.isLessThan({ major: 6, minor: 0 }) && edition === 'enterprise') { const driver = driverGlobal const bufferWriter = Uint8Array.from([1, 1]) From 5773cd594e9e5f052a4502dad0aba61c05d0e979 Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:44:46 +0200 Subject: [PATCH 2/9] change to ProtocolVersion object --- packages/bolt-connection/src/bolt/create.js | 3 +- .../bolt-connection/src/bolt/handshake.js | 3 +- .../connection-provider-direct.js | 8 ++-- .../connection-provider-routing.js | 8 ++-- .../test/bolt/bolt-protocol-v1.test.js | 5 ++- .../test/bolt/bolt-protocol-v2.test.js | 5 ++- .../test/bolt/bolt-protocol-v3.test.js | 5 ++- .../test/bolt/bolt-protocol-v4x0.test.js | 5 ++- .../test/bolt/bolt-protocol-v4x3.test.js | 5 ++- .../test/bolt/bolt-protocol-v4x4.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x0.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x1.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x2.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x3.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x4.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x5.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x6.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x7.test.js | 5 ++- .../test/bolt/bolt-protocol-v5x8.test.js | 5 ++- .../test/bolt/bolt-protocol-v6x0.test.js | 5 ++- .../bolt-connection/test/bolt/index.test.js | 38 +++++++++---------- packages/core/src/connection-provider.ts | 3 +- packages/core/src/connection.ts | 3 +- packages/core/src/driver.ts | 3 +- packages/core/src/index.ts | 7 +++- packages/core/src/internal/constants.ts | 38 ++++++++++--------- .../src/internal/protocol-version.ts} | 20 +++++----- packages/core/src/result-summary.ts | 13 ++++--- packages/core/test/driver.test.ts | 7 ++-- packages/core/test/result-summary.test.ts | 7 ++-- packages/core/test/result.test.ts | 11 +++--- packages/core/test/utils/connection.fake.ts | 9 +++-- .../neo4j-driver/test/temporal-types.test.js | 2 +- 33 files changed, 146 insertions(+), 117 deletions(-) rename packages/{bolt-connection/src/bolt/protocol-version.js => core/src/internal/protocol-version.ts} (61%) diff --git a/packages/bolt-connection/src/bolt/create.js b/packages/bolt-connection/src/bolt/create.js index c6e5df0b8..5974e2a29 100644 --- a/packages/bolt-connection/src/bolt/create.js +++ b/packages/bolt-connection/src/bolt/create.js @@ -15,7 +15,7 @@ * limitations under the License. */ -import { newError } from 'neo4j-driver-core' +import { newError, ProtocolVersion } from 'neo4j-driver-core' import BoltProtocolV1 from './bolt-protocol-v1' import BoltProtocolV2 from './bolt-protocol-v2' import BoltProtocolV3 from './bolt-protocol-v3' @@ -37,7 +37,6 @@ import BoltProtocolV6x0 from './bolt-protocol-v6x0' // eslint-disable-next-line no-unused-vars import { Chunker, Dechunker } from '../channel' import ResponseHandler from './response-handler' -import { ProtocolVersion } from './protocol-version' /** * Creates a protocol with a given version diff --git a/packages/bolt-connection/src/bolt/handshake.js b/packages/bolt-connection/src/bolt/handshake.js index 3decb7e54..27e3c4b51 100644 --- a/packages/bolt-connection/src/bolt/handshake.js +++ b/packages/bolt-connection/src/bolt/handshake.js @@ -16,8 +16,7 @@ */ import { alloc } from '../channel' -import { newError } from 'neo4j-driver-core' -import { ProtocolVersion } from './protocol-version' +import { newError, ProtocolVersion } from 'neo4j-driver-core' const BOLT_MAGIC_PREAMBLE = 0x6060b017 const AVAILABLE_BOLT_PROTOCOLS = ['6.0', '5.8', '5.7', '5.6', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '3.0'] // bolt protocols the client will accept, ordered by preference diff --git a/packages/bolt-connection/src/connection-provider/connection-provider-direct.js b/packages/bolt-connection/src/connection-provider/connection-provider-direct.js index 6c18130f3..d322450a5 100644 --- a/packages/bolt-connection/src/connection-provider/connection-provider-direct.js +++ b/packages/bolt-connection/src/connection-provider/connection-provider-direct.js @@ -91,7 +91,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsMultiDb () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } @@ -104,19 +104,19 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } diff --git a/packages/bolt-connection/src/connection-provider/connection-provider-routing.js b/packages/bolt-connection/src/connection-provider/connection-provider-routing.js index e87fec6a2..9ff7fd82f 100644 --- a/packages/bolt-connection/src/connection-provider/connection-provider-routing.js +++ b/packages/bolt-connection/src/connection-provider/connection-provider-routing.js @@ -260,25 +260,25 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider async supportsMultiDb () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js index 7b5ada8ed..ad82fce1b 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js @@ -32,7 +32,8 @@ import { UnboundRelationship, Node, newError, - Vector + Vector, + ProtocolVersion } from 'neo4j-driver-core' import utils from '../test-utils' import { LoginObserver } from '../../src/bolt/stream-observers' @@ -224,7 +225,7 @@ describe('#unit BoltProtocolV1', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV1(null, null, false) - expect(protocol.version).toBe('1.0') + expect(protocol.version).toEqual(new ProtocolVersion(1, 0)) }) describe('Bolt V3', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js index efd040079..301fccaca 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js @@ -31,7 +31,8 @@ import { Relationship, Time, UnboundRelationship, - Node + Node, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -69,7 +70,7 @@ describe('#unit BoltProtocolV2', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV2(null, null, false) - expect(protocol.version).toBe('2.0') + expect(protocol.version).toEqual(new ProtocolVersion(2, 0)) }) describe('unpacker configuration', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js index bfeb83117..12a5a8407 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js @@ -36,7 +36,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -202,7 +203,7 @@ describe('#unit BoltProtocolV3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV3(null, null, false) - expect(protocol.version).toBe('3.0') + expect(protocol.version).toEqual(new ProtocolVersion(3, 0)) }) it('should request the routing table from the correct procedure', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js index 0da093061..34590dddc 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js @@ -36,7 +36,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -149,7 +150,7 @@ describe('#unit BoltProtocolV4x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x0(null, null, false) - expect(protocol.version).toBe('4.0') + expect(protocol.version).toEqual(new ProtocolVersion(4, 0)) }) it('should request the routing table from the correct procedure', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js index 768411c03..5844ff6f8 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js @@ -32,7 +32,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -169,7 +170,7 @@ describe('#unit BoltProtocolV4x3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x3(null, null, false) - expect(protocol.version).toBe('4.3') + expect(protocol.version).toEqual(new ProtocolVersion(4, 3)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js index 2b6148700..49869979f 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js @@ -32,7 +32,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV4x4', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV4x4(null, null, false) - expect(protocol.version).toBe('4.4') + expect(protocol.version).toEqual(new ProtocolVersion(4, 4)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js index 05cf0b304..04126daa7 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x0(null, null, false) - expect(protocol.version).toBe('5.0') + expect(protocol.version).toEqual(new ProtocolVersion(5, 0)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js index e5ecc9c83..801b2d189 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x1', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x1(null, null, false) - expect(protocol.version).toBe('5.1') + expect(protocol.version).toEqual(new ProtocolVersion(5, 1)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js index ab7e3b088..d24adc5ad 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x2', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x2(null, null, false) - expect(protocol.version).toBe('5.2') + expect(protocol.version).toEqual(new ProtocolVersion(5, 2)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js index a22899efc..c0ca5182c 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -243,7 +244,7 @@ describe('#unit BoltProtocolV5x3', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x3(null, null, false) - expect(protocol.version).toBe('5.3') + expect(protocol.version).toEqual(new ProtocolVersion(5, 3)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js index 24e65b988..7005950b7 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x4.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -245,7 +246,7 @@ describe('#unit BoltProtocolV5x4', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x4(null, null, false) - expect(protocol.version).toBe('5.4') + expect(protocol.version).toEqual(new ProtocolVersion(5, 4)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js index c1523be5b..598817bcb 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x5.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -245,7 +246,7 @@ describe('#unit BoltProtocolV5x5', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x5(null, null, false) - expect(protocol.version).toBe('5.5') + expect(protocol.version).toEqual(new ProtocolVersion(5, 5)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js index 181c7f7ef..9403ae467 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x6.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -245,7 +246,7 @@ describe('#unit BoltProtocolV5x6', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x6(null, null, false) - expect(protocol.version).toBe('5.6') + expect(protocol.version).toEqual(new ProtocolVersion(5, 6)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js index fbc4666be..717668744 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x7.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -254,7 +255,7 @@ describe('#unit BoltProtocolV5x7', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x7(null, null, false) - expect(protocol.version).toBe('5.7') + expect(protocol.version).toEqual(new ProtocolVersion(5, 7)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js index f4eae35af..ceb551b06 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v5x8.test.js @@ -34,7 +34,8 @@ import { Time, UnboundRelationship, Node, - internal + internal, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -254,7 +255,7 @@ describe('#unit BoltProtocolV5x8', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV5x8(null, null, false) - expect(protocol.version).toBe('5.8') + expect(protocol.version).toEqual(new ProtocolVersion(5, 8)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js b/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js index 90e890e02..7abaad9ab 100644 --- a/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js +++ b/packages/bolt-connection/test/bolt/bolt-protocol-v6x0.test.js @@ -36,7 +36,8 @@ import { Node, internal, vector, - json + json, + ProtocolVersion } from 'neo4j-driver-core' import { alloc } from '../../src/channel' @@ -256,7 +257,7 @@ describe('#unit BoltProtocolV6x0', () => { it('should return correct bolt version number', () => { const protocol = new BoltProtocolV6x0(null, null, false) - expect(protocol.version).toBe('6.0') + expect(protocol.version).toEqual(new ProtocolVersion(6, 0)) }) it('should update metadata', () => { diff --git a/packages/bolt-connection/test/bolt/index.test.js b/packages/bolt-connection/test/bolt/index.test.js index 1529a38f4..1c721ab25 100644 --- a/packages/bolt-connection/test/bolt/index.test.js +++ b/packages/bolt-connection/test/bolt/index.test.js @@ -17,7 +17,7 @@ import Bolt from '../../src/bolt' import DummyChannel from '../dummy-channel' import { alloc } from '../../src/channel' -import { newError, internal } from 'neo4j-driver-core' +import { newError, internal, ProtocolVersion } from 'neo4j-driver-core' import { Chunker, Dechunker } from '../../src/channel/chunking' import BoltProtocolV1 from '../../src/bolt/bolt-protocol-v1' @@ -383,24 +383,24 @@ describe('#unit Bolt', () => { } const availableProtocols = [ - v('1.0', BoltProtocolV1), - v('2.0', BoltProtocolV2), - v('3.0', BoltProtocolV3), - v('4.0', BoltProtocolV4x0), - v('4.1', BoltProtocolV4x1), - v('4.2', BoltProtocolV4x2), - v('4.3', BoltProtocolV4x3), - v('4.4', BoltProtocolV4x4), - v('5.0', BoltProtocolV5x0), - v('5.1', BoltProtocolV5x1), - v('5.2', BoltProtocolV5x2), - v('5.3', BoltProtocolV5x3), - v('5.4', BoltProtocolV5x4), - v('5.5', BoltProtocolV5x5), - v('5.6', BoltProtocolV5x6), - v('5.7', BoltProtocolV5x7), - v('5.8', BoltProtocolV5x8), - v('6.0', BoltProtocolV6x0) + v(new ProtocolVersion(1, 0), BoltProtocolV1), + v(new ProtocolVersion(2, 0), BoltProtocolV2), + v(new ProtocolVersion(3, 0), BoltProtocolV3), + v(new ProtocolVersion(4, 0), BoltProtocolV4x0), + v(new ProtocolVersion(4, 1), BoltProtocolV4x1), + v(new ProtocolVersion(4, 2), BoltProtocolV4x2), + v(new ProtocolVersion(4, 3), BoltProtocolV4x3), + v(new ProtocolVersion(4, 4), BoltProtocolV4x4), + v(new ProtocolVersion(5, 0), BoltProtocolV5x0), + v(new ProtocolVersion(5, 1), BoltProtocolV5x1), + v(new ProtocolVersion(5, 2), BoltProtocolV5x2), + v(new ProtocolVersion(5, 3), BoltProtocolV5x3), + v(new ProtocolVersion(5, 4), BoltProtocolV5x4), + v(new ProtocolVersion(5, 5), BoltProtocolV5x5), + v(new ProtocolVersion(5, 6), BoltProtocolV5x6), + v(new ProtocolVersion(5, 7), BoltProtocolV5x7), + v(new ProtocolVersion(5, 8), BoltProtocolV5x8), + v(new ProtocolVersion(6, 0), BoltProtocolV6x0) ] availableProtocols.forEach(lambda) diff --git a/packages/core/src/connection-provider.ts b/packages/core/src/connection-provider.ts index f9e1fe53a..a393026ef 100644 --- a/packages/core/src/connection-provider.ts +++ b/packages/core/src/connection-provider.ts @@ -18,6 +18,7 @@ import Connection from './connection' import { bookmarks } from './internal' +import { ProtocolVersion } from './internal/protocol-version' import { ServerInfo } from './result-summary' import { AuthToken } from './types' @@ -155,7 +156,7 @@ class ConnectionProvider { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { throw Error('Not Implemented') } diff --git a/packages/core/src/connection.ts b/packages/core/src/connection.ts index 2b03a4bd5..188d24be1 100644 --- a/packages/core/src/connection.ts +++ b/packages/core/src/connection.ts @@ -19,6 +19,7 @@ import { Bookmarks } from './internal/bookmarks' import { AccessMode, TelemetryApis } from './internal/constants' import { ResultStreamObserver } from './internal/observers' +import { ProtocolVersion } from './internal/protocol-version' import { TxConfig } from './internal/tx-config' import NotificationFilter from './notification-filter' @@ -131,7 +132,7 @@ class Connection { * * @returns {number} */ - getProtocolVersion (): string { + getProtocolVersion (): ProtocolVersion { throw new Error('Not implemented') } diff --git a/packages/core/src/driver.ts b/packages/core/src/driver.ts index 2f6fed974..144f42bca 100644 --- a/packages/core/src/driver.ts +++ b/packages/core/src/driver.ts @@ -48,6 +48,7 @@ import { newError } from './error' import NotificationFilter from './notification-filter' import HomeDatabaseCache from './internal/homedb-cache' import { cacheKey } from './internal/auth-util' +import { ProtocolVersion } from './internal/protocol-version' const DEFAULT_MAX_CONNECTION_LIFETIME: number = 60 * 60 * 1000 // 1 hour @@ -739,7 +740,7 @@ class Driver { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { const connectionProvider = this._getOrCreateConnectionProvider() return connectionProvider.getNegotiatedProtocolVersion() } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 83fc1400b..f0db6abba 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -103,6 +103,7 @@ import resultTransformers, { ResultTransformer } from './result-transformers' import ClientCertificate, { clientCertificateProviders, ClientCertificateProvider, ClientCertificateProviders, RotatingClientCertificateProvider, resolveCertificateProvider } from './client-certificate' import * as internal from './internal' // todo: removed afterwards import Vector, { VectorType, vector } from './vector' +import { ProtocolVersion } from './internal/protocol-version' /** * Object containing string constants representing predefined {@link Neo4jError} codes. @@ -189,7 +190,8 @@ const forExport = { notificationFilterDisabledClassification, notificationFilterMinimumSeverityLevel, clientCertificateProviders, - resolveCertificateProvider + resolveCertificateProvider, + ProtocolVersion } export { @@ -269,7 +271,8 @@ export { clientCertificateProviders, resolveCertificateProvider, Vector, - vector + vector, + ProtocolVersion } export type { diff --git a/packages/core/src/internal/constants.ts b/packages/core/src/internal/constants.ts index 2bf8aeb4c..032e81a6e 100644 --- a/packages/core/src/internal/constants.ts +++ b/packages/core/src/internal/constants.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +import { ProtocolVersion } from './protocol-version' + const FETCH_ALL = -1 const DEFAULT_POOL_ACQUISITION_TIMEOUT = 60 * 1000 // 60 seconds const DEFAULT_POOL_MAX_SIZE = 100 @@ -23,24 +25,24 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default const ACCESS_MODE_READ: 'READ' = 'READ' const ACCESS_MODE_WRITE: 'WRITE' = 'WRITE' -const BOLT_PROTOCOL_V1: string = '1.0' -const BOLT_PROTOCOL_V2: string = '2.0' -const BOLT_PROTOCOL_V3: string = '3.0' -const BOLT_PROTOCOL_V4_0: string = '4.0' -const BOLT_PROTOCOL_V4_1: string = '4.1' -const BOLT_PROTOCOL_V4_2: string = '4.2' -const BOLT_PROTOCOL_V4_3: string = '4.3' -const BOLT_PROTOCOL_V4_4: string = '4.4' -const BOLT_PROTOCOL_V5_0: string = '5.0' -const BOLT_PROTOCOL_V5_1: string = '5.1' -const BOLT_PROTOCOL_V5_2: string = '5.2' -const BOLT_PROTOCOL_V5_3: string = '5.3' -const BOLT_PROTOCOL_V5_4: string = '5.4' -const BOLT_PROTOCOL_V5_5: string = '5.5' -const BOLT_PROTOCOL_V5_6: string = '5.6' -const BOLT_PROTOCOL_V5_7: string = '5.7' -const BOLT_PROTOCOL_V5_8: string = '5.8' -const BOLT_PROTOCOL_V6_0: string = '6.0' +const BOLT_PROTOCOL_V1: ProtocolVersion = new ProtocolVersion(1, 0) +const BOLT_PROTOCOL_V2: ProtocolVersion = new ProtocolVersion(2, 0) +const BOLT_PROTOCOL_V3: ProtocolVersion = new ProtocolVersion(3, 0) +const BOLT_PROTOCOL_V4_0: ProtocolVersion = new ProtocolVersion(4, 0) +const BOLT_PROTOCOL_V4_1: ProtocolVersion = new ProtocolVersion(4, 1) +const BOLT_PROTOCOL_V4_2: ProtocolVersion = new ProtocolVersion(4, 2) +const BOLT_PROTOCOL_V4_3: ProtocolVersion = new ProtocolVersion(4, 3) +const BOLT_PROTOCOL_V4_4: ProtocolVersion = new ProtocolVersion(4, 4) +const BOLT_PROTOCOL_V5_0: ProtocolVersion = new ProtocolVersion(5, 0) +const BOLT_PROTOCOL_V5_1: ProtocolVersion = new ProtocolVersion(5, 1) +const BOLT_PROTOCOL_V5_2: ProtocolVersion = new ProtocolVersion(5, 2) +const BOLT_PROTOCOL_V5_3: ProtocolVersion = new ProtocolVersion(5, 3) +const BOLT_PROTOCOL_V5_4: ProtocolVersion = new ProtocolVersion(5, 4) +const BOLT_PROTOCOL_V5_5: ProtocolVersion = new ProtocolVersion(5, 5) +const BOLT_PROTOCOL_V5_6: ProtocolVersion = new ProtocolVersion(5, 6) +const BOLT_PROTOCOL_V5_7: ProtocolVersion = new ProtocolVersion(5, 7) +const BOLT_PROTOCOL_V5_8: ProtocolVersion = new ProtocolVersion(5, 8) +const BOLT_PROTOCOL_V6_0: ProtocolVersion = new ProtocolVersion(6, 0) const TELEMETRY_APIS = { MANAGED_TRANSACTION: 0, diff --git a/packages/bolt-connection/src/bolt/protocol-version.js b/packages/core/src/internal/protocol-version.ts similarity index 61% rename from packages/bolt-connection/src/bolt/protocol-version.js rename to packages/core/src/internal/protocol-version.ts index 4e41d43b9..4a2fd2b89 100644 --- a/packages/bolt-connection/src/bolt/protocol-version.js +++ b/packages/core/src/internal/protocol-version.ts @@ -1,18 +1,20 @@ export class ProtocolVersion { - constructor (major, minor) { + private readonly major: number + private readonly minor: number + constructor (major: number, minor: number) { this.major = major this.minor = minor } - getMajor () { + getMajor (): number { return this.major } - getMinor () { + getMinor (): number { return this.major } - isLessThan (other) { + isLessThan (other: ProtocolVersion): boolean { if (this.major < other.major) { return true } else if (this.major === other.major && this.minor < other.minor) { @@ -21,7 +23,7 @@ export class ProtocolVersion { return false } - isGreaterThan (other) { + isGreaterThan (other: ProtocolVersion): boolean { if (this.major > other.major) { return true } else if (this.major === other.major && this.minor > other.minor) { @@ -30,19 +32,19 @@ export class ProtocolVersion { return false } - isGreaterOrEqualTo (other) { + isGreaterOrEqualTo (other: ProtocolVersion): boolean { return !this.isLessThan(other) } - isLessOrEqualTo (other) { + isLessOrEqualTo (other: ProtocolVersion): boolean { return !this.isGreaterThan(other) } - equalTo (other) { + equalTo (other: ProtocolVersion): boolean { return this.major === other.major && this.minor === other.minor } - toString () { + toString (): string { return this.major.toString() + '.' + this.minor.toString() } } diff --git a/packages/core/src/result-summary.ts b/packages/core/src/result-summary.ts index 8bbc77792..fbfa21085 100644 --- a/packages/core/src/result-summary.ts +++ b/packages/core/src/result-summary.ts @@ -19,6 +19,7 @@ import Integer from './integer' import { NumberOrInteger } from './graph-types' import { util } from './internal' import GqlStatusObject, { Notification, buildGqlStatusObjectFromMetadata, buildNotificationsFromMetadata } from './notification' +import { ProtocolVersion } from './internal/protocol-version' /** * A ResultSummary instance contains structured metadata for a {@link Result}. @@ -42,13 +43,13 @@ class ResultSummary { * @param {string} query - The query this summary is for * @param {Object} parameters - Parameters for the query * @param {Object} metadata - Query metadata - * @param {string|undefined} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion|undefined} protocolVersion - Bolt Protocol Version */ constructor ( query: string, parameters: { [key: string]: any }, metadata: any, - protocolVersion?: string + protocolVersion?: ProtocolVersion ) { /** * The query and parameters this summary is for. @@ -434,7 +435,7 @@ class QueryStatistics { */ class ServerInfo { address?: string - protocolVersion?: string + protocolVersion?: ProtocolVersion agent?: string /** @@ -442,9 +443,9 @@ class ServerInfo { * @constructor * @param {Object} serverMeta - Object with serverMeta data * @param {Object} connectionInfo - Bolt connection info - * @param {string} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion} protocolVersion - Bolt Protocol Version */ - constructor (serverMeta?: any, protocolVersion?: string) { + constructor (serverMeta?: any, protocolVersion?: ProtocolVersion) { if (serverMeta != null) { /** * The server adress @@ -463,7 +464,7 @@ class ServerInfo { /** * The protocol version used by the connection - * @type {string} + * @type {ProtocolVersion} * @public */ this.protocolVersion = protocolVersion diff --git a/packages/core/test/driver.test.ts b/packages/core/test/driver.test.ts index 2c1b1055d..8b45f1714 100644 --- a/packages/core/test/driver.test.ts +++ b/packages/core/test/driver.test.ts @@ -25,6 +25,7 @@ import { LogLevel } from '../src/types' import resultTransformers from '../src/result-transformers' import Record, { RecordShape } from '../src/record' import { invalidNotificationFilters, validNotificationFilters } from './utils/notification-filters.fixtures' +import { ProtocolVersion } from '../src/internal/protocol-version' describe('Driver', () => { let driver: Driver | null @@ -391,7 +392,7 @@ describe('Driver', () => { const expected: EagerResult = { keys: ['a'], records: [], - summary: new ResultSummary(query, params, {}, 5.0) + summary: new ResultSummary(query, params, {}, new ProtocolVersion(5, 0)) } spiedExecute.mockResolvedValue(expected) @@ -414,7 +415,7 @@ describe('Driver', () => { const expected: EagerResult = { keys: ['a'], records: [], - summary: new ResultSummary(query, params, {}, 5.0) + summary: new ResultSummary(query, params, {}, new ProtocolVersion(5, 0)) } spiedExecute.mockResolvedValue(expected) @@ -447,7 +448,7 @@ describe('Driver', () => { records: [ new Record(['name', 'age'], ['A Person', 25]) ], - summary: new ResultSummary(query, params, {}, 5.0) + summary: new ResultSummary(query, params, {}, new ProtocolVersion(5, 0)) } spiedExecute.mockResolvedValue(expected) diff --git a/packages/core/test/result-summary.test.ts b/packages/core/test/result-summary.test.ts index 69c28595f..051970c58 100644 --- a/packages/core/test/result-summary.test.ts +++ b/packages/core/test/result-summary.test.ts @@ -16,6 +16,7 @@ */ import { int } from '../src' +import { ProtocolVersion } from '../src/internal/protocol-version' import { ServerInfo, ProfiledPlan, @@ -29,10 +30,10 @@ describe('ServerInfo', () => { it.each([ [ { address: '192.168.0.1', version: 'neo4j' }, - 4.3, + new ProtocolVersion(4, 3), { address: '192.168.0.1', - protocolVersion: 4.3, + protocolVersion: new ProtocolVersion(4, 3), agent: 'neo4j' } ], @@ -45,7 +46,7 @@ describe('ServerInfo', () => { agent: 'neo4j' } ], - [undefined, 4.3, { protocolVersion: 4.3 }], + [undefined, new ProtocolVersion(4, 3), { protocolVersion: new ProtocolVersion(4, 3) }], [undefined, undefined, {}] ])( 'new ServerInfo(%o, %i) === %j', diff --git a/packages/core/test/result.test.ts b/packages/core/test/result.test.ts index fcba57ad0..4cbc08950 100644 --- a/packages/core/test/result.test.ts +++ b/packages/core/test/result.test.ts @@ -26,6 +26,7 @@ import ResultStreamObserverMock from './utils/result-stream-observer.mock' import Result from '../src/result' import FakeConnection from './utils/connection.fake' import { Logger } from '../src/internal/logger' +import { ProtocolVersion } from '../src/internal/protocol-version' interface AB { a: number @@ -188,7 +189,7 @@ describe('Result', () => { resultAvailableAfter: 124, extraInfo: 'extra' } - const protocolVersion = 5.0 + const protocolVersion = new ProtocolVersion(5, 0) const expectedSummary = new ResultSummary( expected.query, @@ -462,7 +463,7 @@ describe('Result', () => { expect(releaseConnection).toHaveBeenCalled() }) - it.each([123, undefined])( + it.each([new ProtocolVersion(123, 0), undefined])( 'should enrich summary with the protocol version onCompleted', async version => { const connectionMock = new FakeConnection() @@ -470,7 +471,7 @@ describe('Result', () => { // this test is considering the situation where protocol version // is undefined, which should not happen during normal driver // operation. - connectionMock.protocolVersion = version as unknown as number + connectionMock.protocolVersion = version as unknown as ProtocolVersion connectionHolderMock.getConnection = async (): Promise => { return connectionMock @@ -676,7 +677,7 @@ describe('Result', () => { expect(releaseConnection).toHaveBeenCalled() }) - it.each([123, undefined])( + it.each([new ProtocolVersion(123, 0), undefined])( 'should enrich summary with the protocol version on completed', async version => { const connectionMock = new FakeConnection() @@ -684,7 +685,7 @@ describe('Result', () => { // this test is considering the situation where protocol version // is undefined, which should not happen during normal driver // operation. - connectionMock.protocolVersion = version as unknown as number + connectionMock.protocolVersion = version as unknown as ProtocolVersion connectionHolderMock.getConnection = async (): Promise => { return await Promise.resolve(connectionMock) diff --git a/packages/core/test/utils/connection.fake.ts b/packages/core/test/utils/connection.fake.ts index a96830a92..ef5fb176f 100644 --- a/packages/core/test/utils/connection.fake.ts +++ b/packages/core/test/utils/connection.fake.ts @@ -18,6 +18,7 @@ import { Connection, ResultObserver, ResultSummary } from '../../src' import { BeginTransactionConfig, CommitTransactionConfig, RollbackConnectionConfig, RunQueryConfig } from '../../src/connection' import { ResultStreamObserver } from '../../src/internal/observers' +import { ProtocolVersion } from '../../src/internal/protocol-version' /** * This class is like a mock of {@link Connection} that tracks invocations count. @@ -38,7 +39,7 @@ export default class FakeConnection extends Connection { public seenParameters: any[] public seenProtocolOptions: any[] private readonly _server: any - public protocolVersion: string + public protocolVersion: ProtocolVersion public protocolErrorsHandled: number public seenProtocolErrors: string[] public seenRequestRoutingInformation: any[] @@ -61,7 +62,7 @@ export default class FakeConnection extends Connection { this.seenParameters = [] this.seenProtocolOptions = [] this._server = {} - this.protocolVersion = '1.0' + this.protocolVersion = new ProtocolVersion(1, 0) this.protocolErrorsHandled = 0 this.seenProtocolErrors = [] this.seenRequestRoutingInformation = [] @@ -119,7 +120,7 @@ export default class FakeConnection extends Connection { return mockResultStreamObserver('ROLLBACK', {}) } - getProtocolVersion (): string { + getProtocolVersion (): ProtocolVersion { return this.protocolVersion } @@ -152,7 +153,7 @@ export default class FakeConnection extends Connection { this.seenProtocolErrors.push(message) } - withProtocolVersion (version: number): FakeConnection { + withProtocolVersion (version: ProtocolVersion): FakeConnection { this.protocolVersion = version return this } diff --git a/packages/neo4j-driver/test/temporal-types.test.js b/packages/neo4j-driver/test/temporal-types.test.js index bbb1f933f..86eed37b8 100644 --- a/packages/neo4j-driver/test/temporal-types.test.js +++ b/packages/neo4j-driver/test/temporal-types.test.js @@ -1466,7 +1466,7 @@ describe('#integration temporal-types', () => { } function neo4jDoesNotSupportTemporalTypes () { - if (protocolVersion.isLessThan({ major: 2, minor: 0 })) { + if (protocolVersion?.isLessThan({ major: 2, minor: 0 })) { return true } return false From 1c67af2099098ec930aca0cdaaf2704d84f8f82a Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:50:28 +0200 Subject: [PATCH 3/9] deno sync and fix --- packages/bolt-connection/src/index.js | 1 - .../lib/bolt-connection/bolt/create.js | 3 +- .../lib/bolt-connection/bolt/handshake.js | 3 +- .../connection-provider-direct.js | 8 ++-- .../connection-provider-routing.js | 8 ++-- .../lib/bolt-connection/index.js | 1 - .../lib/core/connection-provider.ts | 3 +- .../neo4j-driver-deno/lib/core/connection.ts | 3 +- packages/neo4j-driver-deno/lib/core/driver.ts | 3 +- packages/neo4j-driver-deno/lib/core/index.ts | 7 +++- .../lib/core/internal/constants.ts | 38 ++++++++++--------- .../internal/protocol-version.ts} | 20 +++++----- .../lib/core/result-summary.ts | 13 ++++--- 13 files changed, 59 insertions(+), 52 deletions(-) rename packages/neo4j-driver-deno/lib/{bolt-connection/bolt/protocol-version.js => core/internal/protocol-version.ts} (61%) diff --git a/packages/bolt-connection/src/index.js b/packages/bolt-connection/src/index.js index d8fcd1669..d27358e1f 100644 --- a/packages/bolt-connection/src/index.js +++ b/packages/bolt-connection/src/index.js @@ -20,6 +20,5 @@ export * as bolt from './bolt' export * as buf from './buf' export * as channel from './channel' export * as packstream from './packstream' -export * from './bolt/protocol-version' export * from './connection-provider' diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js index 58cc1b211..9c8885202 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/create.js @@ -15,7 +15,7 @@ * limitations under the License. */ -import { newError } from '../../core/index.ts' +import { newError, ProtocolVersion } from '../../core/index.ts' import BoltProtocolV1 from './bolt-protocol-v1.js' import BoltProtocolV2 from './bolt-protocol-v2.js' import BoltProtocolV3 from './bolt-protocol-v3.js' @@ -37,7 +37,6 @@ import BoltProtocolV6x0 from './bolt-protocol-v6x0.js' // eslint-disable-next-line no-unused-vars import { Chunker, Dechunker } from '../channel/index.js' import ResponseHandler from './response-handler.js' -import { ProtocolVersion } from './protocol-version.js' /** * Creates a protocol with a given version diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js index 9ad9d02a1..91276257a 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/bolt/handshake.js @@ -16,8 +16,7 @@ */ import { alloc } from '../channel/index.js' -import { newError } from '../../core/index.ts' -import { ProtocolVersion } from './protocol-version.js' +import { newError, ProtocolVersion } from '../../core/index.ts' const BOLT_MAGIC_PREAMBLE = 0x6060b017 const AVAILABLE_BOLT_PROTOCOLS = ['6.0', '5.8', '5.7', '5.6', '5.4', '5.3', '5.2', '5.1', '5.0', '4.4', '4.3', '4.2', '3.0'] // bolt protocols the client will accept, ordered by preference diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js index fa2e10bf1..ce8d3c048 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-direct.js @@ -91,7 +91,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsMultiDb () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } @@ -104,19 +104,19 @@ export default class DirectConnectionProvider extends PooledConnectionProvider { async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js index 3089b524e..23f3a23af 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/connection-provider/connection-provider-routing.js @@ -260,25 +260,25 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider async supportsMultiDb () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_0 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_0) ) } async supportsTransactionConfig () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V3 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V3) ) } async supportsUserImpersonation () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V4_4 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V4_4) ) } async supportsSessionAuth () { return await this._hasProtocolVersion( - version => version.toString() >= BOLT_PROTOCOL_V5_1 + version => version.isGreaterOrEqualTo(BOLT_PROTOCOL_V5_1) ) } diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/index.js b/packages/neo4j-driver-deno/lib/bolt-connection/index.js index 3fdcba96a..fbb9783a5 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/index.js +++ b/packages/neo4j-driver-deno/lib/bolt-connection/index.js @@ -20,6 +20,5 @@ export * as bolt from './bolt/index.js' export * as buf from './buf/index.js' export * as channel from './channel/index.js' export * as packstream from './packstream/index.js' -export * from './bolt/protocol-version.js' export * from './connection-provider/index.js' diff --git a/packages/neo4j-driver-deno/lib/core/connection-provider.ts b/packages/neo4j-driver-deno/lib/core/connection-provider.ts index c77e64501..4f165500d 100644 --- a/packages/neo4j-driver-deno/lib/core/connection-provider.ts +++ b/packages/neo4j-driver-deno/lib/core/connection-provider.ts @@ -18,6 +18,7 @@ import Connection from './connection.ts' import { bookmarks } from './internal/index.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' import { ServerInfo } from './result-summary.ts' import { AuthToken } from './types.ts' @@ -155,7 +156,7 @@ class ConnectionProvider { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { throw Error('Not Implemented') } diff --git a/packages/neo4j-driver-deno/lib/core/connection.ts b/packages/neo4j-driver-deno/lib/core/connection.ts index fa0f20521..40bee0ecf 100644 --- a/packages/neo4j-driver-deno/lib/core/connection.ts +++ b/packages/neo4j-driver-deno/lib/core/connection.ts @@ -19,6 +19,7 @@ import { Bookmarks } from './internal/bookmarks.ts' import { AccessMode, TelemetryApis } from './internal/constants.ts' import { ResultStreamObserver } from './internal/observers.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' import { TxConfig } from './internal/tx-config.ts' import NotificationFilter from './notification-filter.ts' @@ -131,7 +132,7 @@ class Connection { * * @returns {number} */ - getProtocolVersion (): string { + getProtocolVersion (): ProtocolVersion { throw new Error('Not implemented') } diff --git a/packages/neo4j-driver-deno/lib/core/driver.ts b/packages/neo4j-driver-deno/lib/core/driver.ts index 1f8019cfb..7248e9026 100644 --- a/packages/neo4j-driver-deno/lib/core/driver.ts +++ b/packages/neo4j-driver-deno/lib/core/driver.ts @@ -48,6 +48,7 @@ import { newError } from './error.ts' import NotificationFilter from './notification-filter.ts' import HomeDatabaseCache from './internal/homedb-cache.ts' import { cacheKey } from './internal/auth-util.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' const DEFAULT_MAX_CONNECTION_LIFETIME: number = 60 * 60 * 1000 // 1 hour @@ -739,7 +740,7 @@ class Driver { * @returns {Promise} the protocol version negotiated via handshake. * @throws {Error} When protocol negotiation fails */ - getNegotiatedProtocolVersion (): Promise { + getNegotiatedProtocolVersion (): Promise { const connectionProvider = this._getOrCreateConnectionProvider() return connectionProvider.getNegotiatedProtocolVersion() } diff --git a/packages/neo4j-driver-deno/lib/core/index.ts b/packages/neo4j-driver-deno/lib/core/index.ts index b22a6600b..ec1efe74b 100644 --- a/packages/neo4j-driver-deno/lib/core/index.ts +++ b/packages/neo4j-driver-deno/lib/core/index.ts @@ -103,6 +103,7 @@ import resultTransformers, { ResultTransformer } from './result-transformers.ts' import ClientCertificate, { clientCertificateProviders, ClientCertificateProvider, ClientCertificateProviders, RotatingClientCertificateProvider, resolveCertificateProvider } from './client-certificate.ts' import * as internal from './internal/index.ts' import Vector, { VectorType, vector } from './vector.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' /** * Object containing string constants representing predefined {@link Neo4jError} codes. @@ -189,7 +190,8 @@ const forExport = { notificationFilterDisabledClassification, notificationFilterMinimumSeverityLevel, clientCertificateProviders, - resolveCertificateProvider + resolveCertificateProvider, + ProtocolVersion } export { @@ -269,7 +271,8 @@ export { clientCertificateProviders, resolveCertificateProvider, Vector, - vector + vector, + ProtocolVersion } export type { diff --git a/packages/neo4j-driver-deno/lib/core/internal/constants.ts b/packages/neo4j-driver-deno/lib/core/internal/constants.ts index 33de40970..b709889e3 100644 --- a/packages/neo4j-driver-deno/lib/core/internal/constants.ts +++ b/packages/neo4j-driver-deno/lib/core/internal/constants.ts @@ -15,6 +15,8 @@ * limitations under the License. */ +import { ProtocolVersion } from './protocol-version.ts' + const FETCH_ALL = -1 const DEFAULT_POOL_ACQUISITION_TIMEOUT = 60 * 1000 // 60 seconds const DEFAULT_POOL_MAX_SIZE = 100 @@ -23,24 +25,24 @@ const DEFAULT_CONNECTION_TIMEOUT_MILLIS = 30000 // 30 seconds by default const ACCESS_MODE_READ: 'READ' = 'READ' const ACCESS_MODE_WRITE: 'WRITE' = 'WRITE' -const BOLT_PROTOCOL_V1: string = "1.0" -const BOLT_PROTOCOL_V2: string = "2.0" -const BOLT_PROTOCOL_V3: string = "3.0" -const BOLT_PROTOCOL_V4_0: string = "4.0" -const BOLT_PROTOCOL_V4_1: string = "4.1" -const BOLT_PROTOCOL_V4_2: string = "4.2" -const BOLT_PROTOCOL_V4_3: string = "4.3" -const BOLT_PROTOCOL_V4_4: string = "4.4" -const BOLT_PROTOCOL_V5_0: string = "5.0" -const BOLT_PROTOCOL_V5_1: string = "5.1" -const BOLT_PROTOCOL_V5_2: string = "5.2" -const BOLT_PROTOCOL_V5_3: string = "5.3" -const BOLT_PROTOCOL_V5_4: string = "5.4" -const BOLT_PROTOCOL_V5_5: string = "5.5" -const BOLT_PROTOCOL_V5_6: string = "5.6" -const BOLT_PROTOCOL_V5_7: string = "5.7" -const BOLT_PROTOCOL_V5_8: string = "5.8" -const BOLT_PROTOCOL_V6_0: string = "6.0" +const BOLT_PROTOCOL_V1: ProtocolVersion = new ProtocolVersion(1, 0) +const BOLT_PROTOCOL_V2: ProtocolVersion = new ProtocolVersion(2, 0) +const BOLT_PROTOCOL_V3: ProtocolVersion = new ProtocolVersion(3, 0) +const BOLT_PROTOCOL_V4_0: ProtocolVersion = new ProtocolVersion(4, 0) +const BOLT_PROTOCOL_V4_1: ProtocolVersion = new ProtocolVersion(4, 1) +const BOLT_PROTOCOL_V4_2: ProtocolVersion = new ProtocolVersion(4, 2) +const BOLT_PROTOCOL_V4_3: ProtocolVersion = new ProtocolVersion(4, 3) +const BOLT_PROTOCOL_V4_4: ProtocolVersion = new ProtocolVersion(4, 4) +const BOLT_PROTOCOL_V5_0: ProtocolVersion = new ProtocolVersion(5, 0) +const BOLT_PROTOCOL_V5_1: ProtocolVersion = new ProtocolVersion(5, 1) +const BOLT_PROTOCOL_V5_2: ProtocolVersion = new ProtocolVersion(5, 2) +const BOLT_PROTOCOL_V5_3: ProtocolVersion = new ProtocolVersion(5, 3) +const BOLT_PROTOCOL_V5_4: ProtocolVersion = new ProtocolVersion(5, 4) +const BOLT_PROTOCOL_V5_5: ProtocolVersion = new ProtocolVersion(5, 5) +const BOLT_PROTOCOL_V5_6: ProtocolVersion = new ProtocolVersion(5, 6) +const BOLT_PROTOCOL_V5_7: ProtocolVersion = new ProtocolVersion(5, 7) +const BOLT_PROTOCOL_V5_8: ProtocolVersion = new ProtocolVersion(5, 8) +const BOLT_PROTOCOL_V6_0: ProtocolVersion = new ProtocolVersion(6, 0) const TELEMETRY_APIS = { MANAGED_TRANSACTION: 0, diff --git a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js b/packages/neo4j-driver-deno/lib/core/internal/protocol-version.ts similarity index 61% rename from packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js rename to packages/neo4j-driver-deno/lib/core/internal/protocol-version.ts index 4e41d43b9..4a2fd2b89 100644 --- a/packages/neo4j-driver-deno/lib/bolt-connection/bolt/protocol-version.js +++ b/packages/neo4j-driver-deno/lib/core/internal/protocol-version.ts @@ -1,18 +1,20 @@ export class ProtocolVersion { - constructor (major, minor) { + private readonly major: number + private readonly minor: number + constructor (major: number, minor: number) { this.major = major this.minor = minor } - getMajor () { + getMajor (): number { return this.major } - getMinor () { + getMinor (): number { return this.major } - isLessThan (other) { + isLessThan (other: ProtocolVersion): boolean { if (this.major < other.major) { return true } else if (this.major === other.major && this.minor < other.minor) { @@ -21,7 +23,7 @@ export class ProtocolVersion { return false } - isGreaterThan (other) { + isGreaterThan (other: ProtocolVersion): boolean { if (this.major > other.major) { return true } else if (this.major === other.major && this.minor > other.minor) { @@ -30,19 +32,19 @@ export class ProtocolVersion { return false } - isGreaterOrEqualTo (other) { + isGreaterOrEqualTo (other: ProtocolVersion): boolean { return !this.isLessThan(other) } - isLessOrEqualTo (other) { + isLessOrEqualTo (other: ProtocolVersion): boolean { return !this.isGreaterThan(other) } - equalTo (other) { + equalTo (other: ProtocolVersion): boolean { return this.major === other.major && this.minor === other.minor } - toString () { + toString (): string { return this.major.toString() + '.' + this.minor.toString() } } diff --git a/packages/neo4j-driver-deno/lib/core/result-summary.ts b/packages/neo4j-driver-deno/lib/core/result-summary.ts index 7889e8b51..7dabd337c 100644 --- a/packages/neo4j-driver-deno/lib/core/result-summary.ts +++ b/packages/neo4j-driver-deno/lib/core/result-summary.ts @@ -19,6 +19,7 @@ import Integer from './integer.ts' import { NumberOrInteger } from './graph-types.ts' import { util } from './internal/index.ts' import GqlStatusObject, { Notification, buildGqlStatusObjectFromMetadata, buildNotificationsFromMetadata } from './notification.ts' +import { ProtocolVersion } from './internal/protocol-version.ts' /** * A ResultSummary instance contains structured metadata for a {@link Result}. @@ -42,13 +43,13 @@ class ResultSummary { * @param {string} query - The query this summary is for * @param {Object} parameters - Parameters for the query * @param {Object} metadata - Query metadata - * @param {string|undefined} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion|undefined} protocolVersion - Bolt Protocol Version */ constructor ( query: string, parameters: { [key: string]: any }, metadata: any, - protocolVersion?: string + protocolVersion?: ProtocolVersion ) { /** * The query and parameters this summary is for. @@ -434,7 +435,7 @@ class QueryStatistics { */ class ServerInfo { address?: string - protocolVersion?: string + protocolVersion?: ProtocolVersion agent?: string /** @@ -442,9 +443,9 @@ class ServerInfo { * @constructor * @param {Object} serverMeta - Object with serverMeta data * @param {Object} connectionInfo - Bolt connection info - * @param {string} protocolVersion - Bolt Protocol Version + * @param {ProtocolVersion} protocolVersion - Bolt Protocol Version */ - constructor (serverMeta?: any, protocolVersion?: string) { + constructor (serverMeta?: any, protocolVersion?: ProtocolVersion) { if (serverMeta != null) { /** * The server adress @@ -463,7 +464,7 @@ class ServerInfo { /** * The protocol version used by the connection - * @type {string} + * @type {ProtocolVersion} * @public */ this.protocolVersion = protocolVersion From f6902684a0fe2555fe2a191d93467709b4f46611 Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:04:09 +0200 Subject: [PATCH 4/9] decommit deno lock --- packages/neo4j-driver-deno/deno.lock | 96 ---------------------------- 1 file changed, 96 deletions(-) delete mode 100644 packages/neo4j-driver-deno/deno.lock diff --git a/packages/neo4j-driver-deno/deno.lock b/packages/neo4j-driver-deno/deno.lock deleted file mode 100644 index 5b9ec739b..000000000 --- a/packages/neo4j-driver-deno/deno.lock +++ /dev/null @@ -1,96 +0,0 @@ -{ - "version": "5", - "remote": { - "https://deno.land/std@0.119.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", - "https://deno.land/std@0.119.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", - "https://deno.land/std@0.119.0/async/deadline.ts": "1d6ac7aeaee22f75eb86e4e105d6161118aad7b41ae2dd14f4cfd3bf97472b93", - "https://deno.land/std@0.119.0/async/debounce.ts": "b2f693e4baa16b62793fd618de6c003b63228db50ecfe3bd51fc5f6dc0bc264b", - "https://deno.land/std@0.119.0/async/deferred.ts": "ab60d46ba561abb3b13c0c8085d05797a384b9f182935f051dc67136817acdee", - "https://deno.land/std@0.119.0/async/delay.ts": "f2d8ccaa8ebc26594bd8b0989edfd8a96257a714c1dee2fb54d986e5bdd840ac", - "https://deno.land/std@0.119.0/async/mod.ts": "78425176fabea7bd1046ce3819fd69ce40da85c83e0f174d17e8e224a91f7d10", - "https://deno.land/std@0.119.0/async/mux_async_iterator.ts": "62abff3af9ff619e8f2adc96fc70d4ca020fa48a50c23c13f12d02ed2b760dbe", - "https://deno.land/std@0.119.0/async/pool.ts": "353ce4f91865da203a097aa6f33de8966340c91b6f4a055611c8c5d534afd12f", - "https://deno.land/std@0.119.0/async/tee.ts": "3e9f2ef6b36e55188de16a667c702ace4ad0cf84e3720379160e062bf27348ad", - "https://deno.land/std@0.119.0/bytes/bytes_list.ts": "3bff6a09c72b2e0b1e92e29bd3b135053894196cca07a2bba842901073efe5cb", - "https://deno.land/std@0.119.0/bytes/equals.ts": "69f55fdbd45c71f920c1a621e6c0865dc780cd8ae34e0f5e55a9497b70c31c1b", - "https://deno.land/std@0.119.0/bytes/mod.ts": "fedb80b8da2e7ad8dd251148e65f92a04c73d6c5a430b7d197dc39588c8dda6f", - "https://deno.land/std@0.119.0/encoding/base64.ts": "0b58bd6477214838bf711eef43eac21e47ba9e5c81b2ce185fe25d9ecab3ebb3", - "https://deno.land/std@0.119.0/encoding/base64url.ts": "a5c3f71c99a397f9c6da7701e7cae4c031700ae180ba68a0fc9ff9baca71e4ac", - "https://deno.land/std@0.119.0/flags/mod.ts": "5bd80147c97e481efcc4c041096c6c1a1393248e2849ccd571269d62c2634cbe", - "https://deno.land/std@0.119.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621", - "https://deno.land/std@0.119.0/fmt/printf.ts": "419510e0a3f7c8d680fbf6472d5a11e372854f1c2b32fca5fdb513575c485068", - "https://deno.land/std@0.119.0/fs/_util.ts": "f2ce811350236ea8c28450ed822a5f42a0892316515b1cd61321dec13569c56b", - "https://deno.land/std@0.119.0/fs/empty_dir.ts": "5f08b263dd064dc7917c4bbeb13de0f5505a664b9cdfe312fa86e7518cfaeb84", - "https://deno.land/std@0.119.0/fs/ensure_dir.ts": "b7c103dc41a3d1dbbb522bf183c519c37065fdc234831a4a0f7d671b1ed5fea7", - "https://deno.land/std@0.119.0/fs/ensure_file.ts": "c06031af24368e80c330897e4b8e9109efc8602ffabc8f3e2306be07529e1d13", - "https://deno.land/std@0.119.0/fs/ensure_link.ts": "26e54363508b822afd87a3f6e873bbbcd6b5993dd638f8170758c16262a75065", - "https://deno.land/std@0.119.0/fs/ensure_symlink.ts": "c07b6d19ef58b6f5c671ffa942e7f9be50315f4f78e2f9f511626fd2e13beccc", - "https://deno.land/std@0.119.0/fs/eol.ts": "afaebaaac36f48c423b920c836551997715672b80a0fee9aa7667c181a94f2df", - "https://deno.land/std@0.119.0/fs/exists.ts": "c3c3335a212bd945bb75df379096ab57fb6c86598fa273dfb24da3b3939a951e", - "https://deno.land/std@0.119.0/fs/expand_glob.ts": "f6f64ef54addcc84c9012d6dfcf66d39ecc2565e40c4d2b7644d585fe4d12a04", - "https://deno.land/std@0.119.0/fs/mod.ts": "2bf5468fc950479b2a791cceae3d6fe3f32e573243b004d1f8e0a3df92211680", - "https://deno.land/std@0.119.0/fs/move.ts": "4623058e39bbbeb3ad30aeff9c974c55d2d574ad7c480295c12b04c244686a99", - "https://deno.land/std@0.119.0/fs/walk.ts": "31464d75099aa3fc7764212576a8772dfabb2692783e6eabb910f874a26eac54", - "https://deno.land/std@0.119.0/io/buffer.ts": "8f10342821b81990acf859cdccb4e4031c7c9187a0ffc3ed6b356ee29ecc6681", - "https://deno.land/std@0.119.0/log/handlers.ts": "bb0685d4124c7401efbacd9e019c0c1abd2dfb381b939601338b158d2b327cb7", - "https://deno.land/std@0.119.0/log/levels.ts": "088a883039ece5fa0da5f74bc7688654045ea7cb01bf200b438191a28d728eae", - "https://deno.land/std@0.119.0/log/logger.ts": "6b2dd8cbe6f407100b9becfe61595d7681f8ce3692412fad843de84d617a038e", - "https://deno.land/std@0.119.0/log/mod.ts": "9393719dafdb360620ea9222c0ce0db35a0ebb0d49ea6d5c30406f332d2be334", - "https://deno.land/std@0.119.0/node/_buffer.js": "a43c35f89ef15c2107cba863d2cd0bd573e829a2a3b80167033da9b96066ce51", - "https://deno.land/std@0.119.0/node/_core.ts": "8b105f152c9f8990f7558b0a0a514d4f3ab90a85c09ca60e489ca92ed5271f75", - "https://deno.land/std@0.119.0/node/_errors.ts": "bf047995427fc15a27a182ee13021e94315fa758c1cc7c3576374876ab9f952a", - "https://deno.land/std@0.119.0/node/_fixed_queue.ts": "ac68975e5663ea9cf2e465e91a7600fa3d5dc1a2f556cf80fd1ee25b37dbcedf", - "https://deno.land/std@0.119.0/node/_next_tick.ts": "9b0bde39bfad9774be73b0fe9e77df757e147e2fc04784d51fe777d36d142260", - "https://deno.land/std@0.119.0/node/_process/process.ts": "828b67fa5858e30901e11a84968b2732057cd0bea34afcf49f617498040e7dbe", - "https://deno.land/std@0.119.0/node/_util/_debuglog.ts": "b46f7b640bad2afb8adf2b3560e6969071f9de0721dcec9e3530465ab5ec6c40", - "https://deno.land/std@0.119.0/node/_util/_util_callbackify.ts": "a89ade5b5d989f9eb9261cd8179a5f8a1579c6a898549fab304200a85ee520b0", - "https://deno.land/std@0.119.0/node/_util/_util_promisify.ts": "6d8d88fd81763f1074c84f4494484f9dd86182dfe46b63fe5aadd6448b767896", - "https://deno.land/std@0.119.0/node/_utils.ts": "42e5b28e1740ba0be9b4ace2c9adb95317d9cadb099418c51ed34cd6a301cae3", - "https://deno.land/std@0.119.0/node/buffer.ts": "cf37645cd1fc08f1afa02532dc6682cefd8cabbf44812aa9a4916e79bdd1cd11", - "https://deno.land/std@0.119.0/node/internal/buffer.js": "21f4bfea78679e18bfebeb1d9ece1a94d337d282a2a68d43ab5ff655c2d33e56", - "https://deno.land/std@0.119.0/node/internal/idna.ts": "6d7cce3e569fd1d9e558d63ab522700e57b998597196a4746436a62f3f8b1c7f", - "https://deno.land/std@0.119.0/node/internal/querystring.ts": "1fdee1158205dd220c3711cce2e994bd0848abc7518d245856d142b08a266a07", - "https://deno.land/std@0.119.0/node/internal/util.js": "11ef4e4724a4d40f1f5ed4a54e42cee3c3af0f75dcea33ac063747a6e3b9a582", - "https://deno.land/std@0.119.0/node/internal/util/comparisons.ts": "9e6979948221ee00a105355d8a9afe47fa059a331351cbb2e11fa8e2f50749d4", - "https://deno.land/std@0.119.0/node/internal/util/inspect.js": "2b50eb7e8b1d5a73a933f56a361262cf2f23429a8e1ca6ee47db04229bf12208", - "https://deno.land/std@0.119.0/node/internal/util/types.ts": "31745332605771b59701baebf1655f389202b10bb787afb78e66c92486bc0332", - "https://deno.land/std@0.119.0/node/internal/validators.js": "16b58d8ac8505897422d4ad273652a8cb36c470f470df9677700cc3b78c24c19", - "https://deno.land/std@0.119.0/node/internal_binding/_libuv_winerror.ts": "689b8fa52dafb7a1b55f3ffceca5905f77fb2720a8b9f77c921cd598e3ef3757", - "https://deno.land/std@0.119.0/node/internal_binding/_node.ts": "c257e872993334cfab1eaab8212d422b24f7388281f73c7bbdd9bbf1bb2a7841", - "https://deno.land/std@0.119.0/node/internal_binding/_utils.ts": "ee6830db046e829b5c4d6df1de21f1a3d6464469a2fe303b32bc44bb171c2eeb", - "https://deno.land/std@0.119.0/node/internal_binding/_winerror.ts": "27e4a7d78ae31e7b07faafd25fe46fa367271aec0a49f3be067f7ec160396a38", - "https://deno.land/std@0.119.0/node/internal_binding/buffer.ts": "f92daf02083bdaf0006a06fa1f26a26436f4b7b0c5d000aff7d01da3d1aa42a5", - "https://deno.land/std@0.119.0/node/internal_binding/constants.ts": "91c9274c8891f93262032129348b25f170162cb126dc424ec7ce8a2172812657", - "https://deno.land/std@0.119.0/node/internal_binding/string_decoder.ts": "6aca87fb018705e34c39d6f67d610b14c8ca04a47ca58f0d1fc8d5f9281e6b7b", - "https://deno.land/std@0.119.0/node/internal_binding/types.ts": "80621e22989a1431068bc3b7f59cab3afb42cfb4d4cd273e61fa2d11ab3abab6", - "https://deno.land/std@0.119.0/node/internal_binding/util.ts": "446b4d704f4d588df98db9c6f9c7465c08a23f20f781ba55bcc246fb260012af", - "https://deno.land/std@0.119.0/node/internal_binding/uv.ts": "3b722cd20508d54e4d790c825b23510a5fa4313ad42bfb8904704a738df32325", - "https://deno.land/std@0.119.0/node/path.ts": "86b262d6957fba13d4f3d58a92ced49de4f40169d06542326b5547ff97257f0d", - "https://deno.land/std@0.119.0/node/querystring.ts": "4f436efdd97659fe567c00f1cff233d4f5b67002ef388951db052dfe7c3de114", - "https://deno.land/std@0.119.0/node/string_decoder.ts": "e97d4988a3490fd572fc23e64b3a33dabc4ac76c1fb82665f34dc8956d57a658", - "https://deno.land/std@0.119.0/node/url.ts": "c58bd8adfde3833026c1c3c8f55cd14e37f9f1e4dd6b7b99c5feb4ace710e9b4", - "https://deno.land/std@0.119.0/node/util.ts": "3be88d5d1c908f279bf7fecd77ff3933e048aa50205029fdd69280f67aea5901", - "https://deno.land/std@0.119.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", - "https://deno.land/std@0.119.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", - "https://deno.land/std@0.119.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", - "https://deno.land/std@0.119.0/path/common.ts": "f41a38a0719a1e85aa11c6ba3bea5e37c15dd009d705bd8873f94c833568cbc4", - "https://deno.land/std@0.119.0/path/glob.ts": "ea87985765b977cc284b92771003b2070c440e0807c90e1eb0ff3e095911a820", - "https://deno.land/std@0.119.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", - "https://deno.land/std@0.119.0/path/posix.ts": "34349174b9cd121625a2810837a82dd8b986bbaaad5ade690d1de75bbb4555b2", - "https://deno.land/std@0.119.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", - "https://deno.land/std@0.119.0/path/win32.ts": "11549e8c6df8307a8efcfa47ad7b2a75da743eac7d4c89c9723a944661c8bd2e", - "https://deno.land/std@0.119.0/streams/conversion.ts": "7ff9af42540063fa72003ab31a377ba9dde8532d43b16329b933c37a6d7aac5f", - "https://deno.land/std@0.119.0/testing/_diff.ts": "e6a10d2aca8d6c27a9c5b8a2dbbf64353874730af539707b5b39d4128140642d", - "https://deno.land/std@0.119.0/testing/asserts.ts": "e8bd3ff280731e2d2b48c67d6ed97ce2c0b717601ccb38816aff89edce71680d", - "https://deno.land/std@0.157.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", - "https://deno.land/std@0.157.0/bytes/bytes_list.ts": "aba5e2369e77d426b10af1de0dcc4531acecec27f9b9056f4f7bfbf8ac147ab4", - "https://deno.land/std@0.157.0/bytes/equals.ts": "3c3558c3ae85526f84510aa2b48ab2ad7bdd899e2e0f5b7a8ffc85acb3a6043a", - "https://deno.land/std@0.157.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf", - "https://deno.land/std@0.157.0/io/buffer.ts": "fae02290f52301c4e0188670e730cd902f9307fb732d79c4aa14ebdc82497289", - "https://deno.land/std@0.157.0/streams/conversion.ts": "fc4eb76a14148c43f0b85e903a5a1526391aa40ed9434dc21e34f88304eb823e", - "https://deno.land/std@0.182.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e", - "https://deno.land/std@0.182.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea", - "https://deno.land/std@0.182.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", - "https://deno.land/std@0.182.0/testing/asserts.ts": "e16d98b4d73ffc4ed498d717307a12500ae4f2cbe668f1a215632d19fcffc22f" - } -} From be85e5979503962631c71a67c43f43283d6ffd02 Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:33:26 +0200 Subject: [PATCH 5/9] stringify ProtocolVersion --- packages/testkit-backend/src/responses.js | 2 +- packages/testkit-backend/src/summary-binder.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/testkit-backend/src/responses.js b/packages/testkit-backend/src/responses.js index b78324672..ad08e3b73 100644 --- a/packages/testkit-backend/src/responses.js +++ b/packages/testkit-backend/src/responses.js @@ -69,7 +69,7 @@ export function Bookmarks ({ bookmarks }) { export function ServerInfo ({ serverInfo }) { return response('ServerInfo', { ...serverInfo, - protocolVersion: serverInfo.protocolVersion.toFixed(1) + protocolVersion: serverInfo.protocolVersion.toString() }) } diff --git a/packages/testkit-backend/src/summary-binder.js b/packages/testkit-backend/src/summary-binder.js index 9f13f75a5..ccbc85a89 100644 --- a/packages/testkit-backend/src/summary-binder.js +++ b/packages/testkit-backend/src/summary-binder.js @@ -69,7 +69,7 @@ export function nativeToTestkitSummary (summary, binder) { }, serverInfo: { agent: summary.server.agent, - protocolVersion: summary.server.protocolVersion.toFixed(1) + protocolVersion: summary.server.protocolVersion.toString() }, counters: mapCounters(summary.counters), plan: mapPlan(summary.plan), From 9e43e378ac96e1d3e9e364ad16bf613ea3ae43dd Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:54:43 +0200 Subject: [PATCH 6/9] test fixes --- .../connection-provider-routing.test.js | 22 ++++++++----------- .../neo4j-driver/test/vector-type.test.js | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js b/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js index 5ec6eac6b..8894b379d 100644 --- a/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js +++ b/packages/bolt-connection/test/connection-provider/connection-provider-routing.test.js @@ -24,7 +24,8 @@ import { internal, ServerInfo, staticAuthTokenManager, - authTokenManagers + authTokenManagers, + ProtocolVersion } from 'neo4j-driver-core' import { RoutingTable } from '../../src/rediscovery/' import SimpleHostNameResolver from '../../src/channel/browser/browser-host-name-resolver' @@ -45,15 +46,10 @@ const READ = 'READ' const WRITE = 'WRITE' describe.each([ - '3.0', - '4.0', - '4.1', - '4.2', - '4.3', - '4.4', - '5.0', - '5.1', - '6.0' + new ProtocolVersion(4, 4), + new ProtocolVersion(5, 0), + new ProtocolVersion(5, 8), + new ProtocolVersion(6, 0) ])('#unit RoutingConnectionProvider (PROTOCOL_VERSION=%d)', (PROTOCOL_VERSION) => { const server0 = ServerAddress.fromUrl('server0') const server1 = ServerAddress.fromUrl('server1') @@ -3044,7 +3040,7 @@ describe.each([ [server3, server4], [server5, server6] ) - const protocolVersion = '4.4' + const protocolVersion = new ProtocolVersion(4, 4) const server = { address: 'localhost:123', version: 'neo4j/1234' } const seenConnectionsPerAddress = new Map() @@ -3121,7 +3117,7 @@ describe.each([ const pool = newPool({ create: (address, release) => { if (i++ % 2 === 0) { - return new FakeConnection(address, release, 'version', '4.4', {}) + return new FakeConnection(address, release, 'version', new ProtocolVersion(4, 4), {}) } throw error } @@ -3135,7 +3131,7 @@ describe.each([ ) const serverInfo = await connectionProvider.verifyConnectivityAndGetServerInfo({ database, accessMode }) - expect(serverInfo).toEqual(new ServerInfo({}, '4.4')) + expect(serverInfo).toEqual(new ServerInfo({}, new ProtocolVersion(4, 4))) }) }) diff --git a/packages/neo4j-driver/test/vector-type.test.js b/packages/neo4j-driver/test/vector-type.test.js index b318aaa51..e27287a26 100644 --- a/packages/neo4j-driver/test/vector-type.test.js +++ b/packages/neo4j-driver/test/vector-type.test.js @@ -47,7 +47,7 @@ describe('#integration vector type', () => { }) it('write and read vectors', async () => { - if (protocolVersion.isLessThan({ major: 6, minor: 0 }) && edition === 'enterprise') { + if (protocolVersion.isGreaterOrEqualTo({ major: 6, minor: 0 }) && edition === 'enterprise') { const driver = driverGlobal const bufferWriter = Uint8Array.from([1, 1]) From d0d144bb634211134d008784944b82e6aa660cb3 Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Fri, 22 Aug 2025 09:36:28 +0200 Subject: [PATCH 7/9] Update index.test.ts --- packages/neo4j-driver-lite/test/unit/index.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/neo4j-driver-lite/test/unit/index.test.ts b/packages/neo4j-driver-lite/test/unit/index.test.ts index 98971e38a..e80264abe 100644 --- a/packages/neo4j-driver-lite/test/unit/index.test.ts +++ b/packages/neo4j-driver-lite/test/unit/index.test.ts @@ -58,7 +58,7 @@ import neo4j, { RecordShape } from '../../' -import { internal } from 'neo4j-driver-core' +import { internal, ProtocolVersion } from 'neo4j-driver-core' const { logger: { Logger } @@ -261,7 +261,7 @@ describe('index', () => { supportsTransactionConfig: async () => true, supportsUserImpersonation: async () => true, verifyConnectivityAndGetServerInfo: async () => new ServerInfo({}), - getNegotiatedProtocolVersion: async () => 5.0, + getNegotiatedProtocolVersion: async () => new ProtocolVersion(5, 0), verifyAuthentication: async () => true, supportsSessionAuth: async () => true, SSREnabled: () => false From 1d7971f3ad6b80c0bbc74b02c98b1813f1c9d983 Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Fri, 22 Aug 2025 10:26:23 +0200 Subject: [PATCH 8/9] syntax error in test --- packages/neo4j-driver/test/examples.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/neo4j-driver/test/examples.test.js b/packages/neo4j-driver/test/examples.test.js index 864e59534..688889f98 100644 --- a/packages/neo4j-driver/test/examples.test.js +++ b/packages/neo4j-driver/test/examples.test.js @@ -898,7 +898,7 @@ describe('#integration examples', () => { }, 60000) it('use another database example', async () => { - if (protocolVersion.isLessThan({ major: 4, minor: 0 } || edition !== 'enterprise')) { + if (protocolVersion.isLessThan({ major: 4, minor: 0 }) || edition !== 'enterprise') { return } From 0b75ce66280e2398ff506f7486db4947c69c1e3e Mon Sep 17 00:00:00 2001 From: ci <61233757+MaxAake@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:51:40 +0200 Subject: [PATCH 9/9] fix home db tests --- packages/neo4j-driver/test/driver.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/neo4j-driver/test/driver.test.js b/packages/neo4j-driver/test/driver.test.js index 8a35f5611..66001d9b1 100644 --- a/packages/neo4j-driver/test/driver.test.js +++ b/packages/neo4j-driver/test/driver.test.js @@ -591,7 +591,7 @@ describe('#integration driver', () => { `neo4j://${sharedNeo4j.hostnameWithBoltPort}`, sharedNeo4j.authToken ) - if (protocolVersion.isGreaterOrEqualTo({ major: 4, minor: 0 })) { + if (protocolVersion.isGreaterOrEqualTo({ major: 5, minor: 8 })) { try { const session1 = driver.session(auth) await session1.run('CREATE () RETURN 42')