-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/release'
- Loading branch information
Showing
60 changed files
with
1,213 additions
and
816 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import elasticSearch, { RequestParams } from '@elastic/elasticsearch'; | ||
import { | ||
TransportRequestOptions, | ||
RequestBody, | ||
RequestNDBody, | ||
} from '@elastic/elasticsearch/lib/Transport'; | ||
import { tenants } from 'api/tenants'; | ||
import { EntitySchema } from 'shared/types/entityType'; | ||
import { SearchResponse, IndicesPutMapping, IndicesDelete, IndicesCreate } from './elasticTypes'; | ||
|
||
const elasticClient = new elasticSearch.Client({ | ||
node: process.env.ELASTICSEARCH_URL || 'http://localhost:9200', | ||
}); | ||
|
||
const elastic = { | ||
async search(params?: RequestParams.Search<RequestBody>, options?: TransportRequestOptions) { | ||
return elasticClient.search<SearchResponse<EntitySchema>, RequestBody>( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
|
||
async delete(params: RequestParams.Delete, options?: TransportRequestOptions) { | ||
return elasticClient.delete({ ...params, index: tenants.current().indexName }, options); | ||
}, | ||
|
||
async bulk(params: RequestParams.Bulk<RequestNDBody>, options?: TransportRequestOptions) { | ||
return elasticClient.bulk({ ...params, index: tenants.current().indexName }, options); | ||
}, | ||
|
||
async deleteByQuery( | ||
params: RequestParams.DeleteByQuery<RequestBody>, | ||
options?: TransportRequestOptions | ||
) { | ||
return elasticClient.deleteByQuery({ ...params, index: tenants.current().indexName }, options); | ||
}, | ||
|
||
indices: { | ||
async putMapping(params: IndicesPutMapping, options?: TransportRequestOptions) { | ||
return elasticClient.indices.putMapping( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
|
||
async getMapping(params?: RequestParams.IndicesGetMapping, options?: TransportRequestOptions) { | ||
return elasticClient.indices.getMapping( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
|
||
async delete(params?: IndicesDelete, options?: TransportRequestOptions) { | ||
return elasticClient.indices.delete( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
|
||
async create(params?: IndicesCreate, options?: TransportRequestOptions) { | ||
return elasticClient.indices.create( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
|
||
async refresh(params?: RequestParams.IndicesRefresh, options?: TransportRequestOptions) { | ||
return elasticClient.indices.refresh( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
|
||
async validateQuery( | ||
params?: RequestParams.IndicesValidateQuery<RequestBody>, | ||
options?: TransportRequestOptions | ||
) { | ||
return elasticClient.indices.validateQuery( | ||
{ ...params, index: tenants.current().indexName }, | ||
options | ||
); | ||
}, | ||
}, | ||
}; | ||
|
||
export { elastic, elasticClient }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { RequestParams } from '@elastic/elasticsearch'; | ||
import { RequestBody } from '@elastic/elasticsearch/lib/Transport'; | ||
|
||
interface ShardsResponse { | ||
total: number; | ||
successful: number; | ||
failed: number; | ||
skipped: number; | ||
} | ||
|
||
interface Explanation { | ||
value: number; | ||
description: string; | ||
details: Explanation[]; | ||
} | ||
|
||
export interface SearchResponse<T> { | ||
took: number; | ||
// eslint-disable-next-line camelcase | ||
timed_out: boolean; | ||
// eslint-disable-next-line camelcase | ||
_scroll_id?: string; | ||
_shards: ShardsResponse; | ||
hits: { | ||
total: number; | ||
// eslint-disable-next-line camelcase | ||
max_score: number; | ||
hits: Array<{ | ||
_index: string; | ||
_type: string; | ||
_id: string; | ||
_score: number; | ||
_source: T; | ||
_version?: number; | ||
_explanation?: Explanation; | ||
fields?: any; | ||
highlight?: any; | ||
// eslint-disable-next-line camelcase | ||
inner_hits?: any; | ||
// eslint-disable-next-line camelcase | ||
matched_queries?: string[]; | ||
sort?: string[]; | ||
}>; | ||
}; | ||
aggregations?: any; | ||
} | ||
|
||
export type IndicesDelete = Omit<RequestParams.IndicesDelete, 'index'>; | ||
export type IndicesCreate = Omit<RequestParams.IndicesCreate<RequestBody>, 'index'>; | ||
export type IndicesPutMapping = Omit<RequestParams.IndicesPutMapping<RequestBody>, 'index'>; |
Oops, something went wrong.