@cubejs-backend/elasticsearch-driver 0.30.73 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/driver/ElasticSearchDriver.js +33 -14
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.31.0](https://github.com/cube-js/cube.js/compare/v0.30.75...v0.31.0) (2022-10-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* multiple data source ([#5326](https://github.com/cube-js/cube.js/issues/5326)) ([334af8c](https://github.com/cube-js/cube.js/commit/334af8c56cd02ae551844e9d1e9ab5e107fb1555))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.30.73](https://github.com/cube-js/cube.js/compare/v0.30.72...v0.30.73) (2022-09-19)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @cubejs-backend/elasticsearch-driver
|
|
@@ -1,41 +1,58 @@
|
|
|
1
1
|
const { Client } = require('@elastic/elasticsearch');
|
|
2
2
|
const SqlString = require('sqlstring');
|
|
3
|
+
const { getEnv, assertDataSource } = require('@cubejs-backend/shared');
|
|
3
4
|
const { BaseDriver } = require('@cubejs-backend/base-driver');
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* ElasticSearch driver class.
|
|
8
|
+
*/
|
|
5
9
|
class ElasticSearchDriver extends BaseDriver {
|
|
6
10
|
/**
|
|
7
11
|
* Returns default concurrency value.
|
|
12
|
+
* @return {number}
|
|
8
13
|
*/
|
|
9
14
|
static getDefaultConcurrency() {
|
|
10
15
|
return 2;
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Class constructor.
|
|
20
|
+
*/
|
|
13
21
|
constructor(config = {}) {
|
|
14
22
|
super();
|
|
15
23
|
|
|
24
|
+
const dataSource =
|
|
25
|
+
config.dataSource ||
|
|
26
|
+
assertDataSource('default');
|
|
27
|
+
|
|
16
28
|
const auth = {
|
|
17
|
-
username:
|
|
18
|
-
password:
|
|
29
|
+
username: getEnv('dbUser', { dataSource }),
|
|
30
|
+
password: getEnv('dbPass', { dataSource }),
|
|
19
31
|
};
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
if (
|
|
33
|
+
getEnv('elasticApiId', { dataSource }) ||
|
|
34
|
+
getEnv('elasticApiKey', { dataSource })
|
|
35
|
+
) {
|
|
22
36
|
auth.apiKey = {
|
|
23
|
-
id:
|
|
24
|
-
api_key:
|
|
37
|
+
id: getEnv('elasticApiId', { dataSource }),
|
|
38
|
+
api_key: getEnv('elasticApiKey', { dataSource }),
|
|
25
39
|
};
|
|
26
40
|
}
|
|
27
41
|
|
|
28
|
-
// TODO: This config applies to AWS ES, Elastic.co ES, Native ES
|
|
29
|
-
// They have different dialects according to
|
|
42
|
+
// TODO: This config applies to AWS ES, Elastic.co ES, Native ES
|
|
43
|
+
// and OpenDistro ES. They have different dialects according to
|
|
44
|
+
// their respective documentation.
|
|
30
45
|
this.config = {
|
|
31
|
-
url: process.env.CUBEJS_DB_URL,
|
|
32
|
-
ssl: this.getSslOptions(),
|
|
33
46
|
auth,
|
|
47
|
+
url: getEnv('dbUrl', { dataSource }),
|
|
48
|
+
ssl: this.getSslOptions(dataSource),
|
|
34
49
|
openDistro:
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
(getEnv('elasticOpenDistro', { dataSource }) || 'false')
|
|
51
|
+
.toLowerCase() === 'true' ||
|
|
52
|
+
getEnv('dbType', { dataSource }) === 'odelasticsearch',
|
|
53
|
+
queryFormat:
|
|
54
|
+
getEnv('elasticQueryFormat', { dataSource }) || 'jdbc',
|
|
55
|
+
...config,
|
|
39
56
|
};
|
|
40
57
|
|
|
41
58
|
this.client = new Client({
|
|
@@ -57,6 +74,8 @@ class ElasticSearchDriver extends BaseDriver {
|
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
static driverEnvVariables() {
|
|
77
|
+
// TODO (buntarb): check how this method can/must be used with split
|
|
78
|
+
// names by the data source.
|
|
60
79
|
return [
|
|
61
80
|
'CUBEJS_DB_URL',
|
|
62
81
|
'CUBEJS_DB_ELASTIC_QUERY_FORMAT',
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@cubejs-backend/elasticsearch-driver",
|
|
3
3
|
"description": "Cube.js elasticsearch database driver",
|
|
4
4
|
"author": "Cube Dev, Inc.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.31.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/cube-js/cube.js.git",
|
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
"driver"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@cubejs-backend/base-driver": "^0.
|
|
26
|
+
"@cubejs-backend/base-driver": "^0.31.0",
|
|
27
|
+
"@cubejs-backend/shared": "^0.31.0",
|
|
27
28
|
"@elastic/elasticsearch": "7.12.0",
|
|
28
29
|
"sqlstring": "^2.3.1"
|
|
29
30
|
},
|
|
30
31
|
"license": "Apache-2.0",
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@cubejs-backend/linter": "^0.
|
|
33
|
+
"@cubejs-backend/linter": "^0.31.0",
|
|
33
34
|
"@types/jest": "^26.0.20",
|
|
34
35
|
"jest": "^26.6.3",
|
|
35
36
|
"testcontainers": "^8.12"
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"**/?(*.)+(spec|test|integration).js?(x)"
|
|
48
49
|
]
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "8cdec759f298fb20c48194254ccc04b6fdad46bf"
|
|
51
52
|
}
|