@broid/twilio
Version:
Convert Twilio messages into Activity Streams 2 with Broid Integration
1,378 lines (1,244 loc) • 146 kB
TypeScript
// Generated by typings
// Source: https://raw.githubusercontent.com/types/env-node/4fbb2e31b2e4f1b0e7680fc0dc13380e06160174/6.0/node.d.ts
interface NodeError {
/**
* Returns a string describing the point in the code at which the Error was instantiated.
*
* For example:
*
* ```
* Error: Things keep happening!
* at /home/gbusey/file.js:525:2
* at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21)
* at Actor.<anonymous> (/home/gbusey/actors.js:400:8)
* at increaseSynergy (/home/gbusey/actors.js:701:6)
* ```
*
* The first line is formatted as <error class name>: <error message>, and is followed by a series of stack frames (each line beginning with "at "). Each frame describes a call site within the code that lead to the error being generated. V8 attempts to display a name for each function (by variable name, function name, or object method name), but occasionally it will not be able to find a suitable name. If V8 cannot determine a name for the function, only location information will be displayed for that frame. Otherwise, the determined function name will be displayed with location information appended in parentheses.
*/
stack?: string;
/**
* Returns the string description of error as set by calling new Error(message). The message passed to the constructor will also appear in the first line of the stack trace of the Error, however changing this property after the Error object is created may not change the first line of the stack trace.
*
* ```
* const err = new Error('The message');
* console.log(err.message);
* // Prints: The message
* ```
*/
message: string;
}
interface Error extends NodeError { }
interface ErrorConstructor {
/**
* Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()`` was called.
*
* ```js
* const myObject = {};
* Error.captureStackTrace(myObject);
* myObject.stack // similar to `new Error().stack`
* ```
*
* The first line of the trace, instead of being prefixed with `ErrorType : message`, will be the result of calling `targetObject.toString()``.
*
* The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.
*
* The constructorOpt argument is useful for hiding implementation details of error generation from an end user. For instance:
*
* ```js
* function MyError() {
* Error.captureStackTrace(this, MyError);
* }
*
* // Without passing MyError to captureStackTrace, the MyError
* // frame would should up in the .stack property. by passing
* // the constructor, we omit that frame and all frames above it.
* new MyError().stack
* ```
*/
captureStackTrace<T extends { stack?: string }>(targetObject: T, constructorOpt?: new () => T): void;
/**
* The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj))``.
*
* The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed.
*
* If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
*/
stackTraceLimit: number;
}
// ES2015 collection types
interface NodeCollection {
size: number;
}
interface NodeWeakCollection {}
interface IterableIterator<T> {}
interface NodeCollectionConstructor<T> {
prototype: T;
}
interface Map<K, V> extends NodeCollection {
clear(): void;
delete(key: K): boolean;
entries(): Array<[K, V]>;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
keys(): Array<K>;
set(key: K, value?: V): Map<K, V>;
values(): Array<V>;
// [Symbol.iterator]():Array<[K,V]>;
// [Symbol.toStringTag]: "Map";
}
interface MapConstructor extends NodeCollectionConstructor<Map<any, any>> {
new (): Map<any, any>;
new <K, V>(): Map<K, V>;
}
declare var Map: MapConstructor;
interface WeakMap<K, V> extends NodeWeakCollection {
clear(): void;
delete(key: K): boolean;
get(key: K): V | void;
has(key: K): boolean;
set(key: K, value?: V): WeakMap<K, V>;
}
interface WeakMapConstructor extends NodeCollectionConstructor<WeakMap<any, any>> {
new (): WeakMap<any, any>;
new <K, V>(): WeakMap<K, V>;
}
declare var WeakMap: WeakMapConstructor;
interface Set<T> extends NodeCollection {
add(value: T): Set<T>;
clear(): void;
delete(value: T): boolean;
entries(): Array<[T, T]>;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
keys(): Array<T>;
values(): Array<T>;
// [Symbol.iterator]():Array<T>;
// [Symbol.toStringTag]: "Set";
}
interface SetConstructor extends NodeCollectionConstructor<Set<any>> {
new (): Set<any>;
new <T>(): Set<T>;
new <T>(iterable: Array<T>): Set<T>;
}
declare var Set: SetConstructor;
interface WeakSet<T> extends NodeWeakCollection {
add(value: T): WeakSet<T>;
clear(): void;
delete(value: T): boolean;
has(value: T): boolean;
// [Symbol.toStringTag]: "WeakSet";
}
interface WeakSetConstructor extends NodeCollectionConstructor<WeakSet<any>> {
new (): WeakSet<any>;
new <T>(): WeakSet<T>;
new <T>(iterable: Array<T>): WeakSet<T>;
}
declare var WeakSet: WeakSetConstructor;
/************************************************
* *
* GLOBAL *
* *
************************************************/
declare var process: NodeJS.Process;
declare var global: NodeJS.Global;
declare var __filename: string;
declare var __dirname: string;
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearInterval(intervalId: NodeJS.Timer): void;
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
declare function clearImmediate(immediateId: any): void;
interface NodeRequireFunction {
(id: string): any;
}
interface NodeRequire extends NodeRequireFunction {
resolve(id: string): string;
cache: { [filename: string]: NodeModule };
extensions: NodeExtensions;
main: any;
}
interface NodeExtensions {
'.js': (m: NodeModule, filename: string) => any;
'.json': (m: NodeModule, filename: string) => any;
'.node': (m: NodeModule, filename: string) => any;
[ext: string]: (m: NodeModule, filename: string) => any;
}
declare var require: NodeRequire;
declare class NodeModule {
static runMain(): void;
static wrap(code: string): string;
static _nodeModulePaths(path: string): string[];
static _load(request: string, parent?: NodeModule, isMain?: boolean): any;
static _resolveFilename(request: string, parent?: NodeModule, isMain?: boolean): string;
static _extensions: NodeExtensions;
constructor(filename: string);
_compile(code: string, filename: string): string;
id: string;
parent: NodeModule;
filename: string;
paths: string[];
children: NodeModule[];
exports: any;
loaded: boolean;
require: NodeRequireFunction;
}
declare var module: NodeModule;
// Same as module.exports
declare var exports: any;
declare var SlowBuffer: {
new (str: string, encoding?: string): Buffer;
new (size: number): Buffer;
new (size: Uint8Array): Buffer;
new (array: any[]): Buffer;
prototype: Buffer;
isBuffer(obj: any): boolean;
byteLength(string: string, encoding?: string): number;
concat(list: Buffer[], totalLength?: number): Buffer;
};
// Console class (compatible with TypeScript `lib.d.ts`).
declare interface Console {
log(msg: any, ...params: any[]): void;
info(msg: any, ...params: any[]): void;
warn(msg: any, ...params: any[]): void;
error(msg: any, ...params: any[]): void;
dir(value: any, ...params: any[]): void;
time(timerName?: string): void;
timeEnd(timerName?: string): void;
trace(msg: any, ...params: any[]): void;
assert(test?: boolean, msg?: string, ...params: any[]): void;
Console: new (stdout: NodeJS.WritableStream) => Console;
}
declare var console: Console;
declare class Buffer extends Uint8Array {
[index: number]: number;
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
*/
constructor(str: string, encoding?: string);
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
*/
constructor(size: number);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor(array: Uint8Array);
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}.
*
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
*/
constructor(arrayBuffer: ArrayBuffer);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor(array: any[]);
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
*/
constructor(buffer: Buffer);
/**
* Allocates a new Buffer using an {array} of octets.
*
* @param array
*/
static from(array: any[]): Buffer;
/**
* When passed a reference to the .buffer property of a TypedArray instance,
* the newly created Buffer will share the same allocated memory as the TypedArray.
* The optional {byteOffset} and {length} arguments specify a memory range
* within the {arrayBuffer} that will be shared by the Buffer.
*
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
* @param byteOffset
* @param length
*/
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Copies the passed {buffer} data onto a new Buffer instance.
*
* @param buffer
*/
static from(buffer: Buffer): Buffer;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
* If not provided, {encoding} defaults to 'utf8'.
*
* @param str
*/
static from(str: string, encoding?: string): Buffer;
/**
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be _zero-filled_.
*
* @param size The desired length of the new `Buffer`
* @param fill A value to pre-fill the new `Buffer` with. Default: `0`
* @param encoding If `fill` is a string, this is its encoding. Default: `'utf8'`
*/
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
/**
* Allocates a new _non-zero-filled_ `Buffer` of `size` bytes. The `size` must be less than or equal to the value of `buffer.kMaxLength`. Otherwise, a `RangeError` is thrown. A zero-length `Buffer` will be created if `size <= 0`.
*
* The underlying memory for `Buffer` instances created in this way is not initialized. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize such `Buffer` instances to zeroes.
*
* @param size The desired length of the new `Buffer`
*/
static allocUnsafe(size: number): Buffer;
/**
* Returns `true` if `obj` is a Buffer, `false` otherwise.
*/
static isBuffer(obj: any): obj is Buffer;
/**
* Returns `true` if `encoding` contains a supported character encoding, or `false` otherwise.
*
* @param encoding A character encoding name to check.
*/
static isEncoding(encoding: string): boolean;
/**
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
* This is not the same as String.prototype.length since that returns the number of characters in a string.
*
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
static byteLength(string: string, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
* If the list has exactly one item, then the first item of the list is returned.
* If the list has more than one item, then a new Buffer is created.
*
* @param list An array of Buffer objects to concatenate
* @param totalLength Total length of the buffers when concatenated.
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
static concat(list: Buffer[], totalLength?: number): Buffer;
/**
* The same as buf1.compare(buf2).
*/
compare(buf1: Buffer, buf2: Buffer): number;
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): any;
equals(otherBuffer: Buffer): boolean;
compare(otherBuffer: Buffer): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): this;
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
swap16(): this;
swap32(): this;
swap64(): this;
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
entries(): IterableIterator<[number, number]>;
keys(): IterableIterator<number>;
values(): IterableIterator<number>;
}
/************************************************
* *
* GLOBAL INTERFACES *
* *
************************************************/
declare namespace NodeJS {
export interface ErrnoException extends Error {
errno?: number;
code?: string;
path?: string;
syscall?: string;
stack?: string;
}
export interface EventEmitter {
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
prependListener(event: string, listener: Function): this;
prependOnceListener(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
eventNames(): string[];
listenerCount(type: string): number;
}
export interface ReadableStream extends EventEmitter {
readable: boolean;
read(size?: number): string | Buffer;
setEncoding(encoding: string): this;
isPaused(): boolean;
pause(): this;
resume(): this;
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
unpipe<T extends WritableStream>(destination?: T): void;
unshift(chunk: string): void;
unshift(chunk: Buffer): void;
wrap(oldStream: ReadableStream): ReadableStream;
}
export interface WritableStream extends EventEmitter {
writable: boolean;
setDefaultEncoding(encoding: string): this;
write(buffer: Buffer | string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export interface ReadWriteStream extends ReadableStream, WritableStream { }
export interface Events extends EventEmitter { }
export interface Domain extends Events {
run(fn: Function): void;
add(emitter: Events): void;
remove(emitter: Events): void;
bind(cb: (err: Error, data: any) => any): any;
intercept(cb: (data: any) => any): any;
dispose(): void;
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
}
export interface MemoryUsage {
rss: number;
heapTotal: number;
heapUsed: number;
}
export interface Env {
PATH: string;
[key: string]: string;
}
export interface Versions {
http_parser: string;
node: string;
v8: string;
ares: string;
uv: string;
zlib: string;
modules: string;
openssl: string;
}
export interface Process extends EventEmitter {
stdout: WritableStream;
stderr: WritableStream;
stdin: ReadableStream;
argv: string[];
argv0: string;
/**
* The process.execArgv property returns the set of Node.js-specific command-line options passed when the Node.js process was launched. These options do not appear in the array returned by the process.argv property, and do not include the Node.js executable, the name of the script, or any options following the script name. These options are useful in order to spawn child processes with the same execution environment as the parent.
*/
execArgv: string[];
execPath: string;
abort(): void;
chdir(directory: string): void;
cwd(): string;
env: Env;
exit(code?: number): void;
exitCode?: number;
getgid(): number;
setgid(id: number): void;
setgid(id: string): void;
getuid(): number;
setuid(id: number): void;
setuid(id: string): void;
version: string;
versions: Versions;
config: {
target_defaults: {
cflags: any[];
default_configuration: string;
defines: string[];
include_dirs: string[];
libraries: string[];
};
variables: {
clang: number;
host_arch: string;
node_install_npm: boolean;
node_install_waf: boolean;
node_prefix: string;
node_shared_openssl: boolean;
node_shared_v8: boolean;
node_shared_zlib: boolean;
node_use_dtrace: boolean;
node_use_etw: boolean;
node_use_openssl: boolean;
target_arch: string;
v8_no_strict_aliasing: number;
v8_use_snapshot: boolean;
visibility: string;
};
};
kill(pid: number, signal?: string | number): void;
pid: number;
title: string;
arch: string;
platform: string;
memoryUsage(): MemoryUsage;
nextTick(callback: Function): void;
umask(mask?: number): number;
uptime(): number;
hrtime(time?: [number, number]): [number, number];
domain: Domain;
// Worker
send?(message: any, sendHandle?: any): void;
disconnect(): void;
connected: boolean;
}
export interface Global {
Array: typeof Array;
ArrayBuffer: typeof ArrayBuffer;
Boolean: typeof Boolean;
Buffer: typeof Buffer;
DataView: typeof DataView;
Date: typeof Date;
Error: typeof Error;
EvalError: typeof EvalError;
Float32Array: typeof Float32Array;
Float64Array: typeof Float64Array;
Function: typeof Function;
GLOBAL: Global;
Infinity: typeof Infinity;
Int16Array: typeof Int16Array;
Int32Array: typeof Int32Array;
Int8Array: typeof Int8Array;
Intl: typeof Intl;
JSON: typeof JSON;
Map: MapConstructor;
Math: typeof Math;
NaN: typeof NaN;
Number: typeof Number;
Object: typeof Object;
Promise: Function;
RangeError: typeof RangeError;
ReferenceError: typeof ReferenceError;
RegExp: typeof RegExp;
Set: SetConstructor;
String: typeof String;
Symbol: Function;
SyntaxError: typeof SyntaxError;
TypeError: typeof TypeError;
URIError: typeof URIError;
Uint16Array: typeof Uint16Array;
Uint32Array: typeof Uint32Array;
Uint8Array: typeof Uint8Array;
Uint8ClampedArray: Function;
WeakMap: WeakMapConstructor;
WeakSet: WeakSetConstructor;
clearImmediate: (immediateId: any) => void;
clearInterval: (intervalId: NodeJS.Timer) => void;
clearTimeout: (timeoutId: NodeJS.Timer) => void;
console: typeof console;
decodeURI: typeof decodeURI;
decodeURIComponent: typeof decodeURIComponent;
encodeURI: typeof encodeURI;
encodeURIComponent: typeof encodeURIComponent;
escape: (str: string) => string;
eval: typeof eval;
global: Global;
isFinite: typeof isFinite;
isNaN: typeof isNaN;
parseFloat: typeof parseFloat;
parseInt: typeof parseInt;
process: Process;
root: Global;
setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
undefined: typeof undefined;
unescape: (str: string) => string;
gc: () => void;
v8debug?: any;
}
export interface Timer {
ref(): void;
unref(): void;
_called: boolean;
_onTimeout: Function;
_timerArgs?: any[];
}
export interface Immediate {
_argv?: any[];
_callback: Function;
_onImmediate: Function;
}
}
/************************************************
* *
* MODULES *
* *
************************************************/
declare module "buffer" {
export var INSPECT_MAX_BYTES: number;
export var kMaxLength: number;
export type Encoding = "ascii" | "latin1" | "binary" | "utf8" | "utf-8" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "hex" | "base64";
var BuffType: typeof Buffer;
var SlowBuffType: typeof SlowBuffer;
export { BuffType as Buffer, SlowBuffType as SlowBuffer };
}
declare module "querystring" {
export interface StringifyOptions {
encodeURIComponent?: Function;
}
export interface ParseOptions {
maxKeys?: number;
decodeURIComponent?: Function;
}
export function stringify<T>(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any;
export function parse<T extends { [key: string]: string | string[] }>(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
export function escape(str: string): string;
export function unescape(str: string): string;
}
declare module "events" {
export class EventEmitter implements NodeJS.EventEmitter {
static EventEmitter: EventEmitter;
static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
static defaultMaxListeners: number;
addListener(event: string, listener: (...args: any[]) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
removeListener(event: string, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Array<(...args: any[]) => void>;
listenerCount(event: string): number;
emit(event: string, ...args: any[]): boolean;
eventNames(): string[];
}
export interface Listener<E extends string, L extends Function> {
on(event: E, listener: L): this;
once(event: E, listener: L): this;
addListener(event: E, listener: L): this;
removeListener(event: E, listener: L): this;
listeners(event: E): L[];
}
}
declare module "http" {
import * as events from "events";
import * as net from "net";
import * as stream from "stream";
export interface OutgoingHeaders {
[header: string]: number | string | string[];
}
export interface IncomingHeaders {
[header: string]: string | string[];
}
export interface RequestOptions {
protocol?: string;
host?: string;
hostname?: string;
family?: number;
port?: number | string;
localAddress?: string;
socketPath?: string;
method?: string;
path?: string;
headers?: OutgoingHeaders;
auth?: string;
agent?: Agent | boolean;
}
export class Server extends net.Server {
setTimeout(msecs: number, callback: Function): void;
maxHeadersCount: number;
timeout: number;
listening: boolean;
}
export class ServerResponse extends stream.Writable {
finished: boolean;
headersSent: boolean;
statusCode: number;
statusMessage: string;
sendDate: boolean;
// Extended base methods
write(buffer: Buffer): boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
write(str: string, encoding?: string, fd?: string): boolean;
writeContinue(): void;
writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void;
writeHead(statusCode: number, headers?: OutgoingHeaders): void;
setHeader(name: string, value: string | string[]): void;
setTimeout(msecs: number, callback: () => void): this;
getHeader(name: string): string;
removeHeader(name: string): void;
write(chunk: any, encoding?: string): any;
addTrailers(headers: OutgoingHeaders): void;
// Extended base methods
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
}
export class ClientRequest extends stream.Writable {
// Extended base methods
write(buffer: Buffer): boolean;
write(buffer: Buffer, cb?: Function): boolean;
write(str: string, cb?: Function): boolean;
write(str: string, encoding?: string, cb?: Function): boolean;
write(str: string, encoding?: string, fd?: string): boolean;
write(chunk: any, encoding?: string): void;
abort(): void;
setTimeout(timeout: number, callback?: Function): void;
setNoDelay(noDelay?: boolean): void;
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
setHeader(name: string, value: string | string[]): void;
getHeader(name: string): string;
removeHeader(name: string): void;
addTrailers(headers: any): void;
// Extended base methods
end(): void;
end(buffer: Buffer, cb?: Function): void;
end(str: string, cb?: Function): void;
end(str: string, encoding?: string, cb?: Function): void;
end(data?: any, encoding?: string): void;
}
export class IncomingMessage extends stream.Readable {
httpVersion: string;
headers: IncomingHeaders;
rawHeaders: string[];
trailers: IncomingHeaders;
rawTrailers: string[];
setTimeout(msecs: number, callback: Function): NodeJS.Timer;
destroy(error?: Error): void;
/**
* Only valid for request obtained from http.Server.
*/
method?: string;
/**
* Only valid for request obtained from http.Server.
*/
url?: string;
/**
* Only valid for response obtained from http.ClientRequest.
*/
statusCode?: number;
/**
* Only valid for response obtained from http.ClientRequest.
*/
statusMessage?: string;
socket: net.Socket;
}
export interface AgentOptions {
/**
* Keep sockets around in a pool to be used by other requests in the future. Default = false
*/
keepAlive?: boolean;
/**
* When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
* Only relevant if keepAlive is set to true.
*/
keepAliveMsecs?: number;
/**
* Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
*/
maxSockets?: number;
/**
* Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
*/
maxFreeSockets?: number;
}
export class Agent {
maxSockets: number;
sockets: any;
requests: any;
constructor(opts?: AgentOptions);
/**
* Destroy any sockets that are currently in use by the agent.
* It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
* then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
* sockets may hang open for quite a long time before the server terminates them.
*/
destroy(): void;
}
export var METHODS: string[];
export var STATUS_CODES: {
[errorCode: number]: string;
[errorCode: string]: string;
};
export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server;
export function createClient(port?: number, host?: string): any;
export function request(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
export function get(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
export var globalAgent: Agent;
}
declare module "cluster" {
import * as child from "child_process";
import * as events from "events";
export interface ClusterSettings {
exec?: string;
args?: string[];
silent?: boolean;
}
export interface Address {
address: string;
port: number;
addressType: string;
}
export class Worker extends events.EventEmitter {
id: string;
process: child.ChildProcess;
suicide: boolean;
send(message: any, sendHandle?: any): boolean;
kill(signal?: string): void;
destroy(signal?: string): void;
disconnect(): void;
isConnected(): boolean;
isDead(): boolean;
}
export var settings: ClusterSettings;
export var isMaster: boolean;
export var isWorker: boolean;
export function setupMaster(settings?: ClusterSettings): void;
export function fork(env?: any): Worker;
export function disconnect(callback?: Function): void;
export var worker: Worker;
export var workers: {
[index: string]: Worker
};
// Event emitter
export function addListener(event: string, listener: Function): void;
export function on(event: "disconnect", listener: (worker: Worker) => void): void;
export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void;
export function on(event: "fork", listener: (worker: Worker) => void): void;
export function on(event: "listening", listener: (worker: Worker, address: any) => void): void;
export function on(event: "message", listener: (worker: Worker, message: any) => void): void;
export function on(event: "online", listener: (worker: Worker) => void): void;
export function on(event: "setup", listener: (settings: any) => void): void;
export function on(event: string, listener: Function): any;
export function once(event: string, listener: Function): void;
export function removeListener(event: string, listener: Function): void;
export function removeAllListeners(event?: string): void;
export function setMaxListeners(n: number): void;
export function listeners(event: string): Function[];
export function emit(event: string, ...args: any[]): boolean;
}
declare module "zlib" {
import * as stream from "stream";
export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
export interface ZlibCallback { (error: Error, result: any): void }
export interface Gzip extends stream.Transform { }
export interface Gunzip extends stream.Transform { }
export interface Deflate extends stream.Transform { }
export interface Inflate extends stream.Transform { }
export interface DeflateRaw extends stream.Transform { }
export interface InflateRaw extends stream.Transform { }
export interface Unzip extends stream.Transform { }
export function createGzip(options?: ZlibOptions): Gzip;
export function createGunzip(options?: ZlibOptions): Gunzip;
export function createDeflate(options?: ZlibOptions): Deflate;
export function createInflate(options?: ZlibOptions): Inflate;
export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
export function createInflateRaw(options?: ZlibOptions): InflateRaw;
export function createUnzip(options?: ZlibOptions): Unzip;
export function deflate(buf: Buffer | string, callback?: ZlibCallback): void;
export function deflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function deflateSync(buf: Buffer | string, options?: ZlibOptions): any;
export function deflateRaw(buf: Buffer | string, callback?: ZlibCallback): void;
export function deflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): any;
export function gzip(buf: Buffer | string, callback?: ZlibCallback): void;
export function gzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function gzipSync(buf: Buffer | string, options?: ZlibOptions): any;
export function gunzip(buf: Buffer | string, callback?: ZlibCallback): void;
export function gunzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function gunzipSync(buf: Buffer | string, options?: ZlibOptions): any;
export function inflate(buf: Buffer | string, callback?: ZlibCallback): void;
export function inflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function inflateSync(buf: Buffer | string, options?: ZlibOptions): any;
export function inflateRaw(buf: Buffer | string, callback?: ZlibCallback): void;
export function inflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function inflateRawSync(buf: Buffer | string, options?: ZlibOptions): any;
export function unzip(buf: Buffer | string, callback?: ZlibCallback): void;
export function unzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void;
export function unzipSync(buf: Buffer | string, options?: ZlibOptions): any;
// Constants
export var Z_NO_FLUSH: number;
export var Z_PARTIAL_FLUSH: number;
export var Z_SYNC_FLUSH: number;
export var Z_FULL_FLUSH: number;
export var Z_FINISH: number;
export var Z_BLOCK: number;
export var Z_TREES: number;
export var Z_OK: number;
export var Z_STREAM_END: number;
export var Z_NEED_DICT: number;
export var Z_ERRNO: number;
export var Z_STREAM_ERROR: number;
export var Z_DATA_ERROR: number;
export var Z_MEM_ERROR: number;
export var Z_BUF_ERROR: number;
export var Z_VERSION_ERROR: number;
export var Z_NO_COMPRESSION: number;
export var Z_BEST_SPEED: number;
export var Z_BEST_COMPRESSION: number;
export var Z_DEFAULT_COMPRESSION: number;
export var Z_FILTERED: number;
export var Z_HUFFMAN_ONLY: number;
export var Z_RLE: number;
export var Z_FIXED: number;
export var Z_DEFAULT_STRATEGY: number;
export var Z_BINARY: number;
export var Z_TEXT: number;
export var Z_ASCII: number;
export var Z_UNKNOWN: number;
export var Z_DEFLATED: number;
export var Z_NULL: number;
}
declare module "os" {
export interface CpuInfo {
model: string;
speed: number;
times: {
user: number;
nice: number;
sys: number;
idle: number;
irq: number;
};
}
export interface NetworkInterfaceInfo {
address: string;
netmask: string;
family: string;
mac: string;
internal: boolean;
}
export function tmpdir(): string;
export function homedir(): string;
export function endianness(): "BE" | "LE";
export function hostname(): string;
export function type(): string;
export function platform(): string;
export function arch(): string;
export function release(): string;
export function uptime(): number;
export function loadavg(): number[];
export function totalmem(): number;
export function freemem(): number;
export function cpus(): CpuInfo[];
export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] };
export function userInfo(options?: { encoding: 'buffer' }): { username: Buffer, uid: number, gid: number, shell: Buffer | null, homedir: Buffer }
export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: string | null, homedir: string }
export var EOL: string;
}
declare module "https" {
import * as tls from "tls";
import * as events from "events";
import * as http from "http";
export interface ServerOptions {
pfx?: any;
key?: any;
passphrase?: string;
cert?: any;
ca?: any;
crl?: any;
ciphers?: string;
honorCipherOrder?: boolean;
requestCert?: boolean;
rejectUnauthorized?: boolean;
NPNProtocols?: any;
SNICallback?: (servername: string) => any;
}
export interface RequestOptions extends http.RequestOptions {
pfx?: string | Buffer;
key?: string | Buffer;
passphrase?: string;
cert?: string | Buffer;
ca?: string | Buffer | string[] | Buffer[];
ciphers?: string;
rejectUnauthorized?: boolean;
secureProtocol?: string;
}
export interface AgentOptions extends http.AgentOptions {
/**
* Certificate, Private key and CA certificates to use for SSL. Default `null`.
*/
pfx?: string | Buffer;
/**
* Private key to use for SSL. Default `null`.
*/
key?: string | Buffer | string[] | Buffer[];
/**
* A string of passphrase for the private key or pfx. Default `null`.
*/
passphrase?: string;
/**
* Public x509 certificate to use. Default `null`.
*/
cert?: string | Buffer | string[] | Buffer[];
/**
* A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections.
*/
ca?: string | Buffer | string[] | Buffer[];
/**
* A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format.
*/
ciphers?: string;
/**
* If `true`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default `true`.
*/
rejectUnauthorized?: boolean;
/**
* Servername for SNI (Server Name Indication) TLS extension.
*/
servername?: string;
/**
* The SSL method to use, e.g. `SSLv3_method` to force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constant SSL_METHODS.
*/
secureProtocol?: string;
maxCachedSessions?: number;
}
export class Agent extends http.Agent {
constructor(options?: AgentOptions);
}
export class Server extends tls.Server { }
export function createServer(options: ServerOptions, requestListener?: Function): Server;
export function request(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
export function get(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
export var globalAgent: Agent;
}
declare module "punycode" {
export function decode(string: string): string;
export function encode(string: string): string;
export function toUnicode(domain: string): string;
export function toASCII(domain: string): string;
export var ucs2: ucs2;
interface ucs2 {
decode(string: string): number[];
encode(codePoints: number[]): string;
}
export var version: any;
}
declare module "repl" {
import { EventEmitter } from "events";
import { Interface } from "readline";
export interface ReplOptions {
prompt?: string;
input?: NodeJS.ReadableStream;
output?: NodeJS.WritableStream;
terminal?: boolean;
eval?: Function;
useColors?: boolean;
useGlobal?: boolean;
ignoreUndefined?: boolean;
writer?: Function;
completer?: Function;
replMode?: symbol;
breakEvalOnSigint?: boolean;
}
export function start(options: ReplOptions): REPLServer;
export type REPLCommand = (this: REPLServer, rest: string) => void;
export class REPLServer extends Interface {
inputStream: NodeJS.ReadableStream;
outputStream: NodeJS.WritableStream;
useColors: boolean;
commands: {
[command: string]: REPLCommand;
};
defineCommand(keyword: string, cmd: REPLCommand | { help: string, action: REPLCommand }): void;
displayPrompt(preserveCursor?: boolean): void;
setPrompt(prompt: string): void;
turnOffEditorMode(): void;
}
export class Recoverable extends SyntaxError {
err: Error;
constructor(err: Error);
}
}
declare module "readline" {
import * as events from "events";
import * as stream from "stream";
export interface Key {
sequence?: string;
name?: string;
ctrl?: boolean;
meta?: boolean;
shift?: boolean;
}
export class Interface extends events.EventEmitter {
setPrompt(prompt: string): void;
prompt(preserveCursor?: boolean): void;
question(query: string, callback: (answer: string) => void): void;
pause(): this;
resume(): this;
close(): void;
write(data: string | Buffer, key?: Key): void;
}
export interface Completer {
(line: string): CompleterResult;
(line: string, callback: (err: any, result: CompleterResult) => void): any;
}
export interface CompleterResult {
completions: string[];
line: string;
}
export interface InterfaceOptions {
input: NodeJS.ReadableStream;
output?: NodeJS.WritableStream;
completer?: Completer;
terminal?: boolean;
historySize?: number;
}
export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): Interface;
export function createInterface(options: InterfaceOptions): Interface;
export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
export function clearScreenDown(stream: NodeJS.WritableStream): void;
}
declare module "vm" {
export interface Context { }
export interface ScriptOptions {
filename?: string;
lineOffset?: number;
columnOffset?: number;
displayErrors?: boolean;
timeout?: number;
cachedData?: Buffer;
produceCachedData?: boolean;
}
export interface RunInNewContextOptions {
filename?: string;
lineOffset?: number;
columnOffset?: number;
displayErrors?: boolean;
timeout?: number;
}
export interface RunInContextOptions extends RunInNewContextOptions {
breakOnSigint?: boolean;
}
export class Script {
constructor(code: string, options?: string | ScriptOptions);
runInContext(contextifiedSandbox: Context, options?: RunInContextOptions): any;
runInNewContext(sandbox?: Context, options?: RunInNewContextOptions): any;
runInThisContext(options?: RunInNewContextOptions): any;
}
export function createContext(sandbox?: Context): Context;
export function isContext(sandbox: Context): boolean;
export function runInContext(code: string, contextifiedSandbox: Context, options?: string | RunInNewContextOptions): any;
export function runInDebugContext(code: string): any;
export function runInNewContext(code: string, sandbox?: Context, options?: string | RunInNewContextOptions): any;
export function runInThisContext(code: string, options?: string | RunInNewContextOptions): any;
/**
* @deprecated
*/
export function createScript(code: string, options?: string | ScriptOptions): Script;
}
declare module "child_process" {
import * as events from "events";
import * as stream from "stream";
import * as buffer from "buffer";
import * as net from "net";
export class ChildProcess extends events.EventEmitter implements
events.Listener<'close', (code: number, signal: string) => void>,
events.Listener<'error', (error: Error) => void>,
events.Listener<'exit', ((code: number, signal: string | null) => void) | ((code: number | null, signal: string) => void)>,
events.Listener<'message', (message: any, sendHandle?: net.Socket | net.Server) => void>,
events.Listener<'disconnect', () => void> {
stdin: stream.Writable;
stdout: stream.Readable;
stderr: stream.Readable;
stdio: [stream.Writable, stream.Readable, stream.Readable];
pid: number;
kill(signal?: string): void;
send(message: any, sendHandle?: any): boolean;
connected: boolean;
disconnect(): void;
unref(): void;
}
export interface SpawnOptions {
cwd?: string;
env?: any;
stdio?: any;
detached?: boolean;
uid?: number;
gid?: number;
shell?: boolean | string;
}
export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
export interface ExecOptions {
cwd?: string;
env?: any;
shell?: string;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
uid?: number;
gid?: number;
encoding?: buffer.Encoding | 'buffer';
}
export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
export function exec(command: string, options: ExecOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
export interface ExecFileOptions {
cwd?: string;
env?: any;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
uid?: number;
gid?: number;
encoding?: buffer.Encoding | 'buffer';
}
export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess;
export function execFile(file: string, options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer