@opra/elastic 1.6.0 → 1.7.1
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/cjs/elastic-collection-service.js +15 -12
- package/cjs/elastic-entity-service.js +41 -2
- package/esm/elastic-collection-service.js +15 -12
- package/esm/elastic-entity-service.js +41 -2
- package/package.json +3 -3
- package/types/adapter-utils/prepare-filter.d.ts +2 -2
- package/types/elastic-adapter.d.ts +2 -2
- package/types/elastic-collection-service.d.ts +9 -8
- package/types/elastic-entity-service.d.ts +38 -15
|
@@ -220,7 +220,7 @@ class ElasticCollectionService extends elastic_entity_service_js_1.ElasticEntity
|
|
|
220
220
|
};
|
|
221
221
|
const r = await this._findMany(newCommand);
|
|
222
222
|
if (r.hits.hits?.length) {
|
|
223
|
-
const outputCodec = this.
|
|
223
|
+
const outputCodec = this.getOutputCodec('find');
|
|
224
224
|
return {
|
|
225
225
|
_id: r.hits.hits[0]._id,
|
|
226
226
|
...outputCodec(r.hits.hits[0]._source),
|
|
@@ -250,7 +250,7 @@ class ElasticCollectionService extends elastic_entity_service_js_1.ElasticEntity
|
|
|
250
250
|
};
|
|
251
251
|
const r = await this._findMany(newCommand);
|
|
252
252
|
if (r.hits.hits?.length) {
|
|
253
|
-
const outputCodec = this.
|
|
253
|
+
const outputCodec = this.getOutputCodec('find');
|
|
254
254
|
return {
|
|
255
255
|
_id: r.hits.hits[0]._id,
|
|
256
256
|
...outputCodec(r.hits.hits[0]._source),
|
|
@@ -276,16 +276,19 @@ class ElasticCollectionService extends elastic_entity_service_js_1.ElasticEntity
|
|
|
276
276
|
const limit = command.options?.limit || this.defaultLimit;
|
|
277
277
|
command.options = { ...command.options, filter, limit };
|
|
278
278
|
const r = await this._findMany(command);
|
|
279
|
-
|
|
280
|
-
const outputCodec = this._getOutputCodec('find');
|
|
281
|
-
return r.hits.hits.map((x) => ({
|
|
282
|
-
_id: x._id,
|
|
283
|
-
...outputCodec(x._source),
|
|
284
|
-
}));
|
|
285
|
-
}
|
|
286
|
-
return [];
|
|
279
|
+
return r.hits?.hits.map((x) => x._source) || [];
|
|
287
280
|
});
|
|
288
281
|
}
|
|
282
|
+
async searchRaw(request, options) {
|
|
283
|
+
const command = {
|
|
284
|
+
crud: 'read',
|
|
285
|
+
method: 'searchRaw',
|
|
286
|
+
byId: false,
|
|
287
|
+
request,
|
|
288
|
+
options,
|
|
289
|
+
};
|
|
290
|
+
return this._executeCommand(command, async () => this._searchRaw(command));
|
|
291
|
+
}
|
|
289
292
|
/**
|
|
290
293
|
*
|
|
291
294
|
*/
|
|
@@ -311,7 +314,7 @@ class ElasticCollectionService extends elastic_entity_service_js_1.ElasticEntity
|
|
|
311
314
|
const r = await this._findMany(command);
|
|
312
315
|
const out = {};
|
|
313
316
|
if (r.hits.hits?.length) {
|
|
314
|
-
const outputCodec = this.
|
|
317
|
+
const outputCodec = this.getOutputCodec('find');
|
|
315
318
|
out.items = r.hits.hits.map((x) => ({
|
|
316
319
|
_id: x._id,
|
|
317
320
|
...outputCodec(x._source),
|
|
@@ -343,7 +346,7 @@ class ElasticCollectionService extends elastic_entity_service_js_1.ElasticEntity
|
|
|
343
346
|
* @param {string} id - The ID of the document to update.
|
|
344
347
|
* @param {PatchDTO<T>} input - The partial input data to update the document with.
|
|
345
348
|
* @param {ElasticEntityService.UpdateOneOptions} [options] - The options for updating the document.
|
|
346
|
-
* @returns {Promise<
|
|
349
|
+
* @returns {Promise<estypes.UpdateResponse>} - A promise that resolves to the number of documents modified.
|
|
347
350
|
*/
|
|
348
351
|
async update(id, input, options) {
|
|
349
352
|
const command = {
|
|
@@ -221,7 +221,46 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
221
221
|
query,
|
|
222
222
|
};
|
|
223
223
|
const client = this.getClient();
|
|
224
|
-
|
|
224
|
+
const r = await client.search(request, options?.transport);
|
|
225
|
+
if (options?.noDecode)
|
|
226
|
+
return r;
|
|
227
|
+
if (r.hits.hits?.length) {
|
|
228
|
+
const outputCodec = this.getOutputCodec('find');
|
|
229
|
+
r.hits.hits = r.hits.hits.map((x) => ({
|
|
230
|
+
...x,
|
|
231
|
+
_source: {
|
|
232
|
+
_id: x._id,
|
|
233
|
+
...outputCodec(x._source),
|
|
234
|
+
},
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
return r;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Executes a search operation on the Elasticsearch index using the provided search command.
|
|
241
|
+
*
|
|
242
|
+
* @param {ElasticEntityService.SearchCommand} command - The search command containing the request configuration and optional transport settings.
|
|
243
|
+
* @return {Promise<ElasticEntityService.SearchResponse>} A promise resolving to the search response from Elasticsearch.
|
|
244
|
+
*/
|
|
245
|
+
async _searchRaw(command) {
|
|
246
|
+
const { options } = command;
|
|
247
|
+
const request = {
|
|
248
|
+
index: this.getIndexName(),
|
|
249
|
+
...command.request,
|
|
250
|
+
};
|
|
251
|
+
const client = this.getClient();
|
|
252
|
+
const r = await client.search(request, options?.transport);
|
|
253
|
+
if (r.hits.hits?.length) {
|
|
254
|
+
const outputCodec = this.getOutputCodec('find');
|
|
255
|
+
r.hits.hits = r.hits.hits.map((x) => ({
|
|
256
|
+
...x,
|
|
257
|
+
_source: {
|
|
258
|
+
_id: x._id,
|
|
259
|
+
...outputCodec(x._source),
|
|
260
|
+
},
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
return r;
|
|
225
264
|
}
|
|
226
265
|
/**
|
|
227
266
|
* Updates multiple documents in the collection based on the specified input and options.
|
|
@@ -319,7 +358,7 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
319
358
|
/**
|
|
320
359
|
* Retrieves the codec.
|
|
321
360
|
*/
|
|
322
|
-
|
|
361
|
+
getOutputCodec(operation) {
|
|
323
362
|
const cacheKey = operation + (this._dataTypeScope ? ':' + this._dataTypeScope : '');
|
|
324
363
|
let validator = this._outputCodecs[cacheKey];
|
|
325
364
|
if (validator)
|
|
@@ -217,7 +217,7 @@ export class ElasticCollectionService extends ElasticEntityService {
|
|
|
217
217
|
};
|
|
218
218
|
const r = await this._findMany(newCommand);
|
|
219
219
|
if (r.hits.hits?.length) {
|
|
220
|
-
const outputCodec = this.
|
|
220
|
+
const outputCodec = this.getOutputCodec('find');
|
|
221
221
|
return {
|
|
222
222
|
_id: r.hits.hits[0]._id,
|
|
223
223
|
...outputCodec(r.hits.hits[0]._source),
|
|
@@ -247,7 +247,7 @@ export class ElasticCollectionService extends ElasticEntityService {
|
|
|
247
247
|
};
|
|
248
248
|
const r = await this._findMany(newCommand);
|
|
249
249
|
if (r.hits.hits?.length) {
|
|
250
|
-
const outputCodec = this.
|
|
250
|
+
const outputCodec = this.getOutputCodec('find');
|
|
251
251
|
return {
|
|
252
252
|
_id: r.hits.hits[0]._id,
|
|
253
253
|
...outputCodec(r.hits.hits[0]._source),
|
|
@@ -273,16 +273,19 @@ export class ElasticCollectionService extends ElasticEntityService {
|
|
|
273
273
|
const limit = command.options?.limit || this.defaultLimit;
|
|
274
274
|
command.options = { ...command.options, filter, limit };
|
|
275
275
|
const r = await this._findMany(command);
|
|
276
|
-
|
|
277
|
-
const outputCodec = this._getOutputCodec('find');
|
|
278
|
-
return r.hits.hits.map((x) => ({
|
|
279
|
-
_id: x._id,
|
|
280
|
-
...outputCodec(x._source),
|
|
281
|
-
}));
|
|
282
|
-
}
|
|
283
|
-
return [];
|
|
276
|
+
return r.hits?.hits.map((x) => x._source) || [];
|
|
284
277
|
});
|
|
285
278
|
}
|
|
279
|
+
async searchRaw(request, options) {
|
|
280
|
+
const command = {
|
|
281
|
+
crud: 'read',
|
|
282
|
+
method: 'searchRaw',
|
|
283
|
+
byId: false,
|
|
284
|
+
request,
|
|
285
|
+
options,
|
|
286
|
+
};
|
|
287
|
+
return this._executeCommand(command, async () => this._searchRaw(command));
|
|
288
|
+
}
|
|
286
289
|
/**
|
|
287
290
|
*
|
|
288
291
|
*/
|
|
@@ -308,7 +311,7 @@ export class ElasticCollectionService extends ElasticEntityService {
|
|
|
308
311
|
const r = await this._findMany(command);
|
|
309
312
|
const out = {};
|
|
310
313
|
if (r.hits.hits?.length) {
|
|
311
|
-
const outputCodec = this.
|
|
314
|
+
const outputCodec = this.getOutputCodec('find');
|
|
312
315
|
out.items = r.hits.hits.map((x) => ({
|
|
313
316
|
_id: x._id,
|
|
314
317
|
...outputCodec(x._source),
|
|
@@ -340,7 +343,7 @@ export class ElasticCollectionService extends ElasticEntityService {
|
|
|
340
343
|
* @param {string} id - The ID of the document to update.
|
|
341
344
|
* @param {PatchDTO<T>} input - The partial input data to update the document with.
|
|
342
345
|
* @param {ElasticEntityService.UpdateOneOptions} [options] - The options for updating the document.
|
|
343
|
-
* @returns {Promise<
|
|
346
|
+
* @returns {Promise<estypes.UpdateResponse>} - A promise that resolves to the number of documents modified.
|
|
344
347
|
*/
|
|
345
348
|
async update(id, input, options) {
|
|
346
349
|
const command = {
|
|
@@ -218,7 +218,46 @@ export class ElasticEntityService extends ElasticService {
|
|
|
218
218
|
query,
|
|
219
219
|
};
|
|
220
220
|
const client = this.getClient();
|
|
221
|
-
|
|
221
|
+
const r = await client.search(request, options?.transport);
|
|
222
|
+
if (options?.noDecode)
|
|
223
|
+
return r;
|
|
224
|
+
if (r.hits.hits?.length) {
|
|
225
|
+
const outputCodec = this.getOutputCodec('find');
|
|
226
|
+
r.hits.hits = r.hits.hits.map((x) => ({
|
|
227
|
+
...x,
|
|
228
|
+
_source: {
|
|
229
|
+
_id: x._id,
|
|
230
|
+
...outputCodec(x._source),
|
|
231
|
+
},
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
return r;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Executes a search operation on the Elasticsearch index using the provided search command.
|
|
238
|
+
*
|
|
239
|
+
* @param {ElasticEntityService.SearchCommand} command - The search command containing the request configuration and optional transport settings.
|
|
240
|
+
* @return {Promise<ElasticEntityService.SearchResponse>} A promise resolving to the search response from Elasticsearch.
|
|
241
|
+
*/
|
|
242
|
+
async _searchRaw(command) {
|
|
243
|
+
const { options } = command;
|
|
244
|
+
const request = {
|
|
245
|
+
index: this.getIndexName(),
|
|
246
|
+
...command.request,
|
|
247
|
+
};
|
|
248
|
+
const client = this.getClient();
|
|
249
|
+
const r = await client.search(request, options?.transport);
|
|
250
|
+
if (r.hits.hits?.length) {
|
|
251
|
+
const outputCodec = this.getOutputCodec('find');
|
|
252
|
+
r.hits.hits = r.hits.hits.map((x) => ({
|
|
253
|
+
...x,
|
|
254
|
+
_source: {
|
|
255
|
+
_id: x._id,
|
|
256
|
+
...outputCodec(x._source),
|
|
257
|
+
},
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
return r;
|
|
222
261
|
}
|
|
223
262
|
/**
|
|
224
263
|
* Updates multiple documents in the collection based on the specified input and options.
|
|
@@ -316,7 +355,7 @@ export class ElasticEntityService extends ElasticService {
|
|
|
316
355
|
/**
|
|
317
356
|
* Retrieves the codec.
|
|
318
357
|
*/
|
|
319
|
-
|
|
358
|
+
getOutputCodec(operation) {
|
|
320
359
|
const cacheKey = operation + (this._dataTypeScope ? ':' + this._dataTypeScope : '');
|
|
321
360
|
let validator = this._outputCodecs[cacheKey];
|
|
322
361
|
if (validator)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/elastic",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Opra Elastic Search adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@elastic/elasticsearch": ">=8.7.0",
|
|
14
|
-
"@opra/common": "^1.
|
|
15
|
-
"@opra/core": "^1.
|
|
14
|
+
"@opra/common": "^1.7.1",
|
|
15
|
+
"@opra/core": "^1.7.1"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@opra/core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { estypes } from '@elastic/elasticsearch';
|
|
3
3
|
import { type ElasticAdapter } from '../elastic-adapter.js';
|
|
4
|
-
export default function prepareFilter(filters: ElasticAdapter.FilterInput | ElasticAdapter.FilterInput[]): QueryDslQueryContainer | undefined;
|
|
4
|
+
export default function prepareFilter(filters: ElasticAdapter.FilterInput | ElasticAdapter.FilterInput[]): estypes.QueryDslQueryContainer | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { estypes } from '@elastic/elasticsearch';
|
|
2
2
|
import { OpraFilter } from '@opra/common';
|
|
3
3
|
import type { ExecutionContext } from '@opra/core';
|
|
4
4
|
import _prepareFilter from './adapter-utils/prepare-filter.js';
|
|
@@ -6,7 +6,7 @@ import _preparePatch from './adapter-utils/prepare-patch.js';
|
|
|
6
6
|
import _prepareProjection from './adapter-utils/prepare-projection.js';
|
|
7
7
|
import _prepareSort from './adapter-utils/prepare-sort.js';
|
|
8
8
|
export declare namespace ElasticAdapter {
|
|
9
|
-
type FilterInput = OpraFilter.Expression | QueryDslQueryContainer | string | undefined;
|
|
9
|
+
type FilterInput = OpraFilter.Expression | estypes.QueryDslQueryContainer | string | undefined;
|
|
10
10
|
const prepareFilter: typeof _prepareFilter;
|
|
11
11
|
const preparePatch: typeof _preparePatch;
|
|
12
12
|
const prepareProjection: typeof _prepareProjection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { estypes } from '@elastic/elasticsearch';
|
|
2
2
|
import { ExecutionContext, ServiceBase } from '@opra/core';
|
|
3
3
|
import type { Nullish, PartialDTO, PatchDTO, RequiredSome, Type } from 'ts-gems';
|
|
4
4
|
import { ElasticAdapter } from './elastic-adapter.js';
|
|
@@ -23,7 +23,7 @@ export declare namespace ElasticCollectionService {
|
|
|
23
23
|
interface FindManyWithCountResult<X> {
|
|
24
24
|
items: X[];
|
|
25
25
|
count: number;
|
|
26
|
-
relation:
|
|
26
|
+
relation: estypes.SearchTotalHitsRelation;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -70,7 +70,7 @@ export declare class ElasticCollectionService<T extends object = any> extends El
|
|
|
70
70
|
* @returns {Promise<PartialDTO<T>>} A promise that resolves to the created document.
|
|
71
71
|
* @throws {Error} if an unknown error occurs while creating the document.
|
|
72
72
|
*/
|
|
73
|
-
create(input: PartialDTO<T>, options?: ElasticEntityService.CreateOptions): Promise<
|
|
73
|
+
create(input: PartialDTO<T>, options?: ElasticEntityService.CreateOptions): Promise<estypes.CreateResponse>;
|
|
74
74
|
/**
|
|
75
75
|
* Returns the count of documents in the collection based on the provided options.
|
|
76
76
|
*
|
|
@@ -85,14 +85,14 @@ export declare class ElasticCollectionService<T extends object = any> extends El
|
|
|
85
85
|
* @param {ElasticEntityService.DeleteOptions} [options] - Optional delete options.
|
|
86
86
|
* @return {Promise<number>} - A Promise that resolves to the number of documents deleted.
|
|
87
87
|
*/
|
|
88
|
-
delete(id: string, options?: ElasticEntityService.DeleteOptions): Promise<
|
|
88
|
+
delete(id: string, options?: ElasticEntityService.DeleteOptions): Promise<estypes.DeleteByQueryResponse>;
|
|
89
89
|
/**
|
|
90
90
|
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
91
91
|
*
|
|
92
92
|
* @param {ElasticEntityService.DeleteManyOptions} options - The options for the delete operation.
|
|
93
93
|
* @return {Promise<number>} - A promise that resolves to the number of documents deleted.
|
|
94
94
|
*/
|
|
95
|
-
deleteMany(options?: ElasticEntityService.DeleteManyOptions): Promise<
|
|
95
|
+
deleteMany(options?: ElasticEntityService.DeleteManyOptions): Promise<estypes.DeleteByQueryResponse>;
|
|
96
96
|
/**
|
|
97
97
|
* Checks if an object with the given id exists.
|
|
98
98
|
*
|
|
@@ -152,6 +152,7 @@ export declare class ElasticCollectionService<T extends object = any> extends El
|
|
|
152
152
|
* @return {Promise<T | undefined>} A Promise that resolves to an array of partial outputs of type T.
|
|
153
153
|
*/
|
|
154
154
|
findMany(options?: ElasticEntityService.FindManyOptions): Promise<T[]>;
|
|
155
|
+
searchRaw(request: estypes.SearchRequest, options?: ElasticEntityService.SearchOptions): Promise<estypes.SearchResponse<PartialDTO<T>>>;
|
|
155
156
|
/**
|
|
156
157
|
* Finds multiple documents in the collection and returns both records (max limit)
|
|
157
158
|
* and total count that matched the given criteria
|
|
@@ -194,9 +195,9 @@ export declare class ElasticCollectionService<T extends object = any> extends El
|
|
|
194
195
|
* @param {string} id - The ID of the document to update.
|
|
195
196
|
* @param {PatchDTO<T>} input - The partial input data to update the document with.
|
|
196
197
|
* @param {ElasticEntityService.UpdateOneOptions} [options] - The options for updating the document.
|
|
197
|
-
* @returns {Promise<
|
|
198
|
+
* @returns {Promise<estypes.UpdateResponse>} - A promise that resolves to the number of documents modified.
|
|
198
199
|
*/
|
|
199
|
-
update(id: string, input: PatchDTO<T>, options?: ElasticEntityService.UpdateOneOptions): Promise<
|
|
200
|
+
update(id: string, input: PatchDTO<T>, options?: ElasticEntityService.UpdateOneOptions): Promise<estypes.UpdateByQueryResponse>;
|
|
200
201
|
/**
|
|
201
202
|
* Updates multiple documents in the collection based on the specified input and options.
|
|
202
203
|
*
|
|
@@ -204,7 +205,7 @@ export declare class ElasticCollectionService<T extends object = any> extends El
|
|
|
204
205
|
* @param {ElasticEntityService.UpdateManyOptions} options - The options for updating the documents.
|
|
205
206
|
* @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
|
|
206
207
|
*/
|
|
207
|
-
updateMany(input: PatchDTO<T>, options?: ElasticEntityService.UpdateManyOptions): Promise<
|
|
208
|
+
updateMany(input: PatchDTO<T>, options?: ElasticEntityService.UpdateManyOptions): Promise<estypes.UpdateByQueryResponse>;
|
|
208
209
|
/**
|
|
209
210
|
* Retrieves the common filter used for querying documents.
|
|
210
211
|
* This method is mostly used for security issues like securing multi-tenant applications.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { estypes } from '@elastic/elasticsearch';
|
|
2
2
|
import type { TransportRequestOptions } from '@elastic/transport';
|
|
3
3
|
import { ComplexType } from '@opra/common';
|
|
4
4
|
import type { PartialDTO, PatchDTO, RequiredSome, StrictOmit, Type } from 'ts-gems';
|
|
@@ -30,7 +30,7 @@ export declare namespace ElasticEntityService {
|
|
|
30
30
|
* @interface
|
|
31
31
|
*/
|
|
32
32
|
interface CreateOptions {
|
|
33
|
-
request?:
|
|
33
|
+
request?: estypes.CreateRequest;
|
|
34
34
|
transport?: TransportRequestOptions;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -41,7 +41,7 @@ export declare namespace ElasticEntityService {
|
|
|
41
41
|
*/
|
|
42
42
|
interface CountOptions {
|
|
43
43
|
filter?: ElasticAdapter.FilterInput;
|
|
44
|
-
request?:
|
|
44
|
+
request?: estypes.CountRequest;
|
|
45
45
|
transport?: TransportRequestOptions;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -52,7 +52,7 @@ export declare namespace ElasticEntityService {
|
|
|
52
52
|
*/
|
|
53
53
|
interface DeleteOptions {
|
|
54
54
|
filter?: ElasticAdapter.FilterInput;
|
|
55
|
-
request?:
|
|
55
|
+
request?: estypes.DeleteByQueryRequest;
|
|
56
56
|
transport?: TransportRequestOptions;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -63,7 +63,7 @@ export declare namespace ElasticEntityService {
|
|
|
63
63
|
*/
|
|
64
64
|
interface DeleteManyOptions {
|
|
65
65
|
filter?: ElasticAdapter.FilterInput;
|
|
66
|
-
request?:
|
|
66
|
+
request?: estypes.DeleteByQueryRequest;
|
|
67
67
|
transport?: TransportRequestOptions;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
@@ -86,8 +86,18 @@ export declare namespace ElasticEntityService {
|
|
|
86
86
|
sort?: string[];
|
|
87
87
|
limit?: number;
|
|
88
88
|
skip?: number;
|
|
89
|
-
request?:
|
|
89
|
+
request?: estypes.SearchRequest;
|
|
90
90
|
transport?: TransportRequestOptions;
|
|
91
|
+
noDecode?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Represents options for "search" operation
|
|
95
|
+
*
|
|
96
|
+
* @interface
|
|
97
|
+
*/
|
|
98
|
+
interface SearchOptions {
|
|
99
|
+
transport?: TransportRequestOptions;
|
|
100
|
+
noDecode?: boolean;
|
|
91
101
|
}
|
|
92
102
|
/**
|
|
93
103
|
* Represents options for "update" operation
|
|
@@ -97,7 +107,7 @@ export declare namespace ElasticEntityService {
|
|
|
97
107
|
*/
|
|
98
108
|
interface UpdateOneOptions {
|
|
99
109
|
filter?: ElasticAdapter.FilterInput;
|
|
100
|
-
request?:
|
|
110
|
+
request?: estypes.UpdateByQueryRequest;
|
|
101
111
|
transport?: TransportRequestOptions;
|
|
102
112
|
}
|
|
103
113
|
/**
|
|
@@ -108,7 +118,7 @@ export declare namespace ElasticEntityService {
|
|
|
108
118
|
*/
|
|
109
119
|
interface UpdateManyOptions {
|
|
110
120
|
filter?: ElasticAdapter.FilterInput;
|
|
111
|
-
request?:
|
|
121
|
+
request?: estypes.UpdateByQueryRequest;
|
|
112
122
|
transport?: TransportRequestOptions;
|
|
113
123
|
}
|
|
114
124
|
interface CreateCommand extends StrictOmit<RequiredSome<CommandInfo, 'input'>, 'documentId'> {
|
|
@@ -131,11 +141,17 @@ export declare namespace ElasticEntityService {
|
|
|
131
141
|
crud: 'read';
|
|
132
142
|
options?: FindManyOptions;
|
|
133
143
|
}
|
|
144
|
+
interface SearchCommand extends StrictOmit<CommandInfo, 'input'> {
|
|
145
|
+
crud: 'read';
|
|
146
|
+
request: estypes.SearchRequest;
|
|
147
|
+
options?: SearchOptions;
|
|
148
|
+
}
|
|
134
149
|
interface UpdateCommand<T> extends CommandInfo {
|
|
135
150
|
crud: 'update';
|
|
136
151
|
input: PatchDTO<T>;
|
|
137
152
|
options?: UpdateOneOptions;
|
|
138
153
|
}
|
|
154
|
+
type SearchResponse<T> = estypes.SearchResponse<T>;
|
|
139
155
|
}
|
|
140
156
|
/**
|
|
141
157
|
* @class ElasticEntityService
|
|
@@ -203,40 +219,47 @@ export declare class ElasticEntityService<T extends object = any> extends Elasti
|
|
|
203
219
|
* @param {ElasticEntityService.CreateCommand} command
|
|
204
220
|
* @protected
|
|
205
221
|
*/
|
|
206
|
-
protected _create(command: ElasticEntityService.CreateCommand): Promise<
|
|
222
|
+
protected _create(command: ElasticEntityService.CreateCommand): Promise<estypes.CreateResponse>;
|
|
207
223
|
/**
|
|
208
224
|
* Returns the count of documents in the collection based on the provided options.
|
|
209
225
|
*
|
|
210
226
|
* @param {ElasticEntityService.CountCommand} command
|
|
211
227
|
* @protected
|
|
212
228
|
*/
|
|
213
|
-
protected _count(command: ElasticEntityService.CountCommand): Promise<
|
|
229
|
+
protected _count(command: ElasticEntityService.CountCommand): Promise<estypes.CountResponse>;
|
|
214
230
|
/**
|
|
215
231
|
* Deletes a document from the collection.
|
|
216
232
|
*
|
|
217
233
|
* @param {ElasticEntityService.DeleteCommand} command
|
|
218
234
|
* @protected
|
|
219
235
|
*/
|
|
220
|
-
protected _delete(command: ElasticEntityService.DeleteCommand): Promise<
|
|
236
|
+
protected _delete(command: ElasticEntityService.DeleteCommand): Promise<estypes.DeleteByQueryResponse>;
|
|
221
237
|
/**
|
|
222
238
|
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
223
239
|
*
|
|
224
240
|
* @param {ElasticEntityService.DeleteManyCommand} command
|
|
225
241
|
* @protected
|
|
226
242
|
*/
|
|
227
|
-
protected _deleteMany(command: ElasticEntityService.DeleteManyCommand): Promise<
|
|
243
|
+
protected _deleteMany(command: ElasticEntityService.DeleteManyCommand): Promise<estypes.DeleteByQueryResponse>;
|
|
228
244
|
/**
|
|
229
245
|
* Returns search hits that match the query defined in the request
|
|
230
246
|
*
|
|
231
247
|
* @param {ElasticEntityService.FindManyCommand} command
|
|
232
248
|
*/
|
|
233
|
-
protected _findMany(command: ElasticEntityService.FindManyCommand): Promise<
|
|
249
|
+
protected _findMany(command: ElasticEntityService.FindManyCommand): Promise<ElasticEntityService.SearchResponse<PartialDTO<T>>>;
|
|
250
|
+
/**
|
|
251
|
+
* Executes a search operation on the Elasticsearch index using the provided search command.
|
|
252
|
+
*
|
|
253
|
+
* @param {ElasticEntityService.SearchCommand} command - The search command containing the request configuration and optional transport settings.
|
|
254
|
+
* @return {Promise<ElasticEntityService.SearchResponse>} A promise resolving to the search response from Elasticsearch.
|
|
255
|
+
*/
|
|
256
|
+
protected _searchRaw(command: ElasticEntityService.SearchCommand): Promise<ElasticEntityService.SearchResponse<PartialDTO<T>>>;
|
|
234
257
|
/**
|
|
235
258
|
* Updates multiple documents in the collection based on the specified input and options.
|
|
236
259
|
*
|
|
237
260
|
* @param {ElasticEntityService.UpdateCommand<T>} command
|
|
238
261
|
*/
|
|
239
|
-
protected _updateMany(command: ElasticEntityService.UpdateCommand<T>): Promise<
|
|
262
|
+
protected _updateMany(command: ElasticEntityService.UpdateCommand<T>): Promise<estypes.UpdateByQueryResponse>;
|
|
240
263
|
/**
|
|
241
264
|
* Generates an ID.
|
|
242
265
|
*
|
|
@@ -253,7 +276,7 @@ export declare class ElasticEntityService<T extends object = any> extends Elasti
|
|
|
253
276
|
/**
|
|
254
277
|
* Retrieves the codec.
|
|
255
278
|
*/
|
|
256
|
-
|
|
279
|
+
getOutputCodec(operation: string): IsObject.Validator<T>;
|
|
257
280
|
protected _executeCommand(command: ElasticEntityService.CommandInfo, commandFn: () => any): Promise<any>;
|
|
258
281
|
protected _beforeCreate(command: ElasticEntityService.CreateCommand): Promise<void>;
|
|
259
282
|
protected _beforeUpdate(command: ElasticEntityService.UpdateCommand<T>): Promise<void>;
|