@webiny/api-headless-cms 5.19.0-beta.3 → 5.19.0-beta.4

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.
@@ -116,6 +116,20 @@ const buildReferenceFieldPaths = params => {
116
116
  }, []);
117
117
  };
118
118
 
119
+ const getReferenceFieldValue = ref => {
120
+ if (!ref) {
121
+ return {
122
+ id: null,
123
+ modelId: null
124
+ };
125
+ }
126
+
127
+ return {
128
+ id: (ref.id || ref.entryId || "").trim() || null,
129
+ modelId: (ref.modelId || "").trim() || null
130
+ };
131
+ };
132
+
119
133
  const referenceFieldsMapping = async params => {
120
134
  const {
121
135
  context,
@@ -141,21 +155,26 @@ const referenceFieldsMapping = async params => {
141
155
  for (const path of referenceFieldPaths) {
142
156
  const ref = _dotProp.default.get(output, path);
143
157
 
144
- if (!ref || !ref.id || !ref.modelId) {
158
+ const {
159
+ id,
160
+ modelId
161
+ } = getReferenceFieldValue(ref);
162
+
163
+ if (!id || !modelId) {
145
164
  continue;
146
165
  }
147
166
 
148
- if (!referencesByModel[ref.modelId]) {
149
- referencesByModel[ref.modelId] = [];
167
+ if (!referencesByModel[modelId]) {
168
+ referencesByModel[modelId] = [];
150
169
  }
151
170
 
152
- referencesByModel[ref.modelId].push(ref.id);
171
+ referencesByModel[modelId].push(id);
153
172
 
154
- if (!pathsByReferenceId[ref.id]) {
155
- pathsByReferenceId[ref.id] = [];
173
+ if (!pathsByReferenceId[id]) {
174
+ pathsByReferenceId[id] = [];
156
175
  }
157
176
 
158
- pathsByReferenceId[ref.id].push(path);
177
+ pathsByReferenceId[id].push(path);
159
178
  }
160
179
  /**
161
180
  * Again, no point in going further.
@@ -35,7 +35,8 @@ const assignBeforeModelDelete = params => {
35
35
  const result = await storageOperations.entries.list(model, {
36
36
  where: {
37
37
  tenant: model.tenant,
38
- locale: model.locale
38
+ locale: model.locale,
39
+ latest: true
39
40
  },
40
41
  limit: 1
41
42
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "5.19.0-beta.3",
3
+ "version": "5.19.0-beta.4",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "cms:base"
@@ -21,23 +21,23 @@
21
21
  "@babel/runtime": "7.16.3",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
23
  "@graphql-tools/schema": "7.1.5",
24
- "@webiny/api-file-manager": "5.19.0-beta.3",
25
- "@webiny/api-i18n": "5.19.0-beta.3",
26
- "@webiny/api-i18n-content": "5.19.0-beta.3",
27
- "@webiny/api-i18n-ddb": "5.19.0-beta.3",
28
- "@webiny/api-security": "5.19.0-beta.3",
29
- "@webiny/api-tenancy": "5.19.0-beta.3",
30
- "@webiny/api-upgrade": "5.19.0-beta.3",
31
- "@webiny/error": "5.19.0-beta.3",
32
- "@webiny/handler": "5.19.0-beta.3",
33
- "@webiny/handler-aws": "5.19.0-beta.3",
34
- "@webiny/handler-db": "5.19.0-beta.3",
35
- "@webiny/handler-graphql": "5.19.0-beta.3",
36
- "@webiny/handler-http": "5.19.0-beta.3",
37
- "@webiny/plugins": "5.19.0-beta.3",
38
- "@webiny/pubsub": "5.19.0-beta.3",
39
- "@webiny/utils": "5.19.0-beta.3",
40
- "@webiny/validation": "5.19.0-beta.3",
24
+ "@webiny/api-file-manager": "5.19.0-beta.4",
25
+ "@webiny/api-i18n": "5.19.0-beta.4",
26
+ "@webiny/api-i18n-content": "5.19.0-beta.4",
27
+ "@webiny/api-i18n-ddb": "5.19.0-beta.4",
28
+ "@webiny/api-security": "5.19.0-beta.4",
29
+ "@webiny/api-tenancy": "5.19.0-beta.4",
30
+ "@webiny/api-upgrade": "5.19.0-beta.4",
31
+ "@webiny/error": "5.19.0-beta.4",
32
+ "@webiny/handler": "5.19.0-beta.4",
33
+ "@webiny/handler-aws": "5.19.0-beta.4",
34
+ "@webiny/handler-db": "5.19.0-beta.4",
35
+ "@webiny/handler-graphql": "5.19.0-beta.4",
36
+ "@webiny/handler-http": "5.19.0-beta.4",
37
+ "@webiny/plugins": "5.19.0-beta.4",
38
+ "@webiny/pubsub": "5.19.0-beta.4",
39
+ "@webiny/utils": "5.19.0-beta.4",
40
+ "@webiny/validation": "5.19.0-beta.4",
41
41
  "boolean": "3.1.4",
42
42
  "commodo-fields-object": "1.0.6",
43
43
  "dataloader": "2.0.0",
@@ -54,10 +54,10 @@
54
54
  "@babel/core": "^7.5.5",
55
55
  "@babel/preset-env": "^7.5.5",
56
56
  "@babel/preset-flow": "^7.0.0",
57
- "@webiny/api-security-so-ddb": "^5.19.0-beta.3",
58
- "@webiny/api-tenancy-so-ddb": "^5.19.0-beta.3",
59
- "@webiny/cli": "^5.19.0-beta.3",
60
- "@webiny/project-utils": "^5.19.0-beta.3",
57
+ "@webiny/api-security-so-ddb": "^5.19.0-beta.4",
58
+ "@webiny/api-tenancy-so-ddb": "^5.19.0-beta.4",
59
+ "@webiny/cli": "^5.19.0-beta.4",
60
+ "@webiny/project-utils": "^5.19.0-beta.4",
61
61
  "apollo-graphql": "^0.4.1",
62
62
  "get-yarn-workspaces": "^1.0.2",
63
63
  "graphql": "^14.6.0",
@@ -77,5 +77,5 @@
77
77
  "build": "yarn webiny run build",
78
78
  "watch": "yarn webiny run watch"
79
79
  },
80
- "gitHead": "a1cca819f83172183b907de16fd5746d07d13ad0"
80
+ "gitHead": "d115a87beb3ad3979c91a4ddf14082883be241f0"
81
81
  }