@travetto/model-elasticsearch 8.0.0-alpha.17 → 8.0.0-alpha.19
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 +7 -7
- package/src/internal/schema.ts +15 -9
- package/src/service.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-elasticsearch",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.",
|
|
6
6
|
"keywords": [
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"directory": "module/model-elasticsearch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@elastic/elasticsearch": "^9.
|
|
32
|
-
"@travetto/config": "^8.0.0-alpha.
|
|
33
|
-
"@travetto/model": "^8.0.0-alpha.
|
|
34
|
-
"@travetto/model-indexed": "^8.0.0-alpha.
|
|
35
|
-
"@travetto/model-query": "^8.0.0-alpha.
|
|
31
|
+
"@elastic/elasticsearch": "^9.4.2",
|
|
32
|
+
"@travetto/config": "^8.0.0-alpha.17",
|
|
33
|
+
"@travetto/model": "^8.0.0-alpha.17",
|
|
34
|
+
"@travetto/model-indexed": "^8.0.0-alpha.19",
|
|
35
|
+
"@travetto/model-query": "^8.0.0-alpha.18"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
38
|
+
"@travetto/cli": "^8.0.0-alpha.22"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@travetto/cli": {
|
package/src/internal/schema.ts
CHANGED
|
@@ -7,8 +7,8 @@ import type { EsSchemaConfig } from './types.ts';
|
|
|
7
7
|
|
|
8
8
|
const PointConcrete = toConcrete<Point>();
|
|
9
9
|
|
|
10
|
-
const isMappingType = (input: estypes.MappingProperty): input is estypes.MappingTypeMapping =>
|
|
11
|
-
(input.type === 'object' || input.type === 'nested')
|
|
10
|
+
const isMappingType = (input: estypes.MappingProperty): input is estypes.MappingTypeMapping & estypes.MappingProperty =>
|
|
11
|
+
!!input && !!input.type && (input.type === 'object' || input.type === 'nested');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Utils for ES Schema management
|
|
@@ -163,14 +163,20 @@ export class ElasticsearchSchemaUtil {
|
|
|
163
163
|
const currentProperty = currentProperties[key];
|
|
164
164
|
const neededProperty = neededProperties[key];
|
|
165
165
|
|
|
166
|
-
if (
|
|
167
|
-
|
|
166
|
+
if (isMappingType(currentProperty) && isMappingType(neededProperty)) {
|
|
167
|
+
if (currentProperty.type !== neededProperty.type) {
|
|
168
|
+
changed.push(path);
|
|
169
|
+
} else {
|
|
170
|
+
changed.push(...this.getChangedFields(
|
|
171
|
+
'properties' in currentProperty ? currentProperty : { properties: {} },
|
|
172
|
+
'properties' in neededProperty ? neededProperty : { properties: {} },
|
|
173
|
+
path
|
|
174
|
+
));
|
|
175
|
+
}
|
|
168
176
|
} else if (isMappingType(currentProperty) || isMappingType(neededProperty)) {
|
|
169
|
-
changed.push(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
path
|
|
173
|
-
));
|
|
177
|
+
changed.push(path);
|
|
178
|
+
} else if (!currentProperty || !neededProperty || currentProperty.type !== neededProperty.type) {
|
|
179
|
+
changed.push(path);
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
182
|
return changed;
|
package/src/service.ts
CHANGED
|
@@ -662,7 +662,7 @@ export class ElasticsearchModelService implements
|
|
|
662
662
|
});
|
|
663
663
|
const search = ElasticsearchQueryUtil.getSearchObject(cls, resolvedQuery);
|
|
664
664
|
const result = await this.execSearch(cls, search);
|
|
665
|
-
const all = result.hits.hits.map(hit => castTo<T>((
|
|
665
|
+
const all = result.hits.hits.map(hit => castTo<T>((field === 'id' ? { id: hit._id } : hit._source)));
|
|
666
666
|
return ModelQuerySuggestUtil.combineSuggestResults(cls, field, prefix, all, item => item, query && query.limit);
|
|
667
667
|
}
|
|
668
668
|
|