couchbase 4.2.3 → 4.2.5-dev.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CMakeLists.txt +136 -11
- package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
- package/deps/couchbase-cxx-client/README.md +1 -0
- package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
- package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
- package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
- package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
- package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
- package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
- package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
- package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
- package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
- package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
- package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
- package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
- package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
- package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
- package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
- package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
- package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
- package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
- package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
- package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
- package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
- package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
- package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
- package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
- package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
- package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
- package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
- package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
- package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
- package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
- package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
- package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
- package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
- package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
- package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
- package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
- package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
- package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
- package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
- package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
- package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
- package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
- package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
- package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
- package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
- package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
- package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
- package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
- package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
- package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
- package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
- package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
- package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
- package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
- package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
- package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
- package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
- package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
- package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
- package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
- package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
- package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
- package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
- package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
- package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
- package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
- package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
- package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
- package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
- package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
- package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
- package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
- package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
- package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
- package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
- package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
- package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
- package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
- package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
- package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
- package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
- package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
- package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
- package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
- package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
- package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
- package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
- package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
- package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
- package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
- package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
- package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
- package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
- package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
- package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
- package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
- package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
- package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
- package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
- package/dist/binding.d.ts +1 -1
- package/dist/binding.js +3 -2
- package/package.json +96 -1
- package/scripts/createPlatformPackages.js +108 -0
- package/scripts/install.js +45 -0
- package/scripts/prebuilds.js +249 -0
- package/scripts/prune.js +124 -0
- package/src/jstocbpp_autogen.hpp +3 -2
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
const path = require('path')
|
4
|
+
var proc = require('child_process')
|
5
|
+
const prebuilds = require('./prebuilds')
|
6
|
+
|
7
|
+
if (hasLocalPrebuild()) {
|
8
|
+
const destination = path.join(
|
9
|
+
path.resolve(__dirname, '..'),
|
10
|
+
'build',
|
11
|
+
'Release'
|
12
|
+
)
|
13
|
+
const source = getLocalPrebuild()
|
14
|
+
// on either success or failure of resolving local prebuild we still confirm we have a prebuild
|
15
|
+
prebuilds.resolveLocalPrebuild(source, destination).then(installPrebuild())
|
16
|
+
} else {
|
17
|
+
installPrebuild()
|
18
|
+
}
|
19
|
+
|
20
|
+
function getLocalPrebuild() {
|
21
|
+
const localPrebuildsName = `npm_config_couchbase_local_prebuilds`
|
22
|
+
return process.env[localPrebuildsName]
|
23
|
+
}
|
24
|
+
|
25
|
+
function hasLocalPrebuild() {
|
26
|
+
return typeof getLocalPrebuild() === 'string'
|
27
|
+
}
|
28
|
+
|
29
|
+
function installPrebuild() {
|
30
|
+
try {
|
31
|
+
prebuilds.resolvePrebuild(path.resolve(__dirname, '..'), false)
|
32
|
+
process.exit(0)
|
33
|
+
} catch (err) {
|
34
|
+
const cmakejs = path.join(
|
35
|
+
require.resolve('cmake-js/package.json'),
|
36
|
+
'..',
|
37
|
+
require('cmake-js/package.json').bin['cmake-js']
|
38
|
+
)
|
39
|
+
// @TODO: is spawning sync a problem? Seemed to be easiest way to get Ctrl-C to kill the whole build process
|
40
|
+
const cmakejsProc = proc.spawnSync(process.execPath, [cmakejs, 'compile'], {
|
41
|
+
stdio: 'inherit',
|
42
|
+
})
|
43
|
+
process.exit(cmakejsProc.status)
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,249 @@
|
|
1
|
+
const fs = require('fs')
|
2
|
+
const path = require('path')
|
3
|
+
const zlib = require('zlib')
|
4
|
+
const stream = require('stream')
|
5
|
+
const { promisify } = require('util')
|
6
|
+
const pipe = promisify(stream.pipeline)
|
7
|
+
|
8
|
+
// Workaround to fix webpack's build warnings: 'the request of a dependency is an expression'
|
9
|
+
const runtimeRequire =
|
10
|
+
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
|
11
|
+
|
12
|
+
const openSSLVersions = ['openssl1', 'openssl3']
|
13
|
+
const supportedPlatforms = ['darwin', 'linux', 'linuxmusl', 'win32']
|
14
|
+
const supportedArches = ['x64', 'arm64']
|
15
|
+
|
16
|
+
const runtime = isElectron() ? 'electron' : 'node'
|
17
|
+
const nodeVersion = getNodeVersion()
|
18
|
+
const nodeVersionMajor = getNodeMajorVersion(nodeVersion)
|
19
|
+
const arch = process.arch
|
20
|
+
const platform = process.platform
|
21
|
+
const libc = getLinuxType(platform)
|
22
|
+
const sslType = getSSLType(runtime, nodeVersion)
|
23
|
+
|
24
|
+
function getLocalPrebuild(dir) {
|
25
|
+
const localPrebuildDir = path.join(dir, 'build/Release')
|
26
|
+
const files = readdirSync(localPrebuildDir).filter(matchBuild)
|
27
|
+
return files[0] && path.join(localPrebuildDir, files[0])
|
28
|
+
}
|
29
|
+
|
30
|
+
function getLinuxType(platform) {
|
31
|
+
if (platform !== 'linux') {
|
32
|
+
return ''
|
33
|
+
}
|
34
|
+
return `linux${isAlpine(platform) ? 'musl' : ''}`
|
35
|
+
}
|
36
|
+
|
37
|
+
function getNodeMajorVersion(version) {
|
38
|
+
const tokens = version.split('.')
|
39
|
+
return parseInt(tokens[0])
|
40
|
+
}
|
41
|
+
|
42
|
+
function getNodeVersion() {
|
43
|
+
return process.version.replace('v', '')
|
44
|
+
}
|
45
|
+
|
46
|
+
function getPrebuildsInfo(dir) {
|
47
|
+
dir = path.resolve(dir || '.')
|
48
|
+
const info = {
|
49
|
+
packageDir: path.join(dir, 'package.json'),
|
50
|
+
platformPackageDir: undefined,
|
51
|
+
}
|
52
|
+
|
53
|
+
const packageName = JSON.parse(fs.readFileSync(info.packageDir)).name
|
54
|
+
if (packageName !== undefined) {
|
55
|
+
const allowedPlatformPkg = `${packageName}-${
|
56
|
+
platform === 'linux' ? libc : platform
|
57
|
+
}-${arch}-${sslType}`
|
58
|
+
const fullPlatformPkgName = `@${packageName}/${allowedPlatformPkg}`
|
59
|
+
const packageRequire = require('module').createRequire(
|
60
|
+
path.join(dir, 'package.json')
|
61
|
+
)
|
62
|
+
info.packageDir = path.dirname(path.join(dir, 'package.json'))
|
63
|
+
info.platformPackageDir = path.dirname(
|
64
|
+
packageRequire.resolve(fullPlatformPkgName)
|
65
|
+
)
|
66
|
+
}
|
67
|
+
return info
|
68
|
+
}
|
69
|
+
|
70
|
+
function getSSLType(runtime, version) {
|
71
|
+
if (runtime === 'electron') {
|
72
|
+
return 'boringssl'
|
73
|
+
}
|
74
|
+
|
75
|
+
const major = getNodeMajorVersion(version)
|
76
|
+
if (major >= 18) {
|
77
|
+
return 'openssl3'
|
78
|
+
}
|
79
|
+
return 'openssl1'
|
80
|
+
}
|
81
|
+
|
82
|
+
function getSupportedPlatformPackages(packageName) {
|
83
|
+
packageName = packageName || 'couchbase'
|
84
|
+
if (packageName !== 'couchbase') {
|
85
|
+
throw new Error(
|
86
|
+
'Cannot build supported platform packages for package other than couchbase.'
|
87
|
+
)
|
88
|
+
}
|
89
|
+
|
90
|
+
const packageNames = []
|
91
|
+
// format: <platform>-<arch>-<runtime>-<SSL Type>
|
92
|
+
supportedPlatforms.forEach((plat) => {
|
93
|
+
supportedArches.forEach((arch) => {
|
94
|
+
if (plat === 'win32' && arch === 'arm64') return
|
95
|
+
openSSLVersions.forEach((ssl) => {
|
96
|
+
packageNames.push(`${packageName}-${plat}-${arch}-${ssl}`)
|
97
|
+
})
|
98
|
+
packageNames.push(`${packageName}-${plat}-${arch}-boringssl`)
|
99
|
+
})
|
100
|
+
})
|
101
|
+
return packageNames
|
102
|
+
}
|
103
|
+
|
104
|
+
function isAlpine(platform) {
|
105
|
+
return platform === 'linux' && fs.existsSync('/etc/alpine-release')
|
106
|
+
}
|
107
|
+
|
108
|
+
function isElectron() {
|
109
|
+
if (process.versions && process.versions.electron) return true
|
110
|
+
if (process.env.ELECTRON_RUN_AS_NODE) return true
|
111
|
+
return (
|
112
|
+
typeof window !== 'undefined' &&
|
113
|
+
window.process &&
|
114
|
+
window.process.type === 'renderer'
|
115
|
+
)
|
116
|
+
}
|
117
|
+
|
118
|
+
function loadPrebuild(dir) {
|
119
|
+
return runtimeRequire(resolvePrebuild(dir))
|
120
|
+
}
|
121
|
+
|
122
|
+
function matchBuild(name) {
|
123
|
+
return /\.node$/.test(name)
|
124
|
+
}
|
125
|
+
|
126
|
+
function matchingPlatformPrebuild(filename) {
|
127
|
+
if (['index.js', 'package.json', 'README.md'].includes(filename)) {
|
128
|
+
return false
|
129
|
+
}
|
130
|
+
const tokens = filename.split('-')
|
131
|
+
// filename format:
|
132
|
+
// couchbase-v<pkg-version>-<runtime>-v<runtime-version>-<platform>-<arch>-<ssltype>.node
|
133
|
+
if (tokens.length < 7) return false
|
134
|
+
const prebuildSSL = tokens[tokens.length - 1].replace('.node', '')
|
135
|
+
if (runtime === 'electron') {
|
136
|
+
if (prebuildSSL !== 'boringssl') return false
|
137
|
+
} else {
|
138
|
+
if (nodeVersionMajor >= 18 && prebuildSSL !== 'openssl3') return false
|
139
|
+
if (nodeVersionMajor < 18 && prebuildSSL !== 'openssl1') return false
|
140
|
+
}
|
141
|
+
if (tokens[tokens.length - 2] !== arch) return false
|
142
|
+
const platCompare = platform === 'linux' ? libc : platform
|
143
|
+
if (tokens[tokens.length - 3] !== platCompare) return false
|
144
|
+
if (!matchBuild(filename)) return false
|
145
|
+
// yay -- found a match!
|
146
|
+
return true
|
147
|
+
}
|
148
|
+
|
149
|
+
function matchPrebuild(name) {
|
150
|
+
return /\.tar\.gz$/.test(name) || matchBuild(name)
|
151
|
+
}
|
152
|
+
|
153
|
+
function readdirSync(dir) {
|
154
|
+
try {
|
155
|
+
return fs.readdirSync(dir)
|
156
|
+
} catch (err) {
|
157
|
+
return []
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
async function resolveLocalPrebuild(src, dest) {
|
162
|
+
if (fs.existsSync(src)) {
|
163
|
+
const prebuilds = readdirSync(src).filter(matchPrebuild)
|
164
|
+
if (prebuilds && prebuilds.length >= 1) {
|
165
|
+
if (!fs.existsSync(dest)) {
|
166
|
+
fs.mkdirSync(dest, { recursive: true })
|
167
|
+
}
|
168
|
+
const prebuild = prebuilds[0]
|
169
|
+
let prebuildDestName = prebuild
|
170
|
+
if (prebuild.endsWith('.tar.gz')) {
|
171
|
+
const gzip = zlib.createGunzip()
|
172
|
+
const source = fs.createReadStream(src)
|
173
|
+
prebuildDestName = `${prebuild.substring(0, prebuild.length - 7)}.node`
|
174
|
+
const destination = fs.createWriteStream(
|
175
|
+
path.join(src, prebuildDestName)
|
176
|
+
)
|
177
|
+
await pipe(source, gzip, destination)
|
178
|
+
}
|
179
|
+
try {
|
180
|
+
fs.copyFileSync(
|
181
|
+
path.join(src, prebuild),
|
182
|
+
path.join(dest, prebuildDestName)
|
183
|
+
)
|
184
|
+
} catch (_) {}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
function resolvePrebuild(dir, runtimeResolve = true) {
|
190
|
+
dir = path.resolve(dir || '.')
|
191
|
+
try {
|
192
|
+
const localPrebuild = getLocalPrebuild(dir)
|
193
|
+
if (localPrebuild) {
|
194
|
+
return localPrebuild
|
195
|
+
}
|
196
|
+
|
197
|
+
const packageName = runtimeResolve
|
198
|
+
? runtimeRequire(path.join(dir, 'package.json')).name
|
199
|
+
: JSON.parse(fs.readFileSync(path.join(dir, 'package.json'))).name
|
200
|
+
if (packageName !== undefined) {
|
201
|
+
const supportedPackages = getSupportedPlatformPackages(packageName)
|
202
|
+
const platformPkg = `${packageName}-${
|
203
|
+
platform === 'linux' ? libc : platform
|
204
|
+
}-${arch}-${sslType}`
|
205
|
+
if (supportedPackages.includes(platformPkg)) {
|
206
|
+
const fullPlatformPkgName = `@${packageName}/${platformPkg}`
|
207
|
+
const packageRequire = require('module').createRequire(
|
208
|
+
path.join(dir, 'package.json')
|
209
|
+
)
|
210
|
+
const platformPackagesDir = path.dirname(
|
211
|
+
packageRequire.resolve(fullPlatformPkgName)
|
212
|
+
)
|
213
|
+
if (platformPackagesDir !== undefined) {
|
214
|
+
const platformPrebuild = readdirSync(platformPackagesDir).filter(
|
215
|
+
matchingPlatformPrebuild
|
216
|
+
)
|
217
|
+
if (platformPrebuild && platformPrebuild.length == 1) {
|
218
|
+
return path.join(platformPackagesDir, platformPrebuild[0])
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
} catch (_) {}
|
224
|
+
|
225
|
+
let target = [
|
226
|
+
`platform=${platform}`,
|
227
|
+
`arch=${arch}`,
|
228
|
+
`runtime=${runtime}`,
|
229
|
+
`nodeVersion=${nodeVersion}`,
|
230
|
+
`sslType=${sslType}`,
|
231
|
+
]
|
232
|
+
if (libc) {
|
233
|
+
target.push(`libc=${libc}`)
|
234
|
+
}
|
235
|
+
if (typeof __webpack_require__ === 'function') {
|
236
|
+
target.push('webpack=true')
|
237
|
+
}
|
238
|
+
throw new Error(
|
239
|
+
`Could not find native build for ${target.join(', ')} loaded from ${dir}.`
|
240
|
+
)
|
241
|
+
}
|
242
|
+
|
243
|
+
module.exports = {
|
244
|
+
getPrebuildsInfo,
|
245
|
+
getSupportedPlatformPackages,
|
246
|
+
loadPrebuild,
|
247
|
+
resolveLocalPrebuild,
|
248
|
+
resolvePrebuild,
|
249
|
+
}
|
package/scripts/prune.js
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
const fs = require('fs')
|
2
|
+
const path = require('path')
|
3
|
+
const prebuilds = require('./prebuilds')
|
4
|
+
|
5
|
+
function getMismatchedPlatformPackagesInfo(
|
6
|
+
platformPackagesDir,
|
7
|
+
expectedPlatformPackage
|
8
|
+
) {
|
9
|
+
let message = `Checking for platform packages in ${platformPackagesDir} `
|
10
|
+
message += `that do not match the expected platform package (${expectedPlatformPackage}).`
|
11
|
+
console.log(message)
|
12
|
+
let mismatches = []
|
13
|
+
try {
|
14
|
+
const files = fs.readdirSync(platformPackagesDir)
|
15
|
+
files.forEach((file) => {
|
16
|
+
if (file === expectedPlatformPackage) {
|
17
|
+
return
|
18
|
+
}
|
19
|
+
const stats = fs.statSync(path.join(platformPackagesDir, file))
|
20
|
+
if (!stats.isDirectory()) {
|
21
|
+
return
|
22
|
+
}
|
23
|
+
const filePath = path.join(platformPackagesDir, file)
|
24
|
+
const size = getDirectorySize(filePath)
|
25
|
+
console.log(`Found mismatch: Path=${filePath}`)
|
26
|
+
const platformPackage = path.basename(filePath)
|
27
|
+
mismatches.push({
|
28
|
+
name: platformPackage,
|
29
|
+
dir: filePath,
|
30
|
+
size: size,
|
31
|
+
})
|
32
|
+
})
|
33
|
+
} catch (err) {
|
34
|
+
console.error(`Error trying to delete mismatched platform packages.`, err)
|
35
|
+
}
|
36
|
+
return mismatches
|
37
|
+
}
|
38
|
+
|
39
|
+
function getDirectorySize(dir) {
|
40
|
+
let size = 0
|
41
|
+
const dirContents = fs.readdirSync(dir)
|
42
|
+
dirContents.forEach((content) => {
|
43
|
+
const contentPath = path.join(dir, content)
|
44
|
+
const stats = fs.statSync(contentPath)
|
45
|
+
if (stats.isFile()) {
|
46
|
+
size += stats.size
|
47
|
+
} else if (stats.isDirectory()) {
|
48
|
+
size += getDirectorySize(contentPath)
|
49
|
+
}
|
50
|
+
})
|
51
|
+
|
52
|
+
return size
|
53
|
+
}
|
54
|
+
|
55
|
+
function getPrebuildsInfo() {
|
56
|
+
try {
|
57
|
+
const prebuildsInfo = prebuilds.getPrebuildsInfo()
|
58
|
+
return prebuildsInfo
|
59
|
+
} catch (err) {
|
60
|
+
console.error('Error trying to obtain couchbase prebuilds info.', err)
|
61
|
+
return undefined
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function pruneCouchbaseHelp() {
|
66
|
+
const prebuildsInfo = getPrebuildsInfo()
|
67
|
+
const platformPackagesDir = path.dirname(prebuildsInfo.platformPackageDir)
|
68
|
+
const expectedPlatformPackage = path.basename(
|
69
|
+
prebuildsInfo.platformPackageDir
|
70
|
+
)
|
71
|
+
|
72
|
+
const mismatchedPlatPkgs = getMismatchedPlatformPackagesInfo(
|
73
|
+
platformPackagesDir,
|
74
|
+
expectedPlatformPackage
|
75
|
+
)
|
76
|
+
const cbDeps = {
|
77
|
+
dir: path.join(prebuildsInfo.packageDir, 'deps'),
|
78
|
+
size: undefined,
|
79
|
+
}
|
80
|
+
const cbSrc = {
|
81
|
+
dir: path.join(prebuildsInfo.packageDir, 'src'),
|
82
|
+
size: undefined,
|
83
|
+
}
|
84
|
+
try {
|
85
|
+
cbDeps.size = getDirectorySize(cbDeps.dir)
|
86
|
+
} catch (_) {
|
87
|
+
console.log('Couchbase deps/ not found.')
|
88
|
+
}
|
89
|
+
try {
|
90
|
+
cbSrc.size = getDirectorySize(cbSrc.dir)
|
91
|
+
} catch (_) {
|
92
|
+
console.log('Couchbase src/ not found.')
|
93
|
+
}
|
94
|
+
|
95
|
+
console.log('\nRecommendations for pruning:\n')
|
96
|
+
if (mismatchedPlatPkgs.length > 0) {
|
97
|
+
for (const pkg of mismatchedPlatPkgs) {
|
98
|
+
const sizeMb = pkg.size / 1024 / 1024
|
99
|
+
console.log(
|
100
|
+
`Removing mismatched platform=${pkg.name} (path=${
|
101
|
+
pkg.dir
|
102
|
+
}) saves ~${sizeMb.toFixed(2)} MB on disk.`
|
103
|
+
)
|
104
|
+
}
|
105
|
+
}
|
106
|
+
if (cbDeps.size) {
|
107
|
+
const sizeMb = cbDeps.size / 1024 / 1024
|
108
|
+
console.log(
|
109
|
+
`Removing Couchbase deps/ (path=${cbDeps.dir}) saves ~${sizeMb.toFixed(
|
110
|
+
2
|
111
|
+
)} MB on disk.`
|
112
|
+
)
|
113
|
+
}
|
114
|
+
if (cbSrc.size) {
|
115
|
+
const sizeMb = cbSrc.size / 1024 / 1024
|
116
|
+
console.log(
|
117
|
+
`Removing Couchbase src/ (path=${cbSrc.dir}) saves ~${sizeMb.toFixed(
|
118
|
+
2
|
119
|
+
)} MB on disk.`
|
120
|
+
)
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
pruneCouchbaseHelp()
|
package/src/jstocbpp_autogen.hpp
CHANGED
@@ -3723,7 +3723,7 @@ struct js_to_cbpp_t<couchbase::core::operations::search_request> {
|
|
3723
3723
|
jsObj.Get("limit"));
|
3724
3724
|
js_to_cbpp<std::optional<std::uint32_t>>(cppObj.skip,
|
3725
3725
|
jsObj.Get("skip"));
|
3726
|
-
js_to_cbpp<bool
|
3726
|
+
js_to_cbpp<std::optional<bool>>(cppObj.explain, jsObj.Get("explain"));
|
3727
3727
|
js_to_cbpp<bool>(cppObj.disable_scoring, jsObj.Get("disable_scoring"));
|
3728
3728
|
js_to_cbpp<bool>(cppObj.include_locations,
|
3729
3729
|
jsObj.Get("include_locations"));
|
@@ -3767,7 +3767,8 @@ struct js_to_cbpp_t<couchbase::core::operations::search_request> {
|
|
3767
3767
|
cbpp_to_js<std::optional<std::uint32_t>>(env, cppObj.limit));
|
3768
3768
|
resObj.Set("skip",
|
3769
3769
|
cbpp_to_js<std::optional<std::uint32_t>>(env, cppObj.skip));
|
3770
|
-
resObj.Set("explain",
|
3770
|
+
resObj.Set("explain",
|
3771
|
+
cbpp_to_js<std::optional<bool>>(env, cppObj.explain));
|
3771
3772
|
resObj.Set("disable_scoring",
|
3772
3773
|
cbpp_to_js<bool>(env, cppObj.disable_scoring));
|
3773
3774
|
resObj.Set("include_locations",
|