Files
DefinitelyTyped/pg/index.d.ts
Leo Liang eab542d3d6 Merge commit '84a760de85868091952eddb76eb21374267cdc0e' into types-2.0
* commit '84a760de85868091952eddb76eb21374267cdc0e': (424 commits)
  Add confit typings (#11168)
  d3-array: * Add explicit typing to an `extent` test with mixed array including NumCoercible. It appears type inference has changed with the lates TypeScript@next (2.1.0-dev.20160912 or 2.1.0-dev.20160913). This could be a regression in TS, but for now to not break DT/types-2.0 in the interim an explicit cast is applied.
  Updated pasteHTML(...) interface definitions and bumped version to v1.0.3
  Add missing semicolon
  Node.d.ts: Update definitions for module "stream" (#11086)
  [node]Rearrange the order and add missing stuff for os (#11146)
  Add new stuff (#11147)
  Added definitions for Validate.js (#10988)
  [node] Correct constants module for node v6 (#11140)
  Added typings for libxslt (#11094)
  Node.d.ts: Update definitions for module "dgram" (#11143)
  Change type definition for angular-es@1.0.0 (#11141)
  Added toast class property to toast options/config object per commit … (#11132)
  [node] imported and global process are same (#11092)
  fixing a typo in cache-manager/cache-manager.d.ts (#11129)
  Add humps definitions (#11127)
  Definitions braintree-web v3.0.2 (#11126)
  Remove JQuery dependency for Segment analytics (#11124)
  Update resolve type in angular-material.d.ts. (#11122)
  manager using credentials (#11078)
  ...

# Conflicts:
#	pg-pool/pg-pool-tests.ts
#	pg/index.d.ts
2016-09-16 15:51:12 +08:00

132 lines
4.3 KiB
TypeScript

// Type definitions for pg 6.1.0
// Project: https://github.com/brianc/node-postgres
// Definitions by: Phips Peter <http://pspeter3.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import events = require("events");
import stream = require("stream");
export declare function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void;
export declare function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void;
export declare function end(): void;
export interface ConnectionConfig {
user?: string;
database?: string;
password?: string;
port?: number;
host?: string;
}
export interface Defaults extends ConnectionConfig {
poolSize?: number;
poolIdleTimeout?: number;
reapIntervalMillis?: number;
binary?: boolean;
parseInt8?: boolean;
}
export interface ClientConfig extends ConnectionConfig {
ssl?: boolean;
}
export interface PoolConfig extends ClientConfig {
// properties from module 'node-pool'
max?: number;
min?: number;
refreshIdle?: boolean;
idleTimeoutMillis?: number;
reapIntervalMillis?: number;
returnToHead?: boolean;
}
export interface QueryConfig {
name?: string;
text: string;
values?: any[];
}
export interface QueryResult {
command: string;
rowCount: number;
oid: number;
rows: any[];
}
export interface ResultBuilder extends QueryResult {
addRow(row: any): void;
}
export declare class Pool extends events.EventEmitter {
constructor();
// `new Pool('pg://user@localhost/mydb')` is not allowed.
// But it passes type check because of issue:
// https://github.com/Microsoft/TypeScript/issues/7485
constructor(config: PoolConfig);
connect(): Promise<Client>;
connect(callback: (err: Error, client: Client, done: () => void) => void): void;
end(): Promise<void>;
query(queryText: string): Promise<QueryResult>;
query(queryText: string, values: any[]): Promise<QueryResult>;
query(queryText: string, callback: (err: Error, result: QueryResult) => void): void;
query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): void;
public on(event: "error", listener: (err: Error, client: Client) => void): this;
public on(event: "connect", listener: (client: Client) => void): this;
public on(event: "acquire", listener: (client: Client) => void): this;
public on(event: string, listener: Function): this;
}
export declare class Client extends events.EventEmitter {
constructor(connection: string);
constructor(config: ClientConfig);
connect(callback?: (err:Error) => void): void;
end(): void;
release(): void;
query(queryText: string): Promise<QueryResult>;
query(queryText: string, values: any[]): Promise<QueryResult>;
query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query;
query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query;
query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query;
copyFrom(queryText: string): stream.Writable;
copyTo(queryText: string): stream.Readable;
pauseDrain(): void;
resumeDrain(): void;
public on(event: "drain", listener: () => void): this;
public on(event: "error", listener: (err: Error) => void): this;
public on(event: "notification", listener: (message: any) => void): this;
public on(event: "notice", listener: (message: any) => void): this;
public on(event: string, listener: Function): this;
}
export declare class Query extends events.EventEmitter {
public on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this;
public on(event: "error", listener: (err: Error) => void): this;
public on(event: "end", listener: (result: ResultBuilder) => void): this;
public on(event: string, listener: Function): this;
}
export declare class Events extends events.EventEmitter {
public on(event: "error", listener: (err: Error, client: Client) => void): this;
public on(event: string, listener: Function): this;
}
declare namespace types {
function setTypeParser<T>(typeId: number, parser: (value: string) => T): void;
}