@travetto/model-elasticsearch 5.0.16 → 5.0.18

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ArcSine Technologies
3
+ Copyright (c) 2020 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-elasticsearch",
3
- "version": "5.0.16",
3
+ "version": "5.0.18",
4
4
  "description": "Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.",
5
5
  "keywords": [
6
6
  "elasticsearch",
@@ -27,11 +27,11 @@
27
27
  "directory": "module/model-elasticsearch"
28
28
  },
29
29
  "dependencies": {
30
- "@elastic/elasticsearch": "^8.15.1",
31
- "@travetto/cli": "^5.0.15",
32
- "@travetto/config": "^5.0.12",
33
- "@travetto/model": "^5.0.13",
34
- "@travetto/model-query": "^5.0.13"
30
+ "@elastic/elasticsearch": "^8.17.0",
31
+ "@travetto/cli": "^5.0.17",
32
+ "@travetto/config": "^5.0.14",
33
+ "@travetto/model": "^5.0.15",
34
+ "@travetto/model-query": "^5.0.15"
35
35
  },
36
36
  "travetto": {
37
37
  "displayName": "Elasticsearch Model Source"
@@ -1,4 +1,4 @@
1
- import { DeleteByQueryRequest, QueryDslQueryContainer, SearchRequest, SearchResponse, Sort, SortOptions } from '@elastic/elasticsearch/lib/api/types';
1
+ import { estypes } from '@elastic/elasticsearch';
2
2
 
3
3
  import { castTo, Class, TypedObject } from '@travetto/runtime';
4
4
  import { WhereClause, SelectClause, SortClause, Query } from '@travetto/model-query';
@@ -54,8 +54,8 @@ export class ElasticsearchQueryUtil {
54
54
  /**
55
55
  * Build sort mechanism
56
56
  */
57
- static getSort<T extends ModelType>(sort: SortClause<T>[] | IndexConfig<T>['fields']): Sort {
58
- return sort.map<SortOptions>(x => {
57
+ static getSort<T extends ModelType>(sort: SortClause<T>[] | IndexConfig<T>['fields']): estypes.Sort {
58
+ return sort.map<estypes.SortOptions>(x => {
59
59
  const o = this.extractSimple(x);
60
60
  const k = Object.keys(o)[0];
61
61
  const v: boolean | -1 | 1 = castTo(o[k]);
@@ -217,7 +217,7 @@ export class ElasticsearchQueryUtil {
217
217
  * @param cls
218
218
  * @param search
219
219
  */
220
- static getSearchQuery<T extends ModelType>(cls: Class<T>, search: Record<string, unknown>, checkExpiry = true): QueryDslQueryContainer {
220
+ static getSearchQuery<T extends ModelType>(cls: Class<T>, search: Record<string, unknown>, checkExpiry = true): estypes.QueryDslQueryContainer {
221
221
  const clauses = [];
222
222
  if (search && Object.keys(search).length) {
223
223
  clauses.push(search);
@@ -250,8 +250,8 @@ export class ElasticsearchQueryUtil {
250
250
  */
251
251
  static getSearchObject<T extends ModelType>(
252
252
  cls: Class<T>, query: Query<T>, config?: EsSchemaConfig, checkExpiry = true
253
- ): SearchRequest & Omit<DeleteByQueryRequest, 'index' | 'sort'> {
254
- const search: (SearchRequest & Omit<DeleteByQueryRequest, 'index' | 'sort'>) = {
253
+ ): estypes.SearchRequest & Omit<estypes.DeleteByQueryRequest, 'index' | 'sort'> {
254
+ const search: (estypes.SearchRequest & Omit<estypes.DeleteByQueryRequest, 'index' | 'sort'>) = {
255
255
  query: this.getSearchQuery(cls, this.extractWhereQuery(cls, query.where ?? {}, config), checkExpiry)
256
256
  };
257
257
 
@@ -286,7 +286,7 @@ export class ElasticsearchQueryUtil {
286
286
  /**
287
287
  * Safely load the data, excluding ids if needed
288
288
  */
289
- static cleanIdRemoval<T>(req: SearchRequest, results: SearchResponse<T>): T[] {
289
+ static cleanIdRemoval<T>(req: estypes.SearchRequest, results: estypes.SearchResponse<T>): T[] {
290
290
  const out: T[] = [];
291
291
 
292
292
  const toArr = <V>(x: V | V[] | undefined): V[] => (x ? (Array.isArray(x) ? x : [x]) : []);
package/src/service.ts CHANGED
@@ -1,12 +1,11 @@
1
- import { Client, errors } from '@elastic/elasticsearch';
2
- import { AggregationsStringTermsAggregate, SearchRequest, SearchResponse } from '@elastic/elasticsearch/lib/api/types';
1
+ import { Client, errors, estypes } from '@elastic/elasticsearch';
3
2
 
4
3
  import {
5
4
  ModelCrudSupport, BulkOp, BulkResponse, ModelBulkSupport, ModelExpirySupport,
6
5
  ModelIndexedSupport, ModelType, ModelStorageSupport, NotFoundError, ModelRegistry,
7
6
  OptionalId
8
7
  } from '@travetto/model';
9
- import { ShutdownManager, type DeepPartial, type Class, AppError, castTo, asFull, TypedObject, asConstructable } from '@travetto/runtime';
8
+ import { ShutdownManager, type DeepPartial, type Class, castTo, asFull, TypedObject, asConstructable } from '@travetto/runtime';
10
9
  import { SchemaChange, BindUtil } from '@travetto/schema';
11
10
  import { Injectable } from '@travetto/di';
12
11
  import {
@@ -55,7 +54,7 @@ export class ElasticsearchModelService implements
55
54
  /**
56
55
  * Directly run the search
57
56
  */
58
- async execSearch<T extends ModelType>(cls: Class<T>, search: SearchRequest): Promise<SearchResponse<T>> {
57
+ async execSearch<T extends ModelType>(cls: Class<T>, search: estypes.SearchRequest): Promise<estypes.SearchResponse<T>> {
59
58
  let query = search.query;
60
59
  if (query && Object.keys(query).length === 0) {
61
60
  query = undefined;
@@ -238,7 +237,7 @@ export class ElasticsearchModelService implements
238
237
  }
239
238
 
240
239
  async * list<T extends ModelType>(cls: Class<T>): AsyncIterable<T> {
241
- let search: SearchResponse<T> = await this.execSearch<T>(cls, {
240
+ let search: estypes.SearchResponse<T> = await this.execSearch<T>(cls, {
242
241
  scroll: '2m',
243
242
  size: 100,
244
243
  query: ElasticsearchQueryUtil.getSearchQuery(cls, {})
@@ -342,7 +341,7 @@ export class ElasticsearchModelService implements
342
341
  // Indexed
343
342
  async getByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): Promise<T> {
344
343
  const { key } = ModelIndexedUtil.computeIndexKey(cls, idx, body);
345
- const res: SearchResponse<T> = await this.execSearch<T>(cls, {
344
+ const res = await this.execSearch<T>(cls, {
346
345
  query: ElasticsearchQueryUtil.getSearchQuery(cls,
347
346
  ElasticsearchQueryUtil.extractWhereTermQuery(cls,
348
347
  ModelIndexedUtil.projectIndex(cls, idx, body))
@@ -539,7 +538,7 @@ export class ElasticsearchModelService implements
539
538
  };
540
539
 
541
540
  const res = await this.execSearch(cls, search);
542
- const { buckets } = castTo<AggregationsStringTermsAggregate>('buckets' in res.aggregations![field] ? res.aggregations![field] : { buckets: [] });
541
+ const { buckets } = castTo<estypes.AggregationsStringTermsAggregate>('buckets' in res.aggregations![field] ? res.aggregations![field] : { buckets: [] });
543
542
  const out = Array.isArray(buckets) ? buckets.map(b => ({ key: b.key, count: b.doc_count })) : [];
544
543
  return out;
545
544
  }
@@ -1,6 +1,6 @@
1
1
  import type { ServiceDescriptor } from '@travetto/cli';
2
2
 
3
- const version = '8.9.1';
3
+ const version = '8.17.0';
4
4
 
5
5
  const port = 9200;
6
6