Skip to content

Commit

Permalink
update typesrcipt support for 4x client
Browse files Browse the repository at this point in the history
  • Loading branch information
rpandian-spike committed Jul 5, 2022
1 parent 9b81383 commit 646793a
Show file tree
Hide file tree
Showing 24 changed files with 1,769 additions and 1,770 deletions.
61 changes: 37 additions & 24 deletions lib/aerospike.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
const as = require('bindings')('aerospike.node')
const AerospikeError = require('./error')
const EventLoop = require('./event_loop')
const utils = require('./utils')

/**
* @module aerospike
Expand Down Expand Up @@ -63,7 +62,6 @@ exp.type = as.exp.type
/**
* @summary POSIX regex compilation flags.
*
* @readonly
* @enum {number}
*
* @see {@link module:aerospike/predexp.stringRegex} for usage.
Expand Down Expand Up @@ -166,21 +164,22 @@ exp.operations = require('./exp_operations')
* @summary {@link module:aerospike/policy|aerospike/policy} module
* @static
*/
const policy = exports.policy = require('./policy')
exports.policy = require('./policy')

// short-cuts to the policy classes defined under the policy module
exports.ApplyPolicy = policy.ApplyPolicy
exports.BatchPolicy = policy.BatchPolicy
exports.CommandQueuePolicy = policy.CommandQueuePolicy
exports.InfoPolicy = policy.InfoPolicy
exports.ListPolicy = policy.ListPolicy
exports.MapPolicy = policy.MapPolicy
exports.OperatePolicy = policy.OperatePolicy
exports.QueryPolicy = policy.QueryPolicy
exports.ReadPolicy = policy.ReadPolicy
exports.RemovePolicy = policy.RemovePolicy
exports.ScanPolicy = policy.ScanPolicy
exports.WritePolicy = policy.WritePolicy
exports.BasePolicy = require('./policy').BasePolicy
exports.ApplyPolicy = require('./policy').ApplyPolicy
exports.BatchPolicy = require('./policy').BatchPolicy
exports.OperatePolicy = require('./policy').OperatePolicy
exports.QueryPolicy = require('./policy').QueryPolicy
exports.ReadPolicy = require('./policy').ReadPolicy
exports.RemovePolicy = require('./policy').RemovePolicy
exports.ScanPolicy = require('./policy').ScanPolicy
exports.WritePolicy = require('./policy').WritePolicy
exports.CommandQueuePolicy = require('./policy').CommandQueuePolicy
exports.InfoPolicy = require('./policy').InfoPolicy
exports.ListPolicy = require('./policy').ListPolicy
exports.MapPolicy = require('./policy').MapPolicy

/**
* The {@link module:aerospike/status|status} module contains a list of the
Expand Down Expand Up @@ -277,7 +276,6 @@ exports.Record = require('./record')
* Linux as well. External authentication can be used on macOS or Windows but
* it will _not_ be secure!
*
* @readonly
* @enum {number}
*
* @property {number} INTERNAL - Use internal authentication only. Hashed
Expand All @@ -292,6 +290,9 @@ exports.Record = require('./record')
* clear password on node login whether or not TLS is enabled. This mode
* should only be used for testing purposes because it is not secure
* authentication.
* @property {number} AUTH_PKI - Use PKI authentication.
* Authentication and authorization is based on a certificate. No user name or
* password needs to be configured. Requires mTLS and a client certificate.
*
* @example <caption>Using external authentication mode, e.g. to use LDAP authentication</caption>
*
Expand All @@ -303,6 +304,24 @@ exports.Record = require('./record')
* authMode: Aerospike.auth.EXTERNAL
* }
*
*
* @example <caption>Using PKI authentication mode</caption>
*
* const Aerospike = require('aerospike')
*
* const config = {
* hosts: [
* { addr: 'bob-cluster-a', port: process.env.PORT}
* ],
* tls: {
* cafile: process.env.CAFILE,
* keyfile: process.env.KEYFILE,
* certfile: process.env.CERT,
* }
* authMode: Aerospike.auth.AUTH_PKI,
* }
*
*
* Aerospike.connect(config).then(async (client) => {
* const info = await client.infoAny().then(Aerospike.info.parse)
* console.info(info)
Expand All @@ -314,7 +333,6 @@ exports.auth = as.auth
/**
* @summary Enumeration of UDF types.
*
* @readonly
* @enum {number}
*
* @property {number} LUA - Lua (only supported UDF type at the moment)
Expand All @@ -324,7 +342,6 @@ exports.language = as.language
/**
* @summary Enumeration of log levels
*
* @readonly
* @enum {number}
*
* @property {number} OFF - Turn off logging
Expand Down Expand Up @@ -364,7 +381,6 @@ exports.log = as.log
* @description Instead of specifying a TTL in seconds, you can set the TTL
* to one of these special values when creating or updating a record.
*
* @readonly
* @enum {number}
*
* @property {number} NAMESPACE_DEFAULT - Use the default TTL value for the
Expand Down Expand Up @@ -409,7 +425,6 @@ exports.ttl = as.ttl
/**
* @summary Enumeration of job status codes.
*
* @readonly
* @enum {number}
*
* @property {number} UNDEF - The job status is undefined. This is likely due to the
Expand All @@ -424,7 +439,6 @@ exports.jobStatus = as.jobStatus
/**
* @summary Enumeration of SI data types.
*
* @readonly
* @enum {number}
*
* @property {number} STRING - Values contained in the SI are strings.
Expand All @@ -438,7 +452,6 @@ exports.indexDataType = as.indexDataType
/**
* @summary Enumeration of SI types.
*
* @readonly
* @enum {number}
*
* @property {number} DEFAULT - Default SI type for bins
Expand All @@ -461,8 +474,8 @@ exports.indexType = as.indexType
// Functions
// ========================================================================

exports.print = utils.print
exports.releaseEventLoop = EventLoop.releaseEventLoop
exports.print = require('./utils').print
exports.releaseEventLoop = require('./event_loop').releaseEventLoop

const Client = exports.Client

Expand Down
10 changes: 5 additions & 5 deletions lib/bitwise.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ exports.resize = function (bin, size, flags = 0) {
*
* @param {string} bin - The name of the bin. The bin must contain a byte value.
* @param {number} offset - Offset in bytes.
* @param {buffer} value - Bytes to insert.
* @param {Buffer} value - Bytes to insert.
* @returns {BitwiseOperation} Operation that can be passed to the {@link Client#operate} command.
*/
exports.insert = function (bin, byteOffset, value) {
Expand Down Expand Up @@ -190,7 +190,7 @@ exports.remove = function (bin, byteOffset, byteSize) {
* @param {string} bin - The name of the bin. The bin must contain a byte value.
* @param {number} bitOffset - Offset in bits.
* @param {number} bitSize - Number of bits to set.
* @param {number | buffer} value - Value to set.
* @param {number | Buffer} value - Value to set.
* @returns {BitwiseOperation} Operation that can be passed to the {@link Client#operate} command.
*
* @throws TypeError unless value is an integer or a Buffer.
Expand Down Expand Up @@ -220,7 +220,7 @@ exports.set = function (bin, bitOffset, bitSize, value) {
* @param {string} bin - The name of the bin. The bin must contain a byte value.
* @param {number} bitOffset - Offset in bits.
* @param {number} bitSize - Number of bits.
* @param {buffer} value - Value.
* @param {Buffer} value - Value.
* @returns {BitwiseOperation} Operation that can be passed to the {@link Client#operate} command.
*/
exports.or = function (bin, bitOffset, bitSize, value) {
Expand All @@ -239,7 +239,7 @@ exports.or = function (bin, bitOffset, bitSize, value) {
* @param {string} bin - The name of the bin. The bin must contain a byte value.
* @param {number} bitOffset - Offset in bits.
* @param {number} bitSize - Number of bits.
* @param {buffer} value - Value.
* @param {Buffer} value - Value.
* @returns {BitwiseOperation} Operation that can be passed to the {@link Client#operate} command.
*/
exports.xor = function (bin, bitOffset, bitSize, value) {
Expand All @@ -258,7 +258,7 @@ exports.xor = function (bin, bitOffset, bitSize, value) {
* @param {string} bin - The name of the bin. The bin must contain a byte value.
* @param {number} bitOffset - Offset in bits.
* @param {number} bitSize - Number of bits.
* @param {buffer} value - Value.
* @param {Buffer} value - Value.
* @returns {BitwiseOperation} Operation that can be passed to the {@link Client#operate} command.
*/
exports.and = function (bin, bitOffset, bitSize, value) {
Expand Down
4 changes: 2 additions & 2 deletions lib/cdt_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class CdtContext {
* Retrieve expression type list/map from ctx or from type.
*
* @param {CdtContext} ctx, ctx value object.
* @param {exp.type} type, default expression type.
* @return {exp.type} expression type.
* @param {number} type, {@link exp.type} default expression type.
* @return {number} {@link exp.type} expression type.
*/
static getContextType (/* CdtContext */ctx, type) {
if (ctx != null) {
Expand Down
17 changes: 9 additions & 8 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,11 @@ Client.prototype.batchGet = function (keys, policy, callback) {
* This method allows different namespaces/bins to be requested for each key in
* the batch. This method requires server >= 3.6.0.
*
* @param {object[]} records - List of keys and bins to retrieve.
* @param {Key} records[].key - Key to retrieve.
* @param {object[]} records - {@link Record} List of keys and bins to retrieve.
* @param {number} records[].type - {@link Record#type} Batch type.
* @param {Key} records[].key - Record Key.
* @param {string[]} [records[].bins] - List of bins to retrieve.
* @param {boolean} [records[].read_all_bins] - Whether to retrieve all bins or
* @param {boolean} [records[].readAllBins] - Whether to retrieve all bins or
* just the meta data of the record. If true, ignore <code>bins</code> and read
* all bins; if false and <code>bins</code> is specified, read specified bins;
* if false and <code>bins</code> is not specified, read only record meta data
Expand Down Expand Up @@ -1346,7 +1347,7 @@ Client.prototype.incr = Client.prototype.add
* @param {object} bins - A record object used for specifying the fields to store.
* @param {object} [meta] - Meta data.
* @param {WritePolicy} [policy] - The Write Policy to use for this operation.
* @param {writeCallback} callback - The function to call when the operation completes with the result of the operation.
* @param {writeCallback} [callback] - The function to call when the operation completes with the result of the operation.
*
* @example
*
Expand Down Expand Up @@ -1416,7 +1417,7 @@ Client.prototype.query = function (ns, set, options) {
*
* @param {Key} key - The key of the record.
* @param {RemovePolicy} [policy] - The Remove Policy to use for this operation.
* @param {writeCallback} callback - The function to call when the operation completes with the results of the operation.
* @param {writeCallback} [callback] - The function to call when the operation completes with the results of the operation.
*
* @example
*
Expand Down Expand Up @@ -1513,7 +1514,7 @@ Client.prototype.select = function (key, bins, policy, callback) {
* specified, the value must be before the current time. Pass in 0 to delete
* all records in namespace/set regardless of last udpate time.
* @param {InfoPolicy} [policy] - The Info Policy to use for this operation.
* @param {doneCallback} callback - The function to call when the
* @param {doneCallback} [callback] - The function to call when the
* operation completes with the result of the operation.
*
* @see https://www.aerospike.com/docs/reference/info#truncate
Expand Down Expand Up @@ -1556,7 +1557,7 @@ Client.prototype.truncate = function (ns, set, beforeNanos, policy, callback) {
* and only supported scripting language for UDF modules at the moment; ref.
* {@link module:aerospike.language}.
* @param {InfoPolicy} [policy] - The Info Policy to use for this operation.
* @param {jobCallback} callback - The function to call when the
* @param {jobCallback} [callback] - The function to call when the
* operation completes with the result of the operation.
*
* @example
Expand Down Expand Up @@ -1648,7 +1649,7 @@ Client.prototype.stats = function () {
* @param {string} udfModule - The basename of the UDF module, without the
* local pathname but including the file extension (".lua").
* @param {InfoPolicy} [policy] - The Info Policy to use for this operation.
* @param {jobCallback} callback - The function to call when the
* @param {jobCallback} [callback] - The function to call when the
* operation completes which the result of the operation.
*
* @example
Expand Down
4 changes: 1 addition & 3 deletions lib/commands/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const AerospikeError = require('../error')
/**
* @class Command
* @classdesc Database command.
* @type Class
*/
module.exports = asCommand => class Command {
/** @private */
Expand All @@ -39,7 +40,6 @@ module.exports = asCommand => class Command {
*
* @name Command#client
* @type {Client}
* @readonly
*/
this.client = client

Expand All @@ -56,7 +56,6 @@ module.exports = asCommand => class Command {
*
* @name Command#captureStackTraces
* @type {boolean}
* @readonly
* @see {@link Client#captureStackTraces}
*/
this.captureStackTraces = client.captureStackTraces
Expand All @@ -66,7 +65,6 @@ module.exports = asCommand => class Command {
*
* @name Command#key
* @type {?Key}
* @readonly
*/
this.key = undefined

Expand Down
21 changes: 5 additions & 16 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ const policy = require('./policy')
const inspect = Symbol.for('nodejs.util.inspect.custom')

/**
* @class Config
* @classdesc config command.
* The Config class contains the settings for an Aerospike client
* instance, including the list of seed hosts, default policies, and other
* settings.
*
* @type Class
* @throws {TypeError} If invalid config values are passed.
*
* @example
Expand Down Expand Up @@ -250,7 +253,7 @@ class Config {
* you may find it beneficial to set the global {@link WritePolicy} in
* {@link Config#policies}, which all operations will use.
*
* @type {Config~Policies}
* @type {Policies}
*
* @example <caption>Setting a default <code>key</code> policy for all write operations</caption>
*
Expand Down Expand Up @@ -544,7 +547,7 @@ class Config {
/**
* Set default policies from the given policy values.
*
* @param {Config~Policies} one or more default policies
* @param {Policies} one or more default policies
* @throws {TypeError} if any of the properties of the policies object is not
* a valid policy type
*/
Expand All @@ -570,18 +573,4 @@ class Config {
}
}

/**
* @typedef {Object} Config~Policies
*
* @property {ApplyPolicy} apply - Default apply policy
* @property {BatchPolicy} batch - Default batch policy
* @property {InfoPolicy} info - Default info policy
* @property {OperatePolicy} operate - Default operate policy
* @property {ReadPolicy} read - Default read policy
* @property {RemovePolicy} remove - Default remove policy
* @property {ScanPolicy} scan - Default scan policy
* @property {QueryPolicy} query - Default query policy
* @property {WritePolicy} write - Default write policy
*/

module.exports = Config
Loading

0 comments on commit 646793a

Please sign in to comment.