@terascope/elasticsearch-api 3.20.3 → 4.0.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/.eslintrc.json +14 -0
- package/README.md +1 -1
- package/index.js +8 -10
- package/jest.config.js +19 -2
- package/package.json +5 -4
- package/test/api-spec.js +11 -12
- package/test/bulk-send-dlq-spec.js +4 -9
- package/test/bulk-send-limit-spec.js +4 -9
- package/test/retry-spec.js +4 -6
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@terascope",
|
|
3
|
+
"parserOptions": {
|
|
4
|
+
"ecmaVersion": "latest",
|
|
5
|
+
"sourceType": "module"
|
|
6
|
+
},
|
|
7
|
+
"rules": {
|
|
8
|
+
"@typescript-eslint/naming-convention": "off",
|
|
9
|
+
"@typescript-eslint/no-duplicate-enum-values": "warn",
|
|
10
|
+
"import/extensions": "off",
|
|
11
|
+
"import/no-import-module-exports": "off"
|
|
12
|
+
},
|
|
13
|
+
"ignorePatterns":[]
|
|
14
|
+
}
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> Elasticsearch client api used across multiple services, handles retries and exponential backoff
|
|
6
6
|
|
|
7
|
-
This a package within the [Teraslice](https://github.com/terascope/teraslice) monorepo. See our [documentation](https://terascope.github.io/teraslice/docs/packages/elasticsearch-api/overview) for more information or the [issues](https://github.com/terascope/teraslice/issues?q=is%3Aopen+is%3Aissue+label%3Apkg%2Felasticsearch-api) associated with this package
|
|
7
|
+
This is a package within the [Teraslice](https://github.com/terascope/teraslice) monorepo. See our [documentation](https://terascope.github.io/teraslice/docs/packages/elasticsearch-api/overview) for more information or the [issues](https://github.com/terascope/teraslice/issues?q=is%3Aopen+is%3Aissue+label%3Apkg%2Felasticsearch-api) associated with this package
|
|
8
8
|
|
|
9
9
|
## Contributing
|
|
10
10
|
|
package/index.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
3
|
// polyfill because opensearch has references to an api that won't exist
|
|
6
4
|
// on the client side, should be able to remove in the future
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const Promise = require('bluebird');
|
|
10
|
-
const {
|
|
5
|
+
import Promise from 'bluebird';
|
|
6
|
+
import {
|
|
11
7
|
isTest, TSError, isFatalError,
|
|
12
8
|
parseError, getBackoffDelay, isRetryableError,
|
|
13
9
|
get, toNumber, isString, isSimpleObject,
|
|
14
10
|
castArray, flatten, toBoolean,
|
|
15
11
|
uniq, random, cloneDeep, DataEntity,
|
|
16
12
|
isDeepEqual, getTypeOf, isProd
|
|
17
|
-
}
|
|
18
|
-
|
|
13
|
+
} from '@terascope/utils';
|
|
14
|
+
import { ElasticsearchDistribution } from '@terascope/types';
|
|
15
|
+
|
|
16
|
+
import('setimmediate');
|
|
19
17
|
|
|
20
18
|
const DOCUMENT_EXISTS = 409;
|
|
21
19
|
const TOO_MANY_REQUESTS = 429;
|
|
22
20
|
|
|
23
21
|
// Module to manage persistence in Elasticsearch.
|
|
24
22
|
// All functions in this module return promises that must be resolved to get the final result.
|
|
25
|
-
|
|
23
|
+
export default function elasticsearchApi(client, logger, _opConfig) {
|
|
26
24
|
const config = _opConfig || {};
|
|
27
25
|
if (!client) {
|
|
28
26
|
throw new Error('Elasticsearch API requires client');
|
|
@@ -1288,4 +1286,4 @@ module.exports = function elasticsearchApi(client, logger, _opConfig) {
|
|
|
1288
1286
|
getESVersion,
|
|
1289
1287
|
isErrorRetryable
|
|
1290
1288
|
};
|
|
1291
|
-
}
|
|
1289
|
+
}
|
package/jest.config.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const dirPath = fileURLToPath(new URL('.', import.meta.url));
|
|
5
|
+
const configModulePath = path.join(dirPath, '../../jest.config.base.js');
|
|
6
|
+
|
|
7
|
+
const module = await import(configModulePath);
|
|
8
|
+
|
|
9
|
+
const config = module.default(dirPath);
|
|
10
|
+
|
|
11
|
+
config.extensionsToTreatAsEsm = ['.ts'];
|
|
12
|
+
config.moduleNameMapper = {
|
|
13
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
14
|
+
};
|
|
15
|
+
config.testTimeout = 60 * 1000;
|
|
16
|
+
config.transform = {};
|
|
17
|
+
|
|
18
|
+
config.transform['^.+\\.(t|j)sx?$'] = '@swc/jest';
|
|
19
|
+
|
|
20
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terascope/elasticsearch-api",
|
|
3
3
|
"displayName": "Elasticsearch API",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "Elasticsearch client api used across multiple services, handles retries and exponential backoff",
|
|
6
6
|
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-api#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"repository": "git@github.com:terascope/teraslice.git",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Terascope, LLC <info@terascope.io>",
|
|
13
|
+
"type": "module",
|
|
13
14
|
"main": "index.js",
|
|
14
15
|
"typings": "types/index.d.ts",
|
|
15
16
|
"scripts": {
|
|
@@ -23,8 +24,8 @@
|
|
|
23
24
|
"test:watch": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test --watch . --"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@terascope/types": "^0.
|
|
27
|
-
"@terascope/utils": "^0.
|
|
27
|
+
"@terascope/types": "^1.0.0",
|
|
28
|
+
"@terascope/utils": "^1.0.0",
|
|
28
29
|
"bluebird": "^3.7.2",
|
|
29
30
|
"setimmediate": "^1.0.5"
|
|
30
31
|
},
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"@opensearch-project/opensearch": "^1.2.0",
|
|
33
34
|
"@types/elasticsearch": "^5.0.43",
|
|
34
35
|
"elasticsearch": "^15.4.1",
|
|
35
|
-
"elasticsearch-store": "^0.
|
|
36
|
+
"elasticsearch-store": "^1.0.0",
|
|
36
37
|
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
|
|
37
38
|
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
|
|
38
39
|
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
|
package/test/api-spec.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = require('@terascope/utils');
|
|
7
|
-
const esApi = require('..');
|
|
1
|
+
import {
|
|
2
|
+
debugLogger, cloneDeep, DataEntity,
|
|
3
|
+
isEmpty, pDelay
|
|
4
|
+
} from '@terascope/utils';
|
|
5
|
+
import esApi from '../index.js';
|
|
8
6
|
|
|
9
7
|
describe('elasticsearch-api', () => {
|
|
10
8
|
let recordsReturned = [];
|
|
@@ -66,11 +64,12 @@ describe('elasticsearch-api', () => {
|
|
|
66
64
|
};
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
function waitFor(time, fn) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
67
|
+
async function waitFor(time, fn) {
|
|
68
|
+
await pDelay(time);
|
|
69
|
+
if (fn) {
|
|
70
|
+
fn();
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
function postedData(action, id) {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
cloneDeep,
|
|
6
|
-
DataEntity
|
|
7
|
-
} = require('@terascope/utils');
|
|
8
|
-
const { ElasticsearchTestHelpers } = require('elasticsearch-store');
|
|
9
|
-
const elasticsearchAPI = require('../index');
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import { debugLogger, cloneDeep, DataEntity } from '@terascope/utils';
|
|
3
|
+
import { ElasticsearchTestHelpers } from 'elasticsearch-store';
|
|
4
|
+
import elasticsearchAPI from '../index.js';
|
|
10
5
|
|
|
11
6
|
const {
|
|
12
7
|
makeClient, cleanupIndex, EvenDateData,
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
chunk,
|
|
6
|
-
pMap
|
|
7
|
-
} = require('@terascope/utils');
|
|
8
|
-
const { ElasticsearchTestHelpers } = require('elasticsearch-store');
|
|
9
|
-
const elasticsearchAPI = require('../index');
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import { debugLogger, chunk, pMap } from '@terascope/utils';
|
|
3
|
+
import { ElasticsearchTestHelpers } from 'elasticsearch-store';
|
|
4
|
+
import elasticsearchAPI from '../index.js';
|
|
10
5
|
|
|
11
6
|
const {
|
|
12
7
|
makeClient, cleanupIndex, waitForData,
|
package/test/retry-spec.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const opensearch = require('@opensearch-project/opensearch');
|
|
6
|
-
const API = require('../index');
|
|
1
|
+
import { ElasticsearchTestHelpers } from 'elasticsearch-store';
|
|
2
|
+
import { debugLogger } from '@terascope/utils';
|
|
3
|
+
import opensearch from '@opensearch-project/opensearch';
|
|
4
|
+
import API from '../index.js';
|
|
7
5
|
|
|
8
6
|
const logger = debugLogger('retry spec');
|
|
9
7
|
const port = '1111';
|