@webiny/api-headless-cms 5.18.3 → 5.19.0-beta.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.
Files changed (27) hide show
  1. package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
  2. package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
  3. package/content/plugins/crud/contentEntry/markLockedFields.d.ts +7 -3
  4. package/content/plugins/crud/contentEntry/markLockedFields.js +41 -7
  5. package/content/plugins/crud/contentEntry/referenceFieldsMapping.d.ts +12 -0
  6. package/content/plugins/crud/contentEntry/referenceFieldsMapping.js +251 -0
  7. package/content/plugins/crud/contentEntry.crud.d.ts +0 -4
  8. package/content/plugins/crud/contentEntry.crud.js +50 -51
  9. package/content/plugins/crud/contentModel/beforeCreate.js +1 -1
  10. package/content/plugins/crud/index.js +6 -4
  11. package/content/plugins/graphqlFields/ref.js +70 -34
  12. package/content/plugins/modelManager/DefaultCmsModelManager.js +7 -1
  13. package/content/plugins/schema/contentEntries.js +39 -28
  14. package/content/plugins/schema/createManageResolvers.js +1 -2
  15. package/content/plugins/schema/resolvers/manage/resolveDelete.js +7 -1
  16. package/content/plugins/utils/renderSortEnum.js +12 -12
  17. package/content/plugins/validators/patternPlugins/index.js +5 -1
  18. package/content/plugins/validators/patternPlugins/lowerCaseSpace.d.ts +3 -0
  19. package/content/plugins/validators/patternPlugins/lowerCaseSpace.js +17 -0
  20. package/content/plugins/validators/patternPlugins/upperCaseSpace.d.ts +3 -0
  21. package/content/plugins/validators/patternPlugins/upperCaseSpace.js +17 -0
  22. package/index.d.ts +1 -1
  23. package/package.json +24 -23
  24. package/plugins/crud/index.js +20 -2
  25. package/plugins/crud/system.crud.js +2 -1
  26. package/types.d.ts +20 -36
  27. package/types.js +0 -6
@@ -0,0 +1,7 @@
1
+ import { Topic } from "@webiny/pubsub/types";
2
+ import { AfterEntryDeleteTopicParams, CmsContext } from "../../../../types";
3
+ export interface Params {
4
+ context: CmsContext;
5
+ onAfterDelete: Topic<AfterEntryDeleteTopicParams>;
6
+ }
7
+ export declare const assignAfterEntryDelete: (params: Params) => void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.assignAfterEntryDelete = void 0;
7
+
8
+ var _markLockedFields = require("./markLockedFields");
9
+
10
+ const assignAfterEntryDelete = params => {
11
+ const {
12
+ context,
13
+ onAfterDelete
14
+ } = params;
15
+ onAfterDelete.subscribe(async params => {
16
+ const {
17
+ entry,
18
+ model
19
+ } = params;
20
+ const {
21
+ items
22
+ } = await context.cms.storageOperations.entries.list(model, {
23
+ where: {
24
+ entryId_not: entry.entryId,
25
+ latest: true
26
+ },
27
+ limit: 1
28
+ });
29
+
30
+ if (items.length > 0) {
31
+ return;
32
+ }
33
+
34
+ await (0, _markLockedFields.markUnlockedFields)({
35
+ context,
36
+ model
37
+ });
38
+ });
39
+ };
40
+
41
+ exports.assignAfterEntryDelete = assignAfterEntryDelete;
@@ -1,8 +1,12 @@
1
1
  import { CmsEntry, CmsModel, CmsContext } from "../../../../types";
2
- interface Args {
2
+ export interface MarkLockedFieldsParams {
3
3
  model: CmsModel;
4
4
  entry: CmsEntry;
5
5
  context: CmsContext;
6
6
  }
7
- export declare const markLockedFields: ({ model, context }: Args) => Promise<void>;
8
- export {};
7
+ export declare const markLockedFields: (params: MarkLockedFieldsParams) => Promise<void>;
8
+ export interface MarkFieldsUnlockedParams {
9
+ context: CmsContext;
10
+ model: CmsModel;
11
+ }
12
+ export declare const markUnlockedFields: (params: MarkFieldsUnlockedParams) => Promise<void>;
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.markLockedFields = void 0;
8
+ exports.markUnlockedFields = exports.markLockedFields = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
@@ -17,11 +17,15 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
17
17
 
18
18
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
19
 
20
- const markLockedFields = async ({
21
- model,
22
- context
23
- }) => {
24
- // If the model is registered via a plugin, we don't need do process anything.
20
+ const markLockedFields = async params => {
21
+ const {
22
+ model,
23
+ context
24
+ } = params;
25
+ /**
26
+ * If the model is registered via a plugin, we don't need do process anything.
27
+ */
28
+
25
29
  const plugins = context.plugins.byType(_CmsModelPlugin.CmsModelPlugin.type);
26
30
 
27
31
  if (plugins.find(plugin => plugin.contentModel.modelId === model.modelId)) {
@@ -80,4 +84,34 @@ const markLockedFields = async ({
80
84
  }
81
85
  };
82
86
 
83
- exports.markLockedFields = markLockedFields;
87
+ exports.markLockedFields = markLockedFields;
88
+
89
+ const markUnlockedFields = async params => {
90
+ const {
91
+ context,
92
+ model
93
+ } = params;
94
+ /**
95
+ * If the model is registered via a plugin, we don't need do process anything.
96
+ */
97
+
98
+ const plugins = context.plugins.byType(_CmsModelPlugin.CmsModelPlugin.type);
99
+
100
+ if (plugins.find(plugin => plugin.contentModel.modelId === model.modelId)) {
101
+ return;
102
+ }
103
+
104
+ try {
105
+ await context.cms.updateModelDirect({
106
+ original: model,
107
+ model: _objectSpread(_objectSpread({}, model), {}, {
108
+ lockedFields: []
109
+ })
110
+ });
111
+ model.lockedFields = [];
112
+ } catch (ex) {
113
+ throw new _error.default(`Could not update model "${model.modelId}" with unlocked fields.`, "MODEL_UNLOCKED_FIELDS_UPDATE_FAILED", ex);
114
+ }
115
+ };
116
+
117
+ exports.markUnlockedFields = markUnlockedFields;
@@ -0,0 +1,12 @@
1
+ import { CmsContext, CmsModel } from "../../../../types";
2
+ interface ReferenceObject {
3
+ id: string;
4
+ modelId: string;
5
+ }
6
+ interface Params {
7
+ context: CmsContext;
8
+ model: CmsModel;
9
+ input: Record<string, ReferenceObject | ReferenceObject[]>;
10
+ }
11
+ export declare const referenceFieldsMapping: (params: Params) => Promise<Record<string, any>>;
12
+ export {};
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.referenceFieldsMapping = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+
14
+ var _dotProp = _interopRequireDefault(require("dot-prop"));
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ const buildReferenceFieldPaths = params => {
21
+ const {
22
+ fields,
23
+ parentPaths: initialParentPaths,
24
+ input
25
+ } = params;
26
+ const parentPaths = [].concat(initialParentPaths);
27
+ const isMultipleValues = Array.isArray(input);
28
+ return fields.filter(field => ["object", "ref"].includes(field.type)).reduce((collection, field) => {
29
+ /**
30
+ * First we check the ref field
31
+ */
32
+ if (field.type === "ref") {
33
+ const parentPathsValue = parentPaths.length > 0 ? `${parentPaths.join(".")}.` : "";
34
+
35
+ if (field.multipleValues) {
36
+ const inputValue = _dotProp.default.get(input, `${field.fieldId}`, []);
37
+
38
+ if (Array.isArray(inputValue) === false) {
39
+ return collection;
40
+ }
41
+
42
+ for (const key in inputValue) {
43
+ const path = `${parentPathsValue}${field.fieldId}.${key}`;
44
+ collection.push(path);
45
+ }
46
+
47
+ return collection;
48
+ }
49
+
50
+ if (isMultipleValues) {
51
+ for (const key in input) {
52
+ const path = `${parentPathsValue}${key}.${field.fieldId}`;
53
+ collection.push(path);
54
+ }
55
+
56
+ return collection;
57
+ }
58
+
59
+ collection.push(`${parentPathsValue}${field.fieldId}`);
60
+ return collection;
61
+ }
62
+ /**
63
+ * Then we move onto the object field
64
+ */
65
+
66
+
67
+ const parentPathsValue = parentPaths.length > 0 ? `${parentPaths.join(".")}.` : "";
68
+ /**
69
+ * This is if received input is array. We need to map key with fieldId at this point.
70
+ */
71
+
72
+ if (isMultipleValues) {
73
+ for (const key in input) {
74
+ const path = `${parentPathsValue}${key}.${field.fieldId}`;
75
+ collection.push(path);
76
+ }
77
+
78
+ return collection;
79
+ }
80
+
81
+ const objFieldPath = `${field.fieldId}`;
82
+
83
+ const objFieldInputValue = _dotProp.default.get(input, objFieldPath, []);
84
+ /**
85
+ * If field is multiple values one, we need to go through the input and use the existing keys.
86
+ */
87
+
88
+
89
+ if (field.multipleValues) {
90
+ if (Array.isArray(objFieldInputValue) === false) {
91
+ return collection;
92
+ }
93
+
94
+ for (const key in objFieldInputValue) {
95
+ const result = buildReferenceFieldPaths({
96
+ fields: field.settings.fields,
97
+ input: objFieldInputValue[key],
98
+ parentPaths: parentPaths.concat([field.fieldId, key])
99
+ });
100
+ collection.push(...result);
101
+ }
102
+
103
+ return collection;
104
+ }
105
+ /**
106
+ * Single value reference field.
107
+ */
108
+
109
+
110
+ const results = buildReferenceFieldPaths({
111
+ fields: field.settings.fields,
112
+ input: objFieldInputValue,
113
+ parentPaths: parentPaths.concat([field.fieldId])
114
+ });
115
+ return collection.concat(results);
116
+ }, []);
117
+ };
118
+
119
+ const referenceFieldsMapping = async params => {
120
+ const {
121
+ context,
122
+ model,
123
+ input
124
+ } = params;
125
+
126
+ let output = _objectSpread({}, input);
127
+
128
+ const referenceFieldPaths = buildReferenceFieldPaths({
129
+ fields: model.fields,
130
+ input,
131
+ parentPaths: []
132
+ });
133
+
134
+ if (referenceFieldPaths.length === 0) {
135
+ return output;
136
+ }
137
+
138
+ const referencesByModel = {};
139
+ const pathsByReferenceId = {};
140
+
141
+ for (const path of referenceFieldPaths) {
142
+ const ref = _dotProp.default.get(output, path);
143
+
144
+ if (!ref || !ref.id || !ref.modelId) {
145
+ continue;
146
+ }
147
+
148
+ if (!referencesByModel[ref.modelId]) {
149
+ referencesByModel[ref.modelId] = [];
150
+ }
151
+
152
+ referencesByModel[ref.modelId].push(ref.id);
153
+
154
+ if (!pathsByReferenceId[ref.id]) {
155
+ pathsByReferenceId[ref.id] = [];
156
+ }
157
+
158
+ pathsByReferenceId[ref.id].push(path);
159
+ }
160
+ /**
161
+ * Again, no point in going further.
162
+ */
163
+
164
+
165
+ if (Object.keys(referencesByModel).length === 0) {
166
+ return output;
167
+ }
168
+ /**
169
+ * Load all models and use only those that are used in reference.
170
+ */
171
+
172
+
173
+ const models = (await context.cms.listModels()).filter(model => {
174
+ const entries = referencesByModel[model.modelId];
175
+
176
+ if (Array.isArray(entries) === false || entries.length === 0) {
177
+ return false;
178
+ }
179
+
180
+ return true;
181
+ });
182
+ /**
183
+ * Check for any model existence, just in case.
184
+ */
185
+
186
+ if (models.length === 0) {
187
+ return output;
188
+ }
189
+ /**
190
+ * Load all the entries by their ID
191
+ */
192
+
193
+
194
+ const promises = models.map(model => {
195
+ return context.cms.getEntriesByIds(model, referencesByModel[model.modelId]);
196
+ });
197
+ const results = await Promise.all(promises);
198
+ const records = results.reduce((collection, entries) => {
199
+ for (const entry of entries) {
200
+ collection[entry.id] = entry;
201
+ }
202
+
203
+ return collection;
204
+ }, {});
205
+ /**
206
+ * Verify that all referenced entries actually exist.
207
+ */
208
+
209
+ for (const modelId in referencesByModel) {
210
+ const entries = referencesByModel[modelId];
211
+
212
+ for (const entry of entries) {
213
+ if (records[entry]) {
214
+ continue;
215
+ }
216
+
217
+ throw new _error.default(`Missing referenced entry with id "${entry}" in model "${modelId}".`, "ENTRY_NOT_FOUND", {
218
+ entry,
219
+ model: modelId
220
+ });
221
+ }
222
+ }
223
+ /**
224
+ * In the end, assign the entryId, id and model values to the output.
225
+ */
226
+
227
+
228
+ for (const id in pathsByReferenceId) {
229
+ const entry = records[id];
230
+ const paths = pathsByReferenceId[id];
231
+
232
+ if (!entry) {
233
+ throw new _error.default("Missing entry in records.", "ENTRY_ERROR", {
234
+ id,
235
+ paths
236
+ });
237
+ }
238
+
239
+ for (const path of paths) {
240
+ output = _dotProp.default.set(output, path, {
241
+ id: entry.id,
242
+ entryId: entry.entryId,
243
+ modelId: entry.modelId
244
+ });
245
+ }
246
+ }
247
+
248
+ return output;
249
+ };
250
+
251
+ exports.referenceFieldsMapping = referenceFieldsMapping;
@@ -1,6 +1,4 @@
1
1
  import { CmsEntryContext, CmsContext, HeadlessCmsStorageOperations } from "../../../types";
2
- import { I18NLocale } from "@webiny/api-i18n/types";
3
- import { Tenant } from "@webiny/api-tenancy/types";
4
2
  import { SecurityIdentity } from "@webiny/api-security/types";
5
3
  export declare const STATUS_DRAFT = "draft";
6
4
  export declare const STATUS_PUBLISHED = "published";
@@ -10,8 +8,6 @@ export declare const STATUS_REVIEW_REQUESTED = "reviewRequested";
10
8
  export interface Params {
11
9
  storageOperations: HeadlessCmsStorageOperations;
12
10
  context: CmsContext;
13
- getTenant: () => Tenant;
14
- getLocale: () => I18NLocale;
15
11
  getIdentity: () => SecurityIdentity;
16
12
  }
17
13
  export declare const createContentEntryCrud: (params: Params) => CmsEntryContext;
@@ -29,6 +29,10 @@ var _utils2 = require("@webiny/utils");
29
29
 
30
30
  var _entryStorage = require("../utils/entryStorage");
31
31
 
32
+ var _afterDelete = require("./contentEntry/afterDelete");
33
+
34
+ var _referenceFieldsMapping = require("./contentEntry/referenceFieldsMapping");
35
+
32
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
33
37
 
34
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -79,20 +83,23 @@ const createEntryId = version => {
79
83
  };
80
84
 
81
85
  const increaseEntryIdVersion = id => {
82
- if (id.includes("#") === false) {
86
+ const {
87
+ id: entryId,
88
+ version
89
+ } = (0, _utils2.parseIdentifier)(id);
90
+
91
+ if (!version) {
83
92
  throw new _error.default("Cannot increase version on the ID without the version part.", "WRONG_ID", {
84
93
  id
85
94
  });
86
95
  }
87
96
 
88
- const [entryId, version] = id.split("#");
89
- const ver = parseInt(version) + 1;
90
97
  return {
91
98
  entryId,
92
- version: ver,
99
+ version: version + 1,
93
100
  id: (0, _utils2.createIdentifier)({
94
101
  id: entryId,
95
- version: ver
102
+ version: version + 1
96
103
  })
97
104
  };
98
105
  };
@@ -101,8 +108,6 @@ const createContentEntryCrud = params => {
101
108
  const {
102
109
  storageOperations,
103
110
  context,
104
- getTenant,
105
- getLocale,
106
111
  getIdentity
107
112
  } = params;
108
113
  const onBeforeCreate = (0, _pubsub.createTopic)();
@@ -137,6 +142,10 @@ const createContentEntryCrud = params => {
137
142
  context,
138
143
  onBeforeUpdate
139
144
  });
145
+ (0, _afterDelete.assignAfterEntryDelete)({
146
+ context,
147
+ onAfterDelete
148
+ });
140
149
 
141
150
  const checkEntryPermissions = check => {
142
151
  return utils.checkPermissions(context, "cms.contentEntry", check);
@@ -183,8 +192,6 @@ const createContentEntryCrud = params => {
183
192
  });
184
193
  await utils.checkModelAccess(context, model);
185
194
  const entries = await storageOperations.entries.getByIds(model, {
186
- tenant: getTenant().id,
187
- locale: getLocale().code,
188
195
  ids
189
196
  });
190
197
  return entries.filter(entry => utils.validateOwnership(context, permission, entry));
@@ -246,8 +253,6 @@ const createContentEntryCrud = params => {
246
253
  });
247
254
  await utils.checkModelAccess(context, model);
248
255
  const entries = await storageOperations.entries.getPublishedByIds(model, {
249
- tenant: getTenant().id,
250
- locale: getLocale().code,
251
256
  ids
252
257
  });
253
258
  return entries.filter(entry => utils.validateOwnership(context, permission, entry));
@@ -262,16 +267,12 @@ const createContentEntryCrud = params => {
262
267
  });
263
268
  await utils.checkModelAccess(context, model);
264
269
  const entries = await storageOperations.entries.getLatestByIds(model, {
265
- tenant: getTenant().id,
266
- locale: getLocale().code,
267
270
  ids
268
271
  });
269
272
  return entries.filter(entry => utils.validateOwnership(context, permission, entry));
270
273
  },
271
274
  getEntryRevisions: async (model, entryId) => {
272
275
  return storageOperations.entries.getRevisions(model, {
273
- tenant: getTenant().id,
274
- locale: getLocale().code,
275
276
  id: entryId
276
277
  });
277
278
  },
@@ -313,8 +314,8 @@ const createContentEntryCrud = params => {
313
314
  const ownedBy = permission.own ? getIdentity().id : where.ownedBy;
314
315
 
315
316
  const listWhere = _objectSpread(_objectSpread({}, where), {}, {
316
- tenant: where.tenant || getTenant().id,
317
- locale: where.locale || getLocale().code
317
+ tenant: model.tenant,
318
+ locale: model.locale
318
319
  });
319
320
 
320
321
  if (ownedBy !== undefined) {
@@ -374,8 +375,13 @@ const createContentEntryCrud = params => {
374
375
  * Make sure we only work with fields that are defined in the model.
375
376
  */
376
377
 
377
- const input = cleanInputData(model, inputData);
378
- await (0, _entryDataValidation.validateModelEntryData)(context, model, input);
378
+ const initialInput = cleanInputData(model, inputData);
379
+ await (0, _entryDataValidation.validateModelEntryData)(context, model, initialInput);
380
+ const input = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
381
+ context,
382
+ model,
383
+ input: initialInput
384
+ });
379
385
  const identity = context.security.getIdentity();
380
386
  const locale = context.cms.getLocale();
381
387
  const owner = {
@@ -448,15 +454,13 @@ const createContentEntryCrud = params => {
448
454
  * Entries are identified by a common parent ID + Revision number.
449
455
  */
450
456
 
451
- const [uniqueId] = sourceId.split("#");
457
+ const {
458
+ id: uniqueId
459
+ } = (0, _utils2.parseIdentifier)(sourceId);
452
460
  const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
453
- tenant: getTenant().id,
454
- locale: getLocale().code,
455
461
  id: sourceId
456
462
  });
457
463
  const latestStorageEntry = await storageOperations.entries.getLatestRevisionByEntryId(model, {
458
- tenant: getTenant().id,
459
- locale: getLocale().code,
460
464
  id: uniqueId
461
465
  });
462
466
 
@@ -470,9 +474,14 @@ const createContentEntryCrud = params => {
470
474
 
471
475
  const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
472
476
 
473
- const values = _objectSpread(_objectSpread({}, originalEntry.values), input);
477
+ const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
474
478
 
475
- await (0, _entryDataValidation.validateModelEntryData)(context, model, values);
479
+ await (0, _entryDataValidation.validateModelEntryData)(context, model, initialValues);
480
+ const values = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
481
+ context,
482
+ model,
483
+ input: initialValues
484
+ });
476
485
  utils.checkOwnership(context, permission, originalEntry);
477
486
  const latestEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, latestStorageEntry);
478
487
  const identity = context.security.getIdentity();
@@ -550,8 +559,6 @@ const createContentEntryCrud = params => {
550
559
  */
551
560
 
552
561
  const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
553
- tenant: getTenant().id,
554
- locale: getLocale().code,
555
562
  id
556
563
  });
557
564
 
@@ -565,13 +572,21 @@ const createContentEntryCrud = params => {
565
572
 
566
573
  const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
567
574
  utils.checkOwnership(context, permission, originalEntry);
575
+
576
+ const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
577
+
578
+ const values = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
579
+ context,
580
+ model,
581
+ input: initialValues
582
+ });
568
583
  /**
569
584
  * We always send the full entry to the hooks and storage operations update.
570
585
  */
571
586
 
572
587
  const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
573
588
  savedOn: new Date().toISOString(),
574
- values: _objectSpread(_objectSpread({}, originalEntry.values), input)
589
+ values
575
590
  });
576
591
 
577
592
  let storageEntry = undefined;
@@ -619,18 +634,12 @@ const createContentEntryCrud = params => {
619
634
  version
620
635
  } = (0, _utils2.parseIdentifier)(revisionId);
621
636
  const storageEntryToDelete = await storageOperations.entries.getRevisionById(model, {
622
- tenant: getTenant().id,
623
- locale: getLocale().code,
624
637
  id: revisionId
625
638
  });
626
639
  const latestStorageEntry = await storageOperations.entries.getLatestRevisionByEntryId(model, {
627
- tenant: getTenant().id,
628
- locale: getLocale().code,
629
640
  id: entryId
630
641
  });
631
642
  const previousStorageEntry = await storageOperations.entries.getPreviousRevision(model, {
632
- tenant: getTenant().id,
633
- locale: getLocale().code,
634
643
  entryId,
635
644
  version
636
645
  });
@@ -698,8 +707,6 @@ const createContentEntryCrud = params => {
698
707
  });
699
708
  await utils.checkModelAccess(context, model);
700
709
  const storageEntry = await storageOperations.entries.getLatestRevisionByEntryId(model, {
701
- tenant: getTenant().id,
702
- locale: getLocale().code,
703
710
  id: entryId
704
711
  });
705
712
 
@@ -720,11 +727,7 @@ const createContentEntryCrud = params => {
720
727
  pw: "p"
721
728
  });
722
729
  await utils.checkModelAccess(context, model);
723
- const tenant = getTenant().id;
724
- const locale = getLocale().code;
725
730
  const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
726
- tenant,
727
- locale,
728
731
  id
729
732
  });
730
733
 
@@ -778,8 +781,6 @@ const createContentEntryCrud = params => {
778
781
  pw: "c"
779
782
  });
780
783
  const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
781
- tenant: getTenant().id,
782
- locale: getLocale().code,
783
784
  id
784
785
  });
785
786
 
@@ -836,15 +837,13 @@ const createContentEntryCrud = params => {
836
837
  const permission = await checkEntryPermissions({
837
838
  pw: "r"
838
839
  });
839
- const [entryId] = id.split("#");
840
+ const {
841
+ id: entryId
842
+ } = (0, _utils2.parseIdentifier)(id);
840
843
  const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
841
- tenant: getTenant().id,
842
- locale: getLocale().code,
843
844
  id
844
845
  });
845
846
  const latestEntryRevision = await storageOperations.entries.getLatestRevisionByEntryId(model, {
846
- tenant: getTenant().id,
847
- locale: getLocale().code,
848
847
  id: entryId
849
848
  });
850
849
 
@@ -900,10 +899,10 @@ const createContentEntryCrud = params => {
900
899
  const permission = await checkEntryPermissions({
901
900
  pw: "u"
902
901
  });
903
- const [entryId] = id.split("#");
902
+ const {
903
+ id: entryId
904
+ } = (0, _utils2.parseIdentifier)(id);
904
905
  const originalStorageEntry = await storageOperations.entries.getPublishedRevisionByEntryId(model, {
905
- tenant: getTenant().id,
906
- locale: getLocale().code,
907
906
  id: entryId
908
907
  });
909
908
 
@@ -21,7 +21,7 @@ const disallowedModelIdList = ["contentModel", "contentModels", "contentModelGro
21
21
  * Add more if required.
22
22
  */
23
23
 
24
- const disallowedModelIdEndingList = ["Response", "List", "Meta", "Input", "Sorter"];
24
+ const disallowedModelIdEndingList = ["Response", "List", "Meta", "Input", "Sorter", "RefType"];
25
25
  /**
26
26
  * Checks for the uniqueness of provided modelId, against the provided list of models.
27
27
  * It also takes plural / singular forms of the provided modelId into account.