@travetto/model-elasticsearch 4.0.0-rc.3 → 4.0.0-rc.4
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/package.json +5 -5
- package/src/index-manager.ts +3 -3
- package/src/service.ts +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-elasticsearch",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.4",
|
|
4
4
|
"description": "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elasticsearch",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@elastic/elasticsearch": "^8.12.0",
|
|
31
|
-
"@travetto/config": "^4.0.0-rc.
|
|
32
|
-
"@travetto/model": "^4.0.0-rc.
|
|
33
|
-
"@travetto/model-query": "^4.0.0-rc.
|
|
31
|
+
"@travetto/config": "^4.0.0-rc.4",
|
|
32
|
+
"@travetto/model": "^4.0.0-rc.4",
|
|
33
|
+
"@travetto/model-query": "^4.0.0-rc.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/command": "^4.0.0-rc.
|
|
36
|
+
"@travetto/command": "^4.0.0-rc.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/command": {
|
package/src/index-manager.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Client } from '@elastic/elasticsearch';
|
|
2
2
|
import { ReindexRequest } from '@elastic/elasticsearch/lib/api/types';
|
|
3
3
|
|
|
4
4
|
import { Class } from '@travetto/base';
|
|
@@ -17,9 +17,9 @@ export class IndexManager implements ModelStorageSupport {
|
|
|
17
17
|
#indexToAlias = new Map<string, string>();
|
|
18
18
|
#aliasToIndex = new Map<string, string>();
|
|
19
19
|
#identities = new Map<Class, { index: string }>();
|
|
20
|
-
#client:
|
|
20
|
+
#client: Client;
|
|
21
21
|
|
|
22
|
-
constructor(public readonly config: ElasticsearchModelConfig, client:
|
|
22
|
+
constructor(public readonly config: ElasticsearchModelConfig, client: Client) {
|
|
23
23
|
this.#client = client;
|
|
24
24
|
}
|
|
25
25
|
|
package/src/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Client, errors } from '@elastic/elasticsearch';
|
|
2
2
|
import {
|
|
3
3
|
AggregationsStringTermsAggregate, AggregationsStringTermsBucket, DeleteByQueryRequest, SearchRequest, SearchResponse, UpdateByQueryResponse
|
|
4
4
|
} from '@elastic/elasticsearch/lib/api/types';
|
|
@@ -48,7 +48,7 @@ export class ElasticsearchModelService implements
|
|
|
48
48
|
ModelQuerySuggestSupport, ModelQueryFacetSupport {
|
|
49
49
|
|
|
50
50
|
idSource = ModelCrudUtil.uuidSource();
|
|
51
|
-
client:
|
|
51
|
+
client: Client;
|
|
52
52
|
manager: IndexManager;
|
|
53
53
|
|
|
54
54
|
constructor(public readonly config: ElasticsearchModelConfig) { }
|
|
@@ -69,7 +69,7 @@ export class ElasticsearchModelService implements
|
|
|
69
69
|
});
|
|
70
70
|
return res;
|
|
71
71
|
} catch (err) {
|
|
72
|
-
if (err instanceof
|
|
72
|
+
if (err instanceof errors.ResponseError && err.meta.body && typeof err.meta.body === 'object' && 'error' in err.meta.body) {
|
|
73
73
|
console.error(err.meta.body.error);
|
|
74
74
|
}
|
|
75
75
|
throw err;
|
|
@@ -100,7 +100,7 @@ export class ElasticsearchModelService implements
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async postConstruct(this: ElasticsearchModelService): Promise<void> {
|
|
103
|
-
this.client = new
|
|
103
|
+
this.client = new Client({
|
|
104
104
|
nodes: this.config.hosts,
|
|
105
105
|
...(this.config.options || {}),
|
|
106
106
|
});
|
|
@@ -144,7 +144,7 @@ export class ElasticsearchModelService implements
|
|
|
144
144
|
throw new NotFoundError(cls, id);
|
|
145
145
|
}
|
|
146
146
|
} catch (err) {
|
|
147
|
-
if (err && err instanceof
|
|
147
|
+
if (err && err instanceof errors.ResponseError && err.body && err.body.result === 'not_found') {
|
|
148
148
|
throw new NotFoundError(cls, id);
|
|
149
149
|
}
|
|
150
150
|
throw err;
|
|
@@ -462,7 +462,7 @@ export class ElasticsearchModelService implements
|
|
|
462
462
|
}
|
|
463
463
|
} catch (err) {
|
|
464
464
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
465
|
-
if (err instanceof
|
|
465
|
+
if (err instanceof errors.ResponseError && (err.body as UpdateByQueryResponse).version_conflicts) {
|
|
466
466
|
throw new NotFoundError(cls, id);
|
|
467
467
|
} else {
|
|
468
468
|
throw err;
|