Add typings for tarantool-driver

This commit is contained in:
Evgeni Zharkov
2019-03-02 18:31:09 +03:00
parent f0b06ef54e
commit 0a5d7232d4
4 changed files with 85 additions and 0 deletions

58
types/tarantool-driver/index.d.ts vendored Normal file
View File

@@ -0,0 +1,58 @@
// Type definitions for tarantool-driver 3.0
// Project: https://github.com/tarantool/node-tarantool-driver
// Definitions by: Evgeni Zharkov <https://github.com/zharkov-eu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { EventEmitter } from "events";
export interface TarantoolOptions {
host?: string;
port?: number;
username?: string;
password?: string;
reserveHosts?: string[];
beforeReserve?: number;
timeout?: number;
retryStrategy?: (times: number) => number;
lazyConnect?: boolean;
}
export default class TarantoolConnection extends EventEmitter {
constructor(options: TarantoolOptions);
/* Connection */
connect(): Promise<void>;
flushQueue(cb: (err: Error) => void): void;
destroy(): void;
disconnect(reconnect?: boolean): void;
/* Commands */
select(spaceId: number | string,
indexId: number | string,
limit: number, offset: number,
iterator: string, key: string | string[]): Promise<any>;
delete(spaceId: number | string,
indexId: number | string,
key: any[]): Promise<any>;
update(spaceId: number | string,
indexId: number | string,
key: any[], ops: any[]): Promise<any>;
upsert(spaceId: number | string,
ops: any[], tuple: any[]): Promise<any>;
eval(expression: string, ...args: any[]): Promise<any>;
call(functionName: string, ...args: any[]): Promise<any>;
insert(spaceId: number | string, tuple: any[]): Promise<any>;
replace(spaceId: number | string, tuple: any[]): Promise<any>;
}

View File

@@ -0,0 +1,3 @@
import TarantoolDriver from "tarantool-driver";
new TarantoolDriver({}).connect(); // $ExpectedType Promise

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"tarantool-driver-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }