Skip to content

Commit 8a3dc00

Browse files
pocesarlutovich
authored andcommitted
needs to go inside lib or npm won't install
mv command left over can't use types as variables add some missing stuff, fix implicitAny errors can't use types for vars noImplicitAny and optional parameters type safety for session.run results needs typeof in const declaration for it to work result summary members unprotect members
1 parent d4a4458 commit 8a3dc00

30 files changed

+504
-512
lines changed
File renamed without changes.

src/v1/driver.d.ts renamed to lib/v1/driver.d.ts

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Promise } from "core-js";
2-
31
import Session from "./session";
42
import Pool from "./internal/pool";
53
import Integer from "./integer";
@@ -12,7 +10,7 @@ interface AuthCredentials {
1210
principal: string;
1311
credentials: string;
1412
realm?: string;
15-
parameters?: {[key: string]: any};
13+
parameters?: { [key: string]: any };
1614
}
1715

1816
interface ConfigurationOptions {
@@ -22,38 +20,33 @@ interface ConfigurationOptions {
2220
knownHosts?: string;
2321
}
2422

25-
declare type READ = "READ";
26-
declare type WRITE = "WRITE";
23+
declare const READ: string;
24+
declare const WRITE: string;
2725

2826
declare class Driver {
29-
constructor(url: string,
27+
constructor(
28+
url: string,
3029
userAgent: string,
3130
token: AuthCredentials,
32-
config: ConfigurationOptions)
33-
34-
_createConnection( url: string,
35-
release: ( url: string, conn: Connection ) => void
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
3639
): Connection;
37-
38-
static _validateConnection( conn: Connection ): Boolean
39-
40-
_destroyConnection( conn: Connection ): void;
41-
42-
session( mode: string ): Session;
43-
44-
_acquireConnection( mode: string ): Promise<Connection>;
45-
46-
_createSession(connectionPromise: Promise<Connection>, cb: Function): Session;
47-
40+
static _validateConnection(conn: Connection): Boolean
41+
session(mode?: string): Session;
4842
close(): void;
4943
}
5044

5145
declare class _ConnectionStreamObserver extends StreamObserver {
52-
constructor( driver: Driver, conn: Connection )
53-
54-
onError( error: Error ): void;
46+
constructor(driver: Driver, conn: Connection);
5547

56-
onCompleted( message: any ): void;
48+
onError(error: Error): void;
49+
onCompleted(message: any): void;
5750
}
5851

5952
export { Driver, READ, WRITE, AuthCredentials, ConfigurationOptions }

lib/v1/error.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declare const SERVICE_UNAVAILABLE: string;
2+
declare const SESSION_EXPIRED: string;
3+
4+
declare function newError(message: any, code: string): Neo4jError;
5+
6+
declare class Neo4jError extends Error {
7+
code: string;
8+
message: string;
9+
10+
constructor(message: any, code: string)
11+
}
12+
13+
export {
14+
newError,
15+
Neo4jError,
16+
SERVICE_UNAVAILABLE,
17+
SESSION_EXPIRED,
18+
}

src/v1/graph-types.d.ts renamed to lib/v1/graph-types.d.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
declare class Node {
2-
constructor(identity: string,
2+
constructor(
3+
identity: string,
34
labels: string[],
45
properties: Object
56
)
@@ -14,11 +15,13 @@ declare class Relationship {
1415
type: string;
1516
properties: Object;
1617

17-
constructor(identity: string,
18+
constructor(
19+
identity: string,
1820
start: string,
1921
end: string,
2022
type: string,
21-
properties: Object)
23+
properties: Object
24+
);
2225

2326
toString(): string;
2427
}
@@ -28,12 +31,13 @@ declare class UnboundRelationship {
2831
type: string;
2932
properties: Object;
3033

31-
constructor(identity: string,
34+
constructor(
35+
identity: string,
3236
type: string,
33-
properties: Object)
34-
35-
bind( start: string, end: string ): Relationship;
37+
properties: Object
38+
);
3639

40+
bind(start: string, end: string): Relationship;
3741
toString(): string;
3842
}
3943

@@ -42,9 +46,11 @@ declare class PathSegment {
4246
rel: Relationship;
4347
end: string;
4448

45-
constructor(start: string,
49+
constructor(
50+
start: string,
4651
rel: Relationship,
47-
end: string)
52+
end: string
53+
);
4854
}
4955

5056
declare class Path {

lib/v1/index.d.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { int, isInt, inSafeRange, toNumber, toString } from "./integer";
2+
import { Node, Relationship, UnboundRelationship, PathSegment, Path } from "./graph-types";
3+
import { Neo4jError, SERVICE_UNAVAILABLE, SESSION_EXPIRED } from "./error";
4+
import Result from "./result";
5+
import ResultSummary from "./result-summary";
6+
import Record from "./record";
7+
import { Driver, READ, WRITE, AuthCredentials, ConfigurationOptions } from "./driver";
8+
import RoutingDriver from "./routing-driver";
9+
import VERSION from "../version";
10+
import { parseScheme, parseUrl } from "./internal/connector";
11+
12+
declare const auth: {
13+
basic: (username: string,
14+
password: string,
15+
realm?: string) => AuthCredentials,
16+
custom: (principal: string,
17+
credentials: string,
18+
realm: string,
19+
scheme: string,
20+
parameters?: { [key: string]: any }) => AuthCredentials,
21+
};
22+
23+
declare const USER_AGENT: string;
24+
25+
declare function driver(url: string,
26+
authToken: AuthCredentials,
27+
config?: ConfigurationOptions): Driver;
28+
29+
declare const types: {
30+
Node: typeof Node;
31+
Relationship: typeof Relationship;
32+
UnboundRelationship: typeof UnboundRelationship;
33+
PathSegment: typeof PathSegment;
34+
Path: typeof Path;
35+
Result: typeof Result;
36+
ResultSummary: typeof ResultSummary;
37+
Record: typeof Record;
38+
};
39+
40+
declare const session: {
41+
READ: typeof READ;
42+
WRITE: typeof WRITE;
43+
};
44+
45+
declare const error: {
46+
SERVICE_UNAVAILABLE: typeof SERVICE_UNAVAILABLE;
47+
SESSION_EXPIRED: typeof SESSION_EXPIRED;
48+
};
49+
50+
declare const integer: {
51+
toNumber: typeof toNumber;
52+
toString: typeof toString;
53+
inSafeRange: typeof inSafeRange;
54+
};
55+
56+
declare const forExport: {
57+
driver: typeof driver;
58+
int: typeof int;
59+
isInt: typeof isInt;
60+
integer: typeof integer;
61+
Neo4jError: typeof Neo4jError;
62+
auth: typeof auth;
63+
types: typeof types;
64+
session: typeof session;
65+
error: typeof error;
66+
AuthCredentials: AuthCredentials;
67+
ConfigurationOptions: ConfigurationOptions;
68+
};
69+
70+
export {
71+
driver,
72+
int,
73+
isInt,
74+
integer,
75+
Neo4jError,
76+
auth,
77+
types,
78+
session,
79+
error,
80+
AuthCredentials,
81+
ConfigurationOptions,
82+
}
83+
84+
export default forExport;

lib/v1/integer.d.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { newError } from "./error";
2+
3+
declare class Integer {
4+
low: number;
5+
high: number;
6+
7+
constructor(low: number, high: number)
8+
9+
inSafeRange(): boolean;
10+
toInt(): number;
11+
toNumber(): number;
12+
toString(): string;
13+
getHighBits(): number;
14+
getLowBits(): number;
15+
getNumBitsAbs(): number;
16+
isZero(): boolean;
17+
isNegative(): boolean;
18+
isPositive(): boolean;
19+
isOdd(): boolean;
20+
isEven(): boolean;
21+
equals(other: Integer | number | string): boolean;
22+
notEquals(other: Integer | number | string): boolean;
23+
lessThan(other: Integer | number | string): boolean;
24+
lessThanOrEqual(other: Integer | number | string): boolean;
25+
greaterThan(other: Integer | number | string): boolean;
26+
greaterThanOrEqual(other: Integer | number | string): boolean;
27+
compare(other: Integer | number | string): number;
28+
negate(): Integer;
29+
add(addend: Integer | number | string): Integer;
30+
subtract(subtrahend: Integer | number | string): Integer;
31+
multiply(multiplier: Integer | number | string): Integer;
32+
div(divisor: Integer | number | string): Integer;
33+
modulo(divisor: Integer | number | string): Integer;
34+
not(): Integer;
35+
and(other: Integer | number | string): Integer;
36+
or(other: Integer | number | string): Integer;
37+
xor(other: Integer | number | string): Integer;
38+
shiftLeft(numBits: Integer | number): Integer;
39+
shiftRight(numBits: Integer | number): Integer;
40+
41+
static __isInteger__: true;
42+
static isInteger(obj: Object): boolean;
43+
static fromInt(value: number): Integer;
44+
static fromNumber(value: number): Integer;
45+
static fromBits(lowBits: number, highBits: number): Integer;
46+
static fromString(str: string, radix?: number): Integer;
47+
static fromValue(val: Integer | number | string | { low: number, high: number }): Integer;
48+
static toNumber(val: Integer | number | string | { low: number, high: number }): number;
49+
static toString(val: Integer | number | string | { low: number, high: number }, radix?: number): Integer;
50+
static inSafeRange(val: Integer | number | string | { low: number, high: number }): boolean;
51+
52+
static ZERO: Integer;
53+
static ONE: Integer;
54+
static NEG_ONE: Integer;
55+
static MAX_VALUE: Integer;
56+
static MIN_VALUE: Integer;
57+
static MIN_SAFE_VALUE: Integer;
58+
static MAX_SAFE_VALUE: Integer;
59+
}
60+
61+
declare function int(val: Integer | number | string | { low: number, high: number }): Integer;
62+
declare function isInt(obj: Object): boolean;
63+
declare function inSafeRange(val: Integer | number | string | { low: number, high: number }): boolean;
64+
declare function toNumber(val: Integer | number | string | { low: number, high: number }): number;
65+
declare function toString(val: Integer | number | string | { low: number, high: number }, radix?: number): Integer;
66+
67+
declare const TWO_PWR_16_DBL: number;
68+
declare const TWO_PWR_24_DBL: number;
69+
declare const TWO_PWR_32_DBL: number;
70+
declare const TWO_PWR_64_DBL: number;
71+
declare const TWO_PWR_63_DBL: number;
72+
declare const TWO_PWR_24: Integer;
73+
74+
declare const INT_CACHE: Object;
75+
76+
export {
77+
int,
78+
isInt,
79+
inSafeRange,
80+
toNumber,
81+
toString
82+
}
83+
84+
export default Integer;

lib/v1/internal/connector.d.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { ConfigurationOptions } from "../driver";
2+
3+
declare class Connection {
4+
constructor(channel: { write: Function, onMessage: Function }, url: string);
5+
6+
initialise(
7+
clientName: string,
8+
token: any,
9+
observer: any
10+
): void;
11+
12+
run(
13+
statement: any,
14+
params: Object,
15+
observer: any
16+
): void;
17+
18+
pullAll(observer: any): void;
19+
discardAll(observer: any): void;
20+
reset(observer: any): void;
21+
sync(): any;
22+
isOpen(): boolean;
23+
isEncrypted(): boolean;
24+
close(cb?: Function): void;
25+
setServerVersion(version: string): void;
26+
}
27+
28+
declare function connect(
29+
url: string,
30+
config?: ConfigurationOptions
31+
): Connection;
32+
33+
declare function parseScheme(url: string): string;
34+
declare function parseUrl(url: string): string;
35+
36+
export {
37+
connect,
38+
Connection,
39+
parseScheme,
40+
parseUrl,
41+
}

lib/v1/internal/pool.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
declare class Pool {
2+
constructor(
3+
create: Function,
4+
destroy: Function,
5+
validate: Function,
6+
maxIdle: number
7+
);
8+
aquire(key: string | number): any;
9+
purge(key: string | number): any;
10+
purgeAll(): void;
11+
has(key: string | number): any;
12+
}
13+
14+
export default Pool;
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
declare class RoundRobinArray {
2-
constructor( items: any )
2+
constructor(items: any);
33

44
next(): any;
5-
6-
push( elem: any ): any;
7-
8-
pushAll( elem: any ): any;
9-
5+
push(elem: any): any;
6+
pushAll(elem: any): any;
107
empty(): number;
11-
128
clear(): void;
13-
149
size(): number;
15-
1610
toArray(): any[];
17-
18-
remove( item: any ): any;
11+
remove(item: any): any;
1912
}
2013

2114
export default RoundRobinArray;

0 commit comments

Comments
 (0)