|
| 1 | +/** |
| 2 | + * Copyright (c) 2002-2017 "Neo Technology,"," |
| 3 | + * Network Engine for Objects in Lund AB [http://neotechnology.com] |
| 4 | + * |
| 5 | + * This file is part of Neo4j. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | + |
1 | 20 | import Session from "./session"; |
2 | | -import Pool from "./internal/pool"; |
3 | | -import Integer from "./integer"; |
4 | | -import { connect, Connection } from "./internal/connector"; |
5 | | -import StreamObserver from "./internal/stream-observer"; |
6 | | -import { newError, SERVICE_UNAVAILABLE } from "./error"; |
| 21 | +import {Parameters} from "./statement-runner"; |
7 | 22 |
|
8 | | -interface AuthCredentials { |
| 23 | +interface AuthToken { |
9 | 24 | scheme: string; |
10 | 25 | principal: string; |
11 | 26 | credentials: string; |
12 | 27 | realm?: string; |
13 | | - parameters?: { [key: string]: any }; |
| 28 | + parameters?: Parameters; |
14 | 29 | } |
15 | 30 |
|
16 | | -interface ConfigurationOptions { |
17 | | - encrypted?: string; |
18 | | - trust?: string; |
19 | | - trustedCertificates?: any[]; |
| 31 | +type EncryptionLevel = "ENCRYPTION_ON" | "ENCRYPTION_OFF"; |
| 32 | +type TrustStrategy = |
| 33 | + "TRUST_ALL_CERTIFICATES" | |
| 34 | + "TRUST_ON_FIRST_USE" | |
| 35 | + "TRUST_SIGNED_CERTIFICATES" | |
| 36 | + "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES" | |
| 37 | + "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"; |
| 38 | + |
| 39 | +interface Config { |
| 40 | + encrypted?: boolean | EncryptionLevel; |
| 41 | + trust?: TrustStrategy; |
| 42 | + trustedCertificates?: string[]; |
20 | 43 | knownHosts?: string; |
| 44 | + connectionPoolSize?: number; |
| 45 | + maxTransactionRetryTime?: number; |
21 | 46 | } |
22 | 47 |
|
23 | | -declare const READ: string; |
24 | | -declare const WRITE: string; |
25 | | - |
26 | | -declare class Driver { |
27 | | - constructor( |
28 | | - url: string, |
29 | | - userAgent: string, |
30 | | - token: AuthCredentials, |
31 | | - config?: ConfigurationOptions |
32 | | - ); |
33 | | - |
34 | | - protected _destroyConnection(conn: Connection): void; |
35 | | - protected _acquireConnection(mode: string): PromiseLike<Connection>; |
36 | | - protected _createSession(connectionPromise: PromiseLike<Connection>, cb: Function): Session; |
37 | | - protected _createConnection(url: string, |
38 | | - release: (url: string, conn: Connection) => void |
39 | | - ): Connection; |
40 | | - static _validateConnection(conn: Connection): Boolean |
41 | | - session(mode?: string): Session; |
42 | | - close(): void; |
43 | | -} |
| 48 | +type SessionMode = "READ" | "WRITE"; |
44 | 49 |
|
45 | | -declare class _ConnectionStreamObserver<T> extends StreamObserver<T> { |
46 | | - constructor(driver: Driver, conn: Connection); |
| 50 | +declare const READ: SessionMode; |
| 51 | +declare const WRITE: SessionMode; |
47 | 52 |
|
48 | | - onError(error: Error): void; |
49 | | - onCompleted(message: any): void; |
| 53 | +declare interface Driver { |
| 54 | + session(mode?: SessionMode, bookmark?: string): Session; |
| 55 | + |
| 56 | + close(): void; |
50 | 57 | } |
51 | 58 |
|
52 | | -export { Driver, READ, WRITE, AuthCredentials, ConfigurationOptions } |
| 59 | +export {Driver, READ, WRITE, AuthToken, Config} |
53 | 60 |
|
54 | 61 | export default Driver; |
0 commit comments