@opra/elastic 1.12.5 → 1.12.6
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.
|
@@ -101,16 +101,19 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
101
101
|
id: input._id,
|
|
102
102
|
document: doc,
|
|
103
103
|
};
|
|
104
|
-
const
|
|
105
|
-
const r = options?.replaceIfExists
|
|
106
|
-
? await client.index(request, options?.transport)
|
|
107
|
-
: await client.create(request, options?.transport);
|
|
104
|
+
const r = await this.__create(request, options);
|
|
108
105
|
/* istanbul ignore next */
|
|
109
106
|
if (!(r._id && (r.result === 'created' || r.result === 'updated'))) {
|
|
110
107
|
throw new common_1.InternalServerError(`Unknown error while creating document for "${this.getResourceName()}"`);
|
|
111
108
|
}
|
|
112
109
|
return r;
|
|
113
110
|
}
|
|
111
|
+
async __create(request, options) {
|
|
112
|
+
const client = this.getClient();
|
|
113
|
+
return options?.replaceIfExists
|
|
114
|
+
? await client.index(request, options?.transport)
|
|
115
|
+
: await client.create(request, options?.transport);
|
|
116
|
+
}
|
|
114
117
|
/**
|
|
115
118
|
* Returns the count of documents in the collection based on the provided options.
|
|
116
119
|
*
|
|
@@ -134,6 +137,9 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
134
137
|
...options?.request,
|
|
135
138
|
query,
|
|
136
139
|
};
|
|
140
|
+
return this.__count(request, options);
|
|
141
|
+
}
|
|
142
|
+
__count(request, options) {
|
|
137
143
|
const client = this.getClient();
|
|
138
144
|
return client.count(request, options?.transport);
|
|
139
145
|
}
|
|
@@ -162,8 +168,7 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
162
168
|
...options?.request,
|
|
163
169
|
query,
|
|
164
170
|
};
|
|
165
|
-
|
|
166
|
-
return client.deleteByQuery(request, options?.transport);
|
|
171
|
+
return this.__delete(request, options);
|
|
167
172
|
}
|
|
168
173
|
/**
|
|
169
174
|
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
@@ -188,6 +193,9 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
188
193
|
index: this.getIndexName(),
|
|
189
194
|
query,
|
|
190
195
|
};
|
|
196
|
+
return await this.__delete(request, options);
|
|
197
|
+
}
|
|
198
|
+
async __delete(request, options) {
|
|
191
199
|
const client = this.getClient();
|
|
192
200
|
return client.deleteByQuery(request, options?.transport);
|
|
193
201
|
}
|
|
@@ -219,8 +227,7 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
219
227
|
...options?.request,
|
|
220
228
|
query,
|
|
221
229
|
};
|
|
222
|
-
const
|
|
223
|
-
const r = await client.search(request, options?.transport);
|
|
230
|
+
const r = await this.__findMany(request, options);
|
|
224
231
|
if (options?.noDecode)
|
|
225
232
|
return r;
|
|
226
233
|
if (r.hits.hits?.length) {
|
|
@@ -235,6 +242,10 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
235
242
|
}
|
|
236
243
|
return r;
|
|
237
244
|
}
|
|
245
|
+
async __findMany(request, options) {
|
|
246
|
+
const client = this.getClient();
|
|
247
|
+
return client.search(request, options?.transport);
|
|
248
|
+
}
|
|
238
249
|
/**
|
|
239
250
|
* Executes a search operation on the Elasticsearch index using the provided search command.
|
|
240
251
|
*
|
|
@@ -317,6 +328,9 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
317
328
|
script,
|
|
318
329
|
query,
|
|
319
330
|
};
|
|
331
|
+
return await this.__update(request, options);
|
|
332
|
+
}
|
|
333
|
+
async __update(request, options) {
|
|
320
334
|
const client = this.getClient();
|
|
321
335
|
return client.updateByQuery(request, options?.transport);
|
|
322
336
|
}
|
|
@@ -98,16 +98,19 @@ export class ElasticEntityService extends ElasticService {
|
|
|
98
98
|
id: input._id,
|
|
99
99
|
document: doc,
|
|
100
100
|
};
|
|
101
|
-
const
|
|
102
|
-
const r = options?.replaceIfExists
|
|
103
|
-
? await client.index(request, options?.transport)
|
|
104
|
-
: await client.create(request, options?.transport);
|
|
101
|
+
const r = await this.__create(request, options);
|
|
105
102
|
/* istanbul ignore next */
|
|
106
103
|
if (!(r._id && (r.result === 'created' || r.result === 'updated'))) {
|
|
107
104
|
throw new InternalServerError(`Unknown error while creating document for "${this.getResourceName()}"`);
|
|
108
105
|
}
|
|
109
106
|
return r;
|
|
110
107
|
}
|
|
108
|
+
async __create(request, options) {
|
|
109
|
+
const client = this.getClient();
|
|
110
|
+
return options?.replaceIfExists
|
|
111
|
+
? await client.index(request, options?.transport)
|
|
112
|
+
: await client.create(request, options?.transport);
|
|
113
|
+
}
|
|
111
114
|
/**
|
|
112
115
|
* Returns the count of documents in the collection based on the provided options.
|
|
113
116
|
*
|
|
@@ -131,6 +134,9 @@ export class ElasticEntityService extends ElasticService {
|
|
|
131
134
|
...options?.request,
|
|
132
135
|
query,
|
|
133
136
|
};
|
|
137
|
+
return this.__count(request, options);
|
|
138
|
+
}
|
|
139
|
+
__count(request, options) {
|
|
134
140
|
const client = this.getClient();
|
|
135
141
|
return client.count(request, options?.transport);
|
|
136
142
|
}
|
|
@@ -159,8 +165,7 @@ export class ElasticEntityService extends ElasticService {
|
|
|
159
165
|
...options?.request,
|
|
160
166
|
query,
|
|
161
167
|
};
|
|
162
|
-
|
|
163
|
-
return client.deleteByQuery(request, options?.transport);
|
|
168
|
+
return this.__delete(request, options);
|
|
164
169
|
}
|
|
165
170
|
/**
|
|
166
171
|
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
@@ -185,6 +190,9 @@ export class ElasticEntityService extends ElasticService {
|
|
|
185
190
|
index: this.getIndexName(),
|
|
186
191
|
query,
|
|
187
192
|
};
|
|
193
|
+
return await this.__delete(request, options);
|
|
194
|
+
}
|
|
195
|
+
async __delete(request, options) {
|
|
188
196
|
const client = this.getClient();
|
|
189
197
|
return client.deleteByQuery(request, options?.transport);
|
|
190
198
|
}
|
|
@@ -216,8 +224,7 @@ export class ElasticEntityService extends ElasticService {
|
|
|
216
224
|
...options?.request,
|
|
217
225
|
query,
|
|
218
226
|
};
|
|
219
|
-
const
|
|
220
|
-
const r = await client.search(request, options?.transport);
|
|
227
|
+
const r = await this.__findMany(request, options);
|
|
221
228
|
if (options?.noDecode)
|
|
222
229
|
return r;
|
|
223
230
|
if (r.hits.hits?.length) {
|
|
@@ -232,6 +239,10 @@ export class ElasticEntityService extends ElasticService {
|
|
|
232
239
|
}
|
|
233
240
|
return r;
|
|
234
241
|
}
|
|
242
|
+
async __findMany(request, options) {
|
|
243
|
+
const client = this.getClient();
|
|
244
|
+
return client.search(request, options?.transport);
|
|
245
|
+
}
|
|
235
246
|
/**
|
|
236
247
|
* Executes a search operation on the Elasticsearch index using the provided search command.
|
|
237
248
|
*
|
|
@@ -314,6 +325,9 @@ export class ElasticEntityService extends ElasticService {
|
|
|
314
325
|
script,
|
|
315
326
|
query,
|
|
316
327
|
};
|
|
328
|
+
return await this.__update(request, options);
|
|
329
|
+
}
|
|
330
|
+
async __update(request, options) {
|
|
317
331
|
const client = this.getClient();
|
|
318
332
|
return client.updateByQuery(request, options?.transport);
|
|
319
333
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/elastic",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.6",
|
|
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 <9",
|
|
14
|
-
"@opra/common": "^1.12.
|
|
15
|
-
"@opra/core": "^1.12.
|
|
14
|
+
"@opra/common": "^1.12.6",
|
|
15
|
+
"@opra/core": "^1.12.6"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
@@ -232,6 +232,7 @@ export declare class ElasticEntityService<T extends object = any> extends Elasti
|
|
|
232
232
|
* @protected
|
|
233
233
|
*/
|
|
234
234
|
protected _create(command: ElasticEntityService.CreateCommand): Promise<ElasticEntityService.CreateResponse>;
|
|
235
|
+
protected __create(request: ElasticEntityService.CreateRequest, options?: ElasticEntityService.CreateOptions): Promise<estypes.WriteResponseBase>;
|
|
235
236
|
/**
|
|
236
237
|
* Returns the count of documents in the collection based on the provided options.
|
|
237
238
|
*
|
|
@@ -239,6 +240,7 @@ export declare class ElasticEntityService<T extends object = any> extends Elasti
|
|
|
239
240
|
* @protected
|
|
240
241
|
*/
|
|
241
242
|
protected _count(command: ElasticEntityService.CountCommand): Promise<ElasticEntityService.CountResponse>;
|
|
243
|
+
protected __count(request: ElasticEntityService.CountRequest, options?: ElasticEntityService.CountOptions): Promise<estypes.CountResponse>;
|
|
242
244
|
/**
|
|
243
245
|
* Deletes a document from the collection.
|
|
244
246
|
*
|
|
@@ -253,12 +255,14 @@ export declare class ElasticEntityService<T extends object = any> extends Elasti
|
|
|
253
255
|
* @protected
|
|
254
256
|
*/
|
|
255
257
|
protected _deleteMany(command: ElasticEntityService.DeleteManyCommand): Promise<ElasticEntityService.DeleteByQueryResponse>;
|
|
258
|
+
protected __delete(request: ElasticEntityService.DeleteByQueryRequest, options?: ElasticEntityService.DeleteOptions): Promise<estypes.DeleteByQueryResponse>;
|
|
256
259
|
/**
|
|
257
260
|
* Returns search hits that match the query defined in the request
|
|
258
261
|
*
|
|
259
262
|
* @param {ElasticEntityService.FindManyCommand} command
|
|
260
263
|
*/
|
|
261
264
|
protected _findMany(command: ElasticEntityService.FindManyCommand): Promise<ElasticEntityService.SearchResponse<PartialDTO<T>>>;
|
|
265
|
+
protected __findMany(request: ElasticEntityService.SearchRequest, options?: ElasticEntityService.FindManyOptions): Promise<estypes.SearchResponse<T, Record<string, estypes.AggregationsAggregate>>>;
|
|
262
266
|
/**
|
|
263
267
|
* Executes a search operation on the Elasticsearch index using the provided search command.
|
|
264
268
|
*
|
|
@@ -272,6 +276,7 @@ export declare class ElasticEntityService<T extends object = any> extends Elasti
|
|
|
272
276
|
* @param {ElasticEntityService.UpdateCommand<T>} command
|
|
273
277
|
*/
|
|
274
278
|
protected _updateMany(command: ElasticEntityService.UpdateCommand<T>): Promise<ElasticEntityService.UpdateByQueryResponse>;
|
|
279
|
+
protected __update(request: ElasticEntityService.UpdateByQueryRequest, options?: ElasticEntityService.UpdateManyOptions): Promise<estypes.UpdateByQueryResponse>;
|
|
275
280
|
/**
|
|
276
281
|
* Generates an ID.
|
|
277
282
|
*
|