From 9ee1f10be8d96866bcc68bb5c42a870031d8164a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=BCfel?= Date: Sat, 31 Mar 2018 17:51:55 +0200 Subject: [PATCH] cassandra-driver: update to 3.4.1 --- types/cassandra-driver/index.d.ts | 153 +++++++++++++++++++++++++----- 1 file changed, 128 insertions(+), 25 deletions(-) diff --git a/types/cassandra-driver/index.d.ts b/types/cassandra-driver/index.d.ts index 5c0578ccf2..33a9f5988f 100644 --- a/types/cassandra-driver/index.d.ts +++ b/types/cassandra-driver/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for cassandra-driver v3.2.2 +// Type definitions for cassandra-driver v3.4.1 // Project: https://github.com/datastax/nodejs-driver // Definitions by: Marc Fisher +// Christian D // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -115,7 +116,11 @@ export namespace policies { interface RetryPolicyStatic { new (): RetryPolicy; - retryDecision: any; + retryDecision: { + rethrow: number, + retry: number, + ignore: number + }; } interface RetryPolicy { @@ -126,15 +131,55 @@ export namespace policies { retryResult(): { decision: retryDecision, consistency: types.consistencies, useCurrentHost: boolean }; } } + + namespace speculativeExecution { + let NoSpeculativeExecutionPolicy: NoSpeculativeExecutionPolicyStatic + + interface SpeculativeExecutionPolicy { + init(client: Client): void; + newPlan(keyspace: string, queryInfo: string | Array): { + nextExecution: Function + } + } + + interface NoSpeculativeExecutionPolicyStatic { + new (): NoSpeculativeExecutionPolicy + } + + interface NoSpeculativeExecutionPolicy extends SpeculativeExecutionPolicy { } + + interface ConstantSpeculativeExecutionPolicyStatic { + new (delay: number, maxSpeculativeExecutions: number): ConstantSpeculativeExecutionPolicy + } + + interface ConstantSpeculativeExecutionPolicy extends SpeculativeExecutionPolicy { } + } + + namespace timestampGeneration { + let MonotonicTimestampGenerator: MonotonicTimestampGeneratorStatic + + interface TimestampGenerator { + next(client: Client): null | number | _Long + } + + interface MonotonicTimestampGeneratorStatic { + new (warningThreshold?: number, minLogInterval?: number): MonotonicTimestampGeneratorStatic + } + + interface MonotonicTimestampGenerator extends TimestampGenerator { + getDate(): number + } + } } export namespace types { let BigDecimal: BigDecimalStatic; + let Duration: DurationStatic; + let Long: _Long; let InetAddress: InetAddressStatic; let Integer: IntegerStatic; let LocalDate: LocalDateStatic; let LocalTime: LocalTimeStatic; - let Long: _Long; let ResultSet: ResultSetStatic; // let ResultStream: ResultStreamStatic; let Row: RowStatic; @@ -221,6 +266,19 @@ export namespace types { toJSON(): string; } + interface DurationStatic { + new (month: number, days: number, nanoseconds: number | _Long): Duration; + + fromBuffer(buffer: Buffer): Duration; + fromString(input: string): Duration; + } + + interface Duration { + equals(other: Duration): boolean; + toBuffer(): Buffer; + toString(): string; + } + interface InetAddressStatic { new (buffer: Buffer): InetAddress; @@ -336,13 +394,14 @@ export namespace types { } interface ResultSetStatic { - new (response: any, host: string, triedHost: { [key: string]: any }, consistency: consistencies): ResultSet; + new (response: any, host: string, triedHost: { [key: string]: any }, speculativeExecutions: number, consistency: consistencies): ResultSet; } interface ResultSet { info: { queriedHost: Host, triedHosts: { [key: string]: string; }, + speculativeExecutions: number, achievedConsistency: consistencies, traceId: Uuid, warnings: Array, @@ -352,11 +411,13 @@ export namespace types { rowLength: number; columns: Array<{ [key: string]: string; }>; pageState: string; - nextPage: any; // function + nextPage: Function; first(): Row; getPageState(): string; getColumns(): Array<{ [key: string]: string; }>; + wasApplied(): boolean; + [Symbol.iterator](): Iterator; } interface ResultStreamStatic { @@ -442,40 +503,50 @@ export let Encoder: EncoderStatic; export interface ClientOptions { contactPoints: Array, keyspace?: string, + refreshSchemaDelay?: number, + isMetadataSyncEnabled?: boolean, + prepareOnAllHosts?: boolean, + rePrepareOnUp?: boolean, + maxPrepared?: number, policies?: { - addressResolution?: policies.addressResolution.AddressTranslator, loadBalancing?: policies.loadBalancing.LoadBalancingPolicy, + retry?: policies.retry.RetryPolicy, reconnection?: policies.reconnection.ReconnectionPolicy, - retry?: policies.retry.RetryPolicy + addressResolution?: policies.addressResolution.AddressTranslator, + speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy, + timestampGeneration?: policies.timestampGeneration.TimestampGenerator, }, queryOptions?: QueryOptions, pooling?: { - heartBeatInterval: number, - coreConnectionsPerHost: { [key: number]: number; }, - warmup: boolean; + heartBeatInterval?: number, + coreConnectionsPerHost?: { [key: number]: number; }, + maxRequestsPerConnection?: number, + warmup?: boolean; }, protocolOptions?: { - port: number, - maxSchemaAgreementWaitSeconds: number, - maxVersion: number + port?: number, + maxSchemaAgreementWaitSeconds?: number, + maxVersion?: number }, socketOptions?: { - connectTimeout: number, - defunctReadTimeoutThreshold: number, - keepAlive: boolean, - keepAliveDelay: number, - readTimeout: number, - tcpNoDelay: boolean, - coalescingThreshold: number + 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 - } + map?: Function, + set?: Function, + copyBuffer?: boolean, + useUndefinedAsUnset?: boolean + }, + profiles?: Array, + promiseFactory?: Function, } export interface QueryOptions { @@ -483,8 +554,11 @@ export interface QueryOptions { captureStackTrace?: boolean; consistency?: number; customPayload?: any; + executionProfile?: string | ExecutionProfile; fetchSize?: number; hints?: Array | Array>; + isIdempotent?: boolean; + keyspace?: string; logged?: boolean; pageState?: Buffer | string; prepare?: boolean; @@ -520,6 +594,7 @@ export interface Client extends events.EventEmitter { 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? + getState(): metadata.ClientState; shutdown(callback?: Callback): void; shutdown(): Promise; stream(query: string, params?: any, options?: QueryOptions, callback?: Callback): NodeJS.ReadableStream; @@ -548,6 +623,7 @@ export interface HostMapStatic { export interface HostMap extends events.EventEmitter { length: number; + clear(): Array; forEach(callback: Callback): void; get(key: string): Host; keys(): Array; @@ -566,6 +642,22 @@ 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 ExecutionProfileStatic { + new (name: string, options: ExecutionProfileOptions): ExecutionProfile +} + +export interface ExecutionProfile extends ExecutionProfileOptions { +} + export namespace auth { let Authenticator: AuthenticatorStatic; let PlainTextAuthProvider: PlainTextAuthProviderStatic; @@ -649,6 +741,17 @@ export namespace metadata { stateFunction: string; stateType: string; } + + interface ClientStateStatic { + new (): ClientState; + } + + interface ClientState { + getConnectedHosts(): Array; + getInFlightQueries(host: Host): number; + getOpenConnections(host: Host): number; + toString(): string; + } interface DataTypeInfo { code: number,