@webiny/api-headless-cms 5.20.0 → 5.22.0-beta.1
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/content/contextSetup.d.ts +1 -1
- package/content/contextSetup.js +2 -2
- package/content/graphQLHandlerFactory.js +13 -7
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +1 -1
- package/content/plugins/crud/contentEntry/afterDelete.js +2 -2
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +1 -1
- package/content/plugins/crud/contentEntry/beforeCreate.js +2 -2
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +1 -1
- package/content/plugins/crud/contentEntry/beforeUpdate.js +2 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +8 -2
- package/content/plugins/crud/contentEntry/entryDataValidation.js +16 -6
- package/content/plugins/crud/contentEntry/markLockedFields.js +2 -2
- package/content/plugins/crud/contentEntry/referenceFieldsMapping.js +2 -2
- package/content/plugins/crud/contentEntry.crud.js +163 -77
- package/content/plugins/crud/contentModel/afterCreate.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterCreate.js +2 -2
- package/content/plugins/crud/contentModel/afterDelete.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterDelete.js +2 -2
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +1 -1
- package/content/plugins/crud/contentModel/afterUpdate.js +2 -2
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +2 -2
- package/content/plugins/crud/contentModel/beforeCreate.js +4 -4
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +1 -1
- package/content/plugins/crud/contentModel/beforeDelete.js +2 -2
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +1 -1
- package/content/plugins/crud/contentModel/beforeUpdate.js +2 -2
- package/content/plugins/crud/contentModel/models.js +2 -1
- package/content/plugins/crud/contentModel.crud.js +52 -67
- package/content/plugins/crud/contentModelGroup.crud.js +2 -2
- package/content/plugins/crud/index.d.ts +1 -1
- package/content/plugins/crud/index.js +4 -4
- package/content/plugins/graphqlFields/boolean.js +4 -2
- package/content/plugins/graphqlFields/datetime.js +4 -1
- package/content/plugins/graphqlFields/file.js +5 -2
- package/content/plugins/graphqlFields/longText.js +4 -2
- package/content/plugins/graphqlFields/number.js +4 -2
- package/content/plugins/graphqlFields/object.js +3 -1
- package/content/plugins/graphqlFields/ref.js +6 -4
- package/content/plugins/graphqlFields/requiredField.d.ts +2 -0
- package/content/plugins/graphqlFields/requiredField.js +24 -0
- package/content/plugins/graphqlFields/richText.js +5 -2
- package/content/plugins/graphqlFields/text.js +4 -2
- package/content/plugins/schema/baseSchema.js +2 -2
- package/content/plugins/schema/contentModelGroups.js +6 -2
- package/content/plugins/schema/contentModels.js +2 -0
- package/content/plugins/schema/createFieldResolvers.js +2 -2
- package/content/plugins/schema/createManageResolvers.js +2 -2
- package/content/plugins/schema/createPreviewResolvers.js +2 -2
- package/content/plugins/schema/createReadResolvers.js +2 -2
- package/content/plugins/schema/resolvers/preview/resolveGet.js +2 -2
- package/content/plugins/schema/resolvers/read/resolveGet.js +2 -2
- package/content/plugins/storage/object.js +7 -2
- package/content/plugins/utils/entryStorage.js +2 -2
- package/content/plugins/validators/index.js +3 -1
- package/content/plugins/validators/unique.d.ts +7 -0
- package/content/plugins/validators/unique.js +62 -0
- package/index.d.ts +3 -3
- package/package.json +31 -31
- package/plugins/context.d.ts +1 -1
- package/plugins/context.js +4 -4
- package/plugins/crud/index.d.ts +1 -1
- package/plugins/crud/index.js +4 -4
- package/plugins/crud/settings.crud.js +2 -2
- package/plugins/crud/system.crud.js +13 -5
- package/types.d.ts +66 -31
- package/types.js +15 -0
|
@@ -37,9 +37,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
37
37
|
|
|
38
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; }
|
|
39
39
|
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
41
|
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
42
|
+
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; }
|
|
43
43
|
|
|
44
44
|
const STATUS_DRAFT = "draft";
|
|
45
45
|
exports.STATUS_DRAFT = STATUS_DRAFT;
|
|
@@ -50,17 +50,89 @@ exports.STATUS_UNPUBLISHED = STATUS_UNPUBLISHED;
|
|
|
50
50
|
const STATUS_CHANGES_REQUESTED = "changesRequested";
|
|
51
51
|
exports.STATUS_CHANGES_REQUESTED = STATUS_CHANGES_REQUESTED;
|
|
52
52
|
const STATUS_REVIEW_REQUESTED = "reviewRequested";
|
|
53
|
+
/**
|
|
54
|
+
* Used for some fields to convert their values.
|
|
55
|
+
*/
|
|
56
|
+
|
|
53
57
|
exports.STATUS_REVIEW_REQUESTED = STATUS_REVIEW_REQUESTED;
|
|
54
58
|
|
|
55
|
-
const
|
|
59
|
+
const convertDefaultValue = (field, value) => {
|
|
60
|
+
switch (field.type) {
|
|
61
|
+
case "boolean":
|
|
62
|
+
return Boolean(value);
|
|
63
|
+
|
|
64
|
+
case "number":
|
|
65
|
+
return Number(value);
|
|
66
|
+
|
|
67
|
+
default:
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const getDefaultValue = field => {
|
|
73
|
+
const {
|
|
74
|
+
settings,
|
|
75
|
+
multipleValues
|
|
76
|
+
} = field;
|
|
77
|
+
|
|
78
|
+
if (settings && settings.defaultValue !== undefined) {
|
|
79
|
+
return convertDefaultValue(field, settings.defaultValue);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
predefinedValues
|
|
84
|
+
} = field;
|
|
85
|
+
|
|
86
|
+
if (!predefinedValues || !predefinedValues.enabled || Array.isArray(predefinedValues.values) === false) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!multipleValues) {
|
|
91
|
+
const selectedValue = predefinedValues.values.find(value => {
|
|
92
|
+
return !!value.selected;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (selectedValue) {
|
|
96
|
+
return convertDefaultValue(field, selectedValue.value);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return predefinedValues.values.filter(({
|
|
103
|
+
selected
|
|
104
|
+
}) => !!selected).map(({
|
|
105
|
+
value
|
|
106
|
+
}) => {
|
|
107
|
+
return convertDefaultValue(field, value);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Cleans and adds default values to create input data.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const cleanInputData = (model, input) => {
|
|
56
116
|
return model.fields.reduce((acc, field) => {
|
|
57
|
-
|
|
117
|
+
const value = input[field.fieldId];
|
|
118
|
+
/**
|
|
119
|
+
* We set the default value on create input if value is not defined.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
acc[field.fieldId] = value === undefined ? getDefaultValue(field) : value;
|
|
58
123
|
return acc;
|
|
59
124
|
}, {});
|
|
60
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Cleans the update input entry data.
|
|
128
|
+
*/
|
|
129
|
+
|
|
61
130
|
|
|
62
131
|
const cleanUpdatedInputData = (model, input) => {
|
|
63
132
|
return model.fields.reduce((acc, field) => {
|
|
133
|
+
/**
|
|
134
|
+
* We cannot set default value here because user might want to updated only certain field values.
|
|
135
|
+
*/
|
|
64
136
|
if (input[field.fieldId] === undefined) {
|
|
65
137
|
return acc;
|
|
66
138
|
}
|
|
@@ -110,41 +182,41 @@ const createContentEntryCrud = params => {
|
|
|
110
182
|
context,
|
|
111
183
|
getIdentity
|
|
112
184
|
} = params;
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const
|
|
185
|
+
const onBeforeEntryCreate = (0, _pubsub.createTopic)();
|
|
186
|
+
const onAfterEntryCreate = (0, _pubsub.createTopic)();
|
|
187
|
+
const onBeforeEntryCreateRevision = (0, _pubsub.createTopic)();
|
|
188
|
+
const onAfterEntryCreateRevision = (0, _pubsub.createTopic)();
|
|
189
|
+
const onBeforeEntryUpdate = (0, _pubsub.createTopic)();
|
|
190
|
+
const onAfterEntryUpdate = (0, _pubsub.createTopic)();
|
|
191
|
+
const onBeforeEntryPublish = (0, _pubsub.createTopic)();
|
|
192
|
+
const onAfterEntryPublish = (0, _pubsub.createTopic)();
|
|
193
|
+
const onBeforeEntryUnpublish = (0, _pubsub.createTopic)();
|
|
194
|
+
const onAfterEntryUnpublish = (0, _pubsub.createTopic)();
|
|
195
|
+
const onBeforeEntryRequestChanges = (0, _pubsub.createTopic)();
|
|
196
|
+
const onAfterEntryRequestChanges = (0, _pubsub.createTopic)();
|
|
197
|
+
const onBeforeEntryRequestReview = (0, _pubsub.createTopic)();
|
|
198
|
+
const onAfterEntryRequestReview = (0, _pubsub.createTopic)();
|
|
199
|
+
const onBeforeEntryDelete = (0, _pubsub.createTopic)();
|
|
200
|
+
const onAfterEntryDelete = (0, _pubsub.createTopic)();
|
|
201
|
+
const onBeforeEntryDeleteRevision = (0, _pubsub.createTopic)();
|
|
202
|
+
const onAfterEntryDeleteRevision = (0, _pubsub.createTopic)();
|
|
203
|
+
const onBeforeEntryGet = (0, _pubsub.createTopic)();
|
|
204
|
+
const onBeforeEntryList = (0, _pubsub.createTopic)();
|
|
133
205
|
/**
|
|
134
206
|
* We need to assign some default behaviors.
|
|
135
207
|
*/
|
|
136
208
|
|
|
137
209
|
(0, _beforeCreate.assignBeforeEntryCreate)({
|
|
138
210
|
context,
|
|
139
|
-
|
|
211
|
+
onBeforeEntryCreate
|
|
140
212
|
});
|
|
141
213
|
(0, _beforeUpdate.assignBeforeEntryUpdate)({
|
|
142
214
|
context,
|
|
143
|
-
|
|
215
|
+
onBeforeEntryUpdate
|
|
144
216
|
});
|
|
145
217
|
(0, _afterDelete.assignAfterEntryDelete)({
|
|
146
218
|
context,
|
|
147
|
-
|
|
219
|
+
onAfterEntryDelete
|
|
148
220
|
});
|
|
149
221
|
|
|
150
222
|
const checkEntryPermissions = check => {
|
|
@@ -163,7 +235,7 @@ const createContentEntryCrud = params => {
|
|
|
163
235
|
} = params;
|
|
164
236
|
|
|
165
237
|
try {
|
|
166
|
-
await
|
|
238
|
+
await onBeforeEntryDelete.publish({
|
|
167
239
|
entry,
|
|
168
240
|
model
|
|
169
241
|
});
|
|
@@ -171,7 +243,7 @@ const createContentEntryCrud = params => {
|
|
|
171
243
|
entry,
|
|
172
244
|
storageEntry
|
|
173
245
|
});
|
|
174
|
-
await
|
|
246
|
+
await onAfterEntryDelete.publish({
|
|
175
247
|
entry,
|
|
176
248
|
model
|
|
177
249
|
});
|
|
@@ -198,26 +270,26 @@ const createContentEntryCrud = params => {
|
|
|
198
270
|
};
|
|
199
271
|
|
|
200
272
|
return {
|
|
201
|
-
onBeforeEntryCreate
|
|
202
|
-
onAfterEntryCreate
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
onBeforeEntryUpdate
|
|
206
|
-
onAfterEntryUpdate
|
|
207
|
-
onBeforeEntryDelete
|
|
208
|
-
onAfterEntryDelete
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
onBeforeEntryPublish
|
|
212
|
-
onAfterEntryPublish
|
|
213
|
-
onBeforeEntryUnpublish
|
|
214
|
-
onAfterEntryUnpublish
|
|
215
|
-
onBeforeEntryRequestChanges
|
|
216
|
-
onAfterEntryRequestChanges
|
|
217
|
-
onBeforeEntryRequestReview
|
|
218
|
-
onAfterEntryRequestReview
|
|
219
|
-
onBeforeEntryGet
|
|
220
|
-
onBeforeEntryList
|
|
273
|
+
onBeforeEntryCreate,
|
|
274
|
+
onAfterEntryCreate,
|
|
275
|
+
onBeforeEntryCreateRevision,
|
|
276
|
+
onAfterEntryCreateRevision,
|
|
277
|
+
onBeforeEntryUpdate,
|
|
278
|
+
onAfterEntryUpdate,
|
|
279
|
+
onBeforeEntryDelete,
|
|
280
|
+
onAfterEntryDelete,
|
|
281
|
+
onBeforeEntryDeleteRevision,
|
|
282
|
+
onAfterEntryDeleteRevision,
|
|
283
|
+
onBeforeEntryPublish,
|
|
284
|
+
onAfterEntryPublish,
|
|
285
|
+
onBeforeEntryUnpublish,
|
|
286
|
+
onAfterEntryUnpublish,
|
|
287
|
+
onBeforeEntryRequestChanges,
|
|
288
|
+
onAfterEntryRequestChanges,
|
|
289
|
+
onBeforeEntryRequestReview,
|
|
290
|
+
onAfterEntryRequestReview,
|
|
291
|
+
onBeforeEntryGet,
|
|
292
|
+
onBeforeEntryList,
|
|
221
293
|
|
|
222
294
|
/**
|
|
223
295
|
* Get entries by exact revision IDs from the database.
|
|
@@ -231,7 +303,7 @@ const createContentEntryCrud = params => {
|
|
|
231
303
|
const where = {
|
|
232
304
|
id
|
|
233
305
|
};
|
|
234
|
-
await
|
|
306
|
+
await onBeforeEntryGet.publish({
|
|
235
307
|
where,
|
|
236
308
|
model
|
|
237
309
|
});
|
|
@@ -290,7 +362,7 @@ const createContentEntryCrud = params => {
|
|
|
290
362
|
where,
|
|
291
363
|
sort
|
|
292
364
|
} = params;
|
|
293
|
-
await
|
|
365
|
+
await onBeforeEntryGet.publish({
|
|
294
366
|
where,
|
|
295
367
|
model
|
|
296
368
|
});
|
|
@@ -351,7 +423,7 @@ const createContentEntryCrud = params => {
|
|
|
351
423
|
listWhere.ownedBy = ownedBy;
|
|
352
424
|
}
|
|
353
425
|
|
|
354
|
-
await
|
|
426
|
+
await onBeforeEntryList.publish({
|
|
355
427
|
where: listWhere,
|
|
356
428
|
model
|
|
357
429
|
});
|
|
@@ -405,7 +477,11 @@ const createContentEntryCrud = params => {
|
|
|
405
477
|
*/
|
|
406
478
|
|
|
407
479
|
const initialInput = cleanInputData(model, inputData);
|
|
408
|
-
await (0, _entryDataValidation.validateModelEntryData)(
|
|
480
|
+
await (0, _entryDataValidation.validateModelEntryData)({
|
|
481
|
+
context,
|
|
482
|
+
model,
|
|
483
|
+
data: initialInput
|
|
484
|
+
});
|
|
409
485
|
const input = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
|
|
410
486
|
context,
|
|
411
487
|
model,
|
|
@@ -443,7 +519,7 @@ const createContentEntryCrud = params => {
|
|
|
443
519
|
let storageEntry = null;
|
|
444
520
|
|
|
445
521
|
try {
|
|
446
|
-
await
|
|
522
|
+
await onBeforeEntryCreate.publish({
|
|
447
523
|
entry,
|
|
448
524
|
input,
|
|
449
525
|
model
|
|
@@ -454,7 +530,7 @@ const createContentEntryCrud = params => {
|
|
|
454
530
|
entry,
|
|
455
531
|
storageEntry
|
|
456
532
|
});
|
|
457
|
-
await
|
|
533
|
+
await onAfterEntryCreate.publish({
|
|
458
534
|
entry,
|
|
459
535
|
storageEntry: result,
|
|
460
536
|
model,
|
|
@@ -470,7 +546,7 @@ const createContentEntryCrud = params => {
|
|
|
470
546
|
});
|
|
471
547
|
}
|
|
472
548
|
},
|
|
473
|
-
createEntryRevisionFrom: async (model, sourceId, inputData
|
|
549
|
+
createEntryRevisionFrom: async (model, sourceId, inputData) => {
|
|
474
550
|
const permission = await checkEntryPermissions({
|
|
475
551
|
rwd: "w"
|
|
476
552
|
});
|
|
@@ -506,7 +582,12 @@ const createContentEntryCrud = params => {
|
|
|
506
582
|
|
|
507
583
|
const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
|
|
508
584
|
|
|
509
|
-
await (0, _entryDataValidation.validateModelEntryData)(
|
|
585
|
+
await (0, _entryDataValidation.validateModelEntryData)({
|
|
586
|
+
context,
|
|
587
|
+
model,
|
|
588
|
+
data: initialValues,
|
|
589
|
+
entry: originalEntry
|
|
590
|
+
});
|
|
510
591
|
const values = await (0, _referenceFieldsMapping.referenceFieldsMapping)({
|
|
511
592
|
context,
|
|
512
593
|
model,
|
|
@@ -541,8 +622,10 @@ const createContentEntryCrud = params => {
|
|
|
541
622
|
let storageEntry = undefined;
|
|
542
623
|
|
|
543
624
|
try {
|
|
544
|
-
await
|
|
625
|
+
await onBeforeEntryCreateRevision.publish({
|
|
626
|
+
input,
|
|
545
627
|
entry,
|
|
628
|
+
original: originalEntry,
|
|
546
629
|
model
|
|
547
630
|
});
|
|
548
631
|
storageEntry = await (0, _entryStorage.entryToStorageTransform)(context, model, entry);
|
|
@@ -554,9 +637,11 @@ const createContentEntryCrud = params => {
|
|
|
554
637
|
latestEntry,
|
|
555
638
|
latestStorageEntry
|
|
556
639
|
});
|
|
557
|
-
await
|
|
640
|
+
await onAfterEntryCreateRevision.publish({
|
|
641
|
+
input,
|
|
558
642
|
entry,
|
|
559
643
|
model,
|
|
644
|
+
original: originalEntry,
|
|
560
645
|
storageEntry: result
|
|
561
646
|
});
|
|
562
647
|
return result;
|
|
@@ -579,12 +664,7 @@ const createContentEntryCrud = params => {
|
|
|
579
664
|
* Make sure we only work with fields that are defined in the model.
|
|
580
665
|
*/
|
|
581
666
|
|
|
582
|
-
const input =
|
|
583
|
-
/**
|
|
584
|
-
* Validate data early. We don't want to query DB if input data is invalid.
|
|
585
|
-
*/
|
|
586
|
-
|
|
587
|
-
await (0, _entryDataValidation.validateModelEntryData)(context, model, input);
|
|
667
|
+
const input = cleanUpdatedInputData(model, inputData);
|
|
588
668
|
/**
|
|
589
669
|
* The entry we are going to update.
|
|
590
670
|
*/
|
|
@@ -602,6 +682,12 @@ const createContentEntryCrud = params => {
|
|
|
602
682
|
}
|
|
603
683
|
|
|
604
684
|
const originalEntry = await (0, _entryStorage.entryFromStorageTransform)(context, model, originalStorageEntry);
|
|
685
|
+
await (0, _entryDataValidation.validateModelEntryData)({
|
|
686
|
+
context,
|
|
687
|
+
model,
|
|
688
|
+
data: input,
|
|
689
|
+
entry: originalEntry
|
|
690
|
+
});
|
|
605
691
|
utils.checkOwnership(context, permission, originalEntry);
|
|
606
692
|
|
|
607
693
|
const initialValues = _objectSpread(_objectSpread({}, originalEntry.values), input);
|
|
@@ -624,7 +710,7 @@ const createContentEntryCrud = params => {
|
|
|
624
710
|
let storageEntry = undefined;
|
|
625
711
|
|
|
626
712
|
try {
|
|
627
|
-
await
|
|
713
|
+
await onBeforeEntryUpdate.publish({
|
|
628
714
|
entry,
|
|
629
715
|
model,
|
|
630
716
|
input,
|
|
@@ -638,7 +724,7 @@ const createContentEntryCrud = params => {
|
|
|
638
724
|
storageEntry,
|
|
639
725
|
input
|
|
640
726
|
});
|
|
641
|
-
await
|
|
727
|
+
await onAfterEntryUpdate.publish({
|
|
642
728
|
entry,
|
|
643
729
|
storageEntry: result,
|
|
644
730
|
model,
|
|
@@ -787,7 +873,7 @@ const createContentEntryCrud = params => {
|
|
|
787
873
|
}
|
|
788
874
|
|
|
789
875
|
try {
|
|
790
|
-
await
|
|
876
|
+
await onBeforeEntryDeleteRevision.publish({
|
|
791
877
|
entry: entryToDelete,
|
|
792
878
|
model
|
|
793
879
|
});
|
|
@@ -797,7 +883,7 @@ const createContentEntryCrud = params => {
|
|
|
797
883
|
entryToSetAsLatest,
|
|
798
884
|
storageEntryToSetAsLatest
|
|
799
885
|
});
|
|
800
|
-
await
|
|
886
|
+
await onAfterEntryDeleteRevision.publish({
|
|
801
887
|
entry: entryToDelete,
|
|
802
888
|
model
|
|
803
889
|
});
|
|
@@ -859,7 +945,7 @@ const createContentEntryCrud = params => {
|
|
|
859
945
|
let storageEntry = undefined;
|
|
860
946
|
|
|
861
947
|
try {
|
|
862
|
-
await
|
|
948
|
+
await onBeforeEntryPublish.publish({
|
|
863
949
|
entry,
|
|
864
950
|
model
|
|
865
951
|
});
|
|
@@ -870,7 +956,7 @@ const createContentEntryCrud = params => {
|
|
|
870
956
|
originalEntry,
|
|
871
957
|
originalStorageEntry
|
|
872
958
|
});
|
|
873
|
-
await
|
|
959
|
+
await onAfterEntryPublish.publish({
|
|
874
960
|
entry,
|
|
875
961
|
storageEntry: result,
|
|
876
962
|
model
|
|
@@ -919,7 +1005,7 @@ const createContentEntryCrud = params => {
|
|
|
919
1005
|
let storageEntry = undefined;
|
|
920
1006
|
|
|
921
1007
|
try {
|
|
922
|
-
await
|
|
1008
|
+
await onBeforeEntryRequestChanges.publish({
|
|
923
1009
|
entry,
|
|
924
1010
|
model
|
|
925
1011
|
});
|
|
@@ -930,7 +1016,7 @@ const createContentEntryCrud = params => {
|
|
|
930
1016
|
entry,
|
|
931
1017
|
storageEntry
|
|
932
1018
|
});
|
|
933
|
-
await
|
|
1019
|
+
await onAfterEntryRequestChanges.publish({
|
|
934
1020
|
entry,
|
|
935
1021
|
storageEntry: result,
|
|
936
1022
|
model
|
|
@@ -981,7 +1067,7 @@ const createContentEntryCrud = params => {
|
|
|
981
1067
|
let storageEntry = undefined;
|
|
982
1068
|
|
|
983
1069
|
try {
|
|
984
|
-
await
|
|
1070
|
+
await onBeforeEntryRequestReview.publish({
|
|
985
1071
|
entry,
|
|
986
1072
|
model
|
|
987
1073
|
});
|
|
@@ -992,7 +1078,7 @@ const createContentEntryCrud = params => {
|
|
|
992
1078
|
entry,
|
|
993
1079
|
storageEntry
|
|
994
1080
|
});
|
|
995
|
-
await
|
|
1081
|
+
await onAfterEntryRequestReview.publish({
|
|
996
1082
|
entry,
|
|
997
1083
|
storageEntry: result,
|
|
998
1084
|
model
|
|
@@ -1036,7 +1122,7 @@ const createContentEntryCrud = params => {
|
|
|
1036
1122
|
let storageEntry = undefined;
|
|
1037
1123
|
|
|
1038
1124
|
try {
|
|
1039
|
-
await
|
|
1125
|
+
await onBeforeEntryUnpublish.publish({
|
|
1040
1126
|
entry,
|
|
1041
1127
|
model
|
|
1042
1128
|
});
|
|
@@ -1047,7 +1133,7 @@ const createContentEntryCrud = params => {
|
|
|
1047
1133
|
entry,
|
|
1048
1134
|
storageEntry
|
|
1049
1135
|
});
|
|
1050
|
-
await
|
|
1136
|
+
await onAfterEntryUnpublish.publish({
|
|
1051
1137
|
entry,
|
|
1052
1138
|
storageEntry: result,
|
|
1053
1139
|
model
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AfterModelCreateTopicParams, CmsContext } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
export interface Params {
|
|
4
|
-
|
|
4
|
+
onAfterModelCreate: Topic<AfterModelCreateTopicParams>;
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
}
|
|
7
7
|
export declare const assignAfterModelCreate: (params: Params) => void;
|
|
@@ -7,10 +7,10 @@ exports.assignAfterModelCreate = void 0;
|
|
|
7
7
|
|
|
8
8
|
const assignAfterModelCreate = params => {
|
|
9
9
|
const {
|
|
10
|
-
|
|
10
|
+
onAfterModelCreate,
|
|
11
11
|
context
|
|
12
12
|
} = params;
|
|
13
|
-
|
|
13
|
+
onAfterModelCreate.subscribe(async () => {
|
|
14
14
|
await context.cms.updateModelLastChange();
|
|
15
15
|
});
|
|
16
16
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AfterModelDeleteTopicParams, CmsContext } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
export interface Params {
|
|
4
|
-
|
|
4
|
+
onAfterModelDelete: Topic<AfterModelDeleteTopicParams>;
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
}
|
|
7
7
|
export declare const assignAfterModelDelete: (params: Params) => void;
|
|
@@ -7,10 +7,10 @@ exports.assignAfterModelDelete = void 0;
|
|
|
7
7
|
|
|
8
8
|
const assignAfterModelDelete = params => {
|
|
9
9
|
const {
|
|
10
|
-
|
|
10
|
+
onAfterModelDelete,
|
|
11
11
|
context
|
|
12
12
|
} = params;
|
|
13
|
-
|
|
13
|
+
onAfterModelDelete.subscribe(async () => {
|
|
14
14
|
await context.cms.updateModelLastChange();
|
|
15
15
|
});
|
|
16
16
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AfterModelUpdateTopicParams, CmsContext } from "../../../../types";
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
export interface Params {
|
|
4
|
-
|
|
4
|
+
onAfterModelUpdate: Topic<AfterModelUpdateTopicParams>;
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
}
|
|
7
7
|
export declare const assignAfterModelUpdate: (params: Params) => void;
|
|
@@ -7,10 +7,10 @@ exports.assignAfterModelUpdate = void 0;
|
|
|
7
7
|
|
|
8
8
|
const assignAfterModelUpdate = params => {
|
|
9
9
|
const {
|
|
10
|
-
|
|
10
|
+
onAfterModelUpdate,
|
|
11
11
|
context
|
|
12
12
|
} = params;
|
|
13
|
-
|
|
13
|
+
onAfterModelUpdate.subscribe(async () => {
|
|
14
14
|
await context.cms.updateModelLastChange();
|
|
15
15
|
});
|
|
16
16
|
};
|
|
@@ -2,8 +2,8 @@ import { BeforeModelCreateTopicParams, HeadlessCmsStorageOperations } from "../.
|
|
|
2
2
|
import { Topic } from "@webiny/pubsub/types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
export interface Params {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
onBeforeModelCreate: Topic<BeforeModelCreateTopicParams>;
|
|
6
|
+
onBeforeModelCreateFrom: Topic<BeforeModelCreateTopicParams>;
|
|
7
7
|
storageOperations: HeadlessCmsStorageOperations;
|
|
8
8
|
plugins: PluginsContainer;
|
|
9
9
|
}
|
|
@@ -147,16 +147,16 @@ const createOnBeforeCb = ({
|
|
|
147
147
|
*/
|
|
148
148
|
const assignBeforeModelCreate = params => {
|
|
149
149
|
const {
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
onBeforeModelCreate,
|
|
151
|
+
onBeforeModelCreateFrom,
|
|
152
152
|
storageOperations,
|
|
153
153
|
plugins
|
|
154
154
|
} = params;
|
|
155
|
-
|
|
155
|
+
onBeforeModelCreate.subscribe(createOnBeforeCb({
|
|
156
156
|
storageOperations,
|
|
157
157
|
plugins
|
|
158
158
|
}));
|
|
159
|
-
|
|
159
|
+
onBeforeModelCreateFrom.subscribe(createOnBeforeCb({
|
|
160
160
|
storageOperations,
|
|
161
161
|
plugins
|
|
162
162
|
}));
|
|
@@ -2,7 +2,7 @@ import { Topic } from "@webiny/pubsub/types";
|
|
|
2
2
|
import { BeforeModelDeleteTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
export interface Params {
|
|
5
|
-
|
|
5
|
+
onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;
|
|
6
6
|
storageOperations: HeadlessCmsStorageOperations;
|
|
7
7
|
plugins: PluginsContainer;
|
|
8
8
|
}
|
|
@@ -13,11 +13,11 @@ var _CmsModelPlugin = require("../../CmsModelPlugin");
|
|
|
13
13
|
|
|
14
14
|
const assignBeforeModelDelete = params => {
|
|
15
15
|
const {
|
|
16
|
-
|
|
16
|
+
onBeforeModelDelete,
|
|
17
17
|
storageOperations,
|
|
18
18
|
plugins
|
|
19
19
|
} = params;
|
|
20
|
-
|
|
20
|
+
onBeforeModelDelete.subscribe(async params => {
|
|
21
21
|
const {
|
|
22
22
|
model
|
|
23
23
|
} = params;
|
|
@@ -2,7 +2,7 @@ import { Topic } from "@webiny/pubsub/types";
|
|
|
2
2
|
import { BeforeModelUpdateTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
export interface Params {
|
|
5
|
-
|
|
5
|
+
onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;
|
|
6
6
|
storageOperations: HeadlessCmsStorageOperations;
|
|
7
7
|
plugins: PluginsContainer;
|
|
8
8
|
}
|
|
@@ -55,10 +55,10 @@ const getContentModelTitleFieldId = (fields, titleFieldId) => {
|
|
|
55
55
|
|
|
56
56
|
const assignBeforeModelUpdate = params => {
|
|
57
57
|
const {
|
|
58
|
-
|
|
58
|
+
onBeforeModelUpdate,
|
|
59
59
|
plugins
|
|
60
60
|
} = params;
|
|
61
|
-
|
|
61
|
+
onBeforeModelUpdate.subscribe(async params => {
|
|
62
62
|
const {
|
|
63
63
|
model
|
|
64
64
|
} = params;
|
|
@@ -90,7 +90,8 @@ const ContentModelFieldModel = (0, _fields.withFields)({
|
|
|
90
90
|
list: true,
|
|
91
91
|
instanceOf: (0, _fields.withFields)({
|
|
92
92
|
label: (0, _fields.string)(),
|
|
93
|
-
value: (0, _fields.string)()
|
|
93
|
+
value: (0, _fields.string)(),
|
|
94
|
+
selected: (0, _fields.boolean)()
|
|
94
95
|
})()
|
|
95
96
|
})
|
|
96
97
|
})()
|