diff --git a/types/tarantool-driver/index.d.ts b/types/tarantool-driver/index.d.ts new file mode 100644 index 0000000000..63b34cb6fa --- /dev/null +++ b/types/tarantool-driver/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for tarantool-driver 3.0 +// Project: https://github.com/tarantool/node-tarantool-driver +// Definitions by: Evgeni Zharkov +// 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; + + 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; + + delete(spaceId: number | string, + indexId: number | string, + key: any[]): Promise; + + update(spaceId: number | string, + indexId: number | string, + key: any[], ops: any[]): Promise; + + upsert(spaceId: number | string, + ops: any[], tuple: any[]): Promise; + + eval(expression: string, ...args: any[]): Promise; + + call(functionName: string, ...args: any[]): Promise; + + insert(spaceId: number | string, tuple: any[]): Promise; + + replace(spaceId: number | string, tuple: any[]): Promise; +} diff --git a/types/tarantool-driver/tarantool-driver-tests.ts b/types/tarantool-driver/tarantool-driver-tests.ts new file mode 100644 index 0000000000..cf27d123fb --- /dev/null +++ b/types/tarantool-driver/tarantool-driver-tests.ts @@ -0,0 +1,3 @@ +import TarantoolDriver from "tarantool-driver"; + +new TarantoolDriver({}).connect(); // $ExpectedType Promise diff --git a/types/tarantool-driver/tsconfig.json b/types/tarantool-driver/tsconfig.json new file mode 100644 index 0000000000..c49fafed46 --- /dev/null +++ b/types/tarantool-driver/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/types/tarantool-driver/tslint.json b/types/tarantool-driver/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/tarantool-driver/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file