@webiny/api-headless-cms 0.0.0-unstable.5e7233243f → 0.0.0-unstable.615a930a68
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.
- package/context.js +3 -7
- package/context.js.map +1 -1
- package/crud/contentEntry/afterDelete.d.ts +2 -2
- package/crud/contentEntry/afterDelete.js +2 -2
- package/crud/contentEntry/afterDelete.js.map +1 -1
- package/crud/contentEntry/beforeCreate.d.ts +2 -2
- package/crud/contentEntry/beforeCreate.js +2 -2
- package/crud/contentEntry/beforeCreate.js.map +1 -1
- package/crud/contentEntry/beforeUpdate.d.ts +2 -2
- package/crud/contentEntry/beforeUpdate.js +2 -2
- package/crud/contentEntry/beforeUpdate.js.map +1 -1
- package/crud/contentEntry/entryDataValidation.js +3 -7
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry/markLockedFields.js +6 -10
- package/crud/contentEntry/markLockedFields.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.js +3 -9
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry/searchableFields.d.ts +9 -0
- package/crud/contentEntry/searchableFields.js +83 -0
- package/crud/contentEntry/searchableFields.js.map +1 -0
- package/crud/contentEntry.crud.d.ts +0 -2
- package/crud/contentEntry.crud.js +200 -269
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/afterCreate.d.ts +3 -3
- package/crud/contentModel/afterCreate.js +5 -5
- package/crud/contentModel/afterCreate.js.map +1 -1
- package/crud/contentModel/afterCreateFrom.d.ts +3 -3
- package/crud/contentModel/afterCreateFrom.js +5 -5
- package/crud/contentModel/afterCreateFrom.js.map +1 -1
- package/crud/contentModel/afterDelete.d.ts +3 -3
- package/crud/contentModel/afterDelete.js +5 -5
- package/crud/contentModel/afterDelete.js.map +1 -1
- package/crud/contentModel/afterUpdate.d.ts +3 -3
- package/crud/contentModel/afterUpdate.js +5 -5
- package/crud/contentModel/afterUpdate.js.map +1 -1
- package/crud/contentModel/beforeCreate.d.ts +4 -4
- package/crud/contentModel/beforeCreate.js +10 -10
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.d.ts +3 -3
- package/crud/contentModel/beforeDelete.js +6 -6
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/beforeUpdate.d.ts +3 -3
- package/crud/contentModel/beforeUpdate.js +5 -5
- package/crud/contentModel/beforeUpdate.js.map +1 -1
- package/crud/contentModel/validateModel.js +1 -1
- package/crud/contentModel/validateModelFields.js +3 -7
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel.crud.js +84 -60
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/beforeCreate.d.ts +2 -2
- package/crud/contentModelGroup/beforeCreate.js +3 -3
- package/crud/contentModelGroup/beforeCreate.js.map +1 -1
- package/crud/contentModelGroup/beforeDelete.d.ts +2 -2
- package/crud/contentModelGroup/beforeDelete.js +3 -3
- package/crud/contentModelGroup/beforeDelete.js.map +1 -1
- package/crud/contentModelGroup/beforeUpdate.d.ts +2 -2
- package/crud/contentModelGroup/beforeUpdate.js +2 -2
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
- package/crud/contentModelGroup.crud.js +58 -38
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/crud/index.js +3 -7
- package/crud/index.js.map +1 -1
- package/crud/settings.crud.js +3 -8
- package/crud/settings.crud.js.map +1 -1
- package/crud/system.crud.js +63 -51
- package/crud/system.crud.js.map +1 -1
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +1 -1
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +17 -19
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
- package/graphql/graphQLHandlerFactory.js +1 -1
- package/graphql/schema/baseContentSchema.js +5 -9
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/contentEntries.js +1 -1
- package/graphql/schema/contentModels.js +19 -0
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +4 -10
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createManageResolvers.js +4 -18
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.js +6 -8
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createPreviewResolvers.js +3 -7
- package/graphql/schema/createPreviewResolvers.js.map +1 -1
- package/graphql/schema/createReadResolvers.js +3 -7
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.js +3 -1
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGet.js +5 -9
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveGet.js +3 -7
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveGet.js +3 -7
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
- package/graphqlFields/number.js +4 -0
- package/graphqlFields/number.js.map +1 -1
- package/graphqlFields/object.js +102 -16
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +4 -8
- package/graphqlFields/ref.js.map +1 -1
- package/modelManager/DefaultCmsModelManager.d.ts +7 -7
- package/modelManager/DefaultCmsModelManager.js +1 -1
- package/package.json +27 -28
- package/parameters/header.js +1 -1
- package/parameters/manual.js +7 -8
- package/parameters/manual.js.map +1 -1
- package/parameters/path.js +1 -1
- package/plugins/CmsGroupPlugin.js +1 -1
- package/plugins/CmsModelFieldConverterPlugin.js +1 -1
- package/plugins/CmsModelPlugin.d.ts +6 -2
- package/plugins/CmsModelPlugin.js +18 -13
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/CmsParametersPlugin.js +1 -1
- package/plugins/StorageTransformPlugin.d.ts +1 -1
- package/plugins/StorageTransformPlugin.js +1 -1
- package/plugins/StorageTransformPlugin.js.map +1 -1
- package/storage/object.js +3 -7
- package/storage/object.js.map +1 -1
- package/types.d.ts +276 -127
- package/types.js +0 -2
- package/types.js.map +1 -1
- package/upgrades/5.33.0/index.js +5 -9
- package/upgrades/5.33.0/index.js.map +1 -1
- package/utils/converters/Converter.js +1 -1
- package/utils/converters/ConverterCollection.d.ts +7 -0
- package/utils/converters/ConverterCollection.js +31 -7
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.js +3 -7
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeName.js +1 -1
- package/utils/entryStorage.js +3 -7
- package/utils/entryStorage.js.map +1 -1
- package/utils/filterModelFields.js +5 -9
- package/utils/filterModelFields.js.map +1 -1
- package/utils/permissions.js +1 -5
- package/utils/permissions.js.map +1 -1
- package/utils/pluralizedTypeName.js +1 -1
- package/utils/renderListFilterFields.js +9 -1
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/toSlug.js +1 -1
- package/validators/unique.js +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.createContentEntryCrud = exports.STATUS_UNPUBLISHED = exports.
|
|
8
|
+
exports.createContentEntryCrud = exports.STATUS_UNPUBLISHED = exports.STATUS_PUBLISHED = exports.STATUS_DRAFT = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _mdbid = _interopRequireDefault(require("mdbid"));
|
|
13
13
|
|
|
@@ -41,20 +41,18 @@ var _entryStorage = require("../utils/entryStorage");
|
|
|
41
41
|
|
|
42
42
|
var _valueKeyStorageConverter = require("../utils/converters/valueKeyStorageConverter");
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
44
|
+
var _searchableFields = require("./contentEntry/searchableFields");
|
|
47
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Package mdbid does not have types.
|
|
48
|
+
*/
|
|
49
|
+
// @ts-ignore
|
|
48
50
|
const STATUS_DRAFT = "draft";
|
|
49
51
|
exports.STATUS_DRAFT = STATUS_DRAFT;
|
|
50
52
|
const STATUS_PUBLISHED = "published";
|
|
51
53
|
exports.STATUS_PUBLISHED = STATUS_PUBLISHED;
|
|
52
54
|
const STATUS_UNPUBLISHED = "unpublished";
|
|
53
55
|
exports.STATUS_UNPUBLISHED = STATUS_UNPUBLISHED;
|
|
54
|
-
const STATUS_CHANGES_REQUESTED = "changesRequested";
|
|
55
|
-
exports.STATUS_CHANGES_REQUESTED = STATUS_CHANGES_REQUESTED;
|
|
56
|
-
const STATUS_REVIEW_REQUESTED = "reviewRequested";
|
|
57
|
-
exports.STATUS_REVIEW_REQUESTED = STATUS_REVIEW_REQUESTED;
|
|
58
56
|
|
|
59
57
|
/**
|
|
60
58
|
* Used for some fields to convert their values.
|
|
@@ -221,33 +219,10 @@ const increaseEntryIdVersion = id => {
|
|
|
221
219
|
};
|
|
222
220
|
};
|
|
223
221
|
|
|
224
|
-
const
|
|
225
|
-
const {
|
|
226
|
-
plugins,
|
|
227
|
-
model,
|
|
228
|
-
fields
|
|
229
|
-
} = params;
|
|
230
|
-
const fieldPluginMap = plugins.byType("cms-model-field-to-graphql").reduce((collection, field) => {
|
|
231
|
-
collection[field.fieldType] = field;
|
|
232
|
-
return collection;
|
|
233
|
-
}, {});
|
|
234
|
-
return model.fields.filter(field => {
|
|
235
|
-
if (!field.fieldId) {
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const plugin = fieldPluginMap[field.type];
|
|
240
|
-
|
|
241
|
-
if (!plugin) {
|
|
242
|
-
return false;
|
|
243
|
-
} else if (!plugin.fullTextSearch) {
|
|
244
|
-
return false;
|
|
245
|
-
} else if (!fields || fields.length === 0) {
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
222
|
+
const allowedEntryStatus = ["draft", "published", "unpublished"];
|
|
248
223
|
|
|
249
|
-
|
|
250
|
-
|
|
224
|
+
const transformEntryStatus = status => {
|
|
225
|
+
return allowedEntryStatus.includes(status) ? status : "draft";
|
|
251
226
|
};
|
|
252
227
|
|
|
253
228
|
const createContentEntryCrud = params => {
|
|
@@ -259,42 +234,54 @@ const createContentEntryCrud = params => {
|
|
|
259
234
|
} = params;
|
|
260
235
|
const {
|
|
261
236
|
plugins
|
|
262
|
-
} = context;
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
const
|
|
282
|
-
const
|
|
237
|
+
} = context; // create
|
|
238
|
+
|
|
239
|
+
const onEntryBeforeCreate = (0, _pubsub.createTopic)("cms.onEntryBeforeCreate");
|
|
240
|
+
const onEntryAfterCreate = (0, _pubsub.createTopic)("cms.onEntryAfterCreate");
|
|
241
|
+
const onEntryCreateError = (0, _pubsub.createTopic)("cms.onEntryCreateError"); // create revision
|
|
242
|
+
|
|
243
|
+
const onEntryBeforeCreateRevision = (0, _pubsub.createTopic)("cms.onEntryBeforeCreateRevision");
|
|
244
|
+
const onEntryRevisionAfterCreate = (0, _pubsub.createTopic)("cms.onEntryRevisionAfterCreate");
|
|
245
|
+
const onEntryCreateRevisionError = (0, _pubsub.createTopic)("cms.onEntryCreateRevisionError"); // update
|
|
246
|
+
|
|
247
|
+
const onEntryBeforeUpdate = (0, _pubsub.createTopic)("cms.onEntryBeforeUpdate");
|
|
248
|
+
const onEntryAfterUpdate = (0, _pubsub.createTopic)("cms.onEntryAfterUpdate");
|
|
249
|
+
const onEntryUpdateError = (0, _pubsub.createTopic)("cms.onEntryUpdateError"); // publish
|
|
250
|
+
|
|
251
|
+
const onEntryBeforePublish = (0, _pubsub.createTopic)("cms.onEntryBeforePublish");
|
|
252
|
+
const onEntryAfterPublish = (0, _pubsub.createTopic)("cms.onEntryAfterPublic");
|
|
253
|
+
const onEntryPublishError = (0, _pubsub.createTopic)("cms.onEntryPublishError"); // unpublish
|
|
254
|
+
|
|
255
|
+
const onEntryBeforeUnpublish = (0, _pubsub.createTopic)("cms.onEntryBeforeUnpublish");
|
|
256
|
+
const onEntryAfterUnpublish = (0, _pubsub.createTopic)("cms.onEntryAfterUnpublish");
|
|
257
|
+
const onEntryUnpublishError = (0, _pubsub.createTopic)("cms.onEntryUnpublishError"); // delete
|
|
258
|
+
|
|
259
|
+
const onEntryBeforeDelete = (0, _pubsub.createTopic)("cms.onEntryBeforeDelete");
|
|
260
|
+
const onEntryAfterDelete = (0, _pubsub.createTopic)("cms.onEntryAfterDelete");
|
|
261
|
+
const onEntryDeleteError = (0, _pubsub.createTopic)("cms.onEntryDeleteError"); // delete revision
|
|
262
|
+
|
|
263
|
+
const onEntryRevisionBeforeDelete = (0, _pubsub.createTopic)("cms.onEntryRevisionBeforeDelete");
|
|
264
|
+
const onEntryRevisionAfterDelete = (0, _pubsub.createTopic)("cms.onEntryRevisionAfterDelete");
|
|
265
|
+
const onEntryRevisionDeleteError = (0, _pubsub.createTopic)("cms.onEntryRevisionDeleteError"); // get
|
|
266
|
+
|
|
267
|
+
const onEntryBeforeGet = (0, _pubsub.createTopic)("cms.onEntryBeforeGet"); // list
|
|
268
|
+
|
|
269
|
+
const onEntryBeforeList = (0, _pubsub.createTopic)("cms.onEntryBeforeList");
|
|
283
270
|
/**
|
|
284
271
|
* We need to assign some default behaviors.
|
|
285
272
|
*/
|
|
286
273
|
|
|
287
274
|
(0, _beforeCreate.assignBeforeEntryCreate)({
|
|
288
275
|
context,
|
|
289
|
-
|
|
276
|
+
onEntryBeforeCreate
|
|
290
277
|
});
|
|
291
278
|
(0, _beforeUpdate.assignBeforeEntryUpdate)({
|
|
292
279
|
context,
|
|
293
|
-
|
|
280
|
+
onEntryBeforeUpdate
|
|
294
281
|
});
|
|
295
282
|
(0, _afterDelete.assignAfterEntryDelete)({
|
|
296
283
|
context,
|
|
297
|
-
|
|
284
|
+
onEntryAfterDelete
|
|
298
285
|
});
|
|
299
286
|
|
|
300
287
|
const checkEntryPermissions = check => {
|
|
@@ -312,18 +299,23 @@ const createContentEntryCrud = params => {
|
|
|
312
299
|
} = params;
|
|
313
300
|
|
|
314
301
|
try {
|
|
315
|
-
await
|
|
302
|
+
await onEntryBeforeDelete.publish({
|
|
316
303
|
entry,
|
|
317
304
|
model
|
|
318
305
|
});
|
|
319
306
|
await storageOperations.entries.delete(model, {
|
|
320
307
|
entry
|
|
321
308
|
});
|
|
322
|
-
await
|
|
309
|
+
await onEntryAfterDelete.publish({
|
|
323
310
|
entry,
|
|
324
311
|
model
|
|
325
312
|
});
|
|
326
313
|
} catch (ex) {
|
|
314
|
+
await onEntryDeleteError.publish({
|
|
315
|
+
entry,
|
|
316
|
+
model,
|
|
317
|
+
error: ex
|
|
318
|
+
});
|
|
327
319
|
throw new _error.default(ex.message || "Could not delete entry.", ex.code || "DELETE_ERROR", {
|
|
328
320
|
entry
|
|
329
321
|
});
|
|
@@ -350,26 +342,52 @@ const createContentEntryCrud = params => {
|
|
|
350
342
|
};
|
|
351
343
|
|
|
352
344
|
return {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Deprecated - will be removed in 5.35.0
|
|
347
|
+
*/
|
|
348
|
+
onBeforeEntryCreate: onEntryBeforeCreate,
|
|
349
|
+
onAfterEntryCreate: onEntryAfterCreate,
|
|
350
|
+
onBeforeEntryCreateRevision: onEntryBeforeCreateRevision,
|
|
351
|
+
onAfterEntryCreateRevision: onEntryRevisionAfterCreate,
|
|
352
|
+
onBeforeEntryUpdate: onEntryBeforeUpdate,
|
|
353
|
+
onAfterEntryUpdate: onEntryAfterUpdate,
|
|
354
|
+
onBeforeEntryDelete: onEntryBeforeDelete,
|
|
355
|
+
onAfterEntryDelete: onEntryAfterDelete,
|
|
356
|
+
onBeforeEntryDeleteRevision: onEntryRevisionBeforeDelete,
|
|
357
|
+
onAfterEntryDeleteRevision: onEntryRevisionAfterDelete,
|
|
358
|
+
onBeforeEntryPublish: onEntryBeforePublish,
|
|
359
|
+
onAfterEntryPublish: onEntryAfterPublish,
|
|
360
|
+
onBeforeEntryUnpublish: onEntryBeforeUnpublish,
|
|
361
|
+
onAfterEntryUnpublish: onEntryAfterUnpublish,
|
|
362
|
+
onBeforeEntryGet: onEntryBeforeGet,
|
|
363
|
+
onBeforeEntryList: onEntryBeforeList,
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Released in 5.34.0
|
|
367
|
+
*/
|
|
368
|
+
onEntryBeforeCreate,
|
|
369
|
+
onEntryAfterCreate,
|
|
370
|
+
onEntryCreateError,
|
|
371
|
+
onEntryRevisionBeforeCreate: onEntryBeforeCreateRevision,
|
|
372
|
+
onEntryRevisionAfterCreate,
|
|
373
|
+
onEntryRevisionCreateError: onEntryCreateRevisionError,
|
|
374
|
+
onEntryBeforeUpdate,
|
|
375
|
+
onEntryAfterUpdate,
|
|
376
|
+
onEntryUpdateError,
|
|
377
|
+
onEntryBeforeDelete,
|
|
378
|
+
onEntryAfterDelete,
|
|
379
|
+
onEntryDeleteError,
|
|
380
|
+
onEntryRevisionBeforeDelete,
|
|
381
|
+
onEntryRevisionAfterDelete,
|
|
382
|
+
onEntryRevisionDeleteError,
|
|
383
|
+
onEntryBeforePublish,
|
|
384
|
+
onEntryAfterPublish,
|
|
385
|
+
onEntryPublishError,
|
|
386
|
+
onEntryBeforeUnpublish,
|
|
387
|
+
onEntryAfterUnpublish,
|
|
388
|
+
onEntryUnpublishError,
|
|
389
|
+
onEntryBeforeGet,
|
|
390
|
+
onEntryBeforeList,
|
|
373
391
|
|
|
374
392
|
/**
|
|
375
393
|
* Get entries by exact revision IDs from the database.
|
|
@@ -379,7 +397,7 @@ const createContentEntryCrud = params => {
|
|
|
379
397
|
/**
|
|
380
398
|
* Get a single entry by revision ID from the database.
|
|
381
399
|
*/
|
|
382
|
-
|
|
400
|
+
async getEntryById(initialModel, id) {
|
|
383
401
|
const where = {
|
|
384
402
|
id
|
|
385
403
|
};
|
|
@@ -387,7 +405,7 @@ const createContentEntryCrud = params => {
|
|
|
387
405
|
model: initialModel,
|
|
388
406
|
plugins
|
|
389
407
|
});
|
|
390
|
-
await
|
|
408
|
+
await onEntryBeforeGet.publish({
|
|
391
409
|
where,
|
|
392
410
|
model
|
|
393
411
|
});
|
|
@@ -403,7 +421,7 @@ const createContentEntryCrud = params => {
|
|
|
403
421
|
/**
|
|
404
422
|
* Get published revisions by entry IDs.
|
|
405
423
|
*/
|
|
406
|
-
|
|
424
|
+
async getPublishedEntriesByIds(initialModel, ids) {
|
|
407
425
|
const permission = await checkEntryPermissions({
|
|
408
426
|
rwd: "r"
|
|
409
427
|
});
|
|
@@ -421,7 +439,7 @@ const createContentEntryCrud = params => {
|
|
|
421
439
|
/**
|
|
422
440
|
* Get latest revisions by entry IDs.
|
|
423
441
|
*/
|
|
424
|
-
|
|
442
|
+
async getLatestEntriesByIds(initialModel, ids) {
|
|
425
443
|
const permission = await checkEntryPermissions({
|
|
426
444
|
rwd: "r"
|
|
427
445
|
});
|
|
@@ -435,7 +453,8 @@ const createContentEntryCrud = params => {
|
|
|
435
453
|
});
|
|
436
454
|
return entries.filter(entry => (0, _ownership.validateOwnership)(context, permission, entry));
|
|
437
455
|
},
|
|
438
|
-
|
|
456
|
+
|
|
457
|
+
async getEntryRevisions(initialModel, entryId) {
|
|
439
458
|
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
440
459
|
model: initialModel,
|
|
441
460
|
plugins
|
|
@@ -450,7 +469,7 @@ const createContentEntryCrud = params => {
|
|
|
450
469
|
*
|
|
451
470
|
* @internal
|
|
452
471
|
*/
|
|
453
|
-
|
|
472
|
+
async getEntry(initialModel, params) {
|
|
454
473
|
await checkEntryPermissions({
|
|
455
474
|
rwd: "r"
|
|
456
475
|
});
|
|
@@ -462,11 +481,11 @@ const createContentEntryCrud = params => {
|
|
|
462
481
|
where,
|
|
463
482
|
sort
|
|
464
483
|
} = params;
|
|
465
|
-
await
|
|
484
|
+
await onEntryBeforeGet.publish({
|
|
466
485
|
where,
|
|
467
486
|
model
|
|
468
487
|
});
|
|
469
|
-
const [items] = await
|
|
488
|
+
const [items] = await this.listEntries(model, {
|
|
470
489
|
where,
|
|
471
490
|
sort,
|
|
472
491
|
limit: 1
|
|
@@ -484,7 +503,7 @@ const createContentEntryCrud = params => {
|
|
|
484
503
|
*
|
|
485
504
|
* @internal
|
|
486
505
|
*/
|
|
487
|
-
|
|
506
|
+
async listEntries(initialModel, params) {
|
|
488
507
|
const permission = await checkEntryPermissions({
|
|
489
508
|
rwd: "r"
|
|
490
509
|
});
|
|
@@ -500,13 +519,12 @@ const createContentEntryCrud = params => {
|
|
|
500
519
|
* We always assign tenant and locale because we do not allow one model to have content through multiple tenants.
|
|
501
520
|
*/
|
|
502
521
|
|
|
503
|
-
const where =
|
|
522
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
504
523
|
/**
|
|
505
524
|
* Possibly only get records which are owned by current user.
|
|
506
525
|
* Or if searching for the owner set that value - in the case that user can see other entries than their own.
|
|
507
526
|
*/
|
|
508
527
|
|
|
509
|
-
|
|
510
528
|
const ownedBy = permission.own ? getIdentity().id : where.ownedBy;
|
|
511
529
|
|
|
512
530
|
if (ownedBy !== undefined) {
|
|
@@ -528,14 +546,14 @@ const createContentEntryCrud = params => {
|
|
|
528
546
|
});
|
|
529
547
|
}
|
|
530
548
|
|
|
531
|
-
const fields = getSearchableFields({
|
|
532
|
-
model,
|
|
549
|
+
const fields = (0, _searchableFields.getSearchableFields)({
|
|
550
|
+
fields: model.fields,
|
|
533
551
|
plugins: context.plugins,
|
|
534
|
-
|
|
552
|
+
input: params.fields || []
|
|
535
553
|
});
|
|
536
554
|
|
|
537
555
|
try {
|
|
538
|
-
await
|
|
556
|
+
await onEntryBeforeList.publish({
|
|
539
557
|
where,
|
|
540
558
|
model
|
|
541
559
|
});
|
|
@@ -544,7 +562,7 @@ const createContentEntryCrud = params => {
|
|
|
544
562
|
totalCount,
|
|
545
563
|
cursor,
|
|
546
564
|
items
|
|
547
|
-
} = await storageOperations.entries.list(model,
|
|
565
|
+
} = await storageOperations.entries.list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
548
566
|
where,
|
|
549
567
|
fields
|
|
550
568
|
}));
|
|
@@ -562,33 +580,40 @@ const createContentEntryCrud = params => {
|
|
|
562
580
|
} catch (ex) {
|
|
563
581
|
throw new _error.default("Error while fetching entries from storage.", "LIST_ENTRIES_ERROR", {
|
|
564
582
|
params,
|
|
565
|
-
error:
|
|
583
|
+
error: {
|
|
584
|
+
message: ex.message,
|
|
585
|
+
code: ex.code,
|
|
586
|
+
data: ex.data
|
|
587
|
+
},
|
|
566
588
|
model,
|
|
567
589
|
fields
|
|
568
590
|
});
|
|
569
591
|
}
|
|
570
592
|
},
|
|
571
|
-
|
|
593
|
+
|
|
594
|
+
async listLatestEntries(model, params) {
|
|
572
595
|
const where = (params === null || params === void 0 ? void 0 : params.where) || {};
|
|
573
|
-
return
|
|
596
|
+
return this.listEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
574
597
|
sort: ["createdOn_DESC"]
|
|
575
598
|
}, params || {}), {}, {
|
|
576
|
-
where:
|
|
599
|
+
where: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
|
|
577
600
|
latest: true
|
|
578
601
|
})
|
|
579
602
|
}));
|
|
580
603
|
},
|
|
581
|
-
|
|
604
|
+
|
|
605
|
+
async listPublishedEntries(model, params) {
|
|
582
606
|
const where = (params === null || params === void 0 ? void 0 : params.where) || {};
|
|
583
|
-
return
|
|
607
|
+
return this.listEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
584
608
|
sort: ["createdOn_DESC"]
|
|
585
609
|
}, params || {}), {}, {
|
|
586
|
-
where:
|
|
610
|
+
where: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
|
|
587
611
|
published: true
|
|
588
612
|
})
|
|
589
613
|
}));
|
|
590
614
|
},
|
|
591
|
-
|
|
615
|
+
|
|
616
|
+
async createEntry(initialModel, inputData) {
|
|
592
617
|
await checkEntryPermissions({
|
|
593
618
|
rwd: "w"
|
|
594
619
|
});
|
|
@@ -614,7 +639,7 @@ const createContentEntryCrud = params => {
|
|
|
614
639
|
validateEntries: true
|
|
615
640
|
});
|
|
616
641
|
const identity = context.security.getIdentity();
|
|
617
|
-
const locale =
|
|
642
|
+
const locale = this.getLocale();
|
|
618
643
|
const owner = {
|
|
619
644
|
id: identity.id,
|
|
620
645
|
displayName: identity.displayName,
|
|
@@ -644,7 +669,7 @@ const createContentEntryCrud = params => {
|
|
|
644
669
|
let storageEntry = null;
|
|
645
670
|
|
|
646
671
|
try {
|
|
647
|
-
await
|
|
672
|
+
await onEntryBeforeCreate.publish({
|
|
648
673
|
entry,
|
|
649
674
|
input,
|
|
650
675
|
model
|
|
@@ -654,7 +679,7 @@ const createContentEntryCrud = params => {
|
|
|
654
679
|
entry,
|
|
655
680
|
storageEntry
|
|
656
681
|
});
|
|
657
|
-
await
|
|
682
|
+
await onEntryAfterCreate.publish({
|
|
658
683
|
entry,
|
|
659
684
|
storageEntry: result,
|
|
660
685
|
model,
|
|
@@ -662,6 +687,12 @@ const createContentEntryCrud = params => {
|
|
|
662
687
|
});
|
|
663
688
|
return result;
|
|
664
689
|
} catch (ex) {
|
|
690
|
+
await onEntryCreateError.publish({
|
|
691
|
+
error: ex,
|
|
692
|
+
entry,
|
|
693
|
+
model,
|
|
694
|
+
input
|
|
695
|
+
});
|
|
665
696
|
throw new _error.default(ex.message || "Could not create content entry.", ex.code || "CREATE_ENTRY_ERROR", ex.data || {
|
|
666
697
|
error: ex,
|
|
667
698
|
input,
|
|
@@ -670,7 +701,8 @@ const createContentEntryCrud = params => {
|
|
|
670
701
|
});
|
|
671
702
|
}
|
|
672
703
|
},
|
|
673
|
-
|
|
704
|
+
|
|
705
|
+
async createEntryRevisionFrom(initialModel, sourceId, inputData) {
|
|
674
706
|
const permission = await checkEntryPermissions({
|
|
675
707
|
rwd: "w"
|
|
676
708
|
});
|
|
@@ -707,9 +739,7 @@ const createContentEntryCrud = params => {
|
|
|
707
739
|
|
|
708
740
|
|
|
709
741
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
710
|
-
|
|
711
|
-
const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
|
|
712
|
-
|
|
742
|
+
const initialValues = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry.values), input);
|
|
713
743
|
await (0, _entryDataValidation.validateModelEntryData)({
|
|
714
744
|
context,
|
|
715
745
|
model,
|
|
@@ -729,8 +759,7 @@ const createContentEntryCrud = params => {
|
|
|
729
759
|
id,
|
|
730
760
|
version: nextVersion
|
|
731
761
|
} = increaseEntryIdVersion(latestId);
|
|
732
|
-
|
|
733
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
762
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
734
763
|
id,
|
|
735
764
|
version: nextVersion,
|
|
736
765
|
savedOn: new Date().toISOString(),
|
|
@@ -745,11 +774,10 @@ const createContentEntryCrud = params => {
|
|
|
745
774
|
status: STATUS_DRAFT,
|
|
746
775
|
values
|
|
747
776
|
});
|
|
748
|
-
|
|
749
777
|
let storageEntry = null;
|
|
750
778
|
|
|
751
779
|
try {
|
|
752
|
-
await
|
|
780
|
+
await onEntryBeforeCreateRevision.publish({
|
|
753
781
|
input,
|
|
754
782
|
entry,
|
|
755
783
|
original: originalEntry,
|
|
@@ -760,7 +788,7 @@ const createContentEntryCrud = params => {
|
|
|
760
788
|
entry,
|
|
761
789
|
storageEntry
|
|
762
790
|
});
|
|
763
|
-
await
|
|
791
|
+
await onEntryRevisionAfterCreate.publish({
|
|
764
792
|
input,
|
|
765
793
|
entry,
|
|
766
794
|
model,
|
|
@@ -769,6 +797,12 @@ const createContentEntryCrud = params => {
|
|
|
769
797
|
});
|
|
770
798
|
return result;
|
|
771
799
|
} catch (ex) {
|
|
800
|
+
await onEntryCreateRevisionError.publish({
|
|
801
|
+
entry,
|
|
802
|
+
model,
|
|
803
|
+
input,
|
|
804
|
+
error: ex
|
|
805
|
+
});
|
|
772
806
|
throw new _error.default(ex.message || "Could not create entry from existing one.", ex.code || "CREATE_FROM_REVISION_ERROR", {
|
|
773
807
|
error: ex,
|
|
774
808
|
entry,
|
|
@@ -778,7 +812,8 @@ const createContentEntryCrud = params => {
|
|
|
778
812
|
});
|
|
779
813
|
}
|
|
780
814
|
},
|
|
781
|
-
|
|
815
|
+
|
|
816
|
+
async updateEntry(initialModel, id, inputData, metaInput) {
|
|
782
817
|
const permission = await checkEntryPermissions({
|
|
783
818
|
rwd: "w"
|
|
784
819
|
});
|
|
@@ -816,9 +851,7 @@ const createContentEntryCrud = params => {
|
|
|
816
851
|
entry: originalEntry
|
|
817
852
|
});
|
|
818
853
|
(0, _ownership.checkOwnership)(context, permission, originalEntry);
|
|
819
|
-
|
|
820
|
-
const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
|
|
821
|
-
|
|
854
|
+
const initialValues = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry.values), input);
|
|
822
855
|
const values = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
|
|
823
856
|
context,
|
|
824
857
|
model,
|
|
@@ -834,16 +867,16 @@ const createContentEntryCrud = params => {
|
|
|
834
867
|
* We always send the full entry to the hooks and storage operations update.
|
|
835
868
|
*/
|
|
836
869
|
|
|
837
|
-
const entry =
|
|
870
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
838
871
|
savedOn: new Date().toISOString(),
|
|
839
872
|
values,
|
|
840
|
-
meta
|
|
873
|
+
meta,
|
|
874
|
+
status: transformEntryStatus(originalEntry.status)
|
|
841
875
|
});
|
|
842
|
-
|
|
843
876
|
let storageEntry = null;
|
|
844
877
|
|
|
845
878
|
try {
|
|
846
|
-
await
|
|
879
|
+
await onEntryBeforeUpdate.publish({
|
|
847
880
|
entry,
|
|
848
881
|
model,
|
|
849
882
|
input,
|
|
@@ -854,7 +887,7 @@ const createContentEntryCrud = params => {
|
|
|
854
887
|
entry,
|
|
855
888
|
storageEntry
|
|
856
889
|
});
|
|
857
|
-
await
|
|
890
|
+
await onEntryAfterUpdate.publish({
|
|
858
891
|
entry,
|
|
859
892
|
storageEntry: result,
|
|
860
893
|
model,
|
|
@@ -863,6 +896,12 @@ const createContentEntryCrud = params => {
|
|
|
863
896
|
});
|
|
864
897
|
return result;
|
|
865
898
|
} catch (ex) {
|
|
899
|
+
await onEntryUpdateError.publish({
|
|
900
|
+
entry,
|
|
901
|
+
model,
|
|
902
|
+
input,
|
|
903
|
+
error: ex
|
|
904
|
+
});
|
|
866
905
|
throw new _error.default(ex.message || "Could not update existing entry.", ex.code || "UPDATE_ERROR", {
|
|
867
906
|
error: ex,
|
|
868
907
|
entry,
|
|
@@ -872,7 +911,8 @@ const createContentEntryCrud = params => {
|
|
|
872
911
|
});
|
|
873
912
|
}
|
|
874
913
|
},
|
|
875
|
-
|
|
914
|
+
|
|
915
|
+
async republishEntry(initialModel, id) {
|
|
876
916
|
await checkEntryPermissions({
|
|
877
917
|
rwd: "w"
|
|
878
918
|
});
|
|
@@ -911,13 +951,11 @@ const createContentEntryCrud = params => {
|
|
|
911
951
|
input: originalEntry.values,
|
|
912
952
|
validateEntries: false
|
|
913
953
|
});
|
|
914
|
-
|
|
915
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
954
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
916
955
|
savedOn: new Date().toISOString(),
|
|
917
956
|
webinyVersion: context.WEBINY_VERSION,
|
|
918
957
|
values
|
|
919
958
|
});
|
|
920
|
-
|
|
921
959
|
const storageEntry = await (0, _entryStorage.entryToStorageTransform)(context, model, entry);
|
|
922
960
|
/**
|
|
923
961
|
* First we need to update existing entry.
|
|
@@ -949,7 +987,8 @@ const createContentEntryCrud = params => {
|
|
|
949
987
|
});
|
|
950
988
|
}
|
|
951
989
|
},
|
|
952
|
-
|
|
990
|
+
|
|
991
|
+
async deleteEntryRevision(initialModel, revisionId) {
|
|
953
992
|
const permission = await checkEntryPermissions({
|
|
954
993
|
rwd: "d"
|
|
955
994
|
});
|
|
@@ -1005,7 +1044,7 @@ const createContentEntryCrud = params => {
|
|
|
1005
1044
|
}
|
|
1006
1045
|
|
|
1007
1046
|
try {
|
|
1008
|
-
await
|
|
1047
|
+
await onEntryRevisionBeforeDelete.publish({
|
|
1009
1048
|
entry: entryToDelete,
|
|
1010
1049
|
model
|
|
1011
1050
|
});
|
|
@@ -1015,11 +1054,16 @@ const createContentEntryCrud = params => {
|
|
|
1015
1054
|
latestEntry: entryToSetAsLatest,
|
|
1016
1055
|
latestStorageEntry: storageEntryToSetAsLatest
|
|
1017
1056
|
});
|
|
1018
|
-
await
|
|
1057
|
+
await onEntryRevisionAfterDelete.publish({
|
|
1019
1058
|
entry: entryToDelete,
|
|
1020
1059
|
model
|
|
1021
1060
|
});
|
|
1022
1061
|
} catch (ex) {
|
|
1062
|
+
await onEntryRevisionDeleteError.publish({
|
|
1063
|
+
entry: entryToDelete,
|
|
1064
|
+
model,
|
|
1065
|
+
error: ex
|
|
1066
|
+
});
|
|
1023
1067
|
throw new _error.default(ex.message, ex.code || "DELETE_REVISION_ERROR", {
|
|
1024
1068
|
error: ex,
|
|
1025
1069
|
entry: entryToDelete,
|
|
@@ -1029,7 +1073,8 @@ const createContentEntryCrud = params => {
|
|
|
1029
1073
|
});
|
|
1030
1074
|
}
|
|
1031
1075
|
},
|
|
1032
|
-
|
|
1076
|
+
|
|
1077
|
+
async deleteEntry(initialModel, entryId) {
|
|
1033
1078
|
const permission = await checkEntryPermissions({
|
|
1034
1079
|
rwd: "d"
|
|
1035
1080
|
});
|
|
@@ -1053,7 +1098,8 @@ const createContentEntryCrud = params => {
|
|
|
1053
1098
|
entry
|
|
1054
1099
|
});
|
|
1055
1100
|
},
|
|
1056
|
-
|
|
1101
|
+
|
|
1102
|
+
async publishEntry(initialModel, id) {
|
|
1057
1103
|
const permission = await checkEntryPermissions({
|
|
1058
1104
|
pw: "p"
|
|
1059
1105
|
});
|
|
@@ -1073,18 +1119,16 @@ const createContentEntryCrud = params => {
|
|
|
1073
1119
|
(0, _ownership.checkOwnership)(context, permission, originalStorageEntry);
|
|
1074
1120
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
1075
1121
|
const currentDate = new Date().toISOString();
|
|
1076
|
-
|
|
1077
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
1122
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
1078
1123
|
status: STATUS_PUBLISHED,
|
|
1079
1124
|
locked: true,
|
|
1080
1125
|
savedOn: currentDate,
|
|
1081
1126
|
publishedOn: currentDate
|
|
1082
1127
|
});
|
|
1083
|
-
|
|
1084
1128
|
let storageEntry = null;
|
|
1085
1129
|
|
|
1086
1130
|
try {
|
|
1087
|
-
await
|
|
1131
|
+
await onEntryBeforePublish.publish({
|
|
1088
1132
|
entry,
|
|
1089
1133
|
model
|
|
1090
1134
|
});
|
|
@@ -1093,13 +1137,18 @@ const createContentEntryCrud = params => {
|
|
|
1093
1137
|
entry,
|
|
1094
1138
|
storageEntry
|
|
1095
1139
|
});
|
|
1096
|
-
await
|
|
1140
|
+
await onEntryAfterPublish.publish({
|
|
1097
1141
|
entry,
|
|
1098
1142
|
storageEntry: result,
|
|
1099
1143
|
model
|
|
1100
1144
|
});
|
|
1101
1145
|
return result;
|
|
1102
1146
|
} catch (ex) {
|
|
1147
|
+
await onEntryPublishError.publish({
|
|
1148
|
+
entry,
|
|
1149
|
+
model,
|
|
1150
|
+
error: ex
|
|
1151
|
+
});
|
|
1103
1152
|
throw new _error.default(ex.message || "Could not publish entry.", ex.code || "PUBLISH_ERROR", {
|
|
1104
1153
|
error: ex,
|
|
1105
1154
|
entry,
|
|
@@ -1109,130 +1158,8 @@ const createContentEntryCrud = params => {
|
|
|
1109
1158
|
});
|
|
1110
1159
|
}
|
|
1111
1160
|
},
|
|
1112
|
-
requestEntryChanges: async (initialModel, id) => {
|
|
1113
|
-
const permission = await checkEntryPermissions({
|
|
1114
|
-
pw: "c"
|
|
1115
|
-
});
|
|
1116
|
-
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
1117
|
-
model: initialModel,
|
|
1118
|
-
plugins
|
|
1119
|
-
});
|
|
1120
|
-
const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
|
|
1121
|
-
id
|
|
1122
|
-
});
|
|
1123
|
-
|
|
1124
|
-
if (!originalStorageEntry) {
|
|
1125
|
-
throw new _handlerGraphql.NotFoundError(`Entry "${id}" of model "${model.modelId}" was not found.`);
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
1129
1161
|
|
|
1130
|
-
|
|
1131
|
-
throw new _error.default("Cannot request changes on an entry that's not under review.", "ENTRY_NOT_UNDER_REVIEW");
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
const identity = context.security.getIdentity();
|
|
1135
|
-
|
|
1136
|
-
if (originalEntry.ownedBy.id === identity.id) {
|
|
1137
|
-
throw new _error.default("You cannot request changes on your own entry.", "CANNOT_REQUEST_CHANGES_ON_OWN_ENTRY");
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
(0, _ownership.checkOwnership)(context, permission, originalEntry);
|
|
1141
|
-
|
|
1142
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
1143
|
-
status: STATUS_CHANGES_REQUESTED
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
let storageEntry = null;
|
|
1147
|
-
|
|
1148
|
-
try {
|
|
1149
|
-
await onBeforeEntryRequestChanges.publish({
|
|
1150
|
-
entry,
|
|
1151
|
-
model
|
|
1152
|
-
});
|
|
1153
|
-
storageEntry = await (0, _entryStorage.entryToStorageTransform)(context, model, entry);
|
|
1154
|
-
const result = await storageOperations.entries.requestChanges(model, {
|
|
1155
|
-
entry,
|
|
1156
|
-
storageEntry
|
|
1157
|
-
});
|
|
1158
|
-
await onAfterEntryRequestChanges.publish({
|
|
1159
|
-
entry,
|
|
1160
|
-
storageEntry: result,
|
|
1161
|
-
model
|
|
1162
|
-
});
|
|
1163
|
-
return result;
|
|
1164
|
-
} catch (ex) {
|
|
1165
|
-
throw new _error.default(ex.message || "Could not request changes for the entry.", ex.code || "REQUEST_CHANGES_ERROR", {
|
|
1166
|
-
entry,
|
|
1167
|
-
originalEntry
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
},
|
|
1171
|
-
requestEntryReview: async (initialModel, id) => {
|
|
1172
|
-
const permission = await checkEntryPermissions({
|
|
1173
|
-
pw: "r"
|
|
1174
|
-
});
|
|
1175
|
-
const {
|
|
1176
|
-
id: entryId
|
|
1177
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
1178
|
-
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
1179
|
-
model: initialModel,
|
|
1180
|
-
plugins
|
|
1181
|
-
});
|
|
1182
|
-
const originalStorageEntry = await storageOperations.entries.getRevisionById(model, {
|
|
1183
|
-
id
|
|
1184
|
-
});
|
|
1185
|
-
const latestEntryRevision = await storageOperations.entries.getLatestRevisionByEntryId(model, {
|
|
1186
|
-
id: entryId
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
if (!originalStorageEntry) {
|
|
1190
|
-
throw new _handlerGraphql.NotFoundError(`Entry "${id}" of model "${model.modelId}" was not found.`);
|
|
1191
|
-
} else if (!latestEntryRevision) {
|
|
1192
|
-
throw new _handlerGraphql.NotFoundError(`Entry "${id}" does not have latest record`);
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
1196
|
-
const allowedStatuses = [STATUS_DRAFT, STATUS_CHANGES_REQUESTED];
|
|
1197
|
-
|
|
1198
|
-
if (!allowedStatuses.includes(originalEntry.status)) {
|
|
1199
|
-
throw new _error.default("Cannot request review - entry is not a draft nor was a change request issued.", "REQUEST_REVIEW_ERROR", {
|
|
1200
|
-
entry: originalEntry
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
(0, _ownership.checkOwnership)(context, permission, originalEntry);
|
|
1205
|
-
|
|
1206
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
1207
|
-
status: STATUS_REVIEW_REQUESTED
|
|
1208
|
-
});
|
|
1209
|
-
|
|
1210
|
-
let storageEntry = null;
|
|
1211
|
-
|
|
1212
|
-
try {
|
|
1213
|
-
await onBeforeEntryRequestReview.publish({
|
|
1214
|
-
entry,
|
|
1215
|
-
model
|
|
1216
|
-
});
|
|
1217
|
-
storageEntry = await (0, _entryStorage.entryToStorageTransform)(context, model, entry);
|
|
1218
|
-
const result = await storageOperations.entries.requestReview(model, {
|
|
1219
|
-
entry,
|
|
1220
|
-
storageEntry
|
|
1221
|
-
});
|
|
1222
|
-
await onAfterEntryRequestReview.publish({
|
|
1223
|
-
entry,
|
|
1224
|
-
storageEntry: result,
|
|
1225
|
-
model
|
|
1226
|
-
});
|
|
1227
|
-
return result;
|
|
1228
|
-
} catch (ex) {
|
|
1229
|
-
throw new _error.default(ex.message || "Could not request review on the entry.", ex.code || "REQUEST_REVIEW_ERROR", {
|
|
1230
|
-
originalEntry,
|
|
1231
|
-
entry
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
},
|
|
1235
|
-
unpublishEntry: async (initialModel, id) => {
|
|
1162
|
+
async unpublishEntry(initialModel, id) {
|
|
1236
1163
|
const permission = await checkEntryPermissions({
|
|
1237
1164
|
pw: "u"
|
|
1238
1165
|
});
|
|
@@ -1259,15 +1186,13 @@ const createContentEntryCrud = params => {
|
|
|
1259
1186
|
|
|
1260
1187
|
(0, _ownership.checkOwnership)(context, permission, originalStorageEntry);
|
|
1261
1188
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
1262
|
-
|
|
1263
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
1189
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
1264
1190
|
status: STATUS_UNPUBLISHED
|
|
1265
1191
|
});
|
|
1266
|
-
|
|
1267
1192
|
let storageEntry = null;
|
|
1268
1193
|
|
|
1269
1194
|
try {
|
|
1270
|
-
await
|
|
1195
|
+
await onEntryBeforeUnpublish.publish({
|
|
1271
1196
|
entry,
|
|
1272
1197
|
model
|
|
1273
1198
|
});
|
|
@@ -1276,13 +1201,18 @@ const createContentEntryCrud = params => {
|
|
|
1276
1201
|
entry,
|
|
1277
1202
|
storageEntry
|
|
1278
1203
|
});
|
|
1279
|
-
await
|
|
1204
|
+
await onEntryAfterUnpublish.publish({
|
|
1280
1205
|
entry,
|
|
1281
1206
|
storageEntry: result,
|
|
1282
1207
|
model
|
|
1283
1208
|
});
|
|
1284
1209
|
return result;
|
|
1285
1210
|
} catch (ex) {
|
|
1211
|
+
await onEntryUnpublishError.publish({
|
|
1212
|
+
entry,
|
|
1213
|
+
model,
|
|
1214
|
+
error: ex
|
|
1215
|
+
});
|
|
1286
1216
|
throw new _error.default(ex.message || "Could not unpublish entry.", ex.code || "UNPUBLISH_ERROR", {
|
|
1287
1217
|
originalEntry,
|
|
1288
1218
|
originalStorageEntry,
|
|
@@ -1291,6 +1221,7 @@ const createContentEntryCrud = params => {
|
|
|
1291
1221
|
});
|
|
1292
1222
|
}
|
|
1293
1223
|
}
|
|
1224
|
+
|
|
1294
1225
|
};
|
|
1295
1226
|
};
|
|
1296
1227
|
|