diff --git a/types/cassandra-driver/cassandra-driver-tests.ts b/types/cassandra-driver/cassandra-driver-tests.ts index 891c5a0167..ad8a7426fe 100644 --- a/types/cassandra-driver/cassandra-driver-tests.ts +++ b/types/cassandra-driver/cassandra-driver-tests.ts @@ -7,11 +7,15 @@ const client = new cassandra.Client({ keyspace: 'ks1', sslOptions: { cert: fs.readFileSync('certFilePath') + }, + encoding: { + map: Map, + set: Set } }); const query = 'SELECT email, last_name FROM user_profiles WHERE key=?'; -client.execute(query, ['guy'], function(err, result) { +client.execute(query, ['guy'], (err, result) => { console.log('got user profile with email ' + result.rows[0].email); }); diff --git a/types/cassandra-driver/index.d.ts b/types/cassandra-driver/index.d.ts index 0ac22eb263..df95e386b6 100644 --- a/types/cassandra-driver/index.d.ts +++ b/types/cassandra-driver/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cassandra-driver v3.6.0 +// Type definitions for cassandra-driver 3.6 // Project: https://github.com/datastax/nodejs-driver // Definitions by: Marc Fisher // Christian D @@ -6,7 +6,6 @@ // TypeScript Version: 2.2 /// -/// export type Callback = Function; export type ResultCallback = (err: Error, result: types.ResultSet) => void; @@ -50,8 +49,8 @@ export namespace policies { } interface DCAwareRoundRobinPolicy extends LoadBalancingPolicy { - localHostsArray: Array; - remoteHostsArray: Array; + localHostsArray: Host[]; + remoteHostsArray: Host[]; } interface RoundRobinPolicyStatic { @@ -67,7 +66,7 @@ export namespace policies { interface TokenAwarePolicy extends LoadBalancingPolicy { } interface WhiteListPolicyStatic { - new (childPolicy: LoadBalancingPolicy, whiteList: Array): WhiteListPolicy; + new (childPolicy: LoadBalancingPolicy, whiteList: string[]): WhiteListPolicy; } interface WhiteListPolicy extends LoadBalancingPolicy { } @@ -78,7 +77,9 @@ export namespace policies { let ExponentialReconnectionPolicy: ExponentialReconnectionPolicyStatic; interface ReconnectionPolicy { - newSchedule(): { next: Function }; + newSchedule(): { + next(): { delay: number; done: boolean; } + }; } interface ConstantReconnectionPolicyStatic { @@ -103,8 +104,8 @@ export namespace policies { } interface RequestInfo { - request: any, - nbRetry: number + request: any; + nbRetry: number; } enum retryDecision { @@ -133,41 +134,41 @@ export namespace policies { } namespace speculativeExecution { - let NoSpeculativeExecutionPolicy: NoSpeculativeExecutionPolicyStatic + let NoSpeculativeExecutionPolicy: NoSpeculativeExecutionPolicyStatic; interface SpeculativeExecutionPolicy { init(client: Client): void; - newPlan(keyspace: string, queryInfo: string | Array): { - nextExecution: Function - } + newPlan(keyspace: string, queryInfo: string | string[]): { + nextExecution: () => number; + }; } interface NoSpeculativeExecutionPolicyStatic { - new (): NoSpeculativeExecutionPolicy + new (): NoSpeculativeExecutionPolicy; } interface NoSpeculativeExecutionPolicy extends SpeculativeExecutionPolicy { } - + interface ConstantSpeculativeExecutionPolicyStatic { - new (delay: number, maxSpeculativeExecutions: number): ConstantSpeculativeExecutionPolicy + new (delay: number, maxSpeculativeExecutions: number): ConstantSpeculativeExecutionPolicy; } interface ConstantSpeculativeExecutionPolicy extends SpeculativeExecutionPolicy { } } namespace timestampGeneration { - let MonotonicTimestampGenerator: MonotonicTimestampGeneratorStatic + let MonotonicTimestampGenerator: MonotonicTimestampGeneratorStatic; interface TimestampGenerator { - next(client: Client): null | number | _Long + next(client: Client): null | number | _Long; } interface MonotonicTimestampGeneratorStatic { - new (warningThreshold?: number, minLogInterval?: number): MonotonicTimestampGeneratorStatic + new (warningThreshold?: number, minLogInterval?: number): MonotonicTimestampGeneratorStatic; } interface MonotonicTimestampGenerator extends TimestampGenerator { - getDate(): number + getDate(): number; } } } @@ -297,11 +298,11 @@ export namespace types { } interface IntegerStatic { - new (bits: Array, sign: number): Integer; + new (bits: number[], sign: number): Integer; fromInt(value: number): Integer; fromNumber(value: number): Integer; - fromBits(bits: Array): Integer; + fromBits(bits: number[]): Integer; fromString(str: string, opt_radix?: number): Integer; fromBuffer(bits: Buffer): Integer; toBuffer(value: Integer): Buffer; @@ -404,14 +405,14 @@ export namespace types { speculativeExecutions: number, achievedConsistency: consistencies, traceId: Uuid, - warnings: Array, + warnings: string[], customPayload: any }; - rows: Array; + rows: Row[]; rowLength: number; columns: Array<{ [key: string]: string; }>; pageState: string; - nextPage: Function; + nextPage: () => void; first(): Row | null; getPageState(): string; @@ -428,7 +429,7 @@ export namespace types { buffer: Buffer; paused: boolean; - _valve(readNext: Function): void; + _valve(readNext: () => void): void; add(chunk: Buffer): void; } @@ -439,7 +440,7 @@ export namespace types { interface Row { get(columnName: string | number): { [key: string]: any; }; values(): Array<{ [key: string]: any; }>; - keys(): Array; + keys(): string[]; forEach(callback: Callback): void; [key: string]: any; } @@ -462,19 +463,19 @@ export namespace types { } interface TupleStatic { - new (...args: Array): Tuple; + new (...args: any[]): Tuple; - fromArray(elements: Array): Tuple; + fromArray(elements: any[]): Tuple; } interface Tuple { - elements: Array; + elements: any[]; length: number; get(index: number): any; toString(): string; toJSON(): string; - values(): Array; + values(): any[]; } interface UuidStatic { @@ -488,6 +489,7 @@ export namespace types { buffer: Buffer; getBuffer(): Buffer; + // tslint:disable-next-line:no-unnecessary-qualifier equals(other: types.Uuid): boolean; toString(): string; inspect(): string; @@ -501,53 +503,53 @@ export let HostMap: HostMapStatic; export let Encoder: EncoderStatic; export interface ClientOptions { - contactPoints: Array, - keyspace?: string, - refreshSchemaDelay?: number, - isMetadataSyncEnabled?: boolean, - prepareOnAllHosts?: boolean, - rePrepareOnUp?: boolean, - maxPrepared?: number, + contactPoints: string[]; + keyspace?: string; + refreshSchemaDelay?: number; + isMetadataSyncEnabled?: boolean; + prepareOnAllHosts?: boolean; + rePrepareOnUp?: boolean; + maxPrepared?: number; policies?: { - loadBalancing?: policies.loadBalancing.LoadBalancingPolicy, - retry?: policies.retry.RetryPolicy, - reconnection?: policies.reconnection.ReconnectionPolicy, - addressResolution?: policies.addressResolution.AddressTranslator, - speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy, - timestampGeneration?: policies.timestampGeneration.TimestampGenerator, - }, - queryOptions?: QueryOptions, + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + retry?: policies.retry.RetryPolicy; + reconnection?: policies.reconnection.ReconnectionPolicy; + addressResolution?: policies.addressResolution.AddressTranslator; + speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy; + timestampGeneration?: policies.timestampGeneration.TimestampGenerator; + }; + queryOptions?: QueryOptions; pooling?: { - heartBeatInterval?: number, - coreConnectionsPerHost?: { [key: number]: number; }, - maxRequestsPerConnection?: number, + heartBeatInterval?: number; + coreConnectionsPerHost?: { [key: number]: number; }; + maxRequestsPerConnection?: number; warmup?: boolean; - }, + }; protocolOptions?: { - port?: number, - maxSchemaAgreementWaitSeconds?: number, - maxVersion?: number, - noCompact?: boolean - }, + port?: number; + maxSchemaAgreementWaitSeconds?: number; + maxVersion?: number; + noCompact?: boolean; + }; socketOptions?: { - connectTimeout?: number, - defunctReadTimeoutThreshold?: number, - keepAlive?: boolean, - keepAliveDelay?: number, - readTimeout?: number, - tcpNoDelay?: boolean, - coalescingThreshold?: number - }, - authProvider?: auth.AuthProvider, - sslOptions?: tls.ConnectionOptions, + connectTimeout?: number; + defunctReadTimeoutThreshold?: number; + keepAlive?: boolean; + keepAliveDelay?: number; + readTimeout?: number; + tcpNoDelay?: boolean; + coalescingThreshold?: number; + }; + authProvider?: auth.AuthProvider; + sslOptions?: tls.ConnectionOptions; encoding?: { - map?: Function, - set?: Function, - copyBuffer?: boolean, - useUndefinedAsUnset?: boolean - }, - profiles?: Array, - promiseFactory?: Function, + map?: typeof Map | ((...args: any[]) => any); + set?: typeof Set | ((...args: any[]) => any); + copyBuffer?: boolean; + useUndefinedAsUnset?: boolean; + }; + profiles?: ExecutionProfile[]; + promiseFactory?: (handler: (callback: (err?: any, result?: any) => void) => void) => Promise; } export interface QueryOptions { @@ -557,7 +559,7 @@ export interface QueryOptions { customPayload?: any; executionProfile?: string | ExecutionProfile; fetchSize?: number; - hints?: Array | Array>; + hints?: string[] | string[][]; isIdempotent?: boolean; keyspace?: string; logged?: boolean; @@ -566,9 +568,9 @@ export interface QueryOptions { readTimeout?: number; retry?: policies.retry.RetryPolicy; retryOnTimeout?: boolean; - routingIndexes?: Array; - routingKey?: Buffer | Array; - routingNames?: Array; + routingIndexes?: number[]; + routingKey?: Buffer | Buffer[]; + routingNames?: string[]; serialConsistency?: number; timestamp?: number | _Long; traceQuery?: boolean; @@ -584,9 +586,9 @@ export interface Client extends events.EventEmitter { keyspace: string; metadata: metadata.Metadata; - batch(queries: Array | Array<{ query: string, params?: any }>, options: QueryOptions, callback: ResultCallback): void; - batch(queries: Array | Array<{ query: string, params?: any }>, callback: ResultCallback): void; - batch(queries: Array | Array<{ query: string, params?: any }>, options?: QueryOptions): Promise; + batch(queries: string[] | Array<{ query: string, params?: any }>, options: QueryOptions, callback: ResultCallback): void; + batch(queries: string[] | Array<{ query: string, params?: any }>, callback: ResultCallback): void; + batch(queries: string[] | Array<{ query: string, params?: any }>, options?: QueryOptions): Promise; connect(callback: Callback): void; connect(): Promise; @@ -595,7 +597,7 @@ export interface Client extends events.EventEmitter { execute(query: string, params: any, callback: ResultCallback): void; execute(query: string, callback: ResultCallback): void; execute(query: string, params?: any, options?: QueryOptions): Promise; - getReplicas(keyspace: string, token: Buffer): Array; // TODO: Should this be a more explicit return? + getReplicas(keyspace: string, token: Buffer): any[]; // TODO: Should this be a more explicit return? getState(): metadata.ClientState; shutdown(callback?: Callback): void; shutdown(): Promise; @@ -611,10 +613,10 @@ export interface Host extends events.EventEmitter { cassandraVersion: string; dataCenter: string; rack: string; - tokens: Array; + tokens: string[]; canBeConsideredAsUp(): boolean; - getCassandraVersion(): Array; + getCassandraVersion(): number[]; isUp(): boolean; } @@ -625,14 +627,14 @@ export interface HostMapStatic { export interface HostMap extends events.EventEmitter { length: number; - clear(): Array; + clear(): Host[]; forEach(callback: Callback): void; get(key: string): Host; - keys(): Array; + keys(): string[]; remove(key: string): void; - removeMultiple(keys: Array): void; + removeMultiple(keys: string[]): void; set(key: string, value: Host): void; - values(): Array; + values(): Host[]; } export interface EncoderStatic { @@ -644,21 +646,20 @@ export interface Encoder { encode(value: any, typeInfo?: string | number | { code: number, info?: any }): Buffer; } -interface ExecutionProfileOptions { - consistency: number, - loadBalancing: policies.loadBalancing.LoadBalancingPolicy, - name: string, - readTimeout: number, - retry: policies.retry.RetryPolicy, - serialConsistency: number +export interface ExecutionProfileOptions { + consistency: number; + loadBalancing: policies.loadBalancing.LoadBalancingPolicy; + name: string; + readTimeout: number; + retry: policies.retry.RetryPolicy; + serialConsistency: number; } export interface ExecutionProfileStatic { - new (name: string, options: ExecutionProfileOptions): ExecutionProfile + new (name: string, options: ExecutionProfileOptions): ExecutionProfile; } -export interface ExecutionProfile extends ExecutionProfileOptions { -} +export interface ExecutionProfile extends ExecutionProfileOptions {} export namespace auth { let Authenticator: AuthenticatorStatic; @@ -716,7 +717,7 @@ export namespace errors { constructor(message: string); } - class OperationTimedOutError extends DriverError { + class OperationTimedOutError extends DriverError { constructor(message: string, host?: string); host?: string; @@ -751,44 +752,44 @@ export namespace metadata { argumentTypes: Array<{ code: number, info: any }>; finalFunction: string; initCondition: string; - keyspaceName: string, + keyspaceName: string; returnType: string; - signature: Array; + signature: string[]; stateFunction: string; stateType: string; } - + interface ClientStateStatic { new (): ClientState; } - + interface ClientState { - getConnectedHosts(): Array; + getConnectedHosts(): Host[]; getInFlightQueries(host: Host): number; getOpenConnections(host: Host): number; toString(): string; } interface DataTypeInfo { - code: number, - info: string | DataTypeInfo | Array, + code: number; + info: string | DataTypeInfo | DataTypeInfo[]; options: { - frozen: boolean, - reversed: boolean - } + frozen: boolean; + reversed: boolean; + }; } interface ColumnInfo { - name: string, - type: DataTypeInfo + name: string; + type: DataTypeInfo; } interface DataCollection { bloomFilterFalsePositiveChance: number; caching: caching; clusterKeys: Array<{ c: ColumnInfo, index: number, order: string }>; - clusteringOrder: Array; - columns: Array; + clusteringOrder: string[]; + columns: ColumnInfo[]; columnsByName: { [key: string]: ColumnInfo }; comment: string; compactionClass: string; @@ -802,7 +803,7 @@ export namespace metadata { maxIndexInterval?: number; minIndexInterval?: number; name: string; - partitionKeys: Array<{ c: ColumnInfo, index: number }> + partitionKeys: Array<{ c: ColumnInfo, index: number }>; populateCacheOnFlush: boolean; readRepairChance: number; speculateRetry: string; @@ -815,16 +816,16 @@ export namespace metadata { } interface IndexStatic { - new (name: string, target: string, kind: string | IndexType, options: Object): Index; + new (name: string, target: string, kind: string | IndexType, options: object): Index; - fromRows(indexRows: Array): Array; - fromColumnRows(columnRows: Array, columnsByName: { [key: string]: ColumnInfo }): Array; + fromRows(indexRows: types.Row[]): Index[]; + fromColumnRows(columnRows: types.Row[], columnsByName: { [key: string]: ColumnInfo }): Index[]; } interface Index { kind: IndexType; name: string; - options: Object; + options: object; target: string; isCompositesKind(): boolean; @@ -845,12 +846,12 @@ export namespace metadata { interface Metadata { clearPrepared(): void; - getAggregate(keyspaceName: string, name: string, signature: Array | Array<{ code: number, info: any }>, callback: Callback): void; + getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: Callback): void; getAggregates(keyspaceName: string, name: string, callback: Callback): void; - getFunction(keyspaceName: string, name: string, signature: Array | Array<{ code: number, info: any }>, callback: Callback): void; + getFunction(keyspaceName: string, name: string, signature: 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; + getReplicas(keyspaceName: string, tokenBuffer: Buffer): any[]; getTable(keyspaceName: string, name: string, callback: Callback): void; getTrace(traceId: types.Uuid, callback: Callback): void; getUdt(keyspaceName: string, name: string, callback: Callback): void; @@ -863,15 +864,15 @@ export namespace metadata { } interface SchemaFunction { - argumentNames: Array; + argumentNames: string[]; argumentTypes: Array<{ code: number, info: any }>; body: string; calledOnNullInput: boolean; - keyspaceName: string, + keyspaceName: string; language: string; name: string; returnType: string; - signature: Array; + signature: string[]; } interface TableMetadataStatic { @@ -879,7 +880,7 @@ export namespace metadata { } interface TableMetadata extends DataCollection { - indexes: Array; + indexes: Index[]; indexInterval?: number; isCompact: boolean; memtableFlushPeriod: number; diff --git a/types/cassandra-driver/tsconfig.json b/types/cassandra-driver/tsconfig.json index e47bfd4444..59e0316c6a 100644 --- a/types/cassandra-driver/tsconfig.json +++ b/types/cassandra-driver/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "cassandra-driver-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/cassandra-driver/tslint.json b/types/cassandra-driver/tslint.json index a41bf5d19a..ec0272c64c 100644 --- a/types/cassandra-driver/tslint.json +++ b/types/cassandra-driver/tslint.json @@ -1,79 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "no-misused-new": false } }