@opra/elastic 1.11.1 → 1.12.0

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.
@@ -102,7 +102,9 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
102
102
  document: doc,
103
103
  };
104
104
  const client = this.getClient();
105
- const r = await client.create(request, options?.transport);
105
+ const r = options?.replaceIfExists
106
+ ? await client.index(request, options?.transport)
107
+ : await client.create(request, options?.transport);
106
108
  /* istanbul ignore next */
107
109
  if (!(r._id && (r.result === 'created' || r.result === 'updated'))) {
108
110
  throw new common_1.InternalServerError(`Unknown error while creating document for "${this.getResourceName()}"`);
@@ -99,7 +99,9 @@ export class ElasticEntityService extends ElasticService {
99
99
  document: doc,
100
100
  };
101
101
  const client = this.getClient();
102
- const r = await client.create(request, options?.transport);
102
+ const r = options?.replaceIfExists
103
+ ? await client.index(request, options?.transport)
104
+ : await client.create(request, options?.transport);
103
105
  /* istanbul ignore next */
104
106
  if (!(r._id && (r.result === 'created' || r.result === 'updated'))) {
105
107
  throw new InternalServerError(`Unknown error while creating document for "${this.getResourceName()}"`);
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@opra/elastic",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "Opra Elastic Search adapter package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@jsopen/objects": "^1.5.0",
8
+ "@jsopen/objects": "^1.5.2",
9
9
  "tslib": "^2.8.1",
10
10
  "valgen": "^5.13.0"
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@elastic/elasticsearch": ">=8.7.0 <9",
14
- "@opra/common": "^1.11.1",
15
- "@opra/core": "^1.11.1"
14
+ "@opra/common": "^1.12.0",
15
+ "@opra/core": "^1.12.0"
16
16
  },
17
17
  "type": "module",
18
18
  "exports": {
@@ -32,6 +32,7 @@ export declare namespace ElasticEntityService {
32
32
  interface CreateOptions {
33
33
  request?: estypes.CreateRequest;
34
34
  transport?: TransportRequestOptions;
35
+ replaceIfExists?: boolean;
35
36
  }
36
37
  /**
37
38
  * Represents options for "count" operation