Skip to content

Commit 0458328

Browse files
authored
Fix ProtocolVersion API docs (#1346)
1 parent a8e1e30 commit 0458328

File tree

23 files changed

+250
-128
lines changed

23 files changed

+250
-128
lines changed

packages/core/src/connection-provider.ts

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

1919
import Connection from './connection'
2020
import { bookmarks } from './internal'
21-
import { ProtocolVersion } from './internal/protocol-version'
21+
import { ProtocolVersion } from './protocol-version'
2222
import { ServerInfo } from './result-summary'
2323
import { AuthToken } from './types'
2424

packages/core/src/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import { Bookmarks } from './internal/bookmarks'
2020
import { AccessMode, TelemetryApis } from './internal/constants'
2121
import { ResultStreamObserver } from './internal/observers'
22-
import { ProtocolVersion } from './internal/protocol-version'
22+
import { ProtocolVersion } from './protocol-version'
2323
import { TxConfig } from './internal/tx-config'
2424
import NotificationFilter from './notification-filter'
2525

packages/core/src/driver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import { newError } from './error'
4848
import NotificationFilter from './notification-filter'
4949
import HomeDatabaseCache from './internal/homedb-cache'
5050
import { cacheKey } from './internal/auth-util'
51-
import { ProtocolVersion } from './internal/protocol-version'
51+
import { ProtocolVersion } from './protocol-version'
5252

5353
const DEFAULT_MAX_CONNECTION_LIFETIME: number = 60 * 60 * 1000 // 1 hour
5454

packages/core/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ import * as json from './json'
102102
import resultTransformers, { ResultTransformer } from './result-transformers'
103103
import ClientCertificate, { clientCertificateProviders, ClientCertificateProvider, ClientCertificateProviders, RotatingClientCertificateProvider, resolveCertificateProvider } from './client-certificate'
104104
import * as internal from './internal' // todo: removed afterwards
105-
import { ProtocolVersion } from './internal/protocol-version'
105+
import { ProtocolVersion } from './protocol-version'
106106
import Vector, { VectorType, vector, isVector } from './vector'
107107
import { StandardCase } from './mapping.nameconventions'
108108
import { Rule, Rules, RecordObjectMapping } from './mapping.highlevel'
@@ -292,7 +292,7 @@ export {
292292
RecordObjectMapping,
293293
StandardCase,
294294
UnsupportedType,
295-
isUnsupportedType,
295+
isUnsupportedType
296296
}
297297

298298
export type {

packages/core/src/internal/constants.ts

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

18-
import { ProtocolVersion } from './protocol-version'
18+
import { ProtocolVersion } from '../protocol-version'
1919

2020
const FETCH_ALL = -1
2121
const DEFAULT_POOL_ACQUISITION_TIMEOUT = 60 * 1000 // 60 seconds

packages/core/src/internal/protocol-version.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/**
19+
*
20+
* @access public
21+
* @class A class representing a protocol version the driver is using to communicate with the server.
22+
* @param {number} major the major version of the protocol.
23+
* @param {number} minor the minor version of the protocol.
24+
*/
25+
export class ProtocolVersion {
26+
private readonly major: number
27+
private readonly minor: number
28+
constructor (major: number, minor: number) {
29+
this.major = major
30+
this.minor = minor
31+
}
32+
33+
/**
34+
*
35+
* @returns {number} The major version of the protocol
36+
*/
37+
getMajor (): number {
38+
return this.major
39+
}
40+
41+
/**
42+
* @returns {number} The minor version of the protocol
43+
*/
44+
getMinor (): number {
45+
return this.major
46+
}
47+
48+
/**
49+
*
50+
* @param {ProtocolVersion | {major: number, minor: number}} other the protocol version to compare to
51+
* @returns {boolean} If this version semantically smaller than the other version.
52+
*/
53+
isLessThan (other: ProtocolVersion): boolean {
54+
if (this.major < other.major) {
55+
return true
56+
} else if (this.major === other.major && this.minor < other.minor) {
57+
return true
58+
}
59+
return false
60+
}
61+
62+
/**
63+
*
64+
* @param {ProtocolVersion | {major: number, minor: number}} other the protocol version to compare to
65+
* @returns {boolean} If this version is semantically larger than the other version.
66+
*/
67+
isGreaterThan (other: ProtocolVersion): boolean {
68+
if (this.major > other.major) {
69+
return true
70+
} else if (this.major === other.major && this.minor > other.minor) {
71+
return true
72+
}
73+
return false
74+
}
75+
76+
/**
77+
*
78+
* @param {ProtocolVersion | {major: number, minor: number}} other the protocol version to compare to
79+
* @returns {boolean} if this version is semantically larger or equal to the other version.
80+
*/
81+
isGreaterOrEqualTo (other: ProtocolVersion): boolean {
82+
return !this.isLessThan(other)
83+
}
84+
85+
/**
86+
*
87+
* @param {ProtocolVersion | {major: number, minor: number}} other the protocol version to compare to
88+
* @returns {boolean} if this version is semantically smaller or equal to the other version.
89+
*/
90+
isLessOrEqualTo (other: ProtocolVersion): boolean {
91+
return !this.isGreaterThan(other)
92+
}
93+
94+
/**
95+
*
96+
* @param {ProtocolVersion | {major: number, minor: number}} other the protocol version to compare to
97+
* @returns {boolean} If this version is the equal to the other version.
98+
*/
99+
isEqualTo (other: ProtocolVersion): boolean {
100+
return this.major === other.major && this.minor === other.minor
101+
}
102+
103+
toString (): string {
104+
return this.major.toString() + '.' + this.minor.toString()
105+
}
106+
}

packages/core/src/result-summary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Integer from './integer'
1919
import { NumberOrInteger } from './graph-types'
2020
import { util } from './internal'
2121
import GqlStatusObject, { Notification, buildGqlStatusObjectFromMetadata, buildNotificationsFromMetadata } from './notification'
22-
import { ProtocolVersion } from './internal/protocol-version'
22+
import { ProtocolVersion } from './protocol-version'
2323

2424
/**
2525
* A ResultSummary instance contains structured metadata for a {@link Result}.

packages/core/test/driver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { LogLevel } from '../src/types'
2525
import resultTransformers from '../src/result-transformers'
2626
import Record, { RecordShape } from '../src/record'
2727
import { invalidNotificationFilters, validNotificationFilters } from './utils/notification-filters.fixtures'
28-
import { ProtocolVersion } from '../src/internal/protocol-version'
28+
import { ProtocolVersion } from '../src/protocol-version'
2929

3030
describe('Driver', () => {
3131
let driver: Driver | null

packages/core/test/result-summary.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { int } from '../src'
19-
import { ProtocolVersion } from '../src/internal/protocol-version'
19+
import { ProtocolVersion } from '../src/protocol-version'
2020
import {
2121
ServerInfo,
2222
ProfiledPlan,

0 commit comments

Comments
 (0)