@webiny/api-headless-cms 5.20.0-beta.1 → 5.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/graphQLHandlerFactory.js +5 -2
- 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.crud.js +72 -68
- 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.crud.js +50 -65
- 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 +4 -2
- 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/contentModelGroups.js +6 -2
- package/content/plugins/storage/object.js +5 -0
- package/package.json +23 -23
- package/plugins/crud/system.crud.js +11 -3
- package/types.d.ts +43 -27
- package/types.js +15 -0
|
@@ -23,8 +23,6 @@ var _createFieldModels = require("./contentModel/createFieldModels");
|
|
|
23
23
|
|
|
24
24
|
var _validateLayout = require("./contentModel/validateLayout");
|
|
25
25
|
|
|
26
|
-
var _apiSecurity = require("@webiny/api-security");
|
|
27
|
-
|
|
28
26
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
29
27
|
|
|
30
28
|
var _CmsModelPlugin = require("../CmsModelPlugin");
|
|
@@ -148,7 +146,7 @@ const createModelsCrud = params => {
|
|
|
148
146
|
return databaseModels.concat(pluginsModels);
|
|
149
147
|
};
|
|
150
148
|
|
|
151
|
-
const
|
|
149
|
+
const listModels = async () => {
|
|
152
150
|
const permission = await checkModelPermissions("r");
|
|
153
151
|
const models = await modelsList();
|
|
154
152
|
return utils.filterAsync(models, async model => {
|
|
@@ -160,7 +158,7 @@ const createModelsCrud = params => {
|
|
|
160
158
|
});
|
|
161
159
|
};
|
|
162
160
|
|
|
163
|
-
const
|
|
161
|
+
const getModel = async modelId => {
|
|
164
162
|
const permission = await checkModelPermissions("r");
|
|
165
163
|
const model = await modelsGet(modelId);
|
|
166
164
|
utils.checkOwnership(context, permission, model);
|
|
@@ -168,7 +166,9 @@ const createModelsCrud = params => {
|
|
|
168
166
|
return model;
|
|
169
167
|
};
|
|
170
168
|
|
|
171
|
-
const
|
|
169
|
+
const getModelManager = async target => {
|
|
170
|
+
const modelId = typeof target === "string" ? target : target.modelId;
|
|
171
|
+
|
|
172
172
|
if (managers.has(modelId)) {
|
|
173
173
|
return managers.get(modelId);
|
|
174
174
|
}
|
|
@@ -183,72 +183,57 @@ const createModelsCrud = params => {
|
|
|
183
183
|
return await updateManager(context, model);
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
186
|
+
const onBeforeModelCreate = (0, _pubsub.createTopic)();
|
|
187
|
+
const onAfterModelCreate = (0, _pubsub.createTopic)();
|
|
188
|
+
const onBeforeModelCreateFrom = (0, _pubsub.createTopic)();
|
|
189
|
+
const onAfterModelCreateFrom = (0, _pubsub.createTopic)();
|
|
190
|
+
const onBeforeModelUpdate = (0, _pubsub.createTopic)();
|
|
191
|
+
const onAfterModelUpdate = (0, _pubsub.createTopic)();
|
|
192
|
+
const onBeforeModelDelete = (0, _pubsub.createTopic)();
|
|
193
|
+
const onAfterModelDelete = (0, _pubsub.createTopic)();
|
|
194
194
|
/**
|
|
195
195
|
* We need to assign some default behaviors.
|
|
196
196
|
*/
|
|
197
197
|
|
|
198
198
|
(0, _beforeCreate.assignBeforeModelCreate)({
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
onBeforeModelCreate,
|
|
200
|
+
onBeforeModelCreateFrom,
|
|
201
201
|
plugins: context.plugins,
|
|
202
202
|
storageOperations
|
|
203
203
|
});
|
|
204
204
|
(0, _afterCreate.assignAfterModelCreate)({
|
|
205
205
|
context,
|
|
206
|
-
|
|
206
|
+
onAfterModelCreate
|
|
207
207
|
});
|
|
208
208
|
(0, _beforeUpdate.assignBeforeModelUpdate)({
|
|
209
|
-
|
|
209
|
+
onBeforeModelUpdate,
|
|
210
210
|
plugins: context.plugins,
|
|
211
211
|
storageOperations
|
|
212
212
|
});
|
|
213
213
|
(0, _afterUpdate.assignAfterModelUpdate)({
|
|
214
214
|
context,
|
|
215
|
-
|
|
215
|
+
onAfterModelUpdate
|
|
216
216
|
});
|
|
217
217
|
(0, _beforeDelete.assignBeforeModelDelete)({
|
|
218
|
-
|
|
218
|
+
onBeforeModelDelete,
|
|
219
219
|
plugins: context.plugins,
|
|
220
220
|
storageOperations
|
|
221
221
|
});
|
|
222
222
|
(0, _afterDelete.assignAfterModelDelete)({
|
|
223
223
|
context,
|
|
224
|
-
|
|
224
|
+
onAfterModelDelete
|
|
225
225
|
});
|
|
226
226
|
return {
|
|
227
|
-
onBeforeModelCreate
|
|
228
|
-
onAfterModelCreate
|
|
229
|
-
onBeforeModelCreateFrom
|
|
230
|
-
onAfterModelCreateFrom
|
|
231
|
-
onBeforeModelUpdate
|
|
232
|
-
onAfterModelUpdate
|
|
233
|
-
onBeforeModelDelete
|
|
234
|
-
onAfterModelDelete
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
list: async () => {
|
|
238
|
-
try {
|
|
239
|
-
return await listOperations();
|
|
240
|
-
} catch (ex) {
|
|
241
|
-
if (ex instanceof _apiSecurity.NotAuthorizedError) {
|
|
242
|
-
return [];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
throw ex;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
},
|
|
250
|
-
getModel: get,
|
|
251
|
-
listModels: listOperations,
|
|
227
|
+
onBeforeModelCreate,
|
|
228
|
+
onAfterModelCreate,
|
|
229
|
+
onBeforeModelCreateFrom,
|
|
230
|
+
onAfterModelCreateFrom,
|
|
231
|
+
onBeforeModelUpdate,
|
|
232
|
+
onAfterModelUpdate,
|
|
233
|
+
onBeforeModelDelete,
|
|
234
|
+
onAfterModelDelete,
|
|
235
|
+
getModel,
|
|
236
|
+
listModels,
|
|
252
237
|
|
|
253
238
|
async createModel(inputData) {
|
|
254
239
|
await checkModelPermissions("w");
|
|
@@ -287,9 +272,9 @@ const createModelsCrud = params => {
|
|
|
287
272
|
layout: [],
|
|
288
273
|
webinyVersion: context.WEBINY_VERSION
|
|
289
274
|
};
|
|
290
|
-
await
|
|
291
|
-
|
|
292
|
-
|
|
275
|
+
await onBeforeModelCreate.publish({
|
|
276
|
+
input,
|
|
277
|
+
model
|
|
293
278
|
});
|
|
294
279
|
const createdModel = await storageOperations.models.create({
|
|
295
280
|
input,
|
|
@@ -297,7 +282,7 @@ const createModelsCrud = params => {
|
|
|
297
282
|
});
|
|
298
283
|
loaders.listModels.clearAll();
|
|
299
284
|
await updateManager(context, model);
|
|
300
|
-
await
|
|
285
|
+
await onAfterModelCreate.publish({
|
|
301
286
|
input,
|
|
302
287
|
model: createdModel
|
|
303
288
|
});
|
|
@@ -320,7 +305,7 @@ const createModelsCrud = params => {
|
|
|
320
305
|
webinyVersion: context.WEBINY_VERSION
|
|
321
306
|
});
|
|
322
307
|
|
|
323
|
-
await
|
|
308
|
+
await onBeforeModelUpdate.publish({
|
|
324
309
|
input: {},
|
|
325
310
|
original,
|
|
326
311
|
model
|
|
@@ -332,7 +317,7 @@ const createModelsCrud = params => {
|
|
|
332
317
|
});
|
|
333
318
|
await updateManager(context, resultModel);
|
|
334
319
|
loaders.listModels.clearAll();
|
|
335
|
-
await
|
|
320
|
+
await onAfterModelUpdate.publish({
|
|
336
321
|
input: {},
|
|
337
322
|
original,
|
|
338
323
|
model: resultModel
|
|
@@ -346,7 +331,7 @@ const createModelsCrud = params => {
|
|
|
346
331
|
* Get a model record; this will also perform ownership validation.
|
|
347
332
|
*/
|
|
348
333
|
|
|
349
|
-
const original = await
|
|
334
|
+
const original = await getModel(modelId);
|
|
350
335
|
const createdData = new _models.CreateContentModelModelFrom().populate({
|
|
351
336
|
name: data.name,
|
|
352
337
|
modelId: data.modelId,
|
|
@@ -398,10 +383,10 @@ const createModelsCrud = params => {
|
|
|
398
383
|
webinyVersion: context.WEBINY_VERSION
|
|
399
384
|
});
|
|
400
385
|
|
|
401
|
-
await
|
|
386
|
+
await onBeforeModelCreateFrom.publish({
|
|
387
|
+
input,
|
|
402
388
|
model,
|
|
403
|
-
original
|
|
404
|
-
input
|
|
389
|
+
original
|
|
405
390
|
});
|
|
406
391
|
const createdModel = await storageOperations.models.create({
|
|
407
392
|
input,
|
|
@@ -409,7 +394,7 @@ const createModelsCrud = params => {
|
|
|
409
394
|
});
|
|
410
395
|
loaders.listModels.clearAll();
|
|
411
396
|
await updateManager(context, model);
|
|
412
|
-
await
|
|
397
|
+
await onAfterModelCreateFrom.publish({
|
|
413
398
|
input,
|
|
414
399
|
original,
|
|
415
400
|
model: createdModel
|
|
@@ -420,7 +405,7 @@ const createModelsCrud = params => {
|
|
|
420
405
|
async updateModel(modelId, inputData) {
|
|
421
406
|
await checkModelPermissions("w"); // Get a model record; this will also perform ownership validation.
|
|
422
407
|
|
|
423
|
-
const original = await
|
|
408
|
+
const original = await getModel(modelId);
|
|
424
409
|
const updatedData = new _models.UpdateContentModelModel().populate(inputData);
|
|
425
410
|
await updatedData.validate();
|
|
426
411
|
const input = await updatedData.toJSON({
|
|
@@ -463,7 +448,7 @@ const createModelsCrud = params => {
|
|
|
463
448
|
});
|
|
464
449
|
|
|
465
450
|
(0, _validateLayout.validateLayout)(model, modelFields);
|
|
466
|
-
await
|
|
451
|
+
await onBeforeModelUpdate.publish({
|
|
467
452
|
input,
|
|
468
453
|
original,
|
|
469
454
|
model
|
|
@@ -474,18 +459,18 @@ const createModelsCrud = params => {
|
|
|
474
459
|
input
|
|
475
460
|
});
|
|
476
461
|
await updateManager(context, resultModel);
|
|
477
|
-
await
|
|
462
|
+
await onAfterModelUpdate.publish({
|
|
463
|
+
input,
|
|
478
464
|
original,
|
|
479
|
-
model: resultModel
|
|
480
|
-
input
|
|
465
|
+
model: resultModel
|
|
481
466
|
});
|
|
482
467
|
return resultModel;
|
|
483
468
|
},
|
|
484
469
|
|
|
485
470
|
async deleteModel(modelId) {
|
|
486
471
|
await checkModelPermissions("d");
|
|
487
|
-
const model = await
|
|
488
|
-
await
|
|
472
|
+
const model = await getModel(modelId);
|
|
473
|
+
await onBeforeModelDelete.publish({
|
|
489
474
|
model
|
|
490
475
|
});
|
|
491
476
|
|
|
@@ -500,13 +485,13 @@ const createModelsCrud = params => {
|
|
|
500
485
|
});
|
|
501
486
|
}
|
|
502
487
|
|
|
503
|
-
await
|
|
488
|
+
await onAfterModelDelete.publish({
|
|
504
489
|
model
|
|
505
490
|
});
|
|
506
491
|
managers.delete(model.modelId);
|
|
507
492
|
},
|
|
508
493
|
|
|
509
|
-
getModelManager
|
|
494
|
+
getModelManager,
|
|
510
495
|
getManagers: () => managers
|
|
511
496
|
};
|
|
512
497
|
};
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
8
10
|
const createListFilters = ({
|
|
9
11
|
field
|
|
10
12
|
}) => {
|
|
@@ -57,10 +59,10 @@ const plugin = {
|
|
|
57
59
|
field
|
|
58
60
|
}) {
|
|
59
61
|
if (field.multipleValues) {
|
|
60
|
-
return field.fieldId + ": [Boolean]";
|
|
62
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [Boolean]", field);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
return field.fieldId + ": Boolean";
|
|
65
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": Boolean", field);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
}
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
7
10
|
const fieldGraphQLTypes = {
|
|
8
11
|
time: "Time",
|
|
9
12
|
dateTimeWithoutTimezone: "DateTime",
|
|
@@ -74,7 +77,7 @@ const plugin = {
|
|
|
74
77
|
createInputField({
|
|
75
78
|
field
|
|
76
79
|
}) {
|
|
77
|
-
return `${field.fieldId}: ${getFieldGraphQLType(field)}
|
|
80
|
+
return (0, _requiredField.attachRequiredFieldValue)(`${field.fieldId}: ${getFieldGraphQLType(field)}`, field);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
}
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
7
10
|
const plugin = {
|
|
8
11
|
name: "cms-model-field-to-graphql-file",
|
|
9
12
|
type: "cms-model-field-to-graphql",
|
|
@@ -37,10 +40,10 @@ const plugin = {
|
|
|
37
40
|
field
|
|
38
41
|
}) {
|
|
39
42
|
if (field.multipleValues) {
|
|
40
|
-
return field.fieldId + ": [String]";
|
|
43
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [String]", field);
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
return field.fieldId + ": String";
|
|
46
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": String", field);
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
8
10
|
const createListFilters = ({
|
|
9
11
|
field
|
|
10
12
|
}) => {
|
|
@@ -50,10 +52,10 @@ const plugin = {
|
|
|
50
52
|
field
|
|
51
53
|
}) {
|
|
52
54
|
if (field.multipleValues) {
|
|
53
|
-
return field.fieldId + ": [String]";
|
|
55
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [String]", field);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
return field.fieldId + ": String";
|
|
58
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": String", field);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
8
10
|
const createListFilters = ({
|
|
9
11
|
field
|
|
10
12
|
}) => {
|
|
@@ -63,10 +65,10 @@ const plugin = {
|
|
|
63
65
|
field
|
|
64
66
|
}) {
|
|
65
67
|
if (field.multipleValues) {
|
|
66
|
-
return field.fieldId + ": [Number]";
|
|
68
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [Number]", field);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
return field.fieldId + ": Number";
|
|
71
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": Number", field);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
}
|
|
@@ -15,6 +15,8 @@ var _renderInputFields = require("../utils/renderInputFields");
|
|
|
15
15
|
|
|
16
16
|
var _createTypeName = require("../utils/createTypeName");
|
|
17
17
|
|
|
18
|
+
var _requiredField = require("./requiredField");
|
|
19
|
+
|
|
18
20
|
const typeFromField = ({
|
|
19
21
|
typeOfType,
|
|
20
22
|
model,
|
|
@@ -182,7 +184,7 @@ const plugin = {
|
|
|
182
184
|
typeDefs
|
|
183
185
|
} = result;
|
|
184
186
|
return {
|
|
185
|
-
fields: `${field.fieldId}: ${field.multipleValues ? `[${fieldType}!]` : fieldType}`,
|
|
187
|
+
fields: (0, _requiredField.attachRequiredFieldValue)(`${field.fieldId}: ${field.multipleValues ? `[${fieldType}!]` : fieldType}`, field),
|
|
186
188
|
typeDefs
|
|
187
189
|
};
|
|
188
190
|
},
|
|
@@ -13,6 +13,8 @@ var _createTypeName = require("../utils/createTypeName");
|
|
|
13
13
|
|
|
14
14
|
var _utils = require("@webiny/utils");
|
|
15
15
|
|
|
16
|
+
var _requiredField = require("./requiredField");
|
|
17
|
+
|
|
16
18
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
19
|
|
|
18
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -228,10 +230,10 @@ const plugin = {
|
|
|
228
230
|
field
|
|
229
231
|
}) {
|
|
230
232
|
if (field.multipleValues) {
|
|
231
|
-
return field.fieldId + ": [RefFieldInput!]";
|
|
233
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [RefFieldInput!]", field);
|
|
232
234
|
}
|
|
233
235
|
|
|
234
|
-
return field.fieldId + ": RefFieldInput";
|
|
236
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": RefFieldInput", field);
|
|
235
237
|
},
|
|
236
238
|
|
|
237
239
|
createListFilters
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attachRequiredFieldValue = void 0;
|
|
7
|
+
|
|
8
|
+
const attachRequiredFieldValue = (def, field) => {
|
|
9
|
+
if (!field.validation || field.validation.length === 0) {
|
|
10
|
+
return def;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const isRequired = field.validation.some(validation => {
|
|
14
|
+
return validation.name === "required";
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (!isRequired) {
|
|
18
|
+
return def;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return `${def}!`;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.attachRequiredFieldValue = attachRequiredFieldValue;
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
7
10
|
const plugin = {
|
|
8
11
|
name: "cms-model-field-to-graphql-rich-text",
|
|
9
12
|
type: "cms-model-field-to-graphql",
|
|
@@ -43,10 +46,10 @@ const plugin = {
|
|
|
43
46
|
field
|
|
44
47
|
}) {
|
|
45
48
|
if (field.multipleValues) {
|
|
46
|
-
return field.fieldId + ": [JSON]";
|
|
49
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [JSON]", field);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
return field.fieldId + ": JSON";
|
|
52
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": JSON", field);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _requiredField = require("./requiredField");
|
|
9
|
+
|
|
8
10
|
const createListFilters = ({
|
|
9
11
|
field
|
|
10
12
|
}) => {
|
|
@@ -60,10 +62,10 @@ const plugin = {
|
|
|
60
62
|
field
|
|
61
63
|
}) {
|
|
62
64
|
if (field.multipleValues) {
|
|
63
|
-
return field.fieldId + ": [String]";
|
|
65
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": [String]", field);
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
return field.fieldId + ": String";
|
|
68
|
+
return (0, _requiredField.attachRequiredFieldValue)(field.fieldId + ": String", field);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
}
|
|
@@ -62,11 +62,15 @@ const plugin = context => {
|
|
|
62
62
|
resolvers = {
|
|
63
63
|
CmsContentModelGroup: {
|
|
64
64
|
contentModels: async (group, _, context) => {
|
|
65
|
-
|
|
65
|
+
context.security.disableAuthorization();
|
|
66
|
+
const models = await context.cms.listModels();
|
|
67
|
+
context.security.enableAuthorization();
|
|
66
68
|
return models.filter(m => m.group.id === group.id);
|
|
67
69
|
},
|
|
68
70
|
totalContentModels: async (group, _, context) => {
|
|
69
|
-
|
|
71
|
+
context.security.disableAuthorization();
|
|
72
|
+
const models = await context.cms.listModels();
|
|
73
|
+
context.security.enableAuthorization();
|
|
70
74
|
return models.filter(m => m.group === group.id).length;
|
|
71
75
|
},
|
|
72
76
|
plugin: async (group, _, context) => {
|
|
@@ -29,6 +29,11 @@ const processValue = async ({
|
|
|
29
29
|
}) => {
|
|
30
30
|
return await (0, _pReduce.default)(fields, async (values, field) => {
|
|
31
31
|
const plugin = getStoragePlugin(field.type);
|
|
32
|
+
|
|
33
|
+
if (!plugin) {
|
|
34
|
+
throw new Error(`Missing storage plugin for field type "${field.type}".`);
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
const value = await plugin[operation]({
|
|
33
38
|
plugins,
|
|
34
39
|
model,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms:base"
|
|
@@ -21,23 +21,23 @@
|
|
|
21
21
|
"@babel/runtime": "7.16.3",
|
|
22
22
|
"@commodo/fields": "1.1.2-beta.20",
|
|
23
23
|
"@graphql-tools/schema": "7.1.5",
|
|
24
|
-
"@webiny/api-file-manager": "5.
|
|
25
|
-
"@webiny/api-i18n": "5.
|
|
26
|
-
"@webiny/api-i18n-content": "5.
|
|
27
|
-
"@webiny/api-i18n-ddb": "5.
|
|
28
|
-
"@webiny/api-security": "5.
|
|
29
|
-
"@webiny/api-tenancy": "5.
|
|
30
|
-
"@webiny/api-upgrade": "5.
|
|
31
|
-
"@webiny/error": "5.
|
|
32
|
-
"@webiny/handler": "5.
|
|
33
|
-
"@webiny/handler-aws": "5.
|
|
34
|
-
"@webiny/handler-db": "5.
|
|
35
|
-
"@webiny/handler-graphql": "5.
|
|
36
|
-
"@webiny/handler-http": "5.
|
|
37
|
-
"@webiny/plugins": "5.
|
|
38
|
-
"@webiny/pubsub": "5.
|
|
39
|
-
"@webiny/utils": "5.
|
|
40
|
-
"@webiny/validation": "5.
|
|
24
|
+
"@webiny/api-file-manager": "5.21.0",
|
|
25
|
+
"@webiny/api-i18n": "5.21.0",
|
|
26
|
+
"@webiny/api-i18n-content": "5.21.0",
|
|
27
|
+
"@webiny/api-i18n-ddb": "5.21.0",
|
|
28
|
+
"@webiny/api-security": "5.21.0",
|
|
29
|
+
"@webiny/api-tenancy": "5.21.0",
|
|
30
|
+
"@webiny/api-upgrade": "5.21.0",
|
|
31
|
+
"@webiny/error": "5.21.0",
|
|
32
|
+
"@webiny/handler": "5.21.0",
|
|
33
|
+
"@webiny/handler-aws": "5.21.0",
|
|
34
|
+
"@webiny/handler-db": "5.21.0",
|
|
35
|
+
"@webiny/handler-graphql": "5.21.0",
|
|
36
|
+
"@webiny/handler-http": "5.21.0",
|
|
37
|
+
"@webiny/plugins": "5.21.0",
|
|
38
|
+
"@webiny/pubsub": "5.21.0",
|
|
39
|
+
"@webiny/utils": "5.21.0",
|
|
40
|
+
"@webiny/validation": "5.21.0",
|
|
41
41
|
"boolean": "3.1.4",
|
|
42
42
|
"commodo-fields-object": "1.0.6",
|
|
43
43
|
"dataloader": "2.0.0",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"@babel/core": "^7.5.5",
|
|
55
55
|
"@babel/preset-env": "^7.5.5",
|
|
56
56
|
"@babel/preset-flow": "^7.0.0",
|
|
57
|
-
"@webiny/api-security-so-ddb": "^5.
|
|
58
|
-
"@webiny/api-tenancy-so-ddb": "^5.
|
|
59
|
-
"@webiny/cli": "^5.
|
|
60
|
-
"@webiny/project-utils": "^5.
|
|
57
|
+
"@webiny/api-security-so-ddb": "^5.21.0",
|
|
58
|
+
"@webiny/api-tenancy-so-ddb": "^5.21.0",
|
|
59
|
+
"@webiny/cli": "^5.21.0",
|
|
60
|
+
"@webiny/project-utils": "^5.21.0",
|
|
61
61
|
"apollo-graphql": "^0.4.1",
|
|
62
62
|
"get-yarn-workspaces": "^1.0.2",
|
|
63
63
|
"graphql": "^14.6.0",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"build": "yarn webiny run build",
|
|
78
78
|
"watch": "yarn webiny run watch"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "c3d4955bf74e7ffdb9628867e3b23cdfe64ea8dc"
|
|
81
81
|
}
|
|
@@ -120,6 +120,10 @@ const createSystemCrud = params => {
|
|
|
120
120
|
if (version) {
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* First trigger before install event.
|
|
125
|
+
*/
|
|
126
|
+
|
|
123
127
|
|
|
124
128
|
await onBeforeInstall.publish({
|
|
125
129
|
tenant: getTenant().id
|
|
@@ -136,9 +140,6 @@ const createSystemCrud = params => {
|
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
|
|
139
|
-
await onAfterInstall.publish({
|
|
140
|
-
tenant: getTenant().id
|
|
141
|
-
});
|
|
142
143
|
const system = {
|
|
143
144
|
version: context.WEBINY_VERSION,
|
|
144
145
|
readAPIKey: createReadAPIKey(),
|
|
@@ -151,6 +152,13 @@ const createSystemCrud = params => {
|
|
|
151
152
|
await storageOperations.system.create({
|
|
152
153
|
system
|
|
153
154
|
});
|
|
155
|
+
/**
|
|
156
|
+
* And trigger after install event.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
await onAfterInstall.publish({
|
|
160
|
+
tenant: getTenant().id
|
|
161
|
+
});
|
|
154
162
|
},
|
|
155
163
|
|
|
156
164
|
async upgradeSystem(version) {
|