diff --git a/.eslintignore b/.eslintignore index d1d207128..be628dea5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,8 +1,10 @@ # TypeScript: js files are generated using tsc transpiler -/test/unit/typescript/*.js +/test/unit/typescript/* # Integer is part of the Closure Library /lib/types/integer.js # TinkerPop-based files -/lib/datastax/graph/type-serializers.js \ No newline at end of file +/lib/datastax/graph/type-serializers.js + +/out/**/*.js \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index ffce4d35b..cd94041a6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,9 @@ module.exports = { + plugins: [ + "@stylistic", + '@typescript-eslint' + ], + parser: '@typescript-eslint/parser', "env": { "commonjs": true, "es6": true @@ -6,7 +11,7 @@ module.exports = { "parserOptions": { "ecmaVersion": 2017 }, - "extends": "eslint:recommended", + "extends": ["eslint:recommended", 'plugin:@typescript-eslint/recommended'], "rules": { "indent": [ "error", @@ -33,6 +38,7 @@ module.exports = { "array-callback-return": "error", "curly": "error", "no-unused-vars": ["error", { "args": "none" }], + "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], "global-require": "error", "eqeqeq": ["error", "allow-null"], @@ -88,6 +94,8 @@ module.exports = { allowShortCircuit: false, allowTernary: false, }], + "@typescript-eslint/no-this-alias": "off", + "@typescript-eslint/no-explicit-any": "off", "no-useless-call": "off", "no-useless-concat": "error", "no-useless-escape": "error", 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..40826b417 --- /dev/null +++ b/index.ts @@ -0,0 +1,93 @@ +/* + * 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'; +import clientOptions from "./lib/client-options"; +import Client from "./lib/client"; +import types from "./lib/types/index"; +import errors from "./lib/errors"; +import policies from "./lib/policies/index"; +import mapping from "./lib/mapping/index"; +import tracker from "./lib/tracker/index"; +import metrics from "./lib/metrics/index"; +import concurrent from "./lib/concurrent/index"; +import Token from "./lib/token"; +import Metadata from "./lib/metadata/index"; +import Encoder from "./lib/encoder"; +import geometry from "./lib/geometry/index"; +import datastax from "./lib/datastax/index"; +import packageJson from './package.json'; + +import { ExecutionProfile } from './lib/execution-profile'; +import { ExecutionOptions } from './lib/execution-options'; + +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 +}; + +export default { + 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..cd916ce8e 100644 --- a/lib/auth/base-dse-authenticator.js +++ b/lib/auth/base-dse-authenticator.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'); -const { Authenticator } = require('./provider'); + +import { Authenticator } from './provider'; +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..4d313a142 100644 --- a/lib/auth/dse-gssapi-auth-provider.js +++ b/lib/auth/dse-gssapi-auth-provider.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 { 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'; +import GssapiClient from './gssapi-client'; +import util from "util"; +import { AuthProvider } from "./provider"; +import dns from "dns"; +import utils from "../utils"; 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..a53674761 100644 --- a/lib/auth/dse-plain-text-auth-provider.js +++ b/lib/auth/dse-plain-text-auth-provider.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 { AuthProvider } = require('./provider'); -const BaseDseAuthenticator = require('./base-dse-authenticator'); -const utils = require('../utils'); +import { AuthProvider } from './provider'; +import BaseDseAuthenticator from './base-dse-authenticator'; +import util from "util"; +import utils from "../utils"; 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..7e128d192 100644 --- a/lib/auth/gssapi-client.js +++ b/lib/auth/gssapi-client.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"; -'use strict'; -const util = require('util'); -const utils = require('../utils'); /** * GSSAPI Client interface. @@ -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.d.ts b/lib/auth/index.d.ts deleted file mode 100644 index c1c374134..000000000 --- a/lib/auth/index.d.ts +++ /dev/null @@ -1,47 +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. - */ - -export namespace auth { - interface Authenticator { - initialResponse(callback: Function): void; - - evaluateChallenge(challenge: Buffer, callback: Function): void; - - onAuthenticationSuccess(token?: Buffer): void; - } - - interface AuthProvider { - newAuthenticator(endpoint: string, name: string): Authenticator; - } - - class PlainTextAuthProvider implements AuthProvider { - constructor(username: string, password: string); - - newAuthenticator(endpoint: string, name: string): Authenticator; - } - - class DsePlainTextAuthProvider implements AuthProvider { - constructor(username: string, password: string, authorizationId?: string); - - newAuthenticator(endpoint: string, name: string): Authenticator; - } - - class DseGssapiAuthProvider implements AuthProvider { - constructor(gssOptions?: { authorizationId?: string, service?: string, hostNameResolver?: Function }); - - newAuthenticator(endpoint: string, name: string): Authenticator; - } -} \ 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..75f9d2814 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, @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + /** * DSE Authentication module. @@ -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'; +import { PlainTextAuthProvider } from './plain-text-auth-provider'; +import DseGssapiAuthProvider from './dse-gssapi-auth-provider'; +import DsePlainTextAuthProvider from './dse-plain-text-auth-provider'; +import NoAuthProvider from './no-auth-provider'; -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 89% rename from lib/auth/no-auth-provider.js rename to lib/auth/no-auth-provider.ts index 7dbcd9ea5..583afd39f 100644 --- a/lib/auth/no-auth-provider.js +++ b/lib/auth/no-auth-provider.ts @@ -14,12 +14,11 @@ * limitations under the License. */ -'use strict'; -const { AuthProvider, Authenticator } = require('./provider'); -const { PlainTextAuthenticator } = require('./plain-text-auth-provider'); -const errors = require('../errors'); +import { AuthProvider, Authenticator } from './provider'; +import { PlainTextAuthenticator } from './plain-text-auth-provider'; +import errors from "../errors"; 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 94% rename from lib/auth/plain-text-auth-provider.js rename to lib/auth/plain-text-auth-provider.ts index f5241f7e4..6c74ca2c8 100644 --- a/lib/auth/plain-text-auth-provider.js +++ b/lib/auth/plain-text-auth-provider.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); -const provider = require('./provider.js'); -const utils = require('../utils'); +import * as provider from './provider'; +import util from "util"; +import utils from "../utils"; 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 96% rename from lib/auth/provider.js rename to lib/auth/provider.ts index d4bf9ed10..6af902d52 100644 --- a/lib/auth/provider.js +++ b/lib/auth/provider.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + /** * @classdesc Provides [Authenticator]{@link module:auth~Authenticator} instances to be used when connecting to a host. * @constructor @@ -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..2dfe5b481 100644 --- a/lib/client-options.js +++ b/lib/client-options.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import policies from "./policies/index"; +import types from "./types/index"; +import utils from "./utils"; +import tracker from "./tracker/index"; +import metrics from "./metrics/index"; +import auth from "./auth/index"; -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'); /** Core connections per host for protocol versions 1 and 2 */ const coreConnectionsPerHostV2 = { @@ -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..c5ed328ff 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. */ -'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'); - +import events from "events"; +import util from "util"; +import utils from "./utils"; +import errors from "./errors"; +import types from "./types/index"; +import { ProfileManager } from "./execution-profile"; +import requests from "./requests"; +import clientOptions from "./client-options"; +import ClientState from "./metadata/client-state"; +import { DefaultExecutionOptions } from "./execution-options"; +import ControlConnection from "./control-connection"; +import RequestHandler from "./request-handler"; +import PrepareHandler from "./prepare-handler"; +import InsightsClient from "./insights-client"; +import cloud from "./datastax/cloud/index"; +import GraphExecutor from "./datastax/graph/graph-executor"; +import promiseUtils from "./promise-utils"; +import packageInfo from '../package.json' assert {type: 'json'}; + + + +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.d.ts b/lib/concurrent/index.d.ts deleted file mode 100644 index 91ab56f7d..000000000 --- a/lib/concurrent/index.d.ts +++ /dev/null @@ -1,45 +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 { Client } from '../../'; -import { Readable } from 'stream'; - -export namespace concurrent { - interface ResultSetGroup { - errors: Error[]; - resultItems: any[]; - totalExecuted: number; - } - - type Options = { - collectResults?: boolean; - concurrencyLevel?: number; - executionProfile?: string; - maxErrors?: number; - raiseOnFirstError?: boolean; - } - - function executeConcurrent( - client: Client, - query: string, - parameters: any[][]|Readable, - options?: Options): Promise; - - function executeConcurrent( - client: Client, - queries: Array<{query: string, params: any[]}>, - options?: Options): Promise; -} \ No newline at end of file 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..bb2af667a 100644 --- a/lib/concurrent/index.js +++ b/lib/concurrent/index.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Stream } from "stream"; +import utils from "../utils"; -'use strict'; -const { Stream } = require('stream'); -const utils = require('../utils'); /** * Utilities for concurrent query execution with the DataStax Node.js Driver. @@ -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..f20d2a8a4 100644 --- a/lib/connection.js +++ b/lib/connection.ts @@ -13,25 +13,23 @@ * 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"; +import { WriteQueue } from "./writers"; +import requests from "./requests"; +import streams from "./streams"; +import utils from "./utils"; +import types from "./types/index"; +import errors from "./errors"; +import StreamIdStack from "./stream-id-stack"; +import OperationState from "./operation-state"; +import promiseUtils from "./promise-utils"; +import { ExecutionOptions } from "./execution-options"; + -'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..76bd35d18 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. */ -'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'); +import events from "events"; +import util from "util"; +import net from "net"; +import dns from "dns"; +import errors from "./errors"; +import { Host, HostMap } from "./host"; +import Metadata from "./metadata/index"; +import EventDebouncer from "./metadata/event-debouncer"; +import Connection from "./connection"; +import requests from "./requests"; +import utils from "./utils"; +import types from "./types/index"; +import promiseUtils from "./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..643b1efe6 100644 --- a/lib/datastax/cloud/index.js +++ b/lib/datastax/cloud/index.ts @@ -14,17 +14,15 @@ * limitations under the License. */ -'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'; +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"; +import utils from "../../utils"; // 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..75fdb4874 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"; +import types from "../../types/index"; +import Encoder from "../../encoder"; -'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..1f7d117fb 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'; - -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'); +import types from "../../types/index"; +import utils from "../../utils"; +import { getTypeDefinitionByValue, getUdtTypeDefinitionByValue } from "./complex-type-helper"; +import { Point, Polygon, LineString } from "../../geometry/index"; +import { Edge } from "./structure"; +import { GraphTypeWrapper, UdtGraphWrapper } from "./wrappers"; + + 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..15cc092d0 100644 --- a/lib/datastax/graph/graph-executor.js +++ b/lib/datastax/graph/graph-executor.ts @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "../../utils"; +import policies from "../../policies/index"; +import GraphResultSet from "./result-set"; +import { GraphSON2Reader, GraphSON2Writer, GraphSON3Reader, GraphSON3Writer } from "./graph-serializer"; +import getCustomTypeSerializers from "./custom-type-serializers"; +import { GraphExecutionOptions, graphProtocol } from "./options"; -'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..1a7050b3c 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"; /** * @module datastax/graph/tinkerpop/graphSerializers @@ -26,9 +27,7 @@ /** * @author Jorge Bay Gondra */ -'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.d.ts b/lib/datastax/graph/index.d.ts deleted file mode 100644 index b6e860c42..000000000 --- a/lib/datastax/graph/index.d.ts +++ /dev/null @@ -1,92 +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 { types } from '../../types'; - -export 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; - } -} \ No newline at end of file diff --git a/lib/datastax/graph/index.js b/lib/datastax/graph/index.ts similarity index 80% rename from lib/datastax/graph/index.js rename to lib/datastax/graph/index.ts index a0333a06e..f9250293f 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"; +import getCustomTypeSerializers from "./custom-type-serializers"; +import { asInt, asDouble, asFloat, asTimestamp, asUdt, UdtGraphWrapper, GraphTypeWrapper} from "./wrappers"; +import { Edge, Element, Path, Property, Vertex, VertexProperty } from "./structure"; -/** - * 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'); 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..5e7091a27 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. */ -'use strict'; -const util = require('util'); -const types = require('../../types'); -const utils = require('../../utils'); -const { DefaultExecutionOptions, proxyExecuteKey } = require('../../execution-options'); +import util from "util"; +import types from "../../types/index"; +import utils from "../../utils"; +import { DefaultExecutionOptions, proxyExecuteKey } from "../../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..f3712cd50 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"; + -const utils = require('../../utils'); /** * 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..9732e5f6c 100644 --- a/lib/datastax/graph/structure.js +++ b/lib/datastax/graph/structure.ts @@ -13,10 +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'); /** * @classdesc @@ -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 91% rename from lib/datastax/graph/type-serializers.js rename to lib/datastax/graph/type-serializers.ts index 880c0f336..eaef5ff0e 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"; /** * @module datastax/graph/tinkerpop/typeSerializers @@ -25,7 +26,7 @@ /** * @author Jorge Bay Gondra */ -'use strict'; + // Replace dependencies to minimize code changes from Apache TinkerPop const t = { @@ -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; @@ -78,22 +78,22 @@ class NumberSerializer extends TypeSerializer { [typeKey]: 'g:Double', [valueKey]: '-Infinity' }; - } else { - return item; - } + } + return item; + } deserialize(obj) { - var val = obj[valueKey]; + const val = obj[valueKey]; if (val === 'NaN') { return NaN; } else if (val === 'Infinity') { return Number.POSITIVE_INFINITY; } else if (val === '-Infinity') { return Number.NEGATIVE_INFINITY; - } else { - return parseFloat(val); - } + } + return parseFloat(val); + } canBeUsedFor(value) { @@ -377,9 +377,9 @@ class TSerializer extends TypeSerializer { } class DirectionSerializer extends TypeSerializer { - deserialize(obj) { - return t.direction[obj[valueKey].toLowerCase()]; - } + deserialize(obj) { + return t.direction[obj[valueKey].toLowerCase()]; + } } class ArraySerializer extends TypeSerializer { @@ -411,22 +411,22 @@ class ArraySerializer extends TypeSerializer { class BulkSetSerializer extends TypeSerializer { deserialize(obj) { - const value = obj[valueKey]; - if (!Array.isArray(value)) { - throw new Error('Expected Array, obtained: ' + value); - } + const value = obj[valueKey]; + if (!Array.isArray(value)) { + throw new Error('Expected Array, obtained: ' + value); + } - // coerce the BulkSet to List. if the bulk exceeds the int space then we can't coerce to List anyway, - // so this query will be trouble. we'd need a legit BulkSet implementation here in js. this current - // implementation is here to replicate the previous functionality that existed on the server side in - // previous versions. - let result = []; - for (let ix = 0, iy = value.length; ix < iy; ix += 2) { - const pair = value.slice(ix, ix + 2); - result = result.concat(Array(this.reader.read(pair[1])).fill(this.reader.read(pair[0]))); - } + // coerce the BulkSet to List. if the bulk exceeds the int space then we can't coerce to List anyway, + // so this query will be trouble. we'd need a legit BulkSet implementation here in js. this current + // implementation is here to replicate the previous functionality that existed on the server side in + // previous versions. + let result = []; + for (let ix = 0, iy = value.length; ix < iy; ix += 2) { + const pair = value.slice(ix, ix + 2); + result = result.concat(Array(this.reader.read(pair[1])).fill(this.reader.read(pair[0]))); + } - return result; + return result; } } @@ -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..ccf6e643f 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"; -'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..5fd4ba790 100644 --- a/lib/datastax/index.js +++ b/lib/datastax/index.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -'use strict'; + /** * DataStax module. @@ -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"; +import { DateRange } from "./search/index"; + +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..1a39fba41 100644 --- a/lib/datastax/search/date-range.js +++ b/lib/datastax/search/date-range.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import utils from "../../utils"; +import Long from "long"; -const utils = require('../../utils'); -const Long = require('long'); /** * Regex to parse dates in the following format YYYY-MM-DDThh:mm:ss.mssZ @@ -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.d.ts b/lib/datastax/search/index.d.ts deleted file mode 100644 index 57ba44f7a..000000000 --- a/lib/datastax/search/index.d.ts +++ /dev/null @@ -1,58 +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. - */ - -export namespace search { - enum dateRangePrecision { - year = 0, - month, - day, - hour, - minute, - second, - millisecond - } - - class DateRange { - lowerBound: DateRangeBound; - upperBound: DateRangeBound; - - constructor(lowerBound: DateRangeBound, upperBound: DateRangeBound); - - equals(other: DateRangeBound): boolean; - - toString(): string; - - static fromString(value: string): DateRange; - - static fromBuffer(value: Buffer): DateRange; - } - - class DateRangeBound { - date: Date; - - precision: number; - - equals(other: DateRangeBound): boolean; - - toString(): string; - - static fromString(value: string): DateRangeBound; - - static toLowerBound(bound: DateRangeBound): DateRangeBound; - - static toUpperBound(bound: DateRangeBound): DateRangeBound; - } -} \ No newline at end of file diff --git a/lib/datastax/search/index.js b/lib/datastax/search/index.ts similarity index 76% rename from lib/datastax/search/index.js rename to lib/datastax/search/index.ts index c101f5d14..5e0bc2efb 100644 --- a/lib/datastax/search/index.js +++ b/lib/datastax/search/index.ts @@ -13,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'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"; \ 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..5ca9e00b4 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"; +import MutableLong from "./types/mutable-long"; +import utils from "./utils"; +import token from "./token"; +import { DateRange } from "./datastax/search/index"; +import geo from "./geometry/index"; +import Vector from "./types/vector"; + -const types = require('./types'); 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 91% rename from lib/errors.js rename to lib/errors.ts index 970c528b9..a84ac9b45 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. */ -'use strict'; -const util = require('util'); +import util from "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..987ba540a 100644 --- a/lib/execution-options.js +++ b/lib/execution-options.ts @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "./utils"; +import types from "./types/index"; +import errors from "./errors"; -'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..3350d2257 100644 --- a/lib/execution-profile.js +++ b/lib/execution-profile.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "./utils"; +import types from "./types/index"; +import promiseUtils from "./promise-utils"; -'use strict'; -const utils = require('./utils'); -const types = require('./types'); -const promiseUtils = require('./promise-utils'); /** * Creates a new instance of {@link ExecutionProfile}. @@ -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 98% rename from lib/geometry/geometry.js rename to lib/geometry/geometry.ts index b91c8fdbb..48b974668 100644 --- a/lib/geometry/geometry.js +++ b/lib/geometry/geometry.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + const endianness = { '0': 'BE', @@ -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.d.ts b/lib/geometry/index.d.ts deleted file mode 100644 index 82ad292ba..000000000 --- a/lib/geometry/index.d.ts +++ /dev/null @@ -1,67 +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. - */ - -export namespace geometry { - 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; - - } - - 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; - - } - - 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; - } -} \ No newline at end of file diff --git a/lib/geometry/index.js b/lib/geometry/index.ts similarity index 74% rename from lib/geometry/index.js rename to lib/geometry/index.ts index 28c9bc7b6..e9c97c2e2 100644 --- a/lib/geometry/index.js +++ b/lib/geometry/index.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + /** * Geometry module. @@ -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'; +import LineString from './line-string'; +import Polygon from './polygon'; +import Geometry from './geometry'; + +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..47fd47ded 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. */ -'use strict'; -const util = require('util'); -const utils = require('../utils'); -const Geometry = require('./geometry'); -const Point = require('./point'); +import util from "util"; +import utils from "../utils"; +import Geometry from "./geometry"; +import Point from "./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..4ec4e798a 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. */ -'use strict'; -const util = require('util'); -const utils = require('../utils'); -const Geometry = require('./geometry'); +import util from "util"; +import utils from "../utils"; +import Geometry from "./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 96% rename from lib/geometry/polygon.js rename to lib/geometry/polygon.ts index c4536e118..27d8459b9 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. */ -'use strict'; -const util = require('util'); -const utils = require('../utils'); -const Geometry = require('./geometry'); -const Point = require('./point'); -const LineString = require('./line-string'); +import util from "util"; +import utils from "../utils"; +import Geometry from "./geometry"; +import Point from "./point"; +import LineString from "./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..17a94a1dc 100644 --- a/lib/host-connection-pool.js +++ b/lib/host-connection-pool.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 events = require('events'); +import util from "util"; +import events from "events"; +import Connection from "./connection"; +import utils from "./utils"; +import promiseUtils from "./promise-utils"; +import errors from "./errors"; +import clientOptions from "./client-options"; -const Connection = require('./connection'); -const utils = require('./utils'); -const promiseUtils = require('./promise-utils'); -const errors = require('./errors'); -const clientOptions = require('./client-options'); // Used to get the index of the connection with less in-flight requests let connectionIndex = 0; @@ -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..c011c0344 100644 --- a/lib/host.js +++ b/lib/host.ts @@ -13,16 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import utils from "./utils"; +import types from "./types/index"; +import HostConnectionPool from "./host-connection-pool"; +import PrepareHandler from "./prepare-handler"; +import promiseUtils from "./promise-utils"; -'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..8aa5779a2 100644 --- a/lib/insights-client.js +++ b/lib/insights-client.ts @@ -14,19 +14,19 @@ * limitations under the License. */ -'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'; +import os from "os"; +import path from "path"; +import fs from "fs"; +import utils from "./utils"; +import promiseUtils from "./promise-utils"; +import types from "./types/index"; +import requests from "./requests"; +import { ExecutionOptions } from "./execution-options"; +import packageInfo from "../package.json" assert {type: 'json'}; +import VersionNumber from "./types/version-number"; +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..a8e2e454c 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"; -'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..74175545b 100644 --- a/lib/mapping/doc-info-adapter.js +++ b/lib/mapping/doc-info-adapter.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import errors from "../errors"; +import utils from "../utils"; -'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. @@ -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.d.ts b/lib/mapping/index.d.ts deleted file mode 100644 index 694e789cf..000000000 --- a/lib/mapping/index.d.ts +++ /dev/null @@ -1,189 +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 { types } from '../types'; -import { Client } from '../../'; -import Long = types.Long; - -export namespace mapping { - interface TableMappings { - getColumnName(propName: string): string; - - getPropertyName(columnName: string): string; - - newObjectInstance(): any; - } - - class DefaultTableMappings implements TableMappings { - getColumnName(propName: string): string; - - getPropertyName(columnName: string): string; - - newObjectInstance(): any; - } - - class UnderscoreCqlToCamelCaseMappings implements TableMappings { - getColumnName(propName: string): string; - - getPropertyName(columnName: string): string; - - newObjectInstance(): any; - } - - interface Result extends Iterator { - wasApplied(): boolean; - - first(): T | null; - - forEach(callback: (currentValue: T, index: number) => void, thisArg?: any): void; - - toArray(): T[]; - } - - type MappingExecutionOptions = { - executionProfile?: string; - isIdempotent?: boolean; - logged?: boolean; - timestamp?: number | Long; - fetchSize?: number; - pageState?: number; - } - - interface ModelTables { - name: string; - isView: boolean; - } - - class Mapper { - constructor(client: Client, options?: MappingOptions); - - batch(items: ModelBatchItem[], executionOptions?: string | MappingExecutionOptions): Promise; - - forModel(name: string): ModelMapper; - } - - type MappingOptions = { - models: { [key: string]: ModelOptions }; - } - - type FindDocInfo = { - fields?: string[]; - orderBy?: { [key: string]: string }; - limit?: number; - } - - type InsertDocInfo = { - fields?: string[]; - ttl?: number; - ifNotExists?: boolean; - } - - type UpdateDocInfo = { - fields?: string[]; - ttl?: number; - ifExists?: boolean; - when?: { [key: string]: any }; - orderBy?: { [key: string]: string }; - limit?: number; - deleteOnlyColumns?: boolean; - } - - type RemoveDocInfo = { - fields?: string[]; - ttl?: number; - ifExists?: boolean; - when?: { [key: string]: any }; - deleteOnlyColumns?: boolean; - } - - type ModelOptions = { - tables?: string[] | ModelTables[]; - mappings?: TableMappings; - columns?: { [key: string]: string|ModelColumnOptions }; - keyspace?: string; - } - - type ModelColumnOptions = { - name: string; - toModel?: (columnValue: any) => any; - fromModel?: (modelValue: any) => any; - }; - - interface ModelBatchItem { - - } - - interface ModelBatchMapper { - insert(doc: any, docInfo?: InsertDocInfo): ModelBatchItem; - - remove(doc: any, docInfo?: RemoveDocInfo): ModelBatchItem; - - update(doc: any, docInfo?: UpdateDocInfo): ModelBatchItem; - } - - 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>; - } - - namespace q { - interface QueryOperator { - - } - - function in_(arr: any): QueryOperator; - - function gt(value: any): QueryOperator; - - function gte(value: any): QueryOperator; - - function lt(value: any): QueryOperator; - - function lte(value: any): QueryOperator; - - function notEq(value: any): QueryOperator; - - function and(condition1: any, condition2: any): QueryOperator; - - function incr(value: any): QueryOperator; - - function decr(value: any): QueryOperator; - - function append(value: any): QueryOperator; - - function prepend(value: any): QueryOperator; - - function remove(value: any): QueryOperator; - } -} \ No newline at end of file diff --git a/lib/mapping/index.js b/lib/mapping/index.ts similarity index 50% rename from lib/mapping/index.js rename to lib/mapping/index.ts index e1de6c93b..bd8af8a23 100644 --- a/lib/mapping/index.js +++ b/lib/mapping/index.ts @@ -13,21 +13,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import Mapper from './mapper'; +import ModelMapper from "./model-mapper"; +import ModelBatchMapper from "./model-batch-mapper"; +import { ModelBatchItem } from './model-batch-item'; +import Result from "./result"; +import { q } from "./q"; +import {TableMappings, DefaultTableMappings, UnderscoreCqlToCamelCaseMappings} from "./table-mappings"; + -'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 +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 81% rename from lib/mapping/mapper.js rename to lib/mapping/mapper.ts index 329c87f1c..79dee3337 100644 --- a/lib/mapping/mapper.js +++ b/lib/mapping/mapper.ts @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ModelMapper from "./model-mapper"; +import MappingHandler from "./mapping-handler"; +import DocInfoAdapter from "./doc-info-adapter"; +import errors from "../errors"; +import Result from "./result"; +import ResultMapper from "./result-mapper"; +import ModelMappingInfo from "./model-mapping-info"; +import { ModelBatchItem } from "./model-batch-item"; -'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. @@ -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..641099771 100644 --- a/lib/mapping/mapping-handler.js +++ b/lib/mapping/mapping-handler.ts @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "../utils"; +import QueryGenerator from "./query-generator"; +import ResultMapper from "./result-mapper"; +import Result from "./result"; +import Cache from "./cache"; +import Tree from "./tree"; +import ObjectSelector from "./object-selector"; +import DocInfoAdapter from "./doc-info-adapter"; -'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 96% rename from lib/mapping/model-batch-item.js rename to lib/mapping/model-batch-item.ts index f04528e50..24eee2b34 100644 --- a/lib/mapping/model-batch-item.js +++ b/lib/mapping/model-batch-item.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import Cache from "./cache"; -'use strict'; -const Cache = require('./cache'); /** * Represents a query or a set of queries used to perform a mutation in a batch. @@ -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 97% rename from lib/mapping/model-batch-mapper.js rename to lib/mapping/model-batch-mapper.ts index 4928072c8..c78ac9adf 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"; +import * as moduleBatchItemModule from "./model-batch-item"; -'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..196dcaecb 100644 --- a/lib/mapping/model-mapper.js +++ b/lib/mapping/model-mapper.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ModelBatchMapper from "./model-batch-mapper"; -'use strict'; -const ModelBatchMapper = require('./model-batch-mapper'); /** * Represents an object mapper for a specific model. @@ -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..d42ad44b0 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"; -'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..cc48f0dc6 100644 --- a/lib/mapping/object-selector.js +++ b/lib/mapping/object-selector.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -'use strict'; + const keyMatches = { all: 1, @@ -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..b9c565aa2 100644 --- a/lib/mapping/q.js +++ b/lib/mapping/q.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import errors from "../errors"; -'use strict'; -const errors = require('../errors'); /** * Represents a CQL query operator, like >=, IN, <, ... @@ -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 98% rename from lib/mapping/query-generator.js rename to lib/mapping/query-generator.ts index 83a105d03..d7a83a78e 100644 --- a/lib/mapping/query-generator.js +++ b/lib/mapping/query-generator.ts @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import vm from "vm"; +import qModule from "./q"; +import types from "../types/index"; -'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'; +const vmFileName = 'gen-param-getter'; /** * Provides methods to generate a query and parameter handlers. @@ -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..aa864b90e 100644 --- a/lib/mapping/result-mapper.js +++ b/lib/mapping/result-mapper.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import vm from "vm"; +import utils from "../utils"; +import types from "../types/index"; -'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..cde1969df 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"; -'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 94% rename from lib/mapping/table-mappings.js rename to lib/mapping/table-mappings.ts index 06010a1c0..94ed0ff00 100644 --- a/lib/mapping/table-mappings.js +++ b/lib/mapping/table-mappings.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -'use strict'; + /** * Contains a set of methods to represent a row into a document and a document into a row. @@ -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..5ea5425fb 100644 --- a/lib/mapping/tree.js +++ b/lib/mapping/tree.ts @@ -13,10 +13,9 @@ * 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. @@ -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 97% rename from lib/metadata/aggregate.js rename to lib/metadata/aggregate.ts index 6677f5f6c..df43a4ff7 100644 --- a/lib/metadata/aggregate.js +++ b/lib/metadata/aggregate.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + /** * Creates a new Aggregate. @@ -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..92f242f12 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"; + -const util = require('util'); -const errors = require('../errors'); /** * 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 97% rename from lib/metadata/data-collection.js rename to lib/metadata/data-collection.ts index 1bab680a4..64756744c 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. */ -'use strict'; -const util = require('util'); -const events = require('events'); +import util from "util"; +import events from "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..5fcc32445 100644 --- a/lib/metadata/event-debouncer.js +++ b/lib/metadata/event-debouncer.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import utils from "../utils"; +import promiseUtils from "../promise-utils"; -const util = require('util'); -const utils = require('../utils'); -const promiseUtils = require('../promise-utils'); 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.d.ts b/lib/metadata/index.d.ts deleted file mode 100644 index 80c0d9673..000000000 --- a/lib/metadata/index.d.ts +++ /dev/null @@ -1,211 +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 { types } from '../types'; -import { EmptyCallback, Host, token, ValueCallback } from '../../'; -import dataTypes = types.dataTypes; -import Uuid = types.Uuid; -import InetAddress = types.InetAddress; - -export namespace metadata { - - interface Aggregate { - argumentTypes: Array<{ code: dataTypes, info: any }>; - finalFunction: string; - initCondition: string; - keyspaceName: string; - returnType: string; - signature: string[]; - stateFunction: string; - stateType: string; - } - - interface ClientState { - getConnectedHosts(): Host[]; - - getInFlightQueries(host: Host): number; - - getOpenConnections(host: Host): number; - - toString(): string; - } - - interface DataTypeInfo { - code: dataTypes; - info: string | DataTypeInfo | DataTypeInfo[]; - options: { - frozen: boolean; - reversed: boolean; - }; - } - - interface ColumnInfo { - name: string; - type: DataTypeInfo; - } - - enum IndexKind { - custom = 0, - keys, - composites - } - - interface Index { - kind: IndexKind; - name: string; - options: object; - target: string; - - isCompositesKind(): boolean; - - isCustomKind(): boolean; - - isKeysKind(): boolean; - } - - 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; - } - - interface MaterializedView extends DataCollection { - tableName: string; - whereClause: string; - includeAllColumns: boolean; - } - - interface TableMetadata extends DataCollection { - indexes: Index[]; - indexInterval?: number; - isCompact: boolean; - memtableFlushPeriod: number; - replicateOnWrite: boolean; - cdc?: boolean; - virtual: boolean; - } - - 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 }>; - } - - interface SchemaFunction { - argumentNames: string[]; - argumentTypes: Array<{ code: dataTypes, info: any }>; - body: string; - calledOnNullInput: boolean; - keyspaceName: string; - language: string; - name: string; - returnType: string; - signature: string[]; - } - - interface Udt { - name: string; - fields: ColumnInfo[] - } - - 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; - } -} \ 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..d178236db 100644 --- a/lib/metadata/index.js +++ b/lib/metadata/index.ts @@ -13,26 +13,18 @@ * 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"; +import utils from "../utils"; +import errors from "../errors"; +import types from "../types/index"; +import requests from "../requests"; +import schemaParserFactory from "./schema-parser"; +import promiseUtils from "../promise-utils"; +import { TokenRange } from "../token"; +import { ExecutionOptions } from "../execution-options"; -'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 @@ -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 90% rename from lib/metadata/materialized-view.js rename to lib/metadata/materialized-view.ts index 455a66a0e..6748c16b5 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. */ -'use strict'; -const util = require('util'); -const DataCollection = require('./data-collection'); +import util from "util"; +import DataCollection from "./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..77804f691 100644 --- a/lib/metadata/schema-function.js +++ b/lib/metadata/schema-function.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + /** * Creates a new SchemaFunction. @@ -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..8fc516d55 100644 --- a/lib/metadata/schema-index.js +++ b/lib/metadata/schema-index.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'); -const utils = require('../utils'); -const types = require('../types'); +import util from "util"; +import utils from "../utils"; +import types from "../types/index"; + /** @private */ const kind = { @@ -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..faf6de201 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"; +import utils from "../utils"; +import errors from "../errors"; +import promiseUtils from "../promise-utils"; +import TableMetadata from "./table-metadata"; +import Aggregate from "./aggregate"; +import SchemaFunction from "./schema-function"; +import Index from "./schema-index"; +import MaterializedView from "./materialized-view"; + -'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 94% rename from lib/metadata/table-metadata.js rename to lib/metadata/table-metadata.ts index 87e171ef2..cc77451fd 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. */ -'use strict'; +import util from "util"; +import DataCollection from "./data-collection"; + + -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 98% rename from lib/metrics/client-metrics.js rename to lib/metrics/client-metrics.ts index 88fe073e2..27fc3a959 100644 --- a/lib/metrics/client-metrics.js +++ b/lib/metrics/client-metrics.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -'use strict'; + /** * Represents a base class that is used to measure events from the server and the client as seen by the driver. @@ -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 97% rename from lib/metrics/default-metrics.js rename to lib/metrics/default-metrics.ts index 1df5dfaec..5c051c8a5 100644 --- a/lib/metrics/default-metrics.js +++ b/lib/metrics/default-metrics.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ClientMetrics from "./client-metrics"; +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 @@ -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.d.ts b/lib/metrics/index.d.ts deleted file mode 100644 index 4ad80054c..000000000 --- a/lib/metrics/index.d.ts +++ /dev/null @@ -1,89 +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 { errors } from '../../'; - -export namespace metrics { - 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; - } - - 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; - } -} \ No newline at end of file diff --git a/lib/metrics/index.js b/lib/metrics/index.js deleted file mode 100644 index 9afb03a05..000000000 --- a/lib/metrics/index.js +++ /dev/null @@ -1,28 +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 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 diff --git a/lib/datastax/index.d.ts b/lib/metrics/index.ts similarity index 74% rename from lib/datastax/index.d.ts rename to lib/metrics/index.ts index e41483f8e..aabcb0a1c 100644 --- a/lib/datastax/index.d.ts +++ b/lib/metrics/index.ts @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ClientMetrics from "./client-metrics"; +import DefaultMetrics from "./default-metrics"; -import * as graphModule from './graph'; -import * as searchModule from './search'; -export namespace datastax { - export import graph = graphModule.graph; - export import search = searchModule.search; -} \ 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..7331cc4d7 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"; +import errors from "./errors"; +import requests from "./requests"; + -const util = require('util'); -const utils = require('./utils'); -const errors = require('./errors'); -const requests = require('./requests'); 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 95% rename from lib/policies/address-resolution.js rename to lib/policies/address-resolution.ts index e0a0fc0be..27a3036ba 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. */ -'use strict'; -const dns = require('dns'); -const util = require('util'); -const utils = require('../utils'); +import dns from "dns"; +import util from "util"; +import utils from "../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.d.ts b/lib/policies/index.d.ts deleted file mode 100644 index ffae185be..000000000 --- a/lib/policies/index.d.ts +++ /dev/null @@ -1,210 +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 { Client, EmptyCallback, ExecutionOptions, Host, HostMap } from '../../'; -import { types } from '../types'; - - -export namespace policies { - function defaultAddressTranslator(): addressResolution.AddressTranslator; - - function defaultLoadBalancingPolicy(localDc?: string): loadBalancing.LoadBalancingPolicy; - - function defaultReconnectionPolicy(): reconnection.ReconnectionPolicy; - - function defaultRetryPolicy(): retry.RetryPolicy; - - function defaultSpeculativeExecutionPolicy(): speculativeExecution.SpeculativeExecutionPolicy; - - function defaultTimestampGenerator(): timestampGeneration.TimestampGenerator; - - namespace addressResolution { - interface AddressTranslator { - translate(address: string, port: number, callback: Function): void; - } - - class EC2MultiRegionTranslator implements AddressTranslator { - translate(address: string, port: number, callback: Function): void; - } - } - - namespace loadBalancing { - 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; - } - - class DCAwareRoundRobinPolicy extends LoadBalancingPolicy { - constructor(localDc: string); - } - - class TokenAwarePolicy extends LoadBalancingPolicy { - constructor(childPolicy: LoadBalancingPolicy); - } - - class AllowListPolicy extends LoadBalancingPolicy { - constructor(childPolicy: LoadBalancingPolicy, allowList: string[]); - } - - class WhiteListPolicy extends AllowListPolicy { - } - - class RoundRobinPolicy extends LoadBalancingPolicy { - constructor(); - } - - class DefaultLoadBalancingPolicy extends LoadBalancingPolicy { - constructor(options?: { localDc?: string, filter?: (host: Host) => boolean }); - } - } - - namespace reconnection { - class ConstantReconnectionPolicy implements ReconnectionPolicy { - constructor(delay: number); - - getOptions(): Map; - - newSchedule(): Iterator; - - } - - class ExponentialReconnectionPolicy implements ReconnectionPolicy { - constructor(baseDelay: number, maxDelay: number, startWithNoDelay?: boolean); - - getOptions(): Map; - - newSchedule(): Iterator; - } - - interface ReconnectionPolicy { - getOptions(): Map; - - newSchedule(): Iterator; - } - } - - namespace retry { - class DecisionInfo { - decision: number; - consistency: types.consistencies; - } - - class OperationInfo { - query: string; - executionOptions: ExecutionOptions; - nbRetry: number; - } - - class IdempotenceAwareRetryPolicy extends RetryPolicy { - constructor(childPolicy: RetryPolicy); - } - - class FallthroughRetryPolicy extends RetryPolicy { - constructor(); - } - - 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; - } - - namespace RetryDecision { - enum retryDecision { - ignore, - rethrow, - retry - } - } - } - - namespace speculativeExecution { - 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; - } - - class NoSpeculativeExecutionPolicy implements SpeculativeExecutionPolicy { - constructor(); - - getOptions(): Map; - - init(client: Client): void; - - newPlan(keyspace: string, queryInfo: string | Array): { nextExecution: Function }; - - shutdown(): void; - } - - interface SpeculativeExecutionPolicy { - getOptions(): Map; - - init(client: Client): void; - - newPlan(keyspace: string, queryInfo: string|Array): { nextExecution: Function }; - - shutdown(): void; - } - } - - namespace timestampGeneration { - class MonotonicTimestampGenerator implements TimestampGenerator { - constructor(warningThreshold: number, minLogInterval: number); - - getDate(): number; - - next(client: Client): types.Long | number; - } - - interface TimestampGenerator { - next(client: Client): types.Long|number; - } - } -} \ No newline at end of file diff --git a/lib/policies/index.js b/lib/policies/index.ts similarity index 67% rename from lib/policies/index.js rename to lib/policies/index.ts index 9590d6b57..98062c149 100644 --- a/lib/policies/index.js +++ b/lib/policies/index.ts @@ -13,28 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'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'; +import * as loadBalancing from './load-balancing'; +import * as reconnection from './reconnection'; +import * as retry from './retry'; +import * as speculativeExecution from './speculative-execution'; +import * as timestampGeneration from './timestamp-generation'; /** * 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..944337252 100644 --- a/lib/policies/load-balancing.js +++ b/lib/policies/load-balancing.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import types from "../types/index"; +import utils from "../utils"; +import errors from "../errors"; -const util = require('util'); -const types = require('../types'); -const utils = require('../utils.js'); -const errors = require('../errors.js'); 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..14fcfc32b 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. */ -'use strict'; -const util = require('util'); +import util from "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..cdaeb51c2 100644 --- a/lib/policies/retry.js +++ b/lib/policies/retry.ts @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const util = require('util'); +import util from "util"; + /** @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..201a825be 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"; + -const util = require('util'); -const errors = require('../errors'); /** @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..c91fd4c22 100644 --- a/lib/policies/timestamp-generation.js +++ b/lib/policies/timestamp-generation.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import util from "util"; +import { Long } from "../types/index"; +import errors from "../errors"; -const util = require('util'); -const { Long } = require('../types'); -const errors = require('../errors'); /** @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..9fd6177f3 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"; +import utils from "./utils"; +import types from "./types/index"; +import promiseUtils from "./promise-utils"; + -const errors = require('./errors'); -const utils = require('./utils'); -const types = require('./types'); -const promiseUtils = require('./promise-utils'); /** * 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..7189b4bf7 100644 --- a/lib/promise-utils.js +++ b/lib/promise-utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -'use strict'; + /** * Creates a non-clearable timer that resolves the promise once elapses. @@ -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..274c85a3c 100644 --- a/lib/readers.js +++ b/lib/readers.ts @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import utils from "./utils"; +import types from "./types/index"; +import errors from "./errors"; -'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..b3bf409dd 100644 --- a/lib/request-execution.js +++ b/lib/request-execution.ts @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import errors from "./errors"; +import requests from "./requests"; +import retry from "./policies/retry"; +import types from "./types/index"; +import utils from "./utils"; +import promiseUtils from "./promise-utils"; -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'); const retryOnCurrentHost = Object.freeze({ decision: retry.RetryPolicy.retryDecision.retry, @@ -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 96% rename from lib/request-handler.js rename to lib/request-handler.ts index c1c7b6daf..be16897ea 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"; +import types from "./types/index"; +import utils from "./utils"; +import RequestExecution from "./request-execution"; +import promiseUtils from "./promise-utils"; + -const errors = require('./errors'); -const types = require('./types'); -const utils = require('./utils'); -const RequestExecution = require('./request-execution'); -const promiseUtils = require('./promise-utils'); /** * 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..50283162c 100644 --- a/lib/requests.js +++ b/lib/requests.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'); +import util from "util"; +import { FrameWriter } from "./writers"; +import types from "./types/index"; +import utils from "./utils"; +import { ExecutionOptions } from "./execution-options"; +import packageInfo from "../package.json" assert {type: 'json'}; -const { FrameWriter } = require('./writers'); -const types = require('./types'); -const utils = require('./utils'); -const { ExecutionOptions } = require('./execution-options'); -const packageInfo = require('../package.json'); /** * Options for the execution of the query / prepared statement @@ -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..2bdb68876 100644 --- a/lib/stream-id-stack.js +++ b/lib/stream-id-stack.ts @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import types from "./types/index"; -const types = require('./types'); /** * Group size @@ -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..7dd07159d 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"; +import utils from "./utils"; +import errors from "./errors"; +import { FrameReader } from "./readers"; -'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..29a9c14ba 100644 --- a/lib/token.js +++ b/lib/token.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import types from "./types/index"; +import util from "util"; -const types = require('./types'); -const util = require('util'); const _Murmur3TokenType = types.dataTypes.getByName('bigint'); const _RandomTokenType = types.dataTypes.getByName('varint'); @@ -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..8544f024c 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"; +import token from "./token"; +import utils from "./utils"; +import MutableLong from "./types/mutable-long"; + -const types = require('./types'); -const token = require('./token'); -const utils = require('./utils'); -const MutableLong = require('./types/mutable-long'); 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.d.ts b/lib/tracker/index.d.ts deleted file mode 100644 index e39e8bae3..000000000 --- a/lib/tracker/index.d.ts +++ /dev/null @@ -1,58 +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 { ExecutionOptions, Host } from '../../'; - -export namespace tracker { - 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; - } - - 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; - } -} \ 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..4faeb3566 100644 --- a/lib/tracker/index.js +++ b/lib/tracker/index.ts @@ -14,12 +14,20 @@ * limitations under the License. */ -'use strict'; + /** * Tracker module. * @module tracker */ -exports.RequestLogger = require('./request-logger'); -exports.RequestTracker = require('./request-tracker'); \ No newline at end of file +import RequestTracker from "./request-tracker"; +import RequestLogger from "./request-logger"; +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..9e0292543 100644 --- a/lib/tracker/request-logger.js +++ b/lib/tracker/request-logger.ts @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import events from "events"; +import RequestTracker from "./request-tracker"; +import errors from "../errors"; +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; @@ -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 98% rename from lib/tracker/request-tracker.js rename to lib/tracker/request-tracker.ts index 3a00732e1..82d20a71c 100644 --- a/lib/tracker/request-tracker.js +++ b/lib/tracker/request-tracker.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -'use strict'; + /** * Tracks request execution for a {@link Client}. @@ -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..846c16529 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. */ -'use strict'; -const Integer = require('./integer'); -const utils = require('../utils'); +import Integer from "./integer"; +import utils from "../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..aa2f1a80c 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"; + const VIntCoding = utils.VIntCoding; + /** @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.d.ts b/lib/types/index.d.ts deleted file mode 100644 index 3826ed807..000000000 --- a/lib/types/index.d.ts +++ /dev/null @@ -1,468 +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 _Long = require('long'); -import * as stream from 'stream'; -import { ValueCallback } from '../../'; - -export namespace types { - class Long extends _Long { - - } - - enum consistencies { - any = 0x00, - one = 0x01, - two = 0x02, - three = 0x03, - quorum = 0x04, - all = 0x05, - localQuorum = 0x06, - eachQuorum = 0x07, - serial = 0x08, - localSerial = 0x09, - localOne = 0x0a - } - - 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, - } - - enum distance { - local = 0, - remote, - ignored - } - - 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 - } - - enum protocolVersion { - v1 = 0x01, - v2 = 0x02, - v3 = 0x03, - v4 = 0x04, - v5 = 0x05, - v6 = 0x06, - dseV1 = 0x41, - dseV2 = 0x42, - maxSupported = dseV2, - minSupported = v1 - } - - namespace protocolVersion { - function isSupported(version: protocolVersion): boolean; - } - - const unset: object; - - 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; - } - - 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; - } - - class InetAddress { - length: number; - - version: number; - - constructor(buffer: Buffer); - - static fromString(value: string): InetAddress; - - equals(other: InetAddress): boolean; - - getBuffer(): Buffer; - - toString(): string; - - toJSON(): string; - } - - 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; - } - - 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; - } - - 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; - } - - 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; - } - - interface ResultStream extends stream.Readable { - buffer: Buffer; - paused: boolean; - - add(chunk: Buffer): void; - } - - interface Row { - get(columnName: string | number): any; - - keys(): string[]; - - forEach(callback: (row: Row) => void): void; - - values(): any[]; - - [key: string]: any; - } - - 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; - } - - class Tuple { - elements: any[]; - length: number; - - constructor(...args: any[]); - - static fromArray(elements: any[]): Tuple; - - get(index: number): any; - - toString(): string; - - toJSON(): string; - - values(): any[]; - } - - 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; - } - - class Vector { - static get [Symbol.species](): typeof Vector; - /** - * - * @param {Float32Array | Array} elements - * @param {string?} subtype - */ - constructor(elements: Float32Array | Array, subtype?: string | null); - elements: any[]; - /** - * Returns the number of the elements. - * @type Number - */ - length: number; - subtype: string; - /** - * Returns the string representation of the vector. - * @returns {string} - */ - toString(): string; - /** - * - * @param {number} index - */ - at(index: number): any; - /** - * - * @param {(value: any, index: number, array: any[]) => void} callback - */ - forEach(callback: (value: any, index: number, array: any[]) => void): void; - /** - * @returns {string | null} get the subtype string, e.g., "float", but it's optional so it can return null - */ - getSubtype(): string | null; - /** - * - * @returns {IterableIterator} - */ - [Symbol.iterator](): IterableIterator; - } -} \ No newline at end of file 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..567cb7416 100644 --- a/lib/types/index.js +++ b/lib/types/index.ts @@ -13,21 +13,26 @@ * 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"; +import TimeUuid from "./time-uuid"; +import Uuid from "./uuid"; +import protocolVersion from "./protocol-version"; +import utils from "../utils"; +import Long from "long"; +import BigDecimal from './big-decimal'; +import Duration from './duration'; +import InetAddress from './inet-address'; +import Integer from './integer'; +import LocalDate from './local-date'; +import LocalTime from './local-time'; +import ResultSet from './result-set'; +import ResultStream from './result-stream'; +import Row from './row'; +import Tuple from './tuple'; +import Vector from "./vector"; -const errors = require('../errors'); -const TimeUuid = require('./time-uuid'); -const Uuid = require('./uuid'); -const protocolVersion = require('./protocol-version'); -const utils = require('../utils'); -/** @module types */ -/** - * Long constructor, wrapper of the internal library used: {@link https://github.com/dcodeIO/long.js Long.js}. - * @constructor - */ -const Long = require('long'); /** * Consistency levels @@ -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 98% rename from lib/types/inet-address.js rename to lib/types/inet-address.ts index 1647deaf6..9edfcdd62 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"; + -const utils = require('../utils'); /** @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 80% rename from lib/types/integer.js rename to lib/types/integer.ts index d70d789a1..94d0f0149 100644 --- a/lib/types/integer.js +++ b/lib/types/integer.ts @@ -1,3 +1,5 @@ +import utils from "../utils"; + // 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., @@ -52,9 +50,9 @@ function Integer (bits, sign) { // Copy the 32-bit signed integer values passed in. We prune out those at the // top that equal the sign since they are redundant. - var top = true; - for (var i = bits.length - 1; i >= 0; i--) { - var val = bits[i] | 0; + let top = true; + for (let i = bits.length - 1; i >= 0; i--) { + const val = bits[i] | 0; if (!top || val != sign) { this.bits_[i] = val; top = false; @@ -81,15 +79,15 @@ Integer.IntCache_ = {}; * @return {!Integer} The corresponding Integer value. */ Integer.fromInt = function(value) { - if (-128 <= value && value < 128) { - var cachedObj = Integer.IntCache_[value]; + if (value >= -128 && value < 128) { + const cachedObj = Integer.IntCache_[value]; if (cachedObj) { return cachedObj; } } - var obj = new Integer([value | 0], value < 0 ? -1 : 0); - if (-128 <= value && value < 128) { + const obj = new Integer([value | 0], value < 0 ? -1 : 0); + if (value >= -128 && value < 128) { Integer.IntCache_[value] = obj; } return obj; @@ -107,15 +105,15 @@ Integer.fromNumber = function(value) { return Integer.ZERO; } else if (value < 0) { return Integer.fromNumber(-value).negate(); - } else { - var bits = []; - var pow = 1; - for (var i = 0; value >= pow; i++) { - bits[i] = (value / pow) | 0; - pow *= Integer.TWO_PWR_32_DBL_; - } - return new Integer(bits, 0); + } + const bits = []; + let pow = 1; + for (let i = 0; value >= pow; i++) { + bits[i] = (value / pow) | 0; + pow *= Integer.TWO_PWR_32_DBL_; } + return new Integer(bits, 0); + }; @@ -129,7 +127,7 @@ Integer.fromNumber = function(value) { * @return {!Integer} The corresponding Integer value. */ Integer.fromBits = function(bits) { - var high = bits[bits.length - 1]; + const high = bits[bits.length - 1]; //noinspection JSBitwiseOperatorUsage return new Integer(bits, high & (1 << 31) ? -1 : 0); }; @@ -147,8 +145,8 @@ Integer.fromString = function(str, opt_radix) { throw TypeError('number format error: empty string'); } - var radix = opt_radix || 10; - if (radix < 2 || 36 < radix) { + const radix = opt_radix || 10; + if (radix < 2 || radix > 36) { throw Error('radix out of range: ' + radix); } @@ -160,14 +158,14 @@ Integer.fromString = function(str, opt_radix) { // Do several (8) digits each time through the loop, so as to // minimize the calls to the very expensive emulated div. - var radixToPower = Integer.fromNumber(Math.pow(radix, 8)); + const radixToPower = Integer.fromNumber(Math.pow(radix, 8)); - var result = Integer.ZERO; - for (var i = 0; i < str.length; i += 8) { - var size = Math.min(8, str.length - i); - var value = parseInt(str.substring(i, i + size), radix); + let result = Integer.ZERO; + for (let i = 0; i < str.length; i += 8) { + const size = Math.min(8, str.length - i); + const value = parseInt(str.substring(i, i + size), radix); if (size < 8) { - var power = Integer.fromNumber(Math.pow(radix, size)); + const power = Integer.fromNumber(Math.pow(radix, size)); result = result.multiply(power).add(Integer.fromNumber(value)); } else { result = result.multiply(radixToPower); @@ -184,18 +182,18 @@ Integer.fromString = function(str, opt_radix) { * @returns {Integer} */ Integer.fromBuffer = function (buf) { - var bits = new Array(Math.ceil(buf.length / 4)); + const bits = new Array(Math.ceil(buf.length / 4)); //noinspection JSBitwiseOperatorUsage - var sign = buf[0] & (1 << 7) ? -1 : 0; - for (var i = 0; i < bits.length; i++) { - var offset = buf.length - ((i + 1) * 4); + const sign = buf[0] & (1 << 7) ? -1 : 0; + for (let i = 0; i < bits.length; i++) { + let offset = buf.length - ((i + 1) * 4); var value; if (offset < 0) { //The buffer length is not multiple of 4 offset = offset + 4; value = 0; - for (var j = 0; j < offset; j++) { - var byte = buf[j]; + for (let j = 0; j < offset; j++) { + let byte = buf[j]; if (sign === -1) { //invert the bits byte = ~byte & 0xff; @@ -224,18 +222,18 @@ Integer.fromBuffer = function (buf) { * @returns {Buffer} */ Integer.toBuffer = function (value) { - var sign = value.sign_; - var bits = value.bits_; + const sign = value.sign_; + const bits = value.bits_; if (bits.length === 0) { //[0] or [0xffffffff] return utils.allocBufferFromArray([value.sign_]); } //the high bits might need to be represented in less than 4 bytes - var highBits = bits[bits.length-1]; + let highBits = bits[bits.length-1]; if (sign === -1) { highBits = ~highBits; } - var high = []; + const high = []; if (highBits >>> 24 > 0) { high.push((highBits >> 24) & 0xff); } @@ -257,9 +255,9 @@ Integer.toBuffer = function (value) { //its positive but it lost the byte containing the sign bit high.unshift(0); } - var buf = utils.allocBufferUnsafe(high.length + ((bits.length-1) * 4)); - for (var j = 0; j < high.length; j++) { - var b = high[j]; + const buf = utils.allocBufferUnsafe(high.length + ((bits.length-1) * 4)); + for (let j = 0; j < high.length; j++) { + const b = high[j]; if (sign === -1) { buf[j] = ~b; } @@ -267,9 +265,9 @@ Integer.toBuffer = function (value) { buf[j] = b; } } - for (var i = 0; i < bits.length - 1; i++) { - var group = bits[bits.length - 2 - i]; - var offset = high.length + i * 4; + for (let i = 0; i < bits.length - 1; i++) { + const group = bits[bits.length - 2 - i]; + const offset = high.length + i * 4; buf.writeInt32BE(group, offset); } return buf; @@ -313,15 +311,15 @@ Integer.prototype.toInt = function() { Integer.prototype.toNumber = function() { if (this.isNegative()) { return -this.negate().toNumber(); - } else { - var val = 0; - var pow = 1; - for (var i = 0; i < this.bits_.length; i++) { - val += this.getBitsUnsigned(i) * pow; - pow *= Integer.TWO_PWR_32_DBL_; - } - return val; + } + let val = 0; + let pow = 1; + for (let i = 0; i < this.bits_.length; i++) { + val += this.getBitsUnsigned(i) * pow; + pow *= Integer.TWO_PWR_32_DBL_; } + return val; + }; @@ -331,8 +329,8 @@ Integer.prototype.toNumber = function() { * @override */ Integer.prototype.toString = function(opt_radix) { - var radix = opt_radix || 10; - if (radix < 2 || 36 < radix) { + const radix = opt_radix || 10; + if (radix < 2 || radix > 36) { throw Error('radix out of range: ' + radix); } @@ -344,24 +342,24 @@ Integer.prototype.toString = function(opt_radix) { // Do several (6) digits each time through the loop, so as to // minimize the calls to the very expensive emulated div. - var radixToPower = Integer.fromNumber(Math.pow(radix, 6)); + const radixToPower = Integer.fromNumber(Math.pow(radix, 6)); - var rem = this; - var result = ''; + let rem = this; + let result = ''; while (true) { - var remDiv = rem.divide(radixToPower); - var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); - var digits = intval.toString(radix); + const remDiv = rem.divide(radixToPower); + const intval = rem.subtract(remDiv.multiply(radixToPower)).toInt(); + let digits = intval.toString(radix); rem = remDiv; if (rem.isZero()) { return digits + result; - } else { - while (digits.length < 6) { - digits = '0' + digits; - } - result = '' + digits + result; + } + while (digits.length < 6) { + digits = '0' + digits; } + result = '' + digits + result; + } }; @@ -374,12 +372,12 @@ Integer.prototype.toString = function(opt_radix) { */ Integer.prototype.getBits = function(index) { if (index < 0) { - return 0; // Allowing this simplifies bit shifting operations below... + return 0; // Allowing this simplifies bit shifting operations below... } else if (index < this.bits_.length) { return this.bits_[index]; - } else { - return this.sign_; - } + } + return this.sign_; + }; @@ -389,7 +387,7 @@ Integer.prototype.getBits = function(index) { * @return {number} The requested 32-bits as an unsigned number. */ Integer.prototype.getBitsUnsigned = function(index) { - var val = this.getBits(index); + const val = this.getBits(index); return val >= 0 ? val : Integer.TWO_PWR_32_DBL_ + val; }; @@ -405,7 +403,7 @@ Integer.prototype.isZero = function() { if (this.sign_ != 0) { return false; } - for (var i = 0; i < this.bits_.length; i++) { + for (let i = 0; i < this.bits_.length; i++) { if (this.bits_[i] != 0) { return false; } @@ -435,8 +433,8 @@ Integer.prototype.equals = function(other) { if (this.sign_ != other.sign_) { return false; } - var len = Math.max(this.bits_.length, other.bits_.length); - for (var i = 0; i < len; i++) { + const len = Math.max(this.bits_.length, other.bits_.length); + for (let i = 0; i < len; i++) { if (this.getBits(i) != other.getBits(i)) { return false; } @@ -497,14 +495,14 @@ Integer.prototype.lessThanOrEqual = function(other) { * if the given one is greater. */ Integer.prototype.compare = function(other) { - var diff = this.subtract(other); + const diff = this.subtract(other); if (diff.isNegative()) { return -1; } else if (diff.isZero()) { return 0; - } else { - return +1; - } + } + return +1; + }; @@ -515,23 +513,23 @@ Integer.prototype.compare = function(other) { * @return {!Integer} The shorted integer value. */ Integer.prototype.shorten = function(numBits) { - var arr_index = (numBits - 1) >> 5; - var bit_index = (numBits - 1) % 32; - var bits = []; - for (var i = 0; i < arr_index; i++) { + const arr_index = (numBits - 1) >> 5; + const bit_index = (numBits - 1) % 32; + const bits = []; + for (let i = 0; i < arr_index; i++) { bits[i] = this.getBits(i); } - var sigBits = bit_index == 31 ? 0xFFFFFFFF : (1 << (bit_index + 1)) - 1; - var val = this.getBits(arr_index) & sigBits; + const sigBits = bit_index == 31 ? 0xFFFFFFFF : (1 << (bit_index + 1)) - 1; + let val = this.getBits(arr_index) & sigBits; //noinspection JSBitwiseOperatorUsage if (val & (1 << bit_index)) { val |= 0xFFFFFFFF - sigBits; bits[arr_index] = val; return new Integer(bits, -1); - } else { - bits[arr_index] = val; - return new Integer(bits, 0); - } + } + bits[arr_index] = val; + return new Integer(bits, 0); + }; @@ -547,19 +545,19 @@ Integer.prototype.negate = function() { * @return {!Integer} The Integer result. */ Integer.prototype.add = function(other) { - var len = Math.max(this.bits_.length, other.bits_.length); - var arr = []; - var carry = 0; + const len = Math.max(this.bits_.length, other.bits_.length); + const arr = []; + let carry = 0; - for (var i = 0; i <= len; i++) { - var a1 = this.getBits(i) >>> 16; - var a0 = this.getBits(i) & 0xFFFF; + for (let i = 0; i <= len; i++) { + const a1 = this.getBits(i) >>> 16; + const a0 = this.getBits(i) & 0xFFFF; - var b1 = other.getBits(i) >>> 16; - var b0 = other.getBits(i) & 0xFFFF; + const b1 = other.getBits(i) >>> 16; + const b0 = other.getBits(i) & 0xFFFF; - var c0 = carry + a0 + b0; - var c1 = (c0 >>> 16) + a1 + b1; + let c0 = carry + a0 + b0; + let c1 = (c0 >>> 16) + a1 + b1; carry = c1 >>> 16; c0 &= 0xFFFF; c1 &= 0xFFFF; @@ -594,9 +592,9 @@ Integer.prototype.multiply = function(other) { if (this.isNegative()) { if (other.isNegative()) { return this.negate().multiply(other.negate()); - } else { - return this.negate().multiply(other).negate(); - } + } + return this.negate().multiply(other).negate(); + } else if (other.isNegative()) { return this.multiply(other.negate()).negate(); } @@ -608,18 +606,18 @@ Integer.prototype.multiply = function(other) { } // Fill in an array of 16-bit products. - var len = this.bits_.length + other.bits_.length; - var arr = []; + const len = this.bits_.length + other.bits_.length; + const arr = []; for (var i = 0; i < 2 * len; i++) { arr[i] = 0; } for (var i = 0; i < this.bits_.length; i++) { - for (var j = 0; j < other.bits_.length; j++) { - var a1 = this.getBits(i) >>> 16; - var a0 = this.getBits(i) & 0xFFFF; + for (let j = 0; j < other.bits_.length; j++) { + const a1 = this.getBits(i) >>> 16; + const a0 = this.getBits(i) & 0xFFFF; - var b1 = other.getBits(j) >>> 16; - var b0 = other.getBits(j) & 0xFFFF; + const b1 = other.getBits(j) >>> 16; + const b0 = other.getBits(j) & 0xFFFF; arr[2 * i + 2 * j] += a0 * b0; Integer.carry16_(arr, 2 * i + 2 * j); @@ -672,9 +670,9 @@ Integer.prototype.divide = function(other) { if (this.isNegative()) { if (other.isNegative()) { return this.negate().divide(other.negate()); - } else { - return this.negate().divide(other).negate(); - } + } + return this.negate().divide(other).negate(); + } else if (other.isNegative()) { return this.divide(other.negate()).negate(); } @@ -684,22 +682,22 @@ Integer.prototype.divide = function(other) { // into the result, and subtract it from the remainder. It is critical that // the approximate value is less than or equal to the real value so that the // remainder never becomes negative. - var res = Integer.ZERO; - var rem = this; + let res = Integer.ZERO; + let rem = this; while (rem.greaterThanOrEqual(other)) { // Approximate the result of division. This may be a little greater or // smaller than the actual value. - var approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); + let approx = Math.max(1, Math.floor(rem.toNumber() / other.toNumber())); // We will tweak the approximate result by changing it in the 48-th digit or // the smallest non-fractional digit, whichever is larger. - var log2 = Math.ceil(Math.log(approx) / Math.LN2); - var delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48); + const log2 = Math.ceil(Math.log(approx) / Math.LN2); + const delta = (log2 <= 48) ? 1 : Math.pow(2, log2 - 48); // Decrease the approximation until it is smaller than the remainder. Note // that if it is too large, the product overflows and is negative. - var approxRes = Integer.fromNumber(approx); - var approxRem = approxRes.multiply(other); + let approxRes = Integer.fromNumber(approx); + let approxRem = approxRes.multiply(other); while (approxRem.isNegative() || approxRem.greaterThan(rem)) { approx -= delta; approxRes = Integer.fromNumber(approx); @@ -731,9 +729,9 @@ Integer.prototype.modulo = function(other) { /** @return {!Integer} The bitwise-NOT of this value. */ Integer.prototype.not = function() { - var len = this.bits_.length; - var arr = []; - for (var i = 0; i < len; i++) { + const len = this.bits_.length; + const arr = []; + for (let i = 0; i < len; i++) { arr[i] = ~this.bits_[i]; } return new Integer(arr, ~this.sign_); @@ -746,9 +744,9 @@ Integer.prototype.not = function() { * @return {!Integer} The bitwise-AND of this and the other. */ Integer.prototype.and = function(other) { - var len = Math.max(this.bits_.length, other.bits_.length); - var arr = []; - for (var i = 0; i < len; i++) { + const len = Math.max(this.bits_.length, other.bits_.length); + const arr = []; + for (let i = 0; i < len; i++) { arr[i] = this.getBits(i) & other.getBits(i); } return new Integer(arr, this.sign_ & other.sign_); @@ -761,9 +759,9 @@ Integer.prototype.and = function(other) { * @return {!Integer} The bitwise-OR of this and the other. */ Integer.prototype.or = function(other) { - var len = Math.max(this.bits_.length, other.bits_.length); - var arr = []; - for (var i = 0; i < len; i++) { + const len = Math.max(this.bits_.length, other.bits_.length); + const arr = []; + for (let i = 0; i < len; i++) { arr[i] = this.getBits(i) | other.getBits(i); } return new Integer(arr, this.sign_ | other.sign_); @@ -776,9 +774,9 @@ Integer.prototype.or = function(other) { * @return {!Integer} The bitwise-XOR of this and the other. */ Integer.prototype.xor = function(other) { - var len = Math.max(this.bits_.length, other.bits_.length); - var arr = []; - for (var i = 0; i < len; i++) { + const len = Math.max(this.bits_.length, other.bits_.length); + const arr = []; + for (let i = 0; i < len; i++) { arr[i] = this.getBits(i) ^ other.getBits(i); } return new Integer(arr, this.sign_ ^ other.sign_); @@ -791,11 +789,11 @@ Integer.prototype.xor = function(other) { * @return {!Integer} This shifted to the left by the given amount. */ Integer.prototype.shiftLeft = function(numBits) { - var arr_delta = numBits >> 5; - var bit_delta = numBits % 32; - var len = this.bits_.length + arr_delta + (bit_delta > 0 ? 1 : 0); - var arr = []; - for (var i = 0; i < len; i++) { + const arr_delta = numBits >> 5; + const bit_delta = numBits % 32; + const len = this.bits_.length + arr_delta + (bit_delta > 0 ? 1 : 0); + const arr = []; + for (let i = 0; i < len; i++) { if (bit_delta > 0) { arr[i] = (this.getBits(i - arr_delta) << bit_delta) | (this.getBits(i - arr_delta - 1) >>> (32 - bit_delta)); @@ -813,11 +811,11 @@ Integer.prototype.shiftLeft = function(numBits) { * @return {!Integer} This shifted to the right by the given amount. */ Integer.prototype.shiftRight = function(numBits) { - var arr_delta = numBits >> 5; - var bit_delta = numBits % 32; - var len = this.bits_.length - arr_delta; - var arr = []; - for (var i = 0; i < len; i++) { + const arr_delta = numBits >> 5; + const bit_delta = numBits % 32; + const len = this.bits_.length - arr_delta; + const arr = []; + for (let i = 0; i < len; i++) { if (bit_delta > 0) { arr[i] = (this.getBits(i + arr_delta) >>> bit_delta) | (this.getBits(i + arr_delta + 1) << (32 - bit_delta)); @@ -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..b75be4d44 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"; + -const utils = require('../utils'); /** @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..0c092530c 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. */ -'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"; + + /** @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..33546df7b 100644 --- a/lib/types/mutable-long.js +++ b/lib/types/mutable-long.ts @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -"use strict"; +import Long from "long"; -const Long = require('long'); 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 98% rename from lib/types/protocol-version.js rename to lib/types/protocol-version.ts index 4accf2b68..be271a113 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"; +import VersionNumber from "./version-number"; + -const utils = require('../utils'); -const VersionNumber = require('./version-number'); 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..2c162d9ea 100644 --- a/lib/types/result-set.js +++ b/lib/types/result-set.ts @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import utils from "../utils"; +import errors from "../errors"; -'use strict'; - -const utils = require('../utils'); -const errors = require('../errors'); const asyncIteratorSymbol = Symbol.asyncIterator || '@@asyncIterator'; @@ -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..e121dc641 100644 --- a/lib/types/result-stream.js +++ b/lib/types/result-stream.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Readable } from "stream"; +import utils from "../utils"; +import errors from "../errors"; +import clientOptions from "../client-options"; -'use strict'; -const { Readable } = require('stream'); -const utils = require('../utils'); -const errors = require('../errors'); -const clientOptions = require('../client-options'); /** @module types */ /** @@ -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 98% rename from lib/types/row.js rename to lib/types/row.ts index fca713211..8366fe7d7 100644 --- a/lib/types/row.js +++ b/lib/types/row.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + /** @module types */ /** * Represents a result row @@ -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..bb791f875 100644 --- a/lib/types/time-uuid.js +++ b/lib/types/time-uuid.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 crypto = require('crypto'); -const Long = require('long'); +import util from "util"; +import crypto from "crypto"; +import Long from "long"; +import Uuid from "./uuid"; +import utils from "../utils"; -const Uuid = require('./uuid'); -const utils = require('../utils'); /** @module types */ /** @@ -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 98% rename from lib/types/tuple.js rename to lib/types/tuple.ts index f8989ccb7..da24b05b8 100644 --- a/lib/types/tuple.js +++ b/lib/types/tuple.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -"use strict"; + /** @module types */ @@ -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..4ecb93547 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"; + -const crypto = require('crypto'); -const utils = require('../utils'); /** @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 97% rename from lib/types/vector.js rename to lib/types/vector.ts index 308511eea..27351e1df 100644 --- a/lib/types/vector.js +++ b/lib/types/vector.ts @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -"use strict"; + /** @module types */ /** * 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..b54e0a524 100644 --- a/lib/types/version-number.js +++ b/lib/types/version-number.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; + const _versionPattern = /(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+)?)?(?:[-~]([\w+]*(?:-\w[.\w]*)*))?(?:\+([.\w]+))?/; @@ -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..83613ad37 100644 --- a/lib/utils.js +++ b/lib/utils.ts @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import Long from "long"; +import util from "util"; +import net from "net"; +import { EventEmitter } from "events"; +import errors from "./errors"; +import promiseUtils from "./promise-utils"; -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'); /** * Max int that can be accurately represented with 64-bit Number (2^53) @@ -73,7 +71,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 +1039,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. @@ -1255,6 +1252,7 @@ const VIntCoding = (function () { * @throws VIntOutOfRangeException If the vint doesn't fit into a 32-bit integer */ // eslint-disable-next-line no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars function getUnsignedVInt32(input, readerIndex) { return checkedCast(getUnsignedVInt(input, readerIndex, input.length)); } @@ -1370,49 +1368,97 @@ 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 +}; + +export { + 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 97% rename from lib/writers.js rename to lib/writers.ts index a3d4f2816..d3d6db872 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"; +import utils from "./utils"; + -const types = require('./types'); -const utils = require('./utils.js'); 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..60fb2b572 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,12 @@ "long": "~5.2.3" }, "devDependencies": { + "@stylistic/eslint-plugin": "^3.1.0", + "@types/mocha": "^10.0.10", + "@typescript-eslint/eslint-plugin": "^8.26.1", + "@typescript-eslint/parser": "^8.26.1", "chai": "~4.3.8", + "eslint": "^8.57.1", "kerberos": "~2.0.3", "mocha": "~10.2.0", "mocha-jenkins-reporter": "~0.4.8", @@ -26,6 +31,200 @@ "node": ">=18" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.5.0.tgz", + "integrity": "sha512-RoV8Xs9eNwiDvhv7M+xcL4PWyRyIXRY/FLp3buU4h1EYfdF7unWUy3dOjPqb3C7rMUewIcqwW850PgS8h1o1yg==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "deprecated": "Use @eslint/config-array instead", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", + "dev": true + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@sinonjs/commons": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", @@ -70,6 +269,43 @@ "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, + "node_modules/@stylistic/eslint-plugin": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-3.1.0.tgz", + "integrity": "sha512-pA6VOrOqk0+S8toJYhQGv2MWpQQR0QpeUo9AhNkC49Y26nxBQ/nH1rta9bUU1rPw2fJ1zZEMV5oCX5AazT7J2g==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "^8.13.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "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", @@ -78,6 +314,229 @@ "undici-types": "~5.26.4" } }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.26.1.tgz", + "integrity": "sha512-2X3mwqsj9Bd3Ciz508ZUtoQQYpOhU/kWoUqIf49H8Z0+Vbh6UF/y0OEYp0Q0axOGzaBGs7QxRwq0knSQ8khQNA==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.26.1", + "@typescript-eslint/type-utils": "8.26.1", + "@typescript-eslint/utils": "8.26.1", + "@typescript-eslint/visitor-keys": "8.26.1", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.26.1.tgz", + "integrity": "sha512-w6HZUV4NWxqd8BdeFf81t07d7/YV9s7TCWrQQbG5uhuvGUAW+fq1usZ1Hmz9UPNLniFnD8GLSsDpjP0hm1S4lQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "8.26.1", + "@typescript-eslint/types": "8.26.1", + "@typescript-eslint/typescript-estree": "8.26.1", + "@typescript-eslint/visitor-keys": "8.26.1", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.26.1.tgz", + "integrity": "sha512-6EIvbE5cNER8sqBu6V7+KeMZIC1664d2Yjt+B9EWUXrsyWpxx4lEZrmvxgSKRC6gX+efDL/UY9OpPZ267io3mg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.26.1", + "@typescript-eslint/visitor-keys": "8.26.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.26.1.tgz", + "integrity": "sha512-Kcj/TagJLwoY/5w9JGEFV0dclQdyqw9+VMndxOJKtoFSjfZhLXhYjzsQEeyza03rwHx2vFEGvrJWJBXKleRvZg==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "8.26.1", + "@typescript-eslint/utils": "8.26.1", + "debug": "^4.3.4", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.26.1.tgz", + "integrity": "sha512-n4THUQW27VmQMx+3P+B0Yptl7ydfceUj4ON/AQILAASwgYdZ/2dhfymRMh5egRUrvK5lSmaOm77Ry+lmXPOgBQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.26.1.tgz", + "integrity": "sha512-yUwPpUHDgdrv1QJ7YQal3cMVBGWfnuCdKbXw1yyjArax3353rEJP1ZA+4F8nOlQ3RfS2hUN/wze3nlY+ZOhvoA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.26.1", + "@typescript-eslint/visitor-keys": "8.26.1", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.26.1.tgz", + "integrity": "sha512-V4Urxa/XtSUroUrnI7q6yUTD3hDtfJ2jzVfeT3VK0ciizfK2q/zGC0iDh1lFMUZR8cImRrep6/q0xd/1ZGPQpg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.26.1", + "@typescript-eslint/types": "8.26.1", + "@typescript-eslint/typescript-estree": "8.26.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.26.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.26.1.tgz", + "integrity": "sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.26.1", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/adm-zip": { "version": "0.5.10", "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", @@ -86,6 +545,22 @@ "node": ">=6.0" } }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -227,12 +702,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -268,6 +743,15 @@ "ieee754": "^1.1.13" } }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/camelcase": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", @@ -403,6 +887,20 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -474,6 +972,12 @@ "node": ">=4.0.0" } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, "node_modules/detect-libc": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", @@ -492,6 +996,18 @@ "node": ">=0.3.1" } }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -528,6 +1044,202 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/eslint": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", + "dev": true, + "dependencies": { + "acorn": "^8.14.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -537,6 +1249,61 @@ "node": ">=6" } }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -557,9 +1324,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -593,6 +1360,42 @@ "flat": "cli.js" } }, + "node_modules/flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flat-cache/node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/flatted": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", + "dev": true + }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -605,20 +1408,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", @@ -693,6 +1482,27 @@ "node": "*" } }, + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -743,6 +1553,40 @@ } ] }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -837,6 +1681,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -864,6 +1717,12 @@ "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -876,6 +1735,24 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, "node_modules/just-extend": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", @@ -897,6 +1774,28 @@ "node": ">=12.9.0" } }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -918,6 +1817,12 @@ "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -954,6 +1859,28 @@ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", "dev": true }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, "node_modules/mimic-response": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", @@ -1119,6 +2046,12 @@ "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", "dev": true }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, "node_modules/nise": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", @@ -1153,39 +2086,6 @@ "node": ">=10" } }, - "node_modules/node-abi/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-abi/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/node-abi/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/node-addon-api": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", @@ -1210,6 +2110,23 @@ "wrappy": "1" } }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -1240,6 +2157,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -1258,6 +2187,15 @@ "node": ">=0.10.0" } }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -1320,6 +2258,15 @@ "node": ">=10" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/proxyquire": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz", @@ -1341,6 +2288,35 @@ "once": "^1.3.1" } }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -1412,6 +2388,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -1424,6 +2419,29 @@ "rimraf": "bin.js" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1444,6 +2462,18 @@ } ] }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -1453,6 +2483,27 @@ "randombytes": "^2.1.0" } }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/simple-concat": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", @@ -1672,6 +2723,12 @@ "node": ">=6.0.0" } }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -1684,6 +2741,18 @@ "node": ">=8.0" } }, + "node_modules/ts-api-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.1.tgz", + "integrity": "sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==", + "dev": true, + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -1696,6 +2765,18 @@ "node": "*" } }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -1705,17 +2786,76 @@ "node": ">=4" } }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", + "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "dev": true, + "peer": 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", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/workerpool": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", diff --git a/package.json b/package.json index c1c72aa30..29cea70a1 100644 --- a/package.json +++ b/package.json @@ -18,14 +18,20 @@ "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", "long": "~5.2.3" }, "devDependencies": { + "@stylistic/eslint-plugin": "^3.1.0", + "@types/mocha": "^10.0.10", + "@typescript-eslint/eslint-plugin": "^8.26.1", + "@typescript-eslint/parser": "^8.26.1", "chai": "~4.3.8", + "eslint": "^8.57.1", "kerberos": "~2.0.3", "mocha": "~10.2.0", "mocha-jenkins-reporter": "~0.4.8", @@ -49,7 +55,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 97% rename from test/integration/long/client-metadata-tests.js rename to test/integration/long/client-metadata-tests.ts index 6833f9134..af2cadf72 100644 --- a/test/integration/long/client-metadata-tests.js +++ b/test/integration/long/client-metadata-tests.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Encoder from "../../../lib/encoder"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import tokenizer from "../../../lib/tokenizer"; -const helper = require('../../test-helper'); -const Encoder = require('../../../lib/encoder'); -const Client = require('../../../lib/client'); -const utils = require('../../../lib/utils'); -const tokenizer = require('../../../lib/tokenizer'); describe('Client', function () { this.timeout(240000); diff --git a/test/integration/long/event-tests.js b/test/integration/long/event-tests.ts similarity index 95% rename from test/integration/long/event-tests.js rename to test/integration/long/event-tests.ts index b3cfc3d6d..61b4a67e2 100644 --- a/test/integration/long/event-tests.js +++ b/test/integration/long/event-tests.ts @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../../test-helper'); -const Host = require('../../../lib/host').Host; -const utils = require('../../../lib/utils'); -const Client = require('../../../lib/client'); +import assert from "assert"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import Client from "../../../lib/client"; +import { Host } from "../../../lib/host"; describe('Client', function () { describe('events', function () { diff --git a/test/integration/long/load-balancing-tests.js b/test/integration/long/load-balancing-tests.ts similarity index 96% rename from test/integration/long/load-balancing-tests.js rename to test/integration/long/load-balancing-tests.ts index 2755f9e01..12c9c9d1a 100644 --- a/test/integration/long/load-balancing-tests.js +++ b/test/integration/long/load-balancing-tests.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import loadBalancing from "../../../lib/policies/load-balancing"; + -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 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 91% 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..42610859b 100644 --- a/test/integration/short/auth/dse-gssapi-auth-provider-tests.js +++ b/test/integration/short/auth/dse-gssapi-auth-provider-tests.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../../../test-helper'); -const DseGssapiAuthProvider = require('../../../../lib/auth/dse-gssapi-auth-provider'); -const Client = require('../../../../lib/client'); -const errors = require('../../../../lib/errors'); + +import DseGssapiAuthProvider from '../../../../lib/auth/dse-gssapi-auth-provider'; +import assert from "assert"; +import helper from "../../../test-helper"; +import Client from "../../../../lib/client"; +import errors from "../../../../lib/errors"; const ads = helper.ads; const cDescribe = helper.conditionalDescribe( helper.requireOptional('kerberos') && helper.isDseGreaterThan('5.0'), 'kerberos and DSE required to run'); 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 92% 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..95f187878 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 @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert } = require('chai'); -const helper = require('../../../test-helper'); -const DsePlainTextAuthProvider = require('../../../../lib/auth/dse-plain-text-auth-provider'); -const Client = require('../../../../lib/client'); + +import DsePlainTextAuthProvider from '../../../../lib/auth/dse-plain-text-auth-provider'; +import { assert } from "chai"; +import helper from "../../../test-helper"; +import Client from "../../../../lib/client"; const vdescribe = helper.vdescribe; vdescribe('dse-5.0', 'DsePlainTextAuthProvider @SERVER_API', function () { diff --git a/test/integration/short/auth/proxy-authentication-test.js b/test/integration/short/auth/proxy-authentication-test.ts similarity index 94% rename from test/integration/short/auth/proxy-authentication-test.js rename to test/integration/short/auth/proxy-authentication-test.ts index cd6c9ba37..f5b31d87b 100644 --- a/test/integration/short/auth/proxy-authentication-test.js +++ b/test/integration/short/auth/proxy-authentication-test.ts @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'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'); -const Client = require('../../../../lib/client'); -const utils = require('../../../../lib/utils'); -const errors = require('../../../../lib/errors'); -const types = require('../../../../lib/types'); + +import DsePlainTextAuthProvider from '../../../../lib/auth/dse-plain-text-auth-provider'; +import DseGssapiAuthProvider from '../../../../lib/auth/dse-gssapi-auth-provider'; +import assert from "assert"; +import helper from "../../../test-helper"; +import Client from "../../../../lib/client"; +import utils from "../../../../lib/utils"; +import errors from "../../../../lib/errors"; +import types from "../../../../lib/types/index"; const vdescribe = helper.vdescribe; const ads = helper.ads; const cDescribe = helper.conditionalDescribe(helper.requireOptional('kerberos'), 'kerberos required to run'); diff --git a/test/integration/short/client-batch-tests.js b/test/integration/short/client-batch-tests.ts similarity index 98% rename from test/integration/short/client-batch-tests.js rename to test/integration/short/client-batch-tests.ts index 46564d951..6e5c2589c 100644 --- a/test/integration/short/client-batch-tests.js +++ b/test/integration/short/client-batch-tests.ts @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; + -const helper = require('../../test-helper.js'); -const Client = require('../../../lib/client.js'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); 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 98% rename from test/integration/short/client-each-row-tests.js rename to test/integration/short/client-each-row-tests.ts index af1240ad5..4f49a994e 100644 --- a/test/integration/short/client-each-row-tests.js +++ b/test/integration/short/client-each-row-tests.ts @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import util from "util"; +import sinon from "sinon"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; +import { assert } from "chai"; -"use strict"; -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 types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); 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 99% rename from test/integration/short/client-execute-prepared-tests.js rename to test/integration/short/client-execute-prepared-tests.ts index 864eaee21..2331e20e4 100644 --- a/test/integration/short/client-execute-prepared-tests.js +++ b/test/integration/short/client-execute-prepared-tests.ts @@ -13,23 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; +import loadBalancing from "../../../lib/policies/load-balancing"; +import numericTests from "./numeric-tests"; +import pagingTests from "./paging-tests"; + -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); -const errors = require('../../../lib/errors'); -const loadBalancing = require('../../../lib/policies/load-balancing'); const vit = helper.vit; const vdescribe = helper.vdescribe; const Uuid = types.Uuid; const commonKs = helper.getRandomName('ks'); -const numericTests = require('./numeric-tests'); -const pagingTests = require('./paging-tests'); - describe('Client @SERVER_API', function () { this.timeout(120000); describe('#execute(query, params, {prepare: 1}, callback)', function () { diff --git a/test/integration/short/client-execute-simulator-tests.js b/test/integration/short/client-execute-simulator-tests.ts similarity index 94% rename from test/integration/short/client-execute-simulator-tests.js rename to test/integration/short/client-execute-simulator-tests.ts index b79a6c299..16094ef70 100644 --- a/test/integration/short/client-execute-simulator-tests.js +++ b/test/integration/short/client-execute-simulator-tests.ts @@ -13,19 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import simulacron from "../simulacron"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; +import { responseErrorCodes } from "../../../lib/types/index"; +import Client from "../../../lib/client"; +import {AllowListPolicy, DCAwareRoundRobinPolicy} from "../../../lib/policies/load-balancing"; -'use strict'; - -const { assert } = require('chai'); - -const simulacron = require('../simulacron'); -const helper = require('../../test-helper'); -const utils = require('../../../lib/utils'); -const errors = require('../../../lib/errors'); - -const { responseErrorCodes } = require('../../../lib/types'); -const Client = require('../../../lib/client'); -const { AllowListPolicy, DCAwareRoundRobinPolicy } = require('../../../lib/policies').loadBalancing; const query = "select * from data"; const clusterSize = 3; 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..a2d07012b 100644 --- a/test/integration/short/client-execute-tests.js +++ b/test/integration/short/client-execute-tests.ts @@ -13,21 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; +import numericTests from "./numeric-tests"; +import pagingTests from "./paging-tests"; +import {ExecutionProfile} from "../../../lib/execution-profile"; + -const helper = require('../../test-helper.js'); -const Client = require('../../../lib/client.js'); -const ExecutionProfile = require('../../../lib/execution-profile.js').ExecutionProfile; -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); const vit = helper.vit; const vdescribe = helper.vdescribe; -const numericTests = require('./numeric-tests'); -const pagingTests = require('./paging-tests'); - describe('Client @SERVER_API', function () { this.timeout(120000); describe('#execute(query, params, {prepare: 0}, callback)', function () { diff --git a/test/integration/short/client-pool-tests.js b/test/integration/short/client-pool-tests.ts similarity index 98% rename from test/integration/short/client-pool-tests.js rename to test/integration/short/client-pool-tests.ts index 212d2f521..ce436dc7d 100644 --- a/test/integration/short/client-pool-tests.js +++ b/test/integration/short/client-pool-tests.ts @@ -13,22 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const { assert } = require('chai'); -const dns = require('dns'); -const util = require('util'); - -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const clientOptions = require('../../../lib/client-options'); -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'); + +import { RoundRobinPolicy } from '../../../lib/policies/load-balancing'; +import { Murmur3Tokenizer } from '../../../lib/tokenizer'; +import { PlainTextAuthProvider } from '../../../lib/auth/index'; +import { assert } from "chai"; +import dns from "dns"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import clientOptions from "../../../lib/client-options"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; +import types from "../../../lib/types/index"; +import policies from "../../../lib/policies/index"; + 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 97% rename from test/integration/short/client-stream-tests.js rename to test/integration/short/client-stream-tests.ts index 0ed8ab039..e81a87dd2 100644 --- a/test/integration/short/client-stream-tests.js +++ b/test/integration/short/client-stream-tests.ts @@ -13,17 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; -const helper = require('../../test-helper.js'); -const vit = helper.vit; -const Client = require('../../../lib/client.js'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils.js'); -const errors = require('../../../lib/errors.js'); +const vit = helper.vit; describe('Client', function () { this.timeout(120000); describe('#stream(query, params, {prepare: 0})', function () { diff --git a/test/integration/short/cloud/cloud-helper.js b/test/integration/short/cloud/cloud-helper.ts similarity index 93% rename from test/integration/short/cloud/cloud-helper.js rename to test/integration/short/cloud/cloud-helper.ts index 11eaf5f73..79af2c486 100644 --- a/test/integration/short/cloud/cloud-helper.js +++ b/test/integration/short/cloud/cloud-helper.ts @@ -14,14 +14,11 @@ * limitations under the License. */ -'use strict'; - -const format = require('util').format; -const path = require('path'); -const exec = require('child_process').exec; - -const Client = require('../../../../lib/client'); -const helper = require('../../../test-helper'); +import path from "path"; +import Client from "../../../../lib/client"; +import helper from "../../../test-helper"; +import { format } from "util"; +import { exec } from "child_process"; const ccmCmdString = 'docker exec $(docker ps -a -q --filter ancestor=single_endpoint) ccm %s'; diff --git a/test/integration/short/cloud/cloud-tests.js b/test/integration/short/cloud/cloud-tests.ts similarity index 95% rename from test/integration/short/cloud/cloud-tests.js rename to test/integration/short/cloud/cloud-tests.ts index c0ab629c3..05ba352b8 100644 --- a/test/integration/short/cloud/cloud-tests.js +++ b/test/integration/short/cloud/cloud-tests.ts @@ -13,20 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const { assert } = require('chai'); -const sinon = require('sinon'); -const proxyquire = require('proxyquire'); - -const cloudHelper = require('./cloud-helper'); -const helper = require('../../../test-helper'); -const policies = require('../../../../lib/policies'); -const errors = require('../../../../lib/errors'); -const auth = require('../../../../lib/auth'); -const utils = require('../../../../lib/utils'); -const types = require('../../../../lib/types'); -const promiseUtils = require('../../../../lib/promise-utils'); +import { assert } from "chai"; +import sinon from "sinon"; +import proxyquire from "proxyquire"; +import cloudHelper from "./cloud-helper"; +import helper from "../../../test-helper"; +import policies from "../../../../lib/policies/index"; +import errors from "../../../../lib/errors"; +import auth from "../../../../lib/auth/index"; +import utils from "../../../../lib/utils"; +import types from "../../../../lib/types/index"; +import promiseUtils from "../../../../lib/promise-utils"; + + const vdescribe = helper.vdescribe; const port = 9042; diff --git a/test/integration/short/concurrent/execute-concurrent-tests.js b/test/integration/short/concurrent/execute-concurrent-tests.ts similarity index 96% rename from test/integration/short/concurrent/execute-concurrent-tests.js rename to test/integration/short/concurrent/execute-concurrent-tests.ts index 312bf06fe..27aa2aea8 100644 --- a/test/integration/short/concurrent/execute-concurrent-tests.js +++ b/test/integration/short/concurrent/execute-concurrent-tests.ts @@ -14,16 +14,15 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const fs = require('fs'); -const types = require('../../../../lib/types'); -const errors = require('../../../../lib/errors'); -const helper = require('../../../test-helper'); -const Transform = require('stream').Transform; +import assert from "assert"; +import fs from "fs"; +import types from "../../../../lib/types/index"; +import errors from "../../../../lib/errors"; +import helper from "../../../test-helper"; +import { Transform } from "stream"; +import {executeConcurrent} from "../../../../lib/concurrent"; + const Uuid = types.Uuid; -const executeConcurrent = require('../../../../lib/concurrent').executeConcurrent; const insertQuery1 = 'INSERT INTO table1 (key1, key2, value) VALUES (?, ?, ?)'; const insertQuery2 = 'INSERT INTO table2 (id, value) VALUES (?, ?)'; diff --git a/test/integration/short/connection-tests.js b/test/integration/short/connection-tests.ts similarity index 95% rename from test/integration/short/connection-tests.js rename to test/integration/short/connection-tests.ts index 28d304a5d..f2de4edf8 100644 --- a/test/integration/short/connection-tests.js +++ b/test/integration/short/connection-tests.ts @@ -13,19 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import sinon from "sinon"; +import Connection from "../../../lib/connection"; +import utils from "../../../lib/utils"; +import requests from "../../../lib/requests"; +import helper from "../../test-helper"; +import errors from "../../../lib/errors"; +import types from "../../../lib/types/index"; +import { assert } from "chai"; +import { defaultOptions } from "../../../lib/client-options"; +import { protocolVersion } from "../../../lib/types"; + -"use strict"; -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 protocolVersion = require('../../../lib/types').protocolVersion; -const helper = require('../../test-helper.js'); -const errors = require('../../../lib/errors'); -const types = require('../../../lib/types'); const vit = helper.vit; describe('Connection', function () { diff --git a/test/integration/short/control-connection-simulator-tests.js b/test/integration/short/control-connection-simulator-tests.ts similarity index 96% rename from test/integration/short/control-connection-simulator-tests.js rename to test/integration/short/control-connection-simulator-tests.ts index a5f8db99c..6a04f7c16 100644 --- a/test/integration/short/control-connection-simulator-tests.js +++ b/test/integration/short/control-connection-simulator-tests.ts @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import net from "net"; +import simulacron from "../simulacron"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import Client from "../../../lib/client"; -const assert = require('assert'); -const net = require('net'); -const simulacron = require('../simulacron'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); - -const Client = require('../../../lib/client.js'); 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 94% rename from test/integration/short/control-connection-tests.js rename to test/integration/short/control-connection-tests.ts index b48102160..b946e68c4 100644 --- a/test/integration/short/control-connection-tests.js +++ b/test/integration/short/control-connection-tests.ts @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); - -const helper = require('../../test-helper'); -const Client = require('../../../lib/client.js'); -const ControlConnection = require('../../../lib/control-connection'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); -const clientOptions = require('../../../lib/client-options'); -const policies = require('../../../lib/policies'); -const ProfileManager = require('../../../lib/execution-profile').ProfileManager; + +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import ControlConnection from "../../../lib/control-connection"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import clientOptions from "../../../lib/client-options"; +import policies from "../../../lib/policies/index"; +import {ProfileManager} from "../../../lib/execution-profile"; describe('ControlConnection', function () { this.timeout(240000); diff --git a/test/integration/short/custom-payload-tests.js b/test/integration/short/custom-payload-tests.ts similarity index 97% rename from test/integration/short/custom-payload-tests.js rename to test/integration/short/custom-payload-tests.ts index 1fcfff276..ddff2c4a0 100644 --- a/test/integration/short/custom-payload-tests.js +++ b/test/integration/short/custom-payload-tests.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; + -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); const vit = helper.vit; describe('custom payload @SERVER_API', function () { diff --git a/test/integration/short/duration-type-tests.js b/test/integration/short/duration-type-tests.ts similarity index 94% rename from test/integration/short/duration-type-tests.js rename to test/integration/short/duration-type-tests.ts index 8bffa89ce..cfe53e411 100644 --- a/test/integration/short/duration-type-tests.js +++ b/test/integration/short/duration-type-tests.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); -const helper = require('../../test-helper'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; + const vdescribe = helper.vdescribe; const Duration = types.Duration; diff --git a/test/integration/short/error-simulator-tests.js b/test/integration/short/error-simulator-tests.ts similarity index 97% rename from test/integration/short/error-simulator-tests.js rename to test/integration/short/error-simulator-tests.ts index 83536bb30..068235248 100644 --- a/test/integration/short/error-simulator-tests.js +++ b/test/integration/short/error-simulator-tests.ts @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const errors = require('../../../lib/errors'); -const types = require('../../../lib/types'); -const simulacron = require('../simulacron'); -const helper = require('../../test-helper'); -const utils = require('../../../lib/utils'); +import assert from "assert"; +import errors from "../../../lib/errors"; +import types from "../../../lib/types/index"; +import simulacron from "../simulacron"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import Client from "../../../lib/client"; +import { OrderedLoadBalancingPolicy } from "../../test-helper"; -const Client = require('../../../lib/client'); -const { OrderedLoadBalancingPolicy } = require('../../test-helper'); const query = "select * from data"; diff --git a/test/integration/short/error-tests.js b/test/integration/short/error-tests.ts similarity index 94% rename from test/integration/short/error-tests.js rename to test/integration/short/error-tests.ts index 1e9a92422..8df4c2eaa 100644 --- a/test/integration/short/error-tests.js +++ b/test/integration/short/error-tests.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import errors from "../../../lib/errors"; + -const helper = require('../../test-helper'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); -const errors = require('../../../lib/errors'); const protocolVersion = types.protocolVersion; const vdescribe = helper.vdescribe; const vit = helper.vit; diff --git a/test/integration/short/execution-profile-tests.js b/test/integration/short/execution-profile-tests.ts similarity index 93% rename from test/integration/short/execution-profile-tests.js rename to test/integration/short/execution-profile-tests.ts index 154941d85..13d8580af 100644 --- a/test/integration/short/execution-profile-tests.js +++ b/test/integration/short/execution-profile-tests.ts @@ -13,18 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import simulacron from "../simulacron"; +import { AllowListPolicy, DCAwareRoundRobinPolicy } from "../../../lib/policies/load-balancing"; +import { ExecutionProfile } from "../../../lib/execution-profile"; -'use strict'; - -const assert = require('assert'); - -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); -const simulacron = require('../simulacron'); -const { AllowListPolicy, DCAwareRoundRobinPolicy } = require('../../../lib/policies/load-balancing'); -const { ExecutionProfile } = require('../../../lib/execution-profile'); describe('ProfileManager', function() { this.timeout(40000); diff --git a/test/integration/short/geometry/line-string-tests.js b/test/integration/short/geometry/line-string-tests.ts similarity index 97% rename from test/integration/short/geometry/line-string-tests.js rename to test/integration/short/geometry/line-string-tests.ts index 7effd3ccf..1e00ae09b 100644 --- a/test/integration/short/geometry/line-string-tests.js +++ b/test/integration/short/geometry/line-string-tests.ts @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); -const helper = require('../../../test-helper'); -const Client = require('../../../../lib/client'); +import assert from "assert"; +import util from "util"; +import helper from "../../../test-helper"; +import Client from "../../../../lib/client"; +import geometry from "../../../../lib/geometry/index"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; + + const vdescribe = helper.vdescribe; -const geometry = require('../../../../lib/geometry'); -const types = require('../../../../lib/types'); -const utils = require('../../../../lib/utils'); const Point = geometry.Point; const LineString = geometry.LineString; const Uuid = types.Uuid; diff --git a/test/integration/short/geometry/point-tests.js b/test/integration/short/geometry/point-tests.ts similarity index 97% rename from test/integration/short/geometry/point-tests.js rename to test/integration/short/geometry/point-tests.ts index 3a95c59f9..54e7eb52a 100644 --- a/test/integration/short/geometry/point-tests.js +++ b/test/integration/short/geometry/point-tests.ts @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); -const helper = require('../../../test-helper'); -const Client = require('../../../../lib/client'); +import assert from "assert"; +import util from "util"; +import helper from "../../../test-helper"; +import Client from "../../../../lib/client"; +import geometry from "../../../../lib/geometry/index"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; + + const vdescribe = helper.vdescribe; -const geometry = require('../../../../lib/geometry'); -const types = require('../../../../lib/types'); -const utils = require('../../../../lib/utils'); const Point = geometry.Point; const Uuid = types.Uuid; const Tuple = types.Tuple; diff --git a/test/integration/short/geometry/polygon-tests.js b/test/integration/short/geometry/polygon-tests.ts similarity index 97% rename from test/integration/short/geometry/polygon-tests.js rename to test/integration/short/geometry/polygon-tests.ts index 41715487e..9b3b5c533 100644 --- a/test/integration/short/geometry/polygon-tests.js +++ b/test/integration/short/geometry/polygon-tests.ts @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); -const helper = require('../../../test-helper'); -const Client = require('../../../../lib/client'); +import assert from "assert"; +import util from "util"; +import helper from "../../../test-helper"; +import Client from "../../../../lib/client"; +import geometry from "../../../../lib/geometry/index"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; + + const vdescribe = helper.vdescribe; -const geometry = require('../../../../lib/geometry'); -const types = require('../../../../lib/types'); -const utils = require('../../../../lib/utils'); const Point = geometry.Point; const Polygon = geometry.Polygon; const Uuid = types.Uuid; diff --git a/test/integration/short/graph/graph-olap-tests.js b/test/integration/short/graph/graph-olap-tests.ts similarity index 94% rename from test/integration/short/graph/graph-olap-tests.js rename to test/integration/short/graph/graph-olap-tests.ts index 41789bf1b..8bbe30060 100644 --- a/test/integration/short/graph/graph-olap-tests.js +++ b/test/integration/short/graph/graph-olap-tests.ts @@ -14,21 +14,19 @@ * limitations under the License. */ -'use strict'; +import { assert } from "chai"; +import util from "util"; +import Client from "../../../../lib/client"; +import promiseUtils from "../../../../lib/promise-utils"; +import helper from "../../../test-helper"; +import loadBalancing from "../../../../lib/policies/load-balancing"; +import utils from "../../../../lib/utils"; +import graphModule from "../../../../lib/datastax/graph/index"; +import graphTestHelper from "./graph-test-helper"; +import { ExecutionProfile } from "../../../../lib/execution-profile"; -const { assert } = require('chai'); -const util = require('util'); -const Client = require('../../../../lib/client'); -const promiseUtils = require('../../../../lib/promise-utils'); -const helper = require('../../../test-helper'); const vdescribe = helper.vdescribe; -const loadBalancing = require('../../../../lib/policies/load-balancing'); const DefaultLoadBalancingPolicy = loadBalancing.DefaultLoadBalancingPolicy; -const ExecutionProfile = require('../../../../lib/execution-profile').ExecutionProfile; -const utils = require('../../../../lib/utils'); -const graphModule = require('../../../../lib/datastax/graph'); -const graphTestHelper = require('./graph-test-helper'); - vdescribe('dse-5.0', 'Client with spark workload', function () { this.timeout(360000); diff --git a/test/integration/short/graph/graph-test-helper.js b/test/integration/short/graph/graph-test-helper.ts similarity index 72% rename from test/integration/short/graph/graph-test-helper.js rename to test/integration/short/graph/graph-test-helper.ts index 3e2264e55..a03ea17d6 100644 --- a/test/integration/short/graph/graph-test-helper.js +++ b/test/integration/short/graph/graph-test-helper.ts @@ -13,41 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use strict'; - -const utils = require('../../../../lib/utils'); - -module.exports = { - - /** - * Creates the modern schema and graph - * @param {Client} client - * @param {Function} callback - */ - createModernGraph: function (client, callback) { - utils.series([ - next => client.executeGraph(modernSchema, null, {graphName: "name1"}, next), - next => client.executeGraph(modernGraph, null, {graphName: "name1"}, next) - ], callback); - }, - - /** - * Sets the schema mode to "production". - * @param {Client} client - */ - makeStrict: function (client) { - return client.executeGraph(makeStrictQuery, null, { graphName: 'name1'}); - }, - - /** - * Sets the allow_scan flag. - * @param {Client} client - */ - allowScans: function (client) { - return client.executeGraph(allowScansQuery, null, { graphName: 'name1'}); - } -}; +import utils from "../../../../lib/utils"; const makeStrictQuery = 'schema.config().option("graph.schema_mode").set("production")'; @@ -78,4 +44,39 @@ const modernGraph = 'marko.addEdge("created", lop, "weight", 0.4f);\n' + 'josh.addEdge("created", ripple, "weight", 1.0f);\n' + 'josh.addEdge("created", lop, "weight", 0.4f);\n' + - 'peter.addEdge("created", lop, "weight", 0.2f);'; \ No newline at end of file + 'peter.addEdge("created", lop, "weight", 0.2f);'; + + +/** + * Creates the modern schema and graph + * @param {Client} client + * @param {Function} callback + */ +const createModernGraph = function (client, callback) { + utils.series([ + next => client.executeGraph(modernSchema, null, { graphName: "name1" }, next), + next => client.executeGraph(modernGraph, null, { graphName: "name1" }, next) + ], callback); +}; + +/** + * Sets the schema mode to "production". + * @param {Client} client + */ +const makeStrict = function (client) { + return client.executeGraph(makeStrictQuery, null, { graphName: 'name1' }); +}; + +/** + * Sets the allow_scan flag. + * @param {Client} client + */ +const allowScans = function (client) { + return client.executeGraph(allowScansQuery, null, { graphName: 'name1' }); +}; + +export default { + createModernGraph, + makeStrict, + allowScans +} \ No newline at end of file diff --git a/test/integration/short/graph/graph-tests.js b/test/integration/short/graph/graph-tests.ts similarity index 98% rename from test/integration/short/graph/graph-tests.js rename to test/integration/short/graph/graph-tests.ts index 81e641e71..676eab204 100644 --- a/test/integration/short/graph/graph-tests.js +++ b/test/integration/short/graph/graph-tests.ts @@ -13,25 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const sinon = require('sinon'); -const { assert } = require('chai'); -const util = require('util'); -const Client = require('../../../../lib/client'); -const helper = require('../../../test-helper'); +import sinon from "sinon"; +import { assert } from "chai"; +import util from "util"; +import Client from "../../../../lib/client"; +import helper from "../../../test-helper"; +import { Point, LineString, Polygon } from "../../../../lib/geometry/index"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; +import graphModule from "../../../../lib/datastax/graph/index"; +import { graphProtocol } from "../../../../lib/datastax/graph/options"; +import graphTestHelper from "./graph-test-helper"; +import { ExecutionProfile } from "../../../../lib/execution-profile"; const vdescribe = helper.vdescribe; const vit = helper.vit; -const { Point, LineString, Polygon } = require('../../../../lib/geometry'); -const types = require('../../../../lib/types'); const { InetAddress, Uuid, Tuple } = types; -const ExecutionProfile = require('../../../../lib/execution-profile').ExecutionProfile; -const utils = require('../../../../lib/utils'); -const graphModule = require('../../../../lib/datastax/graph'); const { asInt, asFloat, asUdt, t, Edge, direction } = graphModule; -const { graphProtocol } = require('../../../../lib/datastax/graph/options'); -const graphTestHelper = require('./graph-test-helper'); - const graphLanguageBytecode = 'bytecode-json'; let schemaCounter = 1000; diff --git a/test/integration/short/graph/graph-timeout-tests.js b/test/integration/short/graph/graph-timeout-tests.ts similarity index 95% rename from test/integration/short/graph/graph-timeout-tests.js rename to test/integration/short/graph/graph-timeout-tests.ts index 09b5c863b..4312a4e09 100644 --- a/test/integration/short/graph/graph-timeout-tests.js +++ b/test/integration/short/graph/graph-timeout-tests.ts @@ -14,16 +14,16 @@ * limitations under the License. */ -'use strict'; +import assert from "assert"; +import errors from "../../../../lib/errors"; +import helper from "../../../test-helper"; +import utils from "../../../../lib/utils"; +import Client from "../../../../lib/client"; +import {ExecutionProfile} from "../../../../lib/execution-profile"; +import {DefaultRetryPolicy} from "../../../../lib/policies/retry"; + -const assert = require('assert'); -const errors = require('../../../../lib/errors'); -const helper = require('../../../test-helper'); const vdescribe = helper.vdescribe; -const utils = require('../../../../lib/utils'); -const Client = require('../../../../lib/client'); -const ExecutionProfile = require('../../../../lib/execution-profile').ExecutionProfile; -const DefaultRetryPolicy = require('../../../../lib/policies/retry').RetryPolicy; vdescribe('dse-5.0', 'graph query client timeouts', function () { this.timeout(120000); 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 93% rename from test/integration/short/graph/graph-with-down-node-tests.js rename to test/integration/short/graph/graph-with-down-node-tests.ts index 7b1308536..9a9e4ddf4 100644 --- a/test/integration/short/graph/graph-with-down-node-tests.js +++ b/test/integration/short/graph/graph-with-down-node-tests.ts @@ -14,18 +14,16 @@ * limitations under the License. */ -'use strict'; +import assert from "assert"; +import Client from "../../../../lib/client"; +import helper from "../../../test-helper"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; +import graphTestHelper from "./graph-test-helper"; +import {ExecutionProfile} from "../../../../lib/execution-profile"; -const assert = require('assert'); -const Client = require('../../../../lib/client'); -const helper = require('../../../test-helper'); const vdescribe = helper.vdescribe; -const types = require('../../../../lib/types'); const cl = types.consistencies; -const ExecutionProfile = require('../../../../lib/execution-profile').ExecutionProfile; -const utils = require('../../../../lib/utils'); -const graphTestHelper = require('./graph-test-helper'); - // DSP-15333 prevents this suite to be tested against DSE 5.0 vdescribe('dse-5.1', 'Client with down node', function () { this.timeout(270000); diff --git a/test/integration/short/insights-simulator-tests.js b/test/integration/short/insights-simulator-tests.ts similarity index 93% rename from test/integration/short/insights-simulator-tests.js rename to test/integration/short/insights-simulator-tests.ts index e2f364d8d..4f233adfb 100644 --- a/test/integration/short/insights-simulator-tests.js +++ b/test/integration/short/insights-simulator-tests.ts @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import simulacron from "../simulacron"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import InsightsClient from "../../../lib/insights-client"; -'use strict'; -const assert = require('assert'); -const simulacron = require('../simulacron'); -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const utils = require('../../../lib/utils'); const vdescribe = helper.vdescribe; -const InsightsClient = require('../../../lib/insights-client'); - const insightsRpcQuery = 'CALL InsightsRpc.reportInsight(?)'; vdescribe('dse-6.7', 'InsightsClient', function () { diff --git a/test/integration/short/load-balancing-simulator-tests.js b/test/integration/short/load-balancing-simulator-tests.ts similarity index 96% rename from test/integration/short/load-balancing-simulator-tests.js rename to test/integration/short/load-balancing-simulator-tests.ts index cbcfe7d28..40a78d6bf 100644 --- a/test/integration/short/load-balancing-simulator-tests.js +++ b/test/integration/short/load-balancing-simulator-tests.ts @@ -13,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const util = require('util'); -const simulacron = require('../simulacron'); -const utils = require('../../../lib/utils'); -const helper = require('../../test-helper'); -const policies = require('../../../lib/policies'); -const errors = require('../../../lib/errors'); -const promiseUtils = require('../../../lib/promise-utils'); -const { ExecutionProfile } = require('../../../lib/execution-profile'); -const Client = require('../../../lib/client'); +import assert from "assert"; +import util from "util"; +import simulacron from "../simulacron"; +import utils from "../../../lib/utils"; +import helper from "../../test-helper"; +import policies from "../../../lib/policies/index"; +import errors from "../../../lib/errors"; +import promiseUtils from "../../../lib/promise-utils"; +import { ExecutionProfile } from "../../../lib/execution-profile"; +import Client from "../../../lib/client"; + + const { loadBalancing } = policies; const queryOptions = { prepare: true, routingKey: utils.allocBuffer(16), keyspace: 16 }; diff --git a/test/integration/short/load-balancing-tests.js b/test/integration/short/load-balancing-tests.ts similarity index 97% rename from test/integration/short/load-balancing-tests.js rename to test/integration/short/load-balancing-tests.ts index d1d111936..b08694ad1 100644 --- a/test/integration/short/load-balancing-tests.js +++ b/test/integration/short/load-balancing-tests.ts @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import { RoundRobinPolicy, AllowListPolicy, TokenAwarePolicy} from "../../../lib/policies/load-balancing"; + -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); -const { RoundRobinPolicy, AllowListPolicy, TokenAwarePolicy} = require('../../../lib/policies/load-balancing'); const vdescribe = helper.vdescribe; const maxInFlightRequests = 16; diff --git a/test/integration/short/mapping/custom-queries-tests.js b/test/integration/short/mapping/custom-queries-tests.ts similarity index 90% rename from test/integration/short/mapping/custom-queries-tests.js rename to test/integration/short/mapping/custom-queries-tests.ts index 4847f9d02..7ae3b2e67 100644 --- a/test/integration/short/mapping/custom-queries-tests.js +++ b/test/integration/short/mapping/custom-queries-tests.ts @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import types from "../../../../lib/types/index"; +import Result from "../../../../lib/mapping/result"; +import mapperTestHelper from "./mapper-test-helper"; +import helper from "../../../test-helper"; -'use strict'; -const assert = require('assert'); -const types = require('../../../../lib/types'); -const Result = require('../../../../lib/mapping/result'); const Uuid = types.Uuid; -const mapperTestHelper = require('./mapper-test-helper'); const assertRowMatchesDoc = mapperTestHelper.assertRowMatchesDoc; -const helper = require('../../../test-helper'); - describe('ModelMapper', function () { mapperTestHelper.setupOnce(this); 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 93% 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 index 354575812..93afd82ad 100644 --- a/test/integration/short/mapping/from-and-to-model-function-tests.js +++ b/test/integration/short/mapping/from-and-to-model-function-tests.ts @@ -13,15 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import { Uuid } from "../../../../lib/types/index"; +import mapperTestHelper from "./mapper-test-helper"; +import helper from "../../../test-helper"; +import { UnderscoreCqlToCamelCaseMappings } from "../../../../lib/mapping/table-mappings"; -'use strict'; - -const { assert } = require('chai'); - -const { Uuid } = require('../../../../lib/types'); -const mapperTestHelper = require('./mapper-test-helper'); -const helper = require('../../../test-helper'); -const { UnderscoreCqlToCamelCaseMappings } = require('../../../../lib/mapping/table-mappings'); describe('Mapper', function () { mapperTestHelper.setupOnce(this); diff --git a/test/integration/short/mapping/mapper-test-helper.js b/test/integration/short/mapping/mapper-test-helper.ts similarity index 94% rename from test/integration/short/mapping/mapper-test-helper.js rename to test/integration/short/mapping/mapper-test-helper.ts index cccf0b9d2..67f1ce30d 100644 --- a/test/integration/short/mapping/mapper-test-helper.js +++ b/test/integration/short/mapping/mapper-test-helper.ts @@ -13,25 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import types from "../../../../lib/types/index"; +import helper from "../../../test-helper"; +import tableMappingsModule from "../../../../lib/mapping/table-mappings"; +import Mapper from "../../../../lib/mapping/mapper"; +import Client from "../../../../lib/client"; +import utils from "../../../../lib/utils"; -'use strict'; -const assert = require('assert'); -const types = require('../../../../lib/types'); const Uuid = types.Uuid; -const helper = require('../../../test-helper'); -const tableMappingsModule = require('../../../../lib/mapping/table-mappings'); const UnderscoreCqlToCamelCaseMappings = tableMappingsModule.UnderscoreCqlToCamelCaseMappings; -const Mapper = require('../../../../lib/mapping/mapper'); -const Client = require('../../../../lib/client'); -const utils = require('../../../../lib/utils'); - const videoColumnsToProperties = new Map([ ['videoid', 'id'], ['userid', 'userId'], ['added_date', 'addedDate'], ['location_type', 'locationType'], ['preview_image_location', 'preview'], ['preview_thumbnails', 'thumbnails']]); let hasBeenSetup = false; -const mapperHelper = module.exports = { +const mapperHelper = { setupOnce: function (testInstance) { testInstance.timeout(60000); @@ -191,3 +189,6 @@ const mapperHelper = module.exports = { }); } }; + + +export default mapperHelper; \ No newline at end of file diff --git a/test/integration/short/mapping/mapper-tests.js b/test/integration/short/mapping/mapper-tests.ts similarity index 94% rename from test/integration/short/mapping/mapper-tests.js rename to test/integration/short/mapping/mapper-tests.ts index dda7d8e50..ba937413c 100644 --- a/test/integration/short/mapping/mapper-tests.js +++ b/test/integration/short/mapping/mapper-tests.ts @@ -14,19 +14,18 @@ * limitations under the License. */ -'use strict'; +import assert from "assert"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; +import Mapper from "../../../../lib/mapping/mapper"; +import Client from "../../../../lib/client"; +import mapperTestHelper from "./mapper-test-helper"; +import helper from "../../../test-helper"; +import Result from "../../../../lib/mapping/result"; +import { q } from "../../../../lib/mapping/q"; -const assert = require('assert'); -const types = require('../../../../lib/types'); -const utils = require('../../../../lib/utils'); -const Mapper = require('../../../../lib/mapping/mapper'); -const Client = require('../../../../lib/client'); const Uuid = types.Uuid; -const mapperTestHelper = require('./mapper-test-helper'); const assertRowMatchesDoc = mapperTestHelper.assertRowMatchesDoc; -const helper = require('../../../test-helper'); -const Result = require('../../../../lib/mapping/result'); -const q = require('../../../../lib/mapping/q').q; describe('Mapper', function () { diff --git a/test/integration/short/mapping/model-mapper-tests.js b/test/integration/short/mapping/model-mapper-tests.ts similarity index 98% rename from test/integration/short/mapping/model-mapper-tests.js rename to test/integration/short/mapping/model-mapper-tests.ts index 7892ad47a..a8f68aab9 100644 --- a/test/integration/short/mapping/model-mapper-tests.js +++ b/test/integration/short/mapping/model-mapper-tests.ts @@ -14,19 +14,18 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const util = require('util'); -const helper = require('../../../test-helper'); -const mapperTestHelper = require('./mapper-test-helper'); -const types = require('../../../../lib/types'); -const utils = require('../../../../lib/utils'); +import assert from "assert"; +import util from "util"; +import helper from "../../../test-helper"; +import mapperTestHelper from "./mapper-test-helper"; +import types from "../../../../lib/types/index"; +import utils from "../../../../lib/utils"; +import Mapper from "../../../../lib/mapping/mapper"; +import Result from "../../../../lib/mapping/result"; +import {q} from "../../../../lib/mapping/q"; + const Uuid = types.Uuid; -const q = require('../../../../lib/mapping/q').q; -const Mapper = require('../../../../lib/mapping/mapper'); const assertRowMatchesDoc = mapperTestHelper.assertRowMatchesDoc; -const Result = require('../../../../lib/mapping/result'); const vit = helper.vit; describe('ModelMapper', function () { diff --git a/test/integration/short/metadata-simulator-tests.js b/test/integration/short/metadata-simulator-tests.ts similarity index 95% rename from test/integration/short/metadata-simulator-tests.js rename to test/integration/short/metadata-simulator-tests.ts index acce50779..4e888982c 100644 --- a/test/integration/short/metadata-simulator-tests.js +++ b/test/integration/short/metadata-simulator-tests.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('chai').assert; -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types/index'); -const simulacron = require('../simulacron'); -const util = require('util'); + +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import simulacron from "../simulacron"; +import util from "util"; +import {assert} from "chai"; describe('Metadata', function () { this.timeout(20000); diff --git a/test/integration/short/metadata-tests.js b/test/integration/short/metadata-tests.ts similarity index 99% rename from test/integration/short/metadata-tests.js rename to test/integration/short/metadata-tests.ts index 9941e1a3b..f00e9c3d8 100644 --- a/test/integration/short/metadata-tests.js +++ b/test/integration/short/metadata-tests.ts @@ -14,14 +14,13 @@ * limitations under the License. */ -"use strict"; -const assert = require('chai').assert; - -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); -const packageInfo = require('../../../package.json'); +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import packageInfo from "../../../package.json"; +import { assert } from "chai"; + const vit = helper.vit; const vdescribe = helper.vdescribe; diff --git a/test/integration/short/numeric-tests.js b/test/integration/short/numeric-tests.ts similarity index 96% rename from test/integration/short/numeric-tests.js rename to test/integration/short/numeric-tests.ts index 0b5c6a329..31875b9aa 100644 --- a/test/integration/short/numeric-tests.js +++ b/test/integration/short/numeric-tests.ts @@ -14,12 +14,11 @@ * limitations under the License. */ -'use strict'; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import helper from "../../test-helper"; +import { expect } from 'chai'; -const expect = require('chai').expect; -const Client = require('../../../lib/client'); -const types = require('../../../lib/types'); -const helper = require('../../test-helper'); const Uuid = types.Uuid; const createTableNumericValuesCql = @@ -44,7 +43,10 @@ const createTableNumericCollectionsCql = set_int set)`; // Exported to be called on other fixtures to take advantage from existing setups -module.exports = function (keyspace, prepare) { + + +// Exported to be called on other fixtures to take advantage from existing setups +export default function (keyspace, prepare) { context('with numeric values', () => { diff --git a/test/integration/short/paging-tests.js b/test/integration/short/paging-tests.ts similarity index 93% rename from test/integration/short/paging-tests.js rename to test/integration/short/paging-tests.ts index 3d4fd8b93..8af3a56a7 100644 --- a/test/integration/short/paging-tests.js +++ b/test/integration/short/paging-tests.ts @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import helper from "../../test-helper"; +import promiseUtils from "../../../lib/promise-utils"; -'use strict'; -const { assert } = require('chai'); -const Client = require('../../../lib/client'); -const types = require('../../../lib/types'); -const helper = require('../../test-helper'); -const promiseUtils = require('../../../lib/promise-utils'); +// Exported to be called on other fixtures to take advantage from existing setups // Exported to be called on other fixtures to take advantage from existing setups -module.exports = function (keyspace, prepare) { +export default function (keyspace, prepare) { context('with paging', function () { const client = new Client({ diff --git a/test/integration/short/pool-simulator-tests.js b/test/integration/short/pool-simulator-tests.ts similarity index 98% rename from test/integration/short/pool-simulator-tests.js rename to test/integration/short/pool-simulator-tests.ts index 0b7aa8726..59f9161fd 100644 --- a/test/integration/short/pool-simulator-tests.js +++ b/test/integration/short/pool-simulator-tests.ts @@ -13,22 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import simulacron from "../simulacron"; +import helper from "../../test-helper"; +import errors from "../../../lib/errors"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import policies from "../../../lib/policies/index"; +import promiseUtils from "../../../lib/promise-utils"; +import { version } from "../../../index"; +import Client from "../../../lib/client"; -'use strict'; - -const { assert } = require('chai'); -const simulacron = require('../simulacron'); -const helper = require('../../test-helper'); -const errors = require('../../../lib/errors'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); -const policies = require('../../../lib/policies'); -const promiseUtils = require('../../../lib/promise-utils'); -const { version } = require('../../../index'); -const { distance } = types; - -const Client = require('../../../lib/client'); +const { distance } = types; const healthResponseCountInterval = 200; describe('pool', function () { diff --git a/test/integration/short/prepare-simulator-tests.js b/test/integration/short/prepare-simulator-tests.ts similarity index 94% rename from test/integration/short/prepare-simulator-tests.js rename to test/integration/short/prepare-simulator-tests.ts index d697df7f6..9287b24b0 100644 --- a/test/integration/short/prepare-simulator-tests.js +++ b/test/integration/short/prepare-simulator-tests.ts @@ -13,16 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import { assert } from "chai"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import helper from "../../test-helper"; +import reconnection from "../../../lib/policies/reconnection"; +import simulacron from "../simulacron"; -const { assert } = require('chai'); - -const Client = require('../../../lib/client'); -const types = require('../../../lib/types/index'); -const utils = require('../../../lib/utils'); -const helper = require('../../test-helper'); -const reconnection = require('../../../lib/policies/reconnection'); -const simulacron = require('../simulacron'); describe('Client', function () { this.timeout(20000); diff --git a/test/integration/short/retry-simulator-tests.js b/test/integration/short/retry-simulator-tests.ts similarity index 97% rename from test/integration/short/retry-simulator-tests.js rename to test/integration/short/retry-simulator-tests.ts index 6aca93f43..9d7990c62 100644 --- a/test/integration/short/retry-simulator-tests.js +++ b/test/integration/short/retry-simulator-tests.ts @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import Client from "../../../lib/client"; +import metrics from "../../../lib/metrics/index"; +import errors from "../../../lib/errors"; +import simulacron from "../simulacron"; +import helper from "../../test-helper"; +import policies from "../../../lib/policies/index"; -'use strict'; -const assert = require('assert'); -const Client = require('../../../lib/client'); -const metrics = require('../../../lib/metrics'); -const errors = require('../../../lib/errors'); -const simulacron = require('../simulacron'); -const helper = require('../../test-helper'); -const policies = require('../../../lib/policies'); const RetryPolicy = policies.retry.RetryPolicy; const queries = { diff --git a/test/integration/short/search/date-range-tests.js b/test/integration/short/search/date-range-tests.ts similarity index 96% rename from test/integration/short/search/date-range-tests.js rename to test/integration/short/search/date-range-tests.ts index 5326a3931..6dafd412a 100644 --- a/test/integration/short/search/date-range-tests.js +++ b/test/integration/short/search/date-range-tests.ts @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); -const helper = require('../../../test-helper'); +import assert from "assert"; +import util from "util"; +import helper from "../../../test-helper"; +import utils from "../../../../lib/utils"; +import types from "../../../../lib/types/index"; +import * as dateRangeModule from "../../../../lib/datastax/search/date-range"; +import Client from "../../../../lib/client"; + + const vdescribe = helper.vdescribe; -const utils = require('../../../../lib/utils'); -const types = require('../../../../lib/types'); -const dateRangeModule = require('../../../../lib/datastax/search/date-range'); -const Client = require('../../../../lib/client'); const DateRange = dateRangeModule.DateRange; vdescribe('dse-5.1', 'DateRange', function () { diff --git a/test/integration/short/speculative-execution-simulator-tests.js b/test/integration/short/speculative-execution-simulator-tests.ts similarity index 95% rename from test/integration/short/speculative-execution-simulator-tests.js rename to test/integration/short/speculative-execution-simulator-tests.ts index b5984a3b4..f3063e901 100644 --- a/test/integration/short/speculative-execution-simulator-tests.js +++ b/test/integration/short/speculative-execution-simulator-tests.ts @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const responseErrorCodes = require('../../../lib/types').responseErrorCodes; -const simulacron = require('../simulacron'); -const helper = require('../../test-helper'); -const utils = require('../../../lib/utils'); - -const Client = require('../../../lib/client.js'); -const ConstantSpeculativeExecutionPolicy = require('../../../lib/policies/speculative-execution').ConstantSpeculativeExecutionPolicy; -const NoSpeculativeExecutionPolicy = require('../../../lib/policies/speculative-execution').NoSpeculativeExecutionPolicy; -const OrderedLoadBalancingPolicy = require('../../test-helper').OrderedLoadBalancingPolicy; + +import assert from "assert"; +import simulacron from "../simulacron"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import Client from "../../../lib/client"; +import { responseErrorCodes } from "../../../lib/types"; +import { ConstantSpeculativeExecutionPolicy, NoSpeculativeExecutionPolicy } from "../../../lib/policies/speculative-execution"; +import { OrderedLoadBalancingPolicy } from "../../test-helper"; const query = "select * from data"; const delay = 100; diff --git a/test/integration/short/ssl-tests.js b/test/integration/short/ssl-tests.ts similarity index 89% rename from test/integration/short/ssl-tests.js rename to test/integration/short/ssl-tests.ts index acdd21591..9491aa0a0 100644 --- a/test/integration/short/ssl-tests.js +++ b/test/integration/short/ssl-tests.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import errors from "../../../lib/errors"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; -const helper = require('../../test-helper'); -const Client = require('../../../lib/client'); -const errors = require('../../../lib/errors'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); describe('Client @SERVER_API', function () { this.timeout(60000); diff --git a/test/integration/short/timeout-simulator-tests.js b/test/integration/short/timeout-simulator-tests.ts similarity index 95% rename from test/integration/short/timeout-simulator-tests.js rename to test/integration/short/timeout-simulator-tests.ts index b7cb4bb2d..8aa1e155b 100644 --- a/test/integration/short/timeout-simulator-tests.js +++ b/test/integration/short/timeout-simulator-tests.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import Client from "../../../lib/client"; +import errors from "../../../lib/errors"; +import promiseUtils from "../../../lib/promise-utils"; +import helper from "../../test-helper"; +import simulacron from "../simulacron"; -'use strict'; -const { assert } = require('chai'); -const Client = require('../../../lib/client'); -const errors = require('../../../lib/errors'); -const promiseUtils = require('../../../lib/promise-utils'); -const helper = require('../../test-helper'); -const simulacron = require('../simulacron'); const { OrderedLoadBalancingPolicy } = helper; const queryDelayedOnNode0 = 'INSERT INTO paused_on_first_node'; diff --git a/test/integration/short/tracker-simulator-tests.js b/test/integration/short/tracker-simulator-tests.ts similarity index 95% rename from test/integration/short/tracker-simulator-tests.js rename to test/integration/short/tracker-simulator-tests.ts index 89ddd4d33..3b57d2f74 100644 --- a/test/integration/short/tracker-simulator-tests.js +++ b/test/integration/short/tracker-simulator-tests.ts @@ -14,18 +14,15 @@ * limitations under the License. */ -'use strict'; - -const { assert } = require('chai'); -const sinon = require('sinon'); - -const tracker = require('../../../lib/tracker'); -const errors = require('../../../lib/errors'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); -const Client = require('../../../lib/client'); -const Host = require('../../../lib/host').Host; -const simulacron = require('../simulacron'); +import { assert } from "chai"; +import sinon from "sinon"; +import tracker from "../../../lib/tracker/index"; +import errors from "../../../lib/errors"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; +import Client from "../../../lib/client"; +import simulacron from "../simulacron"; +import { Host } from "../../../lib/host"; const queryDelayed = 'INSERT INTO delayed (id) VALUES (?)'; diff --git a/test/integration/short/udf-tests.js b/test/integration/short/udf-tests.ts similarity index 99% rename from test/integration/short/udf-tests.js rename to test/integration/short/udf-tests.ts index 1da74fd1a..24207c896 100644 --- a/test/integration/short/udf-tests.js +++ b/test/integration/short/udf-tests.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); +import assert from "assert"; +import helper from "../../test-helper"; +import Client from "../../../lib/client"; +import utils from "../../../lib/utils"; +import types from "../../../lib/types/index"; + -const helper = require('../../test-helper'); const vit = helper.vit; -const Client = require('../../../lib/client'); -const utils = require('../../../lib/utils'); -const types = require('../../../lib/types'); const vdescribe = helper.vdescribe; vdescribe('2.2', 'Metadata @SERVER_API', function () { diff --git a/test/integration/short/vector-tests.js b/test/integration/short/vector-tests.ts similarity index 94% rename from test/integration/short/vector-tests.js rename to test/integration/short/vector-tests.ts index 77a3b522d..bcdb082ac 100644 --- a/test/integration/short/vector-tests.js +++ b/test/integration/short/vector-tests.ts @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../../test-helper.js'); +import assert from "assert"; +import helper from "../../test-helper"; +import { types } from "../../../index"; +import Vector from "../../../lib/types/vector"; +import util from "node:util"; + -const { types } = require('../../../index.js'); -const Vector = require('../../../lib/types/vector.js'); -const util = require('node:util'); const vdescribe = helper.vdescribe; vdescribe('5.0.0', 'Vector tests', function () { this.timeout(120000); diff --git a/test/integration/simulacron.js b/test/integration/simulacron.ts similarity index 98% rename from test/integration/simulacron.js rename to test/integration/simulacron.ts index 4f1449243..969cc6710 100644 --- a/test/integration/simulacron.js +++ b/test/integration/simulacron.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const helper = require('../test-helper'); -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'); +import helper from "../test-helper"; +import http from "http"; +import util from "util"; +import fs from "fs"; +import utils from "../../lib/utils"; +import Client from "../../lib/client"; +import { spawn } from "child_process"; + const simulacronHelper = { _execute: function(processName, params, cb) { @@ -573,4 +573,4 @@ SimulacronNode.prototype._filterLogs = function(data) { return data.data_centers[0].nodes[0].queries; }; -module.exports = simulacronHelper; +export default simulacronHelper; diff --git a/test/other/memory/basic-profile.js b/test/other/memory/basic-profile.ts similarity index 94% rename from test/other/memory/basic-profile.js rename to test/other/memory/basic-profile.ts index 75b452811..8e2ce967c 100644 --- a/test/other/memory/basic-profile.js +++ b/test/other/memory/basic-profile.ts @@ -13,9 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); + +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import cassandra from "../../../index"; +import utils from "../../../lib/utils"; + let heapdump; const heapdumpPath = '/var/log/nodejs-driver'; try { @@ -26,13 +30,8 @@ try { 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 Client = cassandra.Client; const types = cassandra.types; -const utils = require('../../../lib/utils'); - let client = new Client(utils.extend({ encoding: { copyBuffer: true}}, helper.baseOptions)); const keyspace = helper.getRandomName('ks'); const table = keyspace + '.' + helper.getRandomName('tbl'); diff --git a/test/other/memory/profile-keeping-ref.js b/test/other/memory/profile-keeping-ref.ts similarity index 94% rename from test/other/memory/profile-keeping-ref.js rename to test/other/memory/profile-keeping-ref.ts index 246be4d47..f59469aa9 100644 --- a/test/other/memory/profile-keeping-ref.js +++ b/test/other/memory/profile-keeping-ref.ts @@ -13,10 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import cassandra from "../../../index"; +import utils from "../../../lib/utils"; + + /* eslint-disable no-console, no-undef */ -const assert = require('assert'); -const util = require('util'); let heapdump; const heapdumpPath = '/var/log/nodejs-driver'; try { @@ -26,13 +30,8 @@ try { catch (e) { console.log(e); } - -const helper = require('../../test-helper.js'); -const cassandra = require('../../../index.js'); const Client = cassandra.Client; const types = cassandra.types; -const utils = require('../../../lib/utils'); - let client = new Client(utils.extend({ encoding: { copyBuffer: true}}, helper.baseOptions)); const keyspace = helper.getRandomName('ks'); const table = keyspace + '.' + helper.getRandomName('tbl'); diff --git a/test/test-helper.js b/test/test-helper.ts similarity index 98% rename from test/test-helper.js rename to test/test-helper.ts index 2a01576b4..9d2415dc8 100644 --- a/test/test-helper.js +++ b/test/test-helper.ts @@ -13,28 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use strict'; - -const { assert } = require('chai'); -const sinon = require('sinon'); -const util = require('util'); -const path = require('path'); -const policies = require('../lib/policies'); -const types = require('../lib/types'); -// const { types } = require('../lib/types'); -const utils = require('../lib/utils'); -const spawn = require('child_process').spawn; -const childProcessExec = require('child_process').exec; -const http = require('http'); -const temp = require('temp').track(true); -const Client = require('../lib/client'); -const defaultOptions = require('../lib/client-options').defaultOptions; -const { Host, HostMap } = require('../lib/host'); -const OperationState = require('../lib/operation-state'); -const promiseUtils = require('../lib/promise-utils'); +import { assert } from "chai"; +import sinon from "sinon"; +import util from "util"; +import path from "path"; +import policies from "../lib/policies/index"; +import types from "../lib/types/index"; +import utils from "../lib/utils"; +import http from "http"; +import Client from "../lib/client"; +import { Host, HostMap } from "../lib/host"; +import OperationState from "../lib/operation-state"; +import promiseUtils from "../lib/promise-utils"; +import { spawn, exec } from "child_process"; +import { defaultOptions } from "../lib/client-options"; +import Temp from "temp"; + + + +const temp = Temp.track(true); const Vector = types.Vector; + util.inherits(RetryMultipleTimes, policies.retry.RetryPolicy); const cassandraVersionByDse = { @@ -2040,8 +2040,7 @@ class OrderedLoadBalancingPolicy extends policies.loadBalancing.RoundRobinPolicy } } +export default helper; - -module.exports = helper; -module.exports.RetryMultipleTimes = RetryMultipleTimes; -module.exports.OrderedLoadBalancingPolicy = OrderedLoadBalancingPolicy; +export { RetryMultipleTimes }; +export { OrderedLoadBalancingPolicy }; diff --git a/test/unit/address-resolution-tests.js b/test/unit/address-resolution-tests.ts similarity index 90% rename from test/unit/address-resolution-tests.js rename to test/unit/address-resolution-tests.ts index b6297bd24..522d6dc37 100644 --- a/test/unit/address-resolution-tests.js +++ b/test/unit/address-resolution-tests.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const dns = require('dns'); +import assert from "assert"; +import dns from "dns"; +import * as addressResolution from "../../lib/policies/address-resolution"; + -const addressResolution = require('../../lib/policies/address-resolution'); const EC2MultiRegionTranslator = addressResolution.EC2MultiRegionTranslator; describe('EC2MultiRegionTranslator', function () { diff --git a/test/unit/api-tests.js b/test/unit/api-tests.ts similarity index 96% rename from test/unit/api-tests.js rename to test/unit/api-tests.ts index b62f67638..e73712a95 100644 --- a/test/unit/api-tests.js +++ b/test/unit/api-tests.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert } = require('chai'); -const api = require('../../index'); -const auth = require('../../lib/auth'); -const helper = require('../test-helper'); +import { assert } from "chai"; +import api from "../../index"; +import auth from "../../lib/auth/index"; +import helper from "../test-helper"; + describe('API', function () { it('should expose auth module', function () { diff --git a/test/unit/basic-tests.js b/test/unit/basic-tests.ts similarity index 97% rename from test/unit/basic-tests.js rename to test/unit/basic-tests.ts index e1b181197..9842050d1 100644 --- a/test/unit/basic-tests.js +++ b/test/unit/basic-tests.ts @@ -14,27 +14,26 @@ * limitations under the License. */ -"use strict"; -const { assert } = require('chai'); -const sinon = require('sinon'); -const util = require('util'); -const events = require('events'); - -const Client = require('../../lib/client'); -const clientOptions = require('../../lib/client-options'); -const auth = require('../../lib/auth'); -const types = require('../../lib/types'); -const { dataTypes } = types; -const loadBalancing = require('../../lib/policies/load-balancing'); -const retry = require('../../lib/policies/retry'); -const speculativeExecution = require('../../lib/policies/speculative-execution'); -const timestampGeneration = require('../../lib/policies/timestamp-generation'); -const Encoder = require('../../lib/encoder'); -const utils = require('../../lib/utils'); -const writers = require('../../lib/writers'); -const OperationState = require('../../lib/operation-state'); -const helper = require('../test-helper'); +import * as auth from '../../lib/auth/index'; +import { assert } from "chai"; +import sinon from "sinon"; +import util from "util"; +import events from "events"; +import Client from "../../lib/client"; +import clientOptions from "../../lib/client-options"; +import types from "../../lib/types/index"; +import loadBalancing from "../../lib/policies/load-balancing"; +import retry from "../../lib/policies/retry"; +import speculativeExecution from "../../lib/policies/speculative-execution"; +import timestampGeneration from "../../lib/policies/timestamp-generation"; +import Encoder from "../../lib/encoder"; +import utils from "../../lib/utils"; +import * as writers from "../../lib/writers"; +import OperationState from "../../lib/operation-state"; +import helper from "../test-helper"; + +const { dataTypes } = types; const contactPoints = ['a']; describe('types', function () { @@ -911,7 +910,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 97% rename from test/unit/big-decimal-tests.js rename to test/unit/big-decimal-tests.ts index beace400f..2c8ae9fcf 100644 --- a/test/unit/big-decimal-tests.js +++ b/test/unit/big-decimal-tests.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; -const assert = require('assert'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); describe('BigDecimal', function () { const BigDecimal = types.BigDecimal; diff --git a/test/unit/client-tests.js b/test/unit/client-tests.ts similarity index 96% rename from test/unit/client-tests.js rename to test/unit/client-tests.ts index 807d16ee8..507146182 100644 --- a/test/unit/client-tests.js +++ b/test/unit/client-tests.ts @@ -13,26 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert } = require('chai'); -const util = require('util'); -const proxyquire = require('proxyquire'); -const sinon = require('sinon'); - -const Client = require('../../lib/client'); -const policies = require('../../lib/policies'); -const helper = require('../test-helper'); -const errors = require('../../lib/errors'); -const utils = require('../../lib/utils'); -const types = require('../../lib/types'); -const HostMap = require('../../lib/host').HostMap; -const Host = require('../../lib/host').Host; -const Metadata = require('../../lib/metadata'); -const Encoder = require('../../lib/encoder'); -const ProfileManager = require('../../lib/execution-profile').ProfileManager; -const ExecutionProfile = require('../../lib/execution-profile').ExecutionProfile; -const clientOptions = require('../../lib/client-options'); -const PrepareHandler = require('../../lib/prepare-handler'); +import { assert } from "chai"; +import util from "util"; +import proxyquire from "proxyquire"; +import sinon from "sinon"; +import Client from "../../lib/client"; +import policies from "../../lib/policies/index"; +import helper from "../test-helper"; +import errors from "../../lib/errors"; +import utils from "../../lib/utils"; +import types from "../../lib/types/index"; +import Metadata from "../../lib/metadata/index"; +import Encoder from "../../lib/encoder"; +import clientOptions from "../../lib/client-options"; +import PrepareHandler from "../../lib/prepare-handler"; +import {Host, HostMap} from "../../lib/host"; +import { ProfileManager, ExecutionProfile } from "../../lib/execution-profile"; describe('Client', function () { describe('constructor', function () { @@ -179,7 +175,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 +544,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 96% rename from test/unit/cloud/certificate-validation-tests.js rename to test/unit/cloud/certificate-validation-tests.ts index 46c94bf78..fd4b02ad2 100644 --- a/test/unit/cloud/certificate-validation-tests.js +++ b/test/unit/cloud/certificate-validation-tests.ts @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import { checkServerIdentity } from "../../../lib/datastax/cloud/index"; -'use strict'; - -const { assert } = require('chai'); -const { checkServerIdentity } = require('../../../lib/datastax/cloud'); describe('checkServerIdentity()', () => { const port = 32598; diff --git a/test/unit/concurrent/execute-concurrent-tests.js b/test/unit/concurrent/execute-concurrent-tests.ts similarity index 98% rename from test/unit/concurrent/execute-concurrent-tests.js rename to test/unit/concurrent/execute-concurrent-tests.ts index add4cb179..1f34bf32b 100644 --- a/test/unit/concurrent/execute-concurrent-tests.js +++ b/test/unit/concurrent/execute-concurrent-tests.ts @@ -14,14 +14,12 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const Readable = require('stream').Readable; -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); -const helper = require('../../test-helper'); -const executeConcurrent = require('../../../lib/concurrent').executeConcurrent; +import assert from "assert"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import helper from "../../test-helper"; +import { Readable } from "stream"; +import { executeConcurrent } from "../../../lib/concurrent"; describe('executeConcurrent(client, query, parameters)', function () { this.timeout(10000); diff --git a/test/unit/connection-tests.js b/test/unit/connection-tests.ts similarity index 94% rename from test/unit/connection-tests.js rename to test/unit/connection-tests.ts index d3100ad3e..b16be81dc 100644 --- a/test/unit/connection-tests.js +++ b/test/unit/connection-tests.ts @@ -13,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const EventEmitter = require('events'); -const proxyquire = require('proxyquire'); -const sinon = require('sinon'); -const Connection = require('../../lib/connection'); -const requests = require('../../lib/requests'); -const defaultOptions = require('../../lib/client-options').defaultOptions(); -const utils = require('../../lib/utils'); -const errors = require('../../lib/errors'); -const ExecutionOptions = require('../../lib/execution-options').ExecutionOptions; -const helper = require('../test-helper'); +import assert from "assert"; +import EventEmitter from "events"; +import proxyquire from "proxyquire"; +import sinon from "sinon"; +import Connection from "../../lib/connection"; +import requests from "../../lib/requests"; +import utils from "../../lib/utils"; +import errors from "../../lib/errors"; +import helper from "../test-helper"; +import ClientOptions from "../../lib/client-options"; +import { ExecutionOptions } from "../../lib/execution-options"; +const defaultOptions = ClientOptions.defaultOptions(); describe('Connection', function () { describe('constructor', function () { it('should parse host endpoint into address and port', function () { diff --git a/test/unit/control-connection-tests.js b/test/unit/control-connection-tests.ts similarity index 96% rename from test/unit/control-connection-tests.js rename to test/unit/control-connection-tests.ts index e4b690169..ce59039f2 100644 --- a/test/unit/control-connection-tests.js +++ b/test/unit/control-connection-tests.ts @@ -13,22 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert } = require('chai'); -const events = require('events'); -const proxyquire = require('proxyquire'); -const util = require('util'); - -const helper = require('../test-helper.js'); -const ControlConnection = require('../../lib/control-connection'); -const Host = require('../../lib/host').Host; -const utils = require('../../lib/utils'); -const Metadata = require('../../lib/metadata'); -const types = require('../../lib/types'); -const errors = require('../../lib/errors'); -const policies = require('../../lib/policies'); -const clientOptions = require('../../lib/client-options'); -const ProfileManager = require('../../lib/execution-profile').ProfileManager; + +import { assert } from "chai"; +import events from "events"; +import proxyquire from "proxyquire"; +import util from "util"; +import helper from "../test-helper"; +import ControlConnection from "../../lib/control-connection"; +import utils from "../../lib/utils"; +import Metadata from "../../lib/metadata/index"; +import types from "../../lib/types/index"; +import errors from "../../lib/errors"; +import policies from "../../lib/policies/index"; +import clientOptions from "../../lib/client-options"; +import { Host } from "../../lib/host"; +import { ProfileManager } from "../../lib/execution-profile"; describe('ControlConnection', function () { describe('constructor', function () { diff --git a/test/unit/default-load-balancing-policy-tests.js b/test/unit/default-load-balancing-policy-tests.ts similarity index 97% rename from test/unit/default-load-balancing-policy-tests.js rename to test/unit/default-load-balancing-policy-tests.ts index 315bc7d7e..ab5080a36 100644 --- a/test/unit/default-load-balancing-policy-tests.js +++ b/test/unit/default-load-balancing-policy-tests.ts @@ -13,19 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const { assert } = require('chai'); -const util = require('util'); -const helper = require('../test-helper'); -const policies = require('../../lib/policies'); -const clientOptions = require('../../lib/client-options'); -const { Host, HostMap } = require('../../lib/host'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); -const { ExecutionOptions } = require('../../lib/execution-options'); -const errors = require('../../lib/errors'); -const Client = require('../../lib/client'); +import { assert } from "chai"; +import util from "util"; +import helper from "../test-helper"; +import policies from "../../lib/policies/index"; +import clientOptions from "../../lib/client-options"; +import { Host, HostMap } from "../../lib/host"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import { ExecutionOptions } from "../../lib/execution-options"; +import errors from "../../lib/errors"; +import Client from "../../lib/client"; + const { loadBalancing } = policies; const { DefaultLoadBalancingPolicy } = loadBalancing; diff --git a/test/unit/dse-gssapi-auth-provider-tests.js b/test/unit/dse-gssapi-auth-provider-tests.ts similarity index 93% rename from test/unit/dse-gssapi-auth-provider-tests.js rename to test/unit/dse-gssapi-auth-provider-tests.ts index 9af2bcdfd..c6c52efcb 100644 --- a/test/unit/dse-gssapi-auth-provider-tests.js +++ b/test/unit/dse-gssapi-auth-provider-tests.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const DseGssapiAuthProvider = require('../../lib/auth/dse-gssapi-auth-provider'); -const helper = require('../test-helper'); -const utils = require('../../lib/utils'); + +import DseGssapiAuthProvider from '../../lib/auth/dse-gssapi-auth-provider'; +import assert from "assert"; +import helper from "../test-helper"; +import utils from "../../lib/utils"; const cDescribe = helper.conditionalDescribe(helper.requireOptional('kerberos'), 'kerberos required to run'); const dseAuthenticatorName = 'com.datastax.bdp.cassandra.auth.DseAuthenticator'; diff --git a/test/unit/dse-plain-text-auth-provider-tests.js b/test/unit/dse-plain-text-auth-provider-tests.ts similarity index 82% rename from test/unit/dse-plain-text-auth-provider-tests.js rename to test/unit/dse-plain-text-auth-provider-tests.ts index 50fa67582..29a89e5fe 100644 --- a/test/unit/dse-plain-text-auth-provider-tests.js +++ b/test/unit/dse-plain-text-auth-provider-tests.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'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'; +import assert from "assert"; describe('DsePlainTextAuthProvider', function () { describe('#newAuthenticator()', function () { diff --git a/test/unit/duration-type-tests.js b/test/unit/duration-type-tests.ts similarity index 96% rename from test/unit/duration-type-tests.js rename to test/unit/duration-type-tests.ts index 151977a73..92b7d912b 100644 --- a/test/unit/duration-type-tests.js +++ b/test/unit/duration-type-tests.ts @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); +import assert from "assert"; +import util from "util"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; + + const Duration = types.Duration; const Long = types.Long; diff --git a/test/unit/encoder-tests.js b/test/unit/encoder-tests.ts similarity index 99% rename from test/unit/encoder-tests.js rename to test/unit/encoder-tests.ts index 354dcba91..424cee51e 100644 --- a/test/unit/encoder-tests.js +++ b/test/unit/encoder-tests.ts @@ -13,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert } = require('chai'); -const sinon = require('sinon'); -const util = require('util'); -const utils = require('../../lib/utils'); -const tokenizer = require('../../lib/tokenizer'); -const token = require('../../lib/token'); -const Vector = require('../../lib/types/vector'); -const Encoder = require('../../lib/encoder'); -const { types } = require('../../index.js'); -const ExecutionOptions = require('../../lib/execution-options').ExecutionOptions; -const dataTypes = types.dataTypes; -const helper = require('../test-helper'); +import { assert } from "chai"; +import sinon from "sinon"; +import util from "util"; +import utils from "../../lib/utils"; +import tokenizer from "../../lib/tokenizer"; +import token from "../../lib/token"; +import Vector from "../../lib/types/vector"; +import Encoder from "../../lib/encoder"; +import { types } from "../../index"; +import helper from "../test-helper"; +import { ExecutionOptions } from "../../lib/execution-options"; + +const dataTypes = types.dataTypes; const zeroLengthTypesSupported = new Set([ dataTypes.text, dataTypes.ascii, diff --git a/test/unit/encoder-vector-tests.js b/test/unit/encoder-vector-tests.ts similarity index 93% rename from test/unit/encoder-vector-tests.js rename to test/unit/encoder-vector-tests.ts index 4b3cc3569..f68c2a323 100644 --- a/test/unit/encoder-vector-tests.js +++ b/test/unit/encoder-vector-tests.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert, util } = require('chai'); -const Encoder = require('../../lib/encoder'); -const { types } = require('../../index'); -const Vector = require('../../lib/types/vector'); -const helper = require('../test-helper'); +import { assert, util } from "chai"; +import Encoder from "../../lib/encoder"; +import { types } from "../../index"; +import Vector from "../../lib/types/vector"; +import helper from "../test-helper"; + describe('Vector tests', function () { const encoder = new Encoder(4, {}); diff --git a/test/unit/error-tests.js b/test/unit/error-tests.ts similarity index 93% rename from test/unit/error-tests.js rename to test/unit/error-tests.ts index de49d96dc..e8c457e2d 100644 --- a/test/unit/error-tests.js +++ b/test/unit/error-tests.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import path from "path"; +import errors from "../../lib/errors"; +import helper from "../test-helper"; + -const assert = require('assert'); -const path = require('path'); -const errors = require('../../lib/errors'); -const helper = require('../test-helper'); const fileName = path.basename(__filename); describe('DriverError', function () { diff --git a/test/unit/event-debouncer-tests.js b/test/unit/event-debouncer-tests.ts similarity index 97% rename from test/unit/event-debouncer-tests.js rename to test/unit/event-debouncer-tests.ts index d2363e1ab..c76198995 100644 --- a/test/unit/event-debouncer-tests.js +++ b/test/unit/event-debouncer-tests.ts @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import { assert } from "chai"; +import sinon from "sinon"; +import helper from "../test-helper"; +import EventDebouncer from "../../lib/metadata/event-debouncer"; -const { assert } = require('chai'); -const sinon = require('sinon'); - -const helper = require('../test-helper'); -const EventDebouncer = require('../../lib/metadata/event-debouncer'); describe('EventDebouncer', function () { describe('timeoutElapsed()', function () { diff --git a/test/unit/execution-options-tests.js b/test/unit/execution-options-tests.ts similarity index 94% rename from test/unit/execution-options-tests.js rename to test/unit/execution-options-tests.ts index 16dbdc03e..c5a049665 100644 --- a/test/unit/execution-options-tests.js +++ b/test/unit/execution-options-tests.ts @@ -14,15 +14,13 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const utils = require('../../lib/utils'); -const types = require('../../lib/types'); -const helper = require('../test-helper'); -const DefaultExecutionOptions = require('../../lib/execution-options').DefaultExecutionOptions; -const ExecutionProfile = require('../../lib/execution-profile').ExecutionProfile; -const defaultOptions = require('../../lib/client-options').defaultOptions; +import assert from "assert"; +import utils from "../../lib/utils"; +import types from "../../lib/types/index"; +import helper from "../test-helper"; +import { DefaultExecutionOptions } from "../../lib/execution-options"; +import { ExecutionProfile } from "../../lib/execution-profile"; +import { defaultOptions } from "../../lib/client-options"; describe('DefaultExecutionOptions', () => { describe('create()', () => { diff --git a/test/unit/execution-profile-tests.js b/test/unit/execution-profile-tests.ts similarity index 90% rename from test/unit/execution-profile-tests.js rename to test/unit/execution-profile-tests.ts index 7b393829d..fb75b5602 100644 --- a/test/unit/execution-profile-tests.js +++ b/test/unit/execution-profile-tests.ts @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); - -const clientOptions = require('../../lib/client-options'); -const ExecutionProfile = require('../../lib/execution-profile').ExecutionProfile; -const ProfileManager = require('../../lib/execution-profile').ProfileManager; -const types = require('../../lib/types'); +import assert from "assert"; +import clientOptions from "../../lib/client-options"; +import types from "../../lib/types/index"; +import {ExecutionProfile} from "../../lib/execution-profile"; +import {ProfileManager} from "../../lib/execution-profile"; describe('ProfileManager', function () { describe('constructor', function () { diff --git a/test/unit/geometry/line-string-tests.js b/test/unit/geometry/line-string-tests.ts similarity index 95% rename from test/unit/geometry/line-string-tests.js rename to test/unit/geometry/line-string-tests.ts index 6dfaaa18e..6f4043850 100644 --- a/test/unit/geometry/line-string-tests.js +++ b/test/unit/geometry/line-string-tests.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../../test-helper'); -const utils = require('../../../lib/utils'); -const Point = require('../../../lib/geometry/point'); -const moduleName = '../../../lib/geometry/line-string'; -const LineString = require(moduleName); +import assert from "assert"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import Point from "../../../lib/geometry/point"; +import { LineString } from "../../../lib/geometry"; + describe('LineString', function () { describe('constructor', function () { diff --git a/test/unit/geometry/point-tests.js b/test/unit/geometry/point-tests.ts similarity index 95% rename from test/unit/geometry/point-tests.js rename to test/unit/geometry/point-tests.ts index 2c509462d..709e56153 100644 --- a/test/unit/geometry/point-tests.js +++ b/test/unit/geometry/point-tests.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../../test-helper'); -const utils = require('../../../lib/utils'); -const moduleName = '../../../lib/geometry/point'; -const Point = require(moduleName); + +import assert from "assert"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import Point from "../../../lib/geometry/point"; describe('Point', function () { describe('constructor', function () { diff --git a/test/unit/geometry/polygon-tests.js b/test/unit/geometry/polygon-tests.ts similarity index 96% rename from test/unit/geometry/polygon-tests.js rename to test/unit/geometry/polygon-tests.ts index 7e62956db..66c413166 100644 --- a/test/unit/geometry/polygon-tests.js +++ b/test/unit/geometry/polygon-tests.ts @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../../test-helper'); -const utils = require('../../../lib/utils'); -const Point = require('../../../lib/geometry/point'); -const moduleName = '../../../lib/geometry/polygon'; -const Polygon = require(moduleName); + +import assert from "assert"; +import helper from "../../test-helper"; +import utils from "../../../lib/utils"; +import Point from "../../../lib/geometry/point"; +import { Polygon } from "../../../lib/geometry"; describe('Polygon', function () { describe('constructor', function () { diff --git a/test/unit/graph/executor-tests.js b/test/unit/graph/executor-tests.ts similarity index 98% rename from test/unit/graph/executor-tests.js rename to test/unit/graph/executor-tests.ts index 439c13440..cf44be624 100644 --- a/test/unit/graph/executor-tests.js +++ b/test/unit/graph/executor-tests.ts @@ -14,17 +14,15 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const Client = require('../../../lib/client'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); -const policies = require('../../../lib/policies'); -const ExecutionProfile = require('../../../lib/execution-profile').ExecutionProfile; -const GraphExecutor = require('../../../lib/datastax/graph/graph-executor'); -const { GraphExecutionOptions, graphProtocol } = require('../../../lib/datastax/graph/options'); -const helper = require('../../test-helper'); +import assert from "assert"; +import Client from "../../../lib/client"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import policies from "../../../lib/policies/index"; +import GraphExecutor from "../../../lib/datastax/graph/graph-executor"; +import { GraphExecutionOptions, graphProtocol } from "../../../lib/datastax/graph/options"; +import helper from "../../test-helper"; +import { ExecutionProfile } from "../../../lib/execution-profile"; const proxyExecuteKey = 'ProxyExecute'; diff --git a/test/unit/graph/graph-result-tests.js b/test/unit/graph/graph-result-tests.ts similarity index 95% rename from test/unit/graph/graph-result-tests.js rename to test/unit/graph/graph-result-tests.ts index 0ae6f53c2..e69983c44 100644 --- a/test/unit/graph/graph-result-tests.js +++ b/test/unit/graph/graph-result-tests.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import utils from "../../../lib/utils"; +import ResultSet from "../../../lib/types/result-set"; +import GraphResultSet from "../../../lib/datastax/graph/result-set"; -const assert = require('assert'); -const utils = require('../../../lib/utils'); -const ResultSet = require('../../../lib/types/result-set'); -const GraphResultSet = require('../../../lib/datastax/graph/result-set'); const resultVertex = getResultSet([ { "gremlin": JSON.stringify({ diff --git a/test/unit/graph/graphson-tests.js b/test/unit/graph/graphson-tests.ts similarity index 93% rename from test/unit/graph/graphson-tests.js rename to test/unit/graph/graphson-tests.ts index a7485db82..4292008c5 100644 --- a/test/unit/graph/graphson-tests.js +++ b/test/unit/graph/graphson-tests.ts @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import { assert } from "chai"; +import helper from "../../test-helper"; +import { GraphSON2Reader, GraphSON3Reader, GraphSON3Writer } from "../../../lib/datastax/graph/graph-serializer"; +import getCustomTypeSerializers from "../../../lib/datastax/graph/custom-type-serializers"; +import graphModule from "../../../lib/datastax/graph/index"; +import types from "../../../lib/types/index"; +import utils from "../../../lib/utils"; +import geometry from "../../../lib/geometry/index"; + -const { assert } = require('chai'); -const helper = require('../../test-helper'); -const { GraphSON2Reader, GraphSON3Reader, GraphSON3Writer } = require('../../../lib/datastax/graph/graph-serializer'); -const getCustomTypeSerializers = require('../../../lib/datastax/graph/custom-type-serializers'); -const graphModule = require('../../../lib/datastax/graph'); -const types = require('../../../lib/types'); -const utils = require('../../../lib/utils'); -const geometry = require('../../../lib/geometry'); const { Tuple } = types; const { asInt, asDouble, asTimestamp } = graphModule; diff --git a/test/unit/host-tests.js b/test/unit/host-tests.ts similarity index 97% rename from test/unit/host-tests.js rename to test/unit/host-tests.ts index ccf90e540..8b3c2b314 100644 --- a/test/unit/host-tests.js +++ b/test/unit/host-tests.ts @@ -13,25 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import { assert } from "chai"; +import sinon from "sinon"; +import util from "util"; +import events from "events"; +import hostModule from "../../lib/host"; +import HostConnectionPool from "../../lib/host-connection-pool"; +import Metadata from "../../lib/metadata/index"; +import types from "../../lib/types/index"; +import clientOptions from "../../lib/client-options"; +import utils from "../../lib/utils"; +import policies from "../../lib/policies/index"; +import helper from "../test-helper"; -const { assert } = require('chai'); -const sinon = require('sinon'); -const util = require('util'); -const events = require('events'); -const hostModule = require('../../lib/host'); const Host = hostModule.Host; -const HostConnectionPool = require('../../lib/host-connection-pool'); -const Metadata = require('../../lib/metadata'); const HostMap = hostModule.HostMap; -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 policies = require('../../lib/policies'); -const helper = require('../test-helper'); const reconnection = policies.reconnection; describe('HostConnectionPool', function () { diff --git a/test/unit/inet-address-tests.js b/test/unit/inet-address-tests.ts similarity index 97% rename from test/unit/inet-address-tests.js rename to test/unit/inet-address-tests.ts index 509f99237..64bc9ef5a 100644 --- a/test/unit/inet-address-tests.js +++ b/test/unit/inet-address-tests.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../test-helper'); -const utils = require('../../lib/utils'); -const InetAddress = require('../../lib/types').InetAddress; + +import assert from "assert"; +import helper from "../test-helper"; +import utils from "../../lib/utils"; +import { InetAddress } from "../../lib/types"; describe('InetAddress', function () { describe('constructor', function () { diff --git a/test/unit/insights-client-tests.js b/test/unit/insights-client-tests.ts similarity index 96% rename from test/unit/insights-client-tests.js rename to test/unit/insights-client-tests.ts index 6ea176af7..69bfb52b9 100644 --- a/test/unit/insights-client-tests.js +++ b/test/unit/insights-client-tests.ts @@ -14,20 +14,18 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const os = require('os'); -const Client = require('../../lib/client'); -const ClientState = require('../../lib/metadata/client-state'); -const InsightsClient = require('../../lib/insights-client'); -const ExecutionProfile = require('../../lib/execution-profile').ExecutionProfile; -const utils = require('../../lib/utils'); -const types = require('../../lib/types'); -const policies = require('../../lib/policies'); -const coreConnectionsPerHostV3 = require('../../lib/client-options').coreConnectionsPerHostV3; -const packageInfo = require('../../package.json'); -const helper = require('../test-helper'); +import assert from "assert"; +import os from "os"; +import Client from "../../lib/client"; +import ClientState from "../../lib/metadata/client-state"; +import InsightsClient from "../../lib/insights-client"; +import utils from "../../lib/utils"; +import types from "../../lib/types/index"; +import policies from "../../lib/policies/index"; +import packageInfo from "../../package.json"; +import helper from "../test-helper"; +import { ExecutionProfile } from "../../lib/execution-profile"; +import { coreConnectionsPerHostV3 } from "../../lib/client-options"; const kerberosModule = helper.requireOptional('kerberos'); const kerberosDescribe = kerberosModule ? describe : xdescribe; diff --git a/test/unit/license-tests.js b/test/unit/license-tests.ts similarity index 96% rename from test/unit/license-tests.js rename to test/unit/license-tests.ts index 0a6c794b8..2e6af295e 100644 --- a/test/unit/license-tests.js +++ b/test/unit/license-tests.ts @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require("assert"); -const path = require("path"); -const fs = require("fs"); +import assert from "assert"; +import path from "path"; +import fs from "fs"; + const licenseHeaderRegex = new RegExp( `/\\* diff --git a/test/unit/load-balancing-tests.js b/test/unit/load-balancing-tests.ts similarity index 97% rename from test/unit/load-balancing-tests.js rename to test/unit/load-balancing-tests.ts index 524649287..012afa350 100644 --- a/test/unit/load-balancing-tests.js +++ b/test/unit/load-balancing-tests.ts @@ -13,19 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); +import assert from "assert"; +import helper from "../test-helper"; +import errors from "../../lib/errors"; +import Client from "../../lib/client"; +import clientOptions from "../../lib/client-options"; +import { Host, HostMap } from "../../lib/host"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import { ExecutionOptions } from "../../lib/execution-options"; +import { AllowListPolicy, LoadBalancingPolicy, TokenAwarePolicy, RoundRobinPolicy, DCAwareRoundRobinPolicy } from "../../lib/policies/load-balancing"; -const helper = require('../test-helper.js'); -const errors = require('../../lib/errors'); -const Client = require('../../lib/client.js'); -const clientOptions = require('../../lib/client-options'); -const { Host, HostMap } = require('../../lib/host'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); -const { ExecutionOptions } = require('../../lib/execution-options'); -const { AllowListPolicy, LoadBalancingPolicy, TokenAwarePolicy, RoundRobinPolicy, DCAwareRoundRobinPolicy } = - require('../../lib/policies/load-balancing'); describe('RoundRobinPolicy', function () { it('should yield an error when the hosts are not set', function(done) { diff --git a/test/unit/mapping/cache-tests.js b/test/unit/mapping/cache-tests.ts similarity index 97% rename from test/unit/mapping/cache-tests.js rename to test/unit/mapping/cache-tests.ts index 2d62b0652..1bac26837 100644 --- a/test/unit/mapping/cache-tests.js +++ b/test/unit/mapping/cache-tests.ts @@ -14,11 +14,9 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const Cache = require('../../../lib/mapping/cache'); -const q = require('../../../lib/mapping/q').q; +import assert from "assert"; +import Cache from "../../../lib/mapping/cache"; +import {q} from "../../../lib/mapping/q"; describe('Cache', function() { this.timeout(5000); diff --git a/test/unit/mapping/mapper-tests.js b/test/unit/mapping/mapper-tests.ts similarity index 96% rename from test/unit/mapping/mapper-tests.js rename to test/unit/mapping/mapper-tests.ts index 9bbf50351..0c3c46440 100644 --- a/test/unit/mapping/mapper-tests.js +++ b/test/unit/mapping/mapper-tests.ts @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import sinon from "sinon"; +import Mapper from "../../../lib/mapping/mapper"; +import ModelMapper from "../../../lib/mapping/model-mapper"; +import helper from "../../test-helper"; +import mapperTestHelper from "./mapper-unit-test-helper"; -'use strict'; - -const { assert } = require('chai'); -const sinon = require('sinon'); -const Mapper = require('../../../lib/mapping/mapper'); -const ModelMapper = require('../../../lib/mapping/model-mapper'); -const helper = require('../../test-helper'); -const mapperTestHelper = require('./mapper-unit-test-helper'); describe('Mapper', () => { describe('constructor', () => { diff --git a/test/unit/mapping/mapper-unit-test-helper.js b/test/unit/mapping/mapper-unit-test-helper.ts similarity index 96% rename from test/unit/mapping/mapper-unit-test-helper.js rename to test/unit/mapping/mapper-unit-test-helper.ts index 9167d20e8..32c234629 100644 --- a/test/unit/mapping/mapper-unit-test-helper.js +++ b/test/unit/mapping/mapper-unit-test-helper.ts @@ -14,16 +14,14 @@ * limitations under the License. */ -'use strict'; +import assert from "assert"; +import types from "../../../lib/types/index"; +import ModelMapper from "../../../lib/mapping/model-mapper"; +import Mapper from "../../../lib/mapping/mapper"; -const assert = require('assert'); -const types = require('../../../lib/types'); -const ModelMapper = require('../../../lib/mapping/model-mapper'); const ResultSet = types.ResultSet; const dataTypes = types.dataTypes; -const Mapper = require('../../../lib/mapping/mapper'); - -const mapperHelper = module.exports = { +const mapperHelper = { /** * Gets a fake client instance that returns metadata for a single table * @param {Array|Function} columns @@ -172,3 +170,4 @@ const mapperHelper = module.exports = { } }; +export default mapperHelper; \ No newline at end of file diff --git a/test/unit/mapping/mapping-handler-tests.js b/test/unit/mapping/mapping-handler-tests.ts similarity index 92% rename from test/unit/mapping/mapping-handler-tests.js rename to test/unit/mapping/mapping-handler-tests.ts index 64b39850e..6260df53e 100644 --- a/test/unit/mapping/mapping-handler-tests.js +++ b/test/unit/mapping/mapping-handler-tests.ts @@ -14,14 +14,12 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const mapperTestHelper = require('./mapper-unit-test-helper'); -const MappingHandler = require('../../../lib/mapping/mapping-handler'); -const ModelMappingInfo = require('../../../lib/mapping/model-mapping-info'); -const DefaultTableMappings = require('../../../lib/mapping/table-mappings').DefaultTableMappings; -const q = require('../../../lib/mapping/q').q; +import assert from "assert"; +import mapperTestHelper from "./mapper-unit-test-helper"; +import MappingHandler from "../../../lib/mapping/mapping-handler"; +import ModelMappingInfo from "../../../lib/mapping/model-mapping-info"; +import { DefaultTableMappings } from "../../../lib/mapping/table-mappings"; +import { q } from "../../../lib/mapping/q"; describe('MappingHandler', () => { describe('#getSelectExecutor()', () => { diff --git a/test/unit/mapping/model-mapper-mutation-tests.js b/test/unit/mapping/model-mapper-mutation-tests.ts similarity index 98% rename from test/unit/mapping/model-mapper-mutation-tests.js rename to test/unit/mapping/model-mapper-mutation-tests.ts index d28846c51..62f4d0dbd 100644 --- a/test/unit/mapping/model-mapper-mutation-tests.js +++ b/test/unit/mapping/model-mapper-mutation-tests.ts @@ -14,13 +14,12 @@ * limitations under the License. */ -'use strict'; +import assert from "assert"; +import types from "../../../lib/types/index"; +import helper from "../../test-helper"; +import mapperTestHelper from "./mapper-unit-test-helper"; +import { q } from "../../../lib/mapping/q"; -const assert = require('assert'); -const q = require('../../../lib/mapping/q').q; -const types = require('../../../lib/types'); -const helper = require('../../test-helper'); -const mapperTestHelper = require('./mapper-unit-test-helper'); const dataTypes = types.dataTypes; describe('ModelMapper', () => { diff --git a/test/unit/mapping/model-mapper-select-tests.js b/test/unit/mapping/model-mapper-select-tests.ts similarity index 98% rename from test/unit/mapping/model-mapper-select-tests.js rename to test/unit/mapping/model-mapper-select-tests.ts index a40f23e83..59eab03a5 100644 --- a/test/unit/mapping/model-mapper-select-tests.js +++ b/test/unit/mapping/model-mapper-select-tests.ts @@ -14,13 +14,11 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const q = require('../../../lib/mapping/q').q; -const dataTypes = require('../../../lib/types').dataTypes; -const helper = require('../../test-helper'); -const mapperTestHelper = require('./mapper-unit-test-helper'); +import assert from "assert"; +import helper from "../../test-helper"; +import mapperTestHelper from "./mapper-unit-test-helper"; +import { q } from "../../../lib/mapping/q"; +import { dataTypes } from "../../../lib/types"; const emptyResponse = { meta: { columns: [] }, rows: [] }; diff --git a/test/unit/mapping/model-mapping-info-tests.js b/test/unit/mapping/model-mapping-info-tests.ts similarity index 95% rename from test/unit/mapping/model-mapping-info-tests.js rename to test/unit/mapping/model-mapping-info-tests.ts index bffbc9a8d..223f32d59 100644 --- a/test/unit/mapping/model-mapping-info-tests.js +++ b/test/unit/mapping/model-mapping-info-tests.ts @@ -13,12 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import ModelMappingInfo from "../../../lib/mapping/model-mapping-info"; -'use strict'; - -const { assert } = require('chai'); - -const ModelMappingInfo = require('../../../lib/mapping/model-mapping-info'); describe('ModelMappingInfo', function () { describe('parse()', function () { diff --git a/test/unit/mapping/result-mapper-tests.js b/test/unit/mapping/result-mapper-tests.ts similarity index 94% rename from test/unit/mapping/result-mapper-tests.js rename to test/unit/mapping/result-mapper-tests.ts index b06758601..e60a4ba9c 100644 --- a/test/unit/mapping/result-mapper-tests.js +++ b/test/unit/mapping/result-mapper-tests.ts @@ -13,13 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { assert } from "chai"; +import sinon from "sinon"; +import ResultMapper from "../../../lib/mapping/result-mapper"; -'use strict'; - -const { assert } = require('chai'); -const sinon = require('sinon'); - -const ResultMapper = require('../../../lib/mapping/result-mapper'); describe('ResultMapper', function () { describe('getSelectAdapter()', function () { diff --git a/test/unit/mapping/result-tests.js b/test/unit/mapping/result-tests.ts similarity index 95% rename from test/unit/mapping/result-tests.js rename to test/unit/mapping/result-tests.ts index 70d47906b..a5aab7de9 100644 --- a/test/unit/mapping/result-tests.js +++ b/test/unit/mapping/result-tests.ts @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import Result from "../../../lib/mapping/result"; +import util from "util"; -'use strict'; - -const assert = require('assert'); -const Result = require('../../../lib/mapping/result'); -const util = require('util'); const expected = [ { id: 1, name: 'name1', adapted: true }, { id: 2, name: 'name2', adapted: true }]; diff --git a/test/unit/mapping/table-mappings-tests.js b/test/unit/mapping/table-mappings-tests.ts similarity index 92% rename from test/unit/mapping/table-mappings-tests.js rename to test/unit/mapping/table-mappings-tests.ts index 369374002..f01202b3d 100644 --- a/test/unit/mapping/table-mappings-tests.js +++ b/test/unit/mapping/table-mappings-tests.ts @@ -13,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import tableMappingsModule from "../../../lib/mapping/table-mappings"; -'use strict'; -const assert = require('assert'); -const tableMappingsModule = require('../../../lib/mapping/table-mappings'); const UnderscoreCqlToCamelCaseMappings = tableMappingsModule.UnderscoreCqlToCamelCaseMappings; describe('UnderscoreCqlToCamelCaseMappings', () => { diff --git a/test/unit/mapping/tree-tests.js b/test/unit/mapping/tree-tests.ts similarity index 97% rename from test/unit/mapping/tree-tests.js rename to test/unit/mapping/tree-tests.ts index 2eb1282c8..4cab9a3ba 100644 --- a/test/unit/mapping/tree-tests.js +++ b/test/unit/mapping/tree-tests.ts @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import assert from "assert"; +import Tree from "../../../lib/mapping/tree"; -'use strict'; - -const assert = require('assert'); -const Tree = require('../../../lib/mapping/tree'); describe('Tree', function () { this.timeout(20000); 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..70a888380 100644 --- a/test/unit/metadata-tests.js +++ b/test/unit/metadata-tests.ts @@ -13,29 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use strict'; - -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 HostMap = require('../../lib/host').HostMap; -const Metadata = require('../../lib/metadata'); -const TableMetadata = require('../../lib/metadata/table-metadata'); -const Murmur3Token = require('../../lib/token').Murmur3Token; -const TokenRange = require('../../lib/token').TokenRange; -const tokenizer = require('../../lib/tokenizer'); -const types = require('../../lib/types'); -const MutableLong = require('../../lib/types/mutable-long'); +import { assert } from "chai"; +import sinon from "sinon"; +import events from "events"; +import helper from "../test-helper"; +import clientOptions from "../../lib/client-options"; +import Metadata from "../../lib/metadata/index"; +import TableMetadata from "../../lib/metadata/table-metadata"; +import tokenizer from "../../lib/tokenizer"; +import types from "../../lib/types/index"; +import MutableLong from "../../lib/types/mutable-long"; +import utils from "../../lib/utils"; +import errors from "../../lib/errors"; +import Encoder from "../../lib/encoder"; + + +import { Host, HostMap } from "../../lib/host"; +import { Murmur3Token, TokenRange } from "../../lib/token"; +import SchemaParser from "../../lib/metadata/schema-parser"; const dataTypes = types.dataTypes; -const utils = require('../../lib/utils'); -const errors = require('../../lib/errors'); -const Encoder = require('../../lib/encoder'); -const isDoneForToken = require('../../lib/metadata/schema-parser').isDoneForToken; +const isDoneForToken = SchemaParser.isDoneForToken; describe('Metadata', function () { this.timeout(5000); diff --git a/test/unit/mutable-long-tests.js b/test/unit/mutable-long-tests.ts similarity index 97% rename from test/unit/mutable-long-tests.js rename to test/unit/mutable-long-tests.ts index 8bbb32fc9..736f8b76c 100644 --- a/test/unit/mutable-long-tests.js +++ b/test/unit/mutable-long-tests.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -"use strict"; -const assert = require('assert'); -const format = require('util').format; -const Long = require('long'); -const MutableLong = require('../../lib/types/mutable-long'); +import assert from "assert"; +import Long from "long"; +import MutableLong from "../../lib/types/mutable-long"; +import { format } from "util"; describe('MutableLong', function () { describe('fromNumber() and #toNumber()', function () { diff --git a/test/unit/parser-tests.js b/test/unit/parser-tests.ts similarity index 99% rename from test/unit/parser-tests.js rename to test/unit/parser-tests.ts index b0d21dd86..d30f1e722 100644 --- a/test/unit/parser-tests.js +++ b/test/unit/parser-tests.ts @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const events = require('events'); +import assert from "assert"; +import events from "events"; +import Encoder from "../../lib/encoder"; +import streams from "../../lib/streams"; +import errors from "../../lib/errors"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import helper from "../test-helper"; -const Encoder = require('../../lib/encoder'); -const streams = require('../../lib/streams'); -const errors = require('../../lib/errors'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); -const helper = require('../test-helper'); /** * Tests for the transform streams that are involved in the reading of a response diff --git a/test/unit/prepare-handler-tests.js b/test/unit/prepare-handler-tests.ts similarity index 94% rename from test/unit/prepare-handler-tests.js rename to test/unit/prepare-handler-tests.ts index 1a2afb1a3..8e172b906 100644 --- a/test/unit/prepare-handler-tests.js +++ b/test/unit/prepare-handler-tests.ts @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const { assert } = require('chai'); -const events = require('events'); -const helper = require('../test-helper'); -const PrepareHandler = require('../../lib/prepare-handler'); -const defaultOptions = require('../../lib/client-options').defaultOptions; -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); + +import { assert } from "chai"; +import events from "events"; +import helper from "../test-helper"; +import PrepareHandler from "../../lib/prepare-handler"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import { defaultOptions } from "../../lib/client-options"; describe('PrepareHandler', function () { diff --git a/test/unit/protocol-stream-tests.js b/test/unit/protocol-stream-tests.ts similarity index 96% rename from test/unit/protocol-stream-tests.js rename to test/unit/protocol-stream-tests.ts index 254a25ed1..b4f681407 100644 --- a/test/unit/protocol-stream-tests.js +++ b/test/unit/protocol-stream-tests.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const Protocol = require('../../lib/streams').Protocol; -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); +import assert from "assert"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import {Protocol} from "../../lib/streams"; describe('Protocol', function () { it('should emit a single frame with 0-length body', function (done) { diff --git a/test/unit/protocol-version-tests.js b/test/unit/protocol-version-tests.ts similarity index 94% rename from test/unit/protocol-version-tests.js rename to test/unit/protocol-version-tests.ts index 780cd99a4..8953ac064 100644 --- a/test/unit/protocol-version-tests.js +++ b/test/unit/protocol-version-tests.ts @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const protocolVersion = require('../../lib/types/').protocolVersion; -const Host = require('../../lib/host').Host; -const options = require('../../lib/client-options').defaultOptions(); +import assert from "assert"; +import {protocolVersion} from "../../lib/types"; +import {Host} from "../../lib/host"; +import clientOptions from "../../lib/client-options"; + +const options = clientOptions.defaultOptions(); describe('protocolVersion', function () { describe('#getHighestCommon()', function () { diff --git a/test/unit/reconnection-test.js b/test/unit/reconnection-test.ts similarity index 95% rename from test/unit/reconnection-test.js rename to test/unit/reconnection-test.ts index 4eeadd9d1..69b5760bb 100644 --- a/test/unit/reconnection-test.js +++ b/test/unit/reconnection-test.ts @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -//project modules -const utils = require('../../lib/utils'); -const helper = require('../test-helper'); -const reconnection = require('../../lib/policies/reconnection'); +import assert from "assert"; +import utils from "../../lib/utils"; +import helper from "../test-helper"; +import reconnection from "../../lib/policies/reconnection"; + +//project modules describe('ConstantReconnectionPolicy', function () { it('should yield the same wait time', function (done) { const delay = 2000; diff --git a/test/unit/request-handler-tests.js b/test/unit/request-handler-tests.ts similarity index 96% rename from test/unit/request-handler-tests.js rename to test/unit/request-handler-tests.ts index 62875e652..55f7bf272 100644 --- a/test/unit/request-handler-tests.js +++ b/test/unit/request-handler-tests.ts @@ -13,28 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const util = require('util'); - -const RequestHandler = require('../../lib/request-handler'); -const requests = require('../../lib/requests'); -const helper = require('../test-helper'); -const errors = require('../../lib/errors'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); -const retry = require('../../lib/policies/retry'); -const speculativeExecution = require('../../lib/policies/speculative-execution'); -const execProfileModule = require('../../lib/execution-profile'); + +import assert from "assert"; +import util from "util"; +import RequestHandler from "../../lib/request-handler"; +import requests from "../../lib/requests"; +import helper from "../test-helper"; +import errors from "../../lib/errors"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import retry from "../../lib/policies/retry"; +import speculativeExecution from "../../lib/policies/speculative-execution"; +import execProfileModule from "../../lib/execution-profile"; +import OperationState from "../../lib/operation-state"; +import * as execOptionsModule from "../../lib/execution-options"; +import ClientMetrics from "../../lib/metrics/client-metrics"; +import { defaultOptions } from "../../lib/client-options"; + const ProfileManager = execProfileModule.ProfileManager; const ExecutionProfile = execProfileModule.ExecutionProfile; -const OperationState = require('../../lib/operation-state'); -const defaultOptions = require('../../lib/client-options').defaultOptions; -const execOptionsModule = require('../../lib/execution-options'); const DefaultExecutionOptions = execOptionsModule.DefaultExecutionOptions; const ExecutionOptions = execOptionsModule.ExecutionOptions; -const ClientMetrics = require('../../lib/metrics/client-metrics'); - describe('RequestHandler', function () { const queryRequest = new requests.QueryRequest('QUERY1'); describe('#send()', function () { diff --git a/test/unit/requests-test.js b/test/unit/requests-test.ts similarity index 97% rename from test/unit/requests-test.js rename to test/unit/requests-test.ts index c8facec6b..b87ae6bf5 100644 --- a/test/unit/requests-test.js +++ b/test/unit/requests-test.ts @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const requests = require('../../lib/requests'); -const Encoder = require('../../lib/encoder'); -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); -const ExecutionOptions = require('../../lib/execution-options').ExecutionOptions; -const packageInfo = require('../../package.json'); + +import assert from "assert"; +import requests from "../../lib/requests"; +import Encoder from "../../lib/encoder"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import packageInfo from "../../package.json"; +import { ExecutionOptions } from "../../lib/execution-options"; + const QueryRequest = requests.QueryRequest; const ExecuteRequest = requests.ExecuteRequest; const BatchRequest = requests.BatchRequest; diff --git a/test/unit/result-set-tests.js b/test/unit/result-set-tests.ts similarity index 97% rename from test/unit/result-set-tests.js rename to test/unit/result-set-tests.ts index 26bb8a784..26c436f08 100644 --- a/test/unit/result-set-tests.js +++ b/test/unit/result-set-tests.ts @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import { assert } from "chai"; +import sinon from "sinon"; +import utils from "../../lib/utils"; +import types from "../../lib/types/index"; +import helper from "../test-helper"; + -const { assert } = require('chai'); -const sinon = require('sinon'); -const utils = require('../../lib/utils'); -const types = require('../../lib/types'); -const helper = require('../test-helper'); const { ResultSet } = types; describe('ResultSet', function () { diff --git a/test/unit/retry-policy-tests.js b/test/unit/retry-policy-tests.ts similarity index 97% rename from test/unit/retry-policy-tests.js rename to test/unit/retry-policy-tests.ts index 19296cf63..14b081071 100644 --- a/test/unit/retry-policy-tests.js +++ b/test/unit/retry-policy-tests.ts @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const types = require('../../lib/types'); -const policies = require('../../lib/policies'); -const helper = require('../test-helper'); -const ExecutionOptions = require('../../lib/execution-options').ExecutionOptions; + +import assert from "assert"; +import types from "../../lib/types/index"; +import policies from "../../lib/policies/index"; +import helper from "../test-helper"; +import {ExecutionOptions} from "../../lib/execution-options"; + const RetryPolicy = policies.retry.RetryPolicy; const IdempotenceAwareRetryPolicy = policies.retry.IdempotenceAwareRetryPolicy; const FallthroughRetryPolicy = policies.retry.FallthroughRetryPolicy; diff --git a/test/unit/search/date-range-tests.js b/test/unit/search/date-range-tests.ts similarity index 96% rename from test/unit/search/date-range-tests.js rename to test/unit/search/date-range-tests.ts index 2fc875675..d0831b74c 100644 --- a/test/unit/search/date-range-tests.js +++ b/test/unit/search/date-range-tests.ts @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import util from "util"; +import helper from "../../test-helper"; +import * as dateRangeModule from "../../../lib/datastax/search/date-range"; + -const assert = require('assert'); -const util = require('util'); -const helper = require('../../test-helper'); -const dateRangeModule = require('../../../lib/datastax/search/date-range'); const DateRange = dateRangeModule.DateRange; const DateRangeBound = dateRangeModule.DateRangeBound; const unbounded = dateRangeModule.unbounded; diff --git a/test/unit/speculative-execution-tests.js b/test/unit/speculative-execution-tests.ts similarity index 89% rename from test/unit/speculative-execution-tests.js rename to test/unit/speculative-execution-tests.ts index 6fe4871dc..9e283cba1 100644 --- a/test/unit/speculative-execution-tests.js +++ b/test/unit/speculative-execution-tests.ts @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import helper from "../test-helper"; +import specExecModule from "../../lib/policies/speculative-execution"; -'use strict'; - -const helper = require('../test-helper'); -const specExecModule = require('../../lib/policies/speculative-execution'); describe('NoSpeculativeExecutionPolicy', () => { describe('#getOptions()', () => { diff --git a/test/unit/stream-id-stack-tests.js b/test/unit/stream-id-stack-tests.ts similarity index 97% rename from test/unit/stream-id-stack-tests.js rename to test/unit/stream-id-stack-tests.ts index c70436a66..81fe24499 100644 --- a/test/unit/stream-id-stack-tests.js +++ b/test/unit/stream-id-stack-tests.ts @@ -13,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import sinon from "sinon"; +import assert from "assert"; +import StreamIdStack from "../../lib/stream-id-stack"; -"use strict"; -const sinon = require('sinon'); -const assert = require('assert'); - -const StreamIdStack = require('../../lib/stream-id-stack'); describe('StreamIdStack', function () { let clock; diff --git a/test/unit/timestamp-tests.js b/test/unit/timestamp-tests.ts similarity index 92% rename from test/unit/timestamp-tests.js rename to test/unit/timestamp-tests.ts index a1f89224b..2fde97d77 100644 --- a/test/unit/timestamp-tests.js +++ b/test/unit/timestamp-tests.ts @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const MonotonicTimestampGenerator = require('../../lib/policies/timestamp-generation').MonotonicTimestampGenerator; -const Long = require('../../lib/types').Long; -const helper = require('../test-helper'); +import assert from "assert"; +import helper from "../test-helper"; +import { MonotonicTimestampGenerator } from "../../lib/policies/timestamp-generation"; +import {Long} from "../../lib/types"; describe('MonotonicTimestampGenerator', function () { describe('#next()', function () { diff --git a/test/unit/token-tests.js b/test/unit/token-tests.ts similarity index 99% rename from test/unit/token-tests.js rename to test/unit/token-tests.ts index 06297ab35..7d578c40d 100644 --- a/test/unit/token-tests.js +++ b/test/unit/token-tests.ts @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import tokenizer from "../../lib/tokenizer"; +import token from "../../lib/token"; +import assert from "assert"; + -const tokenizer = require('../../lib/tokenizer'); -const token = require('../../lib/token'); -const assert = require('assert'); class TokenTester { constructor(tokenizer) { diff --git a/test/unit/tokenizer-tests.js b/test/unit/tokenizer-tests.ts similarity index 94% rename from test/unit/tokenizer-tests.js rename to test/unit/tokenizer-tests.ts index c710d8764..f730e019c 100644 --- a/test/unit/tokenizer-tests.js +++ b/test/unit/tokenizer-tests.ts @@ -13,19 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); +import assert from "assert"; +import tokenizer from "../../lib/tokenizer"; +import token from "../../lib/token"; +import types from "../../lib/types/index"; +import utils from "../../lib/utils"; +import MutableLong from "../../lib/types/mutable-long"; +import helper from "../test-helper"; + -const tokenizer = require('../../lib/tokenizer'); -const token = require('../../lib/token'); const Murmur3Tokenizer = tokenizer.Murmur3Tokenizer; const RandomTokenizer = tokenizer.RandomTokenizer; const ByteOrderedTokenizer = tokenizer.ByteOrderedTokenizer; -const types = require('../../lib/types'); -const utils = require('../../lib/utils'); -const MutableLong = require('../../lib/types/mutable-long'); -const helper = require('../test-helper'); - describe('Murmur3Tokenizer', function () { describe('#rotl64()', function () { it('should return expected results', function () { diff --git a/test/unit/tracker-tests.js b/test/unit/tracker-tests.ts similarity index 97% rename from test/unit/tracker-tests.js rename to test/unit/tracker-tests.ts index 11d35a154..ca54bb918 100644 --- a/test/unit/tracker-tests.js +++ b/test/unit/tracker-tests.ts @@ -14,13 +14,11 @@ * limitations under the License. */ -'use strict'; - -const assert = require('assert'); -const helper = require('../test-helper'); -const types = require('../../lib/types'); -const RequestLogger = require('../../lib/tracker').RequestLogger; -const ExecutionOptions = require('../../lib/execution-options').ExecutionOptions; +import assert from "assert"; +import helper from "../test-helper"; +import types from "../../lib/types/index"; +import { RequestLogger } from "../../lib/tracker"; +import { ExecutionOptions } from "../../lib/execution-options"; describe('RequestLogger', () => { describe('#onSuccess()', () => { diff --git a/test/unit/typescript/api-generation-test.ts b/test/unit/typescript/api-generation-test.ts index cb6f94c5e..a7fd0d65e 100644 --- a/test/unit/typescript/api-generation-test.ts +++ b/test/unit/typescript/api-generation-test.ts @@ -47,7 +47,7 @@ export function generate(): void { * limitations under the License. */ -'use strict'; + import { auth, concurrent, errors, datastax, mapping, geometry, metadata, metrics, policies, tracker, types } from "../../../index"; import * as root from "../../../index"; diff --git a/test/unit/utils-tests.js b/test/unit/utils-tests.ts similarity index 98% rename from test/unit/utils-tests.js rename to test/unit/utils-tests.ts index ba2741601..2322f7a71 100644 --- a/test/unit/utils-tests.js +++ b/test/unit/utils-tests.ts @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const { assert } = require('chai'); -const sinon = require('sinon'); -const utils = require('../../lib/utils'); -const helper = require('../test-helper'); +import { assert } from "chai"; +import sinon from "sinon"; +import utils from "../../lib/utils"; +import helper from "../test-helper"; + + const AddressResolver = utils.AddressResolver; describe('utils', function () { diff --git a/test/unit/uuid-tests.js b/test/unit/uuid-tests.ts similarity index 98% rename from test/unit/uuid-tests.js rename to test/unit/uuid-tests.ts index c53367fbf..f0efd1df8 100644 --- a/test/unit/uuid-tests.js +++ b/test/unit/uuid-tests.ts @@ -13,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; -const assert = require('assert'); -const helper = require('../test-helper'); -const utils = require('../../lib/utils'); -const Uuid = require('../../lib/types').Uuid; -const TimeUuid = require('../../lib/types').TimeUuid; +import assert from "assert"; +import helper from "../test-helper"; +import utils from "../../lib/utils"; +import { Uuid, TimeUuid } from "../../lib/types"; describe('Uuid', function () { describe('constructor', function () { diff --git a/test/unit/version-number-tests.js b/test/unit/version-number-tests.ts similarity index 97% rename from test/unit/version-number-tests.js rename to test/unit/version-number-tests.ts index e93d7d50c..9e90cba9e 100644 --- a/test/unit/version-number-tests.js +++ b/test/unit/version-number-tests.ts @@ -13,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use strict'; +import assert from "assert"; +import VersionNumber from "../../lib/types/version-number"; -const assert = require('assert'); -const VersionNumber = require('../../lib/types/version-number'); describe('VersionNumber', () => { describe('#parse()', () => { diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..fe67c029d --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "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, + "moduleResolution": "nodenext" + }, + "include": [ + "lib/**/*.ts", + "test/**/*.ts", + "index.ts" + ], + "exclude": [ + "node_modules" + ] + } \ No newline at end of file