@webiny/api-headless-cms 0.0.0-unstable.8c4d9f045a → 0.0.0-unstable.fcdad0bc61
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.crud.d.ts +0 -2
- package/crud/contentEntry.crud.js +199 -241
- 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/index.d.ts +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 +3 -7
- 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/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/object.js +1 -1
- package/graphqlFields/ref.js +4 -8
- package/graphqlFields/ref.js.map +1 -1
- package/index.d.ts +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.js +1 -1
- package/storage/object.js +3 -7
- package/storage/object.js.map +1 -1
- package/types.d.ts +267 -126
- 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 +7 -0
- 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,16 @@ var _entryStorage = require("../utils/entryStorage");
|
|
|
41
41
|
|
|
42
42
|
var _valueKeyStorageConverter = require("../utils/converters/valueKeyStorageConverter");
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Package mdbid does not have types.
|
|
46
|
+
*/
|
|
47
|
+
// @ts-ignore
|
|
48
48
|
const STATUS_DRAFT = "draft";
|
|
49
49
|
exports.STATUS_DRAFT = STATUS_DRAFT;
|
|
50
50
|
const STATUS_PUBLISHED = "published";
|
|
51
51
|
exports.STATUS_PUBLISHED = STATUS_PUBLISHED;
|
|
52
52
|
const STATUS_UNPUBLISHED = "unpublished";
|
|
53
53
|
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
54
|
|
|
59
55
|
/**
|
|
60
56
|
* Used for some fields to convert their values.
|
|
@@ -250,6 +246,12 @@ const getSearchableFields = params => {
|
|
|
250
246
|
}).map(field => field.fieldId);
|
|
251
247
|
};
|
|
252
248
|
|
|
249
|
+
const allowedEntryStatus = ["draft", "published", "unpublished"];
|
|
250
|
+
|
|
251
|
+
const transformEntryStatus = status => {
|
|
252
|
+
return allowedEntryStatus.includes(status) ? status : "draft";
|
|
253
|
+
};
|
|
254
|
+
|
|
253
255
|
const createContentEntryCrud = params => {
|
|
254
256
|
const {
|
|
255
257
|
storageOperations,
|
|
@@ -259,42 +261,54 @@ const createContentEntryCrud = params => {
|
|
|
259
261
|
} = params;
|
|
260
262
|
const {
|
|
261
263
|
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
|
|
264
|
+
} = context; // create
|
|
265
|
+
|
|
266
|
+
const onEntryBeforeCreate = (0, _pubsub.createTopic)("cms.onEntryBeforeCreate");
|
|
267
|
+
const onEntryAfterCreate = (0, _pubsub.createTopic)("cms.onEntryAfterCreate");
|
|
268
|
+
const onEntryCreateError = (0, _pubsub.createTopic)("cms.onEntryCreateError"); // create revision
|
|
269
|
+
|
|
270
|
+
const onEntryBeforeCreateRevision = (0, _pubsub.createTopic)("cms.onEntryBeforeCreateRevision");
|
|
271
|
+
const onEntryRevisionAfterCreate = (0, _pubsub.createTopic)("cms.onEntryRevisionAfterCreate");
|
|
272
|
+
const onEntryCreateRevisionError = (0, _pubsub.createTopic)("cms.onEntryCreateRevisionError"); // update
|
|
273
|
+
|
|
274
|
+
const onEntryBeforeUpdate = (0, _pubsub.createTopic)("cms.onEntryBeforeUpdate");
|
|
275
|
+
const onEntryAfterUpdate = (0, _pubsub.createTopic)("cms.onEntryAfterUpdate");
|
|
276
|
+
const onEntryUpdateError = (0, _pubsub.createTopic)("cms.onEntryUpdateError"); // publish
|
|
277
|
+
|
|
278
|
+
const onEntryBeforePublish = (0, _pubsub.createTopic)("cms.onEntryBeforePublish");
|
|
279
|
+
const onEntryAfterPublish = (0, _pubsub.createTopic)("cms.onEntryAfterPublic");
|
|
280
|
+
const onEntryPublishError = (0, _pubsub.createTopic)("cms.onEntryPublishError"); // unpublish
|
|
281
|
+
|
|
282
|
+
const onEntryBeforeUnpublish = (0, _pubsub.createTopic)("cms.onEntryBeforeUnpublish");
|
|
283
|
+
const onEntryAfterUnpublish = (0, _pubsub.createTopic)("cms.onEntryAfterUnpublish");
|
|
284
|
+
const onEntryUnpublishError = (0, _pubsub.createTopic)("cms.onEntryUnpublishError"); // delete
|
|
285
|
+
|
|
286
|
+
const onEntryBeforeDelete = (0, _pubsub.createTopic)("cms.onEntryBeforeDelete");
|
|
287
|
+
const onEntryAfterDelete = (0, _pubsub.createTopic)("cms.onEntryAfterDelete");
|
|
288
|
+
const onEntryDeleteError = (0, _pubsub.createTopic)("cms.onEntryDeleteError"); // delete revision
|
|
289
|
+
|
|
290
|
+
const onEntryRevisionBeforeDelete = (0, _pubsub.createTopic)("cms.onEntryRevisionBeforeDelete");
|
|
291
|
+
const onEntryRevisionAfterDelete = (0, _pubsub.createTopic)("cms.onEntryRevisionAfterDelete");
|
|
292
|
+
const onEntryRevisionDeleteError = (0, _pubsub.createTopic)("cms.onEntryRevisionDeleteError"); // get
|
|
293
|
+
|
|
294
|
+
const onEntryBeforeGet = (0, _pubsub.createTopic)("cms.onEntryBeforeGet"); // list
|
|
295
|
+
|
|
296
|
+
const onEntryBeforeList = (0, _pubsub.createTopic)("cms.onEntryBeforeList");
|
|
283
297
|
/**
|
|
284
298
|
* We need to assign some default behaviors.
|
|
285
299
|
*/
|
|
286
300
|
|
|
287
301
|
(0, _beforeCreate.assignBeforeEntryCreate)({
|
|
288
302
|
context,
|
|
289
|
-
|
|
303
|
+
onEntryBeforeCreate
|
|
290
304
|
});
|
|
291
305
|
(0, _beforeUpdate.assignBeforeEntryUpdate)({
|
|
292
306
|
context,
|
|
293
|
-
|
|
307
|
+
onEntryBeforeUpdate
|
|
294
308
|
});
|
|
295
309
|
(0, _afterDelete.assignAfterEntryDelete)({
|
|
296
310
|
context,
|
|
297
|
-
|
|
311
|
+
onEntryAfterDelete
|
|
298
312
|
});
|
|
299
313
|
|
|
300
314
|
const checkEntryPermissions = check => {
|
|
@@ -312,18 +326,23 @@ const createContentEntryCrud = params => {
|
|
|
312
326
|
} = params;
|
|
313
327
|
|
|
314
328
|
try {
|
|
315
|
-
await
|
|
329
|
+
await onEntryBeforeDelete.publish({
|
|
316
330
|
entry,
|
|
317
331
|
model
|
|
318
332
|
});
|
|
319
333
|
await storageOperations.entries.delete(model, {
|
|
320
334
|
entry
|
|
321
335
|
});
|
|
322
|
-
await
|
|
336
|
+
await onEntryAfterDelete.publish({
|
|
323
337
|
entry,
|
|
324
338
|
model
|
|
325
339
|
});
|
|
326
340
|
} catch (ex) {
|
|
341
|
+
await onEntryDeleteError.publish({
|
|
342
|
+
entry,
|
|
343
|
+
model,
|
|
344
|
+
error: ex
|
|
345
|
+
});
|
|
327
346
|
throw new _error.default(ex.message || "Could not delete entry.", ex.code || "DELETE_ERROR", {
|
|
328
347
|
entry
|
|
329
348
|
});
|
|
@@ -350,26 +369,52 @@ const createContentEntryCrud = params => {
|
|
|
350
369
|
};
|
|
351
370
|
|
|
352
371
|
return {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
372
|
+
/**
|
|
373
|
+
* Deprecated - will be removed in 5.35.0
|
|
374
|
+
*/
|
|
375
|
+
onBeforeEntryCreate: onEntryBeforeCreate,
|
|
376
|
+
onAfterEntryCreate: onEntryAfterCreate,
|
|
377
|
+
onBeforeEntryCreateRevision: onEntryBeforeCreateRevision,
|
|
378
|
+
onAfterEntryCreateRevision: onEntryRevisionAfterCreate,
|
|
379
|
+
onBeforeEntryUpdate: onEntryBeforeUpdate,
|
|
380
|
+
onAfterEntryUpdate: onEntryAfterUpdate,
|
|
381
|
+
onBeforeEntryDelete: onEntryBeforeDelete,
|
|
382
|
+
onAfterEntryDelete: onEntryAfterDelete,
|
|
383
|
+
onBeforeEntryDeleteRevision: onEntryRevisionBeforeDelete,
|
|
384
|
+
onAfterEntryDeleteRevision: onEntryRevisionAfterDelete,
|
|
385
|
+
onBeforeEntryPublish: onEntryBeforePublish,
|
|
386
|
+
onAfterEntryPublish: onEntryAfterPublish,
|
|
387
|
+
onBeforeEntryUnpublish: onEntryBeforeUnpublish,
|
|
388
|
+
onAfterEntryUnpublish: onEntryAfterUnpublish,
|
|
389
|
+
onBeforeEntryGet: onEntryBeforeGet,
|
|
390
|
+
onBeforeEntryList: onEntryBeforeList,
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Released in 5.34.0
|
|
394
|
+
*/
|
|
395
|
+
onEntryBeforeCreate,
|
|
396
|
+
onEntryAfterCreate,
|
|
397
|
+
onEntryCreateError,
|
|
398
|
+
onEntryRevisionBeforeCreate: onEntryBeforeCreateRevision,
|
|
399
|
+
onEntryRevisionAfterCreate,
|
|
400
|
+
onEntryRevisionCreateError: onEntryCreateRevisionError,
|
|
401
|
+
onEntryBeforeUpdate,
|
|
402
|
+
onEntryAfterUpdate,
|
|
403
|
+
onEntryUpdateError,
|
|
404
|
+
onEntryBeforeDelete,
|
|
405
|
+
onEntryAfterDelete,
|
|
406
|
+
onEntryDeleteError,
|
|
407
|
+
onEntryRevisionBeforeDelete,
|
|
408
|
+
onEntryRevisionAfterDelete,
|
|
409
|
+
onEntryRevisionDeleteError,
|
|
410
|
+
onEntryBeforePublish,
|
|
411
|
+
onEntryAfterPublish,
|
|
412
|
+
onEntryPublishError,
|
|
413
|
+
onEntryBeforeUnpublish,
|
|
414
|
+
onEntryAfterUnpublish,
|
|
415
|
+
onEntryUnpublishError,
|
|
416
|
+
onEntryBeforeGet,
|
|
417
|
+
onEntryBeforeList,
|
|
373
418
|
|
|
374
419
|
/**
|
|
375
420
|
* Get entries by exact revision IDs from the database.
|
|
@@ -379,7 +424,7 @@ const createContentEntryCrud = params => {
|
|
|
379
424
|
/**
|
|
380
425
|
* Get a single entry by revision ID from the database.
|
|
381
426
|
*/
|
|
382
|
-
|
|
427
|
+
async getEntryById(initialModel, id) {
|
|
383
428
|
const where = {
|
|
384
429
|
id
|
|
385
430
|
};
|
|
@@ -387,7 +432,7 @@ const createContentEntryCrud = params => {
|
|
|
387
432
|
model: initialModel,
|
|
388
433
|
plugins
|
|
389
434
|
});
|
|
390
|
-
await
|
|
435
|
+
await onEntryBeforeGet.publish({
|
|
391
436
|
where,
|
|
392
437
|
model
|
|
393
438
|
});
|
|
@@ -403,7 +448,7 @@ const createContentEntryCrud = params => {
|
|
|
403
448
|
/**
|
|
404
449
|
* Get published revisions by entry IDs.
|
|
405
450
|
*/
|
|
406
|
-
|
|
451
|
+
async getPublishedEntriesByIds(initialModel, ids) {
|
|
407
452
|
const permission = await checkEntryPermissions({
|
|
408
453
|
rwd: "r"
|
|
409
454
|
});
|
|
@@ -421,7 +466,7 @@ const createContentEntryCrud = params => {
|
|
|
421
466
|
/**
|
|
422
467
|
* Get latest revisions by entry IDs.
|
|
423
468
|
*/
|
|
424
|
-
|
|
469
|
+
async getLatestEntriesByIds(initialModel, ids) {
|
|
425
470
|
const permission = await checkEntryPermissions({
|
|
426
471
|
rwd: "r"
|
|
427
472
|
});
|
|
@@ -435,7 +480,8 @@ const createContentEntryCrud = params => {
|
|
|
435
480
|
});
|
|
436
481
|
return entries.filter(entry => (0, _ownership.validateOwnership)(context, permission, entry));
|
|
437
482
|
},
|
|
438
|
-
|
|
483
|
+
|
|
484
|
+
async getEntryRevisions(initialModel, entryId) {
|
|
439
485
|
const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
|
|
440
486
|
model: initialModel,
|
|
441
487
|
plugins
|
|
@@ -450,7 +496,7 @@ const createContentEntryCrud = params => {
|
|
|
450
496
|
*
|
|
451
497
|
* @internal
|
|
452
498
|
*/
|
|
453
|
-
|
|
499
|
+
async getEntry(initialModel, params) {
|
|
454
500
|
await checkEntryPermissions({
|
|
455
501
|
rwd: "r"
|
|
456
502
|
});
|
|
@@ -462,11 +508,11 @@ const createContentEntryCrud = params => {
|
|
|
462
508
|
where,
|
|
463
509
|
sort
|
|
464
510
|
} = params;
|
|
465
|
-
await
|
|
511
|
+
await onEntryBeforeGet.publish({
|
|
466
512
|
where,
|
|
467
513
|
model
|
|
468
514
|
});
|
|
469
|
-
const [items] = await
|
|
515
|
+
const [items] = await this.listEntries(model, {
|
|
470
516
|
where,
|
|
471
517
|
sort,
|
|
472
518
|
limit: 1
|
|
@@ -484,7 +530,7 @@ const createContentEntryCrud = params => {
|
|
|
484
530
|
*
|
|
485
531
|
* @internal
|
|
486
532
|
*/
|
|
487
|
-
|
|
533
|
+
async listEntries(initialModel, params) {
|
|
488
534
|
const permission = await checkEntryPermissions({
|
|
489
535
|
rwd: "r"
|
|
490
536
|
});
|
|
@@ -500,13 +546,12 @@ const createContentEntryCrud = params => {
|
|
|
500
546
|
* We always assign tenant and locale because we do not allow one model to have content through multiple tenants.
|
|
501
547
|
*/
|
|
502
548
|
|
|
503
|
-
const where =
|
|
549
|
+
const where = (0, _objectSpread2.default)({}, initialWhere);
|
|
504
550
|
/**
|
|
505
551
|
* Possibly only get records which are owned by current user.
|
|
506
552
|
* Or if searching for the owner set that value - in the case that user can see other entries than their own.
|
|
507
553
|
*/
|
|
508
554
|
|
|
509
|
-
|
|
510
555
|
const ownedBy = permission.own ? getIdentity().id : where.ownedBy;
|
|
511
556
|
|
|
512
557
|
if (ownedBy !== undefined) {
|
|
@@ -535,7 +580,7 @@ const createContentEntryCrud = params => {
|
|
|
535
580
|
});
|
|
536
581
|
|
|
537
582
|
try {
|
|
538
|
-
await
|
|
583
|
+
await onEntryBeforeList.publish({
|
|
539
584
|
where,
|
|
540
585
|
model
|
|
541
586
|
});
|
|
@@ -544,7 +589,7 @@ const createContentEntryCrud = params => {
|
|
|
544
589
|
totalCount,
|
|
545
590
|
cursor,
|
|
546
591
|
items
|
|
547
|
-
} = await storageOperations.entries.list(model,
|
|
592
|
+
} = await storageOperations.entries.list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
548
593
|
where,
|
|
549
594
|
fields
|
|
550
595
|
}));
|
|
@@ -562,33 +607,40 @@ const createContentEntryCrud = params => {
|
|
|
562
607
|
} catch (ex) {
|
|
563
608
|
throw new _error.default("Error while fetching entries from storage.", "LIST_ENTRIES_ERROR", {
|
|
564
609
|
params,
|
|
565
|
-
error:
|
|
610
|
+
error: {
|
|
611
|
+
message: ex.message,
|
|
612
|
+
code: ex.code,
|
|
613
|
+
data: ex.data
|
|
614
|
+
},
|
|
566
615
|
model,
|
|
567
616
|
fields
|
|
568
617
|
});
|
|
569
618
|
}
|
|
570
619
|
},
|
|
571
|
-
|
|
620
|
+
|
|
621
|
+
async listLatestEntries(model, params) {
|
|
572
622
|
const where = (params === null || params === void 0 ? void 0 : params.where) || {};
|
|
573
|
-
return
|
|
623
|
+
return this.listEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
574
624
|
sort: ["createdOn_DESC"]
|
|
575
625
|
}, params || {}), {}, {
|
|
576
|
-
where:
|
|
626
|
+
where: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
|
|
577
627
|
latest: true
|
|
578
628
|
})
|
|
579
629
|
}));
|
|
580
630
|
},
|
|
581
|
-
|
|
631
|
+
|
|
632
|
+
async listPublishedEntries(model, params) {
|
|
582
633
|
const where = (params === null || params === void 0 ? void 0 : params.where) || {};
|
|
583
|
-
return
|
|
634
|
+
return this.listEntries(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
584
635
|
sort: ["createdOn_DESC"]
|
|
585
636
|
}, params || {}), {}, {
|
|
586
|
-
where:
|
|
637
|
+
where: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, where), {}, {
|
|
587
638
|
published: true
|
|
588
639
|
})
|
|
589
640
|
}));
|
|
590
641
|
},
|
|
591
|
-
|
|
642
|
+
|
|
643
|
+
async createEntry(initialModel, inputData) {
|
|
592
644
|
await checkEntryPermissions({
|
|
593
645
|
rwd: "w"
|
|
594
646
|
});
|
|
@@ -614,7 +666,7 @@ const createContentEntryCrud = params => {
|
|
|
614
666
|
validateEntries: true
|
|
615
667
|
});
|
|
616
668
|
const identity = context.security.getIdentity();
|
|
617
|
-
const locale =
|
|
669
|
+
const locale = this.getLocale();
|
|
618
670
|
const owner = {
|
|
619
671
|
id: identity.id,
|
|
620
672
|
displayName: identity.displayName,
|
|
@@ -644,7 +696,7 @@ const createContentEntryCrud = params => {
|
|
|
644
696
|
let storageEntry = null;
|
|
645
697
|
|
|
646
698
|
try {
|
|
647
|
-
await
|
|
699
|
+
await onEntryBeforeCreate.publish({
|
|
648
700
|
entry,
|
|
649
701
|
input,
|
|
650
702
|
model
|
|
@@ -654,7 +706,7 @@ const createContentEntryCrud = params => {
|
|
|
654
706
|
entry,
|
|
655
707
|
storageEntry
|
|
656
708
|
});
|
|
657
|
-
await
|
|
709
|
+
await onEntryAfterCreate.publish({
|
|
658
710
|
entry,
|
|
659
711
|
storageEntry: result,
|
|
660
712
|
model,
|
|
@@ -662,6 +714,12 @@ const createContentEntryCrud = params => {
|
|
|
662
714
|
});
|
|
663
715
|
return result;
|
|
664
716
|
} catch (ex) {
|
|
717
|
+
await onEntryCreateError.publish({
|
|
718
|
+
error: ex,
|
|
719
|
+
entry,
|
|
720
|
+
model,
|
|
721
|
+
input
|
|
722
|
+
});
|
|
665
723
|
throw new _error.default(ex.message || "Could not create content entry.", ex.code || "CREATE_ENTRY_ERROR", ex.data || {
|
|
666
724
|
error: ex,
|
|
667
725
|
input,
|
|
@@ -670,7 +728,8 @@ const createContentEntryCrud = params => {
|
|
|
670
728
|
});
|
|
671
729
|
}
|
|
672
730
|
},
|
|
673
|
-
|
|
731
|
+
|
|
732
|
+
async createEntryRevisionFrom(initialModel, sourceId, inputData) {
|
|
674
733
|
const permission = await checkEntryPermissions({
|
|
675
734
|
rwd: "w"
|
|
676
735
|
});
|
|
@@ -707,9 +766,7 @@ const createContentEntryCrud = params => {
|
|
|
707
766
|
|
|
708
767
|
|
|
709
768
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
710
|
-
|
|
711
|
-
const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
|
|
712
|
-
|
|
769
|
+
const initialValues = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry.values), input);
|
|
713
770
|
await (0, _entryDataValidation.validateModelEntryData)({
|
|
714
771
|
context,
|
|
715
772
|
model,
|
|
@@ -729,8 +786,7 @@ const createContentEntryCrud = params => {
|
|
|
729
786
|
id,
|
|
730
787
|
version: nextVersion
|
|
731
788
|
} = increaseEntryIdVersion(latestId);
|
|
732
|
-
|
|
733
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
789
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
734
790
|
id,
|
|
735
791
|
version: nextVersion,
|
|
736
792
|
savedOn: new Date().toISOString(),
|
|
@@ -745,11 +801,10 @@ const createContentEntryCrud = params => {
|
|
|
745
801
|
status: STATUS_DRAFT,
|
|
746
802
|
values
|
|
747
803
|
});
|
|
748
|
-
|
|
749
804
|
let storageEntry = null;
|
|
750
805
|
|
|
751
806
|
try {
|
|
752
|
-
await
|
|
807
|
+
await onEntryBeforeCreateRevision.publish({
|
|
753
808
|
input,
|
|
754
809
|
entry,
|
|
755
810
|
original: originalEntry,
|
|
@@ -760,7 +815,7 @@ const createContentEntryCrud = params => {
|
|
|
760
815
|
entry,
|
|
761
816
|
storageEntry
|
|
762
817
|
});
|
|
763
|
-
await
|
|
818
|
+
await onEntryRevisionAfterCreate.publish({
|
|
764
819
|
input,
|
|
765
820
|
entry,
|
|
766
821
|
model,
|
|
@@ -769,6 +824,12 @@ const createContentEntryCrud = params => {
|
|
|
769
824
|
});
|
|
770
825
|
return result;
|
|
771
826
|
} catch (ex) {
|
|
827
|
+
await onEntryCreateRevisionError.publish({
|
|
828
|
+
entry,
|
|
829
|
+
model,
|
|
830
|
+
input,
|
|
831
|
+
error: ex
|
|
832
|
+
});
|
|
772
833
|
throw new _error.default(ex.message || "Could not create entry from existing one.", ex.code || "CREATE_FROM_REVISION_ERROR", {
|
|
773
834
|
error: ex,
|
|
774
835
|
entry,
|
|
@@ -778,7 +839,8 @@ const createContentEntryCrud = params => {
|
|
|
778
839
|
});
|
|
779
840
|
}
|
|
780
841
|
},
|
|
781
|
-
|
|
842
|
+
|
|
843
|
+
async updateEntry(initialModel, id, inputData, metaInput) {
|
|
782
844
|
const permission = await checkEntryPermissions({
|
|
783
845
|
rwd: "w"
|
|
784
846
|
});
|
|
@@ -816,9 +878,7 @@ const createContentEntryCrud = params => {
|
|
|
816
878
|
entry: originalEntry
|
|
817
879
|
});
|
|
818
880
|
(0, _ownership.checkOwnership)(context, permission, originalEntry);
|
|
819
|
-
|
|
820
|
-
const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
|
|
821
|
-
|
|
881
|
+
const initialValues = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry.values), input);
|
|
822
882
|
const values = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
|
|
823
883
|
context,
|
|
824
884
|
model,
|
|
@@ -834,16 +894,16 @@ const createContentEntryCrud = params => {
|
|
|
834
894
|
* We always send the full entry to the hooks and storage operations update.
|
|
835
895
|
*/
|
|
836
896
|
|
|
837
|
-
const entry =
|
|
897
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
838
898
|
savedOn: new Date().toISOString(),
|
|
839
899
|
values,
|
|
840
|
-
meta
|
|
900
|
+
meta,
|
|
901
|
+
status: transformEntryStatus(originalEntry.status)
|
|
841
902
|
});
|
|
842
|
-
|
|
843
903
|
let storageEntry = null;
|
|
844
904
|
|
|
845
905
|
try {
|
|
846
|
-
await
|
|
906
|
+
await onEntryBeforeUpdate.publish({
|
|
847
907
|
entry,
|
|
848
908
|
model,
|
|
849
909
|
input,
|
|
@@ -854,7 +914,7 @@ const createContentEntryCrud = params => {
|
|
|
854
914
|
entry,
|
|
855
915
|
storageEntry
|
|
856
916
|
});
|
|
857
|
-
await
|
|
917
|
+
await onEntryAfterUpdate.publish({
|
|
858
918
|
entry,
|
|
859
919
|
storageEntry: result,
|
|
860
920
|
model,
|
|
@@ -863,6 +923,12 @@ const createContentEntryCrud = params => {
|
|
|
863
923
|
});
|
|
864
924
|
return result;
|
|
865
925
|
} catch (ex) {
|
|
926
|
+
await onEntryUpdateError.publish({
|
|
927
|
+
entry,
|
|
928
|
+
model,
|
|
929
|
+
input,
|
|
930
|
+
error: ex
|
|
931
|
+
});
|
|
866
932
|
throw new _error.default(ex.message || "Could not update existing entry.", ex.code || "UPDATE_ERROR", {
|
|
867
933
|
error: ex,
|
|
868
934
|
entry,
|
|
@@ -872,7 +938,8 @@ const createContentEntryCrud = params => {
|
|
|
872
938
|
});
|
|
873
939
|
}
|
|
874
940
|
},
|
|
875
|
-
|
|
941
|
+
|
|
942
|
+
async republishEntry(initialModel, id) {
|
|
876
943
|
await checkEntryPermissions({
|
|
877
944
|
rwd: "w"
|
|
878
945
|
});
|
|
@@ -911,13 +978,11 @@ const createContentEntryCrud = params => {
|
|
|
911
978
|
input: originalEntry.values,
|
|
912
979
|
validateEntries: false
|
|
913
980
|
});
|
|
914
|
-
|
|
915
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
981
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
916
982
|
savedOn: new Date().toISOString(),
|
|
917
983
|
webinyVersion: context.WEBINY_VERSION,
|
|
918
984
|
values
|
|
919
985
|
});
|
|
920
|
-
|
|
921
986
|
const storageEntry = await (0, _entryStorage.entryToStorageTransform)(context, model, entry);
|
|
922
987
|
/**
|
|
923
988
|
* First we need to update existing entry.
|
|
@@ -949,7 +1014,8 @@ const createContentEntryCrud = params => {
|
|
|
949
1014
|
});
|
|
950
1015
|
}
|
|
951
1016
|
},
|
|
952
|
-
|
|
1017
|
+
|
|
1018
|
+
async deleteEntryRevision(initialModel, revisionId) {
|
|
953
1019
|
const permission = await checkEntryPermissions({
|
|
954
1020
|
rwd: "d"
|
|
955
1021
|
});
|
|
@@ -1005,7 +1071,7 @@ const createContentEntryCrud = params => {
|
|
|
1005
1071
|
}
|
|
1006
1072
|
|
|
1007
1073
|
try {
|
|
1008
|
-
await
|
|
1074
|
+
await onEntryRevisionBeforeDelete.publish({
|
|
1009
1075
|
entry: entryToDelete,
|
|
1010
1076
|
model
|
|
1011
1077
|
});
|
|
@@ -1015,11 +1081,16 @@ const createContentEntryCrud = params => {
|
|
|
1015
1081
|
latestEntry: entryToSetAsLatest,
|
|
1016
1082
|
latestStorageEntry: storageEntryToSetAsLatest
|
|
1017
1083
|
});
|
|
1018
|
-
await
|
|
1084
|
+
await onEntryRevisionAfterDelete.publish({
|
|
1019
1085
|
entry: entryToDelete,
|
|
1020
1086
|
model
|
|
1021
1087
|
});
|
|
1022
1088
|
} catch (ex) {
|
|
1089
|
+
await onEntryRevisionDeleteError.publish({
|
|
1090
|
+
entry: entryToDelete,
|
|
1091
|
+
model,
|
|
1092
|
+
error: ex
|
|
1093
|
+
});
|
|
1023
1094
|
throw new _error.default(ex.message, ex.code || "DELETE_REVISION_ERROR", {
|
|
1024
1095
|
error: ex,
|
|
1025
1096
|
entry: entryToDelete,
|
|
@@ -1029,7 +1100,8 @@ const createContentEntryCrud = params => {
|
|
|
1029
1100
|
});
|
|
1030
1101
|
}
|
|
1031
1102
|
},
|
|
1032
|
-
|
|
1103
|
+
|
|
1104
|
+
async deleteEntry(initialModel, entryId) {
|
|
1033
1105
|
const permission = await checkEntryPermissions({
|
|
1034
1106
|
rwd: "d"
|
|
1035
1107
|
});
|
|
@@ -1053,7 +1125,8 @@ const createContentEntryCrud = params => {
|
|
|
1053
1125
|
entry
|
|
1054
1126
|
});
|
|
1055
1127
|
},
|
|
1056
|
-
|
|
1128
|
+
|
|
1129
|
+
async publishEntry(initialModel, id) {
|
|
1057
1130
|
const permission = await checkEntryPermissions({
|
|
1058
1131
|
pw: "p"
|
|
1059
1132
|
});
|
|
@@ -1073,18 +1146,16 @@ const createContentEntryCrud = params => {
|
|
|
1073
1146
|
(0, _ownership.checkOwnership)(context, permission, originalStorageEntry);
|
|
1074
1147
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
1075
1148
|
const currentDate = new Date().toISOString();
|
|
1076
|
-
|
|
1077
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
1149
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
1078
1150
|
status: STATUS_PUBLISHED,
|
|
1079
1151
|
locked: true,
|
|
1080
1152
|
savedOn: currentDate,
|
|
1081
1153
|
publishedOn: currentDate
|
|
1082
1154
|
});
|
|
1083
|
-
|
|
1084
1155
|
let storageEntry = null;
|
|
1085
1156
|
|
|
1086
1157
|
try {
|
|
1087
|
-
await
|
|
1158
|
+
await onEntryBeforePublish.publish({
|
|
1088
1159
|
entry,
|
|
1089
1160
|
model
|
|
1090
1161
|
});
|
|
@@ -1093,13 +1164,18 @@ const createContentEntryCrud = params => {
|
|
|
1093
1164
|
entry,
|
|
1094
1165
|
storageEntry
|
|
1095
1166
|
});
|
|
1096
|
-
await
|
|
1167
|
+
await onEntryAfterPublish.publish({
|
|
1097
1168
|
entry,
|
|
1098
1169
|
storageEntry: result,
|
|
1099
1170
|
model
|
|
1100
1171
|
});
|
|
1101
1172
|
return result;
|
|
1102
1173
|
} catch (ex) {
|
|
1174
|
+
await onEntryPublishError.publish({
|
|
1175
|
+
entry,
|
|
1176
|
+
model,
|
|
1177
|
+
error: ex
|
|
1178
|
+
});
|
|
1103
1179
|
throw new _error.default(ex.message || "Could not publish entry.", ex.code || "PUBLISH_ERROR", {
|
|
1104
1180
|
error: ex,
|
|
1105
1181
|
entry,
|
|
@@ -1109,130 +1185,8 @@ const createContentEntryCrud = params => {
|
|
|
1109
1185
|
});
|
|
1110
1186
|
}
|
|
1111
1187
|
},
|
|
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
|
-
|
|
1130
|
-
if (originalEntry.status !== STATUS_REVIEW_REQUESTED) {
|
|
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
1188
|
|
|
1195
|
-
|
|
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) => {
|
|
1189
|
+
async unpublishEntry(initialModel, id) {
|
|
1236
1190
|
const permission = await checkEntryPermissions({
|
|
1237
1191
|
pw: "u"
|
|
1238
1192
|
});
|
|
@@ -1259,15 +1213,13 @@ const createContentEntryCrud = params => {
|
|
|
1259
1213
|
|
|
1260
1214
|
(0, _ownership.checkOwnership)(context, permission, originalStorageEntry);
|
|
1261
1215
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
1262
|
-
|
|
1263
|
-
const entry = _objectSpread(_objectSpread({}, originalEntry), {}, {
|
|
1216
|
+
const entry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, originalEntry), {}, {
|
|
1264
1217
|
status: STATUS_UNPUBLISHED
|
|
1265
1218
|
});
|
|
1266
|
-
|
|
1267
1219
|
let storageEntry = null;
|
|
1268
1220
|
|
|
1269
1221
|
try {
|
|
1270
|
-
await
|
|
1222
|
+
await onEntryBeforeUnpublish.publish({
|
|
1271
1223
|
entry,
|
|
1272
1224
|
model
|
|
1273
1225
|
});
|
|
@@ -1276,13 +1228,18 @@ const createContentEntryCrud = params => {
|
|
|
1276
1228
|
entry,
|
|
1277
1229
|
storageEntry
|
|
1278
1230
|
});
|
|
1279
|
-
await
|
|
1231
|
+
await onEntryAfterUnpublish.publish({
|
|
1280
1232
|
entry,
|
|
1281
1233
|
storageEntry: result,
|
|
1282
1234
|
model
|
|
1283
1235
|
});
|
|
1284
1236
|
return result;
|
|
1285
1237
|
} catch (ex) {
|
|
1238
|
+
await onEntryUnpublishError.publish({
|
|
1239
|
+
entry,
|
|
1240
|
+
model,
|
|
1241
|
+
error: ex
|
|
1242
|
+
});
|
|
1286
1243
|
throw new _error.default(ex.message || "Could not unpublish entry.", ex.code || "UNPUBLISH_ERROR", {
|
|
1287
1244
|
originalEntry,
|
|
1288
1245
|
originalStorageEntry,
|
|
@@ -1291,6 +1248,7 @@ const createContentEntryCrud = params => {
|
|
|
1291
1248
|
});
|
|
1292
1249
|
}
|
|
1293
1250
|
}
|
|
1251
|
+
|
|
1294
1252
|
};
|
|
1295
1253
|
};
|
|
1296
1254
|
|