Skip to content

Commit f8a80e8

Browse files
committed
moving connection classes to the bolt-connection package
1 parent 87c73d7 commit f8a80e8

File tree

99 files changed

+422
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+422
-189
lines changed

bolt-connection/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"neo4j",
1818
"driver"
1919
],
20+
"browser": {
21+
"./lib/channel/node/index.js": "./lib/channel/browser/index.js"
22+
},
2023
"author": "Neo4j",
2124
"license": "Apache-2.0",
2225
"bugs": {

src/internal/bolt/bolt-protocol-v1.js renamed to bolt-connection/src/bolt/bolt-protocol-v1.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ import {
2020
assertDatabaseIsEmpty,
2121
assertTxConfigIsEmpty
2222
} from './bolt-protocol-util'
23-
import Bookmark from '../bookmark'
2423
import { Chunker } from '../chunking'
25-
import { ACCESS_MODE_WRITE, BOLT_PROTOCOL_V1 } from '../constants'
26-
import Logger from '../logger'
27-
import * as v1 from '../packstream-v1'
28-
import { Packer } from '../packstream-v1'
24+
import { v1 } from '../packstream'
2925
import RequestMessage from './request-message'
3026
import {
3127
LoginObserver,
3228
ResetObserver,
3329
ResultStreamObserver,
3430
StreamObserver
3531
} from './stream-observers'
36-
import TxConfig from '../tx-config'
32+
import { internal } from 'neo4j-driver-core'
33+
34+
const {
35+
bookmark: { Bookmark },
36+
constants: { ACCESS_MODE_WRITE, BOLT_PROTOCOL_V1 },
37+
logger: { Logger },
38+
txConfig: { TxConfig }
39+
} = internal
3740

3841
export default class BoltProtocol {
3942
/**

src/internal/bolt/bolt-protocol-v2.js renamed to bolt-connection/src/bolt/bolt-protocol-v2.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
* limitations under the License.
1818
*/
1919
import BoltProtocolV1 from './bolt-protocol-v1'
20-
import * as v2 from '../packstream-v2'
21-
import { BOLT_PROTOCOL_V2 } from '../constants'
20+
import v2 from '../packstream'
21+
import { internal } from 'neo4j-driver-core'
22+
23+
const {
24+
constants: { BOLT_PROTOCOL_V2 }
25+
} = internal
2226

2327
export default class BoltProtocol extends BoltProtocolV1 {
2428
_createPacker (chunker) {

src/internal/bolt/bolt-protocol-v3.js renamed to bolt-connection/src/bolt/bolt-protocol-v3.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ import {
2525
ResultStreamObserver,
2626
ProcedureRouteObserver
2727
} from './stream-observers'
28-
import { BOLT_PROTOCOL_V3 } from '../constants'
29-
import Bookmark from '../bookmark'
30-
import TxConfig from '../tx-config'
28+
import { internal } from 'neo4j-driver-core'
29+
30+
const {
31+
bookmark: { Bookmark },
32+
constants: { BOLT_PROTOCOL_V3 },
33+
txConfig: { TxConfig }
34+
} = internal
35+
3136
const CONTEXT = 'context'
3237
const CALL_GET_ROUTING_TABLE = `CALL dbms.cluster.routing.getRoutingTable($${CONTEXT})`
3338

src/internal/bolt/bolt-protocol-v4x0.js renamed to bolt-connection/src/bolt/bolt-protocol-v4x0.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ import {
2222
ResultStreamObserver,
2323
ProcedureRouteObserver
2424
} from './stream-observers'
25-
import { BOLT_PROTOCOL_V4_0 } from '../constants'
26-
import Bookmark from '../bookmark'
27-
import TxConfig from '../tx-config'
25+
26+
import { internal } from 'neo4j-driver-core'
27+
28+
const {
29+
bookmark: { Bookmark },
30+
constants: { BOLT_PROTOCOL_V4_0 },
31+
txConfig: { TxConfig }
32+
} = internal
2833

2934
const CONTEXT = 'context'
3035
const DATABASE = 'database'

src/internal/bolt/bolt-protocol-v4x1.js renamed to bolt-connection/src/bolt/bolt-protocol-v4x1.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
*/
1919
import BoltProtocolV4 from './bolt-protocol-v4x0'
2020
import RequestMessage, { ALL } from './request-message'
21-
import { BOLT_PROTOCOL_V4_1 } from '../constants'
2221
import { LoginObserver } from './stream-observers'
22+
import { internal } from 'neo4j-driver-core'
23+
24+
const {
25+
constants: { BOLT_PROTOCOL_V4_1 }
26+
} = internal
2327

2428
export default class BoltProtocol extends BoltProtocolV4 {
2529
/**

src/internal/bolt/bolt-protocol-v4x2.js renamed to bolt-connection/src/bolt/bolt-protocol-v4x2.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
* limitations under the License.
1818
*/
1919
import BoltProtocolV41 from './bolt-protocol-v4x1'
20-
import { BOLT_PROTOCOL_V4_2 } from '../constants'
20+
21+
import { internal } from 'neo4j-driver-core'
22+
23+
const {
24+
constants: { BOLT_PROTOCOL_V4_2 }
25+
} = internal
2126

2227
export default class BoltProtocol extends BoltProtocolV41 {
2328
get version () {

src/internal/bolt/bolt-protocol-v4x3.js renamed to bolt-connection/src/bolt/bolt-protocol-v4x3.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717
* limitations under the License.
1818
*/
1919
import BoltProtocolV42 from './bolt-protocol-v4x2'
20-
import { BOLT_PROTOCOL_V4_3 } from '../constants'
2120
import RequestMessage from './request-message'
2221
import { RouteObserver } from './stream-observers'
2322

23+
import { internal } from 'neo4j-driver-core'
24+
25+
const {
26+
constants: { BOLT_PROTOCOL_V4_3 }
27+
} = internal
28+
2429
export default class BoltProtocol extends BoltProtocolV42 {
2530
get version () {
2631
return BOLT_PROTOCOL_V4_3

src/internal/bolt/create.js renamed to bolt-connection/src/bolt/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import BoltProtocolV4x0 from './bolt-protocol-v4x0'
2525
import BoltProtocolV4x1 from './bolt-protocol-v4x1'
2626
import BoltProtocolV4x2 from './bolt-protocol-v4x2'
2727
import BoltProtocolV4x3 from './bolt-protocol-v4x3'
28-
import { Chunker, Dechunker } from '../chunking'
28+
import { Chunker, Dechunker } from '../channel'
2929
import ResponseHandler from './response-handler'
3030

3131
/**

src/internal/bolt/handshake.js renamed to bolt-connection/src/bolt/handshake.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20-
import { alloc } from '../node'
20+
import { alloc } from '../channel'
2121
import { newError } from 'neo4j-driver-core'
2222

2323
const BOLT_MAGIC_PREAMBLE = 0x6060b017
File renamed without changes.

src/internal/bolt/request-message.js renamed to bolt-connection/src/bolt/request-message.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
* limitations under the License.
1818
*/
1919

20-
import { ACCESS_MODE_READ, FETCH_ALL } from '../constants'
21-
import { int } from 'neo4j-driver-core'
22-
import { assertString } from '../util'
20+
import { int, internal } from 'neo4j-driver-core'
21+
22+
const {
23+
constants: { ACCESS_MODE_READ, FETCH_ALL },
24+
util: { assertString }
25+
} = internal
2326

2427
/* eslint-disable no-unused-vars */
2528
// Signature bytes for each request message type
File renamed without changes.

src/internal/buf/combined-buf.js renamed to bolt-connection/src/buf/combined-buf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import BaseBuffer from './base-buf'
21-
import { alloc } from '../node'
21+
import { alloc } from '../channel'
2222

2323
/**
2424
* Buffer that combines multiple buffers, exposing them as one single buffer.

src/internal/connection-provider.js renamed to bolt-connection/src/buf/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Bookmark from './bookmark'
2-
31
/**
42
* Copyright (c) "Neo4j"
53
* Neo4j Sweden AB [http://neo4j.com]
@@ -19,6 +17,8 @@ import Bookmark from './bookmark'
1917
* limitations under the License.
2018
*/
2119

22-
import { ConnectionProvider } from 'neo4j-driver-core'
20+
import BaseBuffer from './base-buf'
21+
import CombinedBuffer from './combined-buf'
2322

24-
export default ConnectionProvider
23+
export default BaseBuffer
24+
export { BaseBuffer, CombinedBuffer }

src/internal/browser/browser-buf.js renamed to bolt-connection/src/channel/browser/browser-buf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20-
import BaseBuffer from '../buf/base-buf'
20+
import BaseBuffer from '../../buf'
2121

2222
export default class HeapBuffer extends BaseBuffer {
2323
constructor (arg) {

src/internal/browser/browser-channel.js renamed to bolt-connection/src/channel/browser/browser-channel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*/
1919

2020
import HeapBuffer from './browser-buf'
21-
import { newError } from 'neo4j-driver-core'
22-
import { ENCRYPTION_OFF, ENCRYPTION_ON } from '../util'
21+
import { newError, internal } from 'neo4j-driver-core'
22+
23+
const {
24+
util: { ENCRYPTION_OFF, ENCRYPTION_ON }
25+
} = internal
2326

2427
// Just to be sure that these values are with us even after WebSocket is injected
2528
// for tests.

src/internal/browser/browser-host-name-resolver.js renamed to bolt-connection/src/channel/browser/browser-host-name-resolver.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
* limitations under the License.
1818
*/
1919

20-
import BaseHostNameResolver from '../resolver/base-host-name-resolver'
20+
import { internal } from 'neo4j-driver-core'
21+
22+
const {
23+
resolver: { BaseHostNameResolver }
24+
} = internal
2125

2226
export default class BrowserHostNameResolver extends BaseHostNameResolver {
2327
resolve (address) {

src/internal/browser/browser-utf8.js renamed to bolt-connection/src/channel/browser/browser-utf8.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20-
import HeapBuffer from '../browser/browser-buf'
20+
import HeapBuffer from './browser-buf'
2121
import { TextEncoder, TextDecoder } from 'text-encoding-utf-8'
2222

2323
const encoder = new TextEncoder('utf-8')

src/internal/channel-config.js renamed to bolt-connection/src/channel/channel-config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
* limitations under the License.
1818
*/
1919

20-
import { newError, error } from 'neo4j-driver-core'
21-
import { ENCRYPTION_OFF, ENCRYPTION_ON } from './util'
20+
import { newError, error, internal } from 'neo4j-driver-core'
21+
22+
const {
23+
util: { ENCRYPTION_OFF, ENCRYPTION_ON }
24+
} = internal
2225

2326
const { SERVICE_UNAVAILABLE } = error
2427

src/internal/chunking.js renamed to bolt-connection/src/channel/chunking.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* limitations under the License.
1818
*/
1919

20-
import BaseBuffer from './buf/base-buf'
20+
import BaseBuffer from '../buf/base-buf'
2121
import { alloc } from './node'
22-
import CombinedBuffer from './buf/combined-buf'
22+
import CombinedBuffer from '../buf/combined-buf'
2323

2424
const _CHUNK_HEADER_SIZE = 2
2525
const _MESSAGE_BOUNDARY = 0x00

bolt-connection/src/channel/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import ChannelConfig from './channel-config'
2+
3+
/**
4+
* Copyright (c) "Neo4j"
5+
* Neo4j Sweden AB [http://neo4j.com]
6+
*
7+
* This file is part of Neo4j.
8+
*
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
*/
21+
export * from './node'
22+
export * from './chunking'
23+
export { default as ChannelConfig } from './channel-config'

src/internal/node/node-buf.js renamed to bolt-connection/src/channel/node/node-buf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import node from 'buffer'
21-
import BaseBuffer from '../buf/base-buf'
21+
import BaseBuffer from '../../buf'
2222

2323
export default class NodeBuffer extends BaseBuffer {
2424
constructor (arg) {

src/internal/node/node-channel.js renamed to bolt-connection/src/channel/node/node-channel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ import net from 'net'
2020
import tls from 'tls'
2121
import fs from 'fs'
2222
import NodeBuffer from './node-buf'
23-
import { ENCRYPTION_OFF, ENCRYPTION_ON, isEmptyObjectOrNull } from '../util'
24-
import { newError } from 'neo4j-driver-core'
23+
import { newError, internal } from 'neo4j-driver-core'
24+
25+
const {
26+
util: { ENCRYPTION_OFF, ENCRYPTION_ON, isEmptyObjectOrNull }
27+
} = internal
2528

2629
let _CONNECTION_IDGEN = 0
2730

src/internal/node/node-host-name-resolver.js renamed to bolt-connection/src/channel/node/node-host-name-resolver.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
* limitations under the License.
1818
*/
1919

20-
import BaseHostNameResolver from '../resolver/base-host-name-resolver'
2120
import nodeDns from 'dns'
21+
import { internal } from 'neo4j-driver-core'
22+
23+
const {
24+
resolver: { BaseHostNameResolver }
25+
} = internal
2226

2327
export default class NodeHostNameResolver extends BaseHostNameResolver {
2428
resolve (address) {

src/internal/connection-provider-direct.js renamed to bolt-connection/src/connection-provider/connection-provider-direct.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
*/
1919

2020
import PooledConnectionProvider from './connection-provider-pooled'
21-
import DelegateConnection from './connection-delegate'
22-
import { createChannelConnection } from './connection-channel'
23-
import { BOLT_PROTOCOL_V4_0, BOLT_PROTOCOL_V3 } from './constants'
21+
import { createChannelConnection, DelegateConnection } from '../connection'
22+
import { internal } from 'neo4j-driver-core'
23+
24+
const {
25+
constants: { BOLT_PROTOCOL_V4_0, BOLT_PROTOCOL_V3 }
26+
} = internal
2427

2528
export default class DirectConnectionProvider extends PooledConnectionProvider {
2629
constructor ({ id, config, log, address, userAgent, authToken }) {

src/internal/connection-provider-pooled.js renamed to bolt-connection/src/connection-provider/connection-provider-pooled.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
* limitations under the License.
1818
*/
1919

20-
import { createChannelConnection } from './connection-channel'
21-
import Pool from './pool'
22-
import PoolConfig from './pool-config'
23-
import ConnectionErrorHandler from './connection-error-handler'
24-
import { error } from 'neo4j-driver-core'
25-
import ConnectionProvider from './connection-provider'
20+
import { createChannelConnection, ConnectionErrorHandler } from '../connection'
21+
import Pool, { PoolConfig } from '../pool'
22+
import { error, ConnectionProvider } from 'neo4j-driver-core'
2623

2724
const { SERVICE_UNAVAILABLE } = error
2825
export default class PooledConnectionProvider extends ConnectionProvider {

0 commit comments

Comments
 (0)