@webiny/api-headless-cms-ddb-es 5.19.0-beta.2 → 5.19.0-beta.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.
@@ -131,12 +131,8 @@ const createInitialQueryValue = args => {
131
131
  }
132
132
  });
133
133
  } // we do not allow not published and not latest
134
- else if (where.published === false) {
135
- throw new _error.default(`Cannot call Elasticsearch query with "published" set at false.`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
136
- where
137
- });
138
- } else if (where.latest === false) {
139
- throw new _error.default(`Cannot call Elasticsearch query with "latest" set at false.`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
134
+ else {
135
+ throw new _error.default(`Cannot call Elasticsearch query when not setting "published" or "latest".`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
140
136
  where
141
137
  });
142
138
  } //
@@ -627,7 +627,7 @@ const createEntriesStorageOperations = params => {
627
627
  model
628
628
  });
629
629
 
630
- if (publishedStorageEntry) {
630
+ if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
631
631
  /**
632
632
  * If there is a `published` entry already, we need to set it to `unpublished`. We need to
633
633
  * execute two updates: update the previously published entry's status and the published entry record.
@@ -126,7 +126,7 @@ const createModelsStorageOperations = params => {
126
126
  }));
127
127
  return model;
128
128
  } catch (ex) {
129
- throw new _error.default(ex.messatge || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
129
+ throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
130
130
  error: ex,
131
131
  model,
132
132
  original,
@@ -143,14 +143,35 @@ const createModelsStorageOperations = params => {
143
143
 
144
144
  try {
145
145
  await entity.delete(keys);
146
- return model;
147
146
  } catch (ex) {
148
- throw new _error.default(ex.messatge || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
147
+ throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
149
148
  error: ex,
150
149
  model,
151
150
  keys
152
151
  });
153
152
  }
153
+
154
+ const {
155
+ index
156
+ } = _configurations.default.es({
157
+ model
158
+ });
159
+ /**
160
+ * In case of DynamoDB error we need to remove the index we created.
161
+ */
162
+
163
+
164
+ try {
165
+ await elasticsearch.indices.delete({
166
+ index
167
+ });
168
+ } catch (ex) {
169
+ throw new _error.default(`Could not delete elasticsearch index "${index}" after model record was deleted.`, "DELETE_MODEL_INDICE_ERROR", {
170
+ error: ex
171
+ });
172
+ }
173
+
174
+ return model;
154
175
  };
155
176
 
156
177
  const get = async params => {
@@ -163,7 +184,7 @@ const createModelsStorageOperations = params => {
163
184
  });
164
185
  return (0, _cleanup.cleanupItem)(entity, item);
165
186
  } catch (ex) {
166
- throw new _error.default(ex.messatge || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
187
+ throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
167
188
  error: ex,
168
189
  keys
169
190
  });
@@ -186,7 +207,7 @@ const createModelsStorageOperations = params => {
186
207
  const items = await (0, _query.queryAll)(queryAllParams);
187
208
  return (0, _cleanup.cleanupItems)(entity, items);
188
209
  } catch (ex) {
189
- throw new _error.default(ex.messatge || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
210
+ throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
190
211
  error: ex,
191
212
  partitionKey: queryAllParams.partitionKey
192
213
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb-es",
3
- "version": "5.19.0-beta.2",
3
+ "version": "5.19.0-beta.6",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-headless-cms",
@@ -23,15 +23,15 @@
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
25
  "@babel/runtime": "7.16.3",
26
- "@webiny/api-headless-cms": "5.19.0-beta.2",
27
- "@webiny/api-upgrade": "5.19.0-beta.2",
28
- "@webiny/db-dynamodb": "5.19.0-beta.2",
29
- "@webiny/error": "5.19.0-beta.2",
30
- "@webiny/handler": "5.19.0-beta.2",
31
- "@webiny/handler-aws": "5.19.0-beta.2",
32
- "@webiny/handler-db": "5.19.0-beta.2",
33
- "@webiny/plugins": "5.19.0-beta.2",
34
- "@webiny/utils": "5.19.0-beta.2",
26
+ "@webiny/api-headless-cms": "5.19.0-beta.6",
27
+ "@webiny/api-upgrade": "5.19.0-beta.6",
28
+ "@webiny/db-dynamodb": "5.19.0-beta.6",
29
+ "@webiny/error": "5.19.0-beta.6",
30
+ "@webiny/handler": "5.19.0-beta.6",
31
+ "@webiny/handler-aws": "5.19.0-beta.6",
32
+ "@webiny/handler-db": "5.19.0-beta.6",
33
+ "@webiny/plugins": "5.19.0-beta.6",
34
+ "@webiny/utils": "5.19.0-beta.6",
35
35
  "dataloader": "2.0.0",
36
36
  "dynamodb-toolbox": "0.3.5",
37
37
  "jsonpack": "1.1.5",
@@ -47,10 +47,10 @@
47
47
  "@elastic/elasticsearch": "7.12.0",
48
48
  "@shelf/jest-elasticsearch": "^1.0.0",
49
49
  "@types/jsonpack": "^1.1.0",
50
- "@webiny/api-dynamodb-to-elasticsearch": "^5.19.0-beta.2",
51
- "@webiny/api-elasticsearch": "^5.19.0-beta.2",
52
- "@webiny/cli": "^5.19.0-beta.2",
53
- "@webiny/project-utils": "^5.19.0-beta.2",
50
+ "@webiny/api-dynamodb-to-elasticsearch": "^5.19.0-beta.6",
51
+ "@webiny/api-elasticsearch": "^5.19.0-beta.6",
52
+ "@webiny/cli": "^5.19.0-beta.6",
53
+ "@webiny/project-utils": "^5.19.0-beta.6",
54
54
  "jest": "^26.6.3",
55
55
  "jest-dynalite": "^3.2.0",
56
56
  "jest-environment-node": "^26.6.2",
@@ -69,5 +69,5 @@
69
69
  "build": "yarn webiny run build",
70
70
  "watch": "yarn webiny run watch"
71
71
  },
72
- "gitHead": "6817702cc537405b7288c1fc63ee5d40531b4122"
72
+ "gitHead": "703856f6067cde3dd2894023f5bba3aaedbf7937"
73
73
  }