Merge branch 'types-2.0' into duplicate_react_router

This commit is contained in:
Mohamed Hegazy
2016-08-17 14:06:01 -07:00
18 changed files with 1000 additions and 940 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/// <reference path="./browser-resolve.d.ts" />
/// <reference types="browser-resolve" />
import * as browserResolve from 'browser-resolve';
-61
View File
@@ -1,61 +0,0 @@
// Type definitions for browser-resolve
// Project: https://github.com/defunctzombie/node-browser-resolve
// Definitions by: Mario Nebl <https://github.com/marionebl/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../resolve/resolve.d.ts" />
declare module 'browser-resolve' {
import * as resolve from 'resolve';
/**
* Callback invoked when resolving asynchronously
*
* @param error
* @param resolved Absolute path to resolved identifier
*/
type resolveCallback = (err?: Error, resolved?: string) => void;
/**
* Resolve a module path and call cb(err, path [, pkg])
*
* @param id Identifier to resolve
* @param callback
*/
function browserResolve(id: string, cb: resolveCallback): void;
/**
* Resolve a module path and call cb(err, path [, pkg])
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
* @param callback
*/
function browserResolve(id: string, opts: browserResolve.AsyncOpts, cb: resolveCallback): void;
/**
* Returns a module path
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
*/
function browserResolveSync(id: string, opts?: browserResolve.SyncOpts): string;
namespace browserResolve {
interface Opts {
// the 'browser' property to use from package.json (defaults to 'browser')
browser?: string;
// the calling filename where the require() call originated (in the source)
filename?: string;
// modules object with id to path mappings to consult before doing manual resolution (use to provide core modules)
modules?: any;
}
export interface AsyncOpts extends resolve.AsyncOpts, Opts {}
export interface SyncOpts extends resolve.SyncOpts, Opts {}
export var sync: typeof browserResolveSync;
}
export = browserResolve
}
+59
View File
@@ -0,0 +1,59 @@
// Type definitions for browser-resolve
// Project: https://github.com/defunctzombie/node-browser-resolve
// Definitions by: Mario Nebl <https://github.com/marionebl/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="resolve" />
import * as resolve from 'resolve';
/**
* Callback invoked when resolving asynchronously
*
* @param error
* @param resolved Absolute path to resolved identifier
*/
type resolveCallback = (err?: Error, resolved?: string) => void;
/**
* Resolve a module path and call cb(err, path [, pkg])
*
* @param id Identifier to resolve
* @param callback
*/
declare function browserResolve(id: string, cb: resolveCallback): void;
/**
* Resolve a module path and call cb(err, path [, pkg])
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
* @param callback
*/
declare function browserResolve(id: string, opts: browserResolve.AsyncOpts, cb: resolveCallback): void;
/**
* Returns a module path
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
*/
declare function browserResolveSync(id: string, opts?: browserResolve.SyncOpts): string;
declare namespace browserResolve {
interface Opts {
// the 'browser' property to use from package.json (defaults to 'browser')
browser?: string;
// the calling filename where the require() call originated (in the source)
filename?: string;
// modules object with id to path mappings to consult before doing manual resolution (use to provide core modules)
modules?: any;
}
export interface AsyncOpts extends resolve.AsyncOpts, Opts { }
export interface SyncOpts extends resolve.SyncOpts, Opts { }
export var sync: typeof browserResolveSync;
}
export = browserResolve;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"browser-resolve-tests.ts"
]
}
-761
View File
@@ -1,761 +0,0 @@
// Type definitions for nodejs-driver v0.8.2
// Project: https://github.com/datastax/nodejs-driver
// Definitions by: Marc Fisher <http://github.com/Svjard>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../long/long.d.ts" />
declare module "cassandra-driver" {
type Callback = Function;
type ResultCallback = (err: Error, result: types.ResultSet) => void;
import * as events from "events";
import * as stream from "stream";
import _Long = require("long");
namespace policies {
namespace addressResolution {
var EC2MultiRegionTranslator: EC2MultiRegionTranslatorStatic;
interface AddressTranslator {
translate(address: string, port: number, callback: Callback): void;
}
interface EC2MultiRegionTranslatorStatic {
new(): EC2MultiRegionTranslator;
}
interface EC2MultiRegionTranslator extends AddressTranslator {
logError(address: string, err: Error): void;
}
}
namespace loadBalancing {
var DCAwareRoundRobinPolicy: DCAwareRoundRobinPolicyStatic;
var RoundRobinPolicy: RoundRobinPolicyStatic;
var TokenAwarePolicy: TokenAwarePolicyStatic;
var WhiteListPolicy: WhiteListPolicyStatic;
interface LoadBalancingPolicy {
init(client: Client, hosts: HostMap, callback: Callback): void;
getDistance(host: Host): types.distance;
newQueryPlan(keyspace: string, queryOptions: any, callback: Callback): void;
}
interface DCAwareRoundRobinPolicyStatic {
new(localDc?: string, usedHostsPerRemoteDc?: number): DCAwareRoundRobinPolicy;
}
interface DCAwareRoundRobinPolicy extends LoadBalancingPolicy {
localHostsArray: Array<Host>;
remoteHostsArray: Array<Host>;
}
interface RoundRobinPolicyStatic {
new(): RoundRobinPolicy;
}
interface RoundRobinPolicy extends LoadBalancingPolicy {}
interface TokenAwarePolicyStatic {
new(childPolicy: LoadBalancingPolicy): TokenAwarePolicy;
}
interface TokenAwarePolicy extends LoadBalancingPolicy {}
interface WhiteListPolicyStatic {
new(childPolicy: LoadBalancingPolicy, whiteList: Array<string>): WhiteListPolicy;
}
interface WhiteListPolicy extends LoadBalancingPolicy {}
}
namespace reconnection {
var ConstantReconnectionPolicy: ConstantReconnectionPolicyStatic;
var ExponentialReconnectionPolicy: ExponentialReconnectionPolicyStatic;
interface ReconnectionPolicy {
newSchedule(): {next: Function};
}
interface ConstantReconnectionPolicyStatic {
new(delay: number): ConstantReconnectionPolicy;
}
interface ConstantReconnectionPolicy extends ReconnectionPolicy {}
interface ExponentialReconnectionPolicyStatic {
new(baseDelay: number, maxDelay: number, startWithNoDelay: boolean): ExponentialReconnectionPolicy;
}
interface ExponentialReconnectionPolicy extends ReconnectionPolicy {}
}
namespace retry {
var RetryPolicy: RetryPolicyStatic;
interface DecisionInfo {
decision: number;
consistency: number;
}
interface RequestInfo {
request: any,
nbRetry: number
}
enum retryDecision {
rethrow = 0,
retry,
ignore
}
interface RetryPolicyStatic {
new (): RetryPolicy;
retryDecision: any;
}
interface RetryPolicy {
onReadTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, isDataPresent: boolean): DecisionInfo;
onUnavailable(requestInfo: RequestInfo, consistency: types.consistencies, required: number, alive: number): DecisionInfo;
onWriteTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, writeType: string): DecisionInfo;
rethrowResult(): { decision: retryDecision };
retryResult(): { decision: retryDecision, consistency: types.consistencies, useCurrentHost: boolean };
}
}
}
namespace types {
var BigDecimal: BigDecimalStatic;
var InetAddress: InetAddressStatic;
var Integer: IntegerStatic;
var LocalDate: LocalDateStatic;
var LocalTime: LocalTimeStatic;
var Long: _Long;
var ResultSet: ResultSetStatic;
var ResultStream: ResultStreamStatic;
var Row: RowStatic;
var TimeUuid: TimeUuidStatic;
var Tuple: TupleStatic;
var Uuid: UuidStatic;
enum consistencies {
any = 0,
one,
two,
three,
quorum,
all,
localQuorm,
eachQuorum,
serial,
localSerial,
localOne
}
enum dataTypes {
custom = 0,
ascii,
bigint,
blob,
boolean,
counter,
decimal,
double,
float,
int,
text,
timestamp,
uuid,
varchar,
varint,
timeuuid,
inet,
date,
time,
smallint,
tinyint,
list,
map,
set,
udt,
tuple
}
enum distance {
local = 0,
remote,
ignored
}
interface responseErrorCodes { [key:string]:number; }
interface unset { unset: boolean; }
function generateTimestamp(date?: Date, microseconds?: number): _Long;
function timeuuid(options?: {msecs: number | Date, node: Buffer, clockseq: number, nsecs: number}, buffer?: Buffer, offset?: number): string;
interface BigDecimalStatic {
new (unscaledValue: number, scale: number): BigDecimal;
fromBuffer(buf: Buffer): BigDecimal;
toBuffer(value: BigDecimal): Buffer;
fromString(value: string): BigDecimal;
fromNumber(value: number): BigDecimal;
}
interface BigDecimal {
equals(other: BigDecimal): boolean;
inspect(): string;
notEquals(other: BigDecimal): boolean;
compare(other: BigDecimal): number;
subtract(other: BigDecimal): BigDecimal;
add(other: BigDecimal): BigDecimal;
greaterThan(other: BigDecimal): boolean;
isNegative(): boolean;
isZero(): boolean;
toString(): string;
toNumber(): number;
toJSON(): string;
}
interface InetAddressStatic {
new(buffer: Buffer): InetAddress;
fromString(value: string): InetAddress;
}
interface InetAddress {
equals(other: InetAddress): boolean;
getBuffer(): Buffer;
inspect(): string;
toString(): string;
toJSON(): string;
length: number;
version: number;
}
interface IntegerStatic {
new(bits: Array<number>, sign: number): Integer;
fromInt(value: number): Integer;
fromNumber(value: number): Integer;
fromBits(bits: Array<number>): Integer;
fromString(str: string, opt_radix?: number): Integer;
fromBuffer(bits: Buffer): Integer;
toBuffer(value: Integer): Buffer;
ZERO: Integer;
ONE: Integer;
}
interface Integer {
toInt(): number;
toNumber(): number;
toString(opt_radix?: number): string;
getBits(index: number): number;
getBitsUnsigned(index: number): number;
getSign(): number;
isZero(): boolean;
isNegative(): boolean;
isOdd(): boolean;
equals(other: Integer): boolean;
notEquals(other: Integer): boolean;
greaterThan(other: Integer): boolean;
greaterThanOrEqual(other: Integer): boolean;
lessThan(other: Integer): boolean;
lessThanOrEqual(other: Integer): boolean;
compare(other: Integer): number;
shorten(numBits: number): Integer;
negate(): Integer;
add(other: Integer): Integer;
subtract(other: Integer): Integer;
multiply(other: Integer): Integer;
divide(other: Integer): Integer;
modulo(other: Integer): Integer;
not(): Integer;
and(other: Integer): Integer;
or(other: Integer): Integer;
xor(other: Integer): Integer;
shiftLeft(numBits: number): Integer;
shiftRight(numBits: number): Integer;
inspect(): string;
abs(): Integer;
toJSON(): string;
}
interface LocalDateStatic {
new(year: number, month: number, day: number): LocalDate;
now(): LocalDate;
utcNow(): LocalDate;
fromDate(date: Date): LocalDate;
fromString(value: string): LocalDate;
fromBuffer(buffer: Buffer): LocalDate;
}
interface LocalDate {
_value: number;
year: number;
month: number;
day: number;
equals(other: LocalDate): boolean;
inspect(): string;
toBuffer(): Buffer;
toString(): string;
toJSON(): string;
}
interface LocalTimeStatic {
new (totalNanoseconds: _Long): LocalTime;
fromString(value: string): LocalTime;
now(nanoseconds?: number): LocalTime;
fromDate(date: Date, nanoseconds: number): LocalTime;
fromMilliseconds(milliseconds: number, nanoseconds?: number): LocalTime;
fromBuffer(value: Buffer): LocalTime;
}
interface LocalTime {
hour: number;
minute: number;
second: number;
nanosecond: number;
compare(other: LocalTime): boolean;
equals(other: LocalTime): boolean;
getTotalNanoseconds(): _Long;
inspect(): string;
toBuffer(): Buffer;
toString(): string;
toJSON(): string;
}
interface ResultSetStatic {
new(response: any, host: string, triedHost: { [key:string]: any }, consistency: consistencies): ResultSet;
}
interface ResultSet {
info: {
queriedHost: Host,
triedHosts: { [key:string]:string; },
achievedConsistency: consistencies,
traceId: Uuid,
warnings: Array<string>,
customPayload: any
};
rows: Array<Row>;
rowLength: number;
columns: Array<{ [key:string]:string; }>;
pageState: string;
nextPage: any; // function
first(): Row;
getPageState(): string;
getColumns(): Array<{ [key:string]:string; }>;
}
interface ResultStreamStatic {
new (opt: any): ResultSet;
}
interface ResultStream extends stream.Readable {
buffer: Buffer;
paused: boolean;
_read(): void;
_valve(readNext: Function): void;
add(chunk: Buffer): void;
}
interface RowStatic {
new(columns: Array<{ [key:string]:string; }>): Row;
}
interface Row {
get(columnName: string|number): { [key:string]:any; };
values(): Array<{ [key:string]:any; }>;
keys(): Array<string>;
forEach(callback: Callback): void;
}
interface TimeUuidStatic {
new (value?: Date, ticks?: number, nodeId?: string|Buffer, clockId?: string|Buffer): TimeUuid;
fromDate(date: Date, ticks?: number, nodeId?: string|Buffer, clockId?: string|Buffer): TimeUuid;
fromString(value: string): TimeUuid;
min(date: Date, ticks?: number): TimeUuid;
max(date: Date, ticks?: number): TimeUuid;
now(nodeId?: string|Buffer, clockId?: string|Buffer): TimeUuid;
}
interface TimeUuid extends Uuid {
getDatePrecision(): { date: Date, ticks: number };
getDate(): Date;
getNodeId(): Buffer;
getNodeIdString(): string;
}
interface TupleStatic {
new (...arguments: Array<any>): Tuple;
fromArray(elements: Array<any>): Tuple;
}
interface Tuple {
elements: Array<any>;
length: number;
get(index: number): any;
toString(): string;
toJSON(): string;
values(): Array<any>;
}
interface UuidStatic {
new (buffer: Buffer): Uuid;
fromString(value: string): Uuid;
random(): Uuid;
}
interface Uuid {
buffer: Buffer;
getBuffer(): Buffer;
equals(other: types.Uuid): boolean;
toString(): string;
inspect(): string;
toJSON(): string;
}
}
var Client: ClientStatic;
var Host: HostStatic;
var HostMap: HostMapStatic;
var Encoder: EncoderStatic;
interface ClientOptions {
contactPoints: Array<string>,
keyspace: string,
policies?: {
addressResolution?: policies.addressResolution.AddressTranslator,
loadBalancing?: policies.loadBalancing.LoadBalancingPolicy,
reconnection?: policies.reconnection.ReconnectionPolicy,
retry?: policies.retry.RetryPolicy
},
queryOptions?: QueryOptions,
pooling?: {
heartBeatInterval: number,
coreConnectionsPerHost: { [key:number]:number; },
warmup: boolean;
},
protocolOptions?: {
port: number,
maxSchemaAgreementWaitSeconds: number,
maxVersion: number
},
socketOptions?: {
connectTimeout: number,
defunctReadTimeoutThreshold: number,
keepAlive: boolean,
keepAliveDelay: number,
readTimeout: number,
tcpNoDelay: boolean,
coalescingThreshold: number
},
authProvider?: auth.AuthProvider,
sslOptions?: any,
encoding?: {
map: Function,
set: Function,
copyBuffer: boolean,
useUndefinedAsUnset: boolean
}
}
interface QueryOptions {
autoPage?: boolean;
captureStackTrace?: boolean;
consistency?: number;
customPayload?: any;
fetchSize?: number;
hints?: Array<string> | Array<Array<string>>;
logged?: boolean;
pageState?: Buffer|string;
prepare?: boolean;
readTimeout?: number;
retry?: policies.retry.RetryPolicy;
retryOnTimeout?: boolean;
routingIndexes?: Array<number>;
routingKey?: Buffer | Array<Buffer>;
routingNames?: Array<string>;
serialConsistency?: number;
timestamp?: number | _Long;
traceQuery?: boolean;
}
interface ClientStatic {
new(options?: ClientOptions): Client;
}
interface Client extends events.EventEmitter {
hosts: HostMap;
keyspace: string;
metadata: metadata.Metadata;
batch(queries: Array<string>|Array<{query: string, params?: any}>, options: QueryOptions, callback: ResultCallback): void;
connect(callback: Callback): void;
eachRow(query: string, params?: any, options?: QueryOptions, rowCallback?: Callback, callback?: Callback): void;
execute(query: string, params?: any, options?: QueryOptions, callback?: ResultCallback): void;
getReplicas(keyspace: string, token: Buffer): Array<any>; // TODO: Should this be a more explicit return?
shutdown(callback?: Callback): void;
stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream;
}
interface HostStatic {
new(address: string, protocolVersion: number, options: ClientOptions): Host;
}
interface Host extends events.EventEmitter {
address: string;
cassandraVersion: string;
dataCenter: string;
rack: string;
tokens: Array<string>;
canBeConsideredAsUp(): boolean;
getCassandraVersion(): Array<number>;
isUp(): boolean;
}
interface HostMapStatic {
new (): HostMap;
}
interface HostMap extends events.EventEmitter {
length: number;
forEach(callback: Callback): void;
get(key: string): Host;
keys(): Array<string>;
remove(key: string): void;
removeMultiple(keys: Array<string>): void;
set(key: string, value: Host): void;
values(): Array<Host>;
}
interface EncoderStatic {
new(protocolVersion: number, options: ClientOptions) : Encoder;
}
interface Encoder {
decode(buffer: Buffer, type: {code: number, info?: any}): void;
encode(value: any, typeInfo?: string|number|{code: number, info?: any}): Buffer;
}
namespace auth {
var Authenticator: AuthenticatorStatic;
var PlainTextAuthProvider: PlainTextAuthProviderStatic;
interface AuthenticatorStatic {
new (): Authenticator;
}
interface Authenticator {
evaluateChallenge(challenge: Buffer, callback: Callback): void;
initialResponse(callback: Callback): void;
onAuthenticationSuccess(token?: Buffer): void;
}
interface AuthProvider {
newAuthenticator(endpoint: string, name: string): void;
}
interface PlainTextAuthProviderStatic {
new (username: string, password: string): PlainTextAuthProvider;
}
interface PlainTextAuthProvider extends AuthProvider {
newAuthenticator(endpoint: string, name: string): void;
}
}
namespace errors {
abstract class DriverError {
constructor(message: string, constructor?: any);
}
class ArgumentError extends DriverError {
constructor(message: string);
}
class AuthenticationError extends DriverError {
constructor(message: string);
}
class DriverInternalError extends DriverError {
constructor(message: string);
}
class NoHostAvailableError extends DriverError {
constructor(innerErrors: any, message?: string);
}
class NotSupportedError extends DriverError {
constructor(message: string);
}
class OperationTimedOutError extends DriverError {}
class ResponseError extends DriverError {
constructor(code: number, message: string);
}
}
namespace metadata {
var Aggregate: AggregateStatic;
var Index: IndexStatic;
var MaterializedView: MaterializedViewStatic;
var Metadata: MetadataStatic;
var SchemaFunction: SchemaFunctionStatic;
var TableMetadata: TableMetadataStatic;
type caching = "all" | "keys_only" | "rows_only" | "none";
interface AggregateStatic {
new (): Aggregate;
}
interface Aggregate {
argumentTypes: Array<{ code: number, info: any}>;
finalFunction: string;
initCondition: string;
keyspaceName: string,
returnType: string;
signature: Array<string>;
stateFunction: string;
stateType: string;
}
interface DataTypeInfo {
code: number,
info: string | DataTypeInfo | Array<DataTypeInfo>,
options: {
frozen: boolean,
reversed: boolean
}
}
interface ColumnInfo {
name: string,
type: DataTypeInfo
}
interface DataCollection {
bloomFilterFalsePositiveChance: number;
caching: caching;
clusterKeys: Array<{ c: ColumnInfo, index: number, order: string }>;
clusteringOrder: Array<string>;
columns: Array<ColumnInfo>;
columnsByName: { [key: string]: ColumnInfo };
comment: string;
compactionClass: string;
compactionOptions: any;
compression: any;
crcCheckChange?: number;
defaultTtl: number;
extensions: any;
gcGraceSeconds: number;
localReadRepairChance: number;
maxIndexInterval?: number;
minIndexInterval?: number;
name: string;
partitionKeys: Array<{ c: ColumnInfo, index: number }>
populateCacheOnFlush: boolean;
readRepairChance: number;
speculateRetry: string;
}
enum IndexType {
custom = 0,
keys,
composites
}
interface IndexStatic {
new (name: string, target: string, kind: IndexType, options: Object): Index;
fromRows(indexRows: Array<types.Row>): Array<Index>;
fromColumnRows(columnRows: Array<types.Row>, columnsByName: { [key:string]: ColumnInfo }): Array<Index>;
}
interface Index {
kind: IndexType;
name: string;
options: Object;
target: string;
isCompositesKind(): boolean;
isCustomKind(): boolean;
isKeysKind(): boolean;
}
interface MaterializedViewStatic {
new (name: string): MaterializedView;
}
interface MaterializedView extends DataCollection {}
interface MetadataStatic {
new (options: ClientOptions, controlConnection: any): Metadata;
}
interface Metadata {
clearPrepared(): void;
getAggregate(keyspaceName: string, name: string, signature: Array<string> | Array<{ code: number, info: any }>, callback: Callback): void;
getAggregates(keyspaceName: string, name: string, callback: Callback): void;
getFunction(keyspaceName: string, name: string, signature: Array<string> | Array<{ code: number, info: any }>, callback: Callback): void;
getFunctions(keyspaceName: string, name: string, callback: Callback): void;
getMaterializedView(keyspaceName: string, name: string, callback: Callback): void;
getReplicas(keyspaceName: string, tokenBuffer: Buffer): Array<any>;
getTable(keyspaceName: string, name: string, callback: Callback): void;
getTrace(traceId: types.Uuid, callback: Callback): void;
getUdt(keyspaceName: string, name: string, callback: Callback): void;
refreshKeyspace(name: string, callback?: Callback): void;
refreshKeyspaces(callback?: Callback): void;
}
interface SchemaFunctionStatic {
new (): SchemaFunction;
}
interface SchemaFunction {
argumentNames: Array<string>;
argumentTypes: Array<{ code: number, info: any}>;
body: string;
calledOnNullInput: boolean;
keyspaceName: string,
language: string;
name: string;
returnType: string;
signature: Array<string>;
}
interface TableMetadataStatic {
new (name: string): TableMetadata;
}
interface TableMetadata extends DataCollection {
indexes: Array<Index>;
indexInterval?: number;
isCompact: boolean;
memtableFlushPeriod: number;
replicateOnWrite: boolean;
}
}
}
+3 -3
View File
@@ -1,4 +1,4 @@
/// <reference path="cassandra-driver.d.ts" />
/// <reference types="cassandra-driver" />
import * as cassandra from 'cassandra-driver';
import * as util from 'util';
@@ -6,6 +6,6 @@ import * as util from 'util';
var client = new cassandra.Client({ contactPoints: ['h1', 'h2'], keyspace: 'ks1'});
var query = 'SELECT email, last_name FROM user_profiles WHERE key=?';
client.execute(query, ['guy'], function(err, result) {
console.log('got user profile with email ' + result.rows[0].email);
client.execute(query, ['guy'], {}, function(err, result) {
console.log('got user profile with email ' + result.rows[0].get("email"));
});
+759
View File
@@ -0,0 +1,759 @@
// Type definitions for nodejs-driver v0.8.2
// Project: https://github.com/datastax/nodejs-driver
// Definitions by: Marc Fisher <http://github.com/Svjard>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/// <reference types="long" />
export type Callback = Function;
export type ResultCallback = (err: Error, result: types.ResultSet) => void;
import * as events from "events";
import * as stream from "stream";
import _Long = require("long");
export namespace policies {
namespace addressResolution {
var EC2MultiRegionTranslator: EC2MultiRegionTranslatorStatic;
interface AddressTranslator {
translate(address: string, port: number, callback: Callback): void;
}
interface EC2MultiRegionTranslatorStatic {
new (): EC2MultiRegionTranslator;
}
interface EC2MultiRegionTranslator extends AddressTranslator {
logError(address: string, err: Error): void;
}
}
namespace loadBalancing {
var DCAwareRoundRobinPolicy: DCAwareRoundRobinPolicyStatic;
var RoundRobinPolicy: RoundRobinPolicyStatic;
var TokenAwarePolicy: TokenAwarePolicyStatic;
var WhiteListPolicy: WhiteListPolicyStatic;
interface LoadBalancingPolicy {
init(client: Client, hosts: HostMap, callback: Callback): void;
getDistance(host: Host): types.distance;
newQueryPlan(keyspace: string, queryOptions: any, callback: Callback): void;
}
interface DCAwareRoundRobinPolicyStatic {
new (localDc?: string, usedHostsPerRemoteDc?: number): DCAwareRoundRobinPolicy;
}
interface DCAwareRoundRobinPolicy extends LoadBalancingPolicy {
localHostsArray: Array<Host>;
remoteHostsArray: Array<Host>;
}
interface RoundRobinPolicyStatic {
new (): RoundRobinPolicy;
}
interface RoundRobinPolicy extends LoadBalancingPolicy { }
interface TokenAwarePolicyStatic {
new (childPolicy: LoadBalancingPolicy): TokenAwarePolicy;
}
interface TokenAwarePolicy extends LoadBalancingPolicy { }
interface WhiteListPolicyStatic {
new (childPolicy: LoadBalancingPolicy, whiteList: Array<string>): WhiteListPolicy;
}
interface WhiteListPolicy extends LoadBalancingPolicy { }
}
namespace reconnection {
var ConstantReconnectionPolicy: ConstantReconnectionPolicyStatic;
var ExponentialReconnectionPolicy: ExponentialReconnectionPolicyStatic;
interface ReconnectionPolicy {
newSchedule(): { next: Function };
}
interface ConstantReconnectionPolicyStatic {
new (delay: number): ConstantReconnectionPolicy;
}
interface ConstantReconnectionPolicy extends ReconnectionPolicy { }
interface ExponentialReconnectionPolicyStatic {
new (baseDelay: number, maxDelay: number, startWithNoDelay: boolean): ExponentialReconnectionPolicy;
}
interface ExponentialReconnectionPolicy extends ReconnectionPolicy { }
}
namespace retry {
var RetryPolicy: RetryPolicyStatic;
interface DecisionInfo {
decision: number;
consistency: number;
}
interface RequestInfo {
request: any,
nbRetry: number
}
enum retryDecision {
rethrow = 0,
retry,
ignore
}
interface RetryPolicyStatic {
new (): RetryPolicy;
retryDecision: any;
}
interface RetryPolicy {
onReadTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, isDataPresent: boolean): DecisionInfo;
onUnavailable(requestInfo: RequestInfo, consistency: types.consistencies, required: number, alive: number): DecisionInfo;
onWriteTimeout(requestInfo: RequestInfo, consistency: types.consistencies, received: number, blockFor: number, writeType: string): DecisionInfo;
rethrowResult(): { decision: retryDecision };
retryResult(): { decision: retryDecision, consistency: types.consistencies, useCurrentHost: boolean };
}
}
}
export namespace types {
var BigDecimal: BigDecimalStatic;
var InetAddress: InetAddressStatic;
var Integer: IntegerStatic;
var LocalDate: LocalDateStatic;
var LocalTime: LocalTimeStatic;
var Long: _Long;
var ResultSet: ResultSetStatic;
var ResultStream: ResultStreamStatic;
var Row: RowStatic;
var TimeUuid: TimeUuidStatic;
var Tuple: TupleStatic;
var Uuid: UuidStatic;
enum consistencies {
any = 0,
one,
two,
three,
quorum,
all,
localQuorm,
eachQuorum,
serial,
localSerial,
localOne
}
enum dataTypes {
custom = 0,
ascii,
bigint,
blob,
boolean,
counter,
decimal,
double,
float,
int,
text,
timestamp,
uuid,
varchar,
varint,
timeuuid,
inet,
date,
time,
smallint,
tinyint,
list,
map,
set,
udt,
tuple
}
enum distance {
local = 0,
remote,
ignored
}
interface responseErrorCodes { [key: string]: number; }
interface unset { unset: boolean; }
function generateTimestamp(date?: Date, microseconds?: number): _Long;
function timeuuid(options?: { msecs: number | Date, node: Buffer, clockseq: number, nsecs: number }, buffer?: Buffer, offset?: number): string;
interface BigDecimalStatic {
new (unscaledValue: number, scale: number): BigDecimal;
fromBuffer(buf: Buffer): BigDecimal;
toBuffer(value: BigDecimal): Buffer;
fromString(value: string): BigDecimal;
fromNumber(value: number): BigDecimal;
}
interface BigDecimal {
equals(other: BigDecimal): boolean;
inspect(): string;
notEquals(other: BigDecimal): boolean;
compare(other: BigDecimal): number;
subtract(other: BigDecimal): BigDecimal;
add(other: BigDecimal): BigDecimal;
greaterThan(other: BigDecimal): boolean;
isNegative(): boolean;
isZero(): boolean;
toString(): string;
toNumber(): number;
toJSON(): string;
}
interface InetAddressStatic {
new (buffer: Buffer): InetAddress;
fromString(value: string): InetAddress;
}
interface InetAddress {
equals(other: InetAddress): boolean;
getBuffer(): Buffer;
inspect(): string;
toString(): string;
toJSON(): string;
length: number;
version: number;
}
interface IntegerStatic {
new (bits: Array<number>, sign: number): Integer;
fromInt(value: number): Integer;
fromNumber(value: number): Integer;
fromBits(bits: Array<number>): Integer;
fromString(str: string, opt_radix?: number): Integer;
fromBuffer(bits: Buffer): Integer;
toBuffer(value: Integer): Buffer;
ZERO: Integer;
ONE: Integer;
}
interface Integer {
toInt(): number;
toNumber(): number;
toString(opt_radix?: number): string;
getBits(index: number): number;
getBitsUnsigned(index: number): number;
getSign(): number;
isZero(): boolean;
isNegative(): boolean;
isOdd(): boolean;
equals(other: Integer): boolean;
notEquals(other: Integer): boolean;
greaterThan(other: Integer): boolean;
greaterThanOrEqual(other: Integer): boolean;
lessThan(other: Integer): boolean;
lessThanOrEqual(other: Integer): boolean;
compare(other: Integer): number;
shorten(numBits: number): Integer;
negate(): Integer;
add(other: Integer): Integer;
subtract(other: Integer): Integer;
multiply(other: Integer): Integer;
divide(other: Integer): Integer;
modulo(other: Integer): Integer;
not(): Integer;
and(other: Integer): Integer;
or(other: Integer): Integer;
xor(other: Integer): Integer;
shiftLeft(numBits: number): Integer;
shiftRight(numBits: number): Integer;
inspect(): string;
abs(): Integer;
toJSON(): string;
}
interface LocalDateStatic {
new (year: number, month: number, day: number): LocalDate;
now(): LocalDate;
utcNow(): LocalDate;
fromDate(date: Date): LocalDate;
fromString(value: string): LocalDate;
fromBuffer(buffer: Buffer): LocalDate;
}
interface LocalDate {
_value: number;
year: number;
month: number;
day: number;
equals(other: LocalDate): boolean;
inspect(): string;
toBuffer(): Buffer;
toString(): string;
toJSON(): string;
}
interface LocalTimeStatic {
new (totalNanoseconds: _Long): LocalTime;
fromString(value: string): LocalTime;
now(nanoseconds?: number): LocalTime;
fromDate(date: Date, nanoseconds: number): LocalTime;
fromMilliseconds(milliseconds: number, nanoseconds?: number): LocalTime;
fromBuffer(value: Buffer): LocalTime;
}
interface LocalTime {
hour: number;
minute: number;
second: number;
nanosecond: number;
compare(other: LocalTime): boolean;
equals(other: LocalTime): boolean;
getTotalNanoseconds(): _Long;
inspect(): string;
toBuffer(): Buffer;
toString(): string;
toJSON(): string;
}
interface ResultSetStatic {
new (response: any, host: string, triedHost: { [key: string]: any }, consistency: consistencies): ResultSet;
}
interface ResultSet {
info: {
queriedHost: Host,
triedHosts: { [key: string]: string; },
achievedConsistency: consistencies,
traceId: Uuid,
warnings: Array<string>,
customPayload: any
};
rows: Array<Row>;
rowLength: number;
columns: Array<{ [key: string]: string; }>;
pageState: string;
nextPage: any; // function
first(): Row;
getPageState(): string;
getColumns(): Array<{ [key: string]: string; }>;
}
interface ResultStreamStatic {
new (opt: any): ResultSet;
}
interface ResultStream extends stream.Readable {
buffer: Buffer;
paused: boolean;
_read(): void;
_valve(readNext: Function): void;
add(chunk: Buffer): void;
}
interface RowStatic {
new (columns: Array<{ [key: string]: string; }>): Row;
}
interface Row {
get(columnName: string | number): { [key: string]: any; };
values(): Array<{ [key: string]: any; }>;
keys(): Array<string>;
forEach(callback: Callback): void;
}
interface TimeUuidStatic {
new (value?: Date, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
fromDate(date: Date, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
fromString(value: string): TimeUuid;
min(date: Date, ticks?: number): TimeUuid;
max(date: Date, ticks?: number): TimeUuid;
now(nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
}
interface TimeUuid extends Uuid {
getDatePrecision(): { date: Date, ticks: number };
getDate(): Date;
getNodeId(): Buffer;
getNodeIdString(): string;
}
interface TupleStatic {
new (...args: Array<any>): Tuple;
fromArray(elements: Array<any>): Tuple;
}
interface Tuple {
elements: Array<any>;
length: number;
get(index: number): any;
toString(): string;
toJSON(): string;
values(): Array<any>;
}
interface UuidStatic {
new (buffer: Buffer): Uuid;
fromString(value: string): Uuid;
random(): Uuid;
}
interface Uuid {
buffer: Buffer;
getBuffer(): Buffer;
equals(other: types.Uuid): boolean;
toString(): string;
inspect(): string;
toJSON(): string;
}
}
export var Client: ClientStatic;
export var Host: HostStatic;
export var HostMap: HostMapStatic;
export var Encoder: EncoderStatic;
export interface ClientOptions {
contactPoints: Array<string>,
keyspace: string,
policies?: {
addressResolution?: policies.addressResolution.AddressTranslator,
loadBalancing?: policies.loadBalancing.LoadBalancingPolicy,
reconnection?: policies.reconnection.ReconnectionPolicy,
retry?: policies.retry.RetryPolicy
},
queryOptions?: QueryOptions,
pooling?: {
heartBeatInterval: number,
coreConnectionsPerHost: { [key: number]: number; },
warmup: boolean;
},
protocolOptions?: {
port: number,
maxSchemaAgreementWaitSeconds: number,
maxVersion: number
},
socketOptions?: {
connectTimeout: number,
defunctReadTimeoutThreshold: number,
keepAlive: boolean,
keepAliveDelay: number,
readTimeout: number,
tcpNoDelay: boolean,
coalescingThreshold: number
},
authProvider?: auth.AuthProvider,
sslOptions?: any,
encoding?: {
map: Function,
set: Function,
copyBuffer: boolean,
useUndefinedAsUnset: boolean
}
}
export interface QueryOptions {
autoPage?: boolean;
captureStackTrace?: boolean;
consistency?: number;
customPayload?: any;
fetchSize?: number;
hints?: Array<string> | Array<Array<string>>;
logged?: boolean;
pageState?: Buffer | string;
prepare?: boolean;
readTimeout?: number;
retry?: policies.retry.RetryPolicy;
retryOnTimeout?: boolean;
routingIndexes?: Array<number>;
routingKey?: Buffer | Array<Buffer>;
routingNames?: Array<string>;
serialConsistency?: number;
timestamp?: number | _Long;
traceQuery?: boolean;
}
export interface ClientStatic {
new (options?: ClientOptions): Client;
}
export interface Client extends events.EventEmitter {
hosts: HostMap;
keyspace: string;
metadata: metadata.Metadata;
batch(queries: Array<string> | Array<{ query: string, params?: any }>, options: QueryOptions, callback: ResultCallback): void;
connect(callback: Callback): void;
eachRow(query: string, params?: any, options?: QueryOptions, rowCallback?: Callback, callback?: Callback): void;
execute(query: string, params?: any, options?: QueryOptions, callback?: ResultCallback): void;
getReplicas(keyspace: string, token: Buffer): Array<any>; // TODO: Should this be a more explicit return?
shutdown(callback?: Callback): void;
stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream;
}
export interface HostStatic {
new (address: string, protocolVersion: number, options: ClientOptions): Host;
}
export interface Host extends events.EventEmitter {
address: string;
cassandraVersion: string;
dataCenter: string;
rack: string;
tokens: Array<string>;
canBeConsideredAsUp(): boolean;
getCassandraVersion(): Array<number>;
isUp(): boolean;
}
export interface HostMapStatic {
new (): HostMap;
}
export interface HostMap extends events.EventEmitter {
length: number;
forEach(callback: Callback): void;
get(key: string): Host;
keys(): Array<string>;
remove(key: string): void;
removeMultiple(keys: Array<string>): void;
set(key: string, value: Host): void;
values(): Array<Host>;
}
export interface EncoderStatic {
new (protocolVersion: number, options: ClientOptions): Encoder;
}
export interface Encoder {
decode(buffer: Buffer, type: { code: number, info?: any }): void;
encode(value: any, typeInfo?: string | number | { code: number, info?: any }): Buffer;
}
export namespace auth {
var Authenticator: AuthenticatorStatic;
var PlainTextAuthProvider: PlainTextAuthProviderStatic;
interface AuthenticatorStatic {
new (): Authenticator;
}
interface Authenticator {
evaluateChallenge(challenge: Buffer, callback: Callback): void;
initialResponse(callback: Callback): void;
onAuthenticationSuccess(token?: Buffer): void;
}
interface AuthProvider {
newAuthenticator(endpoint: string, name: string): void;
}
interface PlainTextAuthProviderStatic {
new (username: string, password: string): PlainTextAuthProvider;
}
interface PlainTextAuthProvider extends AuthProvider {
newAuthenticator(endpoint: string, name: string): void;
}
}
export namespace errors {
abstract class DriverError {
constructor(message: string, constructor?: any);
}
class ArgumentError extends DriverError {
constructor(message: string);
}
class AuthenticationError extends DriverError {
constructor(message: string);
}
class DriverInternalError extends DriverError {
constructor(message: string);
}
class NoHostAvailableError extends DriverError {
constructor(innerErrors: any, message?: string);
}
class NotSupportedError extends DriverError {
constructor(message: string);
}
class OperationTimedOutError extends DriverError { }
class ResponseError extends DriverError {
constructor(code: number, message: string);
}
}
export namespace metadata {
var Aggregate: AggregateStatic;
var Index: IndexStatic;
var MaterializedView: MaterializedViewStatic;
var Metadata: MetadataStatic;
var SchemaFunction: SchemaFunctionStatic;
var TableMetadata: TableMetadataStatic;
type caching = "all" | "keys_only" | "rows_only" | "none";
interface AggregateStatic {
new (): Aggregate;
}
interface Aggregate {
argumentTypes: Array<{ code: number, info: any }>;
finalFunction: string;
initCondition: string;
keyspaceName: string,
returnType: string;
signature: Array<string>;
stateFunction: string;
stateType: string;
}
interface DataTypeInfo {
code: number,
info: string | DataTypeInfo | Array<DataTypeInfo>,
options: {
frozen: boolean,
reversed: boolean
}
}
interface ColumnInfo {
name: string,
type: DataTypeInfo
}
interface DataCollection {
bloomFilterFalsePositiveChance: number;
caching: caching;
clusterKeys: Array<{ c: ColumnInfo, index: number, order: string }>;
clusteringOrder: Array<string>;
columns: Array<ColumnInfo>;
columnsByName: { [key: string]: ColumnInfo };
comment: string;
compactionClass: string;
compactionOptions: any;
compression: any;
crcCheckChange?: number;
defaultTtl: number;
extensions: any;
gcGraceSeconds: number;
localReadRepairChance: number;
maxIndexInterval?: number;
minIndexInterval?: number;
name: string;
partitionKeys: Array<{ c: ColumnInfo, index: number }>
populateCacheOnFlush: boolean;
readRepairChance: number;
speculateRetry: string;
}
enum IndexType {
custom = 0,
keys,
composites
}
interface IndexStatic {
new (name: string, target: string, kind: IndexType, options: Object): Index;
fromRows(indexRows: Array<types.Row>): Array<Index>;
fromColumnRows(columnRows: Array<types.Row>, columnsByName: { [key: string]: ColumnInfo }): Array<Index>;
}
interface Index {
kind: IndexType;
name: string;
options: Object;
target: string;
isCompositesKind(): boolean;
isCustomKind(): boolean;
isKeysKind(): boolean;
}
interface MaterializedViewStatic {
new (name: string): MaterializedView;
}
interface MaterializedView extends DataCollection { }
interface MetadataStatic {
new (options: ClientOptions, controlConnection: any): Metadata;
}
interface Metadata {
clearPrepared(): void;
getAggregate(keyspaceName: string, name: string, signature: Array<string> | Array<{ code: number, info: any }>, callback: Callback): void;
getAggregates(keyspaceName: string, name: string, callback: Callback): void;
getFunction(keyspaceName: string, name: string, signature: Array<string> | Array<{ code: number, info: any }>, callback: Callback): void;
getFunctions(keyspaceName: string, name: string, callback: Callback): void;
getMaterializedView(keyspaceName: string, name: string, callback: Callback): void;
getReplicas(keyspaceName: string, tokenBuffer: Buffer): Array<any>;
getTable(keyspaceName: string, name: string, callback: Callback): void;
getTrace(traceId: types.Uuid, callback: Callback): void;
getUdt(keyspaceName: string, name: string, callback: Callback): void;
refreshKeyspace(name: string, callback?: Callback): void;
refreshKeyspaces(callback?: Callback): void;
}
interface SchemaFunctionStatic {
new (): SchemaFunction;
}
interface SchemaFunction {
argumentNames: Array<string>;
argumentTypes: Array<{ code: number, info: any }>;
body: string;
calledOnNullInput: boolean;
keyspaceName: string,
language: string;
name: string;
returnType: string;
signature: Array<string>;
}
interface TableMetadataStatic {
new (name: string): TableMetadata;
}
interface TableMetadata extends DataCollection {
indexes: Array<Index>;
indexInterval?: number;
isCompact: boolean;
memtableFlushPeriod: number;
replicateOnWrite: boolean;
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cassandra-driver.tests.ts"
]
}
+1
View File
@@ -14,6 +14,7 @@
},
"files": [
"index.d.ts",
"utils/index.d.ts",
"flux-tests.ts"
]
}
+9 -4
View File
@@ -3,6 +3,11 @@
// Definitions by: Steve Baker <https://github.com/stkb/>, Giedrius Grabauskas <https://github.com/GiedriusGrabauskas/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="react" />
/// <reference types="flux" />
/// <reference types="fbemitter" />
/// <reference types="immutable" />
import * as React from 'react';
import * as Flux from 'flux';
import * as fbEmitter from 'fbemitter';
@@ -13,24 +18,24 @@ export = FluxUtils;
declare namespace FluxUtils {
/**
* Default options to create a Container with
*
*
* @interface RealOptions
*/
interface RealOptions {
/**
* Default value: true
*
*
* @type {boolean}
*/
pure?: boolean;
/**
* Default value: false
*
*
* @type {boolean}
*/
withProps?: boolean;
}
export class Container {
constructor();
/**
+4 -6
View File
@@ -3,8 +3,6 @@
// Definitions by: David Deutsch <http://github.com/DavidKDeutsch>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface HighstockChartObject extends HighchartsChartObject {
options: HighstockOptions;
}
@@ -81,9 +79,9 @@ interface HighstockScrollbarOptions {
}
interface HighstockOptions extends HighchartsOptions {
navigator?: HighstockNavigatorOptions;
rangeSelector?: HighstockRangeSelectorOptions;
scrollbar?: HighstockScrollbarOptions;
navigator?: HighstockNavigatorOptions;
rangeSelector?: HighstockRangeSelectorOptions;
scrollbar?: HighstockScrollbarOptions;
}
interface HighstockChart {
@@ -92,7 +90,7 @@ interface HighstockChart {
}
interface HighchartsStatic {
StockChart: HighstockChart;
StockChart: HighstockChart;
}
interface JQuery {
+2
View File
@@ -3,6 +3,8 @@
// Definitions by: Damiano Gambarotto <http://github.com/damianog>, Dan Lewi Harkestad <http://github.com/baltie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="./highstock.d.ts" />
interface HighchartsPosition {
align?: string;
verticalAlign?: string;
+3 -1
View File
@@ -14,6 +14,8 @@
},
"files": [
"index.d.ts",
"highcharts-tests.ts"
"highstock.d.ts",
"highcharts-tests.ts",
"highstock-tests.ts"
]
}
+100
View File
@@ -0,0 +1,100 @@
// Type definitions for resolve
// Project: https://github.com/substack/node-resolve
// Definitions by: Mario Nebl <https://github.com/marionebl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/**
* Callback invoked when resolving asynchronously
*
* @param error
* @param resolved Absolute path to resolved identifier
*/
type resolveCallback = (err: Error, resolved?: string) => void;
/**
* Callback invoked when checking if a file exists
*
* @param error
* @param isFile If the given file exists
*/
type isFileCallback = (err: Error, isFile?: boolean) => void;
/**
* Callback invoked when reading a file
*
* @param error
* @param isFile If the given file exists
*/
type readFileCallback = (err: Error, file?: Buffer) => void;
/**
* Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
*
* @param id Identifier to resolve
* @param callback
*/
declare function resolve(id: string, cb: resolveCallback): void;
/**
* Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
* @param callback
*/
declare function resolve(id: string, opts: resolve.AsyncOpts, cb: resolveCallback): void;
/**
* Synchronously resolve the module path string id, returning the result and throwing an error when id can't be resolved.
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
*/
declare function resolveSync(id: string, opts?: resolve.SyncOpts): string;
/**
* Return whether a package is in core
*
* @param id
*/
declare function resolveIsCore(id: string): boolean;
declare namespace resolve {
interface Opts {
// directory to begin resolving from (defaults to __dirname)
basedir?: string;
// package.json data applicable to the module being loaded
package?: any;
// array of file extensions to search in order (defaults to ['.js'])
extensions?: string | string[];
// transform the parsed package.json contents before looking at the "main" field
packageFilter?: (pkg: any, pkgfile: string) => any;
// transform a path within a package
pathFilter?: (pkg: any, path: string, relativePath: string) => string;
// require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this)
paths?: string | string[];
// directory (or directories) in which to recursively look for modules. (default to 'node_modules')
moduleDirectory?: string | string[]
}
export interface AsyncOpts extends Opts {
// how to read files asynchronously (defaults to fs.readFile)
readFile?: (file: string, cb: readFileCallback) => void;
// function to asynchronously test whether a file exists
isFile?: (file: string, cb: isFileCallback) => void;
}
export interface SyncOpts extends Opts {
// how to read files synchronously (defaults to fs.readFileSync)
readFileSync?: (file: string) => Buffer;
// function to synchronously test whether a file exists
isFile?: (file: string) => boolean;
}
export var sync: typeof resolveSync;
export var isCore: typeof resolveIsCore;
}
export = resolve;
+1 -1
View File
@@ -1,4 +1,4 @@
/// <reference path="resolve.d.ts" />
/// <reference types="resolve" />
import * as fs from 'fs';
import * as resolve from 'resolve';
-102
View File
@@ -1,102 +0,0 @@
// Type definitions for resolve
// Project: https://github.com/substack/node-resolve
// Definitions by: Mario Nebl <https://github.com/marionebl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module 'resolve' {
/**
* Callback invoked when resolving asynchronously
*
* @param error
* @param resolved Absolute path to resolved identifier
*/
type resolveCallback = (err: Error, resolved?: string) => void;
/**
* Callback invoked when checking if a file exists
*
* @param error
* @param isFile If the given file exists
*/
type isFileCallback = (err: Error, isFile?: boolean) => void;
/**
* Callback invoked when reading a file
*
* @param error
* @param isFile If the given file exists
*/
type readFileCallback = (err: Error, file?: Buffer) => void;
/**
* Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
*
* @param id Identifier to resolve
* @param callback
*/
function resolve(id: string, cb: resolveCallback): void;
/**
* Asynchronously resolve the module path string id into cb(err, res [, pkg]), where pkg (if defined) is the data from package.json
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
* @param callback
*/
function resolve(id: string, opts: resolve.AsyncOpts, cb: resolveCallback): void;
/**
* Synchronously resolve the module path string id, returning the result and throwing an error when id can't be resolved.
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
*/
function resolveSync(id: string, opts?: resolve.SyncOpts): string;
/**
* Return whether a package is in core
*
* @param id
*/
function resolveIsCore(id: string): boolean;
namespace resolve {
interface Opts {
// directory to begin resolving from (defaults to __dirname)
basedir?: string;
// package.json data applicable to the module being loaded
package?: any;
// array of file extensions to search in order (defaults to ['.js'])
extensions?: string|string[];
// transform the parsed package.json contents before looking at the "main" field
packageFilter?: (pkg: any, pkgfile: string) => any;
// transform a path within a package
pathFilter?: (pkg: any, path: string, relativePath: string) => string;
// require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this)
paths?: string|string[];
// directory (or directories) in which to recursively look for modules. (default to 'node_modules')
moduleDirectory?: string|string[]
}
export interface AsyncOpts extends Opts {
// how to read files asynchronously (defaults to fs.readFile)
readFile?: (file: string, cb: readFileCallback) => void;
// function to asynchronously test whether a file exists
isFile?: (file: string, cb: isFileCallback) => void;
}
export interface SyncOpts extends Opts {
// how to read files synchronously (defaults to fs.readFileSync)
readFileSync?: (file: string) => Buffer;
// function to synchronously test whether a file exists
isFile?: (file: string) => boolean;
}
export var sync: typeof resolveSync;
export var isCore: typeof resolveIsCore;
}
export = resolve;
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"resolve-tests.ts"
]
}
+1
View File
@@ -14,6 +14,7 @@
},
"files": [
"index.d.ts",
"webpack-env.d.ts",
"webpack-tests.ts"
]
}