@opensearch-project/opensearch 1.1.0 → 2.1.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/.eslintignore +2 -0
- package/.eslintrc.json +31 -0
- package/.prettierrc.json +5 -0
- package/.whitesource +15 -0
- package/ADMINS.md +13 -31
- package/CHANGELOG.md +24 -0
- package/COMPATIBILITY.md +27 -0
- package/DEVELOPER_GUIDE.md +22 -5
- package/MAINTAINERS.md +15 -70
- package/Makefile +2 -12
- package/README.md +19 -123
- package/RELEASING.md +3 -3
- package/SECURITY.md +1 -1
- package/USER_GUIDE.md +197 -0
- package/api/api/bulk.js +54 -28
- package/api/api/cat.js +355 -266
- package/api/api/clear_scroll.js +18 -19
- package/api/api/cluster.js +367 -221
- package/api/api/count.js +56 -26
- package/api/api/create.js +51 -26
- package/api/api/dangling_indices.js +96 -53
- package/api/api/delete.js +50 -24
- package/api/api/delete_by_query.js +89 -27
- package/api/api/delete_by_query_rethrottle.js +34 -21
- package/api/api/delete_script.js +32 -19
- package/api/api/exists.js +56 -24
- package/api/api/exists_source.js +61 -29
- package/api/api/explain.js +61 -24
- package/api/api/features.js +57 -37
- package/api/api/field_caps.js +37 -20
- package/api/api/get.js +56 -24
- package/api/api/get_script.js +31 -19
- package/api/api/get_script_context.js +16 -17
- package/api/api/get_script_languages.js +16 -17
- package/api/api/get_source.js +56 -24
- package/api/api/index.js +61 -30
- package/api/api/indices.js +1069 -859
- package/api/api/info.js +16 -17
- package/api/api/ingest.js +133 -98
- package/api/api/mget.js +51 -28
- package/api/api/msearch.js +50 -28
- package/api/api/msearch_template.js +54 -28
- package/api/api/mtermvectors.js +49 -26
- package/api/api/nodes.js +282 -156
- package/api/api/ping.js +16 -17
- package/api/api/put_script.js +41 -27
- package/api/api/rank_eval.js +38 -22
- package/api/api/reindex.js +39 -19
- package/api/api/reindex_rethrottle.js +33 -21
- package/api/api/render_search_template.js +19 -20
- package/api/api/scripts_painless_execute.js +16 -17
- package/api/api/scroll.js +32 -19
- package/api/api/search.js +109 -26
- package/api/api/search_shards.js +37 -20
- package/api/api/search_template.js +65 -28
- package/api/api/shutdown.js +67 -56
- package/api/api/snapshot.js +348 -226
- package/api/api/tasks.js +66 -48
- package/api/api/terms_enum.js +18 -19
- package/api/api/termvectors.js +58 -28
- package/api/api/update.js +65 -26
- package/api/api/update_by_query.js +90 -25
- package/api/api/update_by_query_rethrottle.js +34 -21
- package/api/index.js +268 -181
- package/api/new.d.ts +2043 -531
- package/api/opensearch_dashboards.d.ts +240 -238
- package/api/requestParams.d.ts +302 -71
- package/api/types.d.ts +6205 -5721
- package/api/utils.js +23 -24
- package/codecov.yml +2 -2
- package/index.d.ts +5203 -1037
- package/index.js +154 -143
- package/index.mjs +10 -11
- package/jenkins/release.JenkinsFile +11 -0
- package/lib/Connection.d.ts +38 -28
- package/lib/Connection.js +166 -170
- package/lib/Helpers.d.ts +108 -68
- package/lib/Helpers.js +401 -378
- package/lib/Serializer.d.ts +3 -4
- package/lib/Serializer.js +40 -41
- package/lib/Transport.d.ts +39 -15
- package/lib/Transport.js +381 -337
- package/lib/aws/AwsSigv4Signer.js +167 -0
- package/lib/aws/errors.js +24 -0
- package/lib/aws/index.d.ts +39 -0
- package/lib/aws/index.js +19 -0
- package/lib/errors.d.ts +26 -9
- package/lib/errors.js +76 -73
- package/lib/pool/BaseConnectionPool.js +101 -99
- package/lib/pool/CloudConnectionPool.js +17 -18
- package/lib/pool/ConnectionPool.js +106 -107
- package/lib/pool/index.d.ts +9 -8
- package/lib/pool/index.js +7 -8
- package/package.json +37 -15
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
const Connection = require('../Connection');
|
|
13
|
+
const Transport = require('../Transport');
|
|
14
|
+
const aws4 = require('aws4');
|
|
15
|
+
const AwsSigv4SignerError = require('./errors');
|
|
16
|
+
|
|
17
|
+
const getAwsSDKCredentialsProvider = async () => {
|
|
18
|
+
// First try V3
|
|
19
|
+
try {
|
|
20
|
+
const awsV3 = await import('@aws-sdk/credential-provider-node');
|
|
21
|
+
if (typeof awsV3.defaultProvider === 'function') {
|
|
22
|
+
return awsV3.defaultProvider();
|
|
23
|
+
}
|
|
24
|
+
} catch (err) {
|
|
25
|
+
// Ignore
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const awsV2 = await import('aws-sdk');
|
|
29
|
+
if (awsV2.default && typeof awsV2.default.config.getCredentials === 'function') {
|
|
30
|
+
return () =>
|
|
31
|
+
new Promise((resolve, reject) => {
|
|
32
|
+
awsV2.default.config.getCredentials((err, credentials) => {
|
|
33
|
+
if (err) {
|
|
34
|
+
reject(err);
|
|
35
|
+
} else {
|
|
36
|
+
resolve(credentials);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// Ignore
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new AwsSigv4SignerError(
|
|
46
|
+
'Unable to find a valid AWS SDK, please provide a valid getCredentials function to AwsSigv4Signer options.'
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const awsDefaultCredentialsProvider = () =>
|
|
51
|
+
new Promise((resolve, reject) => {
|
|
52
|
+
getAwsSDKCredentialsProvider()
|
|
53
|
+
.then((provider) => {
|
|
54
|
+
provider().then(resolve).catch(reject);
|
|
55
|
+
})
|
|
56
|
+
.catch((err) => {
|
|
57
|
+
reject(err);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function AwsSigv4Signer(opts) {
|
|
62
|
+
const credentialsState = {
|
|
63
|
+
credentials: null,
|
|
64
|
+
};
|
|
65
|
+
if (opts && (!opts.region || opts.region === null || opts.region === '')) {
|
|
66
|
+
throw new AwsSigv4SignerError('Region cannot be empty');
|
|
67
|
+
}
|
|
68
|
+
if (opts && typeof opts.getCredentials !== 'function') {
|
|
69
|
+
opts.getCredentials = awsDefaultCredentialsProvider;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function buildSignedRequestObject(request = {}) {
|
|
73
|
+
request.service = 'es';
|
|
74
|
+
request.region = opts.region;
|
|
75
|
+
request.headers = request.headers || {};
|
|
76
|
+
request.headers['host'] = request.hostname;
|
|
77
|
+
return aws4.sign(request, credentialsState.credentials);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
class AwsSigv4SignerConnection extends Connection {
|
|
81
|
+
buildRequestObject(params) {
|
|
82
|
+
const request = super.buildRequestObject(params);
|
|
83
|
+
return buildSignedRequestObject(request);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
class AwsSigv4SignerTransport extends Transport {
|
|
88
|
+
request(params, options = {}, callback = undefined) {
|
|
89
|
+
// options is optional so if options is a function, it's the callback.
|
|
90
|
+
if (typeof options === 'function') {
|
|
91
|
+
callback = options;
|
|
92
|
+
options = {};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const currentCredentials = credentialsState.credentials;
|
|
96
|
+
let expired = false;
|
|
97
|
+
if (!currentCredentials) {
|
|
98
|
+
// Credentials haven't been acquired yet.
|
|
99
|
+
expired = true;
|
|
100
|
+
}
|
|
101
|
+
// AWS SDK V2, needsRefresh should be available.
|
|
102
|
+
else if (typeof currentCredentials.needsRefresh === 'function') {
|
|
103
|
+
expired = currentCredentials.needsRefresh();
|
|
104
|
+
}
|
|
105
|
+
// AWS SDK V2, alternative to needsRefresh.
|
|
106
|
+
else if (currentCredentials.expired === true) {
|
|
107
|
+
expired = true;
|
|
108
|
+
}
|
|
109
|
+
// AWS SDK V2, alternative to needsRefresh and expired.
|
|
110
|
+
else if (currentCredentials.expireTime && currentCredentials.expireTime < new Date()) {
|
|
111
|
+
expired = true;
|
|
112
|
+
}
|
|
113
|
+
// AWS SDK V3, Credentials.expiration is a Date object
|
|
114
|
+
else if (currentCredentials.expiration && currentCredentials.expiration < new Date()) {
|
|
115
|
+
expired = true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!expired) {
|
|
119
|
+
if (typeof callback === 'undefined') {
|
|
120
|
+
return super.request(params, options);
|
|
121
|
+
}
|
|
122
|
+
super.request(params, options, callback);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// In AWS SDK V2 Credentials.refreshPromise should be available.
|
|
127
|
+
if (currentCredentials && typeof currentCredentials.refreshPromise === 'function') {
|
|
128
|
+
if (typeof callback === 'undefined') {
|
|
129
|
+
return currentCredentials.refreshPromise().then(() => {
|
|
130
|
+
return super.request(params, options);
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
currentCredentials
|
|
134
|
+
.refreshPromise()
|
|
135
|
+
.then(() => {
|
|
136
|
+
super.request(params, options, callback);
|
|
137
|
+
})
|
|
138
|
+
.catch(callback);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// For AWS SDK V3 or when the client has not acquired credentials yet.
|
|
144
|
+
if (typeof callback === 'undefined') {
|
|
145
|
+
return opts.getCredentials().then((credentials) => {
|
|
146
|
+
credentialsState.credentials = credentials;
|
|
147
|
+
return super.request(params, options);
|
|
148
|
+
});
|
|
149
|
+
} else {
|
|
150
|
+
opts
|
|
151
|
+
.getCredentials()
|
|
152
|
+
.then((credentials) => {
|
|
153
|
+
credentialsState.credentials = credentials;
|
|
154
|
+
super.request(params, options, callback);
|
|
155
|
+
})
|
|
156
|
+
.catch(callback);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
Transport: AwsSigv4SignerTransport,
|
|
163
|
+
Connection: AwsSigv4SignerConnection,
|
|
164
|
+
buildSignedRequestObject,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
module.exports = AwsSigv4Signer;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
const { OpenSearchClientError } = require('../errors');
|
|
13
|
+
|
|
14
|
+
class AwsSigv4SignerError extends OpenSearchClientError {
|
|
15
|
+
constructor(message, data) {
|
|
16
|
+
super(message, data);
|
|
17
|
+
Error.captureStackTrace(this, AwsSigv4SignerError);
|
|
18
|
+
this.name = 'AwsSigv4SignerError';
|
|
19
|
+
this.message = message || 'AwsSigv4Signer Error';
|
|
20
|
+
this.data = data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = AwsSigv4SignerError;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/// <reference types="node" />
|
|
12
|
+
|
|
13
|
+
import { Credentials } from '@aws-sdk/types';
|
|
14
|
+
import Connection from '../Connection';
|
|
15
|
+
import Transport from '../Transport';
|
|
16
|
+
import * as http from 'http';
|
|
17
|
+
import { OpenSearchClientError } from '../errors';
|
|
18
|
+
|
|
19
|
+
interface AwsSigv4SignerOptions {
|
|
20
|
+
getCredentials?: () => Promise<Credentials>;
|
|
21
|
+
region: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface AwsSigv4SignerResponse {
|
|
25
|
+
Connection: typeof Connection;
|
|
26
|
+
Transport: typeof Transport;
|
|
27
|
+
buildSignedRequestObject(request: any): http.ClientRequestArgs;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare function AwsSigv4Signer (opts: AwsSigv4SignerOptions): AwsSigv4SignerResponse;
|
|
31
|
+
|
|
32
|
+
declare class AwsSigv4SignerError extends OpenSearchClientError {
|
|
33
|
+
name: string;
|
|
34
|
+
message: string;
|
|
35
|
+
data: any;
|
|
36
|
+
constructor(message: string, data: any);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { AwsSigv4Signer, AwsSigv4SignerOptions, AwsSigv4SignerResponse, AwsSigv4SignerError };
|
package/lib/aws/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const AwsSigv4Signer = require('./AwsSigv4Signer');
|
|
14
|
+
const AwsSigv4SignerError = require('./errors');
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
AwsSigv4Signer,
|
|
18
|
+
AwsSigv4SignerError,
|
|
19
|
+
};
|
package/lib/errors.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,28 +27,37 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
import { ApiResponse, Context } from './Transport'
|
|
30
|
+
import { ApiResponse, Context } from './Transport';
|
|
32
31
|
|
|
33
32
|
export declare class OpenSearchClientError extends Error {
|
|
34
33
|
name: string;
|
|
35
34
|
message: string;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
export declare class TimeoutError<
|
|
37
|
+
export declare class TimeoutError<
|
|
38
|
+
TResponse = Record<string, any>,
|
|
39
|
+
TContext = Context
|
|
40
|
+
> extends OpenSearchClientError {
|
|
39
41
|
name: string;
|
|
40
42
|
message: string;
|
|
41
43
|
meta: ApiResponse<TResponse, TContext>;
|
|
42
44
|
constructor(message: string, meta: ApiResponse);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
export declare class ConnectionError<
|
|
47
|
+
export declare class ConnectionError<
|
|
48
|
+
TResponse = Record<string, any>,
|
|
49
|
+
TContext = Context
|
|
50
|
+
> extends OpenSearchClientError {
|
|
46
51
|
name: string;
|
|
47
52
|
message: string;
|
|
48
53
|
meta: ApiResponse<TResponse, TContext>;
|
|
49
54
|
constructor(message: string, meta: ApiResponse);
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
export declare class NoLivingConnectionsError<
|
|
57
|
+
export declare class NoLivingConnectionsError<
|
|
58
|
+
TResponse = Record<string, any>,
|
|
59
|
+
TContext = Context
|
|
60
|
+
> extends OpenSearchClientError {
|
|
53
61
|
name: string;
|
|
54
62
|
message: string;
|
|
55
63
|
meta: ApiResponse<TResponse, TContext>;
|
|
@@ -76,7 +84,10 @@ export declare class ConfigurationError extends OpenSearchClientError {
|
|
|
76
84
|
constructor(message: string);
|
|
77
85
|
}
|
|
78
86
|
|
|
79
|
-
export declare class ResponseError<
|
|
87
|
+
export declare class ResponseError<
|
|
88
|
+
TResponse = Record<string, any>,
|
|
89
|
+
TContext = Context
|
|
90
|
+
> extends OpenSearchClientError {
|
|
80
91
|
name: string;
|
|
81
92
|
message: string;
|
|
82
93
|
meta: ApiResponse<TResponse, TContext>;
|
|
@@ -86,14 +97,20 @@ export declare class ResponseError<TResponse = Record<string, any>, TContext = C
|
|
|
86
97
|
constructor(meta: ApiResponse);
|
|
87
98
|
}
|
|
88
99
|
|
|
89
|
-
export declare class RequestAbortedError<
|
|
100
|
+
export declare class RequestAbortedError<
|
|
101
|
+
TResponse = Record<string, any>,
|
|
102
|
+
TContext = Context
|
|
103
|
+
> extends OpenSearchClientError {
|
|
90
104
|
name: string;
|
|
91
105
|
message: string;
|
|
92
106
|
meta: ApiResponse<TResponse, TContext>;
|
|
93
107
|
constructor(message: string, meta: ApiResponse);
|
|
94
108
|
}
|
|
95
109
|
|
|
96
|
-
export declare class NotCompatibleError<
|
|
110
|
+
export declare class NotCompatibleError<
|
|
111
|
+
TResponse = Record<string, any>,
|
|
112
|
+
TContext = Context
|
|
113
|
+
> extends OpenSearchClientError {
|
|
97
114
|
name: string;
|
|
98
115
|
message: string;
|
|
99
116
|
meta: ApiResponse<TResponse, TContext>;
|
package/lib/errors.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,129 +27,133 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
32
|
class OpenSearchClientError extends Error {
|
|
34
|
-
constructor
|
|
35
|
-
super(message)
|
|
36
|
-
this.name = 'OpenSearchClientError'
|
|
33
|
+
constructor(message) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.name = 'OpenSearchClientError';
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
class TimeoutError extends OpenSearchClientError {
|
|
41
|
-
constructor
|
|
42
|
-
super(message)
|
|
43
|
-
Error.captureStackTrace(this, TimeoutError)
|
|
44
|
-
this.name = 'TimeoutError'
|
|
45
|
-
this.message = message || 'Timeout Error'
|
|
46
|
-
this.meta = meta
|
|
40
|
+
constructor(message, meta) {
|
|
41
|
+
super(message);
|
|
42
|
+
Error.captureStackTrace(this, TimeoutError);
|
|
43
|
+
this.name = 'TimeoutError';
|
|
44
|
+
this.message = message || 'Timeout Error';
|
|
45
|
+
this.meta = meta;
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
class ConnectionError extends OpenSearchClientError {
|
|
51
|
-
constructor
|
|
52
|
-
super(message)
|
|
53
|
-
Error.captureStackTrace(this, ConnectionError)
|
|
54
|
-
this.name = 'ConnectionError'
|
|
55
|
-
this.message = message || 'Connection Error'
|
|
56
|
-
this.meta = meta
|
|
50
|
+
constructor(message, meta) {
|
|
51
|
+
super(message);
|
|
52
|
+
Error.captureStackTrace(this, ConnectionError);
|
|
53
|
+
this.name = 'ConnectionError';
|
|
54
|
+
this.message = message || 'Connection Error';
|
|
55
|
+
this.meta = meta;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
class NoLivingConnectionsError extends OpenSearchClientError {
|
|
61
|
-
constructor
|
|
62
|
-
super(message)
|
|
63
|
-
Error.captureStackTrace(this, NoLivingConnectionsError)
|
|
64
|
-
this.name = 'NoLivingConnectionsError'
|
|
65
|
-
this.message =
|
|
66
|
-
|
|
60
|
+
constructor(message, meta) {
|
|
61
|
+
super(message);
|
|
62
|
+
Error.captureStackTrace(this, NoLivingConnectionsError);
|
|
63
|
+
this.name = 'NoLivingConnectionsError';
|
|
64
|
+
this.message =
|
|
65
|
+
message ||
|
|
66
|
+
'Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.';
|
|
67
|
+
this.meta = meta;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
class SerializationError extends OpenSearchClientError {
|
|
71
|
-
constructor
|
|
72
|
-
super(message, data)
|
|
73
|
-
Error.captureStackTrace(this, SerializationError)
|
|
74
|
-
this.name = 'SerializationError'
|
|
75
|
-
this.message = message || 'Serialization Error'
|
|
76
|
-
this.data = data
|
|
72
|
+
constructor(message, data) {
|
|
73
|
+
super(message, data);
|
|
74
|
+
Error.captureStackTrace(this, SerializationError);
|
|
75
|
+
this.name = 'SerializationError';
|
|
76
|
+
this.message = message || 'Serialization Error';
|
|
77
|
+
this.data = data;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
class DeserializationError extends OpenSearchClientError {
|
|
81
|
-
constructor
|
|
82
|
-
super(message, data)
|
|
83
|
-
Error.captureStackTrace(this, DeserializationError)
|
|
84
|
-
this.name = 'DeserializationError'
|
|
85
|
-
this.message = message || 'Deserialization Error'
|
|
86
|
-
this.data = data
|
|
82
|
+
constructor(message, data) {
|
|
83
|
+
super(message, data);
|
|
84
|
+
Error.captureStackTrace(this, DeserializationError);
|
|
85
|
+
this.name = 'DeserializationError';
|
|
86
|
+
this.message = message || 'Deserialization Error';
|
|
87
|
+
this.data = data;
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
class ConfigurationError extends OpenSearchClientError {
|
|
91
|
-
constructor
|
|
92
|
-
super(message)
|
|
93
|
-
Error.captureStackTrace(this, ConfigurationError)
|
|
94
|
-
this.name = 'ConfigurationError'
|
|
95
|
-
this.message = message || 'Configuration Error'
|
|
92
|
+
constructor(message) {
|
|
93
|
+
super(message);
|
|
94
|
+
Error.captureStackTrace(this, ConfigurationError);
|
|
95
|
+
this.name = 'ConfigurationError';
|
|
96
|
+
this.message = message || 'Configuration Error';
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
class ResponseError extends OpenSearchClientError {
|
|
100
|
-
constructor
|
|
101
|
-
super('Response Error')
|
|
102
|
-
Error.captureStackTrace(this, ResponseError)
|
|
103
|
-
this.name = 'ResponseError'
|
|
101
|
+
constructor(meta) {
|
|
102
|
+
super('Response Error');
|
|
103
|
+
Error.captureStackTrace(this, ResponseError);
|
|
104
|
+
this.name = 'ResponseError';
|
|
104
105
|
if (meta.body && meta.body.error && meta.body.error.type) {
|
|
105
106
|
if (Array.isArray(meta.body.error.root_cause)) {
|
|
106
|
-
this.message = meta.body.error.type + ': '
|
|
107
|
-
this.message += meta.body.error.root_cause
|
|
107
|
+
this.message = meta.body.error.type + ': ';
|
|
108
|
+
this.message += meta.body.error.root_cause
|
|
109
|
+
.map((entry) => `[${entry.type}] Reason: ${entry.reason}`)
|
|
110
|
+
.join('; ');
|
|
108
111
|
} else {
|
|
109
|
-
this.message = meta.body.error.type
|
|
112
|
+
this.message = meta.body.error.type;
|
|
110
113
|
}
|
|
111
114
|
} else {
|
|
112
|
-
this.message = 'Response Error'
|
|
115
|
+
this.message = 'Response Error';
|
|
113
116
|
}
|
|
114
|
-
this.meta = meta
|
|
117
|
+
this.meta = meta;
|
|
115
118
|
}
|
|
116
119
|
|
|
117
|
-
get body
|
|
118
|
-
return this.meta.body
|
|
120
|
+
get body() {
|
|
121
|
+
return this.meta.body;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
get statusCode
|
|
124
|
+
get statusCode() {
|
|
122
125
|
if (this.meta.body && typeof this.meta.body.status === 'number') {
|
|
123
|
-
return this.meta.body.status
|
|
126
|
+
return this.meta.body.status;
|
|
124
127
|
}
|
|
125
|
-
return this.meta.statusCode
|
|
128
|
+
return this.meta.statusCode;
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
get headers
|
|
129
|
-
return this.meta.headers
|
|
131
|
+
get headers() {
|
|
132
|
+
return this.meta.headers;
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
toString
|
|
133
|
-
return JSON.stringify(this.meta.body)
|
|
135
|
+
toString() {
|
|
136
|
+
return JSON.stringify(this.meta.body);
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
class RequestAbortedError extends OpenSearchClientError {
|
|
138
|
-
constructor
|
|
139
|
-
super(message)
|
|
140
|
-
Error.captureStackTrace(this, RequestAbortedError)
|
|
141
|
-
this.name = 'RequestAbortedError'
|
|
142
|
-
this.message = message || 'Request aborted'
|
|
143
|
-
this.meta = meta
|
|
141
|
+
constructor(message, meta) {
|
|
142
|
+
super(message);
|
|
143
|
+
Error.captureStackTrace(this, RequestAbortedError);
|
|
144
|
+
this.name = 'RequestAbortedError';
|
|
145
|
+
this.message = message || 'Request aborted';
|
|
146
|
+
this.meta = meta;
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
class NotCompatibleError extends OpenSearchClientError {
|
|
148
|
-
constructor
|
|
149
|
-
super('Not Compatible Error')
|
|
150
|
-
Error.captureStackTrace(this, NotCompatibleError)
|
|
151
|
-
this.name = 'NotCompatibleError'
|
|
152
|
-
this.message = 'The client noticed that the server is not a supported distribution'
|
|
153
|
-
this.meta = meta
|
|
151
|
+
constructor(meta) {
|
|
152
|
+
super('Not Compatible Error');
|
|
153
|
+
Error.captureStackTrace(this, NotCompatibleError);
|
|
154
|
+
this.name = 'NotCompatibleError';
|
|
155
|
+
this.message = 'The client noticed that the server is not a supported distribution';
|
|
156
|
+
this.meta = meta;
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -164,5 +167,5 @@ module.exports = {
|
|
|
164
167
|
ConfigurationError,
|
|
165
168
|
ResponseError,
|
|
166
169
|
RequestAbortedError,
|
|
167
|
-
NotCompatibleError
|
|
168
|
-
}
|
|
170
|
+
NotCompatibleError,
|
|
171
|
+
};
|