diff --git a/.gitignore b/.gitignore index 1677f5bc7..4388222db 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ out/ /docs **/typescript/*.js **/typescript/*.js.map -**/typescript/generated.ts \ No newline at end of file +**/typescript/generated.ts + +tsdoc-metadata.json \ No newline at end of file diff --git a/api-extractor.json b/api-extractor.json new file mode 100644 index 000000000..3f09edda5 --- /dev/null +++ b/api-extractor.json @@ -0,0 +1,454 @@ +/** + * Config file for API Extractor. For more info, please visit: https://api-extractor.com + */ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + + /** + * Optionally specifies another JSON config file that this file extends from. This provides a way for + * standard settings to be shared across multiple projects. + * + * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains + * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be + * resolved using NodeJS require(). + * + * SUPPORTED TOKENS: none + * DEFAULT VALUE: "" + */ + // "extends": "./shared/api-extractor-base.json" + // "extends": "my-package/include/api-extractor-base.json" + + /** + * Determines the "" token that can be used with other config file settings. The project folder + * typically contains the tsconfig.json and package.json config files, but the path is user-defined. + * + * The path is resolved relative to the folder of the config file that contains the setting. + * + * The default value for "projectFolder" is the token "", which means the folder is determined by traversing + * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder + * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error + * will be reported. + * + * SUPPORTED TOKENS: + * DEFAULT VALUE: "" + */ + // "projectFolder": "..", + + /** + * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor + * analyzes the symbols exported by this module. + * + * The file extension must be ".d.ts" and not ".ts". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + */ + "mainEntryPointFilePath": "/out/index.d.ts", + + /** + * A list of NPM package names whose exports should be treated as part of this package. + * + * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1", + * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part + * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly + * imports library2. To avoid this, we might specify: + * + * "bundledPackages": [ "library2" ], + * + * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been + * local files for library1. + * + * The "bundledPackages" elements may specify glob patterns using minimatch syntax. To ensure deterministic + * output, globs are expanded by matching explicitly declared top-level dependencies only. For example, + * the pattern below will NOT match "@my-company/example" unless it appears in a field such as "dependencies" + * or "devDependencies" of the project's package.json file: + * + * "bundledPackages": [ "@my-company/*" ], + */ + "bundledPackages": [], + + /** + * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files + * will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead. + * To use the OS's default newline kind, specify "os". + * + * DEFAULT VALUE: "crlf" + */ + // "newlineKind": "crlf", + + /** + * Specifies how API Extractor sorts members of an enum when generating the .api.json file. By default, the output + * files will be sorted alphabetically, which is "by-name". To keep the ordering in the source code, specify + * "preserve". + * + * DEFAULT VALUE: "by-name" + */ + // "enumMemberOrder": "by-name", + + /** + * Set to true when invoking API Extractor's test harness. When `testMode` is true, the `toolVersion` field in the + * .api.json file is assigned an empty string to prevent spurious diffs in output files tracked for tests. + * + * DEFAULT VALUE: "false" + */ + // "testMode": false, + + /** + * Determines how the TypeScript compiler engine will be invoked by API Extractor. + */ + "compiler": { + /** + * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * Note: This setting will be ignored if "overrideTsconfig" is used. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/tsconfig.json" + */ + // "tsconfigFilePath": "/tsconfig.json", + /** + * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. + * The object must conform to the TypeScript tsconfig schema: + * + * http://json.schemastore.org/tsconfig + * + * If omitted, then the tsconfig.json file will be read from the "projectFolder". + * + * DEFAULT VALUE: no overrideTsconfig section + */ + // "overrideTsconfig": { + // . . . + // } + /** + * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended + * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when + * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses + * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck. + * + * DEFAULT VALUE: false + */ + // "skipLibCheck": true, + }, + + /** + * Configures how the API report file (*.api.md) will be generated. + */ + "apiReport": { + /** + * (REQUIRED) Whether to generate an API report. + */ + "enabled": true + + /** + * The base filename for the API report files, to be combined with "reportFolder" or "reportTempFolder" + * to produce the full file path. The "reportFileName" should not include any path separators such as + * "\" or "/". The "reportFileName" should not include a file extension, since API Extractor will automatically + * append an appropriate file extension such as ".api.md". If the "reportVariants" setting is used, then the + * file extension includes the variant name, for example "my-report.public.api.md" or "my-report.beta.api.md". + * The "complete" variant always uses the simple extension "my-report.api.md". + * + * Previous versions of API Extractor required "reportFileName" to include the ".api.md" extension explicitly; + * for backwards compatibility, that is still accepted but will be discarded before applying the above rules. + * + * SUPPORTED TOKENS: , + * DEFAULT VALUE: "" + */ + // "reportFileName": "", + + /** + * To support different approval requirements for different API levels, multiple "variants" of the API report can + * be generated. The "reportVariants" setting specifies a list of variants to be generated. If omitted, + * by default only the "complete" variant will be generated, which includes all @internal, @alpha, @beta, + * and @public items. Other possible variants are "alpha" (@alpha + @beta + @public), "beta" (@beta + @public), + * and "public" (@public only). + * + * DEFAULT VALUE: [ "complete" ] + */ + // "reportVariants": ["public", "beta"], + + /** + * Specifies the folder where the API report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy, + * e.g. for an API review. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/etc/" + */ + // "reportFolder": "/etc/", + + /** + * Specifies the folder where the temporary report file is written. The file name portion is determined by + * the "reportFileName" setting. + * + * After the temporary file is written to disk, it is compared with the file in the "reportFolder". + * If they are different, a production build will fail. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/" + */ + // "reportTempFolder": "/temp/", + + /** + * Whether "forgotten exports" should be included in the API report file. Forgotten exports are declarations + * flagged with `ae-forgotten-export` warnings. See https://api-extractor.com/pages/messages/ae-forgotten-export/ to + * learn more. + * + * DEFAULT VALUE: "false" + */ + // "includeForgottenExports": false + }, + + /** + * Configures how the doc model file (*.api.json) will be generated. + */ + "docModel": { + /** + * (REQUIRED) Whether to generate a doc model file. + */ + "enabled": true + + /** + * The output path for the doc model file. The file extension should be ".api.json". + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/temp/.api.json" + */ + // "apiJsonFilePath": "/temp/.api.json", + + /** + * Whether "forgotten exports" should be included in the doc model file. Forgotten exports are declarations + * flagged with `ae-forgotten-export` warnings. See https://api-extractor.com/pages/messages/ae-forgotten-export/ to + * learn more. + * + * DEFAULT VALUE: "false" + */ + // "includeForgottenExports": false, + + /** + * The base URL where the project's source code can be viewed on a website such as GitHub or + * Azure DevOps. This URL path corresponds to the `` path on disk. + * + * This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items. + * For example, if the `projectFolderUrl` is "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor" and an API + * item's file path is "api/ExtractorConfig.ts", the full URL file path would be + * "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js". + * + * This setting can be omitted if you don't need source code links in your API documentation reference. + * + * SUPPORTED TOKENS: none + * DEFAULT VALUE: "" + */ + // "projectFolderUrl": "http://github.com/path/to/your/projectFolder" + }, + + /** + * Configures how the .d.ts rollup file will be generated. + */ + "dtsRollup": { + /** + * (REQUIRED) Whether to generate the .d.ts rollup file. + */ + "enabled": true + + /** + * Specifies the output path for a .d.ts rollup file to be generated without any trimming. + * This file will include all declarations that are exported by the main entry point. + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "/dist/.d.ts" + */ + // "untrimmedFilePath": "/dist/.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release. + * This file will include only declarations that are marked as "@public", "@beta", or "@alpha". + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "alphaTrimmedFilePath": "/dist/-alpha.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release. + * This file will include only declarations that are marked as "@public" or "@beta". + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "betaTrimmedFilePath": "/dist/-beta.d.ts", + + /** + * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release. + * This file will include only declarations that are marked as "@public". + * + * If the path is an empty string, then this file will not be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "publicTrimmedFilePath": "/dist/-public.d.ts", + + /** + * When a declaration is trimmed, by default it will be replaced by a code comment such as + * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the + * declaration completely. + * + * DEFAULT VALUE: false + */ + // "omitTrimmingComments": true + }, + + /** + * Configures how the tsdoc-metadata.json file will be generated. + */ + "tsdocMetadata": { + /** + * Whether to generate the tsdoc-metadata.json file. + * + * DEFAULT VALUE: true + */ + // "enabled": true, + /** + * Specifies where the TSDoc metadata file should be written. + * + * The path is resolved relative to the folder of the config file that contains the setting; to change this, + * prepend a folder token such as "". + * + * The default value is "", which causes the path to be automatically inferred from the "tsdocMetadata", + * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup + * falls back to "tsdoc-metadata.json" in the package folder. + * + * SUPPORTED TOKENS: , , + * DEFAULT VALUE: "" + */ + // "tsdocMetadataFilePath": "/dist/tsdoc-metadata.json" + }, + + /** + * Configures how API Extractor reports error and warning messages produced during analysis. + * + * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages. + */ + "messages": { + /** + * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing + * the input .d.ts files. + * + * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "compilerMessageReporting": { + /** + * Configures the default routing for messages that don't match an explicit rule in this table. + */ + "default": { + /** + * Specifies whether the message should be written to the the tool's output log. Note that + * the "addToApiReportFile" property may supersede this option. + * + * Possible values: "error", "warning", "none" + * + * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail + * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes + * the "--local" option), the warning is displayed but the build will not fail. + * + * DEFAULT VALUE: "warning" + */ + "logLevel": "warning" + + /** + * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md), + * then the message will be written inside that file; otherwise, the message is instead logged according to + * the "logLevel" option. + * + * DEFAULT VALUE: false + */ + // "addToApiReportFile": false + } + + // "TS2551": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by API Extractor during its analysis. + * + * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag" + * + * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings + */ + "extractorMessageReporting": { + "default": { + "logLevel": "warning" + // "addToApiReportFile": false + } + + // "ae-extra-release-tag": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + }, + + /** + * Configures handling of messages reported by the TSDoc parser when analyzing code comments. + * + * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text" + * + * DEFAULT VALUE: A single "default" entry with logLevel=warning. + */ + "tsdocMessageReporting": { + "default": { + "logLevel": "warning" + // "addToApiReportFile": false + } + + // "tsdoc-link-tag-unescaped-text": { + // "logLevel": "warning", + // "addToApiReportFile": true + // }, + // + // . . . + } + } +} diff --git a/dist/cassandra-driver.d.ts b/dist/cassandra-driver.d.ts new file mode 100644 index 000000000..6ed51dc68 --- /dev/null +++ b/dist/cassandra-driver.d.ts @@ -0,0 +1,1653 @@ +import * as events from 'events'; +import _Long = require('long'); +import { Readable } from 'stream'; +import * as stream from 'stream'; +import * as tls from 'tls'; +import { URL as URL_2 } from 'url'; + +export declare type ArrayOrObject = any[]|{[key: string]: any}; + +export declare namespace auth { + export interface Authenticator { + initialResponse(callback: Function): void; + + evaluateChallenge(challenge: Buffer, callback: Function): void; + + onAuthenticationSuccess(token?: Buffer): void; + } + + export interface AuthProvider { + newAuthenticator(endpoint: string, name: string): Authenticator; + } + + export class PlainTextAuthProvider implements AuthProvider { + constructor(username: string, password: string); + + newAuthenticator(endpoint: string, name: string): Authenticator; + } + + export class DsePlainTextAuthProvider implements AuthProvider { + constructor(username: string, password: string, authorizationId?: string); + + newAuthenticator(endpoint: string, name: string): Authenticator; + } + + export class DseGssapiAuthProvider implements AuthProvider { + constructor(gssOptions?: { authorizationId?: string, service?: string, hostNameResolver?: Function }); + + newAuthenticator(endpoint: string, name: string): Authenticator; + } +} + +export declare class Client extends events.EventEmitter { + hosts: HostMap; + keyspace: string; + metadata: metadata.Metadata; + metrics: metrics.ClientMetrics; + + constructor(options: DseClientOptions); + + connect(): Promise; + + connect(callback: EmptyCallback): void; + + execute(query: string, params?: ArrayOrObject, options?: QueryOptions): Promise; + + execute(query: string, params: ArrayOrObject, options: QueryOptions, callback: ValueCallback): void; + + execute(query: string, params: ArrayOrObject, callback: ValueCallback): void; + + execute(query: string, callback: ValueCallback): void; + + executeGraph( + traversal: string, + parameters: { [name: string]: any } | undefined, + options: GraphQueryOptions, + callback: ValueCallback): void; + + executeGraph( + traversal: string, + parameters: { [name: string]: any } | undefined, + callback: ValueCallback): void; + + executeGraph(traversal: string, callback: ValueCallback): void; + + executeGraph( + traversal: string, + parameters?: { [name: string]: any }, + options?: GraphQueryOptions): Promise; + + eachRow(query: string, + params: ArrayOrObject, + options: QueryOptions, + rowCallback: (n: number, row: types.Row) => void, + callback?: ValueCallback): void; + + eachRow(query: string, + params: ArrayOrObject, + rowCallback: (n: number, row: types.Row) => void, + callback?: ValueCallback): void; + + eachRow(query: string, + rowCallback: (n: number, row: types.Row) => void): void; + + stream(query: string, params?: ArrayOrObject, options?: QueryOptions, callback?: EmptyCallback): events.EventEmitter; + + batch( + queries: Array, + options?: QueryOptions): Promise; + + batch( + queries: Array, + options: QueryOptions, + callback: ValueCallback): void; + + batch( + queries: Array, + callback: ValueCallback): void; + + shutdown(): Promise; + + shutdown(callback: EmptyCallback): void; + + getReplicas(keyspace: string, token: Buffer): Host[]; + + getState(): metadata.ClientState; +} + +export declare interface ClientOptions { + contactPoints?: string[]; + localDataCenter?: string; + keyspace?: string; + authProvider?: auth.AuthProvider; + credentials?: { + username: string; + password: string; + } + + cloud?: { + secureConnectBundle: string | URL_2; + }; + + encoding?: { + map?: Function; + set?: Function; + copyBuffer?: boolean; + useUndefinedAsUnset?: boolean; + useBigIntAsLong?: boolean; + useBigIntAsVarint?: boolean; + }; + isMetadataSyncEnabled?: boolean; + maxPrepared?: number; + metrics?: metrics.ClientMetrics; + policies?: { + addressResolution?: policies.addressResolution.AddressTranslator; + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + reconnection?: policies.reconnection.ReconnectionPolicy; + retry?: policies.retry.RetryPolicy; + speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy; + timestampGeneration?: policies.timestampGeneration.TimestampGenerator; + }; + pooling?: { + coreConnectionsPerHost?: { [key: number]: number; }; + heartBeatInterval?: number; + maxRequestsPerConnection?: number; + warmup?: boolean; + }; + prepareOnAllHosts?: boolean; + profiles?: ExecutionProfile[]; + protocolOptions?: { + maxSchemaAgreementWaitSeconds?: number; + maxVersion?: number; + noCompact?: boolean; + port?: number; + }; + promiseFactory?: (handler: (callback: (err: Error, result?: any) => void) => void) => Promise; + queryOptions?: QueryOptions; + refreshSchemaDelay?: number; + rePrepareOnUp?: boolean; + requestTracker?: tracker.RequestTracker; + socketOptions?: { + coalescingThreshold?: number; + connectTimeout?: number; + defunctReadTimeoutThreshold?: number; + keepAlive?: boolean; + keepAliveDelay?: number; + readTimeout?: number; + tcpNoDelay?: boolean; + }; + sslOptions?: tls.ConnectionOptions; +} + +export declare namespace concurrent { + export interface ResultSetGroup { + errors: Error[]; + resultItems: any[]; + totalExecuted: number; + } + + export type Options = { + collectResults?: boolean; + concurrencyLevel?: number; + executionProfile?: string; + maxErrors?: number; + raiseOnFirstError?: boolean; + } + + export function executeConcurrent( + client: Client, + query: string, + parameters: any[][]|Readable, + options?: Options): Promise; + + export function executeConcurrent( + client: Client, + queries: Array<{query: string, params: any[]}>, + options?: Options): Promise; +} + +export declare namespace datastax { + import graph = graphModule.graph; + + import search = searchModule.search; +} + +export declare function defaultOptions(): ClientOptions; + +export declare interface DseClientOptions extends ClientOptions { + id?: Uuid; + applicationName?: string; + applicationVersion?: string; + monitorReporting?: { enabled?: boolean }; + graphOptions?: GraphOptions; +} + +export declare type EmptyCallback = (err: Error) => void; + +export declare namespace errors { + export class ArgumentError extends DriverError { + constructor(message: string); + } + + export class AuthenticationError extends DriverError { + constructor(message: string); + } + + export class BusyConnectionError extends DriverError { + constructor(address: string, maxRequestsPerConnection: number, connectionLength: number); + } + + export abstract class DriverError extends Error { + info: string; + + constructor(message: string, constructor?: any); + } + + export class DriverInternalError extends DriverError { + constructor(message: string); + } + + export class NoHostAvailableError extends DriverError { + innerErrors: any; + + constructor(innerErrors: any, message?: string); + } + + export class NotSupportedError extends DriverError { + constructor(message: string); + } + + export class OperationTimedOutError extends DriverError { + host?: string; + + constructor(message: string, host?: string); + } + + export class ResponseError extends DriverError { + code: number; + + constructor(code: number, message: string); + } +} + +export declare interface ExecutionOptions { + getCaptureStackTrace(): boolean; + + getConsistency(): types.consistencies; + + getCustomPayload(): { [key: string]: any }; + + getFetchSize(): number; + + getFixedHost(): Host; + + getHints(): string[] | string[][]; + + isAutoPage(): boolean; + + isBatchCounter(): boolean; + + isBatchLogged(): boolean; + + isIdempotent(): boolean; + + isPrepared(): boolean; + + isQueryTracing(): boolean; + + getKeyspace(): string; + + getLoadBalancingPolicy(): policies.loadBalancing.LoadBalancingPolicy; + + getPageState(): Buffer; + + getRawQueryOptions(): QueryOptions; + + getReadTimeout(): number; + + getRetryPolicy(): policies.retry.RetryPolicy; + + getRoutingKey(): Buffer | Buffer[]; + + getSerialConsistency(): types.consistencies; + + getTimestamp(): number | Long | undefined | null; + + setHints(hints: string[]): void; +} + +export declare class ExecutionProfile { + consistency?: types.consistencies; + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + name: string; + readTimeout?: number; + retry?: policies.retry.RetryPolicy; + serialConsistency?: types.consistencies; + graphOptions?: { + name?: string; + language?: string; + source?: string; + readConsistency?: types.consistencies; + writeConsistency?: types.consistencies; + }; + + constructor(name: string, options: { + consistency?: types.consistencies; + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + readTimeout?: number; + retry?: policies.retry.RetryPolicy; + serialConsistency?: types.consistencies; + graphOptions?: { + name?: string; + language?: string; + source?: string; + readConsistency?: types.consistencies; + writeConsistency?: types.consistencies; + }; + }); +} + +export declare namespace geometry { + export class LineString { + constructor(...args: Point[]); + + static fromBuffer(buffer: Buffer): LineString; + + static fromString(textValue: string): LineString; + + equals(other: LineString): boolean; + + toBuffer(): Buffer; + + toJSON(): string; + + toString(): string; + + } + + export class Point { + constructor(x: number, y: number); + + static fromBuffer(buffer: Buffer): Point; + + static fromString(textValue: string): Point; + + equals(other: Point): boolean; + + toBuffer(): Buffer; + + toJSON(): string; + + toString(): string; + + } + + export class Polygon { + constructor(...args: Point[]); + + static fromBuffer(buffer: Buffer): Polygon; + + static fromString(textValue: string): Polygon; + + equals(other: Polygon): boolean; + + toBuffer(): Buffer; + + toJSON(): string; + + toString(): string; + } +} + +declare namespace graph { + interface Edge extends Element { + outV?: Vertex; + outVLabel?: string; + inV?: Vertex; + inVLabel?: string; + properties?: object; + } + + interface Element { + id: any; + label: string; + } + + class GraphResultSet implements Iterator { + constructor(rs: types.ResultSet); + + first(): any; + + toArray(): any[]; + + values(): Iterator; + + next(value?: any): IteratorResult; + } + + interface Path { + labels: any[]; + objects: any[]; + } + + interface Property { + value: any + key: any + } + + interface Vertex extends Element { + properties?: { [key: string]: any[] } + } + + interface VertexProperty extends Element { + value: any + key: string + properties?: any + } + + function asDouble(value: number): object; + + function asFloat(value: number): object; + + function asInt(value: number): object; + + function asTimestamp(value: Date): object; + + function asUdt(value: object): object; + + interface EnumValue { + toString(): string + } + + namespace t { + const id: EnumValue; + const key: EnumValue; + const label: EnumValue; + const value: EnumValue; + } + + namespace direction { + // `in` is a reserved word + const in_: EnumValue; + const out: EnumValue; + const both: EnumValue; + } +} + +export declare type GraphOptions = { + language?: string; + name?: string; + readConsistency?: types.consistencies; + readTimeout?: number; + source?: string; + writeConsistency?: types.consistencies; +}; + +export declare interface GraphQueryOptions extends QueryOptions { + graphLanguage?: string; + graphName?: string; + graphReadConsistency?: types.consistencies; + graphSource?: string; + graphWriteConsistency?: types.consistencies; +} + +export declare interface Host extends events.EventEmitter { + address: string; + cassandraVersion: string; + datacenter: string; + rack: string; + tokens: string[]; + hostId: types.Uuid; + + canBeConsideredAsUp(): boolean; + + getCassandraVersion(): number[]; + + isUp(): boolean; +} + +export declare interface HostMap extends events.EventEmitter { + length: number; + + forEach(callback: (value: Host, key: string) => void): void; + + get(key: string): Host; + + keys(): string[]; + + values(): Host[]; +} + +export declare namespace mapping { + export interface TableMappings { + getColumnName(propName: string): string; + + getPropertyName(columnName: string): string; + + newObjectInstance(): any; + } + + export class DefaultTableMappings implements TableMappings { + getColumnName(propName: string): string; + + getPropertyName(columnName: string): string; + + newObjectInstance(): any; + } + + export class UnderscoreCqlToCamelCaseMappings implements TableMappings { + getColumnName(propName: string): string; + + getPropertyName(columnName: string): string; + + newObjectInstance(): any; + } + + export interface Result extends Iterator { + wasApplied(): boolean; + + first(): T | null; + + forEach(callback: (currentValue: T, index: number) => void, thisArg?: any): void; + + toArray(): T[]; + } + + export type MappingExecutionOptions = { + executionProfile?: string; + isIdempotent?: boolean; + logged?: boolean; + timestamp?: number | Long; + fetchSize?: number; + pageState?: number; + } + + export interface ModelTables { + name: string; + isView: boolean; + } + + export class Mapper { + constructor(client: Client, options?: MappingOptions); + + batch(items: ModelBatchItem[], executionOptions?: string | MappingExecutionOptions): Promise; + + forModel(name: string): ModelMapper; + } + + export type MappingOptions = { + models: { [key: string]: ModelOptions }; + } + + export type FindDocInfo = { + fields?: string[]; + orderBy?: { [key: string]: string }; + limit?: number; + } + + export type InsertDocInfo = { + fields?: string[]; + ttl?: number; + ifNotExists?: boolean; + } + + export type UpdateDocInfo = { + fields?: string[]; + ttl?: number; + ifExists?: boolean; + when?: { [key: string]: any }; + orderBy?: { [key: string]: string }; + limit?: number; + deleteOnlyColumns?: boolean; + } + + export type RemoveDocInfo = { + fields?: string[]; + ttl?: number; + ifExists?: boolean; + when?: { [key: string]: any }; + deleteOnlyColumns?: boolean; + } + + export type ModelOptions = { + tables?: string[] | ModelTables[]; + mappings?: TableMappings; + columns?: { [key: string]: string|ModelColumnOptions }; + keyspace?: string; + } + + export type ModelColumnOptions = { + name: string; + toModel?: (columnValue: any) => any; + fromModel?: (modelValue: any) => any; + }; + + export interface ModelBatchItem { + + } + + export interface ModelBatchMapper { + insert(doc: any, docInfo?: InsertDocInfo): ModelBatchItem; + + remove(doc: any, docInfo?: RemoveDocInfo): ModelBatchItem; + + update(doc: any, docInfo?: UpdateDocInfo): ModelBatchItem; + } + + export interface ModelMapper { + name: string; + batching: ModelBatchMapper; + + get(doc: { [key: string]: any }, docInfo?: { fields?: string[] }, executionOptions?: string | MappingExecutionOptions): Promise; + + find(doc: { [key: string]: any }, docInfo?: FindDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + + findAll(docInfo?: FindDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + + insert(doc: { [key: string]: any }, docInfo?: InsertDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + + update(doc: { [key: string]: any }, docInfo?: UpdateDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + + remove(doc: { [key: string]: any }, docInfo?: RemoveDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + + mapWithQuery( + query: string, + paramsHandler: (doc: any) => any[], + executionOptions?: string | MappingExecutionOptions + ): (doc: any, executionOptions?: string | MappingExecutionOptions) => Promise>; + } + + export namespace q { + export interface QueryOperator { + + } + + export function in_(arr: any): QueryOperator; + + export function gt(value: any): QueryOperator; + + export function gte(value: any): QueryOperator; + + export function lt(value: any): QueryOperator; + + export function lte(value: any): QueryOperator; + + export function notEq(value: any): QueryOperator; + + export function and(condition1: any, condition2: any): QueryOperator; + + export function incr(value: any): QueryOperator; + + export function decr(value: any): QueryOperator; + + export function append(value: any): QueryOperator; + + export function prepend(value: any): QueryOperator; + + export function remove(value: any): QueryOperator; + } +} + +export declare namespace metadata { + + export interface Aggregate { + argumentTypes: Array<{ code: dataTypes, info: any }>; + finalFunction: string; + initCondition: string; + keyspaceName: string; + returnType: string; + signature: string[]; + stateFunction: string; + stateType: string; + } + + export interface ClientState { + getConnectedHosts(): Host[]; + + getInFlightQueries(host: Host): number; + + getOpenConnections(host: Host): number; + + toString(): string; + } + + export interface DataTypeInfo { + code: dataTypes; + info: string | DataTypeInfo | DataTypeInfo[]; + options: { + frozen: boolean; + reversed: boolean; + }; + } + + export interface ColumnInfo { + name: string; + type: DataTypeInfo; + } + + export enum IndexKind { + custom = 0, + keys, + composites + } + + export interface Index { + kind: IndexKind; + name: string; + options: object; + target: string; + + isCompositesKind(): boolean; + + isCustomKind(): boolean; + + isKeysKind(): boolean; + } + + export interface DataCollection { + bloomFilterFalsePositiveChance: number; + caching: string; + clusteringKeys: ColumnInfo[]; + clusteringOrder: string[]; + columns: ColumnInfo[]; + columnsByName: { [key: string]: ColumnInfo }; + comment: string; + compactionClass: string; + compactionOptions: { [option: string]: any; }; + compression: { + class?: string; + [option: string]: any; + }; + crcCheckChange?: number; + defaultTtl: number; + extensions: { [option: string]: any; }; + gcGraceSeconds: number; + localReadRepairChance: number; + maxIndexInterval?: number; + minIndexInterval?: number; + name: string; + partitionKeys: ColumnInfo[]; + populateCacheOnFlush: boolean; + readRepairChance: number; + speculativeRetry: string; + } + + export interface MaterializedView extends DataCollection { + tableName: string; + whereClause: string; + includeAllColumns: boolean; + } + + export interface TableMetadata extends DataCollection { + indexes: Index[]; + indexInterval?: number; + isCompact: boolean; + memtableFlushPeriod: number; + replicateOnWrite: boolean; + cdc?: boolean; + virtual: boolean; + } + + export interface QueryTrace { + requestType: string; + coordinator: InetAddress; + parameters: { [key: string]: any }; + startedAt: number | types.Long; + duration: number; + clientAddress: string; + events: Array<{ id: Uuid; activity: any; source: any; elapsed: any; thread: any }>; + } + + export interface SchemaFunction { + argumentNames: string[]; + argumentTypes: Array<{ code: dataTypes, info: any }>; + body: string; + calledOnNullInput: boolean; + keyspaceName: string; + language: string; + name: string; + returnType: string; + signature: string[]; + } + + export interface Udt { + name: string; + fields: ColumnInfo[] + } + + export interface Metadata { + keyspaces: { [name: string]: { name: string, strategy: string }}; + + clearPrepared(): void; + + getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: ValueCallback): void; + + getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>): Promise; + + getAggregates(keyspaceName: string, name: string, callback: ValueCallback): void; + + getAggregates(keyspaceName: string, name: string): Promise; + + getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: ValueCallback): void; + + getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>): Promise; + + getFunctions(keyspaceName: string, name: string, callback: ValueCallback): void; + + getFunctions(keyspaceName: string, name: string): Promise; + + getMaterializedView(keyspaceName: string, name: string, callback: ValueCallback): void; + + getMaterializedView(keyspaceName: string, name: string, callback: EmptyCallback): Promise; + + getReplicas(keyspaceName: string, token: Buffer | token.Token | token.TokenRange): Host[]; + + getTable(keyspaceName: string, name: string, callback: ValueCallback): void; + + getTable(keyspaceName: string, name: string): Promise; + + getTokenRanges(): Set; + + getTokenRangesForHost(keyspaceName: string, host: Host): Set | null; + + getTrace(traceId: Uuid, consistency: types.consistencies, callback: ValueCallback): void; + + getTrace(traceId: Uuid, consistency: types.consistencies): Promise; + + getTrace(traceId: Uuid, callback: ValueCallback): void; + + getTrace(traceId: Uuid): Promise; + + getUdt(keyspaceName: string, name: string, callback: ValueCallback): void; + + getUdt(keyspaceName: string, name: string): Promise; + + newToken(components: Buffer[] | Buffer | string): token.Token; + + newTokenRange(start: token.Token, end: token.Token): token.TokenRange; + + refreshKeyspace(name: string, callback: EmptyCallback): void; + + refreshKeyspace(name: string): Promise; + + refreshKeyspaces(waitReconnect: boolean, callback: EmptyCallback): void; + + refreshKeyspaces(waitReconnect?: boolean): Promise; + + refreshKeyspaces(callback: EmptyCallback): void; + } +} + +export declare namespace metrics { + export interface ClientMetrics { + onAuthenticationError(e: Error | errors.AuthenticationError): void; + + onClientTimeoutError(e: errors.OperationTimedOutError): void; + + onClientTimeoutRetry(e: Error): void; + + onConnectionError(e: Error): void; + + onIgnoreError(e: Error): void; + + onOtherError(e: Error): void; + + onOtherErrorRetry(e: Error): void; + + onReadTimeoutError(e: errors.ResponseError): void; + + onReadTimeoutRetry(e: Error): void; + + onResponse(latency: number[]): void; + + onSpeculativeExecution(): void; + + onSuccessfulResponse(latency: number[]): void; + + onUnavailableError(e: errors.ResponseError): void; + + onUnavailableRetry(e: Error): void; + + onWriteTimeoutError(e: errors.ResponseError): void; + + onWriteTimeoutRetry(e: Error): void; + } + + export class DefaultMetrics implements ClientMetrics { + constructor(); + + onAuthenticationError(e: Error | errors.AuthenticationError): void; + + onClientTimeoutError(e: errors.OperationTimedOutError): void; + + onClientTimeoutRetry(e: Error): void; + + onConnectionError(e: Error): void; + + onIgnoreError(e: Error): void; + + onOtherError(e: Error): void; + + onOtherErrorRetry(e: Error): void; + + onReadTimeoutError(e: errors.ResponseError): void; + + onReadTimeoutRetry(e: Error): void; + + onResponse(latency: number[]): void; + + onSpeculativeExecution(): void; + + onSuccessfulResponse(latency: number[]): void; + + onUnavailableError(e: errors.ResponseError): void; + + onUnavailableRetry(e: Error): void; + + onWriteTimeoutError(e: errors.ResponseError): void; + + onWriteTimeoutRetry(e: Error): void; + } +} + +export declare namespace policies { + export function defaultAddressTranslator(): addressResolution.AddressTranslator; + + export function defaultLoadBalancingPolicy(localDc?: string): loadBalancing.LoadBalancingPolicy; + + export function defaultReconnectionPolicy(): reconnection.ReconnectionPolicy; + + export function defaultRetryPolicy(): retry.RetryPolicy; + + export function defaultSpeculativeExecutionPolicy(): speculativeExecution.SpeculativeExecutionPolicy; + + export function defaultTimestampGenerator(): timestampGeneration.TimestampGenerator; + + export namespace addressResolution { + export interface AddressTranslator { + translate(address: string, port: number, callback: Function): void; + } + + export class EC2MultiRegionTranslator implements AddressTranslator { + translate(address: string, port: number, callback: Function): void; + } + } + + export namespace loadBalancing { + export abstract class LoadBalancingPolicy { + init(client: Client, hosts: HostMap, callback: EmptyCallback): void; + + getDistance(host: Host): types.distance; + + newQueryPlan( + keyspace: string, + executionOptions: ExecutionOptions, + callback: (error: Error, iterator: Iterator) => void): void; + + getOptions(): Map; + } + + export class DCAwareRoundRobinPolicy extends LoadBalancingPolicy { + constructor(localDc: string); + } + + export class TokenAwarePolicy extends LoadBalancingPolicy { + constructor(childPolicy: LoadBalancingPolicy); + } + + export class AllowListPolicy extends LoadBalancingPolicy { + constructor(childPolicy: LoadBalancingPolicy, allowList: string[]); + } + + export class WhiteListPolicy extends AllowListPolicy { + } + + export class RoundRobinPolicy extends LoadBalancingPolicy { + constructor(); + } + + export class DefaultLoadBalancingPolicy extends LoadBalancingPolicy { + constructor(options?: { localDc?: string, filter?: (host: Host) => boolean }); + } + } + + export namespace reconnection { + export class ConstantReconnectionPolicy implements ReconnectionPolicy { + constructor(delay: number); + + getOptions(): Map; + + newSchedule(): Iterator; + + } + + export class ExponentialReconnectionPolicy implements ReconnectionPolicy { + constructor(baseDelay: number, maxDelay: number, startWithNoDelay?: boolean); + + getOptions(): Map; + + newSchedule(): Iterator; + } + + export interface ReconnectionPolicy { + getOptions(): Map; + + newSchedule(): Iterator; + } + } + + export namespace retry { + export class DecisionInfo { + decision: number; + consistency: types.consistencies; + } + + export class OperationInfo { + query: string; + executionOptions: ExecutionOptions; + nbRetry: number; + } + + export class IdempotenceAwareRetryPolicy extends RetryPolicy { + constructor(childPolicy: RetryPolicy); + } + + export class FallthroughRetryPolicy extends RetryPolicy { + constructor(); + } + + export class RetryPolicy { + onReadTimeout( + info: OperationInfo, + consistency: types.consistencies, + received: number, + blockFor: number, + isDataPresent: boolean): DecisionInfo; + + onRequestError(info: OperationInfo, consistency: types.consistencies, err: Error): DecisionInfo; + + onUnavailable( + info: OperationInfo, consistency: types.consistencies, required: number, alive: boolean): DecisionInfo; + + onWriteTimeout( + info: OperationInfo, + consistency: types.consistencies, + received: number, + blockFor: number, + writeType: string): DecisionInfo; + + rethrowResult(): DecisionInfo; + + retryResult(consistency: types.consistencies, useCurrentHost?: boolean): DecisionInfo; + } + + export namespace RetryDecision { + export enum retryDecision { + ignore, + rethrow, + retry + } + } + } + + export namespace speculativeExecution { + export class ConstantSpeculativeExecutionPolicy implements SpeculativeExecutionPolicy { + constructor(delay: number, maxSpeculativeExecutions: number); + + getOptions(): Map; + + init(client: Client): void; + + newPlan(keyspace: string, queryInfo: string | Array): { nextExecution: Function }; + + shutdown(): void; + } + + export class NoSpeculativeExecutionPolicy implements SpeculativeExecutionPolicy { + constructor(); + + getOptions(): Map; + + init(client: Client): void; + + newPlan(keyspace: string, queryInfo: string | Array): { nextExecution: Function }; + + shutdown(): void; + } + + export interface SpeculativeExecutionPolicy { + getOptions(): Map; + + init(client: Client): void; + + newPlan(keyspace: string, queryInfo: string|Array): { nextExecution: Function }; + + shutdown(): void; + } + } + + export namespace timestampGeneration { + export class MonotonicTimestampGenerator implements TimestampGenerator { + constructor(warningThreshold: number, minLogInterval: number); + + getDate(): number; + + next(client: Client): types.Long | number; + } + + export interface TimestampGenerator { + next(client: Client): types.Long|number; + } + } +} + +export declare interface QueryOptions { + autoPage?: boolean; + captureStackTrace?: boolean; + consistency?: number; + counter?: boolean; + customPayload?: any; + executionProfile?: string | ExecutionProfile; + fetchSize?: number; + hints?: string[] | string[][]; + host?: Host; + isIdempotent?: boolean; + keyspace?: string; + logged?: boolean; + pageState?: Buffer | string; + prepare?: boolean; + readTimeout?: number; + retry?: policies.retry.RetryPolicy; + routingIndexes?: number[]; + routingKey?: Buffer | Buffer[]; + routingNames?: string[]; + serialConsistency?: number; + timestamp?: number | Long; + traceQuery?: boolean; +} + +export declare namespace token { + export interface Token { + compare(other: Token): number; + + equals(other: Token): boolean; + + getType(): { code: types.dataTypes, info: any }; + + getValue(): any; + } + + export interface TokenRange { + start: Token; + end: Token; + + compare(other: TokenRange): number; + + contains(token: Token): boolean; + + equals(other: TokenRange): boolean; + + isEmpty(): boolean; + + isWrappedAround(): boolean; + + splitEvenly(numberOfSplits: number): TokenRange[]; + + unwrap(): TokenRange[]; + } +} + +export declare namespace tracker { + export interface RequestTracker { + onError( + host: Host, + query: string | Array<{ query: string, params?: any }>, + parameters: any[] | { [key: string]: any } | null, + executionOptions: ExecutionOptions, + requestLength: number, + err: Error, + latency: number[]): void; + + onSuccess( + host: Host, + query: string | Array<{ query: string, params?: any }>, + parameters: any[] | { [key: string]: any } | null, + executionOptions: ExecutionOptions, + requestLength: number, + responseLength: number, + latency: number[]): void; + + shutdown(): void; + } + + export class RequestLogger implements RequestTracker { + constructor(options: { + slowThreshold?: number; + logNormalRequests?: boolean; + logErroredRequests?: boolean; + messageMaxQueryLength?: number; + messageMaxParameterValueLength?: number; + messageMaxErrorStackTraceLength?: number; + }); + + onError(host: Host, query: string | Array<{ query: string; params?: any }>, parameters: any[] | { [p: string]: any } | null, executionOptions: ExecutionOptions, requestLength: number, err: Error, latency: number[]): void; + + onSuccess(host: Host, query: string | Array<{ query: string; params?: any }>, parameters: any[] | { [p: string]: any } | null, executionOptions: ExecutionOptions, requestLength: number, responseLength: number, latency: number[]): void; + + shutdown(): void; + } +} + +export declare namespace types { + export class Long extends _Long { + + } + + export enum consistencies { + any = 0x00, + one = 0x01, + two = 0x02, + three = 0x03, + quorum = 0x04, + all = 0x05, + localQuorum = 0x06, + eachQuorum = 0x07, + serial = 0x08, + localSerial = 0x09, + localOne = 0x0a + } + + export enum dataTypes { + custom = 0x0000, + ascii = 0x0001, + bigint = 0x0002, + blob = 0x0003, + boolean = 0x0004, + counter = 0x0005, + decimal = 0x0006, + double = 0x0007, + float = 0x0008, + int = 0x0009, + text = 0x000a, + timestamp = 0x000b, + uuid = 0x000c, + varchar = 0x000d, + varint = 0x000e, + timeuuid = 0x000f, + inet = 0x0010, + date = 0x0011, + time = 0x0012, + smallint = 0x0013, + tinyint = 0x0014, + duration = 0x0015, + list = 0x0020, + map = 0x0021, + set = 0x0022, + udt = 0x0030, + tuple = 0x0031, + } + + export enum distance { + local = 0, + remote, + ignored + } + + export enum responseErrorCodes { + serverError = 0x0000, + protocolError = 0x000A, + badCredentials = 0x0100, + unavailableException = 0x1000, + overloaded = 0x1001, + isBootstrapping = 0x1002, + truncateError = 0x1003, + writeTimeout = 0x1100, + readTimeout = 0x1200, + readFailure = 0x1300, + functionFailure = 0x1400, + writeFailure = 0x1500, + syntaxError = 0x2000, + unauthorized = 0x2100, + invalid = 0x2200, + configError = 0x2300, + alreadyExists = 0x2400, + unprepared = 0x2500, + clientWriteFailure = 0x8000 + } + + export enum protocolVersion { + v1 = 0x01, + v2 = 0x02, + v3 = 0x03, + v4 = 0x04, + v5 = 0x05, + v6 = 0x06, + dseV1 = 0x41, + dseV2 = 0x42, + maxSupported = dseV2, + minSupported = v1 + } + + export namespace protocolVersion { + export function isSupported(version: protocolVersion): boolean; + } + + const unset: object; + + export class BigDecimal { + constructor(unscaledValue: number, scale: number); + + static fromBuffer(buf: Buffer): BigDecimal; + + static fromString(value: string): BigDecimal; + + static toBuffer(value: BigDecimal): Buffer; + + static fromNumber(value: number): BigDecimal; + + add(other: BigDecimal): BigDecimal; + + compare(other: BigDecimal): number; + + equals(other: BigDecimal): boolean; + + greaterThan(other: BigDecimal): boolean; + + isNegative(): boolean; + + isZero(): boolean; + + notEquals(other: BigDecimal): boolean; + + subtract(other: BigDecimal): BigDecimal; + + toNumber(): number; + + toString(): string; + + toJSON(): string; + } + + export class Duration { + constructor(month: number, days: number, nanoseconds: number | Long); + + static fromBuffer(buffer: Buffer): Duration; + + static fromString(input: string): Duration; + + equals(other: Duration): boolean; + + toBuffer(): Buffer; + + toString(): string; + } + + export class InetAddress { + length: number; + + version: number; + + constructor(buffer: Buffer); + + static fromString(value: string): InetAddress; + + equals(other: InetAddress): boolean; + + getBuffer(): Buffer; + + toString(): string; + + toJSON(): string; + } + + export class Integer { + static ONE: Integer; + static ZERO: Integer; + + constructor(bits: Array, sign: number); + + static fromBits(bits: Array): Integer; + + static fromBuffer(bits: Buffer): Integer; + + static fromInt(value: number): Integer; + + static fromNumber(value: number): Integer; + + static fromString(str: string, opt_radix?: number): Integer; + + static toBuffer(value: Integer): Buffer; + + abs(): Integer; + + add(other: Integer): Integer; + + compare(other: Integer): number; + + divide(other: Integer): Integer; + + equals(other: Integer): boolean; + + getBits(index: number): number; + + getBitsUnsigned(index: number): number; + + getSign(): number; + + greaterThan(other: Integer): boolean; + + greaterThanOrEqual(other: Integer): boolean; + + isNegative(): boolean; + + isOdd(): boolean; + + isZero(): boolean; + + lessThan(other: Integer): boolean; + + lessThanOrEqual(other: Integer): boolean; + + modulo(other: Integer): Integer; + + multiply(other: Integer): Integer; + + negate(): Integer; + + not(): Integer; + + notEquals(other: Integer): boolean; + + or(other: Integer): Integer; + + shiftLeft(numBits: number): Integer; + + shiftRight(numBits: number): Integer; + + shorten(numBits: number): Integer; + + subtract(other: Integer): Integer; + + toInt(): number; + + toJSON(): string; + + toNumber(): number; + + toString(opt_radix?: number): string; + + xor(other: Integer): Integer; + } + + export class LocalDate { + year: number; + month: number; + day: number; + + constructor(year: number, month: number, day: number); + + static fromDate(date: Date): LocalDate; + + static fromString(value: string): LocalDate; + + static fromBuffer(buffer: Buffer): LocalDate; + + static now(): LocalDate; + + static utcNow(): LocalDate; + + equals(other: LocalDate): boolean; + + inspect(): string; + + toBuffer(): Buffer; + + toJSON(): string; + + toString(): string; + } + + export class LocalTime { + hour: number; + minute: number; + nanosecond: number; + second: number; + + constructor(totalNanoseconds: Long); + + static fromBuffer(value: Buffer): LocalTime; + + static fromDate(date: Date, nanoseconds: number): LocalTime; + + static fromMilliseconds(milliseconds: number, nanoseconds?: number): LocalTime; + + static fromString(value: string): LocalTime; + + static now(nanoseconds?: number): LocalTime; + + compare(other: LocalTime): boolean; + + equals(other: LocalTime): boolean; + + getTotalNanoseconds(): Long; + + inspect(): string; + + toBuffer(): Buffer; + + toJSON(): string; + + toString(): string; + } + + export interface ResultSet extends Iterable, AsyncIterable { + info: { + queriedHost: string, + triedHosts: { [key: string]: any; }, + speculativeExecutions: number, + achievedConsistency: consistencies, + traceId: Uuid, + warnings: string[], + customPayload: any + }; + + columns: Array<{ name: string, type: { code: dataTypes, info: any } }>; + nextPage: (() => void) | null; + pageState: string; + rowLength: number; + rows: Row[]; + + first(): Row; + + wasApplied(): boolean; + } + + export interface ResultStream extends stream.Readable { + buffer: Buffer; + paused: boolean; + + add(chunk: Buffer): void; + } + + export interface Row { + get(columnName: string | number): any; + + keys(): string[]; + + forEach(callback: (row: Row) => void): void; + + values(): any[]; + + [key: string]: any; + } + + export class TimeUuid extends Uuid { + static now(): TimeUuid; + + static now(nodeId: string | Buffer, clockId?: string | Buffer): TimeUuid; + + static now(nodeId: string | Buffer, clockId: string | Buffer, callback: ValueCallback): void; + + static now(callback: ValueCallback): void; + + static fromDate(date: Date, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid; + + static fromDate( + date: Date, + ticks: number, + nodeId: string | Buffer, + clockId: string | Buffer, + callback: ValueCallback): void; + + static fromString(value: string): TimeUuid; + + static max(date: Date, ticks: number): TimeUuid; + + static min(date: Date, ticks: number): TimeUuid; + + getDatePrecision(): { date: Date, ticks: number }; + + getDate(): Date; + } + + export class Tuple { + elements: any[]; + length: number; + + constructor(...args: any[]); + + static fromArray(elements: any[]): Tuple; + + get(index: number): any; + + toString(): string; + + toJSON(): string; + + values(): any[]; + } + + export class Uuid { + constructor(buffer: Buffer); + + static fromString(value: string): Uuid; + + static random(callback: ValueCallback): void; + + static random(): Uuid; + + equals(other: Uuid): boolean; + + getBuffer(): Buffer; + + toString(): string; + + toJSON(): string; + } +} + +export declare type ValueCallback = (err: Error, val: T) => void; + +export declare const version: number; + +export { } diff --git a/etc/cassandra-driver.api.md b/etc/cassandra-driver.api.md new file mode 100644 index 000000000..cc947e4d2 --- /dev/null +++ b/etc/cassandra-driver.api.md @@ -0,0 +1,2221 @@ +## API Report File for "cassandra-driver" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import * as events from 'events'; +import _Long = require('long'); +import { Readable } from 'stream'; +import * as stream from 'stream'; +import * as tls from 'tls'; +import { URL as URL_2 } from 'url'; + +// @public (undocumented) +export type ArrayOrObject = any[]|{[key: string]: any}; + +// @public (undocumented) +export namespace auth { + // (undocumented) + export interface Authenticator { + // (undocumented) + evaluateChallenge(challenge: Buffer, callback: Function): void; + + // (undocumented) + initialResponse(callback: Function): void; + + // (undocumented) + onAuthenticationSuccess(token?: Buffer): void; + } + + // (undocumented) + export interface AuthProvider { + // (undocumented) + newAuthenticator(endpoint: string, name: string): Authenticator; + } + + // (undocumented) + export class DseGssapiAuthProvider implements AuthProvider { + constructor(gssOptions?: { authorizationId?: string, service?: string, hostNameResolver?: Function }); + + // (undocumented) + newAuthenticator(endpoint: string, name: string): Authenticator; + } + + // (undocumented) + export class DsePlainTextAuthProvider implements AuthProvider { + constructor(username: string, password: string, authorizationId?: string); + + // (undocumented) + newAuthenticator(endpoint: string, name: string): Authenticator; + } + + // (undocumented) + export class PlainTextAuthProvider implements AuthProvider { + constructor(username: string, password: string); + + // (undocumented) + newAuthenticator(endpoint: string, name: string): Authenticator; + } +} + +// @public (undocumented) +export class Client extends events.EventEmitter { + constructor(options: DseClientOptions); + // (undocumented) + batch( + queries: Array, + options?: QueryOptions): Promise; + // (undocumented) + batch( + queries: Array, + options: QueryOptions, + callback: ValueCallback): void; + // (undocumented) + batch( + queries: Array, + callback: ValueCallback): void; + // (undocumented) + connect(): Promise; + // (undocumented) + connect(callback: EmptyCallback): void; + // (undocumented) + eachRow(query: string, + params: ArrayOrObject, + options: QueryOptions, + rowCallback: (n: number, row: types.Row) => void, + callback?: ValueCallback): void; + // (undocumented) + eachRow(query: string, + params: ArrayOrObject, + rowCallback: (n: number, row: types.Row) => void, + callback?: ValueCallback): void; + // (undocumented) + eachRow(query: string, + rowCallback: (n: number, row: types.Row) => void): void; + // (undocumented) + execute(query: string, params?: ArrayOrObject, options?: QueryOptions): Promise; + // (undocumented) + execute(query: string, params: ArrayOrObject, options: QueryOptions, callback: ValueCallback): void; + // (undocumented) + execute(query: string, params: ArrayOrObject, callback: ValueCallback): void; + // (undocumented) + execute(query: string, callback: ValueCallback): void; + // Warning: (ae-forgotten-export) The symbol "graph" needs to be exported by the entry point index.d.ts + // + // (undocumented) + executeGraph( + traversal: string, + parameters: { [name: string]: any } | undefined, + options: GraphQueryOptions, + callback: ValueCallback): void; + // (undocumented) + executeGraph( + traversal: string, + parameters: { [name: string]: any } | undefined, + callback: ValueCallback): void; + // (undocumented) + executeGraph(traversal: string, callback: ValueCallback): void; + // (undocumented) + executeGraph( + traversal: string, + parameters?: { [name: string]: any }, + options?: GraphQueryOptions): Promise; + // (undocumented) + getReplicas(keyspace: string, token: Buffer): Host[]; + // (undocumented) + getState(): metadata.ClientState; + // (undocumented) + hosts: HostMap; + // (undocumented) + keyspace: string; + // (undocumented) + metadata: metadata.Metadata; + // (undocumented) + metrics: metrics.ClientMetrics; + // (undocumented) + shutdown(): Promise; + // (undocumented) + shutdown(callback: EmptyCallback): void; + // (undocumented) + stream(query: string, params?: ArrayOrObject, options?: QueryOptions, callback?: EmptyCallback): events.EventEmitter; +} + +// @public (undocumented) +export interface ClientOptions { + // (undocumented) + authProvider?: auth.AuthProvider; + // (undocumented) + cloud?: { + secureConnectBundle: string | URL_2; + }; + // (undocumented) + contactPoints?: string[]; + // (undocumented) + credentials?: { + username: string; + password: string; + } + // (undocumented) + encoding?: { + map?: Function; + set?: Function; + copyBuffer?: boolean; + useUndefinedAsUnset?: boolean; + useBigIntAsLong?: boolean; + useBigIntAsVarint?: boolean; + }; + // (undocumented) + isMetadataSyncEnabled?: boolean; + // (undocumented) + keyspace?: string; + // (undocumented) + localDataCenter?: string; + // (undocumented) + maxPrepared?: number; + // (undocumented) + metrics?: metrics.ClientMetrics; + // (undocumented) + policies?: { + addressResolution?: policies.addressResolution.AddressTranslator; + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + reconnection?: policies.reconnection.ReconnectionPolicy; + retry?: policies.retry.RetryPolicy; + speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy; + timestampGeneration?: policies.timestampGeneration.TimestampGenerator; + }; + // (undocumented) + pooling?: { + coreConnectionsPerHost?: { [key: number]: number; }; + heartBeatInterval?: number; + maxRequestsPerConnection?: number; + warmup?: boolean; + }; + // (undocumented) + prepareOnAllHosts?: boolean; + // (undocumented) + profiles?: ExecutionProfile[]; + // (undocumented) + promiseFactory?: (handler: (callback: (err: Error, result?: any) => void) => void) => Promise; + // (undocumented) + protocolOptions?: { + maxSchemaAgreementWaitSeconds?: number; + maxVersion?: number; + noCompact?: boolean; + port?: number; + }; + // (undocumented) + queryOptions?: QueryOptions; + // (undocumented) + refreshSchemaDelay?: number; + // (undocumented) + rePrepareOnUp?: boolean; + // (undocumented) + requestTracker?: tracker.RequestTracker; + // (undocumented) + socketOptions?: { + coalescingThreshold?: number; + connectTimeout?: number; + defunctReadTimeoutThreshold?: number; + keepAlive?: boolean; + keepAliveDelay?: number; + readTimeout?: number; + tcpNoDelay?: boolean; + }; + // (undocumented) + sslOptions?: tls.ConnectionOptions; +} + +// @public (undocumented) +export namespace concurrent { + // (undocumented) + export function executeConcurrent( + client: Client, + query: string, + parameters: any[][]|Readable, + options?: Options): Promise; + + // (undocumented) + export function executeConcurrent( + client: Client, + queries: Array<{query: string, params: any[]}>, + options?: Options): Promise; + + // (undocumented) + export type Options = { + collectResults?: boolean; + concurrencyLevel?: number; + executionProfile?: string; + maxErrors?: number; + raiseOnFirstError?: boolean; + } + + // (undocumented) + export interface ResultSetGroup { + // (undocumented) + errors: Error[]; + // (undocumented) + resultItems: any[]; + // (undocumented) + totalExecuted: number; + } +} + +// @public (undocumented) +export namespace datastax { + import graph = graphModule.graph; + + import search = searchModule.search; +} + +// @public (undocumented) +export function defaultOptions(): ClientOptions; + +// @public (undocumented) +export interface DseClientOptions extends ClientOptions { + // (undocumented) + applicationName?: string; + // (undocumented) + applicationVersion?: string; + // (undocumented) + graphOptions?: GraphOptions; + // (undocumented) + id?: Uuid; + // (undocumented) + monitorReporting?: { enabled?: boolean }; +} + +// @public (undocumented) +export type EmptyCallback = (err: Error) => void; + +// @public (undocumented) +export namespace errors { + // (undocumented) + export class ArgumentError extends DriverError { + constructor(message: string); + } + + // (undocumented) + export class AuthenticationError extends DriverError { + constructor(message: string); + } + + // (undocumented) + export class BusyConnectionError extends DriverError { + constructor(address: string, maxRequestsPerConnection: number, connectionLength: number); + } + + // (undocumented) + export abstract class DriverError extends Error { + constructor(message: string, constructor?: any); + + // (undocumented) + info: string; + } + + // (undocumented) + export class DriverInternalError extends DriverError { + constructor(message: string); + } + + // (undocumented) + export class NoHostAvailableError extends DriverError { + constructor(innerErrors: any, message?: string); + + // (undocumented) + innerErrors: any; + } + + // (undocumented) + export class NotSupportedError extends DriverError { + constructor(message: string); + } + + // (undocumented) + export class OperationTimedOutError extends DriverError { + constructor(message: string, host?: string); + + // (undocumented) + host?: string; + } + + // (undocumented) + export class ResponseError extends DriverError { + constructor(code: number, message: string); + + // (undocumented) + code: number; + } +} + +// @public (undocumented) +export interface ExecutionOptions { + // (undocumented) + getCaptureStackTrace(): boolean; + + // (undocumented) + getConsistency(): types.consistencies; + + // (undocumented) + getCustomPayload(): { [key: string]: any }; + + // (undocumented) + getFetchSize(): number; + + // (undocumented) + getFixedHost(): Host; + + // (undocumented) + getHints(): string[] | string[][]; + + // (undocumented) + getKeyspace(): string; + + // (undocumented) + getLoadBalancingPolicy(): policies.loadBalancing.LoadBalancingPolicy; + + // (undocumented) + getPageState(): Buffer; + + // (undocumented) + getRawQueryOptions(): QueryOptions; + + // (undocumented) + getReadTimeout(): number; + + // (undocumented) + getRetryPolicy(): policies.retry.RetryPolicy; + + // (undocumented) + getRoutingKey(): Buffer | Buffer[]; + + // (undocumented) + getSerialConsistency(): types.consistencies; + + // (undocumented) + getTimestamp(): number | Long | undefined | null; + + // (undocumented) + isAutoPage(): boolean; + + // (undocumented) + isBatchCounter(): boolean; + + // (undocumented) + isBatchLogged(): boolean; + + // (undocumented) + isIdempotent(): boolean; + + // (undocumented) + isPrepared(): boolean; + + // (undocumented) + isQueryTracing(): boolean; + + // (undocumented) + setHints(hints: string[]): void; +} + +// @public (undocumented) +export class ExecutionProfile { + constructor(name: string, options: { + consistency?: types.consistencies; + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + readTimeout?: number; + retry?: policies.retry.RetryPolicy; + serialConsistency?: types.consistencies; + graphOptions?: { + name?: string; + language?: string; + source?: string; + readConsistency?: types.consistencies; + writeConsistency?: types.consistencies; + }; + }); + // (undocumented) + consistency?: types.consistencies; + // (undocumented) + graphOptions?: { + name?: string; + language?: string; + source?: string; + readConsistency?: types.consistencies; + writeConsistency?: types.consistencies; + }; + // (undocumented) + loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; + // (undocumented) + name: string; + // (undocumented) + readTimeout?: number; + // (undocumented) + retry?: policies.retry.RetryPolicy; + // (undocumented) + serialConsistency?: types.consistencies; +} + +// @public (undocumented) +export namespace geometry { + // (undocumented) + export class LineString { + constructor(...args: Point[]); + + // (undocumented) + equals(other: LineString): boolean; + + // (undocumented) + static fromBuffer(buffer: Buffer): LineString; + + // (undocumented) + static fromString(textValue: string): LineString; + + // (undocumented) + toBuffer(): Buffer; + + // (undocumented) + toJSON(): string; + + // (undocumented) + toString(): string; + + } + + // (undocumented) + export class Point { + constructor(x: number, y: number); + + // (undocumented) + equals(other: Point): boolean; + + // (undocumented) + static fromBuffer(buffer: Buffer): Point; + + // (undocumented) + static fromString(textValue: string): Point; + + // (undocumented) + toBuffer(): Buffer; + + // (undocumented) + toJSON(): string; + + // (undocumented) + toString(): string; + + } + + // (undocumented) + export class Polygon { + constructor(...args: Point[]); + + // (undocumented) + equals(other: Polygon): boolean; + + // (undocumented) + static fromBuffer(buffer: Buffer): Polygon; + + // (undocumented) + static fromString(textValue: string): Polygon; + + // (undocumented) + toBuffer(): Buffer; + + // (undocumented) + toJSON(): string; + + // (undocumented) + toString(): string; + } +} + +// @public (undocumented) +export type GraphOptions = { + language?: string; + name?: string; + readConsistency?: types.consistencies; + readTimeout?: number; + source?: string; + writeConsistency?: types.consistencies; +}; + +// @public (undocumented) +export interface GraphQueryOptions extends QueryOptions { + // (undocumented) + graphLanguage?: string; + // (undocumented) + graphName?: string; + // (undocumented) + graphReadConsistency?: types.consistencies; + // (undocumented) + graphSource?: string; + // (undocumented) + graphWriteConsistency?: types.consistencies; +} + +// @public (undocumented) +export interface Host extends events.EventEmitter { + // (undocumented) + address: string; + // (undocumented) + canBeConsideredAsUp(): boolean; + // (undocumented) + cassandraVersion: string; + // (undocumented) + datacenter: string; + // (undocumented) + getCassandraVersion(): number[]; + // (undocumented) + hostId: types.Uuid; + // (undocumented) + isUp(): boolean; + // (undocumented) + rack: string; + // (undocumented) + tokens: string[]; +} + +// @public (undocumented) +export interface HostMap extends events.EventEmitter { + // (undocumented) + forEach(callback: (value: Host, key: string) => void): void; + + // (undocumented) + get(key: string): Host; + + // (undocumented) + keys(): string[]; + + // (undocumented) + length: number; + + // (undocumented) + values(): Host[]; +} + +// @public (undocumented) +export namespace mapping { + // (undocumented) + export class DefaultTableMappings implements TableMappings { + // (undocumented) + getColumnName(propName: string): string; + + // (undocumented) + getPropertyName(columnName: string): string; + + // (undocumented) + newObjectInstance(): any; + } + + // (undocumented) + export type FindDocInfo = { + fields?: string[]; + orderBy?: { [key: string]: string }; + limit?: number; + } + + // (undocumented) + export type InsertDocInfo = { + fields?: string[]; + ttl?: number; + ifNotExists?: boolean; + } + + // (undocumented) + export class Mapper { + constructor(client: Client, options?: MappingOptions); + + // (undocumented) + batch(items: ModelBatchItem[], executionOptions?: string | MappingExecutionOptions): Promise; + + // (undocumented) + forModel(name: string): ModelMapper; + } + + // (undocumented) + export type MappingExecutionOptions = { + executionProfile?: string; + isIdempotent?: boolean; + logged?: boolean; + timestamp?: number | Long; + fetchSize?: number; + pageState?: number; + } + + // (undocumented) + export type MappingOptions = { + models: { [key: string]: ModelOptions }; + } + + // (undocumented) + export interface ModelBatchItem { + + } + + // (undocumented) + export interface ModelBatchMapper { + // (undocumented) + insert(doc: any, docInfo?: InsertDocInfo): ModelBatchItem; + + // (undocumented) + remove(doc: any, docInfo?: RemoveDocInfo): ModelBatchItem; + + // (undocumented) + update(doc: any, docInfo?: UpdateDocInfo): ModelBatchItem; + } + + // (undocumented) + export type ModelColumnOptions = { + name: string; + toModel?: (columnValue: any) => any; + fromModel?: (modelValue: any) => any; + }; + + // (undocumented) + export interface ModelMapper { + // (undocumented) + batching: ModelBatchMapper; + // (undocumented) + find(doc: { [key: string]: any }, docInfo?: FindDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + // (undocumented) + findAll(docInfo?: FindDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + // (undocumented) + get(doc: { [key: string]: any }, docInfo?: { fields?: string[] }, executionOptions?: string | MappingExecutionOptions): Promise; + // (undocumented) + insert(doc: { [key: string]: any }, docInfo?: InsertDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + // (undocumented) + mapWithQuery( + query: string, + paramsHandler: (doc: any) => any[], + executionOptions?: string | MappingExecutionOptions + ): (doc: any, executionOptions?: string | MappingExecutionOptions) => Promise>; + // (undocumented) + name: string; + // (undocumented) + remove(doc: { [key: string]: any }, docInfo?: RemoveDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + // (undocumented) + update(doc: { [key: string]: any }, docInfo?: UpdateDocInfo, executionOptions?: string | MappingExecutionOptions): Promise>; + } + + // (undocumented) + export type ModelOptions = { + tables?: string[] | ModelTables[]; + mappings?: TableMappings; + columns?: { [key: string]: string|ModelColumnOptions }; + keyspace?: string; + } + + // (undocumented) + export interface ModelTables { + // (undocumented) + isView: boolean; + // (undocumented) + name: string; + } + + // (undocumented) + export namespace q { + // (undocumented) + export function and(condition1: any, condition2: any): QueryOperator; + + // (undocumented) + export function append(value: any): QueryOperator; + + // (undocumented) + export function decr(value: any): QueryOperator; + + // (undocumented) + export function gt(value: any): QueryOperator; + + // (undocumented) + export function gte(value: any): QueryOperator; + + // (undocumented) + export function in_(arr: any): QueryOperator; + + // (undocumented) + export function incr(value: any): QueryOperator; + + // (undocumented) + export function lt(value: any): QueryOperator; + + // (undocumented) + export function lte(value: any): QueryOperator; + + // (undocumented) + export function notEq(value: any): QueryOperator; + + // (undocumented) + export function prepend(value: any): QueryOperator; + + // (undocumented) + export interface QueryOperator { + + } + + // (undocumented) + export function remove(value: any): QueryOperator; + } + + // (undocumented) + export type RemoveDocInfo = { + fields?: string[]; + ttl?: number; + ifExists?: boolean; + when?: { [key: string]: any }; + deleteOnlyColumns?: boolean; + } + + // (undocumented) + export interface Result extends Iterator { + // (undocumented) + first(): T | null; + + // (undocumented) + forEach(callback: (currentValue: T, index: number) => void, thisArg?: any): void; + + // (undocumented) + toArray(): T[]; + + // (undocumented) + wasApplied(): boolean; + } + + // (undocumented) + export interface TableMappings { + // (undocumented) + getColumnName(propName: string): string; + + // (undocumented) + getPropertyName(columnName: string): string; + + // (undocumented) + newObjectInstance(): any; + } + + // (undocumented) + export class UnderscoreCqlToCamelCaseMappings implements TableMappings { + // (undocumented) + getColumnName(propName: string): string; + + // (undocumented) + getPropertyName(columnName: string): string; + + // (undocumented) + newObjectInstance(): any; + } + + // (undocumented) + export type UpdateDocInfo = { + fields?: string[]; + ttl?: number; + ifExists?: boolean; + when?: { [key: string]: any }; + orderBy?: { [key: string]: string }; + limit?: number; + deleteOnlyColumns?: boolean; + } +} + +// @public (undocumented) +export namespace metadata { + + // (undocumented) + export interface Aggregate { + // (undocumented) + argumentTypes: Array<{ code: dataTypes, info: any }>; + // (undocumented) + finalFunction: string; + // (undocumented) + initCondition: string; + // (undocumented) + keyspaceName: string; + // (undocumented) + returnType: string; + // (undocumented) + signature: string[]; + // (undocumented) + stateFunction: string; + // (undocumented) + stateType: string; + } + + // (undocumented) + export interface ClientState { + // (undocumented) + getConnectedHosts(): Host[]; + + // (undocumented) + getInFlightQueries(host: Host): number; + + // (undocumented) + getOpenConnections(host: Host): number; + + // (undocumented) + toString(): string; + } + + // (undocumented) + export interface ColumnInfo { + // (undocumented) + name: string; + // (undocumented) + type: DataTypeInfo; + } + + // (undocumented) + export interface DataCollection { + // (undocumented) + bloomFilterFalsePositiveChance: number; + // (undocumented) + caching: string; + // (undocumented) + clusteringKeys: ColumnInfo[]; + // (undocumented) + clusteringOrder: string[]; + // (undocumented) + columns: ColumnInfo[]; + // (undocumented) + columnsByName: { [key: string]: ColumnInfo }; + // (undocumented) + comment: string; + // (undocumented) + compactionClass: string; + // (undocumented) + compactionOptions: { [option: string]: any; }; + // (undocumented) + compression: { + class?: string; + [option: string]: any; + }; + // (undocumented) + crcCheckChange?: number; + // (undocumented) + defaultTtl: number; + // (undocumented) + extensions: { [option: string]: any; }; + // (undocumented) + gcGraceSeconds: number; + // (undocumented) + localReadRepairChance: number; + // (undocumented) + maxIndexInterval?: number; + // (undocumented) + minIndexInterval?: number; + // (undocumented) + name: string; + // (undocumented) + partitionKeys: ColumnInfo[]; + // (undocumented) + populateCacheOnFlush: boolean; + // (undocumented) + readRepairChance: number; + // (undocumented) + speculativeRetry: string; + } + + // (undocumented) + export interface DataTypeInfo { + // (undocumented) + code: dataTypes; + // (undocumented) + info: string | DataTypeInfo | DataTypeInfo[]; + // (undocumented) + options: { + frozen: boolean; + reversed: boolean; + }; + } + + // (undocumented) + export interface Index { + // (undocumented) + isCompositesKind(): boolean; + // (undocumented) + isCustomKind(): boolean; + // (undocumented) + isKeysKind(): boolean; + // (undocumented) + kind: IndexKind; + // (undocumented) + name: string; + // (undocumented) + options: object; + // (undocumented) + target: string; + } + + // (undocumented) + export enum IndexKind { + // (undocumented) + composites, + // (undocumented) + custom = 0, + // (undocumented) + keys + } + + // (undocumented) + export interface MaterializedView extends DataCollection { + // (undocumented) + includeAllColumns: boolean; + // (undocumented) + tableName: string; + // (undocumented) + whereClause: string; + } + + // (undocumented) + export interface Metadata { + // (undocumented) + clearPrepared(): void; + + // (undocumented) + getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: ValueCallback): void; + + // (undocumented) + getAggregate(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>): Promise; + + // (undocumented) + getAggregates(keyspaceName: string, name: string, callback: ValueCallback): void; + + // (undocumented) + getAggregates(keyspaceName: string, name: string): Promise; + + // (undocumented) + getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>, callback: ValueCallback): void; + + // (undocumented) + getFunction(keyspaceName: string, name: string, signature: string[] | Array<{ code: number, info: any }>): Promise; + + // (undocumented) + getFunctions(keyspaceName: string, name: string, callback: ValueCallback): void; + + // (undocumented) + getFunctions(keyspaceName: string, name: string): Promise; + + // (undocumented) + getMaterializedView(keyspaceName: string, name: string, callback: ValueCallback): void; + + // (undocumented) + getMaterializedView(keyspaceName: string, name: string, callback: EmptyCallback): Promise; + + // (undocumented) + getReplicas(keyspaceName: string, token: Buffer | token.Token | token.TokenRange): Host[]; + + // (undocumented) + getTable(keyspaceName: string, name: string, callback: ValueCallback): void; + + // (undocumented) + getTable(keyspaceName: string, name: string): Promise; + + // (undocumented) + getTokenRanges(): Set; + + // (undocumented) + getTokenRangesForHost(keyspaceName: string, host: Host): Set | null; + + // (undocumented) + getTrace(traceId: Uuid, consistency: types.consistencies, callback: ValueCallback): void; + + // (undocumented) + getTrace(traceId: Uuid, consistency: types.consistencies): Promise; + + // (undocumented) + getTrace(traceId: Uuid, callback: ValueCallback): void; + + // (undocumented) + getTrace(traceId: Uuid): Promise; + + // (undocumented) + getUdt(keyspaceName: string, name: string, callback: ValueCallback): void; + + // (undocumented) + getUdt(keyspaceName: string, name: string): Promise; + + // (undocumented) + keyspaces: { [name: string]: { name: string, strategy: string }}; + + // (undocumented) + newToken(components: Buffer[] | Buffer | string): token.Token; + + // (undocumented) + newTokenRange(start: token.Token, end: token.Token): token.TokenRange; + + // (undocumented) + refreshKeyspace(name: string, callback: EmptyCallback): void; + + // (undocumented) + refreshKeyspace(name: string): Promise; + + // (undocumented) + refreshKeyspaces(waitReconnect: boolean, callback: EmptyCallback): void; + + // (undocumented) + refreshKeyspaces(waitReconnect?: boolean): Promise; + + // (undocumented) + refreshKeyspaces(callback: EmptyCallback): void; + } + + // (undocumented) + export interface QueryTrace { + // (undocumented) + clientAddress: string; + // (undocumented) + coordinator: InetAddress; + // (undocumented) + duration: number; + // (undocumented) + events: Array<{ id: Uuid; activity: any; source: any; elapsed: any; thread: any }>; + // (undocumented) + parameters: { [key: string]: any }; + // (undocumented) + requestType: string; + // (undocumented) + startedAt: number | types.Long; + } + + // (undocumented) + export interface SchemaFunction { + // (undocumented) + argumentNames: string[]; + // (undocumented) + argumentTypes: Array<{ code: dataTypes, info: any }>; + // (undocumented) + body: string; + // (undocumented) + calledOnNullInput: boolean; + // (undocumented) + keyspaceName: string; + // (undocumented) + language: string; + // (undocumented) + name: string; + // (undocumented) + returnType: string; + // (undocumented) + signature: string[]; + } + + // (undocumented) + export interface TableMetadata extends DataCollection { + // (undocumented) + cdc?: boolean; + // (undocumented) + indexes: Index[]; + // (undocumented) + indexInterval?: number; + // (undocumented) + isCompact: boolean; + // (undocumented) + memtableFlushPeriod: number; + // (undocumented) + replicateOnWrite: boolean; + // (undocumented) + virtual: boolean; + } + + // (undocumented) + export interface Udt { + // (undocumented) + fields: ColumnInfo[] + // (undocumented) + name: string; + } +} + +// @public (undocumented) +export namespace metrics { + // (undocumented) + export interface ClientMetrics { + // (undocumented) + onAuthenticationError(e: Error | errors.AuthenticationError): void; + + // (undocumented) + onClientTimeoutError(e: errors.OperationTimedOutError): void; + + // (undocumented) + onClientTimeoutRetry(e: Error): void; + + // (undocumented) + onConnectionError(e: Error): void; + + // (undocumented) + onIgnoreError(e: Error): void; + + // (undocumented) + onOtherError(e: Error): void; + + // (undocumented) + onOtherErrorRetry(e: Error): void; + + // (undocumented) + onReadTimeoutError(e: errors.ResponseError): void; + + // (undocumented) + onReadTimeoutRetry(e: Error): void; + + // (undocumented) + onResponse(latency: number[]): void; + + // (undocumented) + onSpeculativeExecution(): void; + + // (undocumented) + onSuccessfulResponse(latency: number[]): void; + + // (undocumented) + onUnavailableError(e: errors.ResponseError): void; + + // (undocumented) + onUnavailableRetry(e: Error): void; + + // (undocumented) + onWriteTimeoutError(e: errors.ResponseError): void; + + // (undocumented) + onWriteTimeoutRetry(e: Error): void; + } + + // (undocumented) + export class DefaultMetrics implements ClientMetrics { + constructor(); + + // (undocumented) + onAuthenticationError(e: Error | errors.AuthenticationError): void; + + // (undocumented) + onClientTimeoutError(e: errors.OperationTimedOutError): void; + + // (undocumented) + onClientTimeoutRetry(e: Error): void; + + // (undocumented) + onConnectionError(e: Error): void; + + // (undocumented) + onIgnoreError(e: Error): void; + + // (undocumented) + onOtherError(e: Error): void; + + // (undocumented) + onOtherErrorRetry(e: Error): void; + + // (undocumented) + onReadTimeoutError(e: errors.ResponseError): void; + + // (undocumented) + onReadTimeoutRetry(e: Error): void; + + // (undocumented) + onResponse(latency: number[]): void; + + // (undocumented) + onSpeculativeExecution(): void; + + // (undocumented) + onSuccessfulResponse(latency: number[]): void; + + // (undocumented) + onUnavailableError(e: errors.ResponseError): void; + + // (undocumented) + onUnavailableRetry(e: Error): void; + + // (undocumented) + onWriteTimeoutError(e: errors.ResponseError): void; + + // (undocumented) + onWriteTimeoutRetry(e: Error): void; + } +} + +// @public (undocumented) +export namespace policies { + // (undocumented) + export namespace addressResolution { + // (undocumented) + export interface AddressTranslator { + // (undocumented) + translate(address: string, port: number, callback: Function): void; + } + + // (undocumented) + export class EC2MultiRegionTranslator implements AddressTranslator { + // (undocumented) + translate(address: string, port: number, callback: Function): void; + } + } + + // (undocumented) + export function defaultAddressTranslator(): addressResolution.AddressTranslator; + + // (undocumented) + export function defaultLoadBalancingPolicy(localDc?: string): loadBalancing.LoadBalancingPolicy; + + // (undocumented) + export function defaultReconnectionPolicy(): reconnection.ReconnectionPolicy; + + // (undocumented) + export function defaultRetryPolicy(): retry.RetryPolicy; + + // (undocumented) + export function defaultSpeculativeExecutionPolicy(): speculativeExecution.SpeculativeExecutionPolicy; + + // (undocumented) + export function defaultTimestampGenerator(): timestampGeneration.TimestampGenerator; + + // (undocumented) + export namespace loadBalancing { + // (undocumented) + export class AllowListPolicy extends LoadBalancingPolicy { + constructor(childPolicy: LoadBalancingPolicy, allowList: string[]); + } + + // (undocumented) + export class DCAwareRoundRobinPolicy extends LoadBalancingPolicy { + constructor(localDc: string); + } + + // (undocumented) + export class DefaultLoadBalancingPolicy extends LoadBalancingPolicy { + constructor(options?: { localDc?: string, filter?: (host: Host) => boolean }); + } + + // (undocumented) + export abstract class LoadBalancingPolicy { + // (undocumented) + getDistance(host: Host): types.distance; + + // (undocumented) + getOptions(): Map; + + // (undocumented) + init(client: Client, hosts: HostMap, callback: EmptyCallback): void; + + // (undocumented) + newQueryPlan( + keyspace: string, + executionOptions: ExecutionOptions, + callback: (error: Error, iterator: Iterator) => void): void; + } + + // (undocumented) + export class RoundRobinPolicy extends LoadBalancingPolicy { + constructor(); + } + + // (undocumented) + export class TokenAwarePolicy extends LoadBalancingPolicy { + constructor(childPolicy: LoadBalancingPolicy); + } + + // (undocumented) + export class WhiteListPolicy extends AllowListPolicy { + } + } + + // (undocumented) + export namespace reconnection { + // (undocumented) + export class ConstantReconnectionPolicy implements ReconnectionPolicy { + constructor(delay: number); + + // (undocumented) + getOptions(): Map; + + // (undocumented) + newSchedule(): Iterator; + + } + + // (undocumented) + export class ExponentialReconnectionPolicy implements ReconnectionPolicy { + constructor(baseDelay: number, maxDelay: number, startWithNoDelay?: boolean); + + // (undocumented) + getOptions(): Map; + + // (undocumented) + newSchedule(): Iterator; + } + + // (undocumented) + export interface ReconnectionPolicy { + // (undocumented) + getOptions(): Map; + + // (undocumented) + newSchedule(): Iterator; + } + } + + // (undocumented) + export namespace retry { + // (undocumented) + export class DecisionInfo { + // (undocumented) + consistency: types.consistencies; + // (undocumented) + decision: number; + } + + // (undocumented) + export class FallthroughRetryPolicy extends RetryPolicy { + constructor(); + } + + // (undocumented) + export class IdempotenceAwareRetryPolicy extends RetryPolicy { + constructor(childPolicy: RetryPolicy); + } + + // (undocumented) + export class OperationInfo { + // (undocumented) + executionOptions: ExecutionOptions; + // (undocumented) + nbRetry: number; + // (undocumented) + query: string; + } + + // (undocumented) + export namespace RetryDecision { + // (undocumented) + export enum retryDecision { + // (undocumented) + ignore, + // (undocumented) + rethrow, + // (undocumented) + retry + } + } + + // (undocumented) + export class RetryPolicy { + // (undocumented) + onReadTimeout( + info: OperationInfo, + consistency: types.consistencies, + received: number, + blockFor: number, + isDataPresent: boolean): DecisionInfo; + + // (undocumented) + onRequestError(info: OperationInfo, consistency: types.consistencies, err: Error): DecisionInfo; + + // (undocumented) + onUnavailable( + info: OperationInfo, consistency: types.consistencies, required: number, alive: boolean): DecisionInfo; + + // (undocumented) + onWriteTimeout( + info: OperationInfo, + consistency: types.consistencies, + received: number, + blockFor: number, + writeType: string): DecisionInfo; + + // (undocumented) + rethrowResult(): DecisionInfo; + + // (undocumented) + retryResult(consistency: types.consistencies, useCurrentHost?: boolean): DecisionInfo; + } + } + + // (undocumented) + export namespace speculativeExecution { + // (undocumented) + export class ConstantSpeculativeExecutionPolicy implements SpeculativeExecutionPolicy { + constructor(delay: number, maxSpeculativeExecutions: number); + + // (undocumented) + getOptions(): Map; + + // (undocumented) + init(client: Client): void; + + // (undocumented) + newPlan(keyspace: string, queryInfo: string | Array): { nextExecution: Function }; + + // (undocumented) + shutdown(): void; + } + + // (undocumented) + export class NoSpeculativeExecutionPolicy implements SpeculativeExecutionPolicy { + constructor(); + + // (undocumented) + getOptions(): Map; + + // (undocumented) + init(client: Client): void; + + // (undocumented) + newPlan(keyspace: string, queryInfo: string | Array): { nextExecution: Function }; + + // (undocumented) + shutdown(): void; + } + + // (undocumented) + export interface SpeculativeExecutionPolicy { + // (undocumented) + getOptions(): Map; + + // (undocumented) + init(client: Client): void; + + // (undocumented) + newPlan(keyspace: string, queryInfo: string|Array): { nextExecution: Function }; + + // (undocumented) + shutdown(): void; + } + } + + // (undocumented) + export namespace timestampGeneration { + // (undocumented) + export class MonotonicTimestampGenerator implements TimestampGenerator { + constructor(warningThreshold: number, minLogInterval: number); + + // (undocumented) + getDate(): number; + + // (undocumented) + next(client: Client): types.Long | number; + } + + // (undocumented) + export interface TimestampGenerator { + // (undocumented) + next(client: Client): types.Long|number; + } + } +} + +// @public (undocumented) +export interface QueryOptions { + // (undocumented) + autoPage?: boolean; + // (undocumented) + captureStackTrace?: boolean; + // (undocumented) + consistency?: number; + // (undocumented) + counter?: boolean; + // (undocumented) + customPayload?: any; + // (undocumented) + executionProfile?: string | ExecutionProfile; + // (undocumented) + fetchSize?: number; + // (undocumented) + hints?: string[] | string[][]; + // (undocumented) + host?: Host; + // (undocumented) + isIdempotent?: boolean; + // (undocumented) + keyspace?: string; + // (undocumented) + logged?: boolean; + // (undocumented) + pageState?: Buffer | string; + // (undocumented) + prepare?: boolean; + // (undocumented) + readTimeout?: number; + // (undocumented) + retry?: policies.retry.RetryPolicy; + // (undocumented) + routingIndexes?: number[]; + // (undocumented) + routingKey?: Buffer | Buffer[]; + // (undocumented) + routingNames?: string[]; + // (undocumented) + serialConsistency?: number; + // (undocumented) + timestamp?: number | Long; + // (undocumented) + traceQuery?: boolean; +} + +// @public (undocumented) +export namespace token { + // (undocumented) + export interface Token { + // (undocumented) + compare(other: Token): number; + + // (undocumented) + equals(other: Token): boolean; + + // (undocumented) + getType(): { code: types.dataTypes, info: any }; + + // (undocumented) + getValue(): any; + } + + // (undocumented) + export interface TokenRange { + // (undocumented) + compare(other: TokenRange): number; + // (undocumented) + contains(token: Token): boolean; + // (undocumented) + end: Token; + // (undocumented) + equals(other: TokenRange): boolean; + // (undocumented) + isEmpty(): boolean; + // (undocumented) + isWrappedAround(): boolean; + // (undocumented) + splitEvenly(numberOfSplits: number): TokenRange[]; + // (undocumented) + start: Token; + // (undocumented) + unwrap(): TokenRange[]; + } +} + +// @public (undocumented) +export namespace tracker { + // (undocumented) + export class RequestLogger implements RequestTracker { + constructor(options: { + slowThreshold?: number; + logNormalRequests?: boolean; + logErroredRequests?: boolean; + messageMaxQueryLength?: number; + messageMaxParameterValueLength?: number; + messageMaxErrorStackTraceLength?: number; + }); + + // (undocumented) + onError(host: Host, query: string | Array<{ query: string; params?: any }>, parameters: any[] | { [p: string]: any } | null, executionOptions: ExecutionOptions, requestLength: number, err: Error, latency: number[]): void; + + // (undocumented) + onSuccess(host: Host, query: string | Array<{ query: string; params?: any }>, parameters: any[] | { [p: string]: any } | null, executionOptions: ExecutionOptions, requestLength: number, responseLength: number, latency: number[]): void; + + // (undocumented) + shutdown(): void; + } + + // (undocumented) + export interface RequestTracker { + // (undocumented) + onError( + host: Host, + query: string | Array<{ query: string, params?: any }>, + parameters: any[] | { [key: string]: any } | null, + executionOptions: ExecutionOptions, + requestLength: number, + err: Error, + latency: number[]): void; + + // (undocumented) + onSuccess( + host: Host, + query: string | Array<{ query: string, params?: any }>, + parameters: any[] | { [key: string]: any } | null, + executionOptions: ExecutionOptions, + requestLength: number, + responseLength: number, + latency: number[]): void; + + // (undocumented) + shutdown(): void; + } +} + +// @public (undocumented) +export namespace types { + // (undocumented) + export class BigDecimal { + constructor(unscaledValue: number, scale: number); + + // (undocumented) + add(other: BigDecimal): BigDecimal; + + // (undocumented) + compare(other: BigDecimal): number; + + // (undocumented) + equals(other: BigDecimal): boolean; + + // (undocumented) + static fromBuffer(buf: Buffer): BigDecimal; + + // (undocumented) + static fromNumber(value: number): BigDecimal; + + // (undocumented) + static fromString(value: string): BigDecimal; + + // (undocumented) + greaterThan(other: BigDecimal): boolean; + + // (undocumented) + isNegative(): boolean; + + // (undocumented) + isZero(): boolean; + + // (undocumented) + notEquals(other: BigDecimal): boolean; + + // (undocumented) + subtract(other: BigDecimal): BigDecimal; + + // (undocumented) + static toBuffer(value: BigDecimal): Buffer; + + // (undocumented) + toJSON(): string; + + // (undocumented) + toNumber(): number; + + // (undocumented) + toString(): string; + } + + // (undocumented) + export enum consistencies { + // (undocumented) + all = 0x05, + // (undocumented) + any = 0x00, + // (undocumented) + eachQuorum = 0x07, + // (undocumented) + localOne = 0x0a, + // (undocumented) + localQuorum = 0x06, + // (undocumented) + localSerial = 0x09, + // (undocumented) + one = 0x01, + // (undocumented) + quorum = 0x04, + // (undocumented) + serial = 0x08, + // (undocumented) + three = 0x03, + // (undocumented) + two = 0x02 + } + + // (undocumented) + export enum dataTypes { + // (undocumented) + ascii = 0x0001, + // (undocumented) + bigint = 0x0002, + // (undocumented) + blob = 0x0003, + // (undocumented) + boolean = 0x0004, + // (undocumented) + counter = 0x0005, + // (undocumented) + custom = 0x0000, + // (undocumented) + date = 0x0011, + // (undocumented) + decimal = 0x0006, + // (undocumented) + double = 0x0007, + // (undocumented) + duration = 0x0015, + // (undocumented) + float = 0x0008, + // (undocumented) + inet = 0x0010, + // (undocumented) + int = 0x0009, + // (undocumented) + list = 0x0020, + // (undocumented) + map = 0x0021, + // (undocumented) + set = 0x0022, + // (undocumented) + smallint = 0x0013, + // (undocumented) + text = 0x000a, + // (undocumented) + time = 0x0012, + // (undocumented) + timestamp = 0x000b, + // (undocumented) + timeuuid = 0x000f, + // (undocumented) + tinyint = 0x0014, + // (undocumented) + tuple = 0x0031, + // (undocumented) + udt = 0x0030, + // (undocumented) + uuid = 0x000c, + // (undocumented) + varchar = 0x000d, + // (undocumented) + varint = 0x000e, + } + + // (undocumented) + export enum distance { + // (undocumented) + ignored, + // (undocumented) + local = 0, + // (undocumented) + remote + } + + // (undocumented) + export class Duration { + constructor(month: number, days: number, nanoseconds: number | Long); + + // (undocumented) + equals(other: Duration): boolean; + + // (undocumented) + static fromBuffer(buffer: Buffer): Duration; + + // (undocumented) + static fromString(input: string): Duration; + + // (undocumented) + toBuffer(): Buffer; + + // (undocumented) + toString(): string; + } + + // (undocumented) + export class InetAddress { + constructor(buffer: Buffer); + + // (undocumented) + equals(other: InetAddress): boolean; + + // (undocumented) + static fromString(value: string): InetAddress; + + // (undocumented) + getBuffer(): Buffer; + + // (undocumented) + length: number; + + // (undocumented) + toJSON(): string; + + // (undocumented) + toString(): string; + + // (undocumented) + version: number; + } + + // (undocumented) + export class Integer { + constructor(bits: Array, sign: number); + // (undocumented) + abs(): Integer; + // (undocumented) + add(other: Integer): Integer; + // (undocumented) + compare(other: Integer): number; + // (undocumented) + divide(other: Integer): Integer; + // (undocumented) + equals(other: Integer): boolean; + // (undocumented) + static fromBits(bits: Array): Integer; + // (undocumented) + static fromBuffer(bits: Buffer): Integer; + // (undocumented) + static fromInt(value: number): Integer; + // (undocumented) + static fromNumber(value: number): Integer; + // (undocumented) + static fromString(str: string, opt_radix?: number): Integer; + // (undocumented) + getBits(index: number): number; + // (undocumented) + getBitsUnsigned(index: number): number; + // (undocumented) + getSign(): number; + // (undocumented) + greaterThan(other: Integer): boolean; + // (undocumented) + greaterThanOrEqual(other: Integer): boolean; + // (undocumented) + isNegative(): boolean; + // (undocumented) + isOdd(): boolean; + // (undocumented) + isZero(): boolean; + // (undocumented) + lessThan(other: Integer): boolean; + // (undocumented) + lessThanOrEqual(other: Integer): boolean; + // (undocumented) + modulo(other: Integer): Integer; + // (undocumented) + multiply(other: Integer): Integer; + // (undocumented) + negate(): Integer; + // (undocumented) + not(): Integer; + // (undocumented) + notEquals(other: Integer): boolean; + // (undocumented) + static ONE: Integer; + // (undocumented) + or(other: Integer): Integer; + // (undocumented) + shiftLeft(numBits: number): Integer; + // (undocumented) + shiftRight(numBits: number): Integer; + // (undocumented) + shorten(numBits: number): Integer; + // (undocumented) + subtract(other: Integer): Integer; + // (undocumented) + static toBuffer(value: Integer): Buffer; + // (undocumented) + toInt(): number; + // (undocumented) + toJSON(): string; + // (undocumented) + toNumber(): number; + // (undocumented) + toString(opt_radix?: number): string; + // (undocumented) + xor(other: Integer): Integer; + // (undocumented) + static ZERO: Integer; + } + + const // (undocumented) + unset: object; + + // (undocumented) + export class LocalDate { + constructor(year: number, month: number, day: number); + // (undocumented) + day: number; + // (undocumented) + equals(other: LocalDate): boolean; + // (undocumented) + static fromBuffer(buffer: Buffer): LocalDate; + // (undocumented) + static fromDate(date: Date): LocalDate; + // (undocumented) + static fromString(value: string): LocalDate; + // (undocumented) + inspect(): string; + // (undocumented) + month: number; + // (undocumented) + static now(): LocalDate; + // (undocumented) + toBuffer(): Buffer; + // (undocumented) + toJSON(): string; + // (undocumented) + toString(): string; + // (undocumented) + static utcNow(): LocalDate; + // (undocumented) + year: number; + } + + // (undocumented) + export class LocalTime { + constructor(totalNanoseconds: Long); + // (undocumented) + compare(other: LocalTime): boolean; + // (undocumented) + equals(other: LocalTime): boolean; + // (undocumented) + static fromBuffer(value: Buffer): LocalTime; + // (undocumented) + static fromDate(date: Date, nanoseconds: number): LocalTime; + // (undocumented) + static fromMilliseconds(milliseconds: number, nanoseconds?: number): LocalTime; + // (undocumented) + static fromString(value: string): LocalTime; + // (undocumented) + getTotalNanoseconds(): Long; + // (undocumented) + hour: number; + // (undocumented) + inspect(): string; + // (undocumented) + minute: number; + // (undocumented) + nanosecond: number; + // (undocumented) + static now(nanoseconds?: number): LocalTime; + // (undocumented) + second: number; + // (undocumented) + toBuffer(): Buffer; + // (undocumented) + toJSON(): string; + // (undocumented) + toString(): string; + } + + // (undocumented) + export class Long extends _Long { + + } + + // (undocumented) + export enum protocolVersion { + // (undocumented) + dseV1 = 0x41, + // (undocumented) + dseV2 = 0x42, + // (undocumented) + maxSupported = dseV2, + // (undocumented) + minSupported = v1, + // (undocumented) + v1 = 0x01, + // (undocumented) + v2 = 0x02, + // (undocumented) + v3 = 0x03, + // (undocumented) + v4 = 0x04, + // (undocumented) + v5 = 0x05, + // (undocumented) + v6 = 0x06 + } + + // (undocumented) + export namespace protocolVersion { + // (undocumented) + export function isSupported(version: protocolVersion): boolean; + } + + // (undocumented) + export enum responseErrorCodes { + // (undocumented) + alreadyExists = 0x2400, + // (undocumented) + badCredentials = 0x0100, + // (undocumented) + clientWriteFailure = 0x8000, + // (undocumented) + configError = 0x2300, + // (undocumented) + functionFailure = 0x1400, + // (undocumented) + invalid = 0x2200, + // (undocumented) + isBootstrapping = 0x1002, + // (undocumented) + overloaded = 0x1001, + // (undocumented) + protocolError = 0x000A, + // (undocumented) + readFailure = 0x1300, + // (undocumented) + readTimeout = 0x1200, + // (undocumented) + serverError = 0x0000, + // (undocumented) + syntaxError = 0x2000, + // (undocumented) + truncateError = 0x1003, + // (undocumented) + unauthorized = 0x2100, + // (undocumented) + unavailableException = 0x1000, + // (undocumented) + unprepared = 0x2500, + // (undocumented) + writeFailure = 0x1500, + // (undocumented) + writeTimeout = 0x1100 + } + + // (undocumented) + export interface ResultSet extends Iterable, AsyncIterable { + // (undocumented) + columns: Array<{ name: string, type: { code: dataTypes, info: any } }>; + + // (undocumented) + first(): Row; + + // (undocumented) + info: { + queriedHost: string, + triedHosts: { [key: string]: any; }, + speculativeExecutions: number, + achievedConsistency: consistencies, + traceId: Uuid, + warnings: string[], + customPayload: any + }; + + // (undocumented) + nextPage: (() => void) | null; + + // (undocumented) + pageState: string; + + // (undocumented) + rowLength: number; + + // (undocumented) + rows: Row[]; + + // (undocumented) + wasApplied(): boolean; + } + + // (undocumented) + export interface ResultStream extends stream.Readable { + // (undocumented) + add(chunk: Buffer): void; + // (undocumented) + buffer: Buffer; + // (undocumented) + paused: boolean; + } + + // (undocumented) + export interface Row { + // (undocumented) + [key: string]: any; + + // (undocumented) + forEach(callback: (row: Row) => void): void; + + // (undocumented) + get(columnName: string | number): any; + + // (undocumented) + keys(): string[]; + + // (undocumented) + values(): any[]; + } + + // (undocumented) + export class TimeUuid extends Uuid { + // (undocumented) + static fromDate(date: Date, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid; + + // (undocumented) + static fromDate( + date: Date, + ticks: number, + nodeId: string | Buffer, + clockId: string | Buffer, + callback: ValueCallback): void; + + // (undocumented) + static fromString(value: string): TimeUuid; + + // (undocumented) + getDate(): Date; + + // (undocumented) + getDatePrecision(): { date: Date, ticks: number }; + + // (undocumented) + static max(date: Date, ticks: number): TimeUuid; + + // (undocumented) + static min(date: Date, ticks: number): TimeUuid; + + // (undocumented) + static now(): TimeUuid; + + // (undocumented) + static now(nodeId: string | Buffer, clockId?: string | Buffer): TimeUuid; + + // (undocumented) + static now(nodeId: string | Buffer, clockId: string | Buffer, callback: ValueCallback): void; + + // (undocumented) + static now(callback: ValueCallback): void; + } + + // (undocumented) + export class Tuple { + constructor(...args: any[]); + // (undocumented) + elements: any[]; + // (undocumented) + static fromArray(elements: any[]): Tuple; + // (undocumented) + get(index: number): any; + // (undocumented) + length: number; + // (undocumented) + toJSON(): string; + // (undocumented) + toString(): string; + // (undocumented) + values(): any[]; + } + + // (undocumented) + export class Uuid { + constructor(buffer: Buffer); + + // (undocumented) + equals(other: Uuid): boolean; + + // (undocumented) + static fromString(value: string): Uuid; + + // (undocumented) + getBuffer(): Buffer; + + // (undocumented) + static random(callback: ValueCallback): void; + + // (undocumented) + static random(): Uuid; + + // (undocumented) + toJSON(): string; + + // (undocumented) + toString(): string; + } +} + +// @public (undocumented) +export type ValueCallback = (err: Error, val: T) => void; + +// @public (undocumented) +export const version: number; + +// (No @packageDocumentation comment for this package) + +``` diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 90f2b6c3b..000000000 --- a/index.d.ts +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright DataStax, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as events from 'events'; -import * as tls from 'tls'; -import { URL } from 'url'; -import { auth } from './lib/auth'; -import { policies } from './lib/policies'; -import { types } from './lib/types'; -import { metrics } from './lib/metrics'; -import { tracker } from './lib/tracker'; -import { metadata } from './lib/metadata'; -import { datastax } from './lib/datastax/'; -import Long = types.Long; -import Uuid = types.Uuid; -import graph = datastax.graph; - -// Export imported submodules -export { concurrent } from './lib/concurrent'; -export { mapping } from './lib/mapping'; -export { geometry } from './lib/geometry'; -export { auth, datastax, metadata, metrics, policies, tracker, types }; - -export const version: number; - -export function defaultOptions(): ClientOptions; - -export type ValueCallback = (err: Error, val: T) => void; -export type EmptyCallback = (err: Error) => void; -export type ArrayOrObject = any[]|{[key: string]: any}; - -export class Client extends events.EventEmitter { - hosts: HostMap; - keyspace: string; - metadata: metadata.Metadata; - metrics: metrics.ClientMetrics; - - constructor(options: DseClientOptions); - - connect(): Promise; - - connect(callback: EmptyCallback): void; - - execute(query: string, params?: ArrayOrObject, options?: QueryOptions): Promise; - - execute(query: string, params: ArrayOrObject, options: QueryOptions, callback: ValueCallback): void; - - execute(query: string, params: ArrayOrObject, callback: ValueCallback): void; - - execute(query: string, callback: ValueCallback): void; - - executeGraph( - traversal: string, - parameters: { [name: string]: any } | undefined, - options: GraphQueryOptions, - callback: ValueCallback): void; - - executeGraph( - traversal: string, - parameters: { [name: string]: any } | undefined, - callback: ValueCallback): void; - - executeGraph(traversal: string, callback: ValueCallback): void; - - executeGraph( - traversal: string, - parameters?: { [name: string]: any }, - options?: GraphQueryOptions): Promise; - - eachRow(query: string, - params: ArrayOrObject, - options: QueryOptions, - rowCallback: (n: number, row: types.Row) => void, - callback?: ValueCallback): void; - - eachRow(query: string, - params: ArrayOrObject, - rowCallback: (n: number, row: types.Row) => void, - callback?: ValueCallback): void; - - eachRow(query: string, - rowCallback: (n: number, row: types.Row) => void): void; - - stream(query: string, params?: ArrayOrObject, options?: QueryOptions, callback?: EmptyCallback): events.EventEmitter; - - batch( - queries: Array, - options?: QueryOptions): Promise; - - batch( - queries: Array, - options: QueryOptions, - callback: ValueCallback): void; - - batch( - queries: Array, - callback: ValueCallback): void; - - shutdown(): Promise; - - shutdown(callback: EmptyCallback): void; - - getReplicas(keyspace: string, token: Buffer): Host[]; - - getState(): metadata.ClientState; -} - -export interface HostMap extends events.EventEmitter { - length: number; - - forEach(callback: (value: Host, key: string) => void): void; - - get(key: string): Host; - - keys(): string[]; - - values(): Host[]; -} - -export interface Host extends events.EventEmitter { - address: string; - cassandraVersion: string; - datacenter: string; - rack: string; - tokens: string[]; - hostId: types.Uuid; - - canBeConsideredAsUp(): boolean; - - getCassandraVersion(): number[]; - - isUp(): boolean; -} - -export interface ExecutionOptions { - getCaptureStackTrace(): boolean; - - getConsistency(): types.consistencies; - - getCustomPayload(): { [key: string]: any }; - - getFetchSize(): number; - - getFixedHost(): Host; - - getHints(): string[] | string[][]; - - isAutoPage(): boolean; - - isBatchCounter(): boolean; - - isBatchLogged(): boolean; - - isIdempotent(): boolean; - - isPrepared(): boolean; - - isQueryTracing(): boolean; - - getKeyspace(): string; - - getLoadBalancingPolicy(): policies.loadBalancing.LoadBalancingPolicy; - - getPageState(): Buffer; - - getRawQueryOptions(): QueryOptions; - - getReadTimeout(): number; - - getRetryPolicy(): policies.retry.RetryPolicy; - - getRoutingKey(): Buffer | Buffer[]; - - getSerialConsistency(): types.consistencies; - - getTimestamp(): number | Long | undefined | null; - - setHints(hints: string[]): void; -} - -export interface ClientOptions { - contactPoints?: string[]; - localDataCenter?: string; - keyspace?: string; - authProvider?: auth.AuthProvider; - credentials?: { - username: string; - password: string; - } - - cloud?: { - secureConnectBundle: string | URL; - }; - - encoding?: { - map?: Function; - set?: Function; - copyBuffer?: boolean; - useUndefinedAsUnset?: boolean; - useBigIntAsLong?: boolean; - useBigIntAsVarint?: boolean; - }; - isMetadataSyncEnabled?: boolean; - maxPrepared?: number; - metrics?: metrics.ClientMetrics; - policies?: { - addressResolution?: policies.addressResolution.AddressTranslator; - loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; - reconnection?: policies.reconnection.ReconnectionPolicy; - retry?: policies.retry.RetryPolicy; - speculativeExecution?: policies.speculativeExecution.SpeculativeExecutionPolicy; - timestampGeneration?: policies.timestampGeneration.TimestampGenerator; - }; - pooling?: { - coreConnectionsPerHost?: { [key: number]: number; }; - heartBeatInterval?: number; - maxRequestsPerConnection?: number; - warmup?: boolean; - }; - prepareOnAllHosts?: boolean; - profiles?: ExecutionProfile[]; - protocolOptions?: { - maxSchemaAgreementWaitSeconds?: number; - maxVersion?: number; - noCompact?: boolean; - port?: number; - }; - promiseFactory?: (handler: (callback: (err: Error, result?: any) => void) => void) => Promise; - queryOptions?: QueryOptions; - refreshSchemaDelay?: number; - rePrepareOnUp?: boolean; - requestTracker?: tracker.RequestTracker; - socketOptions?: { - coalescingThreshold?: number; - connectTimeout?: number; - defunctReadTimeoutThreshold?: number; - keepAlive?: boolean; - keepAliveDelay?: number; - readTimeout?: number; - tcpNoDelay?: boolean; - }; - sslOptions?: tls.ConnectionOptions; -} - -export interface QueryOptions { - autoPage?: boolean; - captureStackTrace?: boolean; - consistency?: number; - counter?: boolean; - customPayload?: any; - executionProfile?: string | ExecutionProfile; - fetchSize?: number; - hints?: string[] | string[][]; - host?: Host; - isIdempotent?: boolean; - keyspace?: string; - logged?: boolean; - pageState?: Buffer | string; - prepare?: boolean; - readTimeout?: number; - retry?: policies.retry.RetryPolicy; - routingIndexes?: number[]; - routingKey?: Buffer | Buffer[]; - routingNames?: string[]; - serialConsistency?: number; - timestamp?: number | Long; - traceQuery?: boolean; -} - -export interface DseClientOptions extends ClientOptions { - id?: Uuid; - applicationName?: string; - applicationVersion?: string; - monitorReporting?: { enabled?: boolean }; - graphOptions?: GraphOptions; -} - -export interface GraphQueryOptions extends QueryOptions { - graphLanguage?: string; - graphName?: string; - graphReadConsistency?: types.consistencies; - graphSource?: string; - graphWriteConsistency?: types.consistencies; -} - -export type GraphOptions = { - language?: string; - name?: string; - readConsistency?: types.consistencies; - readTimeout?: number; - source?: string; - writeConsistency?: types.consistencies; -}; - -export class ExecutionProfile { - consistency?: types.consistencies; - loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; - name: string; - readTimeout?: number; - retry?: policies.retry.RetryPolicy; - serialConsistency?: types.consistencies; - graphOptions?: { - name?: string; - language?: string; - source?: string; - readConsistency?: types.consistencies; - writeConsistency?: types.consistencies; - }; - - constructor(name: string, options: { - consistency?: types.consistencies; - loadBalancing?: policies.loadBalancing.LoadBalancingPolicy; - readTimeout?: number; - retry?: policies.retry.RetryPolicy; - serialConsistency?: types.consistencies; - graphOptions?: { - name?: string; - language?: string; - source?: string; - readConsistency?: types.consistencies; - writeConsistency?: types.consistencies; - }; - }); -} - -export namespace errors { - class ArgumentError extends DriverError { - constructor(message: string); - } - - class AuthenticationError extends DriverError { - constructor(message: string); - } - - class BusyConnectionError extends DriverError { - constructor(address: string, maxRequestsPerConnection: number, connectionLength: number); - } - - class VIntOutOfRangeException extends DriverError { - constructor(long: Long); - } - - abstract class DriverError extends Error { - info: string; - - constructor(message: string, constructor?: any); - } - - class DriverInternalError extends DriverError { - constructor(message: string); - } - - class NoHostAvailableError extends DriverError { - innerErrors: any; - - constructor(innerErrors: any, message?: string); - } - - class NotSupportedError extends DriverError { - constructor(message: string); - } - - class OperationTimedOutError extends DriverError { - host?: string; - - constructor(message: string, host?: string); - } - - class ResponseError extends DriverError { - code: number; - - constructor(code: number, message: string); - } -} - -export namespace token { - interface Token { - compare(other: Token): number; - - equals(other: Token): boolean; - - getType(): { code: types.dataTypes, info: any }; - - getValue(): any; - } - - interface TokenRange { - start: Token; - end: Token; - - compare(other: TokenRange): number; - - contains(token: Token): boolean; - - equals(other: TokenRange): boolean; - - isEmpty(): boolean; - - isWrappedAround(): boolean; - - splitEvenly(numberOfSplits: number): TokenRange[]; - - unwrap(): TokenRange[]; - } -} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 2acf5ccb6..000000000 --- a/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright DataStax, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; -const clientOptions = require('./lib/client-options'); -exports.Client = require('./lib/client'); -exports.ExecutionProfile = require('./lib/execution-profile').ExecutionProfile; -exports.ExecutionOptions = require('./lib/execution-options').ExecutionOptions; -exports.types = require('./lib/types'); -exports.errors = require('./lib/errors'); -exports.policies = require('./lib/policies'); -exports.auth = require('./lib/auth'); -exports.mapping = require('./lib/mapping'); -exports.tracker = require('./lib/tracker'); -exports.metrics = require('./lib/metrics'); -exports.concurrent = require('./lib/concurrent'); - -const token = require('./lib/token'); -exports.token = { - Token: token.Token, - TokenRange: token.TokenRange -}; -const Metadata = require('./lib/metadata'); -exports.metadata = { - Metadata: Metadata -}; -exports.Encoder = require('./lib/encoder'); -exports.geometry = require('./lib/geometry'); -exports.datastax = require('./lib/datastax'); -/** - * Returns a new instance of the default [options]{@link ClientOptions} used by the driver. - */ -exports.defaultOptions = function () { - return clientOptions.defaultOptions(); -}; -exports.version = require('./package.json').version; \ No newline at end of file diff --git a/index.ts b/index.ts new file mode 100644 index 000000000..d4f4dd0a5 --- /dev/null +++ b/index.ts @@ -0,0 +1,69 @@ +/* + * Copyright DataStax, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import auth from './lib/auth/index.js'; +import clientOptions from "./lib/client-options.js"; +import Client from "./lib/client.js"; +import types from "./lib/types/index.js"; +import errors from "./lib/errors.js"; +import policies from "./lib/policies/index.js"; +import mapping from "./lib/mapping/index.js"; +import tracker from "./lib/tracker/index.js"; +import metrics from "./lib/metrics/index.js"; +import concurrent from "./lib/concurrent/index.js"; +import Token from "./lib/token.js"; +import Metadata from "./lib/metadata/index.js"; +import Encoder from "./lib/encoder.js"; +import geometry from "./lib/geometry/index.js"; +import datastax from "./lib/datastax/index.js"; +import packageJson from './package.json'; + +import { ExecutionProfile } from './lib/execution-profile.js'; +import { ExecutionOptions } from './lib/execution-options.js'; + +const token = { + Token: Token.Token, + TokenRange: Token.TokenRange +} +const metadata = {Metadata: Metadata}; +const defaultOptions = function () { + return clientOptions.defaultOptions(); +} +const version = packageJson.version; + + +export { + Client, + ExecutionProfile, + ExecutionOptions, + types, + errors, + policies, + auth, + mapping, + tracker, + metrics, + concurrent, + token, + metadata, + Encoder, + geometry, + datastax, + /** + * Returns a new instance of the default [options]{@link ClientOptions} used by the driver. + */ + defaultOptions, + version +}; \ No newline at end of file diff --git a/lib/auth/base-dse-authenticator.js b/lib/auth/base-dse-authenticator.ts similarity index 94% rename from lib/auth/base-dse-authenticator.js rename to lib/auth/base-dse-authenticator.ts index bddc6493e..171ad8919 100644 --- a/lib/auth/base-dse-authenticator.js +++ b/lib/auth/base-dse-authenticator.ts @@ -14,8 +14,8 @@ * limitations under the License. */ 'use strict'; -const util = require('util'); -const { Authenticator } = require('./provider'); +import { Authenticator } from './provider.js'; +import util from "util"; const dseAuthenticatorName = 'com.datastax.bdp.cassandra.auth.DseAuthenticator'; @@ -73,4 +73,4 @@ BaseDseAuthenticator.prototype._isDseAuthenticator = function () { return this.authenticatorName === dseAuthenticatorName; }; -module.exports = BaseDseAuthenticator; \ No newline at end of file +export default BaseDseAuthenticator; \ No newline at end of file diff --git a/lib/auth/dse-gssapi-auth-provider.js b/lib/auth/dse-gssapi-auth-provider.ts similarity index 96% rename from lib/auth/dse-gssapi-auth-provider.js rename to lib/auth/dse-gssapi-auth-provider.ts index ac25a5185..d8ed9c11f 100644 --- a/lib/auth/dse-gssapi-auth-provider.js +++ b/lib/auth/dse-gssapi-auth-provider.ts @@ -14,13 +14,12 @@ * limitations under the License. */ 'use strict'; -const util = require('util'); -const { AuthProvider } = require('./provider'); -const BaseDseAuthenticator = require('./base-dse-authenticator'); -const GssapiClient = require('./gssapi-client'); -const dns = require('dns'); -const utils = require('../utils'); - +import BaseDseAuthenticator from './base-dse-authenticator.js'; +import GssapiClient from './gssapi-client.js'; +import util from "util"; +import { AuthProvider } from "./provider.js"; +import dns from "dns"; +import utils from "../utils.js"; const mechanism = utils.allocBufferFromString('GSSAPI'); const initialServerChallenge = 'GSSAPI-START'; const emptyBuffer = utils.allocBuffer(0); @@ -228,4 +227,4 @@ GssapiAuthenticator.prototype.onAuthenticationSuccess = function (token) { }; -module.exports = DseGssapiAuthProvider; \ No newline at end of file +export default DseGssapiAuthProvider; \ No newline at end of file diff --git a/lib/auth/dse-plain-text-auth-provider.js b/lib/auth/dse-plain-text-auth-provider.ts similarity index 94% rename from lib/auth/dse-plain-text-auth-provider.js rename to lib/auth/dse-plain-text-auth-provider.ts index 64a0f649e..95efd6aa5 100644 --- a/lib/auth/dse-plain-text-auth-provider.js +++ b/lib/auth/dse-plain-text-auth-provider.ts @@ -14,11 +14,10 @@ * limitations under the License. */ 'use strict'; -const util = require('util'); -const { AuthProvider } = require('./provider'); -const BaseDseAuthenticator = require('./base-dse-authenticator'); -const utils = require('../utils'); - +import { AuthProvider } from './provider.js'; +import BaseDseAuthenticator from './base-dse-authenticator.js'; +import util from "util"; +import utils from "../utils.js"; const mechanism = utils.allocBufferFromString('PLAIN'); const separatorBuffer = utils.allocBufferFromArray([0]); const initialServerChallenge = 'PLAIN-START'; @@ -107,4 +106,4 @@ PlainTextAuthenticator.prototype.evaluateChallenge = function (challenge, callba ])); }; -module.exports = DsePlainTextAuthProvider; \ No newline at end of file +export default DsePlainTextAuthProvider; \ No newline at end of file diff --git a/lib/auth/gssapi-client.js b/lib/auth/gssapi-client.ts similarity index 97% rename from lib/auth/gssapi-client.js rename to lib/auth/gssapi-client.ts index 92af818ba..6ab64d3ea 100644 --- a/lib/auth/gssapi-client.js +++ b/lib/auth/gssapi-client.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "../utils.js"; 'use strict'; -const util = require('util'); -const utils = require('../utils'); - /** * GSSAPI Client interface. * @ignore @@ -152,4 +151,4 @@ class StandardGssClient extends GssapiClient { } } -module.exports = GssapiClient; \ No newline at end of file +export default GssapiClient; \ No newline at end of file diff --git a/lib/auth/index.js b/lib/auth/index.ts similarity index 61% rename from lib/auth/index.js rename to lib/auth/index.ts index b79b14e22..016a88b07 100644 --- a/lib/auth/index.js +++ b/lib/auth/index.ts @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LsICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -23,13 +23,13 @@ * @module auth */ -const { Authenticator, AuthProvider } = require('./provider'); -const { PlainTextAuthProvider } = require('./plain-text-auth-provider'); -const DseGssapiAuthProvider = require('./dse-gssapi-auth-provider'); -const DsePlainTextAuthProvider = require('./dse-plain-text-auth-provider'); -const NoAuthProvider = require('./no-auth-provider'); +import { Authenticator, AuthProvider } from './provider.js'; +import { PlainTextAuthProvider } from './plain-text-auth-provider.js'; +import DseGssapiAuthProvider from './dse-gssapi-auth-provider.js'; +import DsePlainTextAuthProvider from './dse-plain-text-auth-provider.js'; +import NoAuthProvider from './no-auth-provider.js'; -module.exports = { +export { Authenticator, AuthProvider, DseGssapiAuthProvider, @@ -37,3 +37,12 @@ module.exports = { NoAuthProvider, PlainTextAuthProvider }; + +export default { + Authenticator, + AuthProvider, + DseGssapiAuthProvider, + DsePlainTextAuthProvider, + NoAuthProvider, + PlainTextAuthProvider +}; \ No newline at end of file diff --git a/lib/auth/no-auth-provider.js b/lib/auth/no-auth-provider.ts similarity index 90% rename from lib/auth/no-auth-provider.js rename to lib/auth/no-auth-provider.ts index 7dbcd9ea5..bf32669a1 100644 --- a/lib/auth/no-auth-provider.js +++ b/lib/auth/no-auth-provider.ts @@ -16,10 +16,9 @@ 'use strict'; -const { AuthProvider, Authenticator } = require('./provider'); -const { PlainTextAuthenticator } = require('./plain-text-auth-provider'); -const errors = require('../errors'); - +import { AuthProvider, Authenticator } from './provider.js'; +import { PlainTextAuthenticator } from './plain-text-auth-provider.js'; +import errors from "../errors.js"; const dseAuthenticator = 'com.datastax.bdp.cassandra.auth.DseAuthenticator'; /** @@ -67,4 +66,4 @@ class TransitionalModePlainTextAuthenticator extends PlainTextAuthenticator { } } -module.exports = NoAuthProvider; +export default NoAuthProvider; diff --git a/lib/auth/plain-text-auth-provider.js b/lib/auth/plain-text-auth-provider.ts similarity index 95% rename from lib/auth/plain-text-auth-provider.js rename to lib/auth/plain-text-auth-provider.ts index f5241f7e4..7ebced404 100644 --- a/lib/auth/plain-text-auth-provider.js +++ b/lib/auth/plain-text-auth-provider.ts @@ -14,10 +14,9 @@ * limitations under the License. */ 'use strict'; -const util = require('util'); - -const provider = require('./provider.js'); -const utils = require('../utils'); +import * as provider from './provider.js'; +import util from "util"; +import utils from "../utils.js"; const AuthProvider = provider.AuthProvider; const Authenticator = provider.Authenticator; /** @@ -75,7 +74,7 @@ PlainTextAuthenticator.prototype.evaluateChallenge = function (challenge, callba callback(); }; -module.exports = { +export { PlainTextAuthenticator, PlainTextAuthProvider, }; diff --git a/lib/auth/provider.js b/lib/auth/provider.ts similarity index 97% rename from lib/auth/provider.js rename to lib/auth/provider.ts index d4bf9ed10..50efa992a 100644 --- a/lib/auth/provider.js +++ b/lib/auth/provider.ts @@ -75,5 +75,7 @@ Authenticator.prototype.onAuthenticationSuccess = function (token) { }; -exports.AuthProvider = AuthProvider; -exports.Authenticator = Authenticator; \ No newline at end of file +export { + Authenticator, + AuthProvider +} \ No newline at end of file diff --git a/lib/client-options.js b/lib/client-options.ts similarity index 93% rename from lib/client-options.js rename to lib/client-options.ts index 029e5c8b3..a6c1b2bea 100644 --- a/lib/client-options.js +++ b/lib/client-options.ts @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const util = require('util'); -const policies = require('./policies'); -const types = require('./types'); -const utils = require('./utils'); -const tracker = require('./tracker'); -const metrics = require('./metrics'); -const auth = require('./auth'); +import util from "util"; +import policies from "./policies/index.js"; +import types from "./types/index.js"; +import utils from "./utils.js"; +import tracker from "./tracker/index.js"; +import metrics from "./metrics/index.js"; +import auth from "./auth/index.js"; +'use strict'; /** Core connections per host for protocol versions 1 and 2 */ const coreConnectionsPerHostV2 = { [types.distance.local]: 2, @@ -349,13 +348,28 @@ function setMetadataDependent(client) { {}, { coreConnectionsPerHost, maxRequestsPerConnection }, client.options.pooling); } -exports.extend = extend; -exports.defaultOptions = defaultOptions; -exports.coreConnectionsPerHostV2 = coreConnectionsPerHostV2; -exports.coreConnectionsPerHostV3 = coreConnectionsPerHostV3; -exports.maxRequestsPerConnectionV2 = maxRequestsPerConnectionV2; -exports.maxRequestsPerConnectionV3 = maxRequestsPerConnectionV3; -exports.setMetadataDependent = setMetadataDependent; -exports.continuousPageUnitBytes = continuousPageUnitBytes; -exports.continuousPageDefaultSize = continuousPageDefaultSize; -exports.continuousPageDefaultHighWaterMark = continuousPageDefaultHighWaterMark; +export { + extend, + defaultOptions, + coreConnectionsPerHostV2, + coreConnectionsPerHostV3, + maxRequestsPerConnectionV2, + maxRequestsPerConnectionV3, + setMetadataDependent, + continuousPageUnitBytes, + continuousPageDefaultSize, + continuousPageDefaultHighWaterMark +}; + +export default { + extend, + defaultOptions, + coreConnectionsPerHostV2, + coreConnectionsPerHostV3, + maxRequestsPerConnectionV2, + maxRequestsPerConnectionV3, + setMetadataDependent, + continuousPageUnitBytes, + continuousPageDefaultSize, + continuousPageDefaultHighWaterMark +}; \ No newline at end of file diff --git a/lib/client.js b/lib/client.ts similarity index 97% rename from lib/client.js rename to lib/client.ts index fae8ff83d..3f1cd9c24 100644 --- a/lib/client.js +++ b/lib/client.ts @@ -13,29 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import util from "util"; +import utils from "./utils.js"; +import errors from "./errors.js"; +import types from "./types/index.js"; +import { ProfileManager } from "./execution-profile.js"; +import requests from "./requests.js"; +import clientOptions from "./client-options.js"; +import ClientState from "./metadata/client-state.js"; +import { DefaultExecutionOptions } from "./execution-options.js"; +import ControlConnection from "./control-connection.js"; +import RequestHandler from "./request-handler.js"; +import PrepareHandler from "./prepare-handler.js"; +import InsightsClient from "./insights-client.js"; +import cloud from "./datastax/cloud/index.js"; +import GraphExecutor from "./datastax/graph/graph-executor.js"; +import promiseUtils from "./promise-utils.js"; +import packageInfo from '../package.json' assert {type: 'json'}; + 'use strict'; -const events = require('events'); -const util = require('util'); - -const utils = require('./utils.js'); -const errors = require('./errors.js'); -const types = require('./types'); -const { ProfileManager } = require('./execution-profile'); -const requests = require('./requests'); -const clientOptions = require('./client-options'); -const ClientState = require('./metadata/client-state'); -const description = require('../package.json').description; -const { version } = require('../package.json'); -const { DefaultExecutionOptions } = require('./execution-options'); -const ControlConnection = require('./control-connection'); -const RequestHandler = require('./request-handler'); -const PrepareHandler = require('./prepare-handler'); -const InsightsClient = require('./insights-client'); -const cloud = require('./datastax/cloud'); -const GraphExecutor = require('./datastax/graph/graph-executor'); -const promiseUtils = require('./promise-utils'); +const version = packageInfo.version; +const description = packageInfo.description; /** * Max amount of pools being warmup in parallel, when warmup is enabled * @private @@ -1170,11 +1171,4 @@ Client.prototype._setRoutingInfo = async function (execOptions, params, meta) { } }; -/** - * Callback used by execution methods. - * @callback ResultCallback - * @param {Error} err Error occurred in the execution of the query. - * @param {ResultSet} [result] Result of the execution of the query. - */ - -module.exports = Client; +export default Client; diff --git a/lib/concurrent/index.js b/lib/concurrent/index.ts similarity index 98% rename from lib/concurrent/index.js rename to lib/concurrent/index.ts index c618693bb..e505bc601 100644 --- a/lib/concurrent/index.js +++ b/lib/concurrent/index.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Stream } from "stream"; +import utils from "../utils.js"; 'use strict'; -const { Stream } = require('stream'); -const utils = require('../utils'); - /** * Utilities for concurrent query execution with the DataStax Node.js Driver. * @module concurrent @@ -331,5 +330,12 @@ class ResultSetGroup { } } -exports.executeConcurrent = executeConcurrent; -exports.ResultSetGroup = ResultSetGroup; \ No newline at end of file +export { + executeConcurrent, + ResultSetGroup +}; + +export default { + executeConcurrent, + ResultSetGroup +}; \ No newline at end of file diff --git a/lib/connection.js b/lib/connection.ts similarity index 97% rename from lib/connection.js rename to lib/connection.ts index 843828729..b200d66fd 100644 --- a/lib/connection.js +++ b/lib/connection.ts @@ -13,26 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import util from "util"; +import tls from "tls"; +import net from "net"; +import Encoder from "./encoder.js"; +import { WriteQueue } from "./writers.js"; +import requests from "./requests.js"; +import streams from "./streams.js"; +import utils from "./utils.js"; +import types from "./types/index.js"; +import errors from "./errors.js"; +import StreamIdStack from "./stream-id-stack.js"; +import OperationState from "./operation-state.js"; +import promiseUtils from "./promise-utils.js"; +import { ExecutionOptions } from "./execution-options.js"; 'use strict'; -const events = require('events'); -const util = require('util'); -const tls = require('tls'); -const net = require('net'); - -const Encoder = require('./encoder.js'); -const { WriteQueue } = require('./writers'); -const requests = require('./requests'); -const streams = require('./streams'); -const utils = require('./utils'); -const types = require('./types'); -const errors = require('./errors'); -const StreamIdStack = require('./stream-id-stack'); -const OperationState = require('./operation-state'); -const promiseUtils = require('./promise-utils'); -const { ExecutionOptions } = require('./execution-options'); - /** * Represents a connection to a Cassandra node */ @@ -787,4 +785,4 @@ class Connection extends events.EventEmitter { } } -module.exports = Connection; +export default Connection; diff --git a/lib/control-connection.js b/lib/control-connection.ts similarity index 98% rename from lib/control-connection.js rename to lib/control-connection.ts index 54b3e6171..2df78d79c 100644 --- a/lib/control-connection.js +++ b/lib/control-connection.ts @@ -13,21 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import util from "util"; +import net from "net"; +import dns from "dns"; +import errors from "./errors.js"; +import { Host, HostMap } from "./host.js"; +import Metadata from "./metadata/index.js"; +import EventDebouncer from "./metadata/event-debouncer.js"; +import Connection from "./connection.js"; +import requests from "./requests.js"; +import utils from "./utils.js"; +import types from "./types/index.js"; +import promiseUtils from "./promise-utils.js"; + 'use strict'; -const events = require('events'); -const util = require('util'); -const net = require('net'); -const dns = require('dns'); - -const errors = require('./errors'); -const { Host, HostMap } = require('./host'); -const Metadata = require('./metadata'); -const EventDebouncer = require('./metadata/event-debouncer'); -const Connection = require('./connection'); -const requests = require('./requests'); -const utils = require('./utils'); -const types = require('./types'); -const promiseUtils = require('./promise-utils'); const f = util.format; const selectPeers = "SELECT * FROM system.peers"; @@ -1070,4 +1070,4 @@ function setDseParameters(host, row) { } } -module.exports = ControlConnection; +export default ControlConnection; diff --git a/lib/datastax/cloud/index.js b/lib/datastax/cloud/index.ts similarity index 96% rename from lib/datastax/cloud/index.js rename to lib/datastax/cloud/index.ts index e44a4c7b9..3e60fb31e 100644 --- a/lib/datastax/cloud/index.js +++ b/lib/datastax/cloud/index.ts @@ -15,16 +15,14 @@ */ 'use strict'; - -const https = require('https'); -const fs = require('fs'); -const util = require('util'); -const AdmZip = require('adm-zip'); -const { URL } = require('url'); - -const errors = require('../../errors'); -const utils = require('../../utils'); -const { DsePlainTextAuthProvider, NoAuthProvider } = require('../../auth'); +import { DsePlainTextAuthProvider, NoAuthProvider } from '../../auth/index.js'; +import https from "https"; +import fs from "fs"; +import util from "util"; +import AdmZip from "adm-zip"; +import { URL } from "url"; +import errors from "../../errors.js"; +import utils from "../../utils.js"; // Use the callback-based method fs.readFile() instead of fs.promises as we have to support Node.js 8+ const readFile = util.promisify(fs.readFile); @@ -332,7 +330,12 @@ function checkParts(hostParts, pattern) { return true; } -module.exports = { +export { + checkServerIdentity, + init +}; + +export default { checkServerIdentity, init }; \ No newline at end of file diff --git a/lib/datastax/graph/complex-type-helper.js b/lib/datastax/graph/complex-type-helper.ts similarity index 91% rename from lib/datastax/graph/complex-type-helper.js rename to lib/datastax/graph/complex-type-helper.ts index 130bf0a1d..d9c594431 100644 --- a/lib/datastax/graph/complex-type-helper.js +++ b/lib/datastax/graph/complex-type-helper.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { GraphTypeWrapper, UdtGraphWrapper } from "./wrappers.js"; +import types from "../../types/index.js"; +import Encoder from "../../encoder.js"; 'use strict'; - -const { GraphTypeWrapper, UdtGraphWrapper } = require('./wrappers'); -const types = require('../../types'); -const Encoder = require('../../encoder'); const { dataTypes } = types; function getTypeDefinitionByValue(value) { @@ -96,4 +95,6 @@ function getUdtTypeDefinitionByValue(wrappedValue) { return getUdtTypeDefinition(wrappedValue.udtInfo); } -module.exports = { getTypeDefinitionByValue, getUdtTypeDefinitionByValue }; \ No newline at end of file +export { + getTypeDefinitionByValue, + getUdtTypeDefinitionByValue }; \ No newline at end of file diff --git a/lib/datastax/graph/custom-type-serializers.js b/lib/datastax/graph/custom-type-serializers.ts similarity index 95% rename from lib/datastax/graph/custom-type-serializers.js rename to lib/datastax/graph/custom-type-serializers.ts index e25ef3bbc..208a670ad 100644 --- a/lib/datastax/graph/custom-type-serializers.js +++ b/lib/datastax/graph/custom-type-serializers.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import types from "../../types/index.js"; +import utils from "../../utils.js"; +import { getTypeDefinitionByValue, getUdtTypeDefinitionByValue } from "./complex-type-helper.js"; +import { Point, Polygon, LineString } from "../../geometry/index.js"; +import { Edge } from "./structure.js"; +import { GraphTypeWrapper, UdtGraphWrapper } from "./wrappers.js"; -const types = require('../../types'); -const utils = require('../../utils'); -const { getTypeDefinitionByValue, getUdtTypeDefinitionByValue } = require('./complex-type-helper'); -const { Point, Polygon, LineString } = require('../../geometry'); -const { Edge } = require('./structure'); -const { GraphTypeWrapper, UdtGraphWrapper } = require('./wrappers'); +'use strict'; const { Tuple, dataTypes } = types; const typeKey = '@type'; @@ -359,4 +359,4 @@ function getCustomSerializers() { return customSerializers; } -module.exports = getCustomSerializers; \ No newline at end of file +export default getCustomSerializers; \ No newline at end of file diff --git a/lib/datastax/graph/graph-executor.js b/lib/datastax/graph/graph-executor.ts similarity index 95% rename from lib/datastax/graph/graph-executor.js rename to lib/datastax/graph/graph-executor.ts index 701582675..5e5f0f3cd 100644 --- a/lib/datastax/graph/graph-executor.js +++ b/lib/datastax/graph/graph-executor.ts @@ -13,16 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "../../utils.js"; +import policies from "../../policies/index.js"; +import GraphResultSet from "./result-set.js"; +import { GraphSON2Reader, GraphSON2Writer, GraphSON3Reader, GraphSON3Writer } from "./graph-serializer.js"; +import getCustomTypeSerializers from "./custom-type-serializers.js"; +import { GraphExecutionOptions, graphProtocol } from "./options.js"; 'use strict'; - -const utils = require('../../utils'); -const policies = require('../../policies'); -const GraphResultSet = require('./result-set'); -const { GraphSON2Reader, GraphSON2Writer, GraphSON3Reader, GraphSON3Writer } = require('./graph-serializer'); -const getCustomTypeSerializers = require('./custom-type-serializers'); -const { GraphExecutionOptions, graphProtocol } = require('./options'); - const graphLanguageGroovyString = 'gremlin-groovy'; const graphEngineCore = 'Core'; @@ -277,4 +275,4 @@ function getDefaultWriter(writer) { return value => writer.write(value); } -module.exports = GraphExecutor; \ No newline at end of file +export default GraphExecutor; \ No newline at end of file diff --git a/lib/datastax/graph/graph-serializer.js b/lib/datastax/graph/graph-serializer.ts similarity index 97% rename from lib/datastax/graph/graph-serializer.js rename to lib/datastax/graph/graph-serializer.ts index 4331161a5..857d9807d 100644 --- a/lib/datastax/graph/graph-serializer.js +++ b/lib/datastax/graph/graph-serializer.ts @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +import typeSerializers from "./type-serializers.js"; /** * @module datastax/graph/tinkerpop/graphSerializers @@ -28,8 +29,6 @@ */ 'use strict'; -const typeSerializers = require('./type-serializers'); - /** * GraphSON2 writer. */ @@ -250,11 +249,11 @@ const graphSON3Serializers = graphSON2Serializers.concat([ typeSerializers.MapSerializer ]); -module.exports = { +export { GraphSON3Writer, GraphSON3Reader, GraphSON2Writer, GraphSON2Reader, - GraphSONWriter: GraphSON3Writer, - GraphSONReader: GraphSON3Reader + GraphSON3Writer as GraphSONWriter, + GraphSON3Reader as GraphSONReader }; \ No newline at end of file diff --git a/lib/datastax/graph/index.js b/lib/datastax/graph/index.ts similarity index 81% rename from lib/datastax/graph/index.js rename to lib/datastax/graph/index.ts index a0333a06e..bf63df1cc 100644 --- a/lib/datastax/graph/index.js +++ b/lib/datastax/graph/index.ts @@ -13,17 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import GraphResultSet from "./result-set.js"; +import getCustomTypeSerializers from "./custom-type-serializers.js"; +import { asInt, asDouble, asFloat, asTimestamp, asUdt, UdtGraphWrapper, GraphTypeWrapper} from "./wrappers.js"; +import { Edge, Element, Path, Property, Vertex, VertexProperty } from "./structure.js"; -/** - * Graph module. - * @module datastax/graph - */ - -const GraphResultSet = require('./result-set'); -const getCustomTypeSerializers = require('./custom-type-serializers'); -const { asInt, asDouble, asFloat, asTimestamp, asUdt, UdtGraphWrapper, GraphTypeWrapper} = require('./wrappers'); -const { Edge, Element, Path, Property, Vertex, VertexProperty } = require('./structure'); +'use strict'; class EnumValue { constructor(typeName, elementName) { @@ -60,7 +55,7 @@ const direction = { // Expose an extra property to represent `Direction.IN`. direction.in_ = direction.in; -module.exports = { +export default { Edge, Element, Path, diff --git a/lib/datastax/graph/options.js b/lib/datastax/graph/options.ts similarity index 98% rename from lib/datastax/graph/options.js rename to lib/datastax/graph/options.ts index 2e0e7e711..23c351f9e 100644 --- a/lib/datastax/graph/options.js +++ b/lib/datastax/graph/options.ts @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import types from "../../types/index.js"; +import utils from "../../utils.js"; +import { DefaultExecutionOptions, proxyExecuteKey } from "../../execution-options.js"; + 'use strict'; -const util = require('util'); -const types = require('../../types'); -const utils = require('../../utils'); -const { DefaultExecutionOptions, proxyExecuteKey } = require('../../execution-options'); const Long = types.Long; let consistencyNames; @@ -327,7 +328,7 @@ class GraphExecutionOptions extends DefaultExecutionOptions { } } -module.exports = { +export { GraphExecutionOptions, graphProtocol, payloadKeys diff --git a/lib/datastax/graph/result-set.js b/lib/datastax/graph/result-set.ts similarity index 98% rename from lib/datastax/graph/result-set.js rename to lib/datastax/graph/result-set.ts index 8e8467065..c54d946b8 100644 --- a/lib/datastax/graph/result-set.js +++ b/lib/datastax/graph/result-set.ts @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import utils from "../../utils.js"; -const utils = require('../../utils'); +'use strict'; /** * Creates a new instance of GraphResultSet. @@ -153,4 +153,4 @@ function parsePlainJsonRow(row) { return { object: parsed.result, bulk: parsed.bulk || 1 }; } -module.exports = GraphResultSet; \ No newline at end of file +export default GraphResultSet; \ No newline at end of file diff --git a/lib/datastax/graph/structure.js b/lib/datastax/graph/structure.ts similarity index 98% rename from lib/datastax/graph/structure.js rename to lib/datastax/graph/structure.ts index deef3e134..a239062b0 100644 --- a/lib/datastax/graph/structure.js +++ b/lib/datastax/graph/structure.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; 'use strict'; -const util = require('util'); - /** * @classdesc * Represents a graph Element. @@ -157,7 +156,7 @@ function Path(labels, objects) { this.objects = objects; } -module.exports = { +export { Edge, Element, Path, diff --git a/lib/datastax/graph/type-serializers.js b/lib/datastax/graph/type-serializers.ts similarity index 99% rename from lib/datastax/graph/type-serializers.js rename to lib/datastax/graph/type-serializers.ts index 880c0f336..7d874d11e 100644 --- a/lib/datastax/graph/type-serializers.js +++ b/lib/datastax/graph/type-serializers.ts @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +import g from "./index.js"; /** * @module datastax/graph/tinkerpop/typeSerializers @@ -34,7 +35,6 @@ const t = { }; const ts = { TraversalStrategy: UnsupportedType }; const Bytecode = UnsupportedType; -const g = require('./index'); const utils = { Long: UnsupportedType }; t.t = g.t; t.direction = g.direction; @@ -473,7 +473,7 @@ class SetSerializer extends ArraySerializer { } } -module.exports = { +export default { BulkSetSerializer, BytecodeSerializer, DateSerializer, @@ -498,4 +498,4 @@ module.exports = { valueKey, VertexPropertySerializer, VertexSerializer -}; +}; \ No newline at end of file diff --git a/lib/datastax/graph/wrappers.js b/lib/datastax/graph/wrappers.ts similarity index 94% rename from lib/datastax/graph/wrappers.js rename to lib/datastax/graph/wrappers.ts index 0bbf8c086..004a68d3d 100644 --- a/lib/datastax/graph/wrappers.js +++ b/lib/datastax/graph/wrappers.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import types from "../../types/index.js"; 'use strict'; - -const types = require('../../types'); const { dataTypes } = types; /** @@ -81,4 +80,4 @@ function asTimestamp(value) { return new GraphTypeWrapper(value, dataTypes.times */ function asUdt(value, udtInfo) { return new UdtGraphWrapper(value, udtInfo); } -module.exports = { asInt, asDouble, asFloat, asTimestamp, asUdt, UdtGraphWrapper, GraphTypeWrapper }; \ No newline at end of file +export { asInt, asDouble, asFloat, asTimestamp, asUdt, UdtGraphWrapper, GraphTypeWrapper }; \ No newline at end of file diff --git a/lib/datastax/index.js b/lib/datastax/index.ts similarity index 85% rename from lib/datastax/index.js rename to lib/datastax/index.ts index b193461a0..ee29f737c 100644 --- a/lib/datastax/index.js +++ b/lib/datastax/index.ts @@ -24,5 +24,11 @@ * @module datastax */ -exports.graph = require('./graph'); -exports.search = require('./search'); \ No newline at end of file +import graph from "./graph/index.js"; +import { DateRange } from "./search/index.js"; + +export default { + graph, + DateRange +}; + diff --git a/lib/datastax/search/date-range.js b/lib/datastax/search/date-range.ts similarity index 98% rename from lib/datastax/search/date-range.js rename to lib/datastax/search/date-range.ts index 877c9a392..70c551a37 100644 --- a/lib/datastax/search/date-range.js +++ b/lib/datastax/search/date-range.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const utils = require('../../utils'); -const Long = require('long'); +import utils from "../../utils.js"; +import Long from "long"; +'use strict'; /** * Regex to parse dates in the following format YYYY-MM-DDThh:mm:ss.mssZ * Looks cumbersome but it's straightforward: @@ -531,7 +530,9 @@ BoundaryBuilder.prototype.build = function () { return new DateRangeBound(date, this._index); }; -exports.unbounded = unbounded; -exports.dateRangePrecision = dateRangePrecision; -exports.DateRange = DateRange; -exports.DateRangeBound = DateRangeBound; \ No newline at end of file +export { + unbounded, + dateRangePrecision, + DateRange, + DateRangeBound +} \ No newline at end of file diff --git a/lib/datastax/search/index.js b/lib/datastax/search/index.ts similarity index 77% rename from lib/datastax/search/index.js rename to lib/datastax/search/index.ts index c101f5d14..b216f05bd 100644 --- a/lib/datastax/search/index.js +++ b/lib/datastax/search/index.ts @@ -15,8 +15,6 @@ */ 'use strict'; -const dateRangeModule = require('./date-range'); - /** * Search module. *

@@ -25,6 +23,4 @@ const dateRangeModule = require('./date-range'); * @module datastax/search */ -exports.DateRange = dateRangeModule.DateRange; -exports.DateRangeBound = dateRangeModule.DateRangeBound; -exports.dateRangePrecision = dateRangeModule.dateRangePrecision; \ No newline at end of file +export * from "./date-range.js"; \ No newline at end of file diff --git a/lib/encoder.js b/lib/encoder.ts similarity index 99% rename from lib/encoder.js rename to lib/encoder.ts index 7a78754d6..4106904a1 100644 --- a/lib/encoder.js +++ b/lib/encoder.ts @@ -13,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); +import util from "util"; +import types from "./types/index.js"; +import MutableLong from "./types/mutable-long.js"; +import utils from "./utils.js"; +import token from "./token.js"; +import { DateRange } from "./datastax/search/index.js"; +import geo from "./geometry/index.js"; +import Vector from "./types/vector.js"; -const types = require('./types'); +'use strict'; const dataTypes = types.dataTypes; const Long = types.Long; const Integer = types.Integer; const BigDecimal = types.BigDecimal; -const MutableLong = require('./types/mutable-long'); -const utils = require('./utils'); -const token = require('./token'); -const { DateRange } = require('./datastax/search'); -const geo = require('./geometry'); -const Vector = require('./types/vector'); const Geometry = geo.Geometry; const LineString = geo.LineString; const Point = geo.Point; @@ -2186,4 +2186,4 @@ Encoder.isTypedArray = function(arg) { return (arg instanceof Object.getPrototypeOf(Uint8Array)); }; -module.exports = Encoder; +export default Encoder; diff --git a/lib/errors.js b/lib/errors.ts similarity index 92% rename from lib/errors.js rename to lib/errors.ts index 970c528b9..a667bd3de 100644 --- a/lib/errors.js +++ b/lib/errors.ts @@ -13,8 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; + 'use strict'; -const util = require('util'); + /** * Contains the error classes exposed by the driver. * @module errors @@ -176,13 +178,15 @@ function VIntOutOfRangeException(long){ util.inherits(VIntOutOfRangeException, DriverError); -exports.ArgumentError = ArgumentError; -exports.AuthenticationError = AuthenticationError; -exports.BusyConnectionError = BusyConnectionError; -exports.DriverError = DriverError; -exports.OperationTimedOutError = OperationTimedOutError; -exports.DriverInternalError = DriverInternalError; -exports.NoHostAvailableError = NoHostAvailableError; -exports.NotSupportedError = NotSupportedError; -exports.ResponseError = ResponseError; -exports.VIntOutOfRangeException = VIntOutOfRangeException; \ No newline at end of file +export default { + ArgumentError, + AuthenticationError, + BusyConnectionError, + DriverError, + OperationTimedOutError, + DriverInternalError, + NoHostAvailableError, + NotSupportedError, + ResponseError, + VIntOutOfRangeException +} \ No newline at end of file diff --git a/lib/execution-options.js b/lib/execution-options.ts similarity index 98% rename from lib/execution-options.js rename to lib/execution-options.ts index cc3df181f..ab439faba 100644 --- a/lib/execution-options.js +++ b/lib/execution-options.ts @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "./utils.js"; +import types from "./types/index.js"; +import errors from "./errors.js"; 'use strict'; - -const utils = require('./utils'); -const types = require('./types'); -const errors = require('./errors'); - const proxyExecuteKey = 'ProxyExecute'; /** @@ -616,4 +614,4 @@ function ifUndefined3(v1, v2, v3) { return v2 !== undefined ? v2 : v3; } -module.exports = { ExecutionOptions, DefaultExecutionOptions, proxyExecuteKey }; \ No newline at end of file +export { ExecutionOptions, DefaultExecutionOptions, proxyExecuteKey }; \ No newline at end of file diff --git a/lib/execution-profile.js b/lib/execution-profile.ts similarity index 98% rename from lib/execution-profile.js rename to lib/execution-profile.ts index 78c4fc2b2..8ac1c0f2a 100644 --- a/lib/execution-profile.js +++ b/lib/execution-profile.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "./utils.js"; +import types from "./types/index.js"; +import promiseUtils from "./promise-utils.js"; 'use strict'; -const utils = require('./utils'); -const types = require('./types'); -const promiseUtils = require('./promise-utils'); - /** * Creates a new instance of {@link ExecutionProfile}. * @classdesc @@ -260,7 +259,12 @@ class ProfileManager { } } -module.exports = { +export { + ProfileManager, + ExecutionProfile +}; + +export default { ProfileManager, ExecutionProfile }; \ No newline at end of file diff --git a/lib/geometry/geometry.js b/lib/geometry/geometry.ts similarity index 99% rename from lib/geometry/geometry.js rename to lib/geometry/geometry.ts index b91c8fdbb..9eb6d06b5 100644 --- a/lib/geometry/geometry.js +++ b/lib/geometry/geometry.ts @@ -130,4 +130,4 @@ Geometry.prototype.useBESerialization = function () { throw new Error('Not Implemented'); }; -module.exports = Geometry; \ No newline at end of file +export default Geometry; \ No newline at end of file diff --git a/lib/geometry/index.js b/lib/geometry/index.ts similarity index 73% rename from lib/geometry/index.js rename to lib/geometry/index.ts index 28c9bc7b6..32cd00381 100644 --- a/lib/geometry/index.js +++ b/lib/geometry/index.ts @@ -24,7 +24,21 @@ * @module geometry */ -exports.Geometry = require('./geometry'); -exports.LineString = require('./line-string'); -exports.Point = require('./point'); -exports.Polygon = require('./polygon'); \ No newline at end of file +import Point from './point.js'; +import LineString from './line-string.js'; +import Polygon from './polygon.js'; +import Geometry from './geometry.js'; + +export default { + Point, + LineString, + Polygon, + Geometry +} + +export { + Point, + LineString, + Polygon, + Geometry +} \ No newline at end of file diff --git a/lib/geometry/line-string.js b/lib/geometry/line-string.ts similarity index 97% rename from lib/geometry/line-string.js rename to lib/geometry/line-string.ts index 3e7c8ee25..9dfd92048 100644 --- a/lib/geometry/line-string.js +++ b/lib/geometry/line-string.ts @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "../utils.js"; +import Geometry from "./geometry.js"; +import Point from "./point.js"; + 'use strict'; -const util = require('util'); -const utils = require('../utils'); -const Geometry = require('./geometry'); -const Point = require('./point'); /** * Creates a new {@link LineString} instance. @@ -194,4 +195,4 @@ LineString.prototype.toJSON = function () { })}; }; -module.exports = LineString; \ No newline at end of file +export default LineString; \ No newline at end of file diff --git a/lib/geometry/point.js b/lib/geometry/point.ts similarity index 96% rename from lib/geometry/point.js rename to lib/geometry/point.ts index 473b6cd1d..9566f9e58 100644 --- a/lib/geometry/point.js +++ b/lib/geometry/point.ts @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "../utils.js"; +import Geometry from "./geometry.js"; + 'use strict'; -const util = require('util'); -const utils = require('../utils'); -const Geometry = require('./geometry'); /** * Creates a new {@link Point} instance. @@ -131,4 +132,4 @@ Point.prototype.toJSON = function () { return { type: 'Point', coordinates: [ this.x, this.y ]}; }; -module.exports = Point; \ No newline at end of file +export default Point; \ No newline at end of file diff --git a/lib/geometry/polygon.js b/lib/geometry/polygon.ts similarity index 97% rename from lib/geometry/polygon.js rename to lib/geometry/polygon.ts index c4536e118..1e447d769 100644 --- a/lib/geometry/polygon.js +++ b/lib/geometry/polygon.ts @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "../utils.js"; +import Geometry from "./geometry.js"; +import Point from "./point.js"; +import LineString from "./line-string.js"; + 'use strict'; -const util = require('util'); -const utils = require('../utils'); -const Geometry = require('./geometry'); -const Point = require('./point'); -const LineString = require('./line-string'); /** * Creates a new {@link Polygon} instance. @@ -236,4 +237,4 @@ Polygon.prototype.toJSON = function () { })}; }; -module.exports = Polygon; \ No newline at end of file +export default Polygon; \ No newline at end of file diff --git a/lib/host-connection-pool.js b/lib/host-connection-pool.ts similarity index 97% rename from lib/host-connection-pool.js rename to lib/host-connection-pool.ts index f03e6981e..1c2b153f2 100644 --- a/lib/host-connection-pool.js +++ b/lib/host-connection-pool.ts @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); -const events = require('events'); - -const Connection = require('./connection'); -const utils = require('./utils'); -const promiseUtils = require('./promise-utils'); -const errors = require('./errors'); -const clientOptions = require('./client-options'); +import util from "util"; +import events from "events"; +import Connection from "./connection.js"; +import utils from "./utils.js"; +import promiseUtils from "./promise-utils.js"; +import errors from "./errors.js"; +import clientOptions from "./client-options.js"; +'use strict'; // Used to get the index of the connection with less in-flight requests let connectionIndex = 0; const connectionIndexOverflow = Math.pow(2, 15); @@ -519,4 +518,4 @@ function getDefaultOptions() { return defaultOptions; } -module.exports = HostConnectionPool; \ No newline at end of file +export default HostConnectionPool; \ No newline at end of file diff --git a/lib/host.js b/lib/host.ts similarity index 98% rename from lib/host.js rename to lib/host.ts index 56c128f5b..f1ed776ff 100644 --- a/lib/host.js +++ b/lib/host.ts @@ -13,17 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import utils from "./utils.js"; +import types from "./types/index.js"; +import HostConnectionPool from "./host-connection-pool.js"; +import PrepareHandler from "./prepare-handler.js"; +import promiseUtils from "./promise-utils.js"; 'use strict'; - -const events = require('events'); - -const utils = require('./utils'); -const types = require('./types'); -const HostConnectionPool = require('./host-connection-pool'); -const PrepareHandler = require('./prepare-handler'); -const promiseUtils = require('./promise-utils'); - const healthResponseCountInterval = 200; /** @@ -652,7 +649,12 @@ class HostMap extends events.EventEmitter{ } } -module.exports = { +export { + Host, + HostMap +}; + +export default { Host, HostMap }; \ No newline at end of file diff --git a/lib/insights-client.js b/lib/insights-client.ts similarity index 96% rename from lib/insights-client.js rename to lib/insights-client.ts index 4c9207d4d..400f122d8 100644 --- a/lib/insights-client.js +++ b/lib/insights-client.ts @@ -15,18 +15,18 @@ */ 'use strict'; - -const os = require('os'); -const path = require('path'); -const fs = require('fs'); -const utils = require('./utils'); -const promiseUtils = require('./promise-utils'); -const types = require('./types'); -const requests = require('./requests'); -const { ExecutionOptions } = require('./execution-options'); -const packageInfo = require('../package.json'); -const VersionNumber = require('./types/version-number'); -const { NoAuthProvider } = require('./auth'); +import { NoAuthProvider } from './auth/index.js'; +import os from "os"; +import path from "path"; +import fs from "fs"; +import utils from "./utils.js"; +import promiseUtils from "./promise-utils.js"; +import types from "./types/index.js"; +import requests from "./requests.js"; +import { ExecutionOptions } from "./execution-options.js"; +import packageInfo from "../package.json" assert {type: 'json'}; +import VersionNumber from "./types/version-number.js"; +import { assert } from 'console'; let kerberosModule; @@ -404,7 +404,7 @@ class InsightsClient { } } -module.exports = InsightsClient; +export default InsightsClient; function mapToObject(map) { const result = {}; diff --git a/lib/mapping/cache.js b/lib/mapping/cache.ts similarity index 98% rename from lib/mapping/cache.js rename to lib/mapping/cache.ts index ffc4777da..fd00f29bd 100644 --- a/lib/mapping/cache.js +++ b/lib/mapping/cache.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import qModule from "./q.js"; 'use strict'; - -const qModule = require('./q'); const QueryOperator = qModule.QueryOperator; const QueryAssignment = qModule.QueryAssignment; @@ -204,4 +203,4 @@ class Cache { } } -module.exports = Cache; \ No newline at end of file +export default Cache; \ No newline at end of file diff --git a/lib/mapping/doc-info-adapter.js b/lib/mapping/doc-info-adapter.ts similarity index 97% rename from lib/mapping/doc-info-adapter.js rename to lib/mapping/doc-info-adapter.ts index 32deead54..b2adfa7b8 100644 --- a/lib/mapping/doc-info-adapter.js +++ b/lib/mapping/doc-info-adapter.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import errors from "../errors.js"; +import utils from "../utils.js"; 'use strict'; -const errors = require('../errors'); -const utils = require('../utils'); - /** * Provides utility methods to adapt and map user provided docInfo and executionOptions to a predictable object format. * @ignore @@ -159,4 +158,4 @@ class DocInfoAdapter { } } -module.exports = DocInfoAdapter; \ No newline at end of file +export default DocInfoAdapter; \ No newline at end of file diff --git a/lib/mapping/index.js b/lib/mapping/index.js deleted file mode 100644 index e1de6c93b..000000000 --- a/lib/mapping/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright DataStax, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -/** - * Module containing classes and fields related to the Mapper. - * @module mapping - */ - -exports.Mapper = require('./mapper'); -exports.ModelMapper = require('./model-mapper'); -exports.ModelBatchMapper = require('./model-batch-mapper'); -exports.ModelBatchItem = require('./model-batch-item').ModelBatchItem; -exports.Result = require('./result'); -const tableMappingsModule = require('./table-mappings'); -exports.TableMappings = tableMappingsModule.TableMappings; -exports.DefaultTableMappings = tableMappingsModule.DefaultTableMappings; -exports.UnderscoreCqlToCamelCaseMappings = tableMappingsModule.UnderscoreCqlToCamelCaseMappings; -exports.q = require('./q').q; \ No newline at end of file diff --git a/lib/mapping/index.ts b/lib/mapping/index.ts new file mode 100644 index 000000000..7ba0468f2 --- /dev/null +++ b/lib/mapping/index.ts @@ -0,0 +1,53 @@ +/* + * Copyright DataStax, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Mapper from './mapper.js'; +import ModelMapper from "./model-mapper.js"; +import ModelBatchMapper from "./model-batch-mapper.js"; +import { ModelBatchItem } from './model-batch-item.js'; +import Result from "./result.js"; +import { q } from "./q.js"; +import {TableMappings, DefaultTableMappings, UnderscoreCqlToCamelCaseMappings} from "./table-mappings.js"; + +'use strict'; + +/** + * Module containing classes and fields related to the Mapper. + * @module mapping + */ + +export { + Mapper, + ModelMapper, + ModelBatchMapper, + ModelBatchItem, + Result, + TableMappings, + DefaultTableMappings, + UnderscoreCqlToCamelCaseMappings, + q +} + +export default { + Mapper, + ModelMapper, + ModelBatchMapper, + ModelBatchItem, + Result, + TableMappings, + DefaultTableMappings, + UnderscoreCqlToCamelCaseMappings, + q +} \ No newline at end of file diff --git a/lib/mapping/mapper.js b/lib/mapping/mapper.ts similarity index 82% rename from lib/mapping/mapper.js rename to lib/mapping/mapper.ts index 329c87f1c..dba290d5c 100644 --- a/lib/mapping/mapper.js +++ b/lib/mapping/mapper.ts @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ModelMapper from "./model-mapper.js"; +import MappingHandler from "./mapping-handler.js"; +import DocInfoAdapter from "./doc-info-adapter.js"; +import errors from "../errors.js"; +import Result from "./result.js"; +import ResultMapper from "./result-mapper.js"; +import ModelMappingInfo from "./model-mapping-info.js"; +import { ModelBatchItem } from "./model-batch-item.js"; 'use strict'; -const ModelMapper = require('./model-mapper'); -const MappingHandler = require('./mapping-handler'); -const DocInfoAdapter = require('./doc-info-adapter'); -const errors = require('../errors'); -const Result = require('./result'); -const ResultMapper = require('./result-mapper'); -const ModelMappingInfo = require('./model-mapping-info'); -const { ModelBatchItem } = require('./model-batch-item'); - /** * Represents an object mapper for Apache Cassandra and DataStax Enterprise. * @alias module:mapping~Mapper @@ -171,23 +170,4 @@ class Mapper { } } -/** - * Represents the mapping options. - * @typedef {Object} module:mapping~MappingOptions - * @property {Object} models An associative array containing the - * name of the model as key and the table and column information as value. - */ - -/** - * Represents a set of options that applies to a certain model. - * @typedef {Object} module:mapping~ModelOptions - * @property {Array|Array<{name, isView}>} tables An Array containing the name of the tables or An Array - * containing the name and isView property to describe the table. - * @property {TableMappings} mappings The TableMappings implementation instance that is used to convert from column - * names to property names and the other way around. - * @property {Object.} [columnNames] An associative array containing the name of the columns and - * properties that doesn't follow the convention defined in the TableMappings. - * @property {String} [keyspace] The name of the keyspace. Only mandatory when the Client is not using a keyspace. - */ - -module.exports = Mapper; \ No newline at end of file +export default Mapper; \ No newline at end of file diff --git a/lib/mapping/mapping-handler.js b/lib/mapping/mapping-handler.ts similarity index 97% rename from lib/mapping/mapping-handler.js rename to lib/mapping/mapping-handler.ts index f5bd83177..8083ca336 100644 --- a/lib/mapping/mapping-handler.js +++ b/lib/mapping/mapping-handler.ts @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "../utils.js"; +import QueryGenerator from "./query-generator.js"; +import ResultMapper from "./result-mapper.js"; +import Result from "./result.js"; +import Cache from "./cache.js"; +import Tree from "./tree.js"; +import ObjectSelector from "./object-selector.js"; +import DocInfoAdapter from "./doc-info-adapter.js"; 'use strict'; - -const utils = require('../utils'); -const QueryGenerator = require('./query-generator'); -const ResultMapper = require('./result-mapper'); -const Result = require('./result'); -const Cache = require('./cache'); -const Tree = require('./tree'); -const ObjectSelector = require('./object-selector'); -const DocInfoAdapter = require('./doc-info-adapter'); - const cacheHighWaterMark = 100; /** @@ -409,4 +407,4 @@ class MappingHandler { } } -module.exports = MappingHandler; \ No newline at end of file +export default MappingHandler; \ No newline at end of file diff --git a/lib/mapping/model-batch-item.js b/lib/mapping/model-batch-item.ts similarity index 97% rename from lib/mapping/model-batch-item.js rename to lib/mapping/model-batch-item.ts index f04528e50..9c253bd5c 100644 --- a/lib/mapping/model-batch-item.js +++ b/lib/mapping/model-batch-item.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import Cache from "./cache.js"; 'use strict'; -const Cache = require('./cache'); - /** * Represents a query or a set of queries used to perform a mutation in a batch. * @alias module:mapping~ModelBatchItem @@ -188,4 +187,4 @@ class RemoveModelBatchItem extends ModelBatchItem { } } -module.exports = { ModelBatchItem, InsertModelBatchItem, UpdateModelBatchItem, RemoveModelBatchItem }; \ No newline at end of file +export { ModelBatchItem, InsertModelBatchItem, UpdateModelBatchItem, RemoveModelBatchItem }; \ No newline at end of file diff --git a/lib/mapping/model-batch-mapper.js b/lib/mapping/model-batch-mapper.ts similarity index 98% rename from lib/mapping/model-batch-mapper.js rename to lib/mapping/model-batch-mapper.ts index 4928072c8..0bd3ee158 100644 --- a/lib/mapping/model-batch-mapper.js +++ b/lib/mapping/model-batch-mapper.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import Tree from "./tree.js"; +import * as moduleBatchItemModule from "./model-batch-item.js"; 'use strict'; - -const Tree = require('./tree'); -const moduleBatchItemModule = require('./model-batch-item'); const InsertModelBatchItem = moduleBatchItemModule.InsertModelBatchItem; const UpdateModelBatchItem = moduleBatchItemModule.UpdateModelBatchItem; const RemoveModelBatchItem = moduleBatchItemModule.RemoveModelBatchItem; @@ -122,4 +121,4 @@ class ModelBatchMapper { } } -module.exports = ModelBatchMapper; \ No newline at end of file +export default ModelBatchMapper; \ No newline at end of file diff --git a/lib/mapping/model-mapper.js b/lib/mapping/model-mapper.ts similarity index 99% rename from lib/mapping/model-mapper.js rename to lib/mapping/model-mapper.ts index 8a4d04194..3d15108e2 100644 --- a/lib/mapping/model-mapper.js +++ b/lib/mapping/model-mapper.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ModelBatchMapper from "./model-batch-mapper.js"; 'use strict'; -const ModelBatchMapper = require('./model-batch-mapper'); - /** * Represents an object mapper for a specific model. * @alias module:mapping~ModelMapper @@ -303,4 +302,4 @@ class ModelMapper { } } -module.exports = ModelMapper; \ No newline at end of file +export default ModelMapper; \ No newline at end of file diff --git a/lib/mapping/model-mapping-info.js b/lib/mapping/model-mapping-info.ts similarity index 98% rename from lib/mapping/model-mapping-info.js rename to lib/mapping/model-mapping-info.ts index 23be0408d..c6d46e9c2 100644 --- a/lib/mapping/model-mapping-info.js +++ b/lib/mapping/model-mapping-info.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import tableMappingsModule from "./table-mappings.js"; 'use strict'; - -const tableMappingsModule = require('./table-mappings'); const TableMappings = tableMappingsModule.TableMappings; const DefaultTableMappings = tableMappingsModule.DefaultTableMappings; @@ -191,4 +190,4 @@ class ModelColumnInfo { } } -module.exports = ModelMappingInfo; \ No newline at end of file +export default ModelMappingInfo; \ No newline at end of file diff --git a/lib/mapping/object-selector.js b/lib/mapping/object-selector.ts similarity index 99% rename from lib/mapping/object-selector.js rename to lib/mapping/object-selector.ts index de25df627..9748cdd6f 100644 --- a/lib/mapping/object-selector.js +++ b/lib/mapping/object-selector.ts @@ -318,4 +318,4 @@ function staticColumnCount(table) { return table.columns.reduce((acc, column) => acc + (column.isStatic ? 1 : 0), 0); } -module.exports = ObjectSelector; +export default ObjectSelector; diff --git a/lib/mapping/q.js b/lib/mapping/q.ts similarity index 96% rename from lib/mapping/q.js rename to lib/mapping/q.ts index 7e4c8ce2d..1802b4998 100644 --- a/lib/mapping/q.js +++ b/lib/mapping/q.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import errors from "../errors.js"; 'use strict'; -const errors = require('../errors'); - /** * Represents a CQL query operator, like >=, IN, <, ... * @ignore @@ -149,6 +148,14 @@ const q = { } }; -exports.q = q; -exports.QueryAssignment = QueryAssignment; -exports.QueryOperator = QueryOperator; \ No newline at end of file +export default { + q, + QueryAssignment, + QueryOperator, +} + +export { + q, + QueryAssignment, + QueryOperator, +} \ No newline at end of file diff --git a/lib/mapping/query-generator.js b/lib/mapping/query-generator.ts similarity index 99% rename from lib/mapping/query-generator.js rename to lib/mapping/query-generator.ts index 83a105d03..4c59430e0 100644 --- a/lib/mapping/query-generator.js +++ b/lib/mapping/query-generator.ts @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import vm from "vm"; +import qModule from "./q.js"; +import types from "../types/index.js"; 'use strict'; - -const vm = require('vm'); -const qModule = require('./q'); const QueryOperator = qModule.QueryOperator; const QueryAssignment = qModule.QueryAssignment; -const types = require('../types'); const dataTypes = types.dataTypes; const vmFileName = 'gen-param-getter.js'; @@ -443,4 +442,4 @@ class QueryGenerator { } } -module.exports = QueryGenerator; \ No newline at end of file +export default QueryGenerator; \ No newline at end of file diff --git a/lib/mapping/result-mapper.js b/lib/mapping/result-mapper.ts similarity index 95% rename from lib/mapping/result-mapper.js rename to lib/mapping/result-mapper.ts index c364e5a24..6ea298425 100644 --- a/lib/mapping/result-mapper.js +++ b/lib/mapping/result-mapper.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import vm from "vm"; +import utils from "../utils.js"; +import types from "../types/index.js"; 'use strict'; -const vm = require('vm'); -const utils = require('../utils'); -const types = require('../types'); - /** * @ignore */ @@ -109,4 +108,4 @@ class ResultMapper { } } -module.exports = ResultMapper; \ No newline at end of file +export default ResultMapper; \ No newline at end of file diff --git a/lib/mapping/result.js b/lib/mapping/result.ts similarity index 97% rename from lib/mapping/result.js rename to lib/mapping/result.ts index 6f1ead4d6..24efd72bd 100644 --- a/lib/mapping/result.js +++ b/lib/mapping/result.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "../utils.js"; 'use strict'; - -const util = require('util'); -const utils = require('../utils'); const inspectMethod = util.inspect.custom || 'inspect'; /** @@ -133,4 +132,4 @@ class Result { } } -module.exports = Result; \ No newline at end of file +export default Result; \ No newline at end of file diff --git a/lib/mapping/table-mappings.js b/lib/mapping/table-mappings.ts similarity index 95% rename from lib/mapping/table-mappings.js rename to lib/mapping/table-mappings.ts index 06010a1c0..83a844d21 100644 --- a/lib/mapping/table-mappings.js +++ b/lib/mapping/table-mappings.ts @@ -117,6 +117,14 @@ class DefaultTableMappings extends TableMappings { } } -exports.TableMappings = TableMappings; -exports.UnderscoreCqlToCamelCaseMappings = UnderscoreCqlToCamelCaseMappings; -exports.DefaultTableMappings = DefaultTableMappings; \ No newline at end of file +export default { + TableMappings, + UnderscoreCqlToCamelCaseMappings, + DefaultTableMappings +} + +export { + TableMappings, + UnderscoreCqlToCamelCaseMappings, + DefaultTableMappings +} \ No newline at end of file diff --git a/lib/mapping/tree.js b/lib/mapping/tree.ts similarity index 98% rename from lib/mapping/tree.js rename to lib/mapping/tree.ts index e6adece9a..b1595306c 100644 --- a/lib/mapping/tree.js +++ b/lib/mapping/tree.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import EventEmitter from "events"; 'use strict'; -const EventEmitter = require('events'); - /** * Represents a tree node where the key is composed by 1 or more strings. * @ignore @@ -148,4 +147,4 @@ function iteratorToArray(value, iterator) { return values; } -module.exports = Tree; \ No newline at end of file +export default Tree; \ No newline at end of file diff --git a/lib/metadata/aggregate.js b/lib/metadata/aggregate.ts similarity index 98% rename from lib/metadata/aggregate.js rename to lib/metadata/aggregate.ts index 6677f5f6c..45e924a9a 100644 --- a/lib/metadata/aggregate.js +++ b/lib/metadata/aggregate.ts @@ -75,4 +75,4 @@ function Aggregate() { this.deterministic = null; } -module.exports = Aggregate; \ No newline at end of file +export default Aggregate; \ No newline at end of file diff --git a/lib/metadata/client-state.js b/lib/metadata/client-state.ts similarity index 96% rename from lib/metadata/client-state.js rename to lib/metadata/client-state.ts index 6bf7c372a..a4b5778dc 100644 --- a/lib/metadata/client-state.js +++ b/lib/metadata/client-state.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import errors from "../errors.js"; -const util = require('util'); -const errors = require('../errors'); +'use strict'; /** * Represents the state of a {@link Client}. @@ -111,4 +111,4 @@ class ClientState { } } -module.exports = ClientState; \ No newline at end of file +export default ClientState; \ No newline at end of file diff --git a/lib/metadata/data-collection.js b/lib/metadata/data-collection.ts similarity index 98% rename from lib/metadata/data-collection.js rename to lib/metadata/data-collection.ts index 1bab680a4..481e83ed6 100644 --- a/lib/metadata/data-collection.js +++ b/lib/metadata/data-collection.ts @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import events from "events"; + 'use strict'; -const util = require('util'); -const events = require('events'); + /** * Creates a new instance of DataCollection * @param {String} name Name of the data object. @@ -170,4 +172,4 @@ function DataCollection(name) { util.inherits(DataCollection, events.EventEmitter); -module.exports = DataCollection; \ No newline at end of file +export default DataCollection; \ No newline at end of file diff --git a/lib/metadata/event-debouncer.js b/lib/metadata/event-debouncer.ts similarity index 96% rename from lib/metadata/event-debouncer.js rename to lib/metadata/event-debouncer.ts index 4ea8ddc2e..20dc378ed 100644 --- a/lib/metadata/event-debouncer.js +++ b/lib/metadata/event-debouncer.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const util = require('util'); -const utils = require('../utils'); -const promiseUtils = require('../promise-utils'); +import util from "util"; +import utils from "../utils.js"; +import promiseUtils from "../promise-utils.js"; +'use strict'; const _queueOverflowThreshold = 1000; /** @@ -161,4 +160,4 @@ function processQueue (q) { }); } -module.exports = EventDebouncer; \ No newline at end of file +export default EventDebouncer; \ No newline at end of file diff --git a/lib/metadata/index.js b/lib/metadata/index.ts similarity index 98% rename from lib/metadata/index.js rename to lib/metadata/index.ts index a34c45708..58d68a70a 100644 --- a/lib/metadata/index.js +++ b/lib/metadata/index.ts @@ -13,27 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import util from "util"; +import t from "../tokenizer.js"; +import utils from "../utils.js"; +import errors from "../errors.js"; +import types from "../types/index.js"; +import requests from "../requests.js"; +import schemaParserFactory from "./schema-parser.js"; +import promiseUtils from "../promise-utils.js"; +import { TokenRange } from "../token.js"; +import { ExecutionOptions } from "../execution-options.js"; 'use strict'; - -const events = require('events'); -const util = require('util'); - -/** - * Module containing classes and fields related to metadata. - * @module metadata - */ - -const t = require('../tokenizer'); -const utils = require('../utils'); -const errors = require('../errors'); -const types = require('../types'); -const requests = require('../requests'); -const schemaParserFactory = require('./schema-parser'); -const promiseUtils = require('../promise-utils'); -const { TokenRange } = require('../token'); -const { ExecutionOptions } = require('../execution-options'); - /** * @const * @private @@ -1021,4 +1013,4 @@ class PreparedQueries { } } -module.exports = Metadata; +export default Metadata; diff --git a/lib/metadata/materialized-view.js b/lib/metadata/materialized-view.ts similarity index 91% rename from lib/metadata/materialized-view.js rename to lib/metadata/materialized-view.ts index 455a66a0e..1ca420aa2 100644 --- a/lib/metadata/materialized-view.js +++ b/lib/metadata/materialized-view.ts @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import DataCollection from "./data-collection.js"; + 'use strict'; -const util = require('util'); -const DataCollection = require('./data-collection'); + /** * Creates a new MaterializedView. * @param {String} name Name of the View. @@ -45,4 +47,4 @@ function MaterializedView(name) { util.inherits(MaterializedView, DataCollection); -module.exports = MaterializedView; \ No newline at end of file +export default MaterializedView; \ No newline at end of file diff --git a/lib/metadata/schema-function.js b/lib/metadata/schema-function.ts similarity index 98% rename from lib/metadata/schema-function.js rename to lib/metadata/schema-function.ts index 40105c07f..385263e04 100644 --- a/lib/metadata/schema-function.js +++ b/lib/metadata/schema-function.ts @@ -94,4 +94,4 @@ function SchemaFunction() { this.monotonicOn = null; } -module.exports = SchemaFunction; \ No newline at end of file +export default SchemaFunction; \ No newline at end of file diff --git a/lib/metadata/schema-index.js b/lib/metadata/schema-index.ts similarity index 96% rename from lib/metadata/schema-index.js rename to lib/metadata/schema-index.ts index 8787bad27..cad3d34f6 100644 --- a/lib/metadata/schema-index.js +++ b/lib/metadata/schema-index.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); -const utils = require('../utils'); -const types = require('../types'); +import util from "util"; +import utils from "../utils.js"; +import types from "../types/index.js"; +'use strict'; /** @private */ const kind = { custom: 0, @@ -146,4 +146,4 @@ function getKindByName(name) { return kind[name.toLowerCase()]; } -module.exports = Index; \ No newline at end of file +export default Index; \ No newline at end of file diff --git a/lib/metadata/schema-parser.js b/lib/metadata/schema-parser.ts similarity index 98% rename from lib/metadata/schema-parser.js rename to lib/metadata/schema-parser.ts index af05a3b69..e039bfb3a 100644 --- a/lib/metadata/schema-parser.js +++ b/lib/metadata/schema-parser.ts @@ -13,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import events from "events"; +import types from "../types/index.js"; +import utils from "../utils.js"; +import errors from "../errors.js"; +import promiseUtils from "../promise-utils.js"; +import TableMetadata from "./table-metadata.js"; +import Aggregate from "./aggregate.js"; +import SchemaFunction from "./schema-function.js"; +import Index from "./schema-index.js"; +import MaterializedView from "./materialized-view.js"; 'use strict'; -const util = require('util'); -const events = require('events'); -const types = require('../types'); -const utils = require('../utils'); -const errors = require('../errors'); -const promiseUtils = require('../promise-utils'); -const TableMetadata = require('./table-metadata'); -const Aggregate = require('./aggregate'); -const SchemaFunction = require('./schema-function'); -const Index = require('./schema-index'); -const MaterializedView = require('./materialized-view'); const { format } = util; /** @@ -1173,5 +1173,7 @@ function getByVersion(options, cc, udtResolver, version, currentInstance) { return currentInstance; } -exports.getByVersion = getByVersion; -exports.isDoneForToken = isDoneForToken; \ No newline at end of file +export default { + getByVersion, + isDoneForToken +} \ No newline at end of file diff --git a/lib/metadata/table-metadata.js b/lib/metadata/table-metadata.ts similarity index 95% rename from lib/metadata/table-metadata.js rename to lib/metadata/table-metadata.ts index 87e171ef2..e5992c68f 100644 --- a/lib/metadata/table-metadata.js +++ b/lib/metadata/table-metadata.ts @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import DataCollection from "./data-collection.js"; + 'use strict'; -const util = require('util'); -const DataCollection = require('./data-collection'); /** * Creates a new instance of TableMetadata * @classdesc Describes a table @@ -74,4 +75,4 @@ function TableMetadata(name) { util.inherits(TableMetadata, DataCollection); -module.exports = TableMetadata; \ No newline at end of file +export default TableMetadata; \ No newline at end of file diff --git a/lib/metrics/client-metrics.js b/lib/metrics/client-metrics.ts similarity index 99% rename from lib/metrics/client-metrics.js rename to lib/metrics/client-metrics.ts index 88fe073e2..e7b9a61c6 100644 --- a/lib/metrics/client-metrics.js +++ b/lib/metrics/client-metrics.ts @@ -126,4 +126,4 @@ class ClientMetrics { } } -module.exports = ClientMetrics; \ No newline at end of file +export default ClientMetrics; \ No newline at end of file diff --git a/lib/metrics/default-metrics.js b/lib/metrics/default-metrics.ts similarity index 98% rename from lib/metrics/default-metrics.js rename to lib/metrics/default-metrics.ts index 1df5dfaec..8926d6e5f 100644 --- a/lib/metrics/default-metrics.js +++ b/lib/metrics/default-metrics.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ClientMetrics from "./client-metrics.js"; +import EventEmitter from "events"; 'use strict'; -const ClientMetrics = require('./client-metrics'); -const EventEmitter = require('events'); - /** * A default implementation of [ClientMetrics]{@link module:metrics~ClientMetrics} that exposes the driver events as * Node.js events. @@ -195,4 +194,4 @@ class DefaultMetrics extends ClientMetrics { } } -module.exports = DefaultMetrics; \ No newline at end of file +export default DefaultMetrics; \ No newline at end of file diff --git a/lib/metrics/index.js b/lib/metrics/index.ts similarity index 61% rename from lib/metrics/index.js rename to lib/metrics/index.ts index 9afb03a05..ed12a3884 100644 --- a/lib/metrics/index.js +++ b/lib/metrics/index.ts @@ -13,16 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ClientMetrics from "./client-metrics.js"; +import DefaultMetrics from "./default-metrics.js"; 'use strict'; -const ClientMetrics = require('./client-metrics'); -const DefaultMetrics = require('./default-metrics'); - -/** - * The metrics module contains interfaces and implementations used by the driver to expose - * measurements of its internal behavior and of the server as seen from the driver side. - * @module metrics - */ - -module.exports = { ClientMetrics, DefaultMetrics }; \ No newline at end of file +export { ClientMetrics, DefaultMetrics }; +export default { ClientMetrics, DefaultMetrics }; \ No newline at end of file diff --git a/lib/operation-state.js b/lib/operation-state.ts similarity index 96% rename from lib/operation-state.js rename to lib/operation-state.ts index 8fe623d1d..608a6a32a 100644 --- a/lib/operation-state.js +++ b/lib/operation-state.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import utils from "./utils.js"; +import errors from "./errors.js"; +import requests from "./requests.js"; -const util = require('util'); -const utils = require('./utils'); -const errors = require('./errors'); -const requests = require('./requests'); +'use strict'; const ExecuteRequest = requests.ExecuteRequest; const QueryRequest = requests.QueryRequest; @@ -161,4 +161,4 @@ class OperationState { } } -module.exports = OperationState; \ No newline at end of file +export default OperationState; \ No newline at end of file diff --git a/lib/policies/address-resolution.js b/lib/policies/address-resolution.ts similarity index 96% rename from lib/policies/address-resolution.js rename to lib/policies/address-resolution.ts index e0a0fc0be..7d5ac23da 100644 --- a/lib/policies/address-resolution.js +++ b/lib/policies/address-resolution.ts @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import dns from "dns"; +import util from "util"; +import utils from "../utils.js"; + 'use strict'; -const dns = require('dns'); -const util = require('util'); -const utils = require('../utils'); + /** @module policies/addressResolution */ /** * @class @@ -135,5 +137,7 @@ EC2MultiRegionTranslator.prototype.logError = function (address, err) { //Do nothing by default }; -exports.AddressTranslator = AddressTranslator; -exports.EC2MultiRegionTranslator = EC2MultiRegionTranslator; \ No newline at end of file +export { + AddressTranslator, + EC2MultiRegionTranslator +} \ No newline at end of file diff --git a/lib/policies/index.js b/lib/policies/index.ts similarity index 66% rename from lib/policies/index.js rename to lib/policies/index.ts index 9590d6b57..0bf6c4395 100644 --- a/lib/policies/index.js +++ b/lib/policies/index.ts @@ -15,26 +15,18 @@ */ 'use strict'; -/** - * Contains driver tuning policies to determine [load balancing]{@link module:policies/loadBalancing}, - * [retrying]{@link module:policies/retry} queries, [reconnecting]{@link module:policies/reconnection} to a node, - * [address resolution]{@link module:policies/addressResolution}, - * [timestamp generation]{@link module:policies/timestampGeneration} and - * [speculative execution]{@link module:policies/speculativeExecution}. - * @module policies - */ -const addressResolution = exports.addressResolution = require('./address-resolution'); -const loadBalancing = exports.loadBalancing = require('./load-balancing'); -const reconnection = exports.reconnection = require('./reconnection'); -const retry = exports.retry = require('./retry'); -const speculativeExecution = exports.speculativeExecution = require('./speculative-execution'); -const timestampGeneration = exports.timestampGeneration = require('./timestamp-generation'); +import * as addressResolution from './address-resolution.js'; +import * as loadBalancing from './load-balancing.js'; +import * as reconnection from './reconnection.js'; +import * as retry from './retry.js'; +import * as speculativeExecution from './speculative-execution.js'; +import * as timestampGeneration from './timestamp-generation.js'; /** * Returns a new instance of the default address translator policy used by the driver. * @returns {AddressTranslator} */ -exports.defaultAddressTranslator = function () { +const defaultAddressTranslator = function () { return new addressResolution.AddressTranslator(); }; @@ -46,7 +38,7 @@ exports.defaultAddressTranslator = function () { * provided in the {@link ClientOptions}.

* @returns {LoadBalancingPolicy} */ -exports.defaultLoadBalancingPolicy = function (localDc) { +const defaultLoadBalancingPolicy = function (localDc) { return new loadBalancing.DefaultLoadBalancingPolicy(localDc); }; @@ -54,7 +46,7 @@ exports.defaultLoadBalancingPolicy = function (localDc) { * Returns a new instance of the default retry policy used by the driver. * @returns {RetryPolicy} */ -exports.defaultRetryPolicy = function () { +const defaultRetryPolicy = function () { return new retry.RetryPolicy(); }; @@ -62,7 +54,7 @@ exports.defaultRetryPolicy = function () { * Returns a new instance of the default reconnection policy used by the driver. * @returns {ReconnectionPolicy} */ -exports.defaultReconnectionPolicy = function () { +const defaultReconnectionPolicy = function () { return new reconnection.ExponentialReconnectionPolicy(1000, 10 * 60 * 1000, false); }; @@ -71,7 +63,7 @@ exports.defaultReconnectionPolicy = function () { * Returns a new instance of the default speculative execution policy used by the driver. * @returns {SpeculativeExecutionPolicy} */ -exports.defaultSpeculativeExecutionPolicy = function () { +const defaultSpeculativeExecutionPolicy = function () { return new speculativeExecution.NoSpeculativeExecutionPolicy(); }; @@ -79,6 +71,45 @@ exports.defaultSpeculativeExecutionPolicy = function () { * Returns a new instance of the default timestamp generator used by the driver. * @returns {TimestampGenerator} */ -exports.defaultTimestampGenerator = function () { +const defaultTimestampGenerator = function () { return new timestampGeneration.MonotonicTimestampGenerator(); }; + +/** + * Contains driver tuning policies to determine [load balancing]{@link module:policies/loadBalancing}, + * [retrying]{@link module:policies/retry} queries, [reconnecting]{@link module:policies/reconnection} to a node, + * [address resolution]{@link module:policies/addressResolution}, + * [timestamp generation]{@link module:policies/timestampGeneration} and + * [speculative execution]{@link module:policies/speculativeExecution}. + * @module policies + */ + +export { + addressResolution, + loadBalancing, + reconnection, + retry, + speculativeExecution, + timestampGeneration, + defaultAddressTranslator, + defaultLoadBalancingPolicy, + defaultRetryPolicy, + defaultReconnectionPolicy, + defaultSpeculativeExecutionPolicy, + defaultTimestampGenerator +} + +export default { + addressResolution, + loadBalancing, + reconnection, + retry, + speculativeExecution, + timestampGeneration, + defaultAddressTranslator, + defaultLoadBalancingPolicy, + defaultRetryPolicy, + defaultReconnectionPolicy, + defaultSpeculativeExecutionPolicy, + defaultTimestampGenerator +} diff --git a/lib/policies/load-balancing.js b/lib/policies/load-balancing.ts similarity index 98% rename from lib/policies/load-balancing.js rename to lib/policies/load-balancing.ts index de56e0d5c..bbb9a6aca 100644 --- a/lib/policies/load-balancing.js +++ b/lib/policies/load-balancing.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const util = require('util'); -const types = require('../types'); -const utils = require('../utils.js'); -const errors = require('../errors.js'); +import util from "util"; +import types from "../types/index.js"; +import utils from "../utils.js"; +import errors from "../errors.js"; +'use strict'; const doneIteratorObject = Object.freeze({ done: true }); const newlyUpInterval = 60000; @@ -871,7 +870,18 @@ function getDataCenters(hosts) { return new Set(hosts.values().map(h => h.datacenter)); } -module.exports = { +export { + AllowListPolicy, + DCAwareRoundRobinPolicy, + DefaultLoadBalancingPolicy, + LoadBalancingPolicy, + RoundRobinPolicy, + TokenAwarePolicy, + // Deprecated: for backward compatibility only. + WhiteListPolicy +}; + +export default { AllowListPolicy, DCAwareRoundRobinPolicy, DefaultLoadBalancingPolicy, diff --git a/lib/policies/reconnection.js b/lib/policies/reconnection.ts similarity index 95% rename from lib/policies/reconnection.js rename to lib/policies/reconnection.ts index fa6a899ad..890df6c38 100644 --- a/lib/policies/reconnection.js +++ b/lib/policies/reconnection.ts @@ -13,8 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; + 'use strict'; -const util = require('util'); /** @module policies/reconnection */ /** @@ -152,6 +153,14 @@ ExponentialReconnectionPolicy.prototype.getOptions = function () { ]); }; -exports.ReconnectionPolicy = ReconnectionPolicy; -exports.ConstantReconnectionPolicy = ConstantReconnectionPolicy; -exports.ExponentialReconnectionPolicy = ExponentialReconnectionPolicy; \ No newline at end of file +export { + ReconnectionPolicy, + ConstantReconnectionPolicy, + ExponentialReconnectionPolicy +} + +export default { + ReconnectionPolicy, + ConstantReconnectionPolicy, + ExponentialReconnectionPolicy +} \ No newline at end of file diff --git a/lib/policies/retry.js b/lib/policies/retry.ts similarity index 98% rename from lib/policies/retry.js rename to lib/policies/retry.ts index 370d6c5d9..4e2735c79 100644 --- a/lib/policies/retry.js +++ b/lib/policies/retry.ts @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); +import util from "util"; +'use strict'; /** @module policies/retry */ /** @@ -271,6 +271,14 @@ FallthroughRetryPolicy.prototype.onWriteTimeout = function () { * @property {Number} nbRetry The number of retries already performed for this operation. */ -exports.IdempotenceAwareRetryPolicy = IdempotenceAwareRetryPolicy; -exports.FallthroughRetryPolicy = FallthroughRetryPolicy; -exports.RetryPolicy = RetryPolicy; \ No newline at end of file +export { + IdempotenceAwareRetryPolicy, + FallthroughRetryPolicy, + RetryPolicy +} + +export default { + IdempotenceAwareRetryPolicy, + FallthroughRetryPolicy, + RetryPolicy +} \ No newline at end of file diff --git a/lib/policies/speculative-execution.js b/lib/policies/speculative-execution.ts similarity index 93% rename from lib/policies/speculative-execution.js rename to lib/policies/speculative-execution.ts index 7705802cb..ccd79bc5f 100644 --- a/lib/policies/speculative-execution.js +++ b/lib/policies/speculative-execution.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import errors from "../errors.js"; -const util = require('util'); -const errors = require('../errors'); +'use strict'; /** @module policies/speculativeExecution */ @@ -138,6 +138,14 @@ ConstantSpeculativeExecutionPolicy.prototype.getOptions = function () { ]); }; -exports.NoSpeculativeExecutionPolicy = NoSpeculativeExecutionPolicy; -exports.SpeculativeExecutionPolicy = SpeculativeExecutionPolicy; -exports.ConstantSpeculativeExecutionPolicy = ConstantSpeculativeExecutionPolicy; \ No newline at end of file +export { + NoSpeculativeExecutionPolicy, + SpeculativeExecutionPolicy, + ConstantSpeculativeExecutionPolicy +} + +export default{ + NoSpeculativeExecutionPolicy, + SpeculativeExecutionPolicy, + ConstantSpeculativeExecutionPolicy +} \ No newline at end of file diff --git a/lib/policies/timestamp-generation.js b/lib/policies/timestamp-generation.ts similarity index 94% rename from lib/policies/timestamp-generation.js rename to lib/policies/timestamp-generation.ts index dbae075e5..cb2a46223 100644 --- a/lib/policies/timestamp-generation.js +++ b/lib/policies/timestamp-generation.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const util = require('util'); -const { Long } = require('../types'); -const errors = require('../errors'); +import util from "util"; +import { Long } from "../types/index.js"; +import errors from "../errors.js"; +'use strict'; /** @module policies/timestampGeneration */ /** @@ -84,7 +83,7 @@ TimestampGenerator.prototype.next = function (client) { * @extends {TimestampGenerator} * @constructor */ -function MonotonicTimestampGenerator(warningThreshold, minLogInterval) { +function MonotonicTimestampGenerator(warningThreshold?, minLogInterval?) { if (warningThreshold < 0) { throw new errors.ArgumentError('warningThreshold can not be lower than 0'); } @@ -166,5 +165,12 @@ MonotonicTimestampGenerator.prototype._generateMicroseconds = function () { .add(Long.fromInt(this._micros)); }; -exports.TimestampGenerator = TimestampGenerator; -exports.MonotonicTimestampGenerator = MonotonicTimestampGenerator; \ No newline at end of file +export { + TimestampGenerator, + MonotonicTimestampGenerator +} + +export default{ + TimestampGenerator, + MonotonicTimestampGenerator +} \ No newline at end of file diff --git a/lib/prepare-handler.js b/lib/prepare-handler.ts similarity index 97% rename from lib/prepare-handler.js rename to lib/prepare-handler.ts index 0edaa60de..ad0e4212a 100644 --- a/lib/prepare-handler.js +++ b/lib/prepare-handler.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import errors from "./errors.js"; +import utils from "./utils.js"; +import types from "./types/index.js"; +import promiseUtils from "./promise-utils.js"; -const errors = require('./errors'); -const utils = require('./utils'); -const types = require('./types'); -const promiseUtils = require('./promise-utils'); +'use strict'; /** * Encapsulates the logic for dealing with the different prepare request and response flows, including failover when @@ -294,4 +294,4 @@ class PrepareHandler { } } -module.exports = PrepareHandler; \ No newline at end of file +export default PrepareHandler; \ No newline at end of file diff --git a/lib/promise-utils.js b/lib/promise-utils.ts similarity index 99% rename from lib/promise-utils.js rename to lib/promise-utils.ts index 1fc568029..c85b60164 100644 --- a/lib/promise-utils.js +++ b/lib/promise-utils.ts @@ -164,7 +164,7 @@ function toCallback(promise, callback) { err => process.nextTick(() => callback(err))); } -module.exports = { +export default { delay, fromCallback, fromEvent, diff --git a/lib/readers.js b/lib/readers.ts similarity index 98% rename from lib/readers.js rename to lib/readers.ts index 57f0e0f73..0eb4496ee 100644 --- a/lib/readers.js +++ b/lib/readers.ts @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "./utils.js"; +import types from "./types/index.js"; +import errors from "./errors.js"; 'use strict'; - -const util = require('util'); -const utils = require('./utils'); -const types = require('./types'); -const errors = require('./errors'); - /** * Information on the formatting of the returned rows */ @@ -539,4 +537,5 @@ class FrameReader { } } -module.exports = { FrameReader }; +export { FrameReader }; +export default { FrameReader }; \ No newline at end of file diff --git a/lib/request-execution.js b/lib/request-execution.ts similarity index 98% rename from lib/request-execution.js rename to lib/request-execution.ts index 00cd9a5f1..3ca7054e9 100644 --- a/lib/request-execution.js +++ b/lib/request-execution.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const errors = require('./errors'); -const requests = require('./requests'); -const retry = require('./policies/retry'); -const types = require('./types'); -const utils = require('./utils'); -const promiseUtils = require('./promise-utils'); +import errors from "./errors.js"; +import requests from "./requests.js"; +import retry from "./policies/retry.js"; +import types from "./types/index.js"; +import utils from "./utils.js"; +import promiseUtils from "./promise-utils.js"; +'use strict'; const retryOnCurrentHost = Object.freeze({ decision: retry.RetryPolicy.retryDecision.retry, useCurrentHost: true, @@ -494,4 +493,4 @@ class RequestExecution { } } -module.exports = RequestExecution; \ No newline at end of file +export default RequestExecution; \ No newline at end of file diff --git a/lib/request-handler.js b/lib/request-handler.ts similarity index 97% rename from lib/request-handler.js rename to lib/request-handler.ts index c1c7b6daf..d079d34ff 100644 --- a/lib/request-handler.js +++ b/lib/request-handler.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); +import util from "util"; +import errors from "./errors.js"; +import types from "./types/index.js"; +import utils from "./utils.js"; +import RequestExecution from "./request-execution.js"; +import promiseUtils from "./promise-utils.js"; -const errors = require('./errors'); -const types = require('./types'); -const utils = require('./utils'); -const RequestExecution = require('./request-execution'); -const promiseUtils = require('./promise-utils'); +'use strict'; /** * Handles a BATCH, QUERY and EXECUTE request to the server, dealing with host fail-over and retries on error @@ -308,4 +308,4 @@ class RequestHandler { } } -module.exports = RequestHandler; +export default RequestHandler; diff --git a/lib/requests.js b/lib/requests.ts similarity index 96% rename from lib/requests.js rename to lib/requests.ts index 443347ee3..481a6c9b6 100644 --- a/lib/requests.js +++ b/lib/requests.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); - -const { FrameWriter } = require('./writers'); -const types = require('./types'); -const utils = require('./utils'); -const { ExecutionOptions } = require('./execution-options'); -const packageInfo = require('../package.json'); +import util from "util"; +import { FrameWriter } from "./writers.js"; +import types from "./types/index.js"; +import utils from "./utils.js"; +import { ExecutionOptions } from "./execution-options.js"; +import packageInfo from "../package.json" assert {type: 'json'}; +'use strict'; /** * Options for the execution of the query / prepared statement * @private @@ -529,14 +528,30 @@ class OptionsRequest extends Request { const options = new OptionsRequest(); -exports.AuthResponseRequest = AuthResponseRequest; -exports.BatchRequest = BatchRequest; -exports.CancelRequest = CancelRequest; -exports.CredentialsRequest = CredentialsRequest; -exports.ExecuteRequest = ExecuteRequest; -exports.PrepareRequest = PrepareRequest; -exports.QueryRequest = QueryRequest; -exports.Request = Request; -exports.RegisterRequest = RegisterRequest; -exports.StartupRequest = StartupRequest; -exports.options = options; +export { + AuthResponseRequest, + BatchRequest, + CancelRequest, + CredentialsRequest, + ExecuteRequest, + PrepareRequest, + QueryRequest, + Request, + RegisterRequest, + StartupRequest, + options +}; + +export default { + AuthResponseRequest, + BatchRequest, + CancelRequest, + CredentialsRequest, + ExecuteRequest, + PrepareRequest, + QueryRequest, + Request, + RegisterRequest, + StartupRequest, + options +}; diff --git a/lib/stream-id-stack.js b/lib/stream-id-stack.ts similarity index 98% rename from lib/stream-id-stack.js rename to lib/stream-id-stack.ts index 7947af79d..25b128048 100644 --- a/lib/stream-id-stack.js +++ b/lib/stream-id-stack.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const types = require('./types'); +import types from "./types/index.js"; +'use strict'; /** * Group size * @type {number} @@ -197,4 +196,4 @@ function generateGroup(initialValue) { return arr; } -module.exports = StreamIdStack; \ No newline at end of file +export default StreamIdStack; \ No newline at end of file diff --git a/lib/streams.js b/lib/streams.ts similarity index 98% rename from lib/streams.js rename to lib/streams.ts index 158cc8b72..7071787be 100644 --- a/lib/streams.js +++ b/lib/streams.ts @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import { Transform, Writable } from "stream"; +import types from "./types/index.js"; +import utils from "./utils.js"; +import errors from "./errors.js"; +import { FrameReader } from "./readers.js"; 'use strict'; - -const util = require('util'); -const { Transform, Writable } = require('stream'); - -const types = require('./types'); -const utils = require('./utils'); -const errors = require('./errors'); const { FrameHeader } = types; -const { FrameReader } = require('./readers'); /** * Transforms chunks, emits data objects {header, chunk} @@ -577,6 +575,13 @@ ResultEmitter.prototype.bufferAndEmit = function (item) { } }; -exports.Protocol = Protocol; -exports.Parser = Parser; -exports.ResultEmitter = ResultEmitter; +export { + Protocol, + Parser, + ResultEmitter +} +export default { + Protocol, + Parser, + ResultEmitter +} \ No newline at end of file diff --git a/lib/token.js b/lib/token.ts similarity index 96% rename from lib/token.js rename to lib/token.ts index dabed71f1..e7110b462 100644 --- a/lib/token.js +++ b/lib/token.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const types = require('./types'); -const util = require('util'); +import types from "./types/index.js"; +import util from "util"; +'use strict'; const _Murmur3TokenType = types.dataTypes.getByName('bigint'); const _RandomTokenType = types.dataTypes.getByName('varint'); const _OrderedTokenType = types.dataTypes.getByName('blob'); @@ -279,8 +278,18 @@ class TokenRange { } } -exports.Token = Token; -exports.TokenRange = TokenRange; -exports.ByteOrderedToken = ByteOrderedToken; -exports.Murmur3Token = Murmur3Token; -exports.RandomToken = RandomToken; \ No newline at end of file +export { + Token, + TokenRange, + ByteOrderedToken, + Murmur3Token, + RandomToken +} + +export default { + Token, + TokenRange, + ByteOrderedToken, + Murmur3Token, + RandomToken +} \ No newline at end of file diff --git a/lib/tokenizer.js b/lib/tokenizer.ts similarity index 98% rename from lib/tokenizer.js rename to lib/tokenizer.ts index 57340e651..36c90069e 100644 --- a/lib/tokenizer.js +++ b/lib/tokenizer.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import types from "./types/index.js"; +import token from "./token.js"; +import utils from "./utils.js"; +import MutableLong from "./types/mutable-long.js"; -const types = require('./types'); -const token = require('./token'); -const utils = require('./utils'); -const MutableLong = require('./types/mutable-long'); +'use strict'; const { Integer } = types; // Murmur3 constants @@ -579,6 +579,14 @@ function fromSignedByte(value) { return new MutableLong((value - 256) & 0xffff, 0xffff, 0xffff, 0xffff); } -exports.Murmur3Tokenizer = Murmur3Tokenizer; -exports.RandomTokenizer = RandomTokenizer; -exports.ByteOrderedTokenizer = ByteOrderedTokenizer; +export { + Murmur3Tokenizer, + RandomTokenizer, + ByteOrderedTokenizer +} + +export default { + Murmur3Tokenizer, + RandomTokenizer, + ByteOrderedTokenizer +} \ No newline at end of file diff --git a/lib/tracker/index.js b/lib/tracker/index.ts similarity index 76% rename from lib/tracker/index.js rename to lib/tracker/index.ts index 848d5bb3b..bf0255a5b 100644 --- a/lib/tracker/index.js +++ b/lib/tracker/index.ts @@ -21,5 +21,13 @@ * @module tracker */ -exports.RequestLogger = require('./request-logger'); -exports.RequestTracker = require('./request-tracker'); \ No newline at end of file +import RequestTracker from "./request-tracker.js"; +import RequestLogger from "./request-logger.js"; +export { + RequestTracker, + RequestLogger +} +export default { + RequestTracker, + RequestLogger +} \ No newline at end of file diff --git a/lib/tracker/request-logger.js b/lib/tracker/request-logger.ts similarity index 98% rename from lib/tracker/request-logger.js rename to lib/tracker/request-logger.ts index da3d2085a..47d731483 100644 --- a/lib/tracker/request-logger.js +++ b/lib/tracker/request-logger.ts @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import RequestTracker from "./request-tracker.js"; +import errors from "../errors.js"; +import { format } from "util"; 'use strict'; - -const events = require('events'); -const RequestTracker = require('./request-tracker'); -const errors = require('../errors'); -const { format } = require('util'); - const nanosToMillis = 1000000; const defaultMessageMaxQueryLength = 500; const defaultMaxParameterValueLength = 50; @@ -291,4 +289,4 @@ function formatSize(length) { return length > 1000 ? Math.round(length / 1024) + ' KB' : length + ' bytes'; } -module.exports = RequestLogger; \ No newline at end of file +export default RequestLogger; \ No newline at end of file diff --git a/lib/tracker/request-tracker.js b/lib/tracker/request-tracker.ts similarity index 99% rename from lib/tracker/request-tracker.js rename to lib/tracker/request-tracker.ts index 3a00732e1..71e891195 100644 --- a/lib/tracker/request-tracker.js +++ b/lib/tracker/request-tracker.ts @@ -71,4 +71,4 @@ class RequestTracker { } } -module.exports = RequestTracker; \ No newline at end of file +export default RequestTracker; \ No newline at end of file diff --git a/lib/types/big-decimal.js b/lib/types/big-decimal.ts similarity index 98% rename from lib/types/big-decimal.js rename to lib/types/big-decimal.ts index 39ec9f7bc..bf7551932 100644 --- a/lib/types/big-decimal.js +++ b/lib/types/big-decimal.ts @@ -13,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import Integer from "./integer.js"; +import utils from "../utils.js"; + 'use strict'; -const Integer = require('./integer'); -const utils = require('../utils'); /** @module types */ /** @@ -267,5 +268,4 @@ BigDecimal.prototype.toJSON = function () { return this.toString(); }; - -module.exports = BigDecimal; \ No newline at end of file +export default BigDecimal; \ No newline at end of file diff --git a/lib/types/duration.js b/lib/types/duration.ts similarity index 99% rename from lib/types/duration.js rename to lib/types/duration.ts index 4dc084f04..fcf944ca5 100644 --- a/lib/types/duration.js +++ b/lib/types/duration.ts @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const Long = require('long'); -const util = require('util'); -const utils = require('../utils'); +import Long from "long"; +import util from "util"; +import utils from "../utils.js"; + const VIntCoding = utils.VIntCoding; +'use strict'; /** @module types */ // Reuse the same buffers that should perform slightly better than built-in buffer pool @@ -515,4 +516,4 @@ Builder.prototype.build = function () { new Duration(this._months, this._days, this._nanoseconds)); }; -module.exports = Duration; +export default Duration; diff --git a/lib/types/index.js b/lib/types/index.ts similarity index 92% rename from lib/types/index.js rename to lib/types/index.ts index f28dbb551..0821b35a2 100644 --- a/lib/types/index.js +++ b/lib/types/index.ts @@ -13,22 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); - -const errors = require('../errors'); -const TimeUuid = require('./time-uuid'); -const Uuid = require('./uuid'); -const protocolVersion = require('./protocol-version'); -const utils = require('../utils'); +import util from "util"; +import errors from "../errors.js"; +import TimeUuid from "./time-uuid.js"; +import Uuid from "./uuid.js"; +import protocolVersion from "./protocol-version.js"; +import utils from "../utils.js"; +import Long from "long"; +import BigDecimal from './big-decimal.js'; +import Duration from './duration.js'; +import InetAddress from './inet-address.js'; +import Integer from './integer.js'; +import LocalDate from './local-date.js'; +import LocalTime from './local-time.js'; +import ResultSet from './result-set.js'; +import ResultStream from './result-stream.js'; +import Row from './row.js'; +import Tuple from './tuple.js'; +import Vector from "./vector.js"; -/** @module types */ -/** - * Long constructor, wrapper of the internal library used: {@link https://github.com/dcodeIO/long.js Long.js}. - * @constructor - */ -const Long = require('long'); +'use strict'; /** * Consistency levels * @type {Object} @@ -613,36 +618,74 @@ function TimeoutError (message) { } util.inherits(TimeoutError, errors.DriverError); -exports.opcodes = opcodes; -exports.consistencies = consistencies; -exports.consistencyToString = consistencyToString; -exports.dataTypes = dataTypes; -exports.getDataTypeNameByCode = getDataTypeNameByCode; -exports.distance = distance; -exports.frameFlags = frameFlags; -exports.protocolEvents = protocolEvents; -exports.protocolVersion = protocolVersion; -exports.responseErrorCodes = responseErrorCodes; -exports.resultKind = resultKind; -exports.timeuuid = timeuuid; -exports.uuid = uuid; -exports.BigDecimal = require('./big-decimal'); -exports.Duration = require('./duration'); -exports.FrameHeader = FrameHeader; -exports.InetAddress = require('./inet-address'); -exports.Integer = require('./integer'); -exports.LocalDate = require('./local-date'); -exports.LocalTime = require('./local-time'); -exports.Long = Long; -exports.ResultSet = require('./result-set'); -exports.ResultStream = require('./result-stream'); -exports.Row = require('./row'); -//export DriverError for backward-compatibility -exports.DriverError = errors.DriverError; -exports.TimeoutError = TimeoutError; -exports.TimeUuid = TimeUuid; -exports.Tuple = require('./tuple'); -exports.Vector = require('./vector'); -exports.Uuid = Uuid; -exports.unset = unset; -exports.generateTimestamp = generateTimestamp; +const DriverError = errors.DriverError; + +export { + opcodes, + consistencies, + consistencyToString, + dataTypes, + getDataTypeNameByCode, + distance, + frameFlags, + protocolEvents, + protocolVersion, + responseErrorCodes, + resultKind, + timeuuid, + uuid, + BigDecimal, + Duration, + FrameHeader, + InetAddress, + Integer, + LocalDate, + LocalTime, + Long, + ResultSet, + ResultStream, + Row, + DriverError, + TimeoutError, + TimeUuid, + Tuple, + Uuid, + unset, + generateTimestamp, + Vector +} + +export default { + opcodes, + consistencies, + consistencyToString, + dataTypes, + getDataTypeNameByCode, + distance, + frameFlags, + protocolEvents, + protocolVersion, + responseErrorCodes, + resultKind, + timeuuid, + uuid, + BigDecimal, + Duration, + FrameHeader, + InetAddress, + Integer, + LocalDate, + LocalTime, + Long, + ResultSet, + ResultStream, + Row, + DriverError, + TimeoutError, + TimeUuid, + Tuple, + Uuid, + unset, + generateTimestamp, + Vector +} diff --git a/lib/types/inet-address.js b/lib/types/inet-address.ts similarity index 99% rename from lib/types/inet-address.js rename to lib/types/inet-address.ts index 1647deaf6..1edacb04a 100644 --- a/lib/types/inet-address.js +++ b/lib/types/inet-address.ts @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import utils from "../utils.js"; -const utils = require('../utils'); +'use strict'; /** @module types */ /** @@ -245,4 +245,4 @@ function isValidIPv4Mapped(buffer) { return !(buffer[10] !== 255 || buffer[11] !== 255); } -module.exports = InetAddress; \ No newline at end of file +export default InetAddress; \ No newline at end of file diff --git a/lib/types/integer.js b/lib/types/integer.ts similarity index 99% rename from lib/types/integer.js rename to lib/types/integer.ts index d70d789a1..6f05ef2cd 100644 --- a/lib/types/integer.js +++ b/lib/types/integer.ts @@ -1,3 +1,5 @@ +import utils from "../utils.js"; + // Copyright 2009 The Closure Library Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,10 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -/** @module types */ - -var utils = require('../utils'); - /** * Constructs a two's-complement integer an array containing bits of the * integer in 32-bit (signed) pieces, given in little-endian order (i.e., @@ -852,4 +850,4 @@ Integer.prototype.toJSON = function () { return this.toString(); }; -module.exports = Integer; +export default Integer; diff --git a/lib/types/local-date.js b/lib/types/local-date.ts similarity index 98% rename from lib/types/local-date.js rename to lib/types/local-date.ts index 9651d7355..a3fd09cae 100644 --- a/lib/types/local-date.js +++ b/lib/types/local-date.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); +import util from "util"; +import utils from "../utils.js"; -const utils = require('../utils'); +'use strict'; /** @module types */ /** @@ -249,4 +249,4 @@ function fillZeros(value, amount) { return utils.stringRepeat('0', amount - value.length) + value; } -module.exports = LocalDate; \ No newline at end of file +export default LocalDate; \ No newline at end of file diff --git a/lib/types/local-time.js b/lib/types/local-time.ts similarity index 98% rename from lib/types/local-time.js rename to lib/types/local-time.ts index 0e320cc98..468d23b93 100644 --- a/lib/types/local-time.js +++ b/lib/types/local-time.ts @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import Long from "long"; +import util from "util"; +import utils from "../utils.js"; + 'use strict'; -const Long = require('long'); -const util = require('util'); -const utils = require('../utils'); /** @module types */ /** @@ -292,4 +293,4 @@ function formatTime(values) { return result; } -module.exports = LocalTime; \ No newline at end of file +export default LocalTime; \ No newline at end of file diff --git a/lib/types/mutable-long.js b/lib/types/mutable-long.ts similarity index 99% rename from lib/types/mutable-long.js rename to lib/types/mutable-long.ts index 43992d50b..8569d0562 100644 --- a/lib/types/mutable-long.js +++ b/lib/types/mutable-long.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -"use strict"; - -const Long = require('long'); +import Long from "long"; +"use strict"; const TWO_PWR_16_DBL = 1 << 16; const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL; @@ -326,4 +325,4 @@ class MutableLong { MutableLong.one = new MutableLong(1, 0, 0, 0); -module.exports = MutableLong; \ No newline at end of file +export default MutableLong; \ No newline at end of file diff --git a/lib/types/protocol-version.js b/lib/types/protocol-version.ts similarity index 99% rename from lib/types/protocol-version.js rename to lib/types/protocol-version.ts index 4accf2b68..2a0f805e5 100644 --- a/lib/types/protocol-version.js +++ b/lib/types/protocol-version.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import utils from "../utils.js"; +import VersionNumber from "./version-number.js"; -const utils = require('../utils'); -const VersionNumber = require('./version-number'); +'use strict'; const v200 = VersionNumber.parse('2.0.0'); const v210 = VersionNumber.parse('2.1.0'); const v220 = VersionNumber.parse('2.2.0'); @@ -346,4 +346,4 @@ const protocolVersion = { } }; -module.exports = protocolVersion; \ No newline at end of file +export default protocolVersion; \ No newline at end of file diff --git a/lib/types/result-set.js b/lib/types/result-set.ts similarity index 98% rename from lib/types/result-set.js rename to lib/types/result-set.ts index 4137ddb03..e6a6931a1 100644 --- a/lib/types/result-set.js +++ b/lib/types/result-set.ts @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "../utils.js"; +import errors from "../errors.js"; 'use strict'; - -const utils = require('../utils'); -const errors = require('../errors'); - const asyncIteratorSymbol = Symbol.asyncIterator || '@@asyncIterator'; /** @module types */ @@ -272,4 +270,4 @@ ResultSet.prototype.isPaged = function() { return !!this.rawPageState; }; -module.exports = ResultSet; \ No newline at end of file +export default ResultSet; \ No newline at end of file diff --git a/lib/types/result-stream.js b/lib/types/result-stream.ts similarity index 95% rename from lib/types/result-stream.js rename to lib/types/result-stream.ts index 90cb64c74..c95ca2621 100644 --- a/lib/types/result-stream.js +++ b/lib/types/result-stream.ts @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Readable } from "stream"; +import utils from "../utils.js"; +import errors from "../errors.js"; +import clientOptions from "../client-options.js"; 'use strict'; -const { Readable } = require('stream'); -const utils = require('../utils'); -const errors = require('../errors'); -const clientOptions = require('../client-options'); - /** @module types */ /** * Readable stream using to yield data from a result or a field @@ -145,4 +144,4 @@ class ResultStream extends Readable { } } -module.exports = ResultStream; \ No newline at end of file +export default ResultStream; \ No newline at end of file diff --git a/lib/types/row.js b/lib/types/row.ts similarity index 99% rename from lib/types/row.js rename to lib/types/row.ts index fca713211..61e957fcc 100644 --- a/lib/types/row.js +++ b/lib/types/row.ts @@ -77,4 +77,4 @@ Row.prototype.forEach = function (callback) { } }; -module.exports = Row; \ No newline at end of file +export default Row; \ No newline at end of file diff --git a/lib/types/time-uuid.js b/lib/types/time-uuid.ts similarity index 98% rename from lib/types/time-uuid.js rename to lib/types/time-uuid.ts index d4caae67a..4ab69ba3c 100644 --- a/lib/types/time-uuid.js +++ b/lib/types/time-uuid.ts @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); -const crypto = require('crypto'); -const Long = require('long'); - -const Uuid = require('./uuid'); -const utils = require('../utils'); +import util from "util"; +import crypto from "crypto"; +import Long from "long"; +import Uuid from "./uuid.js"; +import utils from "../utils.js"; +'use strict'; /** @module types */ /** * Oct 15, 1582 in milliseconds since unix epoch @@ -407,4 +406,4 @@ function generateBuffer(date, ticks, nodeId, clockId) { return buffer; } -module.exports = TimeUuid; \ No newline at end of file +export default TimeUuid; \ No newline at end of file diff --git a/lib/types/tuple.js b/lib/types/tuple.ts similarity index 99% rename from lib/types/tuple.js rename to lib/types/tuple.ts index f8989ccb7..f3e415f0c 100644 --- a/lib/types/tuple.js +++ b/lib/types/tuple.ts @@ -99,4 +99,4 @@ Tuple.prototype.values = function () { return this.elements.slice(0); }; -module.exports = Tuple; \ No newline at end of file +export default Tuple; \ No newline at end of file diff --git a/lib/types/uuid.js b/lib/types/uuid.ts similarity index 97% rename from lib/types/uuid.js rename to lib/types/uuid.ts index 56281d58f..9ec0d3ca1 100644 --- a/lib/types/uuid.js +++ b/lib/types/uuid.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import crypto from "crypto"; +import utils from "../utils.js"; -const crypto = require('crypto'); -const utils = require('../utils'); +'use strict'; /** @module types */ @@ -150,4 +150,4 @@ function getRandomBytes (cb) { return crypto.randomBytes(16, cb); } -module.exports = Uuid; +export default Uuid; diff --git a/lib/types/vector.js b/lib/types/vector.ts similarity index 98% rename from lib/types/vector.js rename to lib/types/vector.ts index 308511eea..856a6f753 100644 --- a/lib/types/vector.js +++ b/lib/types/vector.ts @@ -19,7 +19,7 @@ * Creates a new instance of Cql Vector, also compatible with Float32Array. * @class */ -const util = require('node:util'); +import util from 'util'; class Vector { /** * @@ -119,4 +119,4 @@ Object.defineProperty(Vector, Symbol.hasInstance, { return (util.types.isProxy(i) && i.IDENTITY === 'Vector') || i instanceof Float32Array; } }); -module.exports = Vector; +export default Vector; diff --git a/lib/types/version-number.js b/lib/types/version-number.ts similarity index 99% rename from lib/types/version-number.js rename to lib/types/version-number.ts index 7f5b74300..bbbe81893 100644 --- a/lib/types/version-number.js +++ b/lib/types/version-number.ts @@ -141,4 +141,4 @@ class VersionNumber { } } -module.exports = VersionNumber; \ No newline at end of file +export default VersionNumber; \ No newline at end of file diff --git a/lib/utils.js b/lib/utils.ts similarity index 94% rename from lib/utils.js rename to lib/utils.ts index dfc217a7b..8aecdbf52 100644 --- a/lib/utils.js +++ b/lib/utils.ts @@ -13,16 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const Long = require('long'); -const util = require('util'); -const net = require('net'); -const { EventEmitter } = require('events'); - -const errors = require('./errors'); -const promiseUtils = require('./promise-utils'); +import util from "util"; +import net from "net"; +import { EventEmitter } from "events"; +import errors from "./errors.js"; +import promiseUtils from "./promise-utils.js"; +'use strict'; /** * Max int that can be accurately represented with 64-bit Number (2^53) * @type {number} @@ -73,7 +70,7 @@ function allocBufferFillDeprecated(size) { return b; } -function allocBufferFromStringDeprecated(text, encoding) { +function allocBufferFromStringDeprecated(text, encoding?) { if (typeof text !== 'string') { throw new TypeError('Expected string, obtained ' + util.inspect(text)); } @@ -1041,7 +1038,6 @@ function whilst(condition, fn, callback) { } } - /** * Contains the methods for reading and writing vints into binary format. * Exposes only 2 internal methods, the rest are hidden. @@ -1370,49 +1366,50 @@ const VIntCoding = (function () { }; })(); -exports.adaptNamedParamsPrepared = adaptNamedParamsPrepared; -exports.adaptNamedParamsWithHints = adaptNamedParamsWithHints; -exports.AddressResolver = AddressResolver; -exports.allocBuffer = allocBuffer; -exports.allocBufferUnsafe = allocBufferUnsafe; -exports.allocBufferFromArray = allocBufferFromArray; -exports.allocBufferFromString = allocBufferFromString; -exports.arrayIterator = arrayIterator; -exports.binarySearch = binarySearch; -exports.callbackOnce = callbackOnce; -exports.copyBuffer = copyBuffer; -exports.deepExtend = deepExtend; -exports.each = each; -exports.eachSeries = eachSeries; -/** @const */ -exports.emptyArray = Object.freeze([]); -/** @const */ -exports.emptyObject = emptyObject; -exports.extend = extend; -exports.fixStack = fixStack; -exports.forEachOf = forEachOf; -exports.funcCompare = funcCompare; -exports.ifUndefined = ifUndefined; -exports.ifUndefined3 = ifUndefined3; -exports.insertSorted = insertSorted; -exports.iteratorToArray = iteratorToArray; -exports.log = log; -exports.map = map; -exports.mapSeries = mapSeries; -exports.maxInt = maxInt; -exports.noop = noop; -exports.objectValues = objectValues; -exports.parallel = parallel; -exports.promiseWrapper = promiseWrapper; -exports.propCompare = propCompare; -exports.series = series; -exports.shuffleArray = shuffleArray; -exports.stringRepeat = stringRepeat; -exports.times = times; -exports.timesLimit = timesLimit; -exports.timesSeries = timesSeries; -exports.totalLength = totalLength; -exports.validateFn = validateFn; -exports.whilst = whilst; -exports.HashSet = HashSet; -exports.VIntCoding = VIntCoding; \ No newline at end of file + +export default { + adaptNamedParamsPrepared, + adaptNamedParamsWithHints, + AddressResolver, + allocBuffer, + allocBufferUnsafe, + allocBufferFromArray, + allocBufferFromString, + arrayIterator, + binarySearch, + callbackOnce, + copyBuffer, + deepExtend, + each, + eachSeries, + emptyArray, + emptyObject, + extend, + fixStack, + forEachOf, + funcCompare, + ifUndefined, + ifUndefined3, + insertSorted, + iteratorToArray, + log, + map, + mapSeries, + maxInt, + noop, + objectValues, + parallel, + promiseWrapper, + propCompare, + series, + shuffleArray, + stringRepeat, + times, + timesLimit, + timesSeries, + totalLength, + validateFn, + whilst, + HashSet, + VIntCoding +}; diff --git a/lib/writers.js b/lib/writers.ts similarity index 98% rename from lib/writers.js rename to lib/writers.ts index a3d4f2816..9f531b1a6 100644 --- a/lib/writers.js +++ b/lib/writers.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const events = require('events'); +import events from "events"; +import types from "./types/index.js"; +import utils from "./utils.js"; -const types = require('./types'); -const utils = require('./utils.js'); +'use strict'; const FrameHeader = types.FrameHeader; /** @@ -307,4 +307,4 @@ class WriteQueue extends events.EventEmitter { } } -module.exports = { FrameWriter, WriteQueue }; +export { FrameWriter, WriteQueue }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index cc1b48b1b..89a2bee78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,13 +14,16 @@ "long": "~5.2.3" }, "devDependencies": { + "@types/mocha": "^10.0.10", "chai": "~4.3.8", "kerberos": "~2.0.3", "mocha": "~10.2.0", "mocha-jenkins-reporter": "~0.4.8", "proxyquire": "~2.1.3", "sinon": "~15.2.0", - "temp": ">= 0.8.3" + "temp": ">= 0.8.3", + "ts-mocha": "^10.0.0", + "typescript": "^5.7.3" }, "engines": { "node": ">=18" @@ -70,6 +73,19 @@ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true, + "optional": true + }, + "node_modules/@types/mocha": { + "version": "10.0.10", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.10.tgz", + "integrity": "sha512-xPyYSz1cMPnJQhl0CLMH68j3gprKZaTjG3s5Vi+fDgx+uhG9NOXwbVt52eFS8ECyXhyKcjDLCBEqBExKuiZb7Q==", + "dev": true + }, "node_modules/@types/node": { "version": "18.19.53", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.53.tgz", @@ -138,6 +154,15 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -268,6 +293,12 @@ "ieee754": "^1.1.13" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, "node_modules/camelcase": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", @@ -605,20 +636,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -876,6 +893,19 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "optional": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, "node_modules/just-extend": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", @@ -948,6 +978,12 @@ "get-func-name": "^2.0.0" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", @@ -1537,6 +1573,25 @@ "node": ">=8" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -1578,6 +1633,16 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "optional": true, + "engines": { + "node": ">=4" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -1684,6 +1749,71 @@ "node": ">=8.0" } }, + "node_modules/ts-mocha": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-10.0.0.tgz", + "integrity": "sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==", + "dev": true, + "dependencies": { + "ts-node": "7.0.1" + }, + "bin": { + "ts-mocha": "bin/ts-mocha" + }, + "engines": { + "node": ">= 6.X.X" + }, + "optionalDependencies": { + "tsconfig-paths": "^3.5.0" + }, + "peerDependencies": { + "mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X" + } + }, + "node_modules/ts-node": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", + "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", + "dev": true, + "dependencies": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "bin": { + "ts-node": "dist/bin.js" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "optional": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -1705,6 +1835,19 @@ "node": ">=4" } }, + "node_modules/typescript": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", @@ -1802,6 +1945,15 @@ "node": ">=10" } }, + "node_modules/yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index c1c72aa30..e06f761a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "cassandra-driver", - "version": "4.8.0", + "name": "@SiyaoIsHiding/cassandra-driver", + "version": "0.0.8", "description": "DataStax Node.js Driver for Apache Cassandra", "author": "DataStax", "keywords": [ @@ -18,7 +18,8 @@ "graphdb" ], "license": "Apache-2.0", - "types": "./index.d.ts", + "types": "out/index.d.ts", + "main": "out/index.js", "dependencies": { "@types/node": "^18.11.18", "adm-zip": "~0.5.10", @@ -49,7 +50,8 @@ "ci_appveyor": ".\\\"node_modules/.bin/mocha\" test/unit test/integration/short --recursive -R mocha-appveyor-reporter --exit", "ci_unit_appveyor": ".\\\"node_modules/.bin/mocha\" test/unit --recursive -R mocha-appveyor-reporter --exit", "server_api": "./node_modules/.bin/mocha test/integration/short -g '@SERVER_API' --recursive --exit", - "eslint": "eslint lib test" + "eslint": "eslint lib test", + "test-ts": "npx ts-mocha test/unit test/integration/short --extension .ts --recursive --exit" }, "engines": { "node": ">=18" diff --git a/test/integration/long/client-metadata-tests.js b/test/integration/long/client-metadata-tests.ts similarity index 100% rename from test/integration/long/client-metadata-tests.js rename to test/integration/long/client-metadata-tests.ts diff --git a/test/integration/long/event-tests.js b/test/integration/long/event-tests.ts similarity index 100% rename from test/integration/long/event-tests.js rename to test/integration/long/event-tests.ts diff --git a/test/integration/long/load-balancing-tests.js b/test/integration/long/load-balancing-tests.ts similarity index 98% rename from test/integration/long/load-balancing-tests.js rename to test/integration/long/load-balancing-tests.ts index 2755f9e01..d28f6dd32 100644 --- a/test/integration/long/load-balancing-tests.js +++ b/test/integration/long/load-balancing-tests.ts @@ -17,10 +17,10 @@ const assert = require('assert'); const util = require('util'); -const helper = require('../../test-helper.js'); -const Client = require('../../../lib/client.js'); -const utils = require('../../../lib/utils.js'); -const loadBalancing = require('../../../lib/policies/load-balancing.js'); +const helper = require('../../test-helper'); +const Client = require('../../../lib/client'); +const utils = require('../../../lib/utils'); +const loadBalancing = require('../../../lib/policies/load-balancing'); const DCAwareRoundRobinPolicy = loadBalancing.DCAwareRoundRobinPolicy; const TokenAwarePolicy = loadBalancing.TokenAwarePolicy; diff --git a/test/integration/short/auth/dse-gssapi-auth-provider-tests.js b/test/integration/short/auth/dse-gssapi-auth-provider-tests.ts similarity index 97% rename from test/integration/short/auth/dse-gssapi-auth-provider-tests.js rename to test/integration/short/auth/dse-gssapi-auth-provider-tests.ts index 327d1d11e..82e49d7af 100644 --- a/test/integration/short/auth/dse-gssapi-auth-provider-tests.js +++ b/test/integration/short/auth/dse-gssapi-auth-provider-tests.ts @@ -16,7 +16,7 @@ 'use strict'; const assert = require('assert'); const helper = require('../../../test-helper'); -const DseGssapiAuthProvider = require('../../../../lib/auth/dse-gssapi-auth-provider'); +import DseGssapiAuthProvider from '../../../../lib/auth/dse-gssapi-auth-provider'; const Client = require('../../../../lib/client'); const errors = require('../../../../lib/errors'); const ads = helper.ads; diff --git a/test/integration/short/auth/dse-plain-text-auth-provider-tests.js b/test/integration/short/auth/dse-plain-text-auth-provider-tests.ts similarity index 97% rename from test/integration/short/auth/dse-plain-text-auth-provider-tests.js rename to test/integration/short/auth/dse-plain-text-auth-provider-tests.ts index 202ffda9a..2f1c0aa36 100644 --- a/test/integration/short/auth/dse-plain-text-auth-provider-tests.js +++ b/test/integration/short/auth/dse-plain-text-auth-provider-tests.ts @@ -16,7 +16,7 @@ 'use strict'; const { assert } = require('chai'); const helper = require('../../../test-helper'); -const DsePlainTextAuthProvider = require('../../../../lib/auth/dse-plain-text-auth-provider'); +import DsePlainTextAuthProvider from '../../../../lib/auth/dse-plain-text-auth-provider'; const Client = require('../../../../lib/client'); const vdescribe = helper.vdescribe; diff --git a/test/integration/short/auth/proxy-authentication-test.js b/test/integration/short/auth/proxy-authentication-test.ts similarity index 97% rename from test/integration/short/auth/proxy-authentication-test.js rename to test/integration/short/auth/proxy-authentication-test.ts index cd6c9ba37..f751299c7 100644 --- a/test/integration/short/auth/proxy-authentication-test.js +++ b/test/integration/short/auth/proxy-authentication-test.ts @@ -16,8 +16,8 @@ 'use strict'; const assert = require('assert'); const helper = require('../../../test-helper'); -const DsePlainTextAuthProvider = require('../../../../lib/auth/dse-plain-text-auth-provider'); -const DseGssapiAuthProvider = require('../../../../lib/auth/dse-gssapi-auth-provider'); +import DsePlainTextAuthProvider from '../../../../lib/auth/dse-plain-text-auth-provider'; +import DseGssapiAuthProvider from '../../../../lib/auth/dse-gssapi-auth-provider'; const Client = require('../../../../lib/client'); const utils = require('../../../../lib/utils'); const errors = require('../../../../lib/errors'); diff --git a/test/integration/short/client-batch-tests.js b/test/integration/short/client-batch-tests.ts similarity index 99% rename from test/integration/short/client-batch-tests.js rename to test/integration/short/client-batch-tests.ts index 46564d951..662a7f809 100644 --- a/test/integration/short/client-batch-tests.js +++ b/test/integration/short/client-batch-tests.ts @@ -17,11 +17,11 @@ const assert = require('assert'); const util = require('util'); -const helper = require('../../test-helper.js'); -const Client = require('../../../lib/client.js'); +const helper = require('../../test-helper'); +const Client = require('../../../lib/client'); const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); +const utils = require('../../../lib/utils'); +const errors = require('../../../lib/errors'); const vit = helper.vit; describe('Client @SERVER_API', function () { diff --git a/test/integration/short/client-each-row-tests.js b/test/integration/short/client-each-row-tests.ts similarity index 99% rename from test/integration/short/client-each-row-tests.js rename to test/integration/short/client-each-row-tests.ts index af1240ad5..552a5dbd3 100644 --- a/test/integration/short/client-each-row-tests.js +++ b/test/integration/short/client-each-row-tests.ts @@ -19,11 +19,11 @@ const assert = require('chai').assert; const util = require('util'); const sinon = require('sinon'); -const helper = require('../../test-helper.js'); -const Client = require('../../../lib/client.js'); +const helper = require('../../test-helper'); +const Client = require('../../../lib/client'); const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); +const utils = require('../../../lib/utils'); +const errors = require('../../../lib/errors'); const vit = helper.vit; describe('Client', function () { diff --git a/test/integration/short/client-execute-prepared-tests.js b/test/integration/short/client-execute-prepared-tests.ts similarity index 100% rename from test/integration/short/client-execute-prepared-tests.js rename to test/integration/short/client-execute-prepared-tests.ts diff --git a/test/integration/short/client-execute-simulator-tests.js b/test/integration/short/client-execute-simulator-tests.ts similarity index 100% rename from test/integration/short/client-execute-simulator-tests.js rename to test/integration/short/client-execute-simulator-tests.ts diff --git a/test/integration/short/client-execute-tests.js b/test/integration/short/client-execute-tests.ts similarity index 99% rename from test/integration/short/client-execute-tests.js rename to test/integration/short/client-execute-tests.ts index 30575693f..9a24f2412 100644 --- a/test/integration/short/client-execute-tests.js +++ b/test/integration/short/client-execute-tests.ts @@ -17,12 +17,12 @@ const assert = require('assert'); const util = require('util'); -const helper = require('../../test-helper.js'); -const Client = require('../../../lib/client.js'); -const ExecutionProfile = require('../../../lib/execution-profile.js').ExecutionProfile; +const helper = require('../../test-helper'); +const Client = require('../../../lib/client'); +const ExecutionProfile = require('../../../lib/execution-profile').ExecutionProfile; const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); +const utils = require('../../../lib/utils'); +const errors = require('../../../lib/errors'); const vit = helper.vit; const vdescribe = helper.vdescribe; const numericTests = require('./numeric-tests'); diff --git a/test/integration/short/client-pool-tests.js b/test/integration/short/client-pool-tests.ts similarity index 99% rename from test/integration/short/client-pool-tests.js rename to test/integration/short/client-pool-tests.ts index 212d2f521..6e9009242 100644 --- a/test/integration/short/client-pool-tests.js +++ b/test/integration/short/client-pool-tests.ts @@ -26,9 +26,9 @@ const utils = require('../../../lib/utils'); const errors = require('../../../lib/errors'); const types = require('../../../lib/types'); const policies = require('../../../lib/policies'); -const RoundRobinPolicy = require('../../../lib/policies/load-balancing.js').RoundRobinPolicy; -const Murmur3Tokenizer = require('../../../lib/tokenizer.js').Murmur3Tokenizer; -const { PlainTextAuthProvider } = require('../../../lib/auth'); +const RoundRobinPolicy = require('../../../lib/policies/load-balancing').RoundRobinPolicy; +const Murmur3Tokenizer = require('../../../lib/tokenizer').Murmur3Tokenizer; +import { PlainTextAuthProvider } from '../../../lib/auth'; const ConstantSpeculativeExecutionPolicy = policies.speculativeExecution.ConstantSpeculativeExecutionPolicy; const OrderedLoadBalancingPolicy = helper.OrderedLoadBalancingPolicy; const vit = helper.vit; diff --git a/test/integration/short/client-stream-tests.js b/test/integration/short/client-stream-tests.ts similarity index 98% rename from test/integration/short/client-stream-tests.js rename to test/integration/short/client-stream-tests.ts index 0ed8ab039..d7ca1ff79 100644 --- a/test/integration/short/client-stream-tests.js +++ b/test/integration/short/client-stream-tests.ts @@ -17,12 +17,12 @@ const assert = require('assert'); const util = require('util'); -const helper = require('../../test-helper.js'); +const helper = require('../../test-helper'); const vit = helper.vit; -const Client = require('../../../lib/client.js'); +const Client = require('../../../lib/client'); const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); +const utils = require('../../../lib/utils'); +const errors = require('../../../lib/errors'); describe('Client', function () { this.timeout(120000); diff --git a/test/integration/short/cloud/cloud-helper.js b/test/integration/short/cloud/cloud-helper.ts similarity index 100% rename from test/integration/short/cloud/cloud-helper.js rename to test/integration/short/cloud/cloud-helper.ts diff --git a/test/integration/short/cloud/cloud-tests.js b/test/integration/short/cloud/cloud-tests.ts similarity index 100% rename from test/integration/short/cloud/cloud-tests.js rename to test/integration/short/cloud/cloud-tests.ts diff --git a/test/integration/short/concurrent/execute-concurrent-tests.js b/test/integration/short/concurrent/execute-concurrent-tests.ts similarity index 100% rename from test/integration/short/concurrent/execute-concurrent-tests.js rename to test/integration/short/concurrent/execute-concurrent-tests.ts diff --git a/test/integration/short/connection-tests.js b/test/integration/short/connection-tests.ts similarity index 97% rename from test/integration/short/connection-tests.js rename to test/integration/short/connection-tests.ts index 28d304a5d..90318c3c0 100644 --- a/test/integration/short/connection-tests.js +++ b/test/integration/short/connection-tests.ts @@ -18,12 +18,12 @@ const assert = require('chai').assert; const sinon = require('sinon'); -const Connection = require('../../../lib/connection.js'); -const defaultOptions = require('../../../lib/client-options.js').defaultOptions(); -const utils = require('../../../lib/utils.js'); -const requests = require('../../../lib/requests.js'); +const Connection = require('../../../lib/connection'); +const defaultOptions = require('../../../lib/client-options').defaultOptions(); +const utils = require('../../../lib/utils'); +const requests = require('../../../lib/requests'); const protocolVersion = require('../../../lib/types').protocolVersion; -const helper = require('../../test-helper.js'); +const helper = require('../../test-helper'); const errors = require('../../../lib/errors'); const types = require('../../../lib/types'); const vit = helper.vit; diff --git a/test/integration/short/control-connection-simulator-tests.js b/test/integration/short/control-connection-simulator-tests.ts similarity index 99% rename from test/integration/short/control-connection-simulator-tests.js rename to test/integration/short/control-connection-simulator-tests.ts index a5f8db99c..13deac501 100644 --- a/test/integration/short/control-connection-simulator-tests.js +++ b/test/integration/short/control-connection-simulator-tests.ts @@ -21,7 +21,7 @@ const simulacron = require('../simulacron'); const utils = require('../../../lib/utils'); const types = require('../../../lib/types'); -const Client = require('../../../lib/client.js'); +const Client = require('../../../lib/client'); describe('ControlConnection', function() { this.timeout(5000); diff --git a/test/integration/short/control-connection-tests.js b/test/integration/short/control-connection-tests.ts similarity index 99% rename from test/integration/short/control-connection-tests.js rename to test/integration/short/control-connection-tests.ts index b48102160..4908638aa 100644 --- a/test/integration/short/control-connection-tests.js +++ b/test/integration/short/control-connection-tests.ts @@ -18,7 +18,7 @@ const assert = require('assert'); const util = require('util'); const helper = require('../../test-helper'); -const Client = require('../../../lib/client.js'); +const Client = require('../../../lib/client'); const ControlConnection = require('../../../lib/control-connection'); const utils = require('../../../lib/utils'); const types = require('../../../lib/types'); diff --git a/test/integration/short/custom-payload-tests.js b/test/integration/short/custom-payload-tests.ts similarity index 100% rename from test/integration/short/custom-payload-tests.js rename to test/integration/short/custom-payload-tests.ts diff --git a/test/integration/short/duration-type-tests.js b/test/integration/short/duration-type-tests.ts similarity index 100% rename from test/integration/short/duration-type-tests.js rename to test/integration/short/duration-type-tests.ts diff --git a/test/integration/short/error-simulator-tests.js b/test/integration/short/error-simulator-tests.ts similarity index 100% rename from test/integration/short/error-simulator-tests.js rename to test/integration/short/error-simulator-tests.ts diff --git a/test/integration/short/error-tests.js b/test/integration/short/error-tests.ts similarity index 100% rename from test/integration/short/error-tests.js rename to test/integration/short/error-tests.ts diff --git a/test/integration/short/execution-profile-tests.js b/test/integration/short/execution-profile-tests.ts similarity index 100% rename from test/integration/short/execution-profile-tests.js rename to test/integration/short/execution-profile-tests.ts diff --git a/test/integration/short/geometry/line-string-tests.js b/test/integration/short/geometry/line-string-tests.ts similarity index 100% rename from test/integration/short/geometry/line-string-tests.js rename to test/integration/short/geometry/line-string-tests.ts diff --git a/test/integration/short/geometry/point-tests.js b/test/integration/short/geometry/point-tests.ts similarity index 100% rename from test/integration/short/geometry/point-tests.js rename to test/integration/short/geometry/point-tests.ts diff --git a/test/integration/short/geometry/polygon-tests.js b/test/integration/short/geometry/polygon-tests.ts similarity index 100% rename from test/integration/short/geometry/polygon-tests.js rename to test/integration/short/geometry/polygon-tests.ts diff --git a/test/integration/short/graph/graph-olap-tests.js b/test/integration/short/graph/graph-olap-tests.ts similarity index 100% rename from test/integration/short/graph/graph-olap-tests.js rename to test/integration/short/graph/graph-olap-tests.ts diff --git a/test/integration/short/graph/graph-test-helper.js b/test/integration/short/graph/graph-test-helper.ts similarity index 100% rename from test/integration/short/graph/graph-test-helper.js rename to test/integration/short/graph/graph-test-helper.ts diff --git a/test/integration/short/graph/graph-tests.js b/test/integration/short/graph/graph-tests.ts similarity index 100% rename from test/integration/short/graph/graph-tests.js rename to test/integration/short/graph/graph-tests.ts diff --git a/test/integration/short/graph/graph-timeout-tests.js b/test/integration/short/graph/graph-timeout-tests.ts similarity index 100% rename from test/integration/short/graph/graph-timeout-tests.js rename to test/integration/short/graph/graph-timeout-tests.ts diff --git a/test/integration/short/graph/graph-with-down-node-tests.js b/test/integration/short/graph/graph-with-down-node-tests.ts similarity index 100% rename from test/integration/short/graph/graph-with-down-node-tests.js rename to test/integration/short/graph/graph-with-down-node-tests.ts diff --git a/test/integration/short/insights-simulator-tests.js b/test/integration/short/insights-simulator-tests.ts similarity index 100% rename from test/integration/short/insights-simulator-tests.js rename to test/integration/short/insights-simulator-tests.ts diff --git a/test/integration/short/load-balancing-simulator-tests.js b/test/integration/short/load-balancing-simulator-tests.ts similarity index 100% rename from test/integration/short/load-balancing-simulator-tests.js rename to test/integration/short/load-balancing-simulator-tests.ts diff --git a/test/integration/short/load-balancing-tests.js b/test/integration/short/load-balancing-tests.ts similarity index 100% rename from test/integration/short/load-balancing-tests.js rename to test/integration/short/load-balancing-tests.ts diff --git a/test/integration/short/mapping/custom-queries-tests.js b/test/integration/short/mapping/custom-queries-tests.ts similarity index 100% rename from test/integration/short/mapping/custom-queries-tests.js rename to test/integration/short/mapping/custom-queries-tests.ts diff --git a/test/integration/short/mapping/from-and-to-model-function-tests.js b/test/integration/short/mapping/from-and-to-model-function-tests.ts similarity index 100% rename from test/integration/short/mapping/from-and-to-model-function-tests.js rename to test/integration/short/mapping/from-and-to-model-function-tests.ts diff --git a/test/integration/short/mapping/mapper-test-helper.js b/test/integration/short/mapping/mapper-test-helper.ts similarity index 100% rename from test/integration/short/mapping/mapper-test-helper.js rename to test/integration/short/mapping/mapper-test-helper.ts diff --git a/test/integration/short/mapping/mapper-tests.js b/test/integration/short/mapping/mapper-tests.ts similarity index 100% rename from test/integration/short/mapping/mapper-tests.js rename to test/integration/short/mapping/mapper-tests.ts diff --git a/test/integration/short/mapping/model-mapper-tests.js b/test/integration/short/mapping/model-mapper-tests.ts similarity index 100% rename from test/integration/short/mapping/model-mapper-tests.js rename to test/integration/short/mapping/model-mapper-tests.ts diff --git a/test/integration/short/metadata-simulator-tests.js b/test/integration/short/metadata-simulator-tests.ts similarity index 100% rename from test/integration/short/metadata-simulator-tests.js rename to test/integration/short/metadata-simulator-tests.ts diff --git a/test/integration/short/metadata-tests.js b/test/integration/short/metadata-tests.ts similarity index 100% rename from test/integration/short/metadata-tests.js rename to test/integration/short/metadata-tests.ts diff --git a/test/integration/short/numeric-tests.js b/test/integration/short/numeric-tests.ts similarity index 100% rename from test/integration/short/numeric-tests.js rename to test/integration/short/numeric-tests.ts diff --git a/test/integration/short/paging-tests.js b/test/integration/short/paging-tests.ts similarity index 100% rename from test/integration/short/paging-tests.js rename to test/integration/short/paging-tests.ts diff --git a/test/integration/short/pool-simulator-tests.js b/test/integration/short/pool-simulator-tests.ts similarity index 100% rename from test/integration/short/pool-simulator-tests.js rename to test/integration/short/pool-simulator-tests.ts diff --git a/test/integration/short/prepare-simulator-tests.js b/test/integration/short/prepare-simulator-tests.ts similarity index 100% rename from test/integration/short/prepare-simulator-tests.js rename to test/integration/short/prepare-simulator-tests.ts diff --git a/test/integration/short/retry-simulator-tests.js b/test/integration/short/retry-simulator-tests.ts similarity index 100% rename from test/integration/short/retry-simulator-tests.js rename to test/integration/short/retry-simulator-tests.ts diff --git a/test/integration/short/search/date-range-tests.js b/test/integration/short/search/date-range-tests.ts similarity index 100% rename from test/integration/short/search/date-range-tests.js rename to test/integration/short/search/date-range-tests.ts diff --git a/test/integration/short/speculative-execution-simulator-tests.js b/test/integration/short/speculative-execution-simulator-tests.ts similarity index 99% rename from test/integration/short/speculative-execution-simulator-tests.js rename to test/integration/short/speculative-execution-simulator-tests.ts index b5984a3b4..d19e8e956 100644 --- a/test/integration/short/speculative-execution-simulator-tests.js +++ b/test/integration/short/speculative-execution-simulator-tests.ts @@ -20,7 +20,7 @@ const simulacron = require('../simulacron'); const helper = require('../../test-helper'); const utils = require('../../../lib/utils'); -const Client = require('../../../lib/client.js'); +const Client = require('../../../lib/client'); const ConstantSpeculativeExecutionPolicy = require('../../../lib/policies/speculative-execution').ConstantSpeculativeExecutionPolicy; const NoSpeculativeExecutionPolicy = require('../../../lib/policies/speculative-execution').NoSpeculativeExecutionPolicy; const OrderedLoadBalancingPolicy = require('../../test-helper').OrderedLoadBalancingPolicy; diff --git a/test/integration/short/ssl-tests.js b/test/integration/short/ssl-tests.ts similarity index 100% rename from test/integration/short/ssl-tests.js rename to test/integration/short/ssl-tests.ts diff --git a/test/integration/short/timeout-simulator-tests.js b/test/integration/short/timeout-simulator-tests.ts similarity index 100% rename from test/integration/short/timeout-simulator-tests.js rename to test/integration/short/timeout-simulator-tests.ts diff --git a/test/integration/short/tracker-simulator-tests.js b/test/integration/short/tracker-simulator-tests.ts similarity index 100% rename from test/integration/short/tracker-simulator-tests.js rename to test/integration/short/tracker-simulator-tests.ts diff --git a/test/integration/short/udf-tests.js b/test/integration/short/udf-tests.ts similarity index 100% rename from test/integration/short/udf-tests.js rename to test/integration/short/udf-tests.ts diff --git a/test/integration/short/vector-tests.js b/test/integration/short/vector-tests.ts similarity index 100% rename from test/integration/short/vector-tests.js rename to test/integration/short/vector-tests.ts diff --git a/test/integration/simulacron.js b/test/integration/simulacron.ts similarity index 99% rename from test/integration/simulacron.js rename to test/integration/simulacron.ts index 4f1449243..88d4481e6 100644 --- a/test/integration/simulacron.js +++ b/test/integration/simulacron.ts @@ -19,8 +19,8 @@ const http = require('http'); const spawn = require('child_process').spawn; const util = require('util'); const fs = require('fs'); -const utils = require('../../lib/utils.js'); -const Client = require('../../lib/client.js'); +const utils = require('../../lib/utils'); +const Client = require('../../lib/client'); const simulacronHelper = { _execute: function(processName, params, cb) { diff --git a/test/other/memory/basic-profile.js b/test/other/memory/basic-profile.ts similarity index 97% rename from test/other/memory/basic-profile.js rename to test/other/memory/basic-profile.ts index 75b452811..50b75c404 100644 --- a/test/other/memory/basic-profile.js +++ b/test/other/memory/basic-profile.ts @@ -27,8 +27,8 @@ catch (e) { console.error('There was an error while trying to import heapdump', e); } -const helper = require('../../test-helper.js'); -const cassandra = require('../../../index.js'); +const helper = require('../../test-helper'); +const cassandra = require('../../../index'); const Client = cassandra.Client; const types = cassandra.types; const utils = require('../../../lib/utils'); diff --git a/test/other/memory/profile-keeping-ref.js b/test/other/memory/profile-keeping-ref.ts similarity index 97% rename from test/other/memory/profile-keeping-ref.js rename to test/other/memory/profile-keeping-ref.ts index 246be4d47..1decb83fa 100644 --- a/test/other/memory/profile-keeping-ref.js +++ b/test/other/memory/profile-keeping-ref.ts @@ -27,8 +27,8 @@ catch (e) { console.log(e); } -const helper = require('../../test-helper.js'); -const cassandra = require('../../../index.js'); +const helper = require('../../test-helper'); +const cassandra = require('../../../index'); const Client = cassandra.Client; const types = cassandra.types; const utils = require('../../../lib/utils'); diff --git a/test/test-helper.js b/test/test-helper.ts similarity index 100% rename from test/test-helper.js rename to test/test-helper.ts diff --git a/test/unit/address-resolution-tests.js b/test/unit/address-resolution-tests.ts similarity index 100% rename from test/unit/address-resolution-tests.js rename to test/unit/address-resolution-tests.ts diff --git a/test/unit/api-tests.js b/test/unit/api-tests.ts similarity index 100% rename from test/unit/api-tests.js rename to test/unit/api-tests.ts diff --git a/test/unit/basic-tests.js b/test/unit/basic-tests.ts similarity index 99% rename from test/unit/basic-tests.js rename to test/unit/basic-tests.ts index e1b181197..067448c25 100644 --- a/test/unit/basic-tests.js +++ b/test/unit/basic-tests.ts @@ -22,7 +22,7 @@ const events = require('events'); const Client = require('../../lib/client'); const clientOptions = require('../../lib/client-options'); -const auth = require('../../lib/auth'); +import * as auth from '../../lib/auth'; const types = require('../../lib/types'); const { dataTypes } = types; const loadBalancing = require('../../lib/policies/load-balancing'); @@ -911,7 +911,7 @@ describe('exports', function () { //test that the exposed API is the one expected //it looks like a dumb test and it is, but it is necessary! /* eslint-disable global-require */ - const api = require('../../index.js'); + const api = require('../../index'); assert.strictEqual(api.Client, Client); assert.ok(api.errors); assert.strictEqual(typeof api.errors.DriverError, 'function'); diff --git a/test/unit/big-decimal-tests.js b/test/unit/big-decimal-tests.ts similarity index 100% rename from test/unit/big-decimal-tests.js rename to test/unit/big-decimal-tests.ts diff --git a/test/unit/client-tests.js b/test/unit/client-tests.ts similarity index 99% rename from test/unit/client-tests.js rename to test/unit/client-tests.ts index 807d16ee8..a117d798c 100644 --- a/test/unit/client-tests.js +++ b/test/unit/client-tests.ts @@ -179,7 +179,7 @@ describe('Client', function () { await helper.delayAsync(20); }; - const Client = proxyquire('../../lib/client.js', { + const Client = proxyquire('../../lib/client', { './control-connection': ccMock }); const client = new Client(options); @@ -548,7 +548,7 @@ describe('Client', function () { send: () => Promise.resolve() }; - const Client = proxyquire('../../lib/client.js', { + const Client = proxyquire('../../lib/client', { './request-handler': requestHandlerMock }); diff --git a/test/unit/cloud/certificate-validation-tests.js b/test/unit/cloud/certificate-validation-tests.ts similarity index 100% rename from test/unit/cloud/certificate-validation-tests.js rename to test/unit/cloud/certificate-validation-tests.ts diff --git a/test/unit/concurrent/execute-concurrent-tests.js b/test/unit/concurrent/execute-concurrent-tests.ts similarity index 100% rename from test/unit/concurrent/execute-concurrent-tests.js rename to test/unit/concurrent/execute-concurrent-tests.ts diff --git a/test/unit/connection-tests.js b/test/unit/connection-tests.ts similarity index 100% rename from test/unit/connection-tests.js rename to test/unit/connection-tests.ts diff --git a/test/unit/control-connection-tests.js b/test/unit/control-connection-tests.ts similarity index 99% rename from test/unit/control-connection-tests.js rename to test/unit/control-connection-tests.ts index e4b690169..8b6529fe8 100644 --- a/test/unit/control-connection-tests.js +++ b/test/unit/control-connection-tests.ts @@ -19,7 +19,7 @@ const events = require('events'); const proxyquire = require('proxyquire'); const util = require('util'); -const helper = require('../test-helper.js'); +const helper = require('../test-helper'); const ControlConnection = require('../../lib/control-connection'); const Host = require('../../lib/host').Host; const utils = require('../../lib/utils'); diff --git a/test/unit/default-load-balancing-policy-tests.js b/test/unit/default-load-balancing-policy-tests.ts similarity index 100% rename from test/unit/default-load-balancing-policy-tests.js rename to test/unit/default-load-balancing-policy-tests.ts diff --git a/test/unit/dse-gssapi-auth-provider-tests.js b/test/unit/dse-gssapi-auth-provider-tests.ts similarity index 97% rename from test/unit/dse-gssapi-auth-provider-tests.js rename to test/unit/dse-gssapi-auth-provider-tests.ts index 9af2bcdfd..05ec1eee8 100644 --- a/test/unit/dse-gssapi-auth-provider-tests.js +++ b/test/unit/dse-gssapi-auth-provider-tests.ts @@ -15,7 +15,7 @@ */ 'use strict'; const assert = require('assert'); -const DseGssapiAuthProvider = require('../../lib/auth/dse-gssapi-auth-provider'); +import DseGssapiAuthProvider from '../../lib/auth/dse-gssapi-auth-provider'; const helper = require('../test-helper'); const utils = require('../../lib/utils'); const cDescribe = helper.conditionalDescribe(helper.requireOptional('kerberos'), 'kerberos required to run'); diff --git a/test/unit/dse-plain-text-auth-provider-tests.js b/test/unit/dse-plain-text-auth-provider-tests.ts similarity index 86% rename from test/unit/dse-plain-text-auth-provider-tests.js rename to test/unit/dse-plain-text-auth-provider-tests.ts index 50fa67582..22adc98ae 100644 --- a/test/unit/dse-plain-text-auth-provider-tests.js +++ b/test/unit/dse-plain-text-auth-provider-tests.ts @@ -15,8 +15,8 @@ */ 'use strict'; const assert = require('assert'); -const Authenticator = require('../../lib/auth/provider').Authenticator; -const DsePlainTextAuthProvider = require('../../lib/auth/dse-plain-text-auth-provider'); +import { Authenticator } from '../../lib/auth/provider'; +import DsePlainTextAuthProvider from '../../lib/auth/dse-plain-text-auth-provider'; describe('DsePlainTextAuthProvider', function () { describe('#newAuthenticator()', function () { diff --git a/test/unit/duration-type-tests.js b/test/unit/duration-type-tests.ts similarity index 100% rename from test/unit/duration-type-tests.js rename to test/unit/duration-type-tests.ts diff --git a/test/unit/encoder-tests.js b/test/unit/encoder-tests.ts similarity index 100% rename from test/unit/encoder-tests.js rename to test/unit/encoder-tests.ts diff --git a/test/unit/encoder-vector-tests.js b/test/unit/encoder-vector-tests.ts similarity index 100% rename from test/unit/encoder-vector-tests.js rename to test/unit/encoder-vector-tests.ts diff --git a/test/unit/error-tests.js b/test/unit/error-tests.ts similarity index 100% rename from test/unit/error-tests.js rename to test/unit/error-tests.ts diff --git a/test/unit/event-debouncer-tests.js b/test/unit/event-debouncer-tests.ts similarity index 100% rename from test/unit/event-debouncer-tests.js rename to test/unit/event-debouncer-tests.ts diff --git a/test/unit/execution-options-tests.js b/test/unit/execution-options-tests.ts similarity index 100% rename from test/unit/execution-options-tests.js rename to test/unit/execution-options-tests.ts diff --git a/test/unit/execution-profile-tests.js b/test/unit/execution-profile-tests.ts similarity index 100% rename from test/unit/execution-profile-tests.js rename to test/unit/execution-profile-tests.ts diff --git a/test/unit/geometry/line-string-tests.js b/test/unit/geometry/line-string-tests.ts similarity index 100% rename from test/unit/geometry/line-string-tests.js rename to test/unit/geometry/line-string-tests.ts diff --git a/test/unit/geometry/point-tests.js b/test/unit/geometry/point-tests.ts similarity index 100% rename from test/unit/geometry/point-tests.js rename to test/unit/geometry/point-tests.ts diff --git a/test/unit/geometry/polygon-tests.js b/test/unit/geometry/polygon-tests.ts similarity index 100% rename from test/unit/geometry/polygon-tests.js rename to test/unit/geometry/polygon-tests.ts diff --git a/test/unit/graph/executor-tests.js b/test/unit/graph/executor-tests.ts similarity index 100% rename from test/unit/graph/executor-tests.js rename to test/unit/graph/executor-tests.ts diff --git a/test/unit/graph/graph-result-tests.js b/test/unit/graph/graph-result-tests.ts similarity index 100% rename from test/unit/graph/graph-result-tests.js rename to test/unit/graph/graph-result-tests.ts diff --git a/test/unit/graph/graphson-tests.js b/test/unit/graph/graphson-tests.ts similarity index 100% rename from test/unit/graph/graphson-tests.js rename to test/unit/graph/graphson-tests.ts diff --git a/test/unit/host-tests.js b/test/unit/host-tests.ts similarity index 99% rename from test/unit/host-tests.js rename to test/unit/host-tests.ts index ccf90e540..6a87ce05b 100644 --- a/test/unit/host-tests.js +++ b/test/unit/host-tests.ts @@ -29,7 +29,7 @@ const types = require('../../lib/types'); const clientOptions = require('../../lib/client-options'); const defaultOptions = clientOptions.defaultOptions(); defaultOptions.pooling.coreConnectionsPerHost = clientOptions.coreConnectionsPerHostV3; -const utils = require('../../lib/utils.js'); +const utils = require('../../lib/utils'); const policies = require('../../lib/policies'); const helper = require('../test-helper'); const reconnection = policies.reconnection; diff --git a/test/unit/inet-address-tests.js b/test/unit/inet-address-tests.ts similarity index 100% rename from test/unit/inet-address-tests.js rename to test/unit/inet-address-tests.ts diff --git a/test/unit/insights-client-tests.js b/test/unit/insights-client-tests.ts similarity index 100% rename from test/unit/insights-client-tests.js rename to test/unit/insights-client-tests.ts diff --git a/test/unit/license-tests.js b/test/unit/license-tests.ts similarity index 100% rename from test/unit/license-tests.js rename to test/unit/license-tests.ts diff --git a/test/unit/load-balancing-tests.js b/test/unit/load-balancing-tests.ts similarity index 99% rename from test/unit/load-balancing-tests.js rename to test/unit/load-balancing-tests.ts index 524649287..a91fb5c77 100644 --- a/test/unit/load-balancing-tests.js +++ b/test/unit/load-balancing-tests.ts @@ -16,9 +16,9 @@ 'use strict'; const assert = require('assert'); -const helper = require('../test-helper.js'); +const helper = require('../test-helper'); const errors = require('../../lib/errors'); -const Client = require('../../lib/client.js'); +const Client = require('../../lib/client'); const clientOptions = require('../../lib/client-options'); const { Host, HostMap } = require('../../lib/host'); const types = require('../../lib/types'); diff --git a/test/unit/mapping/cache-tests.js b/test/unit/mapping/cache-tests.ts similarity index 100% rename from test/unit/mapping/cache-tests.js rename to test/unit/mapping/cache-tests.ts diff --git a/test/unit/mapping/mapper-tests.js b/test/unit/mapping/mapper-tests.ts similarity index 100% rename from test/unit/mapping/mapper-tests.js rename to test/unit/mapping/mapper-tests.ts diff --git a/test/unit/mapping/mapper-unit-test-helper.js b/test/unit/mapping/mapper-unit-test-helper.ts similarity index 100% rename from test/unit/mapping/mapper-unit-test-helper.js rename to test/unit/mapping/mapper-unit-test-helper.ts diff --git a/test/unit/mapping/mapping-handler-tests.js b/test/unit/mapping/mapping-handler-tests.ts similarity index 100% rename from test/unit/mapping/mapping-handler-tests.js rename to test/unit/mapping/mapping-handler-tests.ts diff --git a/test/unit/mapping/model-mapper-mutation-tests.js b/test/unit/mapping/model-mapper-mutation-tests.ts similarity index 100% rename from test/unit/mapping/model-mapper-mutation-tests.js rename to test/unit/mapping/model-mapper-mutation-tests.ts diff --git a/test/unit/mapping/model-mapper-select-tests.js b/test/unit/mapping/model-mapper-select-tests.ts similarity index 100% rename from test/unit/mapping/model-mapper-select-tests.js rename to test/unit/mapping/model-mapper-select-tests.ts diff --git a/test/unit/mapping/model-mapping-info-tests.js b/test/unit/mapping/model-mapping-info-tests.ts similarity index 100% rename from test/unit/mapping/model-mapping-info-tests.js rename to test/unit/mapping/model-mapping-info-tests.ts diff --git a/test/unit/mapping/result-mapper-tests.js b/test/unit/mapping/result-mapper-tests.ts similarity index 100% rename from test/unit/mapping/result-mapper-tests.js rename to test/unit/mapping/result-mapper-tests.ts diff --git a/test/unit/mapping/result-tests.js b/test/unit/mapping/result-tests.ts similarity index 100% rename from test/unit/mapping/result-tests.js rename to test/unit/mapping/result-tests.ts diff --git a/test/unit/mapping/table-mappings-tests.js b/test/unit/mapping/table-mappings-tests.ts similarity index 100% rename from test/unit/mapping/table-mappings-tests.js rename to test/unit/mapping/table-mappings-tests.ts diff --git a/test/unit/mapping/tree-tests.js b/test/unit/mapping/tree-tests.ts similarity index 100% rename from test/unit/mapping/tree-tests.js rename to test/unit/mapping/tree-tests.ts diff --git a/test/unit/metadata-tests.js b/test/unit/metadata-tests.ts similarity index 99% rename from test/unit/metadata-tests.js rename to test/unit/metadata-tests.ts index f15aa59e3..3c62f7c76 100644 --- a/test/unit/metadata-tests.js +++ b/test/unit/metadata-tests.ts @@ -20,9 +20,9 @@ const { assert } = require('chai'); const sinon = require('sinon'); const events = require('events'); -const helper = require('../test-helper.js'); -const clientOptions = require('../../lib/client-options.js'); -const Host = require('../../lib/host.js').Host; +const helper = require('../test-helper'); +const clientOptions = require('../../lib/client-options'); +const Host = require('../../lib/host').Host; const HostMap = require('../../lib/host').HostMap; const Metadata = require('../../lib/metadata'); const TableMetadata = require('../../lib/metadata/table-metadata'); diff --git a/test/unit/mutable-long-tests.js b/test/unit/mutable-long-tests.ts similarity index 100% rename from test/unit/mutable-long-tests.js rename to test/unit/mutable-long-tests.ts diff --git a/test/unit/parser-tests.js b/test/unit/parser-tests.ts similarity index 100% rename from test/unit/parser-tests.js rename to test/unit/parser-tests.ts diff --git a/test/unit/prepare-handler-tests.js b/test/unit/prepare-handler-tests.ts similarity index 100% rename from test/unit/prepare-handler-tests.js rename to test/unit/prepare-handler-tests.ts diff --git a/test/unit/protocol-stream-tests.js b/test/unit/protocol-stream-tests.ts similarity index 100% rename from test/unit/protocol-stream-tests.js rename to test/unit/protocol-stream-tests.ts diff --git a/test/unit/protocol-version-tests.js b/test/unit/protocol-version-tests.ts similarity index 100% rename from test/unit/protocol-version-tests.js rename to test/unit/protocol-version-tests.ts diff --git a/test/unit/reconnection-test.js b/test/unit/reconnection-test.ts similarity index 100% rename from test/unit/reconnection-test.js rename to test/unit/reconnection-test.ts diff --git a/test/unit/request-handler-tests.js b/test/unit/request-handler-tests.ts similarity index 100% rename from test/unit/request-handler-tests.js rename to test/unit/request-handler-tests.ts diff --git a/test/unit/requests-test.js b/test/unit/requests-test.ts similarity index 100% rename from test/unit/requests-test.js rename to test/unit/requests-test.ts diff --git a/test/unit/result-set-tests.js b/test/unit/result-set-tests.ts similarity index 100% rename from test/unit/result-set-tests.js rename to test/unit/result-set-tests.ts diff --git a/test/unit/retry-policy-tests.js b/test/unit/retry-policy-tests.ts similarity index 100% rename from test/unit/retry-policy-tests.js rename to test/unit/retry-policy-tests.ts diff --git a/test/unit/search/date-range-tests.js b/test/unit/search/date-range-tests.ts similarity index 100% rename from test/unit/search/date-range-tests.js rename to test/unit/search/date-range-tests.ts diff --git a/test/unit/speculative-execution-tests.js b/test/unit/speculative-execution-tests.ts similarity index 100% rename from test/unit/speculative-execution-tests.js rename to test/unit/speculative-execution-tests.ts diff --git a/test/unit/stream-id-stack-tests.js b/test/unit/stream-id-stack-tests.ts similarity index 100% rename from test/unit/stream-id-stack-tests.js rename to test/unit/stream-id-stack-tests.ts diff --git a/test/unit/timestamp-tests.js b/test/unit/timestamp-tests.ts similarity index 100% rename from test/unit/timestamp-tests.js rename to test/unit/timestamp-tests.ts diff --git a/test/unit/token-tests.js b/test/unit/token-tests.ts similarity index 100% rename from test/unit/token-tests.js rename to test/unit/token-tests.ts diff --git a/test/unit/tokenizer-tests.js b/test/unit/tokenizer-tests.ts similarity index 100% rename from test/unit/tokenizer-tests.js rename to test/unit/tokenizer-tests.ts diff --git a/test/unit/tracker-tests.js b/test/unit/tracker-tests.ts similarity index 100% rename from test/unit/tracker-tests.js rename to test/unit/tracker-tests.ts diff --git a/test/unit/utils-tests.js b/test/unit/utils-tests.ts similarity index 100% rename from test/unit/utils-tests.js rename to test/unit/utils-tests.ts diff --git a/test/unit/uuid-tests.js b/test/unit/uuid-tests.ts similarity index 100% rename from test/unit/uuid-tests.js rename to test/unit/uuid-tests.ts diff --git a/test/unit/version-number-tests.js b/test/unit/version-number-tests.ts similarity index 100% rename from test/unit/version-number-tests.js rename to test/unit/version-number-tests.ts diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..d494168fa --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "lib": ["es2015"], + "target": "es2015", + "sourceMap": true, + "strict": false, + "noImplicitAny": false, + "outDir": "out", + "declaration": true, + "allowJs": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "declarationMap": true, + "moduleDetection": "force", + "resolveJsonModule": true + }, + "include": [ + "lib/**/*.ts", + "index.ts" + ], + "exclude": [ + "node_modules" + ] + } \ No newline at end of file