From 2b77535ecb3ccf15ea351d3eb12f8c464bca5277 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 7 Jun 2022 17:28:34 -0700 Subject: [PATCH 01/28] re-creating an index with identical options returns an error (success with new server, verify the existence) --- test/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/index.js b/test/index.js index 4d8646397..7a013e14f 100644 --- a/test/index.js +++ b/test/index.js @@ -96,7 +96,7 @@ context('secondary indexes', function () { .then(() => verifyIndexExists(helper.namespace, testIndex.name)) }) - it('re-creating an index with identical options returns an error', function () { + it('re-creating an index with identical options returns an error (success with new server, verify the existence)', function () { const options = { ns: helper.namespace, set: helper.set, @@ -108,10 +108,11 @@ context('secondary indexes', function () { return client.createIndex(options) .then(job => job.wait(10)) .then(() => client.createIndex(options) - .then(job => Promise.reject(new Error('Recreating existing index should have returned an error'))) .catch(error => { - if (error.code === Aerospike.status.ERR_INDEX_FOUND) { + if (error.code === Aerospike.status.ERR_INDEX_FOUND || + error.code === Aerospike.status.AEROSPIKE_OK) { // All good! + verifyIndexExists(helper.namespace, testIndex.name) } else { return Promise.reject(error) } From c2066f775e9120423483ba0790eed8eda9e11468 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Fri, 10 Jun 2022 15:13:01 -0700 Subject: [PATCH 02/28] doc review update --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 011a9213a..5efc3bb78 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ install the latest stable version of Node.js, visit [nodejs.org](http://nodejs.org/) or use the version that comes bundled with your operating system. -Ensure to install necessary "development tools" and other libraries to build the client software. +Install the necessary "development tools" and other libraries to build the client software. Reference various docker files in the repository under the docker / directory for more information. @@ -143,10 +143,10 @@ sudo apt -y install wget libtool m4 automake #### Ubuntu -To install library prerequisites using `apt-get`: +To install library prerequisites using `apt`: ```bash -sudo apt-get install g++ libssl libssl-dev zlib1g-dev +sudo apt install g++ libssl libssl-dev zlib1g-dev ``` ### macOS (Intel) @@ -242,6 +242,8 @@ Run the following commands to build the C client: $ ./scripts/build-c-client.sh +#### Building and installing Node.js client + To install the module as a dependency of your application, run the following in the application directory: ```bash @@ -257,7 +259,7 @@ const Aerospike = require('aerospike') ## Documentation Access the client API documentation at: -[http://www.aerospike.com/apidocs/nodejs](https://www.aerospike.com/apidocs/nodejs). +[https://docs.aerospike.com/apidocs/nodejs](https://docs.aerospike.com/apidocs/nodejs). This documentation is built from the client's source using [JSDocs v3](http://usejsdoc.org/index.html) for every release. @@ -271,7 +273,7 @@ A variety of additional example applications are provided in the [`examples`](examples) directory of this repository. Access backward incompatible API changes by a release at: -https://www.aerospike.com/docs/client/nodejs/usage/incompatible.html. +https://developer.aerospike.com/client/nodejs/usage/incompatible. ### API Versioning From 25f926ebf85b7f41fd867de8971c669ca89e99dd Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Fri, 10 Jun 2022 15:45:57 -0700 Subject: [PATCH 03/28] disable windows github build action --- .github/workflows/windows-build.yml | 16 ++++++++-------- scripts/build-package.ps1 | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 303381f39..23aa05050 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -23,19 +23,19 @@ jobs: steps: - name: Set up Aerospike Database uses: reugn/github-action-aerospike@v1 - build: - needs: setup - runs-on: windows-latest # https://github.com/actions/virtual-environments - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive + # build: + # needs: setup + # runs-on: windows-latest # https://github.com/actions/virtual-environments + # steps: + # - uses: actions/checkout@v2 + # with: + # submodules: recursive # - name: Use Node.js 16.x # uses: actions/setup-node@v2 # with: # node-version: 16.x # cache: 'npm' - - run: ./scripts/build-package.ps1 1 + # - run: ./scripts/build-package.ps1 1 # test: # needs: build # runs-on: macos-latest diff --git a/scripts/build-package.ps1 b/scripts/build-package.ps1 index 19ae978f5..508c3c2e6 100644 --- a/scripts/build-package.ps1 +++ b/scripts/build-package.ps1 @@ -19,10 +19,10 @@ function build_nodejs_client { # node ${CWD}/node_modules/.bin/mocha --exit --U ${AS_USER} --P ${AS_PWD} --h ${AS_HOST} --port ${AS_PORT} --namespace ${AS_NAMESPACE} } -Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force -Invoke-WebRequest https://github.com/coreybutler/nvm-windows/releases/download/1.1.9/nvm-setup.exe -UseBasicParsing -OutFile .\nvm-setup.exe -.\nvm-setup.exe /VERYSILENT /SUPRESSMSGBOXES /SP -nvm root .\nvm +# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force +# Invoke-WebRequest https://github.com/coreybutler/nvm-windows/releases/download/1.1.9/nvm-setup.exe -UseBasicParsing -OutFile .\nvm-setup.exe +# .\nvm-setup.exe /VERYSILENT /SUPRESSMSGBOXES /SP +# nvm root .\nvm build_nodejs_client v10.20.0 build_nodejs_client v12.22.10 From 636c0beb9ffe82240fad2e737d5566e2ce02e737 Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 09:52:56 +0300 Subject: [PATCH 04/28] use different source of nvm for windows --- scripts/build-package.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/build-package.ps1 b/scripts/build-package.ps1 index 508c3c2e6..224079d47 100644 --- a/scripts/build-package.ps1 +++ b/scripts/build-package.ps1 @@ -24,6 +24,11 @@ function build_nodejs_client { # .\nvm-setup.exe /VERYSILENT /SUPRESSMSGBOXES /SP # nvm root .\nvm +cd $Env:USERPROFILE; +Invoke-WebRequest https://raw.githubusercontent.com/jchip/nvm/v1.5.4/install.ps1 -OutFile install.ps1; +.\install.ps1 -nvmhome $Env:USERPROFILE\nvm; +del install.ps1 + build_nodejs_client v10.20.0 build_nodejs_client v12.22.10 build_nodejs_client v14.19.0 From 42d8fed41e7340324d57f62d57b129a57cf61edb Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 09:57:49 +0300 Subject: [PATCH 05/28] new windows workflow --- .github/workflows/windows-build.yml | 17 ++++++++++------- scripts/build-package.ps1 | 4 ++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 23aa05050..d91345030 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -10,6 +10,7 @@ on: - maint/3.x - maint/4.x - gh-action + - win-workflow-new pull_request: branches: - master @@ -23,13 +24,15 @@ jobs: steps: - name: Set up Aerospike Database uses: reugn/github-action-aerospike@v1 - # build: - # needs: setup - # runs-on: windows-latest # https://github.com/actions/virtual-environments - # steps: - # - uses: actions/checkout@v2 - # with: - # submodules: recursive + + build: + needs: setup + runs-on: windows-latest # https://github.com/actions/virtual-environments + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + - run: ./scripts/build-package.ps1 1 # - name: Use Node.js 16.x # uses: actions/setup-node@v2 # with: diff --git a/scripts/build-package.ps1 b/scripts/build-package.ps1 index 224079d47..d302cc8dd 100644 --- a/scripts/build-package.ps1 +++ b/scripts/build-package.ps1 @@ -24,11 +24,15 @@ function build_nodejs_client { # .\nvm-setup.exe /VERYSILENT /SUPRESSMSGBOXES /SP # nvm root .\nvm +pwd + cd $Env:USERPROFILE; Invoke-WebRequest https://raw.githubusercontent.com/jchip/nvm/v1.5.4/install.ps1 -OutFile install.ps1; .\install.ps1 -nvmhome $Env:USERPROFILE\nvm; del install.ps1 +cd D:\a\aerospike-client-nodejs\aerospike-client-nodejs + build_nodejs_client v10.20.0 build_nodejs_client v12.22.10 build_nodejs_client v14.19.0 From 042d65a6e181e0cf663bc574ad4711e4096cabda Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:49:03 +0300 Subject: [PATCH 06/28] different windows build workflow --- .github/workflows/windows-build.yml | 36 ++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index d91345030..930153541 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -18,6 +18,7 @@ on: - maint/3.x - maint/4.x + jobs: setup: runs-on: ubuntu-latest @@ -26,25 +27,18 @@ jobs: uses: reugn/github-action-aerospike@v1 build: - needs: setup - runs-on: windows-latest # https://github.com/actions/virtual-environments + runs-on: windows-latest + strategy: + matrix: + node: [ 10, 12, 14, 16 ] + name: Node ${{ matrix.node }} sample steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - run: ./scripts/build-package.ps1 1 - # - name: Use Node.js 16.x - # uses: actions/setup-node@v2 - # with: - # node-version: 16.x - # cache: 'npm' - # - run: ./scripts/build-package.ps1 1 - # test: - # needs: build - # runs-on: macos-latest - # steps: - # - run: npm test - # env: - # AEROSPIKE_HOSTS: "127.0.0.1:3000" - # OPTIONS: "--timeout 30000" - # - run: npm run codecov + - uses: actions/checkout@v3 + with: + submodules: recursive + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: npm install --unsafe-perm --build-from-source + # - run: npm test From 4213332039370e36c64a025ead45dcf8cfada5a2 Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 10:57:27 +0300 Subject: [PATCH 07/28] node-gyp too old, update before build --- .github/workflows/windows-build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 930153541..61bada75d 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -40,5 +40,12 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} + - name: Update node-gyp + run: | + $WhereNode = Get-Command node | Select-Object -ExpandProperty Definition + $NodeDirPath = Split-Path $WhereNode -Parent + $NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\npm-lifecycle" + cd $NodeModulesPath + npm install node-gyp@8.x - run: npm install --unsafe-perm --build-from-source # - run: npm test From 880a37e4684f342539a33763781af5033516a522 Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 11:26:21 +0300 Subject: [PATCH 08/28] npm version distinction for node-gyp update --- .github/workflows/windows-build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 61bada75d..b2e186ffa 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -44,7 +44,12 @@ jobs: run: | $WhereNode = Get-Command node | Select-Object -ExpandProperty Definition $NodeDirPath = Split-Path $WhereNode -Parent - $NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\npm-lifecycle" + [Version]$npmVersion = npm --version + if ($npmVersion -lt [Version]"7.0") { + $NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\npm-lifecycle" + } else { + $NodeModulesPath = $NodeDirPath + "\node_modules\npm\node_modules\@npmcli\run-script" + } cd $NodeModulesPath npm install node-gyp@8.x - run: npm install --unsafe-perm --build-from-source From 3f50ebaa63783cbcfa17d9bfed85bc6d11b6a809 Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 12:10:22 +0300 Subject: [PATCH 09/28] use pwsh instead of powershell because of Get-FileHash issue --- .github/workflows/windows-build.yml | 4 +++- scripts/build-c-client.ps1 | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index b2e186ffa..4ffc6ed15 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -52,5 +52,7 @@ jobs: } cd $NodeModulesPath npm install node-gyp@8.x - - run: npm install --unsafe-perm --build-from-source + - name: Install nodejs Client + shell: pwsh + run: npm install --unsafe-perm --build-from-source # - run: npm test diff --git a/scripts/build-c-client.ps1 b/scripts/build-c-client.ps1 index 6a067236e..f4b271e4e 100644 --- a/scripts/build-c-client.ps1 +++ b/scripts/build-c-client.ps1 @@ -105,6 +105,14 @@ function Build-Project { return $process.ExitCode -eq 0 } +### DEBUG +Write-Host "DEBUG" +Write-Host($PSVersionTable | Out-String) +Write-Host(Get-command get-file* | Out-String) +Write-Host((get-filehash $PSHOME\powershell.exe).hash | Out-String) +Write-Host "END DEBUG" +### + $CClientCfg = Parse-IniFile $CClientIni Write-Debug ($CClientCfg | Out-String) $FileHashes = Parse-IniFile $FileHashesIni -sep " " -swap From ca46a5dc6ffd139cc481993feec94ddc6e061b93 Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 13:18:51 +0300 Subject: [PATCH 10/28] change to pwsh --- binding.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index 97125c32a..1d95cf7b3 100644 --- a/binding.gyp +++ b/binding.gyp @@ -40,7 +40,7 @@ 'aerospike-client-c-output/lib/aerospike.lib' ], 'action': [ - 'powershell', 'scripts/build-c-client.ps1', + 'pwsh', 'scripts/build-c-client.ps1', '-Configuration', "$(ConfigurationName)", '-NodeLibFile', "<(node_root_dir)/<(target_arch)/node.lib" ] From 5c9c129a2e382203f28a79bad767429a61178daa Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 15:44:20 +0300 Subject: [PATCH 11/28] Add SDK --- .github/workflows/windows-build.yml | 4 + scripts/Invoke-MsBuild.psm1 | 1397 ++++++++++++++------------- scripts/build-c-client.ps1 | 8 - 3 files changed, 711 insertions(+), 698 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 4ffc6ed15..6569a3f2f 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -36,6 +36,10 @@ jobs: - uses: actions/checkout@v3 with: submodules: recursive + - name: Setup Windows SDK + uses: GuillaumeFalourd/setup-windows10-sdk-action@v1.6 + with: + sdk-version: 17763 - name: Setup node uses: actions/setup-node@v3 with: diff --git a/scripts/Invoke-MsBuild.psm1 b/scripts/Invoke-MsBuild.psm1 index 5dd25b8de..90e649fc4 100644 --- a/scripts/Invoke-MsBuild.psm1 +++ b/scripts/Invoke-MsBuild.psm1 @@ -23,737 +23,754 @@ function Invoke-MsBuild { <# - .SYNOPSIS - Builds the given Visual Studio solution or project file using MsBuild. - - .DESCRIPTION - Executes the MsBuild.exe tool against the specified Visual Studio solution or project file. - Returns a hash table with properties for determining if the build succeeded or not, as well as other information (see the OUTPUTS section for list of properties). - If using the PathThru switch, the process running MsBuild is returned instead. - - .PARAMETER Path - The path of the Visual Studio solution or project to build (e.g. a .sln or .csproj file). - - .PARAMETER MsBuildParameters - Additional parameters to pass to the MsBuild command-line tool. This can be any valid MsBuild command-line parameters except for the path of - the solution/project to build. - - See http://msdn.microsoft.com/en-ca/library/vstudio/ms164311.aspx for valid MsBuild command-line parameters. - - .PARAMETER Use32BitMsBuild - If this switch is provided, the 32-bit version of MsBuild.exe will be used instead of the 64-bit version when both are available. - - .PARAMETER BuildLogDirectoryPath - The directory path to write the build log files to. - Defaults to putting the log files in the users temp directory (e.g. C:\Users\[User Name]\AppData\Local\Temp). - Use the keyword "PathDirectory" to put the log files in the same directory as the .sln or project file being built. - Two log files are generated: one with the complete build log, and one that contains only errors from the build. - - .PARAMETER LogVerbosity - If set, this will set the verbosity of the build log. Possible values are: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. - - .PARAMETER AutoLaunchBuildLogOnFailure - If set, this switch will cause the build log to automatically be launched into the default viewer if the build fails. - This log file contains all of the build output. - NOTE: This switch cannot be used with the PassThru switch. - - .PARAMETER AutoLaunchBuildErrorsLogOnFailure - If set, this switch will cause the build errors log to automatically be launched into the default viewer if the build fails. - This log file only contains errors from the build output. - NOTE: This switch cannot be used with the PassThru switch. - - .PARAMETER KeepBuildLogOnSuccessfulBuilds - If set, this switch will cause the MsBuild log file to not be deleted on successful builds; normally it is only kept around on failed builds. - NOTE: This switch cannot be used with the PassThru switch. - - .PARAMETER ShowBuildOutputInNewWindow - If set, this switch will cause a command prompt window to be shown in order to view the progress of the build. - By default the build output is not shown in any window. - NOTE: This switch cannot be used with the ShowBuildOutputInCurrentWindow switch. - - .PARAMETER ShowBuildOutputInCurrentWindow - If set, this switch will cause the build process to be started in the existing console window, instead of creating a new one. - By default the build output is not shown in any window. - NOTE: This switch will override the ShowBuildOutputInNewWindow switch. - NOTE: There is a problem with the -NoNewWindow parameter of the Start-Process cmdlet; this is used for the ShowBuildOutputInCurrentWindow switch. - The bug is that in some PowerShell consoles, the build output is not directed back to the console calling this function, so nothing is displayed. - To avoid the build process from appearing to hang, PromptForInputBeforeClosing only has an effect with ShowBuildOutputInCurrentWindow when running - in the default "ConsoleHost" PowerShell console window, as we know it works properly with that console (it does not in other consoles like ISE, PowerGUI, etc.). - - .PARAMETER PromptForInputBeforeClosing - If set, this switch will prompt the user for input after the build completes, and will not continue until the user presses a key. - NOTE: This switch only has an effect when used with the ShowBuildOutputInNewWindow and ShowBuildOutputInCurrentWindow switches (otherwise build output is not displayed). - NOTE: This switch cannot be used with the PassThru switch. - NOTE: The user will need to provide input before execution will return back to the calling script (so do not use this switch for automated builds). - NOTE: To avoid the build process from appearing to hang, PromptForInputBeforeClosing only has an effect with ShowBuildOutputInCurrentWindow when running - in the default "ConsoleHost" PowerShell console window, as we know it works properly with that console (it does not in other consoles like ISE, PowerGUI, etc.). - - .PARAMETER MsBuildFilePath - By default this script will locate and use the latest version of MsBuild.exe on the machine. - If you have MsBuild.exe in a non-standard location, or want to force the use of an older MsBuild.exe version, you may pass in the file path of the MsBuild.exe to use. - - .PARAMETER VisualStudioDeveloperCommandPromptFilePath - By default this script will locate and use the latest version of the Visual Studio Developer Command Prompt to run MsBuild. - If you installed Visual Studio in a non-standard location, or want to force the use of an older Visual Studio Command Prompt version, you may pass in the file path to - the Visual Studio Command Prompt to use. The filename is typically VsDevCmd.bat. - - .PARAMETER BypassVisualStudioDeveloperCommandPrompt - By default this script will locate and use the latest version of the Visual Studio Developer Command Prompt to run MsBuild. - The Visual Studio Developer Command Prompt loads additional variables and paths, so it is sometimes able to build project types that MsBuild cannot build by itself alone. - However, loading those additional variables and paths sometimes may have a performance impact, so this switch may be provided to bypass it and just use MsBuild directly. - - .PARAMETER PassThru - If set, this switch will cause the calling script not to wait until the build (launched in another process) completes before continuing execution. - Instead the build will be started in a new process and that process will immediately be returned, allowing the calling script to continue - execution while the build is performed, and also to inspect the process to see when it completes. - NOTE: This switch cannot be used with the AutoLaunchBuildLogOnFailure, AutoLaunchBuildErrorsLogOnFailure, KeepBuildLogOnSuccessfulBuilds, or PromptForInputBeforeClosing switches. - - .PARAMETER WhatIf - If set, the build will not actually be performed. - Instead it will just return the result hash table containing the file paths that would be created if the build is performed with the same parameters. - - .OUTPUTS - When the -PassThru switch is provided, the process being used to run MsBuild.exe is returned. - When the -PassThru switch is not provided, a hash table with the following properties is returned: - - BuildSucceeded = $true if the build passed, $false if the build failed, and $null if we are not sure. - BuildLogFilePath = The path to the build's log file. - BuildErrorsLogFilePath = The path to the build's error log file. - ItemToBuildFilePath = The item that MsBuild ran against. - CommandUsedToBuild = The full command that was used to invoke MsBuild. This can be useful for inspecting what parameters are passed to MsBuild.exe. - Message = A message describing any problems that were encoutered by Invoke-MsBuild. This is typically an empty string unless something went wrong. - MsBuildProcess = The process that was used to execute MsBuild.exe. - BuildDuration = The amount of time the build took to complete, represented as a TimeSpan. - - .EXAMPLE - $buildResult = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" - - if ($buildResult.BuildSucceeded -eq $true) - { - Write-Output ("Build completed successfully in {0:N1} seconds." -f $buildResult.BuildDuration.TotalSeconds) - } - elseif ($buildResult.BuildSucceeded -eq $false) - { - Write-Output ("Build failed after {0:N1} seconds. Check the build log file '$($buildResult.BuildLogFilePath)' for errors." -f $buildResult.BuildDuration.TotalSeconds) - } - elseif ($buildResult.BuildSucceeded -eq $null) - { - Write-Output "Unsure if build passed or failed: $($buildResult.Message)" - } - - Perform the default MsBuild actions on the Visual Studio solution to build the projects in it, and returns a hash table containing the results. - The PowerShell script will halt execution until MsBuild completes. - - .EXAMPLE - $process = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" -PassThru - - while (!$process.HasExited) - { - Write-Host "Solution is still buildling..." - Start-Sleep -Seconds 1 - } - - Perform the default MsBuild actions on the Visual Studio solution to build the projects in it. - The PowerShell script will not halt execution; instead it will return the process running MsBuild.exe back to the caller while the build is performed. - You can check the process's HasExited property to check if the build has completed yet or not. - - .EXAMPLE - if ((Invoke-MsBuild -Path $pathToSolution).BuildSucceeded -eq $true) - { - Write-Output "Build completed successfully." - } - - Perfom the build against the file specified at $pathToSolution and checks it for success in a single line. - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -MsBuildParameters "/target:Clean;Build" -ShowBuildOutputInNewWindow - - Cleans then Builds the given C# project. - A window displaying the output from MsBuild will be shown so the user can view the progress of the build without it polluting their current terminal window. - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInCurrentWindow - - Builds the given C# project and displays the output from MsBuild in the current terminal window. - - .EXAMPLE - Invoke-MsBuild -Path "C:\MySolution.sln" -Params "/target:Clean;Build /property:Configuration=Release;Platform=x64;BuildInParallel=true /verbosity:Detailed /maxcpucount" - - Cleans then Builds the given solution, specifying to build the project in parallel in the Release configuration for the x64 platform. - Here the shorter "Params" alias is used instead of the full "MsBuildParameters" parameter name. - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInNewWindow -PromptForInputBeforeClosing -AutoLaunchBuildLogOnFailure - - Builds the given C# project. - A window displaying the output from MsBuild will be shown so the user can view the progress of the build, and it will not close until the user - gives the window some input after the build completes. This function will also not return until the user gives the window some input, halting the powershell script execution. - If the build fails, the build log will automatically be opened in the default text viewer. - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath "C:\BuildLogs" -KeepBuildLogOnSuccessfulBuilds -AutoLaunchBuildErrorsLogOnFailure - - Builds the given C# project. - The build log will be saved in "C:\BuildLogs", and they will not be automatically deleted even if the build succeeds. - If the build fails, the build errors log will automatically be opened in the default text viewer. - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath PathDirectory - - Builds the given C# project. - The keyword 'PathDirectory' is used, so the build log will be saved in "C:\Some Folder\", which is the same directory as the project being built (i.e. directory specified in the Path). - - .EXAMPLE - Invoke-MsBuild -Path "C:\Database\Database.dbproj" -P "/t:Deploy /p:TargetDatabase=MyDatabase /p:TargetConnectionString=`"Data Source=DatabaseServerName`;Integrated Security=True`;Pooling=False`" /p:DeployToDatabase=True" - - Deploy the Visual Studio Database Project to the database "MyDatabase". - Here the shorter "P" alias is used instead of the full "MsBuildParameters" parameter name. - The shorter alias' of the MsBuild parameters are also used; "/t" instead of "/target", and "/p" instead of "/property". - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -WhatIf - - Returns the result hash table containing the same property values that would be created if the build was ran with the same parameters. - The BuildSucceeded property will be $null since no build will actually be invoked. - This will display all of the returned hash table's properties and their values. - - .EXAMPLE - Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" > $null - - Builds the given C# project, discarding the result hash table and not displaying its properties. - - .LINK - Project home: https://github.com/deadlydog/Invoke-MsBuild - - .NOTES - Name: Invoke-MsBuild - Author: Daniel Schroeder (originally based on the module at http://geekswithblogs.net/dwdii/archive/2011/05/27/part-2-automating-a-visual-studio-build-with-powershell.aspx) - Version: 2.6.0 + .SYNOPSIS + Builds the given Visual Studio solution or project file using MsBuild. + + .DESCRIPTION + Executes the MsBuild.exe tool against the specified Visual Studio solution or project file. + Returns a hash table with properties for determining if the build succeeded or not, as well as other information (see the OUTPUTS section for list of properties). + If using the PathThru switch, the process running MsBuild is returned instead. + + .PARAMETER Path + The path of the Visual Studio solution or project to build (e.g. a .sln or .csproj file). + + .PARAMETER MsBuildParameters + Additional parameters to pass to the MsBuild command-line tool. This can be any valid MsBuild command-line parameters except for the path of + the solution/project to build + + See http://msdn.microsoft.com/en-ca/library/vstudio/ms164311.aspx for valid MsBuild command-line parameters. + + .PARAMETER Use32BitMsBuild + If this switch is provided, the 32-bit version of MsBuild.exe will be used instead of the 64-bit version when both are available. + + .PARAMETER BuildLogDirectoryPath + The directory path to write the build log files to. + Defaults to putting the log files in the users temp directory (e.g. C:\Users\[User Name]\AppData\Local\Temp). + Use the keyword "PathDirectory" to put the log files in the same directory as the .sln or project file being built. + Two log files are generated: one with the complete build log, and one that contains only errors from the build. + + .PARAMETER LogVerbosity + If set, this will set the verbosity of the build log. Possible values are: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. + + .PARAMETER AutoLaunchBuildLogOnFailure + If set, this switch will cause the build log to automatically be launched into the default viewer if the build fails. + This log file contains all of the build output. + NOTE: This switch cannot be used with the PassThru switch. + + .PARAMETER AutoLaunchBuildErrorsLogOnFailure + If set, this switch will cause the build errors log to automatically be launched into the default viewer if the build fails. + This log file only contains errors from the build output. + NOTE: This switch cannot be used with the PassThru switch. + + .PARAMETER KeepBuildLogOnSuccessfulBuilds + If set, this switch will cause the MsBuild log file to not be deleted on successful builds; normally it is only kept around on failed builds. + NOTE: This switch cannot be used with the PassThru switch. + + .PARAMETER ShowBuildOutputInNewWindow + If set, this switch will cause a command prompt window to be shown in order to view the progress of the build. + By default the build output is not shown in any window. + NOTE: This switch cannot be used with the ShowBuildOutputInCurrentWindow switch. + + .PARAMETER ShowBuildOutputInCurrentWindow + If set, this switch will cause the build process to be started in the existing console window, instead of creating a new one. + By default the build output is not shown in any window. + NOTE: This switch will override the ShowBuildOutputInNewWindow switch. + NOTE: There is a problem with the -NoNewWindow parameter of the Start-Process cmdlet; this is used for the ShowBuildOutputInCurrentWindow switch. + The bug is that in some PowerShell consoles, the build output is not directed back to the console calling this function, so nothing is displayed. + To avoid the build process from appearing to hang, PromptForInputBeforeClosing only has an effect with ShowBuildOutputInCurrentWindow when running + in the default "ConsoleHost" PowerShell console window, as we know it works properly with that console (it does not in other consoles like ISE, PowerGUI, etc.). + + .PARAMETER PromptForInputBeforeClosing + If set, this switch will prompt the user for input after the build completes, and will not continue until the user presses a key. + NOTE: This switch only has an effect when used with the ShowBuildOutputInNewWindow and ShowBuildOutputInCurrentWindow switches (otherwise build output is not displayed). + NOTE: This switch cannot be used with the PassThru switch. + NOTE: The user will need to provide input before execution will return back to the calling script (so do not use this switch for automated builds). + NOTE: To avoid the build process from appearing to hang, PromptForInputBeforeClosing only has an effect with ShowBuildOutputInCurrentWindow when running + in the default "ConsoleHost" PowerShell console window, as we know it works properly with that console (it does not in other consoles like ISE, PowerGUI, etc.). + + .PARAMETER MsBuildFilePath + By default this script will locate and use the latest version of MsBuild.exe on the machine. + If you have MsBuild.exe in a non-standard location, or want to force the use of an older MsBuild.exe version, you may pass in the file path of the MsBuild.exe to use. + + .PARAMETER VisualStudioDeveloperCommandPromptFilePath + By default this script will locate and use the latest version of the Visual Studio Developer Command Prompt to run MsBuild. + If you installed Visual Studio in a non-standard location, or want to force the use of an older Visual Studio Command Prompt version, you may pass in the file path to + the Visual Studio Command Prompt to use. The filename is typically VsDevCmd.bat. + + .PARAMETER BypassVisualStudioDeveloperCommandPrompt + By default this script will locate and use the latest version of the Visual Studio Developer Command Prompt to run MsBuild. + The Visual Studio Developer Command Prompt loads additional variables and paths, so it is sometimes able to build project types that MsBuild cannot build by itself alone. + However, loading those additional variables and paths sometimes may have a performance impact, so this switch may be provided to bypass it and just use MsBuild directly. + + .PARAMETER PassThru + If set, this switch will cause the calling script not to wait until the build (launched in another process) completes before continuing execution. + Instead the build will be started in a new process and that process will immediately be returned, allowing the calling script to continue + execution while the build is performed, and also to inspect the process to see when it completes. + NOTE: This switch cannot be used with the AutoLaunchBuildLogOnFailure, AutoLaunchBuildErrorsLogOnFailure, KeepBuildLogOnSuccessfulBuilds, or PromptForInputBeforeClosing switches. + + .PARAMETER WhatIf + If set, the build will not actually be performed. + Instead it will just return the result hash table containing the file paths that would be created if the build is performed with the same parameters. + + .OUTPUTS + When the -PassThru switch is provided, the process being used to run MsBuild.exe is returned. + When the -PassThru switch is not provided, a hash table with the following properties is returned: + + BuildSucceeded = $true if the build passed, $false if the build failed, and $null if we are not sure. + BuildLogFilePath = The path to the build's log file. + BuildErrorsLogFilePath = The path to the build's error log file. + ItemToBuildFilePath = The item that MsBuild ran against. + CommandUsedToBuild = The full command that was used to invoke MsBuild. This can be useful for inspecting what parameters are passed to MsBuild.exe. + Message = A message describing any problems that were encountered by Invoke-MsBuild. This is typically an empty string unless something went wrong. + MsBuildProcess = The process that was used to execute MsBuild.exe. + BuildDuration = The amount of time the build took to complete, represented as a TimeSpan. + + .EXAMPLE + $buildResult = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" + + if ($buildResult.BuildSucceeded -eq $true) + { + Write-Output ("Build completed successfully in {0:N1} seconds." -f $buildResult.BuildDuration.TotalSeconds) + } + elseif ($buildResult.BuildSucceeded -eq $false) + { + Write-Output ("Build failed after {0:N1} seconds. Check the build log file '$($buildResult.BuildLogFilePath)' for errors." -f $buildResult.BuildDuration.TotalSeconds) + } + elseif ($null -eq $buildResult.BuildSucceeded) + { + Write-Output "Unsure if build passed or failed: $($buildResult.Message)" + } + + Perform the default MsBuild actions on the Visual Studio solution to build the projects in it, and returns a hash table containing the results. + The PowerShell script will halt execution until MsBuild completes. + + .EXAMPLE + $process = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" -PassThru + + while (!$process.HasExited) + { + Write-Host "Solution is still building..." + Start-Sleep -Seconds 1 + } + + Perform the default MsBuild actions on the Visual Studio solution to build the projects in it. + The PowerShell script will not halt execution; instead it will return the process running MsBuild.exe back to the caller while the build is performed. + You can check the process's HasExited property to check if the build has completed yet or not. + + .EXAMPLE + if ((Invoke-MsBuild -Path $pathToSolution).BuildSucceeded -eq $true) + { + Write-Output "Build completed successfully." + } + + Perform the build against the file specified at $pathToSolution and checks it for success in a single line. + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -MsBuildParameters "/target:Clean;Build" -ShowBuildOutputInNewWindow + + Cleans then Builds the given C# project. + A window displaying the output from MsBuild will be shown so the user can view the progress of the build without it polluting their current terminal window. + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInCurrentWindow + + Builds the given C# project and displays the output from MsBuild in the current terminal window. + + .EXAMPLE + Invoke-MsBuild -Path "C:\MySolution.sln" -Params "/target:Clean;Build /property:Configuration=Release;Platform=x64;BuildInParallel=true /verbosity:Detailed /maxcpucount" + + Cleans then Builds the given solution, specifying to build the project in parallel in the Release configuration for the x64 platform. + Here the shorter "Params" alias is used instead of the full "MsBuildParameters" parameter name. + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInNewWindow -PromptForInputBeforeClosing -AutoLaunchBuildLogOnFailure + + Builds the given C# project. + A window displaying the output from MsBuild will be shown so the user can view the progress of the build, and it will not close until the user + gives the window some input after the build completes. This function will also not return until the user gives the window some input, halting the powershell script execution. + If the build fails, the build log will automatically be opened in the default text viewer. + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath "C:\BuildLogs" -KeepBuildLogOnSuccessfulBuilds -AutoLaunchBuildErrorsLogOnFailure + + Builds the given C# project. + The build log will be saved in "C:\BuildLogs", and they will not be automatically deleted even if the build succeeds. + If the build fails, the build errors log will automatically be opened in the default text viewer. + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath PathDirectory + + Builds the given C# project. + The keyword 'PathDirectory' is used, so the build log will be saved in "C:\Some Folder\", which is the same directory as the project being built (i.e. directory specified in the Path). + + .EXAMPLE + Invoke-MsBuild -Path "C:\Database\Database.dbproj" -P "/t:Deploy /p:TargetDatabase=MyDatabase /p:TargetConnectionString=`"Data Source=DatabaseServerName`;Integrated Security=True`;Pooling=False`" /p:DeployToDatabase=True" + + Deploy the Visual Studio Database Project to the database "MyDatabase". + Here the shorter "P" alias is used instead of the full "MsBuildParameters" parameter name. + The shorter alias' of the MsBuild parameters are also used; "/t" instead of "/target", and "/p" instead of "/property". + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -WhatIf + + Returns the result hash table containing the same property values that would be created if the build was ran with the same parameters. + The BuildSucceeded property will be $null since no build will actually be invoked. + This will display all of the returned hash table's properties and their values. + + .EXAMPLE + Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" > $null + + Builds the given C# project, discarding the result hash table and not displaying its properties. + + .LINK + Project home: https://github.com/deadlydog/Invoke-MsBuild + + .NOTES + Name: Invoke-MsBuild + Author: Daniel Schroeder (originally based on the module at http://geekswithblogs.net/dwdii/archive/2011/05/27/part-2-automating-a-visual-studio-build-with-powershell.aspx) + Version: 2.7.1 #> - [CmdletBinding(DefaultParameterSetName="Wait")] - param - ( - [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,HelpMessage="The path to the file to build with MsBuild (e.g. a .sln or .csproj file).")] - [ValidateScript({Test-Path -Path $_ -PathType Leaf})] - [string] $Path, - - [parameter(Mandatory=$false)] - [Alias("Parameters","Params","P")] - [string] $MsBuildParameters, - - [parameter(Mandatory=$false)] - [switch] $Use32BitMsBuild, - - [parameter(Mandatory=$false,HelpMessage="The directory path to write the build log file to. Use the keyword 'PathDirectory' to put the log file in the same directory as the .sln or project file being built.")] - [ValidateNotNullOrEmpty()] - [Alias("LogDirectory","L")] - [string] $BuildLogDirectoryPath = $env:Temp, - - [parameter(Mandatory=$false)] - [ValidateSet('q','quiet','m','minimal','n','normal','d','detailed','diag','diagnostic')] - [string] $LogVerbosityLevel = 'normal', - - [parameter(Mandatory=$false,ParameterSetName="Wait")] - [ValidateNotNullOrEmpty()] - [switch] $AutoLaunchBuildLogOnFailure, - - [parameter(Mandatory=$false,ParameterSetName="Wait")] - [ValidateNotNullOrEmpty()] - [switch] $AutoLaunchBuildErrorsLogOnFailure, - - [parameter(Mandatory=$false,ParameterSetName="Wait")] - [ValidateNotNullOrEmpty()] - [switch] $KeepBuildLogOnSuccessfulBuilds, - - [parameter(Mandatory=$false)] - [Alias("ShowBuildWindow")] - [switch] $ShowBuildOutputInNewWindow, - - [parameter(Mandatory=$false)] - [switch] $ShowBuildOutputInCurrentWindow, - - [parameter(Mandatory=$false,ParameterSetName="Wait")] - [switch] $PromptForInputBeforeClosing, - - [parameter(Mandatory=$false)] - [ValidateScript({Test-Path -Path $_ -PathType Leaf})] - [string] $MsBuildFilePath, - - [parameter(Mandatory=$false)] - [ValidateScript({Test-Path -Path $_ -PathType Leaf})] - [string] $VisualStudioDeveloperCommandPromptFilePath, - - [parameter(Mandatory=$false)] - [switch] $BypassVisualStudioDeveloperCommandPrompt, - - [parameter(Mandatory=$false,ParameterSetName="PassThru")] - [switch] $PassThru, - - [parameter(Mandatory=$false)] - [switch] $WhatIf - ) - - BEGIN { } - END { } - PROCESS - { - # Turn on Strict Mode to help catch syntax-related errors. - # This must come after a script's/function's param section. - # Forces a function to be the first non-comment code to appear in a PowerShell Script/Module. - Set-StrictMode -Version Latest - - # Ignore cultural differences. This is so that when reading version numbers it does not change the '.' to ',' when the OS's language/culture is not English. - [System.Threading.Thread]::CurrentThread.CurrentCulture = [CultureInfo]::InvariantCulture - - # Default the ParameterSet variables that may not have been set depending on which parameter set is being used. This is required for PowerShell v2.0 compatibility. - if (!(Test-Path Variable:Private:AutoLaunchBuildLogOnFailure)) { $AutoLaunchBuildLogOnFailure = $false } - if (!(Test-Path Variable:Private:AutoLaunchBuildLogOnFailure)) { $AutoLaunchBuildErrorsLogOnFailure = $false } - if (!(Test-Path Variable:Private:KeepBuildLogOnSuccessfulBuilds)) { $KeepBuildLogOnSuccessfulBuilds = $false } - if (!(Test-Path Variable:Private:PromptForInputBeforeClosing)) { $PromptForInputBeforeClosing = $false } - if (!(Test-Path Variable:Private:PassThru)) { $PassThru = $false } - - # If the keyword was supplied, place the log in the same folder as the solution/project being built. - if ($BuildLogDirectoryPath.Equals("PathDirectory", [System.StringComparison]::InvariantCultureIgnoreCase)) - { - $BuildLogDirectoryPath = [System.IO.Path]::GetDirectoryName($Path) - } - - # Always get the full path to the Log files directory. - $BuildLogDirectoryPath = [System.IO.Path]::GetFullPath($BuildLogDirectoryPath) - - # Local Variables. - $solutionFileName = (Get-ItemProperty -Path $Path).Name - $buildLogFilePath = (Join-Path -Path $BuildLogDirectoryPath -ChildPath $solutionFileName) + ".msbuild.log" - $buildErrorsLogFilePath = (Join-Path -Path $BuildLogDirectoryPath -ChildPath $solutionFileName) + ".msbuild.errors.log" - $windowStyleOfNewWindow = if ($ShowBuildOutputInNewWindow) { "Normal" } else { "Hidden" } - - # Build our hash table that will be returned. - $result = @{} - $result.BuildSucceeded = $null - $result.BuildLogFilePath = $buildLogFilePath - $result.BuildErrorsLogFilePath = $buildErrorsLogFilePath - $result.ItemToBuildFilePath = $Path - $result.CommandUsedToBuild = [string]::Empty - $result.Message = [string]::Empty - $result.MsBuildProcess = $null - $result.BuildDuration = [TimeSpan]::Zero - - # Try and build the solution. - try - { - # Get the verbosity to use for the MsBuild log file. - $verbosityLevel = switch ($LogVerbosityLevel) { - { ($_ -eq "q") -or ($_ -eq "quiet") -or ` - ($_ -eq "m") -or ($_ -eq "minimal") -or ` - ($_ -eq "n") -or ($_ -eq "normal") -or ` - ($_ -eq "d") -or ($_ -eq "detailed") -or ` - ($_ -eq "diag") -or ($_ -eq "diagnostic") } { ";verbosity=$_" ;break } - default { "" } - } - - # Build the arguments to pass to MsBuild. - $buildArguments = """$Path"" $MsBuildParameters /fileLoggerParameters:LogFile=""$buildLogFilePath""$verbosityLevel /fileLoggerParameters1:LogFile=""$buildErrorsLogFilePath"";errorsonly" - - # If the user hasn't set the UseSharedCompilation mode explicitly, turn it off (it's on by default, but can cause MsBuild to hang for some reason). - if ($buildArguments -notlike '*UseSharedCompilation*') - { - $buildArguments += " /p:UseSharedCompilation=false " # prevent processes from hanging (Roslyn compiler?) - } - - # Get the path to the MsBuild executable. - $msBuildPath = $MsBuildFilePath - [bool] $msBuildPathWasNotProvided = [string]::IsNullOrEmpty($msBuildPath) - if ($msBuildPathWasNotProvided) - { - $msBuildPath = Get-LatestMsBuildPath -Use32BitMsBuild:$Use32BitMsBuild - } - - # If we plan on trying to use the VS Command Prompt, we'll need to get the path to it. - [bool] $vsCommandPromptPathWasFound = $false - if (!$BypassVisualStudioDeveloperCommandPrompt) - { - # Get the path to the Visual Studio Developer Command Prompt file. - $vsCommandPromptPath = $VisualStudioDeveloperCommandPromptFilePath - [bool] $vsCommandPromptPathWasNotProvided = [string]::IsNullOrEmpty($vsCommandPromptPath) - if ($vsCommandPromptPathWasNotProvided) - { - $vsCommandPromptPath = Get-LatestVisualStudioCommandPromptPath - } - $vsCommandPromptPathWasFound = ![string]::IsNullOrEmpty($vsCommandPromptPath) - } - - # If we should use the VS Command Prompt, call MsBuild from that since it sets environmental variables that may be needed to build some projects types (e.g. XNA). - $useVsCommandPrompt = !$BypassVisualStudioDeveloperCommandPrompt -and $vsCommandPromptPathWasFound - if ($useVsCommandPrompt) - { - $cmdArgumentsToRunMsBuild = "/k "" ""$vsCommandPromptPath"" & ""$msBuildPath"" " - } - # Else we won't be using the VS Command Prompt, so just build using MsBuild directly. - else - { - $cmdArgumentsToRunMsBuild = "/k "" ""$msBuildPath"" " - } - - # Append the MsBuild arguments to pass into cmd.exe in order to do the build. - $cmdArgumentsToRunMsBuild += "$buildArguments " - - # If necessary, add a pause to wait for input before exiting the cmd.exe window. - # No pausing allowed when using PassThru or not showing the build output. - # The -NoNewWindow parameter of Start-Process does not behave correctly in the ISE and other PowerShell hosts (doesn't display any build output), - # so only allow it if in the default PowerShell host, since we know that one works. - $pauseForInput = [string]::Empty - if ($PromptForInputBeforeClosing -and !$PassThru ` - -and ($ShowBuildOutputInNewWindow -or ($ShowBuildOutputInCurrentWindow -and $Host.Name -eq "ConsoleHost"))) - { $pauseForInput = "Pause & " } - $cmdArgumentsToRunMsBuild += "& $pauseForInput Exit"" " - - # Record the exact command used to perform the build to make it easier to troubleshoot issues with builds. - $result.CommandUsedToBuild = "cmd.exe $cmdArgumentsToRunMsBuild" - - # If we don't actually want to perform a build, return . - if ($WhatIf) - { - $result.BuildSucceeded = $null - $result.Message = "The '-WhatIf' switch was specified, so a build was not invoked." - return $result - } - - Write-Debug "Starting new cmd.exe process with arguments ""$cmdArgumentsToRunMsBuild""." - - # Perform the build. - if ($PassThru) - { - if ($ShowBuildOutputInCurrentWindow) - { - return Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -NoNewWindow -PassThru - } - else - { - return Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -WindowStyle $windowStyleOfNewWindow -PassThru - } - } - else - { - $performBuildScriptBlock = - { - if ($ShowBuildOutputInCurrentWindow) - { - $result.MsBuildProcess = Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -NoNewWindow -Wait -PassThru - } - else - { - $result.MsBuildProcess = Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -WindowStyle $windowStyleOfNewWindow -Wait -PassThru - } - } - - # Perform the build and record how long it takes. - $result.BuildDuration = (Measure-Command -Expression $performBuildScriptBlock) - } - } - # If the build crashed, return that the build didn't succeed. - catch - { - $errorMessage = $_ - $result.Message = "Unexpected error occurred while building ""$Path"": $errorMessage" - $result.BuildSucceeded = $false - - Write-Error ($result.Message) - return $result - } - - # If we can't find the build's log file in order to inspect it, write a warning and return null. - if (!(Test-Path -Path $buildLogFilePath)) - { - $result.BuildSucceeded = $null - $result.Message = "Cannot find the build log file at '$buildLogFilePath', so unable to determine if build succeeded or not." - - Write-Warning ($result.Message) - return $result - } - - # Get if the build succeeded or not. - [bool] $buildOutputDoesNotContainFailureMessage = (Select-String -Path $buildLogFilePath -Pattern "Build FAILED." -SimpleMatch) -eq $null - [bool] $buildReturnedSuccessfulExitCode = $result.MsBuildProcess.ExitCode -eq 0 - $buildSucceeded = $buildOutputDoesNotContainFailureMessage -and $buildReturnedSuccessfulExitCode - - # If the build succeeded. - if ($buildSucceeded) - { - $result.BuildSucceeded = $true - - # If we shouldn't keep the log files around, delete them. - if (!$KeepBuildLogOnSuccessfulBuilds) - { - if (Test-Path $buildLogFilePath -PathType Leaf) { Remove-Item -Path $buildLogFilePath -Force } - if (Test-Path $buildErrorsLogFilePath -PathType Leaf) { Remove-Item -Path $buildErrorsLogFilePath -Force } - } - } - # Else at least one of the projects failed to build. - else - { - $result.BuildSucceeded = $false - $result.Message = "FAILED to build ""$Path"". Please check the build log ""$buildLogFilePath"" for details." - - # Write the error message as a warning. - Write-Warning ($result.Message) - - # If we should show the build logs automatically, open them with the default viewer. - if($AutoLaunchBuildLogOnFailure) - { - Open-BuildLogFileWithDefaultProgram -FilePathToOpen $buildLogFilePath -Result ([ref]$result) - } - if($AutoLaunchBuildErrorsLogOnFailure) - { - Open-BuildLogFileWithDefaultProgram -FilePathToOpen $buildErrorsLogFilePath -Result ([ref]$result) - } - } - - # Return the results of the build. - return $result - } + [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName="Wait")] + param + ( + [parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,HelpMessage="The path to the file to build with MsBuild (e.g. a .sln or .csproj file).")] + [ValidateScript({Test-Path -LiteralPath $_ -PathType Leaf})] + [string] $Path, + + [parameter(Mandatory=$false)] + [Alias("Parameters","Params","P")] + [string] $MsBuildParameters, + + [parameter(Mandatory=$false)] + [switch] $Use32BitMsBuild, + + [parameter(Mandatory=$false,HelpMessage="The directory path to write the build log file to. Use the keyword 'PathDirectory' to put the log file in the same directory as the .sln or project file being built.")] + [ValidateNotNullOrEmpty()] + [Alias("LogDirectory","L")] + [string] $BuildLogDirectoryPath = $env:Temp, + + [parameter(Mandatory=$false)] + [ValidateSet('q','quiet','m','minimal','n','normal','d','detailed','diag','diagnostic')] + [string] $LogVerbosityLevel = 'normal', + + [parameter(Mandatory=$false,ParameterSetName="Wait")] + [ValidateNotNullOrEmpty()] + [switch] $AutoLaunchBuildLogOnFailure, + + [parameter(Mandatory=$false,ParameterSetName="Wait")] + [ValidateNotNullOrEmpty()] + [switch] $AutoLaunchBuildErrorsLogOnFailure, + + [parameter(Mandatory=$false,ParameterSetName="Wait")] + [ValidateNotNullOrEmpty()] + [switch] $KeepBuildLogOnSuccessfulBuilds, + + [parameter(Mandatory=$false)] + [Alias("ShowBuildWindow")] + [switch] $ShowBuildOutputInNewWindow, + + [parameter(Mandatory=$false)] + [switch] $ShowBuildOutputInCurrentWindow, + + [parameter(Mandatory=$false,ParameterSetName="Wait")] + [switch] $PromptForInputBeforeClosing, + + [parameter(Mandatory=$false)] + [ValidateScript({Test-Path -LiteralPath $_ -PathType Leaf})] + [string] $MsBuildFilePath, + + [parameter(Mandatory=$false)] + [ValidateScript({Test-Path -LiteralPath $_ -PathType Leaf})] + [string] $VisualStudioDeveloperCommandPromptFilePath, + + [parameter(Mandatory=$false)] + [switch] $BypassVisualStudioDeveloperCommandPrompt, + + [parameter(Mandatory=$false,ParameterSetName="PassThru")] + [switch] $PassThru + ) + + BEGIN { } + END { } + PROCESS + { + # Turn on Strict Mode to help catch syntax-related errors. + # This must come after a script's/function's param section. + # Forces a function to be the first non-comment code to appear in a PowerShell Script/Module. + Set-StrictMode -Version Latest + + # Ignore cultural differences. This is so that when reading version numbers it does not change the '.' to ',' when the OS's language/culture is not English. + [System.Threading.Thread]::CurrentThread.CurrentCulture = [CultureInfo]::InvariantCulture + + # Default the ParameterSet variables that may not have been set depending on which parameter set is being used. This is required for PowerShell v2.0 compatibility. + if (!(Test-Path Variable:Private:AutoLaunchBuildLogOnFailure)) { $AutoLaunchBuildLogOnFailure = $false } + if (!(Test-Path Variable:Private:AutoLaunchBuildErrorsLogOnFailure)) { $AutoLaunchBuildErrorsLogOnFailure = $false } + if (!(Test-Path Variable:Private:KeepBuildLogOnSuccessfulBuilds)) { $KeepBuildLogOnSuccessfulBuilds = $false } + if (!(Test-Path Variable:Private:PromptForInputBeforeClosing)) { $PromptForInputBeforeClosing = $false } + if (!(Test-Path Variable:Private:PassThru)) { $PassThru = $false } + + # If the keyword was supplied, place the log in the same folder as the solution/project being built. + if ($BuildLogDirectoryPath.Equals("PathDirectory", [System.StringComparison]::InvariantCultureIgnoreCase)) + { + $BuildLogDirectoryPath = [System.IO.Path]::GetDirectoryName($Path) + } + + # Always get the full path to the Log files directory. + $BuildLogDirectoryPath = [System.IO.Path]::GetFullPath($BuildLogDirectoryPath) + + # Local Variables. + $solutionFileName = (Get-ItemProperty -LiteralPath $Path).Name + $buildLogFilePath = (Join-Path -Path $BuildLogDirectoryPath -ChildPath $solutionFileName) + ".msbuild.log" + $buildErrorsLogFilePath = (Join-Path -Path $BuildLogDirectoryPath -ChildPath $solutionFileName) + ".msbuild.errors.log" + $windowStyleOfNewWindow = if ($ShowBuildOutputInNewWindow) { "Normal" } else { "Hidden" } + + # Build our hash table that will be returned. + $result = @{} + $result.BuildSucceeded = $null + $result.BuildLogFilePath = $buildLogFilePath + $result.BuildErrorsLogFilePath = $buildErrorsLogFilePath + $result.ItemToBuildFilePath = $Path + $result.CommandUsedToBuild = [string]::Empty + $result.Message = [string]::Empty + $result.MsBuildProcess = $null + $result.BuildDuration = [TimeSpan]::Zero + + # Try and build the solution. + try + { + # Get the verbosity to use for the MsBuild log file. + $verbosityLevel = switch ($LogVerbosityLevel) { + { ($_ -eq "q") -or ($_ -eq "quiet") -or ` + ($_ -eq "m") -or ($_ -eq "minimal") -or ` + ($_ -eq "n") -or ($_ -eq "normal") -or ` + ($_ -eq "d") -or ($_ -eq "detailed") -or ` + ($_ -eq "diag") -or ($_ -eq "diagnostic") } { ";verbosity=$_" ;break } + default { "" } + } + + # Build the arguments to pass to MsBuild. + $buildArguments = """$Path"" $MsBuildParameters /fileLoggerParameters:LogFile=""$buildLogFilePath""$verbosityLevel /fileLoggerParameters1:LogFile=""$buildErrorsLogFilePath"";errorsonly" + + # Get the path to the MsBuild executable. + $msBuildPath = $MsBuildFilePath + [bool] $msBuildPathWasNotProvided = [string]::IsNullOrEmpty($msBuildPath) + if ($msBuildPathWasNotProvided) + { + $msBuildPath = Get-LatestMsBuildPath -Use32BitMsBuild:$Use32BitMsBuild + } + + # If we plan on trying to use the VS Command Prompt, we'll need to get the path to it. + [bool] $vsCommandPromptPathWasFound = $false + if (!$BypassVisualStudioDeveloperCommandPrompt) + { + # Get the path to the Visual Studio Developer Command Prompt file. + $vsCommandPromptPath = $VisualStudioDeveloperCommandPromptFilePath + [bool] $vsCommandPromptPathWasNotProvided = [string]::IsNullOrEmpty($vsCommandPromptPath) + if ($vsCommandPromptPathWasNotProvided) + { + $vsCommandPromptPath = Get-LatestVisualStudioCommandPromptPath + } + $vsCommandPromptPathWasFound = ![string]::IsNullOrEmpty($vsCommandPromptPath) + } + + # If we should use the VS Command Prompt, call MsBuild from that since it sets environmental variables that may be needed to build some projects types (e.g. XNA). + $useVsCommandPrompt = !$BypassVisualStudioDeveloperCommandPrompt -and $vsCommandPromptPathWasFound + if ($useVsCommandPrompt) + { + $cmdArgumentsToRunMsBuild = "/k "" ""$vsCommandPromptPath"" & ""$msBuildPath"" " + } + # Else we won't be using the VS Command Prompt, so just build using MsBuild directly. + else + { + $cmdArgumentsToRunMsBuild = "/k "" ""$msBuildPath"" " + } + + # Append the MsBuild arguments to pass into cmd.exe in order to do the build. + $cmdArgumentsToRunMsBuild += "$buildArguments " + + # If necessary, add a pause to wait for input before exiting the cmd.exe window. + # No pausing allowed when using PassThru or not showing the build output. + # The -NoNewWindow parameter of Start-Process does not behave correctly in the ISE and other PowerShell hosts (doesn't display any build output), + # so only allow it if in the default PowerShell host, since we know that one works. + $pauseForInput = [string]::Empty + if ($PromptForInputBeforeClosing -and !$PassThru ` + -and ($ShowBuildOutputInNewWindow -or ($ShowBuildOutputInCurrentWindow -and $Host.Name -eq "ConsoleHost"))) + { $pauseForInput = "Pause & " } + $cmdArgumentsToRunMsBuild += "& $pauseForInput Exit"" " + + # Record the exact command used to perform the build to make it easier to troubleshoot issues with builds. + $result.CommandUsedToBuild = "cmd.exe $cmdArgumentsToRunMsBuild" + + # If we don't actually want to perform a build (i.e. the -WhatIf parameter was specified), return the object without actually doing the build. + if (!($pscmdlet.ShouldProcess($result.ItemToBuildFilePath, 'MsBuild'))) + { + $result.BuildSucceeded = $null + $result.Message = "The '-WhatIf' switch was specified, so a build was not invoked." + return $result + } + + Write-Debug "Starting new cmd.exe process with arguments ""$cmdArgumentsToRunMsBuild""." + + # Perform the build. + if ($PassThru) + { + if ($ShowBuildOutputInCurrentWindow) + { + return Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -NoNewWindow -PassThru + } + else + { + return Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -WindowStyle $windowStyleOfNewWindow -PassThru + } + } + else + { + $performBuildScriptBlock = + { + if ($ShowBuildOutputInCurrentWindow) + { + $result.MsBuildProcess = Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -NoNewWindow -PassThru + } + else + { + $result.MsBuildProcess = Start-Process cmd.exe -ArgumentList $cmdArgumentsToRunMsBuild -WindowStyle $windowStyleOfNewWindow -PassThru + } + + Wait-Process -InputObject $result.MsBuildProcess + } + + # Perform the build and record how long it takes. + $result.BuildDuration = (Measure-Command -Expression $performBuildScriptBlock) + } + } + # If the build crashed, return that the build didn't succeed. + catch + { + $errorMessage = $_ + $result.Message = "Unexpected error occurred while building ""$Path"": $errorMessage" + $result.BuildSucceeded = $false + + Write-Error ($result.Message) + return $result + } + + # If we can't find the build's log file in order to inspect it, write a warning and return null. + if (!(Test-Path -LiteralPath $buildLogFilePath -PathType Leaf)) + { + $result.BuildSucceeded = $null + $result.Message = "Cannot find the build log file at '$buildLogFilePath', so unable to determine if build succeeded or not." + + Write-Warning ($result.Message) + return $result + } + + # Get if the build succeeded or not. + [bool] $buildOutputDoesNotContainFailureMessage = $null -eq (Select-String -Path $buildLogFilePath -Pattern "Build FAILED." -SimpleMatch) + [bool] $buildReturnedSuccessfulExitCode = $result.MsBuildProcess.ExitCode -eq 0 + $buildSucceeded = $buildOutputDoesNotContainFailureMessage -and $buildReturnedSuccessfulExitCode + + # If the build succeeded. + if ($buildSucceeded) + { + $result.BuildSucceeded = $true + + # If we shouldn't keep the log files around, delete them. + if (!$KeepBuildLogOnSuccessfulBuilds) + { + if (Test-Path -LiteralPath $buildLogFilePath -PathType Leaf) { Remove-Item -LiteralPath $buildLogFilePath -Force } + if (Test-Path -LiteralPath $buildErrorsLogFilePath -PathType Leaf) { Remove-Item -LiteralPath $buildErrorsLogFilePath -Force } + } + } + # Else at least one of the projects failed to build. + else + { + $result.BuildSucceeded = $false + $result.Message = "FAILED to build ""$Path"". Please check the build log ""$buildLogFilePath"" for details." + + # Write the error message as a warning. + Write-Warning ($result.Message) + + # If we should show the build logs automatically, open them with the default viewer. + if($AutoLaunchBuildLogOnFailure) + { + Open-BuildLogFileWithDefaultProgram -FilePathToOpen $buildLogFilePath -Result ([ref]$result) + } + if($AutoLaunchBuildErrorsLogOnFailure) + { + Open-BuildLogFileWithDefaultProgram -FilePathToOpen $buildErrorsLogFilePath -Result ([ref]$result) + } + } + + # Return the results of the build. + return $result + } } function Open-BuildLogFileWithDefaultProgram([string]$FilePathToOpen, [ref]$Result) { - if (Test-Path -Path $FilePathToOpen -PathType Leaf) - { - Start-Process -verb "Open" $FilePathToOpen - } - else - { - $message = "Could not auto-launch the build log because the expected file does not exist at '$FilePathToOpen'." - $Result.Message += [System.Environment]::NewLine + $message - Write-Warning $message - } + if (Test-Path -LiteralPath $FilePathToOpen -PathType Leaf) + { + Start-Process -verb "Open" $FilePathToOpen + } + else + { + $message = "Could not auto-launch the build log because the expected file does not exist at '$FilePathToOpen'." + $Result.Message += [System.Environment]::NewLine + $message + Write-Warning $message + } } function Get-LatestVisualStudioCommandPromptPath { <# - .SYNOPSIS - Gets the file path to the latest Visual Studio Command Prompt. Returns $null if a path is not found. - - .DESCRIPTION - Gets the file path to the latest Visual Studio Command Prompt. Returns $null if a path is not found. + .SYNOPSIS + Gets the file path to the latest Visual Studio Command Prompt. Returns $null if a path is not found. + + .DESCRIPTION + Gets the file path to the latest Visual Studio Command Prompt. Returns $null if a path is not found. #> - [string] $vsCommandPromptPath = Get-VisualStudioCommandPromptPathForVisualStudio2017AndNewer + [string] $vsCommandPromptPath = Get-VisualStudioCommandPromptPathForVisualStudio2017AndNewer - # If VS 2017 or newer VS Command Prompt was not found, check for older versions of VS Command Prompt. - if ([string]::IsNullOrEmpty($vsCommandPromptPath)) - { - $vsCommandPromptPath = Get-VisualStudioCommandPromptPathForVisualStudio2015AndPrior - } + # If VS 2017 or newer VS Command Prompt was not found, check for older versions of VS Command Prompt. + if ([string]::IsNullOrEmpty($vsCommandPromptPath)) + { + $vsCommandPromptPath = Get-VisualStudioCommandPromptPathForVisualStudio2015AndPrior + } - return $vsCommandPromptPath + return $vsCommandPromptPath } function Get-VisualStudioCommandPromptPathForVisualStudio2017AndNewer { - # Later we can probably make use of the VSSetup.PowerShell module to find the MsBuild.exe: https://github.com/Microsoft/vssetup.powershell - # Or perhaps the VsWhere.exe: https://github.com/Microsoft/vswhere - # But for now, to keep this script PowerShell 2.0 compatible and not rely on external executables, let's look for it ourselve in known locations. - # Example of known locations: - # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" - - [string] $visualStudioDirectoryPath = Get-CommonVisualStudioDirectoryPath - [bool] $visualStudioDirectoryPathDoesNotExist = [string]::IsNullOrEmpty($visualStudioDirectoryPath) - if ($visualStudioDirectoryPathDoesNotExist) - { - return $null - } - - # First search for the VS Command Prompt in the expected locations (faster). - $expectedVsCommandPromptPathWithWildcards = "$visualStudioDirectoryPath\*\*\Common7\Tools\VsDevCmd.bat" - $vsCommandPromptPathObjects = Get-Item -Path $expectedVsCommandPromptPathWithWildcards - - [bool] $vsCommandPromptWasNotFound = ($vsCommandPromptPathObjects -eq $null) -or ($vsCommandPromptPathObjects.Length -eq 0) - if ($vsCommandPromptWasNotFound) - { - # Recurisvely search the entire Microsoft Visual Studio directory for the VS Command Prompt (slower, but will still work if MS changes folder structure). - Write-Verbose "The Visual Studio Command Prompt was not found at an expected location. Searching more locations, but this will be a little slow." - $vsCommandPromptPathObjects = Get-ChildItem -Path $visualStudioDirectoryPath -Recurse | Where-Object { $_.Name -ieq 'VsDevCmd.bat' } - } - - $vsCommandPromptPathObjectsSortedWithNewestVersionsFirst = $vsCommandPromptPathObjects | Sort-Object -Property FullName -Descending - - $newestVsCommandPromptPath = $vsCommandPromptPathObjectsSortedWithNewestVersionsFirst | Select-Object -ExpandProperty FullName -First 1 - return $newestVsCommandPromptPath + # Later we can probably make use of the VSSetup.PowerShell module to find the MsBuild.exe: https://github.com/Microsoft/vssetup.powershell + # Or perhaps the VsWhere.exe: https://github.com/Microsoft/vswhere + # But for now, to keep this script PowerShell 2.0 compatible and not rely on external executables, let's look for it ourselves in known locations. + # Example of known locations: + # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" + + [string] $visualStudioDirectoryPath = Get-CommonVisualStudioDirectoryPath + [bool] $visualStudioDirectoryPathDoesNotExist = [string]::IsNullOrEmpty($visualStudioDirectoryPath) + if ($visualStudioDirectoryPathDoesNotExist) + { + return $null + } + + # First search for the VS Command Prompt in the expected locations (faster). + $expectedVsCommandPromptPathWithWildcards = "$visualStudioDirectoryPath\*\*\Common7\Tools\VsDevCmd.bat" + $vsCommandPromptPathObjects = Get-Item -Path $expectedVsCommandPromptPathWithWildcards + + [bool] $vsCommandPromptWasNotFound = ($null -eq $vsCommandPromptPathObjects) -or ($vsCommandPromptPathObjects.Length -eq 0) + if ($vsCommandPromptWasNotFound) + { + # Recursively search the entire Microsoft Visual Studio directory for the VS Command Prompt (slower, but will still work if MS changes folder structure). + Write-Verbose "The Visual Studio Command Prompt was not found at an expected location. Searching more locations, but this will be a little slow." + $vsCommandPromptPathObjects = Get-ChildItem -Path $visualStudioDirectoryPath -Recurse | Where-Object { $_.Name -ieq 'VsDevCmd.bat' } + } + + $vsCommandPromptPathObjectsSortedWithNewestVersionsFirst = $vsCommandPromptPathObjects | Sort-Object -Property FullName -Descending + + $newestVsCommandPromptPath = $vsCommandPromptPathObjectsSortedWithNewestVersionsFirst | Select-Object -ExpandProperty FullName -First 1 + return $newestVsCommandPromptPath } function Get-VisualStudioCommandPromptPathForVisualStudio2015AndPrior { - # Get some environmental paths. - $vs2015CommandPromptPath = $env:VS140COMNTOOLS + 'VsDevCmd.bat' - $vs2013CommandPromptPath = $env:VS120COMNTOOLS + 'VsDevCmd.bat' - $vs2012CommandPromptPath = $env:VS110COMNTOOLS + 'VsDevCmd.bat' - $vs2010CommandPromptPath = $env:VS100COMNTOOLS + 'vcvarsall.bat' - $potentialVsCommandPromptPaths = @($vs2015CommandPromptPath, $vs2013CommandPromptPath, $vs2012CommandPromptPath, $vs2010CommandPromptPath) - - # Store the VS Command Prompt to do the build in, if one exists. - $newestVsCommandPromptPath = $null - foreach ($path in $potentialVsCommandPromptPaths) - { - [bool] $pathExists = (![string]::IsNullOrEmpty($path)) -and (Test-Path -Path $path -PathType Leaf) - if ($pathExists) - { - $newestVsCommandPromptPath = $path - break - } - } - - # Return the path to the VS Command Prompt if it was found. - return $newestVsCommandPromptPath + # Get some environmental paths. + $vs2015CommandPromptPath = $env:VS140COMNTOOLS + 'VsDevCmd.bat' + $vs2013CommandPromptPath = $env:VS120COMNTOOLS + 'VsDevCmd.bat' + $vs2012CommandPromptPath = $env:VS110COMNTOOLS + 'VsDevCmd.bat' + $vs2010CommandPromptPath = $env:VS100COMNTOOLS + 'vcvarsall.bat' + $potentialVsCommandPromptPaths = @($vs2015CommandPromptPath, $vs2013CommandPromptPath, $vs2012CommandPromptPath, $vs2010CommandPromptPath) + + # Store the VS Command Prompt to do the build in, if one exists. + $newestVsCommandPromptPath = $null + foreach ($path in $potentialVsCommandPromptPaths) + { + [bool] $pathExists = (![string]::IsNullOrEmpty($path)) -and (Test-Path -LiteralPath $path -PathType Leaf) + if ($pathExists) + { + $newestVsCommandPromptPath = $path + break + } + } + + # Return the path to the VS Command Prompt if it was found. + return $newestVsCommandPromptPath +} + +function Get-LatestMsBuildPath_NotUsedYetButCouldBeIfNeeded +{ + [bool] $vsSetupExists = $null -ne (Get-Command Get-VSSetupInstance -ErrorAction SilentlyContinue) + if (!$vsSetupExists) + { + Write-Verbose "Importing the VSSetup module in order to determine TF.exe path..." -Verbose + Install-Module VSSetup -Scope CurrentUser -Force + } + [string] $visualStudioInstallationPath = (Get-VSSetupInstance | Select-VSSetupInstance -Latest -Require Microsoft.Component.MSBuild).InstallationPath + $msBuildExecutableFilePath = (Get-ChildItem $visualStudioInstallationPath -Recurse -Filter "MsBuild.exe" | Select-Object -First 1).FullName + return $msBuildExecutableFilePath } function Get-LatestMsBuildPath([switch] $Use32BitMsBuild) { <# - .SYNOPSIS - Gets the path to the latest version of MsBuild.exe. Throws an exception if MsBuild.exe is not found. - - .DESCRIPTION - Gets the path to the latest version of MsBuild.exe. Throws an exception if MsBuild.exe is not found. + .SYNOPSIS + Gets the path to the latest version of MsBuild.exe. Throws an exception if MsBuild.exe is not found. + + .DESCRIPTION + Gets the path to the latest version of MsBuild.exe. Throws an exception if MsBuild.exe is not found. #> - [string] $msBuildPath = $null - $msBuildPath = Get-MsBuildPathForVisualStudio2017AndNewer -Use32BitMsBuild $Use32BitMsBuild + [string] $msBuildPath = $null + $msBuildPath = Get-MsBuildPathForVisualStudio2017AndNewer -Use32BitMsBuild $Use32BitMsBuild - # If VS 2017 or newer MsBuild.exe was not found, check for older versions of MsBuild. - if ([string]::IsNullOrEmpty($msBuildPath)) - { - $msBuildPath = Get-MsBuildPathForVisualStudio2015AndPrior -Use32BitMsBuild $Use32BitMsBuild - } + # If VS 2017 or newer MsBuild.exe was not found, check for older versions of MsBuild. + if ([string]::IsNullOrEmpty($msBuildPath)) + { + $msBuildPath = Get-MsBuildPathForVisualStudio2015AndPrior -Use32BitMsBuild $Use32BitMsBuild + } - [bool] $msBuildPathWasNotFound = [string]::IsNullOrEmpty($msBuildPath) - if ($msBuildPathWasNotFound) - { - throw 'Could not determine where to find MsBuild.exe.' - } + [bool] $msBuildPathWasNotFound = [string]::IsNullOrEmpty($msBuildPath) + if ($msBuildPathWasNotFound) + { + throw 'Could not determine where to find MsBuild.exe.' + } - [bool] $msBuildExistsAtThePathFound = (Test-Path $msBuildPath -PathType Leaf) - if(!$msBuildExistsAtThePathFound) - { - throw "MsBuild.exe does not exist at the expected path, '$msBuildPath'." - } + [bool] $msBuildExistsAtThePathFound = (Test-Path -LiteralPath $msBuildPath -PathType Leaf) + if(!$msBuildExistsAtThePathFound) + { + throw "MsBuild.exe does not exist at the expected path, '$msBuildPath'." + } - return $msBuildPath + return $msBuildPath } -function Get-MsBuildPathForVisualStudio2017AndNewer([switch] $Use32BitMsBuild) +function Get-MsBuildPathForVisualStudio2017AndNewer([bool] $Use32BitMsBuild) { - # Later we can probably make use of the VSSetup.PowerShell module to find the MsBuild.exe: https://github.com/Microsoft/vssetup.powershell - # Or perhaps the VsWhere.exe: https://github.com/Microsoft/vswhere - # But for now, to keep this script PowerShell 2.0 compatible and not rely on external executables, let's look for it ourselve in known locations. - # Example of known locations: - # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" - 32 bit - # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe" - 64 bit - - [string] $visualStudioDirectoryPath = Get-CommonVisualStudioDirectoryPath - [bool] $visualStudioDirectoryPathDoesNotExist = [string]::IsNullOrEmpty($visualStudioDirectoryPath) - if ($visualStudioDirectoryPathDoesNotExist) - { - return $null - } - - # First search for MsBuild in the expected 32 and 64 bit locations (faster). - $expected32bitPathWithWildcards = "$visualStudioDirectoryPath\*\*\MsBuild\*\Bin\MsBuild.exe" - $expected64bitPathWithWildcards = "$visualStudioDirectoryPath\*\*\MsBuild\*\Bin\amd64\MsBuild.exe" - $msBuildPathObjects = Get-Item -Path $expected32bitPathWithWildcards, $expected64bitPathWithWildcards - - [bool] $msBuildWasNotFound = ($msBuildPathObjects -eq $null) -or ($msBuildPathObjects.Length -eq 0) - if ($msBuildWasNotFound) - { - # Recurisvely search the entire Microsoft Visual Studio directory for MsBuild (slower, but will still work if MS changes folder structure). - Write-Verbose "MsBuild.exe was not found at an expected location. Searching more locations, but this will be a little slow." - $msBuildPathObjects = Get-ChildItem -Path $visualStudioDirectoryPath -Recurse | Where-Object { $_.Name -ieq 'MsBuild.exe' } - } - - $msBuildPathObjectsSortedWithNewestVersionsFirst = $msBuildPathObjects | Sort-Object -Property FullName -Descending - - $newest32BitMsBuildPath = $msBuildPathObjectsSortedWithNewestVersionsFirst | Where-Object { $_.Directory.Name -ine 'amd64' } | Select-Object -ExpandProperty FullName -First 1 - $newest64BitMsBuildPath = $msBuildPathObjectsSortedWithNewestVersionsFirst | Where-Object { $_.Directory.Name -ieq 'amd64' } | Select-Object -ExpandProperty FullName -First 1 - - if ($Use32BitMsBuild) - { - return $newest32BitMsBuildPath - } - return $newest64BitMsBuildPath + # Later we can probably make use of the VSSetup.PowerShell module to find the MsBuild.exe: https://github.com/Microsoft/vssetup.powershell + # Or perhaps the VsWhere.exe: https://github.com/Microsoft/vswhere + # But for now, to keep this script PowerShell 2.0 compatible and not rely on external executables, let's look for it ourselves in known locations. + # Example of known locations: + # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" - 32 bit + # "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe" - 64 bit + # "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" -32 bit + # "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe" - 64 bit + + [string] $visualStudioDirectoryPath = Get-CommonVisualStudioDirectoryPath + [bool] $visualStudioDirectoryPathDoesNotExist = [string]::IsNullOrEmpty($visualStudioDirectoryPath) + if ($visualStudioDirectoryPathDoesNotExist) + { + return $null + } + + # First search for MsBuild in the expected 32 and 64 bit locations (faster). + $expected32bitPathWithWildcards = "$visualStudioDirectoryPath\*\*\MsBuild\*\Bin\MsBuild.exe" + $expected64bitPathWithWildcards = "$visualStudioDirectoryPath\*\*\MsBuild\*\Bin\amd64\MsBuild.exe" + $msBuildPathObjects = Get-Item -Path $expected32bitPathWithWildcards, $expected64bitPathWithWildcards + + [bool] $msBuildWasNotFound = ($null -eq $msBuildPathObjects) -or ($msBuildPathObjects.Length -eq 0) + if ($msBuildWasNotFound) + { + # Recursively search the entire Microsoft Visual Studio directory for MsBuild (slower, but will still work if MS changes folder structure). + Write-Verbose "MsBuild.exe was not found at an expected location. Searching more locations, but this will be a little slow." + $msBuildPathObjects = Get-ChildItem -Path $visualStudioDirectoryPath -Recurse | Where-Object { $_.Name -ieq 'MsBuild.exe' } + } + + $msBuildPathObjectsSortedWithNewestVersionsFirst = $msBuildPathObjects | Sort-Object -Property FullName -Descending + + $newest32BitMsBuildPath = $msBuildPathObjectsSortedWithNewestVersionsFirst | Where-Object { $_.Directory.Name -ine 'amd64' } | Select-Object -ExpandProperty FullName -First 1 + $newest64BitMsBuildPath = $msBuildPathObjectsSortedWithNewestVersionsFirst | Where-Object { $_.Directory.Name -ieq 'amd64' } | Select-Object -ExpandProperty FullName -First 1 + + if ($Use32BitMsBuild) + { + return $newest32BitMsBuildPath + } + return $newest64BitMsBuildPath } -function Get-MsBuildPathForVisualStudio2015AndPrior([switch] $Use32BitMsBuild) +function Get-MsBuildPathForVisualStudio2015AndPrior([bool] $Use32BitMsBuild) { - $registryPathToMsBuildToolsVersions = 'HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\' - if ($Use32BitMsBuild) - { - # If the 32-bit path exists, use it, otherwise stick with the current path (which will be the 64-bit path on 64-bit machines, and the 32-bit path on 32-bit machines). - $registryPathTo32BitMsBuildToolsVersions = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\' - if (Test-Path -Path $registryPathTo32BitMsBuildToolsVersions) - { - $registryPathToMsBuildToolsVersions = $registryPathTo32BitMsBuildToolsVersions - } - } - - # Get the path to the directory that the latest version of MsBuild is in. - $msBuildToolsVersionsStrings = Get-ChildItem -Path $registryPathToMsBuildToolsVersions | Where-Object { $_ -match '[0-9]+\.[0-9]' } | Select-Object -ExpandProperty PsChildName - $msBuildToolsVersions = @{} - $msBuildToolsVersionsStrings | ForEach-Object {$msBuildToolsVersions.Add($_ -as [double], $_)} - $largestMsBuildToolsVersion = ($msBuildToolsVersions.GetEnumerator() | Sort-Object -Descending -Property Name | Select-Object -First 1).Value - $registryPathToMsBuildToolsLatestVersion = Join-Path -Path $registryPathToMsBuildToolsVersions -ChildPath ("{0:n1}" -f $largestMsBuildToolsVersion) - $msBuildToolsVersionsKeyToUse = Get-Item -Path $registryPathToMsBuildToolsLatestVersion - $msBuildDirectoryPath = $msBuildToolsVersionsKeyToUse | Get-ItemProperty -Name 'MSBuildToolsPath' | Select-Object -ExpandProperty 'MSBuildToolsPath' - - if(!$msBuildDirectoryPath) - { - return $null - } - - # Build the expected path to the MsBuild executable. - $msBuildPath = (Join-Path -Path $msBuildDirectoryPath -ChildPath 'MsBuild.exe') - - return $msBuildPath + $registryPathToMsBuildToolsVersions = 'HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\' + if ($Use32BitMsBuild) + { + # If the 32-bit path exists, use it, otherwise stick with the current path (which will be the 64-bit path on 64-bit machines, and the 32-bit path on 32-bit machines). + $registryPathTo32BitMsBuildToolsVersions = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\' + if (Test-Path -Path $registryPathTo32BitMsBuildToolsVersions) + { + $registryPathToMsBuildToolsVersions = $registryPathTo32BitMsBuildToolsVersions + } + } + + # Backup the current culture and force using English US to ensure version numbers are in the expected format (e.g. 17.0). + $previousCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture + [System.Threading.Thread]::CurrentThread.CurrentCulture = 'en-US' + + # Get the path to the directory that the latest version of MsBuild is in. + $msBuildToolsVersionsStrings = Get-ChildItem -Path $registryPathToMsBuildToolsVersions | Where-Object { $_ -match '[0-9]+\.[0-9]' } | Select-Object -ExpandProperty PsChildName + $msBuildToolsVersions = @{} + $msBuildToolsVersionsStrings | ForEach-Object {$msBuildToolsVersions.Add($_ -as [double], $_)} + $largestMsBuildToolsVersion = ($msBuildToolsVersions.GetEnumerator() | Sort-Object -Descending -Property Name | Select-Object -First 1).Value + $registryPathToMsBuildToolsLatestVersion = Join-Path -Path $registryPathToMsBuildToolsVersions -ChildPath ("{0:n1}" -f $largestMsBuildToolsVersion) + $msBuildToolsVersionsKeyToUse = Get-Item -Path $registryPathToMsBuildToolsLatestVersion + $msBuildDirectoryPath = $msBuildToolsVersionsKeyToUse | Get-ItemProperty -Name 'MSBuildToolsPath' | Select-Object -ExpandProperty 'MSBuildToolsPath' + + # Restore the previous culture now that we're done comparing version numbers. + [System.Threading.Thread]::CurrentThread.CurrentCulture = $previousCulture + + if(!$msBuildDirectoryPath) + { + return $null + } + + # Build the expected path to the MsBuild executable. + $msBuildPath = (Join-Path -Path $msBuildDirectoryPath -ChildPath 'MsBuild.exe') + + return $msBuildPath } function Get-CommonVisualStudioDirectoryPath { - [string] $programFilesDirectory = $null - try - { - $programFilesDirectory = Get-Item 'Env:\ProgramFiles(x86)' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Value - } - catch - { } - - if ([string]::IsNullOrEmpty($programFilesDirectory)) - { - $programFilesDirectory = 'C:\Program Files (x86)' - } - - # If we're on a 32-bit machine, we need to go straight after the "Program Files" directory. - if (!(Test-Path -Path $programFilesDirectory -PathType Container)) - { - try - { - $programFilesDirectory = Get-Item 'Env:\ProgramFiles' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Value - } - catch - { - $programFilesDirectory = $null - } - - if ([string]::IsNullOrEmpty($programFilesDirectory)) - { - $programFilesDirectory = 'C:\Program Files' - } - } - - [string] $visualStudioDirectoryPath = Join-Path -Path $programFilesDirectory -ChildPath 'Microsoft Visual Studio' - - [bool] $visualStudioDirectoryPathExists = (Test-Path -Path $visualStudioDirectoryPath -PathType Container) - if (!$visualStudioDirectoryPathExists) - { - return $null - } - return $visualStudioDirectoryPath + # As of VS 2022 Visual Studio is 64-bit, so look in "Program Files" directory before "Program Files (x86)". + [string] $programFilesDirectory = $null + try + { + $programFilesDirectory = Get-Item 'Env:\ProgramFiles' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Value + } + catch + { } + + if ([string]::IsNullOrEmpty($programFilesDirectory)) + { + $programFilesDirectory = 'C:\Program Files' + } + + [string] $visualStudioDirectoryPath = Join-Path -Path $programFilesDirectory -ChildPath 'Microsoft Visual Studio' + [bool] $visualStudioDirectoryPathExists = (Test-Path -LiteralPath $visualStudioDirectoryPath -PathType Container) + if (!$visualStudioDirectoryPathExists) + { + # Look for Visual Studio in "Program Files (x86)" directory. + try + { + $programFilesDirectory = Get-Item 'Env:\ProgramFiles(x86)' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Value + } + catch + { + $programFilesDirectory = $null + } + + if ([string]::IsNullOrEmpty($programFilesDirectory)) + { + $programFilesDirectory = 'C:\Program Files (x86)' + } + } + + $visualStudioDirectoryPath = Join-Path -Path $programFilesDirectory -ChildPath 'Microsoft Visual Studio' + $visualStudioDirectoryPathExists = (Test-Path -LiteralPath $visualStudioDirectoryPath -PathType Container) + if (!$visualStudioDirectoryPathExists) + { + return $null + } + return $visualStudioDirectoryPath } -Export-ModuleMember -Function Invoke-MsBuild \ No newline at end of file +Export-ModuleMember -Function Invoke-MsBuild diff --git a/scripts/build-c-client.ps1 b/scripts/build-c-client.ps1 index f4b271e4e..6a067236e 100644 --- a/scripts/build-c-client.ps1 +++ b/scripts/build-c-client.ps1 @@ -105,14 +105,6 @@ function Build-Project { return $process.ExitCode -eq 0 } -### DEBUG -Write-Host "DEBUG" -Write-Host($PSVersionTable | Out-String) -Write-Host(Get-command get-file* | Out-String) -Write-Host((get-filehash $PSHOME\powershell.exe).hash | Out-String) -Write-Host "END DEBUG" -### - $CClientCfg = Parse-IniFile $CClientIni Write-Debug ($CClientCfg | Out-String) $FileHashes = Parse-IniFile $FileHashesIni -sep " " -swap From 0c48eb07d6188fbbe0a005dfac7cad998819681f Mon Sep 17 00:00:00 2001 From: Zohar Elkayam <5897181+realmgic@users.noreply.github.com> Date: Sat, 11 Jun 2022 17:06:34 +0300 Subject: [PATCH 12/28] remove setup step, add version to test --- .github/workflows/windows-build.yml | 31 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 6569a3f2f..accdbe2d2 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -10,7 +10,6 @@ on: - maint/3.x - maint/4.x - gh-action - - win-workflow-new pull_request: branches: - master @@ -18,20 +17,26 @@ on: - maint/3.x - maint/4.x - jobs: - setup: - runs-on: ubuntu-latest - steps: - - name: Set up Aerospike Database - uses: reugn/github-action-aerospike@v1 + # setup: + # runs-on: ubuntu-latest + # steps: + # - name: Set up Aerospike Database + # uses: reugn/github-action-aerospike@v1 build: runs-on: windows-latest strategy: matrix: - node: [ 10, 12, 14, 16 ] - name: Node ${{ matrix.node }} sample + node-version: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + - 10.x + - 12.x + - 14.x + - 16.x + - 17.x + - 18.x + continue-on-error: true + name: Node ${{ matrix.node-version }} tester steps: - uses: actions/checkout@v3 with: @@ -43,7 +48,7 @@ jobs: - name: Setup node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: ${{ matrix.node-version }} - name: Update node-gyp run: | $WhereNode = Get-Command node | Select-Object -ExpandProperty Definition @@ -59,4 +64,8 @@ jobs: - name: Install nodejs Client shell: pwsh run: npm install --unsafe-perm --build-from-source - # - run: npm test + # - name: Test nodejs client + # run: npm test + # env: + # AEROSPIKE_HOSTS: "127.0.0.1:3000" + # OPTIONS: "--timeout 30000 --set demp ${{ matrix.node }}" From e8877d3b1022ca55cc2860c1813274005e57f24d Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Mon, 20 Jun 2022 17:48:57 -0700 Subject: [PATCH 13/28] typescript decalaration added --- lib/aerospike.js | 49 +- lib/batch_type.js | 49 +- lib/bitwise.js | 10 +- lib/cdt_context.js | 4 +- lib/client.js | 26 +- lib/commands/command.js | 4 +- lib/error.js | 9 +- lib/filter.js | 2 +- lib/maps.js | 6 - lib/operations.js | 2 +- lib/policies/base_policy.js | 3 - lib/query.js | 15 +- lib/scan.js | 9 +- lib/typedefs.js | 54 + test/batch_write.js | 2 +- test/maps.js | 26 +- tsconfig.json | 14 +- typings/index.d.ts | 3031 ++++++++++++++++++----------------- 18 files changed, 1692 insertions(+), 1623 deletions(-) diff --git a/lib/aerospike.js b/lib/aerospike.js index 700b90907..8e791e650 100644 --- a/lib/aerospike.js +++ b/lib/aerospike.js @@ -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 @@ -54,7 +53,6 @@ exp.type = as.exp.type /** * @summary POSIX regex compilation flags. * - * @readonly * @enum {number} * */ @@ -156,26 +154,26 @@ 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.BasePolicy = policy.BasePolicy -exports.ApplyPolicy = policy.ApplyPolicy -exports.BatchPolicy = policy.BatchPolicy -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.BatchApplyPolicy = policy.BatchApplyPolicy -exports.BatchReadPolicy = policy.BatchReadPolicy -exports.BatchRemovePolicy = policy.BatchRemovePolicy -exports.BatchWritePolicy = policy.BatchWritePolicy -exports.CommandQueuePolicy = policy.CommandQueuePolicy -exports.InfoPolicy = policy.InfoPolicy -exports.ListPolicy = policy.ListPolicy -exports.MapPolicy = policy.MapPolicy +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.BatchApplyPolicy = require('./policy').BatchApplyPolicy +exports.BatchReadPolicy = require('./policy').BatchReadPolicy +exports.BatchRemovePolicy = require('./policy').BatchRemovePolicy +exports.BatchWritePolicy = require('./policy').BatchWritePolicy +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 @@ -272,7 +270,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 @@ -309,7 +306,6 @@ exports.auth = as.auth /** * @summary Enumeration of UDF types. * - * @readonly * @enum {number} * * @property {number} LUA - Lua (only supported UDF type at the moment) @@ -319,7 +315,6 @@ exports.language = as.language /** * @summary Enumeration of log levels * - * @readonly * @enum {number} * * @property {number} OFF - Turn off logging @@ -359,7 +354,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 @@ -404,7 +398,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 @@ -419,7 +412,6 @@ exports.jobStatus = as.jobStatus /** * @summary Enumeration of SI data types. * - * @readonly * @enum {number} * * @property {number} STRING - Values contained in the SI are strings. @@ -433,7 +425,6 @@ exports.indexDataType = as.indexDataType /** * @summary Enumeration of SI types. * - * @readonly * @enum {number} * * @property {number} DEFAULT - Default SI type for bins @@ -456,8 +447,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 diff --git a/lib/batch_type.js b/lib/batch_type.js index 6c7b5c49a..e63274e37 100644 --- a/lib/batch_type.js +++ b/lib/batch_type.js @@ -28,27 +28,28 @@ const batchType = as.batchTypes // ======================================================================== // Constants // ======================================================================== - -/** - * An instance of class Record that is used in a batch for read operations. - * @const {number} - */ -exports.BATCH_READ = batchType.BATCH_READ - -/** - * An instance of class Record that is used in a batch for write operations. - * @const {number} - */ -exports.BATCH_WRITE = batchType.BATCH_WRITE - -/** - * An instance of class Record that is used in a batch for applying record. - * @const {number} - */ -exports.BATCH_APPLY = batchType.BATCH_APPLY - -/** - * An instance of class Record that is used in a batch for removal operations. - * @const {number} - */ -exports.BATCH_REMOVE = batchType.BATCH_REMOVE +exports.types = { + /** + * An instance of class Record that is used in a batch for read operations. + * @const {number} + */ + BATCH_READ: batchType.BATCH_READ, + + /** + * An instance of class Record that is used in a batch for write operations. + * @const {number} + */ + BATCH_WRITE: batchType.BATCH_WRITE, + + /** + * An instance of class Record that is used in a batch for applying record. + * @const {number} + */ + BATCH_APPLY: batchType.BATCH_APPLY, + + /** + * An instance of class Record that is used in a batch for removal operations. + * @const {number} + */ + BATCH_REMOVE: batchType.BATCH_REMOVE +} diff --git a/lib/bitwise.js b/lib/bitwise.js index e0fece675..53a32696f 100644 --- a/lib/bitwise.js +++ b/lib/bitwise.js @@ -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) { @@ -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. @@ -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) { @@ -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) { @@ -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) { diff --git a/lib/cdt_context.js b/lib/cdt_context.js index 06ba85fc8..101167ae9 100644 --- a/lib/cdt_context.js +++ b/lib/cdt_context.js @@ -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) { diff --git a/lib/client.js b/lib/client.js index 3a06d61cc..ecc2f439b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -347,8 +347,8 @@ Client.prototype.batchGet = function (keys, policy, callback) { * the batch. This method requires server >= 3.6.0. * * @param {object[]} records - {@link Record} List of keys and bins to retrieve. - * @param {type} records[].type - {@link Record#type} Batch type. - * @param {Key} records[].key - Record Key. + * @param {number} records[].type - {@link Record#type} Batch type. + * @param {string} records[].key - Record Key. * @param {string[]} [records[].bins] - List of bins to retrieve. * @param {boolean} [records[].readAllBins] - Whether to retrieve all bins or * just the meta data of the record. If true, ignore bins and read @@ -409,8 +409,8 @@ Client.prototype.batchRead = function (records, policy, callback) { * This method requires server >= 6.0.0. * * @param {object[]} records - {@link Record} List of batch sub-commands to perform. - * @param {type} records[].type - {@link Record#type} Batch type. - * @param {Key} records[].key - Record Key. + * @param {number} records[].type - {@link Record#type} Batch type. + * @param {string} records[].key - Record Key. * @param {BatchPolicy} [policy] - The Batch Policy to use for this operation. * @param {batchRecordsCallback} [callback] - The function to call when * the operation completes, with the results of the batch operation. @@ -491,8 +491,8 @@ Client.prototype.batchWrite = function (records, policy, callback) { * This method requires server >= 6.0.0. * * @param {object[]} records - {@link Record} List of batch sub-commands to perform. - * @param {type} records[].type - {@link Record#type} Batch type. - * @param {Key} records[].key - Record Key. + * @param {number} records[].type - {@link Record#type} Batch type. + * @param {string} records[].key - Record Key. * @param {object[]} udf - Server UDF module/function and argList to apply. * @param {BatchPolicy} [batchPolicy] - The Batch Policy to use for this operation. * @param {BatchApplyPolicy} [batchApplyPolicy] UDF policy configuration parameters. @@ -580,8 +580,8 @@ Client.prototype.batchApply = function (records, udf, batchPolicy, batchApplyPol * This method requires server >= 6.0.0. * * @param {object[]} records - {@link Record} List of batch sub-commands to perform. - * @param {type} records[].type - {@link Record#type} Batch type. - * @param {Key} records[].key - Record Key. + * @param {number} records[].type - {@link Record#type} Batch type. + * @param {string} records[].key - Record Key. * @param {BatchPolicy} [batchPolicy] - The Batch Policy to use for this operation. * @param {BatchRemovePolicy} [batchRemovePolicy] Remove policy configuration parameters. * @param {batchRecordsCallback} [callback] - The function to call when @@ -1598,7 +1598,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 * @@ -1668,7 +1668,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 * @@ -1765,7 +1765,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 @@ -1808,7 +1808,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 @@ -1900,7 +1900,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 diff --git a/lib/commands/command.js b/lib/commands/command.js index a0db6bfbd..097480776 100644 --- a/lib/commands/command.js +++ b/lib/commands/command.js @@ -30,6 +30,7 @@ const AerospikeError = require('../error') /** * @class Command * @classdesc Database command. + * @type Class */ module.exports = asCommand => class Command { /** @private */ @@ -39,7 +40,6 @@ module.exports = asCommand => class Command { * * @name Command#client * @type {Client} - * @readonly */ this.client = client @@ -56,7 +56,6 @@ module.exports = asCommand => class Command { * * @name Command#captureStackTraces * @type {boolean} - * @readonly * @see {@link Client#captureStackTraces} */ this.captureStackTraces = client.captureStackTraces @@ -66,7 +65,6 @@ module.exports = asCommand => class Command { * * @name Command#key * @type {?Key} - * @readonly */ this.key = undefined diff --git a/lib/error.js b/lib/error.js index 9727a40b8..e086bd628 100644 --- a/lib/error.js +++ b/lib/error.js @@ -47,7 +47,6 @@ class AerospikeError extends Error { * Numeric status code returned by the server or the client. * * @type {number} - * @readonly * * @see {@link module:aerospike.status} contains the full list of possible status codes. */ @@ -56,8 +55,7 @@ class AerospikeError extends Error { /** * Command during which the error occurred. * - * @type {?Command} - * @readonly + * @type {?Object} */ this.command = command || null @@ -65,7 +63,6 @@ class AerospikeError extends Error { * C/C++ function name in which the error occurred. * * @type {?string} - * @readonly */ this.func = null @@ -73,7 +70,6 @@ class AerospikeError extends Error { * File name of the C/C++ source file in which the error occurred. * * @type {?string} - * @readonly */ this.file = null @@ -81,7 +77,6 @@ class AerospikeError extends Error { * Line number in the C/C++ source file in which the error occurred. * * @type {?number} - * @readonly */ this.line = null @@ -91,7 +86,6 @@ class AerospikeError extends Error { * (like timeout) after the command was sent to the server. * * @type {boolean} - * @readonly */ this.inDoubt = false @@ -153,7 +147,6 @@ class AerospikeError extends Error { * The {@link Client} instance associated with this error, if any. * * @type {?Client} - * @readonly * @since v3.7.0 * * @example Closing the client connection, when an error occurs: diff --git a/lib/filter.js b/lib/filter.js index cd32e3ca9..171aaa7ec 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -153,7 +153,7 @@ exports.equal = function (bin, value) { * value that contain the given string or integer. * * @param {string} bin - The name of the bin. - * @param {(string|integer)} value - The value that should be a member of the + * @param {(string|number)} value - The value that should be a member of the * list or map in the bin. * @param {number} indexType - One of {@link module:aerospike.indexType}, * i.e. LIST, MAPVALUES or MAPKEYS. diff --git a/lib/maps.js b/lib/maps.js index 339eb91ef..da86b3eb9 100644 --- a/lib/maps.js +++ b/lib/maps.js @@ -18,7 +18,6 @@ const as = require('bindings')('aerospike.node') const opcodes = as.mapOperations -const policy = require('./policy') const Context = require('./cdt_context') const Operation = require('./operations').Operation @@ -298,11 +297,6 @@ exports.writeFlags = as.maps.writeFlags */ exports.returnType = as.maps.returnType -/** - * @private - */ -exports.MapPolicy = policy.MapPolicy - /** * @summary Sets map policy attributes. * diff --git a/lib/operations.js b/lib/operations.js index 77aeaedee..3e1ed8ba0 100644 --- a/lib/operations.js +++ b/lib/operations.js @@ -108,7 +108,7 @@ exports.write = function (bin, value) { * value must be of the same type. * * @param {string} bin - The name of the bin. - * @param {(number|Double)} value - The value to increment the bin by. + * @param {(number|Object)} value - The number|{@link Double} value to increment the bin by. * @returns {Operation} Operation that can be passed to the {@link Client#operate} command. */ exports.add = function (bin, value) { diff --git a/lib/policies/base_policy.js b/lib/policies/base_policy.js index 0822888ab..953e92bdd 100644 --- a/lib/policies/base_policy.js +++ b/lib/policies/base_policy.js @@ -26,9 +26,6 @@ * @since v3.0.0 */ class BasePolicy { - /** - * @private - */ constructor (props) { props = props || {} diff --git a/lib/query.js b/lib/query.js index de4ee1101..74a67e130 100644 --- a/lib/query.js +++ b/lib/query.js @@ -125,7 +125,7 @@ const util = require('util') * @param {string} ns - The namescape. * @param {string} set - The name of a set. * @param {object} [options] - Query parameters. - * @param {FilterPredicate[]} [options.filters] - List of filter predicates to + * @param {object[]} [options.filters] - List of filter predicates to * apply to the query. See {@link Query#where}. * @param {string[]} [options.select] - List of bin names to select. See * {@link Query#select}. @@ -203,7 +203,7 @@ function Query (client, ns, set, options) { * advanced filtering, you need to use a user-defined function (UDF) to * process the result set on the server. * - * @member {FilterPredicate[]} Query#filters + * @member {object[]} Query#filters * * @see Use {@link Query#where} to add filter predicates to the query. * @see Use {@link module:aerospike/filter} to create a SI @@ -352,8 +352,8 @@ Query.prototype.setUdf = function (udfModule, udfFunction, udfArgs) { * If no partitions are specified, * then all partitions will be scanned and returned. * - * @param {int} begin - Start partition number to scan. - * @param {int} count - Number of partitions from the start to scan. + * @param {number} begin - Start partition number to scan. + * @param {number} count - Number of partitions from the start to scan. * @param {string} digest - Start from this digest if it is specified. */ Query.prototype.partitions = function (begin, count, digest) { @@ -383,6 +383,11 @@ Query.prototype.partitions = function (begin, count, digest) { * stream of values, you should use the {@link Query#apply} method instead. * * @param {QueryPolicy} [policy] - The Query Policy to use for this operation. + * @param {recordCallback} [dataCb] - The function to call when the + * operation completes with the results of the operation; if no callback + * function is provided, the method returns a Promise instead. + * @param {errorCallback} [errorCb] - Callback function called when there is an error. + * @param {doneCallback} [endCb] - Callback function called when an operation has completed. * * @returns {RecordStream} */ @@ -417,7 +422,7 @@ Query.prototype.foreach = function (policy, dataCb, errorCb, endCb) { * * @param {QueryPolicy} [policy] - The Query Policy to use for this operation. * - * @returns {Promise} + * @returns {Promise} */ Query.prototype.results = function (policy) { return new Promise((resolve, reject) => { diff --git a/lib/scan.js b/lib/scan.js index 1614647be..180b311fb 100644 --- a/lib/scan.js +++ b/lib/scan.js @@ -180,8 +180,8 @@ Scan.prototype.select = function (bins) { * If no partitions are specified, * then all partitions will be scanned and returned. * - * @param {int} begin - Start partition number to scan. - * @param {int} count - Number of partitions from the start to scan. + * @param {number} begin - Start partition number to scan. + * @param {number} count - Number of partitions from the start to scan. * @param {string} digest - Start from this digest if it is specified. */ Scan.prototype.partitions = function (begin, count, digest) { @@ -282,6 +282,11 @@ Scan.prototype.operate = function (operations, policy = null, scanID = null, cal * record to the client. * * @param {ScanPolicy} [policy] - The Scan Policy to use for this operation. + * @param {recordCallback} [dataCb] - The function to call when the + * operation completes with the results of the operation; if no callback + * function is provided, the method returns a Promise instead. + * @param {errorCallback} [errorCb] - Callback function called when there is an error. + * @param {doneCallback} [endCb] - Callback function called when an operation has completed. * * @returns {RecordStream} */ diff --git a/lib/typedefs.js b/lib/typedefs.js index 50adbd621..671ceee1f 100644 --- a/lib/typedefs.js +++ b/lib/typedefs.js @@ -64,6 +64,14 @@ * @param {?AerospikeError} error - The error code and message or null if the operation was successful. */ +/** + * @callback errorCallback + * + * @summary Callback function called when an error occured. + * + * @param {?AerospikeError} error - The error code and message or null. + */ + /** * @callback recordCallback * @@ -179,3 +187,49 @@ * * @since v4.0.0 */ + +/** + * @typedef {object} ApplyPolicy + * @typedef {object} BatchPolicy + * @typedef {object} InfoPolicy + * @typedef {object} OperatePolicy + * @typedef {object} ReadPolicy + * @typedef {object} RemovePolicy + * @typedef {object} ScanPolicy + * @typedef {object} QueryPolicy + * @typedef {object} WritePolicy + * @typedef {object} BitwisePolicy + * @typedef {object} MapPolicy + * @typedef {object} CommandQueuePolicy + * + * @summary Aerospike Policy objects + * + */ + +/** + * @typedef {object} Operation + * + * @summary Aerospike Operation object + * + */ + +/** + * @typedef {object} Client + * + * @summary Aerospike Client object + * + */ + +/** + * @typedef {object} Key + * + * @summary Aerospike Key object + * + */ + +// /** +// * @typedef {object} Record +// * +// * @summary Aerospike Record object +// * +// */ diff --git a/test/batch_write.js b/test/batch_write.js index 1bd80134b..cba18413b 100644 --- a/test/batch_write.js +++ b/test/batch_write.js @@ -22,7 +22,7 @@ const Aerospike = require('../lib/aerospike') const helper = require('./test_helper') // const util = require('util') -const batchType = Aerospike.batchType +const batchType = Aerospike.batchType.types const op = Aerospike.operations const GeoJSON = Aerospike.GeoJSON diff --git a/test/maps.js b/test/maps.js index b4baf554d..0a7b4bbe1 100644 --- a/test/maps.js +++ b/test/maps.js @@ -40,7 +40,7 @@ const { } = require('./util/statefulAsyncTest') const orderMap = (bin, order, ctx) => { - const policy = new maps.MapPolicy({ order }) + const policy = new Aerospike.MapPolicy({ order }) const setMapPolicy = maps.setPolicy(bin, policy) if (ctx) setMapPolicy.withContext(ctx) return operate(setMapPolicy) @@ -100,7 +100,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('update-only write mode', function () { - const updateOnlyPolicy = new maps.MapPolicy({ + const updateOnlyPolicy = new Aerospike.MapPolicy({ writeMode: maps.writeMode.UPDATE_ONLY }) @@ -126,7 +126,7 @@ describe('client.operate() - CDT Map operations', function () { context('with update-only flag', function () { helper.skipUnlessVersion('>= 4.3.0', this) - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.UPDATE_ONLY }) @@ -149,7 +149,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('with no-fail flag', function () { - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.UPDATE_ONLY | maps.writeFlags.NO_FAIL }) @@ -165,7 +165,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('create-only write mode', function () { - const createOnlyPolicy = new maps.MapPolicy({ + const createOnlyPolicy = new Aerospike.MapPolicy({ writeMode: maps.writeMode.CREATE_ONLY }) @@ -191,7 +191,7 @@ describe('client.operate() - CDT Map operations', function () { context('with create-only flag', function () { helper.skipUnlessVersion('>= 4.3.0', this) - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.CREATE_ONLY }) @@ -214,7 +214,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('with no-fail flag', function () { - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.CREATE_ONLY | maps.writeFlags.NO_FAIL }) @@ -256,7 +256,7 @@ describe('client.operate() - CDT Map operations', function () { context('with update-only flag', function () { helper.skipUnlessVersion('>= 4.3.0', this) - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.UPDATE_ONLY }) @@ -270,7 +270,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('with no-fail flag', function () { - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.UPDATE_ONLY | maps.writeFlags.NO_FAIL }) @@ -284,7 +284,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('with partial flag', function () { - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.UPDATE_ONLY | maps.writeFlags.NO_FAIL | maps.writeFlags.PARTIAL }) @@ -303,7 +303,7 @@ describe('client.operate() - CDT Map operations', function () { context('with create-only flag', function () { helper.skipUnlessVersion('>= 4.3.0', this) - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.CREATE_ONLY }) @@ -317,7 +317,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('with no-fail flag', function () { - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.CREATE_ONLY | maps.writeFlags.NO_FAIL }) @@ -331,7 +331,7 @@ describe('client.operate() - CDT Map operations', function () { }) context('with partial flag', function () { - const policy = new maps.MapPolicy({ + const policy = new Aerospike.MapPolicy({ writeFlags: maps.writeFlags.CREATE_ONLY | maps.writeFlags.NO_FAIL | maps.writeFlags.PARTIAL }) diff --git a/tsconfig.json b/tsconfig.json index e18540a73..8684691ad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,7 @@ { + "include": ["lib/*", "lib/commands/*", "lib/policies/*"], "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ "strict": true, "module": "commonjs", "moduleResolution": "node", @@ -8,9 +10,9 @@ "es2020", "dom" ], - "removeComments": false, + "removeComments": true, "alwaysStrict": true, - "pretty": true, + "pretty": false, "incremental": true, "noEmitHelpers": true, "importHelpers": true, @@ -22,11 +24,5 @@ "isolatedModules": false, "skipLibCheck": true, "baseUrl": ".", - }, - "exclude": [ - "node_modules", - ], - "include": [ - "typings" - ] + } } diff --git a/typings/index.d.ts b/typings/index.d.ts index e3c5b0a4e..7c6e99a5e 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,1528 +1,1563 @@ -import * as Buffer from "buffer"; -import { EventEmitter, Stream } from "stream"; - -declare namespace Aerospike { - - type PartialAerospikeRecordValue = null | undefined | boolean | string | number | Double | BigInt | Buffer | GeoJSON; - type AerospikeRecordValue = PartialAerospikeRecordValue | PartialAerospikeRecordValue[] | Record; - - type AerospikeBins = { - [key: string]: AerospikeRecordValue - }; - - // Commands - - class Command { - readonly client: Client; - private args: any[]; - private callback?: AddonCallback; - readonly captureStackTraces: boolean; - public key?: IKey; - public ensureConnected: boolean; - constructor(client: Client, args: any[], callback?: AddonCallback); - private captureStackTrace(): void; - private connected(): boolean; - private convertError(): AerospikeError; - private convertResult(arg1, arg2, arg3): any; - private convertResponse(err, arg1, arg2, arg3): [AerospikeError, any]; - private execute(): Promise | void; - private executeWithCallback(callback: AddonCallback): void; - private executeAndReturnPromise(): Promise; - private expectsPromise(): boolean; - private asCommand(): string; - private process(cb: AddonCallback): void; - private sendError(message: string): void; - } - - interface IBatchResult { - status: Status; - record: AerospikeRecord; - } - - class BatchCommand extends Command { - private convertResult(results: AerospikeRecord[]): IBatchResult[]; - } - - class ConnectCommand extends Command { - constructor(client: Client, callback: AddonCallback); - } - - class QueryBackgroundBaseCommand extends Command { - public queryID: number; - public queryObj: IQueryOptions; - constructor(client: Client, ns: string, set: string, queryObj: IQueryOptions, policy: QueryPolicy, queryID: number, callback: AddonCallback); - public convertResult(): Job; - } - - class ReadRecordCommand extends Command { - constructor(client: Client, key: IKey, args: any[]); - public convertResult(bins: AerospikeBins, metadata: IRecordMetadata): AerospikeRecord; - } - - class StreamCommand extends Command { - public stream: RecordStream; - constructor(stream: RecordStream, args: any[]); - private callback(error?: Error, record: AerospikeRecord): boolean; - private convertResult(bins: AerospikeBins, meta: IRecordMetadata, asKey: IKey): AerospikeRecord; - } - - class WriteRecordCommand extends Command { - constructor(client: Client, key: IKey, args: any[], callback: AddOperation); - private convertResult(): IKey; - } - - // C++ bindings - enum Predicates { - EQUAL, - RANGE - } - - enum IndexDataType { - STRING, - NUMERIC, - GEO2DSPHERE - } - - enum IndexType { - DEFAULT, - LIST, - MAPKEYS, - MAPVALUES - } - - enum ListOrder { - UNORDERED, - ORDERED - } - - enum ListSortFlags { - DEFAULT, - DROP_DUPLICATES - } - - enum ListWriteFlags { - DEFAULT, - ADD_UNIQUE, - INSERT_BOUNDED, - NO_FAIL, - PARTIAL - } - - enum ListReturnType { - NONE, - INDEX, - REVERSE_INDEX, - RANK, - REVERSE_RANK, - COUNT, - VALUE, - INVERTED - } - - enum MapReturnType { - NONE, - INDEX, - REVERSE_INDEX, - RANK, - REVERSE_RANK, - COUNT, - KEY, - VALUE, - KEY_VALUE - } - - enum ScalarOperations { - WRITE, - READ, - INCR, - PREPEND, - APPEND, - TOUCH, - DELETE - } - - enum PolicyGen { - IGNORE, - EQ, - GT - } - - enum PolicyKey { - DIGEST, - SEND - } - - enum PolicyExists { - IGNORE, - CREATE, - UPDATE, - REPLACE, - CREATE_OR_REPLACE - } - - enum PolicyReplica { - MASTER, - ANY, - SEQUENCE, - PREFER_RACK - } - - enum PolicyReadModeAP { - ONE, - ALL - } - - enum PolicyReadModeSC { - SESSION, - LINEARIZE, - ALLOW_REPLICA, - ALLOW_UNAVAILABLE - } - - enum PolicyCommitLevel { - ALL, - MASTER - } - - enum BitwiseWriteFlags { - DEFAULT, - CREATE_ONLY, - UPDATE_ONLY, - NO_FAIL, - PARTIAL = 8 - } - - enum BitwiseResizeFlags { - DEFAULT, - FROM_FRONT, - GROW_ONLY, - SHRINK_ONLY = 4 - } - - enum BitwiseOverflow { - FAIL, - SATURATE = 2, - WRAP = 4 - } - - enum HLLWriteFlags { - DEFAULT, - CREATE_ONLY, - UPDATE_ONLY, - NO_FAIL = 4, - ALLOW_FOLD = 8 - } - - enum MapOrder { - UNORDERED, - KEY_ORDERED, - KEY_VALUE_ORDERED - } - - enum MapWriteMode { - UPDATE, - UPDATE_ONLY, - CREATE_ONLY - } - - enum MapWriteFlags { - DEFAULT, - CREATE_ONLY, - UPDATE_ONLY, - NO_FAIL = 4, - PARTIAL = 8 - } - - enum LogLevel { - OFF = -1, - ERROR, - WARN, - INFO, - DEBUG, - TRACE, - DETAIL - } - - enum Auth { - INTERNAL, - EXTERNAL, - EXTERNAL_INSECURE - } - - enum Language { - LUA - } - - enum Log { - OFF = -1, - ERROR, - WARN, - INFO, - DEBUG, - TRACE, - DETAIL = 4 - } - - enum TTL { - DONT_UPDATE = -2, - NEVER_EXPIRE, - NAMESPACE_DEFAULT - } - - enum JobStatus { - UNDEF, - INPROGRESS, - COMPLETED - } - - enum Status { - AEROSPIKE_ERR_ASYNC_QUEUE_FULL = -11, - AEROSPIKE_ERR_CONNECTION, - AEROSPIKE_ERR_TLS_ERROR, - AEROSPIKE_ERR_INVALID_NODE, - AEROSPIKE_ERR_NO_MORE_CONNECTIONS, - AEROSPIKE_ERR_ASYNC_CONNECTION, - AEROSPIKE_ERR_CLIENT_ABORT, - AEROSPIKE_ERR_INVALID_HOST, - AEROSPIKE_NO_MORE_RECORDS, - AEROSPIKE_ERR_PARAM, - AEROSPIKE_ERR_CLIENT, - AEROSPIKE_OK, - AEROSPIKE_ERR_SERVER, - AEROSPIKE_ERR_RECORD_NOT_FOUND, - AEROSPIKE_ERR_RECORD_GENERATION, - AEROSPIKE_ERR_REQUEST_INVALID, - AEROSPIKE_ERR_RECORD_EXISTS, - AEROSPIKE_ERR_BIN_EXISTS, - AEROSPIKE_ERR_CLUSTER_CHANGE, - AEROSPIKE_ERR_SERVER_FULL, - AEROSPIKE_ERR_TIMEOUT, - AEROSPIKE_ERR_ALWAYS_FORBIDDEN, - AEROSPIKE_ERR_CLUSTER, - AEROSPIKE_ERR_BIN_INCOMPATIBLE_TYPE, - AEROSPIKE_ERR_RECORD_TOO_BIG, - AEROSPIKE_ERR_RECORD_BUSY, - AEROSPIKE_ERR_SCAN_ABORTED, - AEROSPIKE_ERR_UNSUPPORTED_FEATURE, - AEROSPIKE_ERR_BIN_NOT_FOUND, - AEROSPIKE_ERR_DEVICE_OVERLOAD, - AEROSPIKE_ERR_RECORD_KEY_MISMATCH, - AEROSPIKE_ERR_NAMESPACE_NOT_FOUND, - AEROSPIKE_ERR_BIN_NAME, - AEROSPIKE_ERR_FAIL_FORBIDDEN, - AEROSPIKE_ERR_FAIL_ELEMENT_NOT_FOUND, - AEROSPIKE_ERR_FAIL_ELEMENT_EXISTS, - AEROSPIKE_ERR_ENTERPRISE_ONLY, - AEROSPIKE_ERR_OP_NOT_APPLICABLE, - AEROSPIKE_FILTERED_OUT, - AEROSPIKE_LOST_CONFLICT, - AEROSPIKE_QUERY_END = 50, - AEROSPIKE_SECURITY_NOT_SUPPORTED, - AEROSPIKE_SECURITY_NOT_ENABLED, - AEROSPIKE_SECURITY_SCHEME_NOT_SUPPORTED, - AEROSPIKE_INVALID_COMMAND, - AEROSPIKE_INVALID_FIELD, - AEROSPIKE_ILLEGAL_STATE, - AEROSPIKE_INVALID_USER = 60, - AEROSPIKE_USER_ALREADY_EXISTS, - AEROSPIKE_INVALID_PASSWORD, - AEROSPIKE_EXPIRED_PASSWORD, - AEROSPIKE_FORBIDDEN_PASSWORD, - AEROSPIKE_INVALID_CREDENTIAL, - AEROSPIKE_INVALID_ROLE = 70, - AEROSPIKE_ROLE_ALREADY_EXISTS, - AEROSPIKE_INVALID_PRIVILEGE, - AEROSPIKE_NOT_AUTHENTICATED = 80, - AEROSPIKE_ROLE_VIOLATION, - AEROSPIKE_ERR_UDF = 100, - AEROSPIKE_ERR_BATCH_DISABLED = 150, - AEROSPIKE_ERR_BATCH_MAX_REQUESTS_EXCEEDED, - AEROSPIKE_ERR_BATCH_QUEUES_FULL, - AEROSPIKE_ERR_GEO_INVALID_GEOJSON = 160, - AEROSPIKE_ERR_INDEX_FOUND = 200, - AEROSPIKE_ERR_INDEX_NOT_FOUND, - AEROSPIKE_ERR_INDEX_OOM, - AEROSPIKE_ERR_INDEX_NOT_READABLE, - AEROSPIKE_ERR_INDEX, - AEROSPIKE_ERR_INDEX_NAME_MAXLEN, - AEROSPIKE_ERR_INDEX_MAXCOUNT, - AEROSPIKE_ERR_QUERY_ABORTED = 210, - AEROSPIKE_ERR_QUERY_QUEUE_FULL, - AEROSPIKE_ERR_QUERY_TIMEOUT, - AEROSPIKE_ERR_QUERY, - AEROSPIKE_ERR_UDF_NOT_FOUND = 1301, - AEROSPIKE_ERR_LUA_FILE_NOT_FOUND - } - - enum HLLWriteFlags { - DEFAULT, - CREATE_ONLY, - UPDATE_ONLY, - NO_FAIL = 4, - ALLOW_FOLD = 8 - } - - interface IAddonUDF { - module: string; - funcname: string; - args: AerospikeRecordValue[]; - } - - interface IAddonNode { - name: string; - address: string; - } - - interface IEventLoopStats { - inFlight: number; - queued: number; - } - - interface IAddonConnectionStats { - inPool: number; - inUse: number; - opened: number; - closed: number; - } - - interface IAddonNodeStats { - name: string; - syncConnections: IAddonConnectionStats; - asyncConnections: IAddonConnectionStats; - } - - interface IAddonStats { - commands: IEventLoopStats; - nodes: IAddonNodeStats[]; - } - - interface IAddonQueryOptions { - filters: SindexFilterPredicate[]; - selected: string[]; - nobins: boolean; - udf: IAddonUDF; - ops: Operation[] - } - - interface IAddonScanOptions { - selected: string[]; - nobins: boolean; - concurrent: boolean; - udf: IAddonUDF; - ops: Operation[] - } - - interface IAddonEvent { - name: string; - [key: string]: any; - } - - type AddonCallback = (error?: Error, result: any) => void; - type AddonEventCallback = (event: IAddonEvent) => void; - - class AddonAerospikeClient { - public addSeedHost(hostname: stirng, port: number): void; - public applyAsync(key: IKey, udf: IAddonUDF, policy: BasePolicy, callback: AddonCallback): void; - public batchExists(keys: IKey[], policy: BasePolicy, callback: AddonCallback): void; - public batchGet(keys: IKey[], policy: BasePolicy, callback: AddonCallback): void; - public batchRead(records: AerospikeRecord[], policy: BasePolicy, callback: AddonCallback): void; - public batchSelect(keys: IKey[], bins: string[], policy: BasePolicy, callback: AddonCallback): void; - public close(): void; - public connect(callback: AddonCallback): void; - public existsAsync(key: IKey, policy: BasePolicy, callback: AddonCallback): void; - public getAsync(key: IKey, policy: BasePolicy, callback: AddonCallback): void; - public getNodes(): IAddonNode[]; - public getStats(): IAddonStats; - public hasPendingAsyncCommands(): boolean; - public indexCreate(ns: string, set: string, bin: string, indexName: string, indexType: IndexType, indexDataType: IndexDataType, policy: InfoPolicy, callback: AddonCallback): void; - public indexRemove(ns: string, indexName: string, policy: InfoPolicy, callback: AddonCallback): void; - public infoAny(request: string, policy: InfoPolicy, callback: AddonCallback): void; - public infoForeach(request: string, policy: InfoPolicy, callback: AddonCallback): void; - public infoHost(request: string, host: IHost, policy: InfoPolicy, callback: AddonCallback): void; - public infoNode(request: string, node: string, policy: InfoPolicy, callback: AddonCallback): void; - public isConnected(): bool; - public jobInfo(jobID: number, module: string, policy: InfoPolicy, callback: AddonCallback): void; - public operateAsync(key: IKey, operations: Operation[], meta: IRecordMetadata, policy: OperatePolicy, callback: AddonCallback): void; - public putAsync(key: IKey, record: AerospikeRecord, meta: IRecordMetadata, policy: WritePolicy, callback: AddonCallback): void; - public queryApply(ns: string, set: string, options: IAddonQueryOptions, policy: QueryPolicy, callback: AddonCallback): void; - public queryAsync(ns: string, set: string, options: IAddonQueryOptions, policy: QueryPolicy, callback: AddonCallback): void; - public queryBackground(ns: string, set: string, options: IAddonQueryOptions, policy: QueryPolicy, queryID: number, callback: AddonCallback); - public queryForeach(ns: string, set: string, options: IAddonQueryOptions, policy: QueryPolicy, callback: AddonCallback): void; - public removeAsync(key: IKey, policy: RemovePolicy, callback: AddonCallback): void; - public removeSeedHost(hostname: string, port: number): void; - public scanAsync(ns: string, set: string, options: IAddonScanOptions, policy: ScanPolicy, scanID: number, callback: AddonCallback): void; - public scanBackground(ns: string, set: string, options: IAddonScanOptions, policy: ScanPolicy, scanID: number, callback: AddonCallback): void; - public selectAsync(key: string, bins: string[], policy: ReadPolicy, callback: AddonCallback): void; - public setupEventCb(callback: AddonEventCallback): void; - public truncate(ns: string, set: string, beforeNanos: number, policy: InfoPolicy, callback: AddonCallback): void; - public udfRegister(filename: string, type: Language, policy: InfoPolicy, callback: AddonCallback): void; - public udfRemove(module: string, policy: InfoPolicy, callback: AddonCallback): void; - public updateLogging(log: ILogInfo): AddonAerospikeClient; - } - - // filter.js - class SindexFilterPredicate { - public constructor ( - predicate: Predicates, - bin: string, - dataType: IndexDataType, - indexType: IndexType, - props?: Record - ); - public predicate: Predicates; - public bin: string; - public datatype: IndexDataType; - public type: IndexType; - } - - class EqualPredicate extends SindexFilterPredicate { - constructor(bin: string, value: string | number, dataType: IndexDataType, indexType: IndexType); - public val: string | number; - } - - class RangePredicate extends SindexFilterPredicate { - constructor(bin: string, min: number, max: number, dataType: IndexDataType, indexType: IndexType); - public min: number; - public max: number; - } - - class GeoPredicate extends SindexFilterPredicate { - constructor (bin: string, value: GeoJSON, indexType: IndexType); - public val: GeoJSON; - } - - // query.js - interface IQueryOptions { - udf?: IAddonUDF; // query.js#581 Why udf with caps? - concurrent?; - percentage?; - priority?; - filters?; - select?: string[]; - nobins?: boolean; - } - - class Query { - public client: Client; - public ns: string; - public set: string; - public filters: SindexFilterPredicate[]; - public selected: string[]; - public nobins: boolean; - public udf: IAddonUDF; - public ops?: Operation[] - constructor(client: Client, ns: string, set: string, options?: IQueryOptions); - public select(bins: string[]): void; - public select(...bins: string[]): void; - public where(predicate: SindexFilterPredicate | PredicateExpression[]): void; - public setSindexFilter(sindexFilter: SindexFilterPredicate): void; - public setUdf(udfModule: string, udfFunction: string, udfArgs?: any[]): void; - public foreach(policy?: QueryPolicy, dataCb?: (data: AerospikeRecord) => void, errorCb?: (error: Error) => void, endCb: () => void): RecordStream; - public results(policy?: QueryPolicy): Promise; - public apply(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: QueryPolicy): Promise; - public apply(udfModule: string, udfFunction: string, callback: TypedCallback): void; - public apply(udfModule: string, udfFunction: string, udfArgs?: any[], callback: TypedCallback): void; - public apply(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: QueryPolicy, callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: WritePolicy, queryID?: number): Promise; - public background(udfModule: string, udfFunction: string, callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: WritePolicy, callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: WritePolicy, queryID?: number, callback: TypedCallback): void; - public operate(operations: Operation[], policy?: QueryPolicy, queryID?: number): Promise; - public operate(operations: Operation[], callback: TypedCallback): void; - public operate(operations: Operation[], policy?: QueryPolicy, callback: TypedCallback): void; - public operate(operations: Operation[], policy?: QueryPolicy, queryID?: number, callback: TypedCallback): void; - } - - // cdt_context.js - enum CdtItemType { - LIST_INDEX = 0x10, - LIST_RANK, - LIST_VALUE = 0x13, - MAP_INDEX = 0x20, - MAP_RANK, - MAP_KEY, - MAP_VALUE - } - - class CdtItems extends Array { - public push(v: [number, CdtContext]); - } - +declare module "status" { + export const ERR_INVALID_NODE: any; + export const ERR_NO_MORE_CONNECTIONS: any; + export const ERR_ASYNC_CONNECTION: any; + export const ERR_CLIENT_ABORT: any; + export const ERR_INVALID_HOST: any; + export const NO_MORE_RECORDS: any; + export const ERR_PARAM: any; + export const ERR_CLIENT: any; + export const OK: any; + export const ERR_SERVER: any; + export const ERR_RECORD_NOT_FOUND: any; + export const ERR_RECORD_GENERATION: any; + export const ERR_REQUEST_INVALID: any; + export const ERR_RECORD_EXISTS: any; + export const ERR_BIN_EXISTS: any; + export const ERR_CLUSTER_CHANGE: any; + export const ERR_SERVER_FULL: any; + export const ERR_TIMEOUT: any; + export const ERR_ALWAYS_FORBIDDEN: any; + export const ERR_CLUSTER: any; + export const ERR_BIN_INCOMPATIBLE_TYPE: any; + export const ERR_RECORD_TOO_BIG: any; + export const ERR_RECORD_BUSY: any; + export const ERR_SCAN_ABORTED: any; + export const ERR_UNSUPPORTED_FEATURE: any; + export const ERR_BIN_NOT_FOUND: any; + export const ERR_DEVICE_OVERLOAD: any; + export const ERR_RECORD_KEY_MISMATCH: any; + export const ERR_NAMESPACE_NOT_FOUND: any; + export const ERR_BIN_NAME: any; + export const ERR_FAIL_FORBIDDEN: any; + export const ERR_FAIL_ELEMENT_NOT_FOUND: any; + export const ERR_FAIL_ELEMENT_EXISTS: any; + export const ERR_ENTERPRISE_ONLY: any; + export const ERR_FAIL_ENTERPRISE_ONLY: any; + export const ERR_OP_NOT_APPLICABLE: any; + export const FILTERED_OUT: any; + export const LOST_CONFLICT: any; + export const QUERY_END: any; + export const SECURITY_NOT_SUPPORTED: any; + export const SECURITY_NOT_ENABLED: any; + export const SECURITY_SCHEME_NOT_SUPPORTED: any; + export const INVALID_COMMAND: any; + export const INVALID_FIELD: any; + export const ILLEGAL_STATE: any; + export const INVALID_USER: any; + export const USER_ALREADY_EXISTS: any; + export const INVALID_PASSWORD: any; + export const EXPIRED_PASSWORD: any; + export const FORBIDDEN_PASSWORD: any; + export const INVALID_CREDENTIAL: any; + export const INVALID_ROLE: any; + export const ROLE_ALREADY_EXISTS: any; + export const INVALID_PRIVILEGE: any; + export const NOT_AUTHENTICATED: any; + export const ROLE_VIOLATION: any; + export const ERR_UDF: any; + export const ERR_BATCH_DISABLED: any; + export const ERR_BATCH_MAX_REQUESTS_EXCEEDED: any; + export const ERR_BATCH_QUEUES_FULL: any; + export const ERR_GEO_INVALID_GEOJSON: any; + export const ERR_INDEX_FOUND: any; + export const ERR_INDEX_NOT_FOUND: any; + export const ERR_INDEX_OOM: any; + export const ERR_INDEX_NOT_READABLE: any; + export const ERR_INDEX: any; + export const ERR_INDEX_NAME_MAXLEN: any; + export const ERR_INDEX_MAXCOUNT: any; + export const ERR_QUERY_ABORTED: any; + export const ERR_QUERY_QUEUE_FULL: any; + export const ERR_QUERY_TIMEOUT: any; + export const ERR_QUERY: any; + export const ERR_UDF_NOT_FOUND: any; + export const ERR_LUA_FILE_NOT_FOUND: any; + export function getMessage(code: any): string; +} +declare module "error" { + export = AerospikeError; + class AerospikeError extends Error { + private static fromASError; + private static copyASErrorProperties; + private static formatMessage; + private constructor(); + code: number; + command: any | null; + func: string | null; + file: string | null; + line: number | null; + inDoubt: boolean; + private setStackTrace; + isServerError(): boolean; + get client(): any; + } +} +declare module "policies/command_queue_policy" { + export = CommandQueuePolicy; + class CommandQueuePolicy { + constructor(props?: { + maxCommandsInProcess?: number | undefined; + maxCommandsInQueue?: number | undefined; + queueInitialCapacity?: number | undefined; + } | undefined); + maxCommandsInProcess: number; + maxCommandsInQueue: number; + queueInitialCapacity: number; + } +} +declare module "event_loop" { + export function releaseEventLoop(): void; + export function registerASEventLoop(): void; + export function referenceEventLoop(): void; + export function unreferenceEventLoop(): void; + export function setCommandQueuePolicy(policy: any): void; +} +declare module "geojson" { + export = GeoJSON; + function GeoJSON(json: any): GeoJSON; + class GeoJSON { + constructor(json: any); + str: string | undefined; + toJSON(): any; + toString(): string; + value(): any; + } + namespace GeoJSON { + function Point(lng: number, lat: number): GeoJSON; + function Polygon(...args: number[][]): GeoJSON; + function Circle(lng: number, lat: number, radius: number): GeoJSON; + } +} +declare module "filter" { + export function range(bin: string, min: number, max: number, indexType?: number | undefined): any; + export function equal(bin: string, value: string): any; + export function contains(bin: string, value: (string | number), indexType: number): any; + export function geoWithinGeoJSONRegion(bin: string, value: GeoJSON, indexType?: number | undefined): any; + export function geoContainsGeoJSONPoint(bin: string, value: GeoJSON, indexType?: number | undefined): any; + export function geoWithinRadius(bin: string, lon: any, lat: number, radius: number, indexType?: number | undefined): any; + export function geoContainsPoint(bin: string, lon: any, lat: number, indexType?: number | undefined): any; + export class SindexFilterPredicate { + constructor(predicate: any, bin: any, dataType: any, indexType: any, props: any); + predicate: any; + bin: any; + datatype: any; + type: any; + } + import GeoJSON = require("geojson"); +} +declare module "cdt_context" { + export = CdtContext; class CdtContext { - public items: CdtItems; - private add(type: CdtItemType, value: CdtContext): CdtContext; - public addListIndex(index: number): CdtContext; - public addListRank(rank: number): CdtContext; - public addListValue(value: AerospikeRecordValue): CdtContext; - public addMapIndex(index: number): CdtContext; - public addMapRank(rank: number): CdtContext; - public addMapKey(key: string): CdtContext; - public addMapValue(value: AerospikeRecordValue): CdtContext; - } - - // operations.js - class Operation { - constructor(op: ScalarOperations, bin: string, props?: Record); - } - - class WriteOperation extends Operation { - public value: any; - } - - class AddOperation extends Operation { - public value: number | Double; - } - - class AppendOperation extends Operation { - public value: string | Buffer; - } - - class PrependOperation extends Operation { - public value: string | Buffer; - } - - class TouchOperation extends Operation { - public ttl: number; - } - - class ListOperation extends Operation { - public andReturn(returnType: ListReturnType): ListOperation; - public withContext(contextOrFunction: CdtContext | Function): ListOperation; - public invertSelection(): void; - } - - class InvertibleListOp extends ListOperation { - public inverted: boolean; - public invertSelection(): InvertibleListOp; - } - - class MapOperation extends Operation { - andReturn(returnType: MapReturnType): MapOperation; - public withContext(contextOrFunction: CdtContext | Function): MapOperation; - } - + static getContextType(ctx: CdtContext, type: number): number; + items: any[]; + addListIndex(index: number): CdtContext; + addListRank(rank: number): CdtContext; + addListValue(value: any): CdtContext; + addMapIndex(index: number): CdtContext; + addMapRank(rank: number): CdtContext; + addMapKey(key: any): CdtContext; + addMapValue(value: any): CdtContext; + private add; + } +} +declare module "exp" { + export function bool(value: any): { + [x: number]: any; + op: any; + }[]; + export function int(value: any): { + [x: number]: any; + op: any; + }[]; + export function uint(value: any): { + [x: number]: any; + op: any; + }[]; + export function float(value: any): { + [x: number]: any; + op: any; + }[]; + export function str(value: any): { + [x: number]: any; + op: any; + }[]; + export function bytes(value: any, size: any): { + [x: number]: any; + op: any; + }[]; + export function geo(value: any): { + [x: number]: any; + op: any; + }[]; + export function nil(): { + op: any; + value: null; + }[]; + export function keyInt(): { + [x: number]: any; + op: any; + }[]; + export function keyStr(): { + [x: number]: any; + op: any; + }[]; + export function keyBlob(): { + [x: number]: any; + op: any; + }[]; + export function keyExist(): AerospikeExp; + export function binBool(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binInt(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binFloat(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binStr(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binBlob(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binGeo(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binList(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binMap(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binHll(binName: any): { + [x: number]: any; + op: any; + }[]; + export function binType(binName: any): ({ + op: any; + strVal: any; + } | { + op: any; + count: number; + })[]; + export function binExists(binName: string): boolean; + export function setName(): { + op: any; + count: number; + }[]; + export function deviceSize(): { + op: any; + count: number; + }[]; + export function lastUpdate(): { + op: any; + count: number; + }[]; + export function sinceUpdate(): { + op: any; + count: number; + }[]; + export function voidTime(): { + op: any; + count: number; + }[]; + export function ttl(): { + op: any; + count: number; + }[]; + export function isTombstone(): { + op: any; + count: number; + }[]; + export function memorySize(): { + op: any; + count: number; + }[]; + export function digestModulo(): { + op: any; + count: number; + }[]; + export function eq(left: any, right: any): { + op: any; + count: number; + }[]; + export function ne(left: any, right: any): { + op: any; + count: number; + }[]; + export function gt(left: any, right: any): { + op: any; + count: number; + }[]; + export function ge(left: any, right: any): { + op: any; + count: number; + }[]; + export function lt(left: any, right: any): { + op: any; + count: number; + }[]; + export function le(left: any, right: any): { + op: any; + count: number; + }[]; + export function cmpRegex(options: number, regex: string, cmpStr: AerospikeExp): AerospikeExp; + export function cmpGeo(left: any, right: any): { + op: any; + count: number; + }[]; + export function not(expr: AerospikeExp): AerospikeExp; + export function and(...expr: any[]): never[]; + export function or(...expr: any[]): never[]; + export function exclusive(...expr: any[]): never[]; + export function add(...expr: any[]): never[]; + export function sub(...expr: any[]): never[]; + export function mul(...expr: any[]): never[]; + export function div(...expr: any[]): never[]; + export function pow(...params: any[]): any[]; + export function log(...params: any[]): any[]; + export function mod(...params: any[]): any[]; + export function abs(...params: any[]): any[]; + export function floor(...params: any[]): any[]; + export function ceil(...params: any[]): any[]; + export function toInt(...params: any[]): any[]; + export function toFloat(...params: any[]): any[]; + export function intAnd(...expr: any[]): never[]; + export function intOr(...expr: any[]): never[]; + export function intXor(...expr: any[]): never[]; + export function intNot(...params: any[]): any[]; + export function intLshift(...params: any[]): any[]; + export function intRshift(...params: any[]): any[]; + export function intArshift(...params: any[]): any[]; + export function intCount(...params: any[]): any[]; + export function intLscan(...params: any[]): any[]; + export function intRscan(...params: any[]): any[]; + export function min(...expr: any[]): never[]; + export function max(...expr: any[]): never[]; + export function cond(...expr: any[]): never[]; + function _let(...expr: any[]): never[]; + export function def(varName: string, expr: AerospikeExp): AerospikeExp; + function _var(varName: string): AerospikeExp; + export namespace lists { + function size(bin: any, ctx?: any): any; + function getByValue(bin: any, value: any, returnType: any, ctx?: any): any; + function getByValueRange(bin: any, begin: any, end: any, returnType: any, ctx?: any): any; + function getByValueList(bin: any, value: any, returnType: any, ctx?: any): any; + function getByRelRankRangeToEnd(bin: any, value: any, rank: any, returnType: any, ctx?: any): any; + function getByRelRankRange(bin: any, value: any, rank: any, count: any, returnType: any, ctx?: any): any; + function getByIndex(bin: any, index: any, valueType: any, returnType: any, ctx?: any): any; + function getByIndexRangeToEnd(bin: any, index: any, returnType: any, ctx?: any): any; + function getByIndexRange(bin: any, index: any, count: any, returnType: any, ctx?: any): any; + function getByRank(bin: any, rank: any, valueType: any, returnType: any, ctx?: any): any; + function getByRankRangeToEnd(bin: any, rank: any, returnType: any, ctx?: any): any; + function getByRankRange(bin: any, rank: any, count: any, returnType: any, ctx?: any): any; + function append(bin: any, value: any, policy?: any, ctx?: any): any; + function appendItems(bin: any, value: any, policy?: any, ctx?: any): any; + function insert(bin: any, value: any, idx: any, policy?: any, ctx?: any): any; + function insertItems(bin: any, value: any, idx: any, policy?: any, ctx?: any): any; + function increment(bin: any, value: any, idx: any, policy?: any, ctx?: any): any; + function set(bin: any, value: any, idx: any, policy?: any, ctx?: any): any; + function clear(bin: any, ctx?: any): any; + function sort(bin: any, order: number, ctx?: any): any; + function removeByValue(bin: any, value: any, ctx?: any): any; + function removeByValueList(bin: any, values: any, ctx?: any): any; + function removeByValueRange(bin: any, end: any, begin: any, ctx?: any): any; + function removeByRelRankRangeToEnd(bin: any, rank: any, value: any, ctx?: any): any; + function removeByRelRankRange(bin: any, count: any, rank: any, value: any, ctx?: any): any; + function removeByIndex(bin: any, idx: any, ctx?: any): any; + function removeByIndexRangeToEnd(bin: any, idx: any, ctx?: any): any; + function removeByIndexRange(bin: any, count: any, idx: any, ctx?: any): any; + function removeByRank(bin: any, rank: any, ctx?: any): any; + function removeByRankRangeToEnd(bin: any, rank: any, ctx?: any): any; + function removeByRankRange(bin: any, count: any, rank: any, ctx?: any): any; + } + export namespace maps { + export function put(bin: any, value: any, key: any, policy?: any, ctx?: any): any; + export function putItems(bin: any, map: any, policy?: any, ctx?: any): any; + export function increment_1(bin: any, value: any, key: any, policy?: any, ctx?: any): any; + export { increment_1 as increment }; + export function clear_1(bin: any, ctx?: any): any; + export { clear_1 as clear }; + export function removeByKey(bin: any, key: any, ctx?: any): any; + export function removeByKeyList(bin: any, keys: any, ctx?: any): any; + export function removeByKeyRange(bin: any, end: any, begin: any, ctx?: any): any; + export function removeByKeyRelIndexRangeToEnd(bin: any, idx: any, key: any, ctx?: any): any; + export function removeByKeyRelIndexRange(bin: any, count: any, idx: any, key: any, ctx?: any): any; + export function removeByValue_1(bin: any, value: any, ctx?: any): any; + export { removeByValue_1 as removeByValue }; + export function removeByValueList_1(bin: any, values: any, ctx?: any): any; + export { removeByValueList_1 as removeByValueList }; + export function removeByValueRange_1(bin: any, end: any, begin: any, ctx?: any): any; + export { removeByValueRange_1 as removeByValueRange }; + export function removeByValueRelRankRangeToEnd(bin: any, rank: any, value: any, ctx?: any): any; + export function removeByValueRelRankRange(bin: any, count: any, rank: any, value: any, key: any, ctx?: any): any; + export function removeByIndex_1(bin: any, idx: any, ctx?: any): any; + export { removeByIndex_1 as removeByIndex }; + export function removeByIndexRangeToEnd_1(bin: any, idx: any, ctx?: any): any; + export { removeByIndexRangeToEnd_1 as removeByIndexRangeToEnd }; + export function removeByIndexRange_1(bin: any, count: any, idx: any, ctx?: any): any; + export { removeByIndexRange_1 as removeByIndexRange }; + export function removeByRank_1(bin: any, rank: any, ctx?: any): any; + export { removeByRank_1 as removeByRank }; + export function removeByRankRangeToEnd_1(bin: any, rank: any, ctx?: any): any; + export { removeByRankRangeToEnd_1 as removeByRankRangeToEnd }; + export function removeByRankRange_1(bin: any, count: any, rank: any, ctx?: any): any; + export { removeByRankRange_1 as removeByRankRange }; + export function size_1(bin: any, ctx?: any): any; + export { size_1 as size }; + export function getByKey(bin: any, key: any, valueType: any, returnType: any, ctx?: any): any; + export function getByKeyRange(bin: any, end: any, begin: any, returnType: any, ctx?: any): any; + export function getByKeyList(bin: any, keys: any, returnType: any, ctx?: any): any; + export function getByKeyRelIndexRangeToEnd(bin: any, idx: any, key: any, returnType: any, ctx?: any): any; + export function getByKeyRelIndexRange(bin: any, count: any, idx: any, key: any, returnType: any, ctx?: any): any; + export function getByValue_1(bin: any, value: any, returnType: any, ctx?: any): any; + export { getByValue_1 as getByValue }; + export function getByValueRange_1(bin: any, end: any, begin: any, returnType: any, ctx?: any): any; + export { getByValueRange_1 as getByValueRange }; + export function getByValueList_1(bin: any, values: any, returnType: any, ctx?: any): any; + export { getByValueList_1 as getByValueList }; + export function getByValueRelRankRangeToEnd(bin: any, rank: any, value: any, returnType: any, ctx?: any): any; + export function getByValueRelRankRange(bin: any, count: any, rank: any, value: any, returnType: any, ctx?: any): any; + export function getByIndex_1(bin: any, idx: any, valueType: any, returnType: any, ctx?: any): any; + export { getByIndex_1 as getByIndex }; + export function getByIndexRangeToEnd_1(bin: any, idx: any, returnType: any, ctx?: any): any; + export { getByIndexRangeToEnd_1 as getByIndexRangeToEnd }; + export function getByIndexRange_1(bin: any, count: any, idx: any, returnType: any, ctx?: any): any; + export { getByIndexRange_1 as getByIndexRange }; + export function getByRank_1(bin: any, rank: any, valueType: any, returnType: any, ctx?: any): any; + export { getByRank_1 as getByRank }; + export function getByRankRangeToEnd_1(bin: any, rank: any, returnType: any, ctx?: any): any; + export { getByRankRangeToEnd_1 as getByRankRangeToEnd }; + export function getByRankRange_1(bin: any, count: any, rank: any, returnType: any, ctx?: any): any; + export { getByRankRange_1 as getByRankRange }; + } + export namespace bit { + export function reSize(bin: any, flags: number, byteSize: number, policy?: any): any; + export function insert_1(bin: any, value: any, byteOffset: any, policy?: any): any; + export { insert_1 as insert }; + export function remove(bin: any, byteSize: number, byteOffset: any, policy?: any): any; + export function set_1(bin: any, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export { set_1 as set }; + export function or(bin: any, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export function xor(bin: any, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export function and(bin: any, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export function not(bin: any, bitSize: any, bitOffset: any, policy?: any): any; + export function lShift(bin: any, shift: number, bitSize: any, bitOffset: any, policy?: any): any; + export function rShift(bin: any, shift: number, bitSize: any, bitOffset: any, policy?: any): any; + export function add(bin: any, action: number, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export function subtract(bin: any, action: number, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export function setInt(bin: any, value: any, bitSize: any, bitOffset: any, policy?: any): any; + export function get(bin: any, bitSize: any, bitOffset: any): any; + export function count(bin: any, bitSize: any, bitOffset: any): number; + export function lScan(bin: any, value: any, bitSize: any, bitOffset: any): number; + export function rScan(bin: any, value: any, bitSize: any, bitOffset: any): number; + export function getInt(bin: any, sign: boolean, bitSize: any, bitOffset: any): any; + } + export namespace hll { + export function initMH(bin: any, mhBitCount: number, indexBitCount: number, policy?: any): any; + export function init(bin: any, indexBitCount: number, policy?: any): any; + export function addMH(bin: any, mhBitCount: number, indexBitCount: number, list: any, policy?: any): any; + export function add_1(bin: any, indexBitCount: number, list: any, policy?: any): any; + export { add_1 as add }; + export function update(bin: any, list: any, policy?: any): any; + export function getCount(bin: any): any; + export function getUnion(bin: any, list: any): any; + export function getUnionCount(bin: any, list: any): any; + export function getIntersectCount(bin: any, list: any): any; + export function getSimilarity(bin: any, list: any): any[]; + export function describe(bin: any): any; + export function mayContain(bin: any, list: any): any; + } + function _val(value: any): { + [x: number]: any; + op: any; + }[]; + export { _val as list, _val as map, _let as let, _var as var }; +} +declare module "info" { + export function parse(info: string): any; + export const separators: { + bins: (string | typeof splitBins)[]; + 'bins/*': (typeof splitBins)[]; + 'namespace/*': string[]; + service: string[]; + sindex: string[]; + 'sindex/*': string[]; + 'sindex/*/**': string[]; + 'udf-list': string[]; + 'get-dc-config': string[]; + sets: string[]; + 'sets/*': string[]; + 'sets/*/**': (string | typeof chop)[]; + }; + function splitBins(str: any): { + stats: {}; + names: any[]; + }; + function chop(str: any): any; + export {}; +} +declare module "operations" { + export function read(bin: string): Operation; + export function write(bin: string, value: any): Operation; + export function add(bin: string, value: (number | any)): Operation; + export function incr(bin: any, value: any): any; + export function append(bin: string, value: (string | Buffer)): Operation; + export function prepend(bin: string, value: (string | Buffer)): Operation; + export function touch(ttl?: number | undefined): Operation; + function _delete(): Operation; + export class Operation { + protected constructor(); + op: any; + bin: any; + } + export { _delete as delete }; +} +declare module "lists" { + export function setOrder(bin: string, order: number): any; + export function sort(bin: string, flags: number): any; + export function append(bin: string, value: any, policy?: any): any; + export function appendItems(bin: string, list: Array, policy?: any): any; + export function insert(bin: string, index: number, value: any, policy?: any): any; + export function insertItems(bin: string, index: number, list: Array, policy: any): any; + export function pop(bin: string, index: number): any; + export function popRange(bin: string, index: number, count?: number | undefined): any; + export function remove(bin: string, index: number): any; + export function removeRange(bin: string, index: number, count?: number | undefined): any; + export function removeByIndex(bin: string, index: number, returnType?: number | undefined): any; + export function removeByIndexRange(bin: string, index: number, count?: number | undefined, returnType?: number | undefined): any; + export function removeByValue(bin: string, value: any, returnType?: number | undefined): any; + export function removeByValueList(bin: string, values: Array, returnType?: number | undefined): any; + export function removeByValueRange(bin: string, begin: any | null, end: any | null, returnType?: number | undefined): any; + export function removeByValueRelRankRange(bin: string, value: any, rank: number, count?: number | undefined, returnType?: number | undefined): any; + export function removeByRank(bin: string, rank: number, returnType?: number | undefined): any; + export function removeByRankRange(bin: string, rank: any, count?: number | undefined, returnType?: number | undefined): any; + export function clear(bin: string): any; + export function set(bin: string, index: number, value: any, policy?: any): any; + export function trim(bin: string, index: number, count: number): any; + export function get(bin: string, index: number): any; + export function getRange(bin: string, index: number, count?: number | undefined): any; + export function getByIndex(bin: string, index: number, returnType?: number | undefined): any; + export function getByIndexRange(bin: string, index: number, count?: number | undefined, returnType?: number | undefined): any; + export function getByValue(bin: string, value: any, returnType?: number | undefined): any; + export function getByValueList(bin: string, values: Array, returnType?: number | undefined): any; + export function getByValueRange(bin: string, begin: any | null, end: any | null, returnType?: number | undefined): any; + export function getByValueRelRankRange(bin: string, value: any, rank: number, count?: number | undefined, returnType?: number | undefined): any; + export function getByRank(bin: string, rank: number, returnType?: number | undefined): any; + export function getByRankRange(bin: string, rank: any, count?: number | undefined, returnType?: number | undefined): any; + export function increment(bin: string, index: number, value?: number | undefined, policy?: any): any; + export function size(bin: string): any; +} +declare module "hll" { + export function init(bin: string, indexBits: number, minhashBits?: number | undefined): any; + export function add(bin: string, list: any[], indexBits?: number | undefined, minhashBits?: number | undefined): any; + export function setUnion(bin: string, list: any[]): any; + export function refreshCount(bin: string): any; + export function fold(bin: string, indexBits: number): any; + export function getCount(bin: string): any; + export function getUnion(bin: string, list: any[]): any; + export function getUnionCount(bin: string, list: any[]): any; + export function getIntersectCount(bin: string, list: any[]): any; + export function getSimilarity(bin: string, list: any[]): any; + export function describe(bin: string): any; +} +declare module "maps" { + export function setPolicy(bin: string, policy: MapPolicy): any; + export function put(bin: string, key: any, value: any, policy?: MapPolicy): any; + export function putItems(bin: string, items: object, policy?: MapPolicy): any; + export function increment(bin: string, key: any, incr: number, policy?: MapPolicy): any; + export function decrement(bin: string, key: any, decr: number, policy?: MapPolicy): any; + export function clear(bin: string): any; + export function removeByKey(bin: string, key: any, returnType?: number | undefined): any; + export function removeByKeyList(bin: string, keys: Array, returnType?: number | undefined): any; + export function removeByKeyRange(bin: string, begin: any | null, end: any | null, returnType?: number | undefined): any; + export function removeByKeyRelIndexRange(bin: string, key: any, index: number, count?: number | undefined, returnType?: number | undefined): any; + export function removeByValue(bin: string, value: any, returnType?: number | undefined): any; + export function removeByValueList(bin: string, values: Array, returnType?: number | undefined): any; + export function removeByValueRange(bin: string, begin: any | null, end: any | null, returnType?: number | undefined): any; + export function removeByValueRelRankRange(bin: string, value: any, rank: number, count?: number | undefined, returnType?: number | undefined): any; + export function removeByIndex(bin: string, index: number, returnType?: number | undefined): any; + export function removeByIndexRange(bin: string, index: number, count?: number | undefined, returnType?: number | undefined): any; + export function removeByRank(bin: string, rank: number, returnType?: number | undefined): any; + export function removeByRankRange(bin: string, rank: any, count?: number | undefined, returnType?: number | undefined): any; + export function size(bin: string): any; + export function getByKey(bin: string, key: any, returnType?: number | undefined): any; + export function getByKeyRange(bin: string, begin: any | null, end: any | null, returnType?: number | undefined): any; + export function getByKeyRelIndexRange(bin: string, key: any, index: number, count?: number | undefined, returnType?: number | undefined): any; + export function getByValue(bin: string, value: any, returnType?: number | undefined): any; + export function getByValueRange(bin: string, begin: any | null, end: any | null, returnType?: number | undefined): any; + export function getByValueRelRankRange(bin: string, value: any, rank: number, count?: number | undefined, returnType?: number | undefined): any; + export function getByIndex(bin: string, index: number, returnType?: number | undefined): any; + export function getByIndexRange(bin: string, index: number, count?: number | undefined, returnType?: number | undefined): any; + export function getByRank(bin: string, rank: number, returnType?: number | undefined): any; + export function getByRankRange(bin: string, rank: any, count: number, returnType?: number | undefined): any; +} +declare module "bitwise" { + export function resize(bin: string, size: number, flags?: number | undefined): BitwiseOperation; + export function insert(bin: string, byteOffset: any, value: Buffer): BitwiseOperation; + export function remove(bin: string, byteOffset: number, byteSize: number): BitwiseOperation; + export function set(bin: string, bitOffset: number, bitSize: number, value: number | Buffer): BitwiseOperation; + export function or(bin: string, bitOffset: number, bitSize: number, value: Buffer): BitwiseOperation; + export function xor(bin: string, bitOffset: number, bitSize: number, value: Buffer): BitwiseOperation; + export function and(bin: string, bitOffset: number, bitSize: number, value: Buffer): BitwiseOperation; + export function not(bin: string, bitOffset: number, bitSize: number): BitwiseOperation; + export function lshift(bin: string, bitOffset: number, bitSize: number, shift: number): BitwiseOperation; + export function rshift(bin: string, bitOffset: number, bitSize: number, shift: number): BitwiseOperation; + export function add(bin: string, bitOffset: number, bitSize: number, value: number, sign: boolean): OverflowableBitwiseOp; + export function subtract(bin: string, bitOffset: number, bitSize: number, value: number, sign: boolean): OverflowableBitwiseOp; + export function get(bin: string, bitOffset: number, bitSize: number): BitwiseOperation; + export function getInt(bin: string, bitOffset: number, bitSize: number, sign: boolean): BitwiseOperation; + export function lscan(bin: string, bitOffset: number, bitSize: number, value: boolean): BitwiseOperation; + export function rscan(bin: string, bitOffset: number, bitSize: number, value: boolean): BitwiseOperation; class BitwiseOperation extends Operation { withPolicy(policy: BitwisePolicy): BitwiseOperation; + policy: any; } - class OverflowableBitwiseOp extends BitwiseOperation { - public overflowAction: BitwiseOverflow; - public onOverflow(action: BitwiseOverflow): OverflowableBitwiseOp; - } - - // policies - interface IBasePolicyProps { - socketTimeout?: number; - totalTimeout?: number; - timeout?: number; - maxRetries?: number; - compress?: boolean; - } - + overflowAction: any; + onOverflow(action: number): OverflowableBitwiseOp; + } + import Operation_1 = require("operations"); + import Operation = Operation_1.Operation; + export {}; +} +declare module "exp_operations" { + export function read(bin: string, exp: any, flags: any): Operation; + export function write(bin: string, exp: any, flags: any): Operation; + export class ExpOperation { + protected constructor(); + op: any; + bin: any; + exp: any; + flags: any; + } +} +declare module "policies/base_policy" { + export = BasePolicy; class BasePolicy { - public socketTimeout: number; - public totalTimeout: number; - public maxRetries: number; - public compress: boolean; - - constructor(props?: IBasePolicyProps); - } - - interface IApplyPolicyProps extends IBasePolicyProps { - key?: PolicyKey; - commitLevel?: PolicyCommitLevel; - ttl?: number; - durableDelete?: boolean; - } - + constructor(props: any); + socketTimeout: number; + totalTimeout: number; + maxRetries: number; + filterExpression: any; + compress: boolean; + } +} +declare module "policies/apply_policy" { + export = ApplyPolicy; class ApplyPolicy extends BasePolicy { - public key?: PolicyKey; - public commitLevel?: PolicyCommitLevel; - public ttl?: number; - public durableDelete: boolean; - constructor(props?: IApplyPolicyProps); - } - - interface IBatchPolicyProps extends IBasePolicyProps { - deserialize?: boolean; - allowInline?: boolean; - sendSetName?: boolean; - readModeAP?: PolicyReadModeAP; - readModeSC?: PolicyReadModeSC; - } - + key: number; + commitLevel: number; + ttl: number; + durableDelete: boolean; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/operate_policy" { + export = OperatePolicy; + class OperatePolicy extends BasePolicy { + key: number; + gen: number; + exists: number; + replica: number; + commitLevel: number; + deserialize: boolean; + durableDelete: boolean; + readModeAP: number; + readModeSC: number; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/query_policy" { + export = QueryPolicy; + class QueryPolicy extends BasePolicy { + deserialize: boolean; + failOnClusterChange: boolean; + infoTimeout: number; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/read_policy" { + export = ReadPolicy; + class ReadPolicy extends BasePolicy { + key: number; + replica: number; + readModeAP: number; + readModeSC: number; + deserialize: boolean; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/remove_policy" { + export = RemovePolicy; + class RemovePolicy extends BasePolicy { + generation: number; + key: number; + gen: number; + commitLevel: number; + durableDelete: boolean; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/scan_policy" { + export = ScanPolicy; + class ScanPolicy extends BasePolicy { + durableDelete: boolean; + recordsPerSecond: number; + maxRecords: number; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/write_policy" { + export = WritePolicy; + class WritePolicy extends BasePolicy { + compressionThreshold: number; + key: number; + gen: number; + exists: number; + commitLevel: number; + durableDelete: boolean; + } + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/batch_policy" { + export = BatchPolicy; class BatchPolicy extends BasePolicy { - public deserialize: boolean; - public allowInline: boolean; - public sendSetName: boolean; - public readModeAP: PolicyReadModeAP; - public readModeSC: PolicyReadModeSC; - constructor(props?: IBatchPolicyProps) - } - - interface IBitwisePolicyProps { - writeFlags?: BitwiseWriteFlags - } - - class BitwisePolicy { - public writeFlags: BitwiseWriteFlags; - constructor(props?: IBitwisePolicyProps); + replica: number; + readModeAP: number; + readModeSC: number; + concurrent: boolean; + allowInline: boolean; + allowInlineSSD: boolean; + respondAllKeys: boolean; + sendSetName: boolean; + deserialize: boolean; } - - interface ICommandQueuePolicyProps { - maxCommandsInProcess?: number; - maxCommandsInQueue?: number; - queueInitialCapacity?: number; + import BasePolicy = require("policies/base_policy"); +} +declare module "policies/batch_apply_policy" { + export = BatchApplyPolicy; + class BatchApplyPolicy { + constructor(props?: any); + filterExpression: any; + key: number; + commitLevel: number; + ttl: number; + durableDelete: boolean; } - - class CommandQueuePolicy { - public maxCommandsInProcess: number; - public maxCommandsInQueue: number; - public queueInitialCapacity: number; - constructor(props?: ICommandQueuePolicyProps); +} +declare module "policies/batch_read_policy" { + export = BatchReadPolicy; + class BatchReadPolicy { + constructor(props?: any); + filterExpression: any; + readModeAP: number; + readModeSC: number; } - - interface IHLLPolicyProps { - writeFlags?: HLLWriteFlags; +} +declare module "policies/batch_remove_policy" { + export = BatchRemovePolicy; + class BatchRemovePolicy { + constructor(props?: any); + filterExpression: any; + key: number; + commitLevel: number; + gen: number; + generation: number; + durableDelete: boolean; } - - class HLLPolicy { - public writeFlags: HLLWriteFlags; - constructor(props?: IHLLPolicyProps); +} +declare module "policies/batch_write_policy" { + export = BatchWritePolicy; + class BatchWritePolicy { + constructor(props?: any); + filterExpression: any; + key: number; + commitLevel: number; + gen: number; + exists: number; + durableDelete: boolean; } - - interface IInfoPolicyProps { - sendAsIs?: boolean; - checkBounds?: boolean; +} +declare module "policies/hll_policy" { + export = HLLPolicy; + class HLLPolicy { + constructor(props?: any); + writeFlags: number; } - +} +declare module "policies/info_policy" { + export = InfoPolicy; class InfoPolicy { - public sendAsIs: boolean; - public checkBounds: boolean; - constructor(props?: IInfoPolicyProps); - } - - interface IListPolicyProps { - order?: ListOrder; - writeFlags?: ListWriteFlags; + constructor(props?: any); + timeout: number; + sendAsIs: boolean; + checkBounds: boolean; } - +} +declare module "policies/list_policy" { + export = ListPolicy; class ListPolicy { - public order: ListOrder; - public writeFlags: ListWriteFlags; - constructor(props?: IListPolicyProps); - } - - interface IMapPolicyProps { - order?: MapOrder; - writeMode?: MapWriteMode; - writeFlags?: MapWriteFlags; + constructor(props?: any); + order: number; + writeFlags: number; } - +} +declare module "policies/map_policy" { + export = MapPolicy; class MapPolicy { - public order: MapOrder; - public writeMode: MapWriteMode; - public writeFlags: MapWriteFlags; - constructor(props?: IMapPolicyProps); - } - - interface IOperatePolicyProps extends IBasePolicyProps { - key?: PolicyKey; - gen?: PolicyGen; - exists?: PolicyExists; - replica?: PolicyReplica; - commitLevel?: PolicyCommitLevel; - deserialize?: boolean; - durableDelete?: boolean; - readModeAP?: PolicyReadModeAP; - readModeSC?: PolicyReadModeSC; - } - - class OperatePolicy extends BasePolicy { - public key?: PolicyKey; - public gen?: PolicyGen; - public exists?: PolicyExists; - public replica?: PolicyReplica; - public commitLevel?: PolicyCommitLevel; - public deserialize: boolean; - public durableDelete: boolean; - public readModeAP: PolicyReadModeAP; - public readModeSC: PolicyReadModeSC; - constructor(props?: IOperatePolicyProps); - } - - interface IQueryPolicyProps extends IBasePolicyProps { - deserialize?: boolean; - failOnClusterChange?: boolean; - } - - class QueryPolicy extends BasePolicy { - public deserialize: boolean; - public failOnClusterChange: boolean; - constructor(props?: IQueryPolicyProps); - } - - interface IReadPolicyProps extends IBasePolicyProps { - key?: PolicyKey; - replica?: PolicyReplica; - readModeAP?: PolicyReadModeAP; - readModeSC?: PolicyReadModeSC; - deserialize?: boolean; - } - - class ReadPolicy extends BasePolicy { - public key?: PolicyKey; - public replica?: PolicyReplica; - public readModeAP: PolicyReadModeAP; - public readModeSC: PolicyReadModeSC; - public deserialize: boolean; - constructor(props?: IReadPolicyProps); - } - - interface IRemovePolicyProps extends IBasePolicyProps { - generation?: number; - key?: PolicyKey; - gen?: PolicyGen; - commitLevel?: PolicyCommitLevel; - durableDelete?: boolean; - } - - class RemovePolicy extends BasePolicy { - public generation?: number; - public key?: PolicyKey; - public gen?: PolicyGen; - public commitLevel?: PolicyCommitLevel; - public durableDelete: boolean; - constructor(props?: IRemovePolicyProps); - } - - interface IScanPolicyProps extends IBasePolicyProps { - durableDelete?: boolean; - recordsPerSecond?: number; - maxRecords?: number; - } - - class ScanPolicy extends BasePolicy { - public durableDelete: boolean; - public recordsPerSecond: number; - public maxRecords?: number; // server version >= 4.9, so probably it should be optional - constructor(props?: IScanPolicyProps); - } - - interface IWritePolicyProps extends IBasePolicyProps { - compressionThreshold?: number; - key?: PolicyKey; - gen?: PolicyGen; - exists?: PolicyExists; - commitLevel?: PolicyCommitLevel; - durableDelete?: boolean; - } - - class WritePolicy extends BasePolicy { - public compressionThreshold?: number; - public key?: PolicyKey; - public gen?: PolicyGen; - public exists?: PolicyExists; - public commitLevel?: PolicyCommitLevel; - public durableDelete: boolean; - constructor(props?: IWritePolicyProps); - } - - // client.js - interface IBatchReadRecord { - key: IKey; - bins?: string[]; - readAllBins?: boolean; - } - - interface IBatchSelectEntity { - status: Status; - key: IKey; - meta?: IRecordMetadata; - bins?: AerospikeBins; - } - - interface IIndexOptions { - ns: string; - set: string; - bin: string; - index: string; - type?: IndexType; - datatype: IndexDataType; + constructor(props?: any); + order: number; + writeMode: number; + writeFlags: number; + } +} +declare module "policy" { + export function createPolicy(type: any, values: any): CommandQueuePolicy | BasePolicy | BatchApplyPolicy | BatchReadPolicy | BatchRemovePolicy | BatchWritePolicy | HLLPolicy | InfoPolicy | undefined; + import BasePolicy = require("policies/base_policy"); + import ApplyPolicy = require("policies/apply_policy"); + import OperatePolicy = require("policies/operate_policy"); + import QueryPolicy = require("policies/query_policy"); + import ReadPolicy = require("policies/read_policy"); + import RemovePolicy = require("policies/remove_policy"); + import ScanPolicy = require("policies/scan_policy"); + import WritePolicy = require("policies/write_policy"); + import BatchPolicy = require("policies/batch_policy"); + import BatchApplyPolicy = require("policies/batch_apply_policy"); + import BatchReadPolicy = require("policies/batch_read_policy"); + import BatchRemovePolicy = require("policies/batch_remove_policy"); + import BatchWritePolicy = require("policies/batch_write_policy"); + import CommandQueuePolicy = require("policies/command_queue_policy"); + import HLLPolicy = require("policies/hll_policy"); + import InfoPolicy = require("policies/info_policy"); + import ListPolicy = require("policies/list_policy"); + import MapPolicy = require("policies/map_policy"); + export { BasePolicy, ApplyPolicy, OperatePolicy, QueryPolicy, ReadPolicy, RemovePolicy, ScanPolicy, WritePolicy, BatchPolicy, BatchApplyPolicy, BatchReadPolicy, BatchRemovePolicy, BatchWritePolicy, CommandQueuePolicy, HLLPolicy, InfoPolicy, ListPolicy, MapPolicy }; +} +declare module "features" { + export const CDT_MAP: "cdt-map"; + export const CDT_LIST: "cdt-list"; + export const BLOB_BITS: "blob-bits"; +} +declare module "commands/command" { + const _exports: Class; + export = _exports; +} +declare module "record" { + export = Record; + class Record { + private constructor(); + key: any; + bins: any; + ttl: any; + gen: any; + type: any; + policy: any; + readAllBins: any; + ops: any; + udf: any; } - - interface ITypedIndexOptions { +} +declare module "commands/batch_command" { + function _exports(asCommand: any): { + new (): { + convertResult(results: any): any; + }; + }; + export = _exports; +} +declare module "commands/connect_command" { + function _exports(asCommand: any): { + new (client: any, callback: any): { + ensureConnected: boolean; + }; + }; + export = _exports; +} +declare module "commands/exists_command" { + function _exports(asCommand: any): { + new (): { + convertResponse(error: any): any[]; + }; + }; + export = _exports; +} +declare module "commands/read_record_command" { + function _exports(asCommand: any): { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(bins: any, metadata: any): any; + }; + }; + export = _exports; +} +declare module "bigint" { + export const BigInt: BigIntConstructor; + export const bigIntSupported: true; + export function isInt64(value: any): boolean; +} +declare module "key" { + export = Key; + function Key(ns: string, set: string, key: (string | number | Buffer), digest: any): void; + class Key { + constructor(ns: string, set: string, key: (string | number | Buffer), digest: any); ns: string; set: string; - bin: string; - index: string; - type?: IndexType; - } - - type TypedCallback = (error?: Error, result?: T) => void; - - interface IInfoNode { - node_id: string; - } - - interface IInfoAllResponse { - host: IInfoNode; - info: string; - } - - interface IInfoNodeParam { - name: string; - } - - class Client extends EventEmitter { - public config: Config; - private as_client: AddonAerospikeClient; - private connected: boolean; - public captureStackTraces: boolean; - constructor(config: IConfigOptions); - private asExec(cmd: string, args?: any): any; - public getNodes(): IAddonNode[]; - public addSeedHost(hostname: string, number?: number): void; - public removeSeedHost(hostname: string, number?: number): void; - public batchExists(keys: IKey[], policy?: BatchPolicy): Promise; - public batchExists(keys: IKey[], callback: TypedCallback): void; - public batchExists(keys: IKey[], policy?: BatchPolicy, callback: TypedCallback): void; - public batchGet(keys: IBatchReadRecord[], policy?: BatchPolicy): Promise; - public batchGet(keys: IBatchReadRecord[], callback: TypedCallback): void; - public batchGet(keys: IBatchReadRecord[], policy?: BatchPolicy, callback: TypedCallback): void; - public batchSelect(keys: IKey[], bins: string[], policy?: BatchPolicy): Promise; - public batchSelect(keys: IKey[], bins: string[], callback: TypedCallback): void; - public batchSelect(keys: IKey[], bins: string[], policy?: BatchPolicy, callback: TypedCallback): void; - public close(releaseEventLoop?: boolean): void; - public connect(callback?: TypedCallback): Promise; - public createIndex(options: IIndexOptions, policy?: InfoPolicy): Promise; - public createIndex(options: IIndexOptions, callback: TypedCallback): void; - public createIndex(options: IIndexOptions, policy?: InfoPolicy, callback: TypedCallback): void; - public createIntegerIndex(options: ITypedIndexOptions, policy: InfoPolicy): Promise; - public createIntegerIndex(options: ITypedIndexOptions, callback: TypedCallback): void; - public createIntegerIndex(options: ITypedIndexOptions, policy?: InfoPolicy, callback: TypedCallback): void; - public createStringIndex(options: ITypedIndexOptions, policy: InfoPolicy): Promise; - public createStringIndex(options: ITypedIndexOptions, callback: TypedCallback): void; - public createStringIndex(options: ITypedIndexOptions, policy?: InfoPolicy, callback: TypedCallback): void; - public createGeo2DSphereIndex(options: ITypedIndexOptions, policy: InfoPolicy): Promise; - public createGeo2DSphereIndex(options: ITypedIndexOptions, callback: TypedCallback): void; - public createGeo2DSphereIndex(options: ITypedIndexOptions, policy?: InfoPolicy, callback: TypedCallback): void; - public apply(key: IKey, udfArgs: IAddonUDF, policy?: ApplyPolicy): Promise; - public apply(key: IKey, udfArgs: IAddonUDF, callback: AddonCallback): void; - public apply(key: IKey, udfArgs: IAddonUDF, policy?: ApplyPolicy, callback: AddonCallback): void; - public exists(key: IKey, policy?: ReadPolicy): Promise; - public exists(key: IKey, policy?: ReadPolicy, callback: TypedCallback): void; - public get(key: IKey, policy?: ReadPolicy): Promise; - public get(key: IKey, policy?: ReadPolicy, callback: TypedCallback): void; - public indexRemove(namespace: string, index: string, policy?: InfoPolicy): Promise; - public indexRemove(namespace: string, index: string, callback: TypedCallback): void; - public indexRemove(namespace: string, index: string, policy?: InfoPolicy, callback: TypedCallback): void; - public info(request?: string, host: IHost | string, policy?: InfoPolicy): Promise; - public info(request?: string, host: IHost | string, callback: TypedCallback): void; - public info(request?: string, host: IHost | string, policy?: InfoPolicy, callback: TypedCallback): void; - public infoAny(request?: string, policy?: InfoPolicy): Promise; - public infoAny(request?: string, callback: TypedCallback): void; - public infoAny(request?: string, policy?: InfoPolicy, callback: TypedCallback): void; - public infoAll(request?: string, policy?: InfoPolicy): Promise; - public infoAll(request?: string, callback: TypedCallback): void; - public infoAll(request?: string, policy?: InfoPolicy, callback: TypedCallback): void; - public infoNode(request?: string, node: IInfoNodeParam, policy?: InfoPolicy): Promise; - public infoNode(request?: string, node: IInfoNodeParam, callback: TypedCallback): void; - public infoNode(request?: string, node: IInfoNodeParam, policy?: InfoPolicy, callback: TypedCallback): void; - public isConnected(checkTenderErrors?: boolean): boolean; - public operate(key: IKey, operations: Operation[], metadata?: IRecordMetadata, policy?: OperatePolicy): Promise; - public operate(key: IKey, operations: Operation[], callback: TypedCallback): void; - public operate(key: IKey, operations: Operation[], metadata?: IRecordMetadata, callback: TypedCallback): void; - public operate(key: IKey, operations: Operation[], metadata?: IRecordMetadata, policy: OperatePolicy, callback: TypedCallback): void; - public append(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, policy?: OperatePolicy): Promise; - public append(key: IKey, bins: AerospikeBins, callback: TypedCallback): void; - public append(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, callback: TypedCallback): void; - public append(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, policy?: OperatePolicy, callback: TypedCallback): void; - public prepend(key: IKey, bins: AerospikeBins, callback: TypedCallback): void; - public prepend(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, callback: TypedCallback): void; - public prepend(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, policy?: OperatePolicy, callback: TypedCallback): void; - public add(key: IKey, bins: AerospikeBins, callback: TypedCallback): void; - public add(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, callback: TypedCallback): void; - public add(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, policy?: OperatePolicy, callback: TypedCallback): void; - public incr(key: IKey, bins: AerospikeBins, callback: TypedCallback): void; - public incr(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, callback: TypedCallback): void; - public incr(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata, policy?: OperatePolicy, callback: TypedCallback): void; - public put(key: IKey, bins: AerospikeBins, meta?: IRecordMetadata, policy?: WritePolicy): Promise; - public put(key: IKey, bins: AerospikeBins, callback: TypedCallback): void; - public put(key: IKey, bins: AerospikeBins, meta?: IRecordMetadata, callback: TypedCallback): void; - public put(key: IKey, bins: AerospikeBins, meta?: IRecordMetadata, policy?: WritePolicy, callback: TypedCallback): void; - public query(ns: string, set: string, options?: IQueryOptions): Query; - public remove(key: IKey, policy?: RemovePolicy): Promise; - public remove(key: IKey, callback: TypedCallback): void; - public remove(key: IKey, policy?: RemovePolicy, callback: TypedCallback): void; - public scan(ns: string, set: string, options: IScanOptions): Scan; - public select(key: IKey, bins: string[], policy?: ReadPolicy): Promise; - public select(key: IKey, bins: string[], callback: TypedCallback): void; - public select(key: IKey, bins: string[], policy?: ReadPolicy, callback: TypedCallback): void; - public truncate(ns: string, set: string | null, beforeNanos: number, policy?: InfoPolicy): Promise; - public truncate(ns: string, set: string | null, beforeNanos: number, callback: TypedCallback): void; - public udfRegister(udfPath: string, udfType?: Language, policy?: InfoPolicy): Promise; - public udfRegister(udfPath: string, callback: TypedCallback): void; - public udfRegister(udfPath: string, udfType?: Language, callback: TypedCallback): void; - public udfRegister(udfPath: string, udfType?: Language, policy?: InfoPolicy, callback: TypedCallback): void; - public stats(): IAddonStats; - public udfRemove(udfModule: string, policy?: InfoPolicy): Promise; - public udfRemove(udfModule: string, callback: TypedCallback): void; - public udfRemove(udfModule: string, policy?: InfoPolicy, callback: TypedCallback): void; - public updateLogging(logConfig: ILogInfo): void; - keyfilePassword?: string; - certfile?: string; - crlCheck?: boolean; - crlCheckAll?: boolean; - logSessionInfo?: boolean; - forLoginOnly?: boolean; - } - - interface IHost { - addr: string; - port?: number; - tlsname?: string; - } - - interface IConfigPolicies { - apply?: ApplyPolicy; - batch?: BasePolicy; - info?: InfoPolicy; - operate?: OperatePolicy; - read?: ReadPolicy; - remove?: RemovePolicy; - scan?: ScanPolicy; - query?: QueryPolicy; - write?: WritePolicy; - } - - interface IConfigLog { - level?: Log; - file?: number; - } - - interface IConfigModLua { - userPath?: string; - } - - interface IConfigSharedMemory { - enable?: boolean; - key: number; - maxNodes?: number; - maxNamespaces?: number; - takeoverThresholdSeconds?: number; - } - - interface IConfigOptions { - user?: string; - password?: string; - authMode?: Auth; - clusterName?: string; - port?: number; - tls?: IConfigTLS; - hosts?: IHost[] | string; - policies?: IConfigPolicies; - log?: IConfigLog; - connTimeoutMs?: number; - loginTimeoutMs?: number; - maxSocketIdle?: number; - tenderInterval?: number; - maxConnsPerNode?: number; - minConnsPerNode?: number; - modlua?: IConfigModLua; - sharedMemory?: IConfigSharedMemory; - useAlternateAccessAddress?: boolean; - rackAware?: boolean; - rackId?: number; - } - - class Config { - public user?: string; - public password?: string; - public authMode?: Auth; - public clusterName?: string; - public port: number; - public tls?: IConfigTLS; - public hosts: IHost[] | string; - public policies: IConfigPolicies; - public log?: IConfigLog; - public connTimeoutMs?: number; - public loginTimeoutMs?: number; - public maxSocketIdle?: number; - public tenderInterval?: number; - public maxConnsPerNode?: number; - public minConnsPerNode?: number; - public modlua: IConfigModLua; - public sharedMemory?: IConfigSharedMemory; - public useAlternateAccessAddress: boolean; - public rackAware?: boolean; - public rackId?: number; - constructor(config?: IConfigOptions); - public setDefaultPolicies(policies?: IConfigPolicies): void; - } - - // double.js - class Double { - constructor(value: number); - public Double: number; - public value(): number; + key: string | number | Buffer; + digest: any; + equals(other: any): any; } - - // error.js - class AerospikeError extends Error { - readonly code: Status; - readonly command: Command | null; - readonly func: string | null; - readonly file: string | null; - readonly line: number | null; - readonly inDoubt: boolean; - constructor(message?: string, command: Command); - static fromASError(asError?: AerospikeError | Error, command: Command): AerospikeError; - static copyASErrorProperties(target: AerospikeError, source: Error): void; - static formatMessage(message: string, code: Status): string; - private setStackTrace(stack: string): void; - public isServerError(): boolean; - readonly get client(): Client | void; - } - - // geojson.js - type GeoJSONType = { - type: string, - coordinates: Array - } - - class GeoJSON { - public str: string; - constructor(json: string | object); - static Point(lng: number, lat: number): GeoJSON; - static Polygon(...coordinates: number[][]): GeoJSON; - static Circle(lng: number, lat: number, radius: number); - public toJSON(): GeoJSONType; - public value(): GeoJSONType; - public toString(): string; - } - - // hll.js - class HLLOperation extends Operation { - public withPolicy(policy: HLLPolicy): HLLOperation; - } - - // index_job.js - interface ISindexInfoEntity { - load_pct: number; - } - class IndexJob extends Job { - public namespace: string; - public indexName: string; - constructor(client: Client, namespace: string, indexName: string); - private hasCompleted(sindexInfo: ISindexInfoEntity[]): boolean; - private info(): Promise - } - - // job.js - interface IJobInfoResponse { - progressPct: number; - recordsRead: number; - status: JobStatus; - } - + namespace Key { + function fromASKey(keyObj: any): Key | null; + } +} +declare module "commands/stream_command" { + function _exports(asCommand: any): { + new (stream: any, args: any): { + stream: any; + callback(error: any, record: any): boolean; + convertResult(bins: any, meta: any, asKey: any): any; + }; + }; + export = _exports; +} +declare module "commands/write_record_command" { + function _exports(asCommand: any): { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(): any; + }; + }; + export = _exports; +} +declare module "job" { + export = Job; + function Job(client: any, jobID: any, module: any): void; class Job { - public client: Client; - public jobID: number; - public module: string; - constructor(client: Client, jobID: number, module: string); - static safeRandomJobID(): number; - static pollUntilDone(statusFunction: () => Promise, pollInterval?: number): Promise; - private hasCompleted(info: IJobInfoResponse): Promise; - private checkStatus(): Promise; - public info(policy?: InfoPolicy): Promise; - public info(callback: TypedCallback): void; - public info(policy?: InfoPolicy, callback: TypedCallback): void; - public wait(poolInterval?: number): Promise; - public wait(callback: TypedCallback): void; - public wait(pollInterval?: number, callback: TypedCallback): void; - public waitUntilDone(pollInterval?: number): Promise; - public waitUntilDone(callback: TypedCallback): void; - public waitUntilDone(pollInterval?: number, callback: TypedCallback): void; - } - - // key.js - interface IKey { + constructor(client: any, jobID: any, module: any); + client: any; + jobID: any; + module: any; + private hasCompleted; + private checkStatus; + info(policy: any, callback: any): Promise | null; + wait(pollInterval?: number | undefined, callback: any): Promise | null; + waitUntilDone: any; + } + namespace Job { + export { safeRandomJobID, pollUntilDone, Job }; + } + function safeRandomJobID(): number; + function pollUntilDone(statusFunction: any, pollInterval: any): Promise; + type Job = () => any; +} +declare module "commands/query_background_command" { + function _exports(asCommand: any): { + new (client: any, ns: any, set: any, queryObj: any, policy: any, queryID: any, callback: any): { + client: any; + queryID: any; + queryObj: any; + convertResult(): Job; + }; + }; + export = _exports; + import Job = require("job"); +} +declare module "commands/index" { + class ApplyCommand { + } + const BatchExistsCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchExistsCommand extends BatchExistsCommand_base { + } + const BatchGetCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchGetCommand extends BatchGetCommand_base { + } + const BatchReadCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchReadCommand extends BatchReadCommand_base { + } + const BatchWriteCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchWriteCommand extends BatchWriteCommand_base { + } + const BatchApplyCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchApplyCommand extends BatchApplyCommand_base { + } + const BatchRemoveCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchRemoveCommand extends BatchRemoveCommand_base { + } + const BatchSelectCommand_base: { + new (): { + convertResult(results: any): any; + }; + }; + class BatchSelectCommand extends BatchSelectCommand_base { + } + const ConnectCommand_base: { + new (client: any, callback: any): { + ensureConnected: boolean; + }; + }; + class ConnectCommand extends ConnectCommand_base { + } + const ExistsCommand_base: { + new (): { + convertResponse(error: any): any[]; + }; + }; + class ExistsCommand extends ExistsCommand_base { + } + const GetCommand_base: { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(bins: any, metadata: any): any; + }; + }; + class GetCommand extends GetCommand_base { + } + class IndexCreateCommand { + } + class IndexRemoveCommand { + } + class InfoAnyCommand { + } + class InfoForeachCommand { + } + class InfoHostCommand { + } + class InfoNodeCommand { + } + class JobInfoCommand { + } + const OperateCommand_base: { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(bins: any, metadata: any): any; + }; + }; + class OperateCommand extends OperateCommand_base { + } + const PutCommand_base: { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(): any; + }; + }; + class PutCommand extends PutCommand_base { + } + const QueryCommand_base: { + new (stream: any, args: any): { + stream: any; + callback(error: any, record: any): boolean; + convertResult(bins: any, meta: any, asKey: any): any; + }; + }; + class QueryCommand extends QueryCommand_base { + } + class QueryApplyCommand { + } + const QueryBackgroundCommand_base: { + new (client: any, ns: any, set: any, queryObj: any, policy: any, queryID: any, callback: any): { + client: any; + queryID: any; + queryObj: any; + convertResult(): import("job"); + }; + }; + class QueryBackgroundCommand extends QueryBackgroundCommand_base { + } + const QueryOperateCommand_base: { + new (client: any, ns: any, set: any, queryObj: any, policy: any, queryID: any, callback: any): { + client: any; + queryID: any; + queryObj: any; + convertResult(): import("job"); + }; + }; + class QueryOperateCommand extends QueryOperateCommand_base { + } + const QueryForeachCommand_base: { + new (stream: any, args: any): { + stream: any; + callback(error: any, record: any): boolean; + convertResult(bins: any, meta: any, asKey: any): any; + }; + }; + class QueryForeachCommand extends QueryForeachCommand_base { + } + const RemoveCommand_base: { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(): any; + }; + }; + class RemoveCommand extends RemoveCommand_base { + } + const ScanCommand_base: { + new (stream: any, args: any): { + stream: any; + callback(error: any, record: any): boolean; + convertResult(bins: any, meta: any, asKey: any): any; + }; + }; + class ScanCommand extends ScanCommand_base { + } + const ScanBackgroundCommand_base: { + new (client: any, ns: any, set: any, queryObj: any, policy: any, queryID: any, callback: any): { + client: any; + queryID: any; + queryObj: any; + convertResult(): import("job"); + }; + }; + class ScanBackgroundCommand extends ScanBackgroundCommand_base { + } + const ScanOperateCommand_base: { + new (client: any, ns: any, set: any, queryObj: any, policy: any, queryID: any, callback: any): { + client: any; + queryID: any; + queryObj: any; + convertResult(): import("job"); + }; + }; + class ScanOperateCommand extends ScanOperateCommand_base { + } + const SelectCommand_base: { + new (client: any, key: any, args: any, callback: any): { + key: any; + convertResult(bins: any, metadata: any): any; + }; + }; + class SelectCommand extends SelectCommand_base { + } + class TruncateCommand { + } + class UdfRegisterCommand { + } + class UdfRemoveCommand { + } + export { ApplyCommand as Apply, BatchExistsCommand as BatchExists, BatchGetCommand as BatchGet, BatchReadCommand as BatchRead, BatchWriteCommand as BatchWrite, BatchApplyCommand as BatchApply, BatchRemoveCommand as BatchRemove, BatchSelectCommand as BatchSelect, ConnectCommand as Connect, ExistsCommand as Exists, GetCommand as Get, IndexCreateCommand as IndexCreate, IndexRemoveCommand as IndexRemove, InfoAnyCommand as InfoAny, InfoForeachCommand as InfoForeach, InfoHostCommand as InfoHost, InfoNodeCommand as InfoNode, JobInfoCommand as JobInfo, OperateCommand as Operate, PutCommand as Put, QueryCommand as Query, QueryApplyCommand as QueryApply, QueryBackgroundCommand as QueryBackground, QueryOperateCommand as QueryOperate, QueryForeachCommand as QueryForeach, RemoveCommand as Remove, ScanCommand as Scan, ScanBackgroundCommand as ScanBackground, ScanOperateCommand as ScanOperate, SelectCommand as Select, TruncateCommand as Truncate, UdfRegisterCommand as UdfRegister, UdfRemoveCommand as UdfRemove }; +} +declare module "config" { + export = Config; + class Config { + constructor(config?: any); + user: any; + password: any; + authMode: any; + clusterName: string; + port: any; + tls: any; + hosts: (Host[] | string); + policies: Config; + log: any; + connTimeoutMs: any; + loginTimeoutMs: any; + maxSocketIdle: any; + tenderInterval: any; + maxConnsPerNode: any; + minConnsPerNode: any; + modlua: any; + sharedMemory: any; + useAlternateAccessAddress: boolean; + rackAware: boolean; + rackId: any; + setDefaultPolicies(policies: any): void; + } + namespace Config { + export { Config }; + } + type Config = { + apply: ApplyPolicy; + batch: BatchPolicy; + info: InfoPolicy; + operate: OperatePolicy; + read: ReadPolicy; + remove: RemovePolicy; + scan: ScanPolicy; + query: QueryPolicy; + write: WritePolicy; + }; +} +declare module "index_job" { + export = IndexJob; + function IndexJob(client: any, namespace: any, indexName: any): void; + class IndexJob { + constructor(client: any, namespace: any, indexName: any); + client: any; + namespace: any; + indexName: any; + private hasCompleted; + private info; + } +} +declare module "record_stream" { + export = RecordStream; + function RecordStream(client: any): void; + class RecordStream { + constructor(client: any); + aborted: boolean; + client: any; + writable: boolean; + readable: boolean; + _read(): void; + abort(): void; + } +} +declare module "query" { + export = Query; + function Query(client: Client, ns: string, set: string, options?: { + filters?: any[] | undefined; + select?: string[] | undefined; + nobins?: boolean | undefined; + } | undefined): void; + class Query { + constructor(client: Client, ns: string, set: string, options?: { + filters?: any[] | undefined; + select?: string[] | undefined; + nobins?: boolean | undefined; + } | undefined); + client: any; ns: string; set: string; - key: string | number | Buffer; - digest?: Buffer; + filters: any[]; + selected: string[] | undefined; + nobins: boolean | undefined; + udf: any; + private pfEnabled; + select(...args: string[]): void; + where(predicate: any): void; + setSindexFilter(sindexFilter: any): void; + setUdf(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined): void; + partitions(begin: number, count: number, digest: string): void; + partFilter: { + begin: number; + count: number; + digest: string; + } | undefined; + foreach(policy?: QueryPolicy, dataCb?: recordCallback | undefined, errorCb?: errorCallback | undefined, endCb?: doneCallback | undefined): RecordStream; + results(policy?: QueryPolicy): Promise; + apply(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: QueryPolicy, callback: any): Promise | null; + background(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: WritePolicy, queryID?: number | undefined, callback?: jobCallback | undefined): Promise | null; + operate(operations: any, policy?: QueryPolicy, queryID?: number | undefined, callback?: jobCallback | undefined): Promise | null; + ops: any; + } + namespace Query { + export { Query }; + } + import RecordStream = require("record_stream"); + type Query = () => any; +} +declare module "scan" { + export = Scan; + function Scan(client: Client, ns: string, set: string, options?: { + select?: string[] | undefined; + nobins?: boolean | undefined; + concurrent?: boolean | undefined; + } | undefined): void; + class Scan { + constructor(client: Client, ns: string, set: string, options?: { + select?: string[] | undefined; + nobins?: boolean | undefined; + concurrent?: boolean | undefined; + } | undefined); + client: any; + ns: string; + set: string; + selected: string[] | undefined; + nobins: boolean | undefined; + concurrent: boolean | undefined; + private pfEnabled; + select(...args: string[]): void; + partitions(begin: number, count: number, digest: string): void; + partFilter: { + begin: number; + count: number; + digest: string; + } | undefined; + background(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: ScanPolicy, scanID?: number | undefined, callback?: jobCallback | undefined): Promise | null; + udf: { + module: string; + funcname: string; + args: any[] | undefined; + } | undefined; + operate(operations: any, policy?: ScanPolicy, scanID?: number | undefined, callback?: jobCallback | undefined): Promise | null; + ops: any; + foreach(policy?: ScanPolicy, dataCb?: recordCallback | undefined, errorCb?: errorCallback | undefined, endCb?: doneCallback | undefined): RecordStream; + } + import RecordStream = require("record_stream"); +} +declare module "udf_job" { + export = UdfJob; + function UdfJob(client: any, udfModule: any, command: any): void; + class UdfJob { + constructor(client: any, udfModule: any, command: any); + client: any; + udfModule: any; + command: any; + private hasCompleted; + private info; + } + namespace UdfJob { + const REGISTER: string; + const UNREGISTER: string; + } +} +declare module "utils" { + export function parseHostString(hostString: any): { + addr: any; + tlsname: any; + port: number; + }; + export function print(err: any, result: any): void; +} +declare module "client" { + export = Client; + function Client(config: Config): void; + class Client { + constructor(config: Config); + config: Config; + private as_client; + private connected; + captureStackTraces: boolean; + private asExec; + getNodes(): Array<{ + name: string; + address: string; + }>; + addSeedHost(hostname: string, port?: number | undefined): void; + removeSeedHost(hostname: string, port?: number | undefined): void; + batchExists(keys: Key[], policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; + batchGet(keys: Key[], policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; + batchRead(records: { + type: number; + key: string; + bins?: string[]; + readAllBins?: boolean; + }, policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; + batchWrite(records: { + type: number; + key: string; + }, policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; + batchApply(records: { + type: number; + key: string; + }, udf: object[], batchPolicy?: BatchPolicy, batchApplyPolicy?: any, callback?: batchRecordsCallback | undefined): Promise | null; + batchRemove(records: { + type: number; + key: string; + }, batchPolicy?: BatchPolicy, batchRemovePolicy?: any, callback?: batchRecordsCallback | undefined): Promise | null; + batchSelect(keys: Key[], bins: string[], policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; + close(releaseEventLoop?: boolean | undefined): void; + connect(callback?: connectCallback | undefined): Promise | null; + createIndex(options: { + ns: string; + set: string; + bin: string; + index: string; + type?: any; + datatype: any; + }, policy?: InfoPolicy, callback?: jobCallback | undefined): Promise | null; + createIntegerIndex(options: { + ns: string; + set: string; + bin: string; + index: string; + type?: any; + }, policy?: InfoPolicy, callback?: jobCallback | undefined): Promise | null; + createStringIndex(options: { + ns: string; + set: string; + bin: string; + index: string; + type?: any; + }, policy?: InfoPolicy, callback?: jobCallback | undefined): Promise | null; + createGeo2DSphereIndex(options: { + ns: string; + set: string; + bin: string; + index: string; + type?: any; + }, policy?: InfoPolicy, callback?: jobCallback | undefined): Promise | null; + apply(key: Key, udfArgs: { + module: string; + funcname: string; + args: Array<(number | string)>; + }, policy?: ApplyPolicy, callback?: valueCallback | undefined): Promise | null; + exists(key: Key, policy?: ReadPolicy, callback?: valueCallback | undefined): Promise | null; + get(key: Key, policy?: ReadPolicy, callback?: recordCallback | undefined): Promise | null; + indexRemove(namespace: string, index: string, policy?: InfoPolicy, callback?: doneCallback | undefined): Promise | null; + info(request: string | null, host: { + addr: string; + port?: number | undefined; + }, policy?: InfoPolicy, callback?: infoCallback | undefined): any; + infoAny(request?: string | undefined, policy?: InfoPolicy, callback?: infoCallback | undefined): any; + infoAll(request?: string | undefined, policy?: InfoPolicy, callback?: infoCallback | undefined): any; + infoNode(request: string | null, node: { + name: string; + }, policy?: InfoPolicy, callback?: infoCallback | undefined): any; + isConnected(checkTenderErrors?: boolean | undefined): boolean; + operate(key: Key, operations: any, metadata?: any, policy?: OperatePolicy, callback?: recordCallback | undefined): any; + incr: any; + put(key: Key, bins: object, meta?: object, policy?: WritePolicy, callback?: writeCallback | undefined): any; + query(ns: string, set: string, options?: object): Query; + remove(key: Key, policy?: RemovePolicy, callback?: writeCallback | undefined): any; + scan(ns: string, set: string, options?: object): Scan; + select(key: Key, bins: string[], policy?: ReadPolicy, callback?: recordCallback | undefined): any; + truncate(ns: string, set: string, beforeNanos: any, policy?: InfoPolicy, callback?: doneCallback | undefined): any; + udfRegister(udfPath: any, udfType?: number | undefined, policy?: InfoPolicy, callback?: jobCallback | undefined): any; + stats(): ClientStats; + udfRemove(udfModule: string, policy?: InfoPolicy, callback?: jobCallback | undefined): any; + updateLogging(logConfig: any): void; + } + import Config = require("config"); + import Query = require("query"); + import Scan = require("scan"); +} +declare module "double" { + export = Double; + function Double(value: number): void; + class Double { + constructor(value: number); + Double: number; + value(): number; } - - class Key implements IKey { - constructor(ns: string, set: string, key: string | number | Buffer, digest?: Buffer); - static fromASKey(keyObj: IKey): Key; - public equals(other: IKey): boolean; +} +declare module "batch_type" { + export namespace types { + const BATCH_READ: any; + const BATCH_WRITE: any; + const BATCH_APPLY: any; + const BATCH_REMOVE: any; } - - // record.js - interface IRecordMetadata { - ttl: number; - gen: number; +} +declare module "aerospike" { + export const filter: typeof import("filter"); + export const exp: typeof import("exp"); + export namespace regex { + const BASIC: number; + const EXTENDED: number; + const ICASE: number; + const NEWLINE: number; + } + export type regex = number; + export const info: typeof import("info"); + export const lists: typeof import("lists"); + export const hll: typeof import("hll"); + export const maps: typeof import("maps"); + export namespace cdt { + const Context: typeof import("cdt_context"); + } + export const bitwise: typeof import("bitwise"); + export const operations: typeof import("operations"); + export const policy: typeof import("policy"); + export const BasePolicy: typeof import("policies/base_policy"); + export const ApplyPolicy: typeof import("policies/apply_policy"); + export const BatchPolicy: typeof import("policies/batch_policy"); + export const OperatePolicy: typeof import("policies/operate_policy"); + export const QueryPolicy: typeof import("policies/query_policy"); + export const ReadPolicy: typeof import("policies/read_policy"); + export const RemovePolicy: typeof import("policies/remove_policy"); + export const ScanPolicy: typeof import("policies/scan_policy"); + export const WritePolicy: typeof import("policies/write_policy"); + export const BatchApplyPolicy: typeof import("policies/batch_apply_policy"); + export const BatchReadPolicy: typeof import("policies/batch_read_policy"); + export const BatchRemovePolicy: typeof import("policies/batch_remove_policy"); + export const BatchWritePolicy: typeof import("policies/batch_write_policy"); + export const CommandQueuePolicy: typeof import("policies/command_queue_policy"); + export const InfoPolicy: typeof import("policies/info_policy"); + export const ListPolicy: typeof import("policies/list_policy"); + export const MapPolicy: typeof import("policies/map_policy"); + export const status: typeof import("status"); + export const features: typeof import("features"); + export { AerospikeError }; + export const Client: typeof import("client"); + export const Config: typeof import("config"); + export const Double: typeof import("double"); + export const GeoJSON: typeof import("geojson"); + export const Key: typeof import("key"); + export const Record: typeof import("record"); + export type auth = number; + export type language = number; + export type log = number; + export type ttl = number; + export type jobStatus = number; + export type indexDataType = number; + export type indexType = number; + export const print: typeof import("utils").print; + export const releaseEventLoop: typeof EventLoop.releaseEventLoop; + export function client(config?: any): import("client"); + export function connect(config?: any, callback?: connectCallback | undefined): Promise | null; + export function setDefaultLogging(logInfo: any): void; + export function setupGlobalCommandQueue(policy: CommandQueuePolicy): void; + export const batchType: typeof import("batch_type"); + import AerospikeError = require("error"); + import EventLoop = require("event_loop"); +} +type Host = object; +type ClientStats = any; +type doneCallback = () => any; +type errorCallback = () => any; +type recordCallback = () => any; +type valueCallback = () => any; +type writeCallback = () => any; +type batchRecordsCallback = () => any; +type connectCallback = () => any; +type infoCallback = () => any; +type infoAllCallback = () => any; +type jobCallback = () => any; +type AerospikeExp = object; +type ApplyPolicy = object; +type BatchPolicy = object; +type InfoPolicy = object; +type OperatePolicy = object; +type ReadPolicy = object; +type RemovePolicy = object; +type ScanPolicy = object; +type QueryPolicy = object; +type WritePolicy = object; +type BitwisePolicy = object; +type MapPolicy = object; +type CommandQueuePolicy = object; +type Operation = object; +type Client = object; +type Key = object; +declare module "policies/bitwise_policy" { + export = BitwisePolicy; + class BitwisePolicy { + constructor(props?: any); + writeFlags: number; } - - // record_stream.js - class RecordStream extends Stream { - public aborted: boolean; - public client: Client; - public writable: boolean; - public readable: boolean; - public _read(): void; - public abort(): void; - } - - // scan.js - interface IScanOptions { - select?: string[]; - nobins?: boolean; - concurrent?: boolean; - } - - class Scan { - public client: Client; - public ns: string; - public set: string; - public selected?: string[]; - public nobins?: boolean; - public concurrent?: boolean; - public udf?: IAddonUDF; - public ops?: Operation[]; - constructor(client: Client, ns: string, set: string, options?: IScanOptions); - public select(bins: string[]): void; - public select(...bins: string[]): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: ScanPolicy, scanID?: number): Promise; - public background(udfModule: string, udfFunction: string, callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: ScanPolicy, callback: TypedCallback): void; - public background(udfModule: string, udfFunction: string, udfArgs?: any[], policy?: ScanPolicy, scanID?: number, callback: TypedCallback): void; - public operate(operations: Operation[], policy?: ScanPolicy, scanID?: number): Promise; - public operate(operations: Operation[], policy?: ScanPolicy, scanID?: number, callback: TypedCallback): void; - public foreach(policy?: ScanPolicy, dataCb?: (data: AerospikeRecord) => void, errorCb?: (error: Error) => void, endCb: () => void): RecordStream; - } - - class AerospikeRecord { - public key: IKey; - public bins: AerospikeRecord; - public ttl: number; - public gen: gen; - constructor(key: IKey, bins: AerospikeBins, metadata?: IRecordMetadata); - } - - export interface FilterModule { - SindexFilterPredicate: SindexFilterPredicate, - range(bin: string, min: number, max: number, indexType?: IndexType): RangePredicate; - equal(bin: string, value: string): EqualPredicate; - contains(bin: string, value: string | number, indexType?: IndexType): EqualPredicate; - geoWithinGeoJSONRegion(bin: string, value: GeoJSON, indexType?: IndexType): GeoPredicate; - geoContainsGeoJSONPoint(bin: string, value: GeoJSON, indexType?: IndexType): GeoPredicate; - geoWithinRadius(bin: string, lng: number, lat: number, radius: number, indexType?: IndexType): GeoPredicate; - geoContainsPoint(bin: string, lng: number, lat: number, indexType?: IndexType): GeoPredicate; - } - - export interface ListsModule { - order: ListOrder; - sortFlags: ListSortFlags; - writeFlags: ListWriteFlags; - returnType: ListReturnType; - setOrder(bin: name, order: ListOrder): ListOperation; - sort(bin: string, flags: ListSortFlags): ListOperation; - append(bin: string, value: AerospikeRecordValue, policy?: ListPolicy): ListOperation; - appendItems(bin: string, list: AerospikeRecordValue[], policy?: ListPolicy): ListOperation; - insert(bin: string, index: number, value: AerospikeRecordValue, policy?: ListPolicy): ListOperation; - insertItems(bin: string, index: number, list: AerospikeRecordValue[], policy?: ListPolicy): ListOperation; - pop(bin: string, index: number): ListOperation; - popRange(bin: string, index: number, count?: number): ListOperation; - remove(bin: string, index: number): ListOperation; - removeRange(bin: string, index: number, count?: number): ListOperation; - removeByIndex(bin: string, index: number, returnType?: ListReturnType): ListOperation; - removeByIndexRange(bin: string, index: number, count?: number, returnType?: ListReturnType): InvertibleListOp; - removeByValue(bin: string, value: AerospikeRecordValue, returnType?: ListReturnType): InvertibleListOp; - removeByValueList(bin: string, values: AerospikeRecordValue[], returnType?: ListReturnType): InvertibleListOp; - removeByValueRange(bin: string, begin: number | null, end: number | null, returnType?: ListReturnType): InvertibleListOp; - removeByValueRelRankRange(bin: string, value: number, rank: number, count?: number, returnType?: ListReturnType): InvertibleListOp; - removeByRank(bin: string, rank: number, returnType?: ListReturnType): ListOperation; - removeByRankRange(bin: string, rank: number, count?: number, returnType?: ListReturnType): InvertibleListOp; - clear(bin: string): ListOperation; - set(bin: string, index: number, value: AerospikeRecordValue, policy?: ListPolicy): ListOperation; - trim(bin: string, index: number, count: number): ListOperation; - get(bin: string, index: number): ListOperation; - getRange(bin: string, index: number, count?: number): ListOperation; - getByIndex(bin: string, index: number, returnType?: ListReturnType): ListOperation; - getByIndexRange(bin: string, index: number, count?: number, returnType?: ListReturnType): InvertibleListOp; - getByValue(bin: string, value: AerospikeRecordValue, returnType?: ListReturnType): InvertibleListOp; - getByValueList(bin: string, values: AerospikeRecordValue[], returnType?: ListReturnType): InvertibleListOp; - getByValueRange(bin: string, begin: number | null, end: number | null, returnType?: ListReturnType): InvertibleListOp; - getByValueRelRankRange(bin: string, value: number, rank: number, count?: number, returnType?: ListReturnType): InvertibleListOp; - getByRank(bin: string, rank: number, returnType?: ListReturnType): ListOperation; - getByRankRange(bin: string, rank: number, count?: number, returnType?: ListReturnType): InvertibleListOp; - increment(bin: string, index: number, value?: number, policy?: ListPolicy): ListOperation; - size(bin: string): ListOperation; - } - - export interface MapsModule { - order: MapOrder; - writeMode: MapWriteMode; - writeFlags: MapWriteFlags; - returnType: MapReturnType; - setPolicy(bin: string, policy: MapPolicy): MapOperation; - put(bin: string, key: string, value: AerospikeRecordValue, policy?: MapPolicy): MapOperation; - putItems(bin: string, items: AerospikeBins, policy?: MapPolicy): MapOperation; - increment(bin: string, key: string, incr?: number, policy?: MapPolicy): MapOperation; - decrement(bin: string, key: string, decr: number, policy?: MapPolicy): MapOperation; - clear(bin: string): MapOperation; - removeByKey(bin: string, key: string, returnType?: MapReturnType): MapOperation; - removeByKeyList(bin: string, keys: string[], returnType?: MapReturnType): MapOperation; - removeByKeyRange(bin: string, begin: string | null, end: string | null, returnType?: MapReturnType): MapOperation; - removeByKeyRelIndexRange(bin: string, key: string, index: number, count?: number, returnType?: MapReturnType): MapOperation; - removeByValue(bin: string, value: AerospikeRecordValue, returnType?: MapReturnType): MapOperation; - removeByValueList(bin: string, values: AerospikeRecordValue[], returnType?: MapReturnType): MapOperation; - removeByValueRange(bin: string, begin: number | null, end: number | null, returnType?: MapReturnType): MapOperation; - removeByValueRelRankRange(bin: string, value: number, rank: number, count?: number, returnType?: MapReturnType): MapOperation; - removeByIndex(bin: string, index: number, returnType?: MapReturnType): MapOperation; - removeByIndexRange(bin: string, index: number, count?: number, returnType?: MapReturnType): MapOperation; - removeByRank(bin: string, rank: number, returnType?: MapReturnType): MapOperation; - removeByRankRange(bin: string, rank: number, count?: number, returnType?: MapReturnType): MapOperation; - size(bin: string): MapOperation; - getByKey(bin: string, key: string, returnType?: MapReturnType): MapOperation; - getByKeyRange(bin: string, begin: string | null, end: string | null, returnType?: MapReturnType): MapOperation; - getByKeyRelIndexRange(bin: string, key: string, index: number, count?: number, returnType?: MapReturnType): MapOperation; - getByValue(bin: string, value: AerospikeRecordValue, returnType?: MapReturnType): MapOperation; - getByValueRange(bin: string, begin: number | null, end: number | null, returnType?: MapReturnType): MapOperation; - getByValueRelRankRange(bin: string, value: number, rank: number, count?: number, returnType?: MapReturnType): MapOperation; - getByIndex(bin: string, index: number, returnType?: MapReturnType): MapOperation; - getByIndexRange(bin: string, index: number, count?: number, returnType?: MapReturnType): MapOperation; - getByRank(bin: string, rank: number, returnType?: MapReturnType): MapOperation; - getByRankRange(bin: string, rank: number, count?: number, returnType?: MapReturnType): MapOperation; - } - - export interface BitwiseModule { - writeFlags: BitwiseWriteFlags; - resizeFlags: BitwiseResizeFlags; - overflow: BitwiseOverflow; - resize(bin: string, size: number, flags?: BitwiseResizeFlags): BitwiseOperation; - insert(bin: string, byteOffset: number, value: Buffer): BitwiseOperation; - remove(bin: string, byteOffset: number, byteSize: number): BitwiseOperation; - set(bin: string, bitOffset: number, bitSize: number, value: number | Buf): BitwiseOperation; - or(bin: string, bitOffset: number, bitSize: number, value: Buffer): BitwiseOperation; - xor(bin: string, bitOffset: number, bitSize: number, value: Buffer): BitwiseOperation; - and(bin: string, bitOffset: number, bitSize: number, value: Buffer): BitwiseOperation; - not(bin: string, bitOffset: number, bitSize: number): BitwiseOperation; - lshift(bin: string, bitOffset: number, bitSize: string, shift: number): BitwiseOperation; - rshift(bin: string, bitOffset: number, bitSize: string, shift: number): BitwiseOperation; - add(bin: string, bitOffset: number, bitSize: number, value: number, sign: boolean): OverflowableBitwiseOp; - subtract(bin: string, bitOffset: number, bitSize: number, value: number, sign: boolean): OverflowableBitwiseOp; - get(bin: string, bitOffset: number, bitSize: number): BitwiseOperation; - getInt(bin: string, bitOffset: number, bitSize: number, sign: boolean): BitwiseOperation; - lscan(bin: string, bitOffset: number, bitSize: number, value: boolean): BitwiseOperation; - rscan(bin: string, bitOffset: number, bitSize: number, value: boolean): BitwiseOperation; - } - - export interface InfoModule { - parse(info: string): Record; - separators: Object; - } - - export interface CdtModule { - Context: CdtContext; - } - - type AnyPolicy = ApplyPolicy | BasePolicy | InfoPolicy | OperatePolicy | QueryPolicy | ReadPolicy | RemovePolicy | ScanPolicy | WritePolicy; - - export interface PolicyModule { - gen: PolicyGen; - exists: PolicyExists; - replica: PolicyReplica; - readModeAP: PolicyReadModeAP; - readModeSC: PolicyReadModeSC; - commitLevel: PolicyCommitLevel; - ApplyPolicy: ApplyPolicy; - BatchPolicy: BatchPolicy; - CommandQueuePolicy: CommandQueuePolicy; - InfoPolicy: InfoPolicy; - ListPolicy: ListPolicy; - MapPolicy: MapPolicy; - OperatePolicy: OperatePolicy; - QueryPolicy: QueryPolicy; - ReadPolicy: ReadPolicy; - RemovePolicy: RemovePolicy; - ScanPolicy: ScanPolicy; - WritePolicy: WritePolicy; - createPolicy(type: string, values: AnyPolicy | Record): AnyPolicy; - } - - export interface StatusModule { - ERR_ASYNC_QUEUE_FULL: Status.AEROSPIKE_ERR_ASYNC_QUEUE_FULL; - ERR_CONNECTION: Status.AEROSPIKE_ERR_INVALID_NODE; - ERR_INVALID_NODE: Status.AEROSPIKE_ERR_INVALID_NODE, - ERR_NO_MORE_CONNECTIONS: Status.AEROSPIKE_ERR_NO_MORE_CONNECTIONS; - ERR_ASYNC_CONNECTION: Status.AEROSPIKE_ERR_ASYNC_CONNECTION; - ERR_CLIENT_ABORT: Status.AEROSPIKE_ERR_CLIENT_ABORT; - ERR_INVALID_HOST: Status.AEROSPIKE_ERR_INVALID_HOST; - NO_MORE_RECORDS: Status.AEROSPIKE_NO_MORE_RECORDS; - ERR_PARAM: Status.AEROSPIKE_ERR_PARAM; - OK: Status.AEROSPIKE_OK; - ERR_SERVER: Status.AEROSPIKE_ERR_SERVER; - ERR_RECORD_NOT_FOUND: Status.AEROSPIKE_ERR_RECORD_NOT_FOUND; - ERR_RECORD_GENERATION: Status.AEROSPIKE_ERR_RECORD_GENERATION; - ERR_REQUEST_INVALID: Status.AEROSPIKE_ERR_REQUEST_INVALID; - ERR_RECORD_EXISTS: Status.AEROSPIKE_ERR_RECORD_EXISTS; - ERR_BIN_EXISTS: Status.AEROSPIKE_ERR_BIN_EXISTS; - ERR_CLUSTER_CHANGE: Status.AEROSPIKE_ERR_CLUSTER_CHANGE; - ERR_SERVER_FULL: Status.AEROSPIKE_ERR_SERVER_FULL; - ERR_TIMEOUT: Status.AEROSPIKE_ERR_TIMEOUT; - ERR_ALWAYS_FORBIDDEN: Status.AEROSPIKE_ERR_ALWAYS_FORBIDDEN; - ERR_CLUSTER: Status.AEROSPIKE_ERR_CLUSTER; - ERR_BIN_INCOMPATIBLE_TYPE: Status.AEROSPIKE_ERR_BIN_INCOMPATIBLE_TYPE; - ERR_RECORD_TOO_BIG: Status.AEROSPIKE_ERR_RECORD_TOO_BIG; - ERR_RECORD_BUSY: Status.AEROSPIKE_ERR_RECORD_BUSY; - ERR_SCAN_ABORTED: Status.AEROSPIKE_ERR_SCAN_ABORTED; - ERR_UNSUPPORTED_FEATURE: Status.AEROSPIKE_ERR_UNSUPPORTED_FEATURE; - ERR_BIN_NOT_FOUND: Status.AEROSPIKE_ERR_BIN_NOT_FOUND; - ERR_DEVICE_OVERLOAD: Status.AEROSPIKE_ERR_DEVICE_OVERLOAD; - ERR_RECORD_KEY_MISMATCH: Status.AEROSPIKE_ERR_RECORD_KEY_MISMATCH; - ERR_NAMESPACE_NOT_FOUND: Status.AEROSPIKE_ERR_NAMESPACE_NOT_FOUND; - ERR_BIN_NAME: Status.AEROSPIKE_ERR_BIN_NAME; - ERR_FAIL_FORBIDDEN: Status.AEROSPIKE_ERR_FAIL_FORBIDDEN; - ERR_FAIL_ELEMENT_NOT_FOUND: Status.AEROSPIKE_ERR_FAIL_ELEMENT_NOT_FOUND; - ERR_FAIL_ELEMENT_EXISTS: Status.AEROSPIKE_ERR_FAIL_ELEMENT_EXISTS; - ERR_ENTERPRISE_ONLY: Status.AEROSPIKE_ERR_ENTERPRISE_ONLY; - // TODO: Remove ERR_FAIL_ENTERPRISE_ONLY - referring to status.js#252 - ERR_FAIL_ENTERPRISE_ONLY: Status.AEROSPIKE_ERR_FAIL_ENTERPRISE_ONLY; - ERR_OP_NOT_APPLICABLE: Status.AEROSPIKE_ERR_OP_NOT_APPLICABLE; - FILTERED_OUT: Status.AEROSPIKE_FILTERED_OUT; - LOST_CONFLICT: Status.AEROSPIKE_LOST_CONFLICT; - QUERY_END: Status.AEROSPIKE_QUERY_END; - SECURITY_NOT_SUPPORTED: Status.AEROSPIKE_SECURITY_NOT_SUPPORTED; - SECURITY_NOT_ENABLED: Status.AEROSPIKE_SECURITY_NOT_ENABLED; - SECURITY_SCHEME_NOT_SUPPORTED: Status.AEROSPIKE_SECURITY_SCHEME_NOT_SUPPORTED; - INVALID_COMMAND: Status.AEROSPIKE_INVALID_COMMAND; - INVALID_FIELD: Status.AEROSPIKE_INVALID_FIELD; - ILLEGAL_STATE: Status.AEROSPIKE_ILLEGAL_STATE; - INVALID_USER: Status.AEROSPIKE_INVALID_USER; - USER_ALREADY_EXISTS: Status.AEROSPIKE_USER_ALREADY_EXISTS; - INVALID_PASSWORD: Status.AEROSPIKE_INVALID_PASSWORD; - EXPIRED_PASSWORD: Status.AEROSPIKE_EXPIRED_PASSWORD; - FORBIDDEN_PASSWORD: Status.AEROSPIKE_FORBIDDEN_PASSWORD; - INVALID_CREDENTIAL: Status.AEROSPIKE_INVALID_CREDENTIAL; - INVALID_ROLE: Status.AEROSPIKE_INVALID_ROLE; - ROLE_ALREADY_EXISTS: Status.AEROSPIKE_ROLE_ALREADY_EXISTS; - INVALID_PRIVILEGE: Status.AEROSPIKE_INVALID_PRIVILEGE; - NOT_AUTHENTICATED: Status.AEROSPIKE_NOT_AUTHENTICATED; - ROLE_VIOLATION: Status.AEROSPIKE_ROLE_VIOLATION; - ERR_UDF: Status.AEROSPIKE_ERR_UDF; - ERR_BATCH_DISABLED: Status.AEROSPIKE_ERR_BATCH_DISABLED; - ERR_BATCH_MAX_REQUESTS_EXCEEDED: Status.AEROSPIKE_ERR_BATCH_MAX_REQUESTS_EXCEEDED; - ERR_BATCH_QUEUES_FULL: Status.AEROSPIKE_ERR_BATCH_QUEUES_FULL; - ERR_GEO_INVALID_GEOJSON: Status.AEROSPIKE_ERR_GEO_INVALID_GEOJSON; - ERR_INDEX_FOUND: Status.AEROSPIKE_ERR_INDEX_FOUND; - ERR_INDEX_NOT_FOUND: Status.AEROSPIKE_ERR_INDEX_NOT_FOUND; - ERR_INDEX_OOM: Status.AEROSPIKE_ERR_INDEX_OOM; - ERR_INDEX_NOT_READABLE: Status.AEROSPIKE_ERR_INDEX_NOT_READABLE; - ERR_INDEX: Status.AEROSPIKE_ERR_INDEX; - ERR_INDEX_NAME_MAXLEN: Status.AEROSPIKE_ERR_INDEX_NAME_MAXLEN; - ERR_INDEX_MAXCOUNT: Status.AEROSPIKE_ERR_INDEX_MAXCOUNT; - ERR_QUERY_ABORTED: Status.AEROSPIKE_ERR_QUERY_ABORTED; - ERR_QUERY_QUEUE_FULL: Status.AEROSPIKE_ERR_QUERY_QUEUE_FULL; - ERR_QUERY_TIMEOUT: Status.AEROSPIKE_ERR_QUERY_TIMEOUT; - ERR_QUERY: Status.AEROSPIKE_ERR_QUERY; - ERR_UDF_NOT_FOUND: Status.AEROSPIKE_ERR_UDF_NOT_FOUND; - ERR_LUA_FILE_NOT_FOUND: Status.AEROSPIKE_ERR_LUA_FILE_NOT_FOUND; - getMessage(code: Status): string; - } - - export interface HLLModule { - writeFlags: HLLWriteFlags; - init(bin: string, indexBits: number, minhashBits: number): HLLOperation; - add(bin: string, list: AerospikeRecordValue[], indexBits?: number, minhashBits?: number): HLLOperation; - setUnion(bin: string, list: AerospikeRecordValue[]): HLLOperation; - refreshCount(bin: string): HLLOperation; - fold(bin: string, indexBits: number): HLLOperation; - getCount(bin: string): HLLOperation; - getUnion(bin: string, list: AerospikeRecordValue[]): HLLOperation; - getUnionCount(bin: string, list: AerospikeRecordValue[]): HLLOperation; - getIntersectCount(bin: string, list: AerospikeRecordValue[]); - getSimilarity(bin: string, list: AerospikeRecordValue[]): HLLOperation; - describe(bin: string): HLLOperation; - } - - interface FeaturesModule { - CDT_MAP: string; - CDT_LIST: string; - BLOB_BITS: string; - } - - interface OperationsModule { - Operation: Operation; - read(bin: string): Operation; - write(bin: string, value: AerospikeRecordValue): WriteOperation; - add(bin: string, value: number | Double): AddOperation; - incr(bin: string, value: number | Double): AddOperation; - append(bin: string, value: string | Buffer): AppendOperation; - prepend(bin: string, value: string | Buffer): PrependOperation; - touch(ttl: number): TouchOperation; - delete(): Operation; - } - - interface ILogInfo { - level?: LogLevel; - file?: Number; - } - - export declare const filter: FilterModule; - export declare enum regex { - BASIC, - EXTENDED, - ICASE, - NEWLINE - } - export declare const info: InfoModule; - export declare const lists: ListsModule - export declare const hll: HLLModule; - export declare const maps: MapsModule; - export declare const cdt: CdtModule; - export declare const bitwise: BitwiseModule; - export declare const operations: OperationsModule; - export declare const policy: PolicyModule; - export declare const ApplyPolicy: ApplyPolicy; - export declare const BatchPolicy: BatchPolicy; - export declare const CommandQueuePolicy: CommandQueuePolicy; - export declare const InfoPolicy: InfoPolicy; - export declare const ListPolicy: ListPolicy; - export declare const MapPolicy: MapPolicy; - export declare const OperatePolicy: OperatePolicy; - export declare const QueryPolicy: QueryPolicy; - export declare const ReadPolicy: ReadPolicy; - export declare const RemovePolicy: RemovePolicy; - export declare const ScanPolicy: ScanPolicy; - export declare const WritePolicy: WritePolicy; - export declare const status: StatusModule; - export declare const features: FeaturesModule; - export declare const AerospikeError: AerospikeError; - export declare const Client: Client; - export declare const Config: Config; - export declare const Double: Double; - export declare const GeoJSON: GeoJSON; - export declare const Key: Key; - export declare const Record: AerospikeRecord; - export declare const auth: Auth; - export declare const language: Language; - export declare const log: Log; - export declare const ttl: TTL; - export declare const jobStatus: JobStatus; - export declare const indexDataType: IndexDataType; - export declare const indexType: IndexType; - export declare function print(err: Error, result: any): void; - export declare function releaseEventLoop(): void; - export declare function client(config: IConfigOptions): Client; - export declare function connect(config: IConfigOptions, callback?: (error?: Error, client?: Client) => void): Promise; - export declare function setDefaultLogging(ILogInfo: ILogInfo): void; - export declare function setupGlobalCommandQueue(policy: CommandQueuePolicy): void; } - -export = Aerospike From d553f9c4d0411a5b359bdcfb519d96a5a2c756bc Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Wed, 22 Jun 2022 14:23:54 -0700 Subject: [PATCH 14/28] typescript support update --- lib/client.js | 6 +++--- lib/config.js | 21 +++++------------- lib/job.js | 24 ++------------------- lib/key.js | 1 + lib/query.js | 18 +--------------- lib/record.js | 2 +- lib/typedefs.js | 50 ++++++++++++++++++++++++++++++++++++++++++ typings/index.d.ts | 54 +++++++++++++++++++++------------------------- 8 files changed, 88 insertions(+), 88 deletions(-) diff --git a/lib/client.js b/lib/client.js index ecc2f439b..42ce70138 100644 --- a/lib/client.js +++ b/lib/client.js @@ -422,7 +422,7 @@ Client.prototype.batchRead = function (records, policy, callback) { * * @example * const Aerospike = require('aerospike') - * const batchType = as.batchTypes + * const batchType = Aerospike.batchType.types * var batchRecords = [ * { type: batchType.BATCH_READ, * key: new Aerospike.Key('test', 'demo', 'key1'), @@ -506,7 +506,7 @@ Client.prototype.batchWrite = function (records, policy, callback) { * * @example * const Aerospike = require('aerospike') - * const batchType = as.batchTypes + * const batchType = Aerospike.batchType.types * var batchRecords = [ * { type: batchType.BATCH_READ, * key: new Aerospike.Key('test', 'demo', 'key1'), @@ -594,7 +594,7 @@ Client.prototype.batchApply = function (records, udf, batchPolicy, batchApplyPol * * @example * const Aerospike = require('aerospike') - * const batchType = as.batchTypes + * const batchType = Aerospike.batchType.types * var batchRecords = [ * { type: batchType.BATCH_REMOVE, * key: new Aerospike.Key('test', 'demo', 'key5'), diff --git a/lib/config.js b/lib/config.js index 6f21c1f55..5f21ec2a4 100644 --- a/lib/config.js +++ b/lib/config.js @@ -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 @@ -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 Setting a default key policy for all write operations * @@ -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 */ @@ -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 diff --git a/lib/job.js b/lib/job.js index 33ff1fe62..881fea2e7 100644 --- a/lib/job.js +++ b/lib/job.js @@ -94,7 +94,7 @@ Job.prototype.checkStatus = function () { * @summary Check the progress of a background job running on the database. * * @param {Client~InfoPolicy} [policy] - The Info Policy to use for this operation. - * @param {Job~infoCallback} [callback] - The function to call with the job info response. + * @param {JobinfoCallback} [callback] - The function to call with the job info response. * * @return {?Promise} If no callback function is passed, the function returns a * Promise that resolves to the job info. @@ -139,7 +139,7 @@ Job.prototype.info = function (policy, callback) { * @summary Wait until the task has been completed. * * @param {number} [pollInterval=1000] - Interval in milliseconds to use when polling the cluster nodes. - * @param {Job~doneCallback} [callback] - The function to call when the task has completed. + * @param {JobdoneCallback} [callback] - The function to call when the task has completed. * * @return {?Promise} If no callback function is passed, the function returns a * Promise that resolves once the job is completed. @@ -162,24 +162,4 @@ Job.prototype.wait = function (pollInterval, callback) { Job.prototype.waitUntilDone = Job.prototype.wait -/** - * @callback Job~doneCallback - * - * @summary Callback function called when a job has completed. - * - * @param {?AerospikeError} error - The error code and message or null if the operation was successful. - */ - -/** - * @callback Job~infoCallback - * - * @summary The function called with the job info response. - * - * @param {?AerospikeError} error - The error code and message or null if the operation was successful. - * @param {object} [info] - The job info. - * @param {number} [info.status] - Status of the job. See {@link module:aerospike.jobStatus}. - * @param {number} [info.progressPct] - Progress estimate for the job, as percentage. - * @param {number} [info.recordsRead] - How many records have been processed. - */ - module.exports = Job diff --git a/lib/key.js b/lib/key.js index eeb7a8c39..b0a32b577 100644 --- a/lib/key.js +++ b/lib/key.js @@ -38,6 +38,7 @@ const DIGEST_LENGTH = 20 * @param {string} set - The Set to which the key belongs. * @param {(string|number|Buffer)} key - The unique key value. Keys can be * strings, integers or an instance of the Buffer class. + * @param {string} [digest] - The digest value of the key. * * @example Creating a new {@link Key} instance * diff --git a/lib/query.js b/lib/query.js index 74a67e130..8e9d29ace 100644 --- a/lib/query.js +++ b/lib/query.js @@ -445,7 +445,7 @@ Query.prototype.results = function (policy) { * @param {string} udfFunction - UDF function name. * @param {Array<*>} [udfArgs] - Arguments for the function. * @param {QueryPolicy} [policy] - The Query Policy to use for this operation. - * @param {Query~aggregationResultCallback} [callback] - The function to call when the operation completes. + * @param {QueryaggregationResultCallback} [callback] - The function to call when the operation completes. * * @returns {?Promise} If no callback function is passed, the function returns * a Promise that resolves to the aggregation results. @@ -567,20 +567,4 @@ function assertValidQueryOptions (options) { assert(!options.aggregationUDF, 'Invalid query arguments: Pass UDF params to Query#apply instead.') } -/** - * @callback Query~aggregationResultCallback - * - * @summary Callback function returning the aggregation result for a query. - * - * @description - * - * If the operation was successful, null will be returned for the - * error parameter. If there was an error, result will be - * undefined and the error paramter will provide more - * information about the error. - * - * @param {?AerospikeError} error - The error code and message or null if the operation was successful. - * @param {(number|string|Array<*>|Object)} [result] - The aggregation result. - */ - module.exports = Query diff --git a/lib/record.js b/lib/record.js index e58de9806..86852cb3b 100644 --- a/lib/record.js +++ b/lib/record.js @@ -108,7 +108,7 @@ * @example Applying functions on batch of records. * * const Aerospike = require('aerospike') - * const batchType = as.batchTypes + * const batchType = Aerospike.batchType.types * var batchRecords = [ * { type: batchType.BATCH_READ, * key: new Aerospike.Key('test', 'demo', 'key1'), diff --git a/lib/typedefs.js b/lib/typedefs.js index 671ceee1f..3ddf8f73c 100644 --- a/lib/typedefs.js +++ b/lib/typedefs.js @@ -180,6 +180,42 @@ * @param {Job} [job] - Handle on a potentially long-running job which can be used to check for job completion. */ +/** + * @callback JobdoneCallback + * + * @summary Callback function called when a job has completed. + * + * @param {?AerospikeError} error - The error code and message or null if the operation was successful. + */ + +/** + * @callback JobinfoCallback + * + * @summary The function called with the job info response. + * + * @param {?AerospikeError} error - The error code and message or null if the operation was successful. + * @param {object} [info] - The job info. + * @param {number} [info.status] - Status of the job. See {@link module:aerospike.jobStatus}. + * @param {number} [info.progressPct] - Progress estimate for the job, as percentage. + * @param {number} [info.recordsRead] - How many records have been processed. + */ + +/** + * @callback QueryaggregationResultCallback + * + * @summary Callback function returning the aggregation result for a query. + * + * @description + * + * If the operation was successful, null will be returned for the + * error parameter. If there was an error, result will be + * undefined and the error paramter will provide more + * information about the error. + * + * @param {?AerospikeError} error - The error code and message or null if the operation was successful. + * @param {(number|string|Array<*>|Object)} [result] - The aggregation result. + */ + /** * @typedef {object} AerospikeExp * @@ -206,6 +242,20 @@ * */ +/** + * @typedef {Object} 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 + */ + /** * @typedef {object} Operation * diff --git a/typings/index.d.ts b/typings/index.d.ts index 7c6e99a5e..bc7a3c34a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -908,13 +908,13 @@ declare module "bigint" { } declare module "key" { export = Key; - function Key(ns: string, set: string, key: (string | number | Buffer), digest: any): void; + function Key(ns: string, set: string, key: (string | number | Buffer), digest?: string | undefined): void; class Key { - constructor(ns: string, set: string, key: (string | number | Buffer), digest: any); + constructor(ns: string, set: string, key: (string | number | Buffer), digest?: string | undefined); ns: string; set: string; key: string | number | Buffer; - digest: any; + digest: string | null; equals(other: any): any; } namespace Key { @@ -950,16 +950,14 @@ declare module "job" { module: any; private hasCompleted; private checkStatus; - info(policy: any, callback: any): Promise | null; - wait(pollInterval?: number | undefined, callback: any): Promise | null; + info(policy: any, callback?: JobinfoCallback | undefined): Promise | null; + wait(pollInterval?: number | undefined, callback?: JobdoneCallback | undefined): Promise | null; waitUntilDone: any; } namespace Job { - export { safeRandomJobID, pollUntilDone, Job }; + function safeRandomJobID(): number; + function pollUntilDone(statusFunction: any, pollInterval: any): Promise; } - function safeRandomJobID(): number; - function pollUntilDone(statusFunction: any, pollInterval: any): Promise; - type Job = () => any; } declare module "commands/query_background_command" { function _exports(asCommand: any): { @@ -1181,7 +1179,7 @@ declare module "config" { port: any; tls: any; hosts: (Host[] | string); - policies: Config; + policies: Policies; log: any; connTimeoutMs: any; loginTimeoutMs: any; @@ -1195,21 +1193,9 @@ declare module "config" { rackAware: boolean; rackId: any; setDefaultPolicies(policies: any): void; + private [inspect]; } - namespace Config { - export { Config }; - } - type Config = { - apply: ApplyPolicy; - batch: BatchPolicy; - info: InfoPolicy; - operate: OperatePolicy; - read: ReadPolicy; - remove: RemovePolicy; - scan: ScanPolicy; - query: QueryPolicy; - write: WritePolicy; - }; + const inspect: unique symbol; } declare module "index_job" { export = IndexJob; @@ -1269,16 +1255,12 @@ declare module "query" { } | undefined; foreach(policy?: QueryPolicy, dataCb?: recordCallback | undefined, errorCb?: errorCallback | undefined, endCb?: doneCallback | undefined): RecordStream; results(policy?: QueryPolicy): Promise; - apply(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: QueryPolicy, callback: any): Promise | null; + apply(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: QueryPolicy, callback?: QueryaggregationResultCallback | undefined): Promise | null; background(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: WritePolicy, queryID?: number | undefined, callback?: jobCallback | undefined): Promise | null; operate(operations: any, policy?: QueryPolicy, queryID?: number | undefined, callback?: jobCallback | undefined): Promise | null; ops: any; } - namespace Query { - export { Query }; - } import RecordStream = require("record_stream"); - type Query = () => any; } declare module "scan" { export = Scan; @@ -1538,6 +1520,9 @@ type connectCallback = () => any; type infoCallback = () => any; type infoAllCallback = () => any; type jobCallback = () => any; +type JobdoneCallback = () => any; +type JobinfoCallback = () => any; +type QueryaggregationResultCallback = () => any; type AerospikeExp = object; type ApplyPolicy = object; type BatchPolicy = object; @@ -1551,6 +1536,17 @@ type WritePolicy = object; type BitwisePolicy = object; type MapPolicy = object; type CommandQueuePolicy = object; +type Policies = { + apply: ApplyPolicy; + batch: BatchPolicy; + info: InfoPolicy; + operate: OperatePolicy; + read: ReadPolicy; + remove: RemovePolicy; + scan: ScanPolicy; + query: QueryPolicy; + write: WritePolicy; +}; type Operation = object; type Client = object; type Key = object; From 1b75651dfabd26a5b9722aebaf773aeb80305cb4 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Wed, 22 Jun 2022 15:54:22 -0700 Subject: [PATCH 15/28] mac openssl ln fix --- scripts/build-commands.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-commands.sh b/scripts/build-commands.sh index 442c1c353..9b83a73c0 100755 --- a/scripts/build-commands.sh +++ b/scripts/build-commands.sh @@ -168,7 +168,7 @@ setup() { brew install ${PACKAGES[@]} # link openssl unlink /usr/local/opt/openssl - ln -s /usr/local/Cellar/openssl@3/3.0.3/ /usr/local/opt/openssl + ln -s /usr/local/Cellar/openssl@3/*/ /usr/local/opt/openssl export LDFLAGS="-L/usr/local/opt/openssl@3/lib" export CPPFLAGS="-I/usr/local/opt/openssl@3/include" fi From a7284a842b4edc8a66288144c3ddf7349c4d17ba Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Thu, 23 Jun 2022 10:59:59 -0700 Subject: [PATCH 16/28] build update --- scripts/build-package.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/build-package.ps1 b/scripts/build-package.ps1 index d302cc8dd..269fd325a 100644 --- a/scripts/build-package.ps1 +++ b/scripts/build-package.ps1 @@ -24,14 +24,14 @@ function build_nodejs_client { # .\nvm-setup.exe /VERYSILENT /SUPRESSMSGBOXES /SP # nvm root .\nvm -pwd +# pwd -cd $Env:USERPROFILE; -Invoke-WebRequest https://raw.githubusercontent.com/jchip/nvm/v1.5.4/install.ps1 -OutFile install.ps1; -.\install.ps1 -nvmhome $Env:USERPROFILE\nvm; -del install.ps1 +# cd $Env:USERPROFILE; +# Invoke-WebRequest https://raw.githubusercontent.com/jchip/nvm/v1.5.4/install.ps1 -OutFile install.ps1; +# .\install.ps1 -nvmhome $Env:USERPROFILE\nvm; +# del install.ps1 -cd D:\a\aerospike-client-nodejs\aerospike-client-nodejs +# cd D:\a\aerospike-client-nodejs\aerospike-client-nodejs build_nodejs_client v10.20.0 build_nodejs_client v12.22.10 From 8f01aab9f75ebf60a404f9125462507b3b577ff3 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Thu, 23 Jun 2022 13:29:12 -0700 Subject: [PATCH 17/28] workflow name update --- .github/workflows/linux-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index de757dfac..e111b4e33 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -1,7 +1,7 @@ # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions -name: Aerospike Node.js Client Tests +name: Aerospike Node.js Linux Client Tests on: push: From a9a97dfd26c95c3e07d5c9944c0256e434e176d9 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Thu, 23 Jun 2022 14:37:10 -0700 Subject: [PATCH 18/28] version bump from 5.0.2 to 5.0.3 for typescript support --- package-lock.json | 92 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/package-lock.json b/package-lock.json index c434c27ba..fe15d00c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "aerospike", - "version": "5.0.2", + "version": "5.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "aerospike", - "version": "5.0.2", + "version": "5.0.3", "cpu": [ "x64" ], @@ -588,9 +588,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "17.0.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz", - "integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==", + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", + "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", "dev": true }, "node_modules/@ungap/promise-all-settled": { @@ -3321,7 +3321,7 @@ "node_modules/load-json-file/node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true, "engines": { "node": ">=4" @@ -4583,7 +4583,7 @@ "node_modules/pkg-conf/node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true, "engines": { "node": ">=4" @@ -4826,7 +4826,7 @@ "node_modules/read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==", "dev": true, "dependencies": { "load-json-file": "^4.0.0", @@ -4840,7 +4840,7 @@ "node_modules/read-pkg-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= sha512-YFzFrVvpC6frF1sz8psoHDBGF7fLPc+llq/8NB43oagqWkx8ar5zYtsTORtOjw9W2RHLpWP+zTWwBvf1bCmcSw==", "dev": true, "dependencies": { "find-up": "^2.0.0", @@ -4974,7 +4974,7 @@ "node_modules/release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", "dev": true, "dependencies": { "es6-error": "^4.0.1" @@ -4986,7 +4986,7 @@ "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I= sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -5036,7 +5036,7 @@ "node_modules/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=", + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", "engines": { "node": ">= 4" } @@ -5099,7 +5099,7 @@ "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc= sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, "node_modules/shebang-command": { "version": "2.0.0", @@ -5287,7 +5287,7 @@ "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "node_modules/ssri": { @@ -5497,7 +5497,7 @@ "node_modules/stubs": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", - "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=", + "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls= sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==", "dev": true }, "node_modules/supports-color": { @@ -5620,7 +5620,7 @@ "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "node_modules/tmp": { @@ -5650,7 +5650,7 @@ "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", "dev": true, "engines": { "node": ">=4" @@ -5671,7 +5671,7 @@ "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/tsconfig-paths": { "version": "3.14.1", @@ -5700,7 +5700,7 @@ "node_modules/tsconfig-paths/node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true, "engines": { "node": ">=4" @@ -5797,7 +5797,7 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/uuid": { "version": "3.4.0", @@ -5828,12 +5828,12 @@ "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0= sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -5872,7 +5872,7 @@ "node_modules/which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==", "dev": true }, "node_modules/wide-align": { @@ -5948,7 +5948,7 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "node_modules/write-file-atomic": { "version": "3.0.3", @@ -6554,9 +6554,9 @@ "dev": true }, "@types/node": { - "version": "17.0.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.38.tgz", - "integrity": "sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==", + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", + "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", "dev": true }, "@ungap/promise-all-settled": { @@ -8570,7 +8570,7 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true } } @@ -9507,7 +9507,7 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true }, "type-fest": { @@ -9696,7 +9696,7 @@ "read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==", "dev": true, "requires": { "load-json-file": "^4.0.0", @@ -9707,7 +9707,7 @@ "read-pkg-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", + "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= sha512-YFzFrVvpC6frF1sz8psoHDBGF7fLPc+llq/8NB43oagqWkx8ar5zYtsTORtOjw9W2RHLpWP+zTWwBvf1bCmcSw==", "dev": true, "requires": { "find-up": "^2.0.0", @@ -9804,7 +9804,7 @@ "release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", - "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", "dev": true, "requires": { "es6-error": "^4.0.1" @@ -9813,7 +9813,7 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I= sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, "require-from-string": { @@ -9848,7 +9848,7 @@ "retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" + "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==" }, "rimraf": { "version": "3.0.2", @@ -9896,7 +9896,7 @@ "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc= sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, "shebang-command": { "version": "2.0.0", @@ -10045,7 +10045,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "ssri": { @@ -10179,7 +10179,7 @@ "stubs": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", - "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls=", + "integrity": "sha1-6NK6H6nJBXAwPAMLaQD31fiavls= sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==", "dev": true }, "supports-color": { @@ -10278,7 +10278,7 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "tmp": { @@ -10304,7 +10304,7 @@ "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", "dev": true }, "to-regex-range": { @@ -10319,7 +10319,7 @@ "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "tsconfig-paths": { "version": "3.14.1", @@ -10345,7 +10345,7 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true } } @@ -10429,7 +10429,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "uuid": { "version": "3.4.0", @@ -10456,12 +10456,12 @@ "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0= sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "requires": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -10491,7 +10491,7 @@ "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==", "dev": true }, "wide-align": { @@ -10554,7 +10554,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "write-file-atomic": { "version": "3.0.3", diff --git a/package.json b/package.json index 225a0a269..010bc500b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aerospike", - "version": "5.0.2", + "version": "5.0.3", "description": "Aerospike Client Library", "keywords": [ "aerospike", From 1aff43247c74f5b74085c4e78c5fca901a28c4b8 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 12:04:29 -0700 Subject: [PATCH 19/28] batch_type export updated - ts --- lib/batch_type.js | 2 +- lib/client.js | 6 +++--- lib/record.js | 2 +- test/batch_write.js | 2 +- typings/index.d.ts | 17 ++++++++++------- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/batch_type.js b/lib/batch_type.js index e63274e37..2352b087a 100644 --- a/lib/batch_type.js +++ b/lib/batch_type.js @@ -28,7 +28,7 @@ const batchType = as.batchTypes // ======================================================================== // Constants // ======================================================================== -exports.types = { +module.exports = { /** * An instance of class Record that is used in a batch for read operations. * @const {number} diff --git a/lib/client.js b/lib/client.js index 42ce70138..cadb9581a 100644 --- a/lib/client.js +++ b/lib/client.js @@ -422,7 +422,7 @@ Client.prototype.batchRead = function (records, policy, callback) { * * @example * const Aerospike = require('aerospike') - * const batchType = Aerospike.batchType.types + * const batchType = Aerospike.batchType * var batchRecords = [ * { type: batchType.BATCH_READ, * key: new Aerospike.Key('test', 'demo', 'key1'), @@ -506,7 +506,7 @@ Client.prototype.batchWrite = function (records, policy, callback) { * * @example * const Aerospike = require('aerospike') - * const batchType = Aerospike.batchType.types + * const batchType = Aerospike.batchType * var batchRecords = [ * { type: batchType.BATCH_READ, * key: new Aerospike.Key('test', 'demo', 'key1'), @@ -594,7 +594,7 @@ Client.prototype.batchApply = function (records, udf, batchPolicy, batchApplyPol * * @example * const Aerospike = require('aerospike') - * const batchType = Aerospike.batchType.types + * const batchType = Aerospike.batchType * var batchRecords = [ * { type: batchType.BATCH_REMOVE, * key: new Aerospike.Key('test', 'demo', 'key5'), diff --git a/lib/record.js b/lib/record.js index 86852cb3b..b6c31fd50 100644 --- a/lib/record.js +++ b/lib/record.js @@ -108,7 +108,7 @@ * @example Applying functions on batch of records. * * const Aerospike = require('aerospike') - * const batchType = Aerospike.batchType.types + * const batchType = Aerospike.batchType * var batchRecords = [ * { type: batchType.BATCH_READ, * key: new Aerospike.Key('test', 'demo', 'key1'), diff --git a/test/batch_write.js b/test/batch_write.js index cba18413b..1bd80134b 100644 --- a/test/batch_write.js +++ b/test/batch_write.js @@ -22,7 +22,7 @@ const Aerospike = require('../lib/aerospike') const helper = require('./test_helper') // const util = require('util') -const batchType = Aerospike.batchType.types +const batchType = Aerospike.batchType const op = Aerospike.operations const GeoJSON = Aerospike.GeoJSON diff --git a/typings/index.d.ts b/typings/index.d.ts index bc7a3c34a..46c1ca140 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1438,12 +1438,10 @@ declare module "double" { } } declare module "batch_type" { - export namespace types { - const BATCH_READ: any; - const BATCH_WRITE: any; - const BATCH_APPLY: any; - const BATCH_REMOVE: any; - } + export const BATCH_READ: any; + export const BATCH_WRITE: any; + export const BATCH_APPLY: any; + export const BATCH_REMOVE: any; } declare module "aerospike" { export const filter: typeof import("filter"); @@ -1504,7 +1502,12 @@ declare module "aerospike" { export function connect(config?: any, callback?: connectCallback | undefined): Promise | null; export function setDefaultLogging(logInfo: any): void; export function setupGlobalCommandQueue(policy: CommandQueuePolicy): void; - export const batchType: typeof import("batch_type"); + export const batchType: { + BATCH_READ: any; + BATCH_WRITE: any; + BATCH_APPLY: any; + BATCH_REMOVE: any; + }; import AerospikeError = require("error"); import EventLoop = require("event_loop"); } From 392a8e252556631cdd87435596f1e3167c717ba1 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 12:32:58 -0700 Subject: [PATCH 20/28] code review - update param types --- lib/client.js | 8 ++++---- lib/query.js | 2 +- lib/typedefs.js | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/client.js b/lib/client.js index cadb9581a..bed9719ee 100644 --- a/lib/client.js +++ b/lib/client.js @@ -348,7 +348,7 @@ Client.prototype.batchGet = function (keys, policy, callback) { * * @param {object[]} records - {@link Record} List of keys and bins to retrieve. * @param {number} records[].type - {@link Record#type} Batch type. - * @param {string} records[].key - Record Key. + * @param {Key} records[].key - Record Key. * @param {string[]} [records[].bins] - List of bins to retrieve. * @param {boolean} [records[].readAllBins] - Whether to retrieve all bins or * just the meta data of the record. If true, ignore bins and read @@ -410,7 +410,7 @@ Client.prototype.batchRead = function (records, policy, callback) { * * @param {object[]} records - {@link Record} List of batch sub-commands to perform. * @param {number} records[].type - {@link Record#type} Batch type. - * @param {string} records[].key - Record Key. + * @param {Key} records[].key - Record Key. * @param {BatchPolicy} [policy] - The Batch Policy to use for this operation. * @param {batchRecordsCallback} [callback] - The function to call when * the operation completes, with the results of the batch operation. @@ -492,7 +492,7 @@ Client.prototype.batchWrite = function (records, policy, callback) { * * @param {object[]} records - {@link Record} List of batch sub-commands to perform. * @param {number} records[].type - {@link Record#type} Batch type. - * @param {string} records[].key - Record Key. + * @param {Key} records[].key - Record Key. * @param {object[]} udf - Server UDF module/function and argList to apply. * @param {BatchPolicy} [batchPolicy] - The Batch Policy to use for this operation. * @param {BatchApplyPolicy} [batchApplyPolicy] UDF policy configuration parameters. @@ -581,7 +581,7 @@ Client.prototype.batchApply = function (records, udf, batchPolicy, batchApplyPol * * @param {object[]} records - {@link Record} List of batch sub-commands to perform. * @param {number} records[].type - {@link Record#type} Batch type. - * @param {string} records[].key - Record Key. + * @param {Key} records[].key - Record Key. * @param {BatchPolicy} [batchPolicy] - The Batch Policy to use for this operation. * @param {BatchRemovePolicy} [batchRemovePolicy] Remove policy configuration parameters. * @param {batchRecordsCallback} [callback] - The function to call when diff --git a/lib/query.js b/lib/query.js index 8e9d29ace..b58497815 100644 --- a/lib/query.js +++ b/lib/query.js @@ -422,7 +422,7 @@ Query.prototype.foreach = function (policy, dataCb, errorCb, endCb) { * * @param {QueryPolicy} [policy] - The Query Policy to use for this operation. * - * @returns {Promise} + * @returns {Promise} */ Query.prototype.results = function (policy) { return new Promise((resolve, reject) => { diff --git a/lib/typedefs.js b/lib/typedefs.js index 3ddf8f73c..979ea7f6b 100644 --- a/lib/typedefs.js +++ b/lib/typedefs.js @@ -277,9 +277,9 @@ * */ -// /** -// * @typedef {object} Record -// * -// * @summary Aerospike Record object -// * -// */ +/** + * @typedef {object} RecordObject + * + * @summary Aerospike Record object + * + */ From bc2ccf4ca5131a53ecb33efaf225a19f67afe77a Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 12:33:21 -0700 Subject: [PATCH 21/28] code review - update param types --- typings/index.d.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 46c1ca140..46fc6bf0c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1254,7 +1254,7 @@ declare module "query" { digest: string; } | undefined; foreach(policy?: QueryPolicy, dataCb?: recordCallback | undefined, errorCb?: errorCallback | undefined, endCb?: doneCallback | undefined): RecordStream; - results(policy?: QueryPolicy): Promise; + results(policy?: QueryPolicy): Promise; apply(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: QueryPolicy, callback?: QueryaggregationResultCallback | undefined): Promise | null; background(udfModule: string, udfFunction: string, udfArgs?: any[] | undefined, policy?: WritePolicy, queryID?: number | undefined, callback?: jobCallback | undefined): Promise | null; operate(operations: any, policy?: QueryPolicy, queryID?: number | undefined, callback?: jobCallback | undefined): Promise | null; @@ -1345,21 +1345,21 @@ declare module "client" { batchGet(keys: Key[], policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; batchRead(records: { type: number; - key: string; + key: Key; bins?: string[]; readAllBins?: boolean; }, policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; batchWrite(records: { type: number; - key: string; + key: Key; }, policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; batchApply(records: { type: number; - key: string; + key: Key; }, udf: object[], batchPolicy?: BatchPolicy, batchApplyPolicy?: any, callback?: batchRecordsCallback | undefined): Promise | null; batchRemove(records: { type: number; - key: string; + key: Key; }, batchPolicy?: BatchPolicy, batchRemovePolicy?: any, callback?: batchRecordsCallback | undefined): Promise | null; batchSelect(keys: Key[], bins: string[], policy?: BatchPolicy, callback?: batchRecordsCallback | undefined): Promise | null; close(releaseEventLoop?: boolean | undefined): void; @@ -1553,6 +1553,7 @@ type Policies = { type Operation = object; type Client = object; type Key = object; +type RecordObject = object; declare module "policies/bitwise_policy" { export = BitwisePolicy; class BitwisePolicy { From 67c46814fe8702e8cdfa7867ded8b180cb2f45bb Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 13:11:53 -0700 Subject: [PATCH 22/28] consider in_doubt result for batch write operation --- src/main/util/conversions_batch.cc | 2 ++ test/batch_write.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/util/conversions_batch.cc b/src/main/util/conversions_batch.cc index 8158a592b..24b175278 100644 --- a/src/main/util/conversions_batch.cc +++ b/src/main/util/conversions_batch.cc @@ -455,6 +455,8 @@ Local batch_records_to_jsarray(const as_batch_records *records, Nan::Set(result, Nan::New("bins").ToLocalChecked(), recordbins_to_jsobject(record, log)); } + Nan::Set(result, Nan::New("inDoubt").ToLocalChecked(), + batch_record->in_doubt ? Nan::True() : Nan::False()); Nan::Set(results, i, result); } diff --git a/test/batch_write.js b/test/batch_write.js index 1bd80134b..5c92fd1dc 100644 --- a/test/batch_write.js +++ b/test/batch_write.js @@ -87,7 +87,9 @@ describe('client.batchWrite()', function () { expect(results.length).to.equal(5) const found = results.filter( result => result.status === Aerospike.status.OK) - expect(found.length).to.equal(3) + const inDoubt = results.filter( + result => result.inDoubt === true) + expect(found.length).to.equal(3-inDoubt) const notFound = results.filter( result => result.status === Aerospike.status.ERR_RECORD_NOT_FOUND) expect(notFound.length).to.equal(2) From 0c5059c78dc22374f67d56afa5a3c66b9fd66dd9 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 13:17:11 -0700 Subject: [PATCH 23/28] lint update --- test/batch_write.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/batch_write.js b/test/batch_write.js index 5c92fd1dc..47cfc0695 100644 --- a/test/batch_write.js +++ b/test/batch_write.js @@ -89,7 +89,7 @@ describe('client.batchWrite()', function () { result => result.status === Aerospike.status.OK) const inDoubt = results.filter( result => result.inDoubt === true) - expect(found.length).to.equal(3-inDoubt) + expect(found.length).to.equal(3 - inDoubt) const notFound = results.filter( result => result.status === Aerospike.status.ERR_RECORD_NOT_FOUND) expect(notFound.length).to.equal(2) From 666ab578937450acab2b4acaf19418a2009ee5be Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 13:51:34 -0700 Subject: [PATCH 24/28] batch write test update --- test/batch_write.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/batch_write.js b/test/batch_write.js index 47cfc0695..abf85a7d7 100644 --- a/test/batch_write.js +++ b/test/batch_write.js @@ -83,15 +83,16 @@ describe('client.batchWrite()', function () { ] client.batchWrite(batchRecords, function (err, results) { - expect(err).not.to.be.ok() - expect(results.length).to.equal(5) const found = results.filter( result => result.status === Aerospike.status.OK) const inDoubt = results.filter( result => result.inDoubt === true) - expect(found.length).to.equal(3 - inDoubt) const notFound = results.filter( result => result.status === Aerospike.status.ERR_RECORD_NOT_FOUND) + console.log("found:", found.length, "inDoubt:", inDoubt.length, "notFound:", notFound.length) + expect(err).not.to.be.ok() + expect(results.length).to.equal(5) + expect(found.length).to.equal(3 - inDoubt.length) expect(notFound.length).to.equal(2) done() }) From b9944eba4437d4749d418e03cb96278f442aecc3 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Tue, 28 Jun 2022 13:52:14 -0700 Subject: [PATCH 25/28] lint update --- test/batch_write.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/batch_write.js b/test/batch_write.js index abf85a7d7..4d9010529 100644 --- a/test/batch_write.js +++ b/test/batch_write.js @@ -89,7 +89,7 @@ describe('client.batchWrite()', function () { result => result.inDoubt === true) const notFound = results.filter( result => result.status === Aerospike.status.ERR_RECORD_NOT_FOUND) - console.log("found:", found.length, "inDoubt:", inDoubt.length, "notFound:", notFound.length) + console.log('found:', found.length, 'inDoubt:', inDoubt.length, 'notFound:', notFound.length) expect(err).not.to.be.ok() expect(results.length).to.equal(5) expect(found.length).to.equal(3 - inDoubt.length) From 26bb135085fd4753b3cc967eab4bddcf3b9a1887 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Wed, 29 Jun 2022 13:41:02 -0700 Subject: [PATCH 26/28] PKI conncection method example added --- lib/aerospike.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/aerospike.js b/lib/aerospike.js index 8e791e650..c481e6cbf 100644 --- a/lib/aerospike.js +++ b/lib/aerospike.js @@ -284,6 +284,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 based on a certificate. No user name or + * password needs to be configured. Requires TLS and a client certificate. * * @example Using external authentication mode, e.g. to use LDAP authentication * @@ -295,6 +298,24 @@ exports.Record = require('./record') * authMode: Aerospike.auth.EXTERNAL * } * + * + * @example Using PKI authentication mode + * + * 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) From fbcd1da8008370e84ef29dec07161901081833a5 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Wed, 29 Jun 2022 13:56:14 -0700 Subject: [PATCH 27/28] PKI conncection method --- lib/aerospike.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/aerospike.js b/lib/aerospike.js index c481e6cbf..dcd41cae1 100644 --- a/lib/aerospike.js +++ b/lib/aerospike.js @@ -284,8 +284,8 @@ 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 based on a certificate. No user name or + * @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 TLS and a client certificate. * * @example Using external authentication mode, e.g. to use LDAP authentication From f48b2749027666e1ea16bcd4528e9042184b01b7 Mon Sep 17 00:00:00 2001 From: rpandian-spike Date: Thu, 30 Jun 2022 10:33:55 -0700 Subject: [PATCH 28/28] PKI conncection method - review update --- lib/aerospike.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aerospike.js b/lib/aerospike.js index dcd41cae1..50e2468d8 100644 --- a/lib/aerospike.js +++ b/lib/aerospike.js @@ -286,7 +286,7 @@ exports.Record = require('./record') * 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 TLS and a client certificate. + * password needs to be configured. Requires mTLS and a client certificate. * * @example Using external authentication mode, e.g. to use LDAP authentication *