@webiny/api-headless-cms 0.0.0-unstable.5e7233243f → 0.0.0-unstable.615a930a68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/context.js +3 -7
  2. package/context.js.map +1 -1
  3. package/crud/contentEntry/afterDelete.d.ts +2 -2
  4. package/crud/contentEntry/afterDelete.js +2 -2
  5. package/crud/contentEntry/afterDelete.js.map +1 -1
  6. package/crud/contentEntry/beforeCreate.d.ts +2 -2
  7. package/crud/contentEntry/beforeCreate.js +2 -2
  8. package/crud/contentEntry/beforeCreate.js.map +1 -1
  9. package/crud/contentEntry/beforeUpdate.d.ts +2 -2
  10. package/crud/contentEntry/beforeUpdate.js +2 -2
  11. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  12. package/crud/contentEntry/entryDataValidation.js +3 -7
  13. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  14. package/crud/contentEntry/markLockedFields.js +6 -10
  15. package/crud/contentEntry/markLockedFields.js.map +1 -1
  16. package/crud/contentEntry/referenceFieldsMapping.js +3 -9
  17. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  18. package/crud/contentEntry/searchableFields.d.ts +9 -0
  19. package/crud/contentEntry/searchableFields.js +83 -0
  20. package/crud/contentEntry/searchableFields.js.map +1 -0
  21. package/crud/contentEntry.crud.d.ts +0 -2
  22. package/crud/contentEntry.crud.js +200 -269
  23. package/crud/contentEntry.crud.js.map +1 -1
  24. package/crud/contentModel/afterCreate.d.ts +3 -3
  25. package/crud/contentModel/afterCreate.js +5 -5
  26. package/crud/contentModel/afterCreate.js.map +1 -1
  27. package/crud/contentModel/afterCreateFrom.d.ts +3 -3
  28. package/crud/contentModel/afterCreateFrom.js +5 -5
  29. package/crud/contentModel/afterCreateFrom.js.map +1 -1
  30. package/crud/contentModel/afterDelete.d.ts +3 -3
  31. package/crud/contentModel/afterDelete.js +5 -5
  32. package/crud/contentModel/afterDelete.js.map +1 -1
  33. package/crud/contentModel/afterUpdate.d.ts +3 -3
  34. package/crud/contentModel/afterUpdate.js +5 -5
  35. package/crud/contentModel/afterUpdate.js.map +1 -1
  36. package/crud/contentModel/beforeCreate.d.ts +4 -4
  37. package/crud/contentModel/beforeCreate.js +10 -10
  38. package/crud/contentModel/beforeCreate.js.map +1 -1
  39. package/crud/contentModel/beforeDelete.d.ts +3 -3
  40. package/crud/contentModel/beforeDelete.js +6 -6
  41. package/crud/contentModel/beforeDelete.js.map +1 -1
  42. package/crud/contentModel/beforeUpdate.d.ts +3 -3
  43. package/crud/contentModel/beforeUpdate.js +5 -5
  44. package/crud/contentModel/beforeUpdate.js.map +1 -1
  45. package/crud/contentModel/validateModel.js +1 -1
  46. package/crud/contentModel/validateModelFields.js +3 -7
  47. package/crud/contentModel/validateModelFields.js.map +1 -1
  48. package/crud/contentModel.crud.js +84 -60
  49. package/crud/contentModel.crud.js.map +1 -1
  50. package/crud/contentModelGroup/beforeCreate.d.ts +2 -2
  51. package/crud/contentModelGroup/beforeCreate.js +3 -3
  52. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  53. package/crud/contentModelGroup/beforeDelete.d.ts +2 -2
  54. package/crud/contentModelGroup/beforeDelete.js +3 -3
  55. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  56. package/crud/contentModelGroup/beforeUpdate.d.ts +2 -2
  57. package/crud/contentModelGroup/beforeUpdate.js +2 -2
  58. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  59. package/crud/contentModelGroup.crud.js +58 -38
  60. package/crud/contentModelGroup.crud.js.map +1 -1
  61. package/crud/index.js +3 -7
  62. package/crud/index.js.map +1 -1
  63. package/crud/settings.crud.js +3 -8
  64. package/crud/settings.crud.js.map +1 -1
  65. package/crud/system.crud.js +63 -51
  66. package/crud/system.crud.js.map +1 -1
  67. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +1 -1
  68. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +17 -19
  69. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  70. package/graphql/graphQLHandlerFactory.js +1 -1
  71. package/graphql/schema/baseContentSchema.js +5 -9
  72. package/graphql/schema/baseContentSchema.js.map +1 -1
  73. package/graphql/schema/contentEntries.js +1 -1
  74. package/graphql/schema/contentModels.js +19 -0
  75. package/graphql/schema/contentModels.js.map +1 -1
  76. package/graphql/schema/createFieldResolvers.js +4 -10
  77. package/graphql/schema/createFieldResolvers.js.map +1 -1
  78. package/graphql/schema/createManageResolvers.js +4 -18
  79. package/graphql/schema/createManageResolvers.js.map +1 -1
  80. package/graphql/schema/createManageSDL.js +6 -8
  81. package/graphql/schema/createManageSDL.js.map +1 -1
  82. package/graphql/schema/createPreviewResolvers.js +3 -7
  83. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  84. package/graphql/schema/createReadResolvers.js +3 -7
  85. package/graphql/schema/createReadResolvers.js.map +1 -1
  86. package/graphql/schema/createReadSDL.js +3 -1
  87. package/graphql/schema/createReadSDL.js.map +1 -1
  88. package/graphql/schema/resolvers/manage/resolveGet.js +5 -9
  89. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  90. package/graphql/schema/resolvers/preview/resolveGet.js +3 -7
  91. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  92. package/graphql/schema/resolvers/read/resolveGet.js +3 -7
  93. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  94. package/graphqlFields/number.js +4 -0
  95. package/graphqlFields/number.js.map +1 -1
  96. package/graphqlFields/object.js +102 -16
  97. package/graphqlFields/object.js.map +1 -1
  98. package/graphqlFields/ref.js +4 -8
  99. package/graphqlFields/ref.js.map +1 -1
  100. package/modelManager/DefaultCmsModelManager.d.ts +7 -7
  101. package/modelManager/DefaultCmsModelManager.js +1 -1
  102. package/package.json +27 -28
  103. package/parameters/header.js +1 -1
  104. package/parameters/manual.js +7 -8
  105. package/parameters/manual.js.map +1 -1
  106. package/parameters/path.js +1 -1
  107. package/plugins/CmsGroupPlugin.js +1 -1
  108. package/plugins/CmsModelFieldConverterPlugin.js +1 -1
  109. package/plugins/CmsModelPlugin.d.ts +6 -2
  110. package/plugins/CmsModelPlugin.js +18 -13
  111. package/plugins/CmsModelPlugin.js.map +1 -1
  112. package/plugins/CmsParametersPlugin.js +1 -1
  113. package/plugins/StorageTransformPlugin.d.ts +1 -1
  114. package/plugins/StorageTransformPlugin.js +1 -1
  115. package/plugins/StorageTransformPlugin.js.map +1 -1
  116. package/storage/object.js +3 -7
  117. package/storage/object.js.map +1 -1
  118. package/types.d.ts +276 -127
  119. package/types.js +0 -2
  120. package/types.js.map +1 -1
  121. package/upgrades/5.33.0/index.js +5 -9
  122. package/upgrades/5.33.0/index.js.map +1 -1
  123. package/utils/converters/Converter.js +1 -1
  124. package/utils/converters/ConverterCollection.d.ts +7 -0
  125. package/utils/converters/ConverterCollection.js +31 -7
  126. package/utils/converters/ConverterCollection.js.map +1 -1
  127. package/utils/converters/valueKeyStorageConverter.js +3 -7
  128. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  129. package/utils/createTypeName.js +1 -1
  130. package/utils/entryStorage.js +3 -7
  131. package/utils/entryStorage.js.map +1 -1
  132. package/utils/filterModelFields.js +5 -9
  133. package/utils/filterModelFields.js.map +1 -1
  134. package/utils/permissions.js +1 -5
  135. package/utils/permissions.js.map +1 -1
  136. package/utils/pluralizedTypeName.js +1 -1
  137. package/utils/renderListFilterFields.js +9 -1
  138. package/utils/renderListFilterFields.js.map +1 -1
  139. package/utils/toSlug.js +1 -1
  140. 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
8
  exports.createModelsCrud = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
12
  var _dataloader = _interopRequireDefault(require("dataloader"));
13
13
 
@@ -51,10 +51,6 @@ var _validateModelFields = require("./contentModel/validateModelFields");
51
51
 
52
52
  var _semver = _interopRequireDefault(require("semver"));
53
53
 
54
- 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; }
55
-
56
- 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; }
57
-
58
54
  /**
59
55
  * TODO: remove for 5.34.0
60
56
  * Required because of the 5.33.0 upgrade.
@@ -122,7 +118,7 @@ const createModelsCrud = params => {
122
118
  }
123
119
  });
124
120
  return [models.map(model => {
125
- return _objectSpread(_objectSpread({}, model), {}, {
121
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
126
122
  fields: attachStorageIdToModelFields(model),
127
123
  tenant: model.tenant || getTenant().id,
128
124
  locale: model.locale || getLocale().code
@@ -173,7 +169,7 @@ const createModelsCrud = params => {
173
169
 
174
170
  return true;
175
171
  }).map(plugin => {
176
- return _objectSpread(_objectSpread({}, plugin.contentModel), {}, {
172
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, plugin.contentModel), {}, {
177
173
  tenant,
178
174
  locale,
179
175
  webinyVersion: context.WEBINY_VERSION
@@ -210,7 +206,7 @@ const createModelsCrud = params => {
210
206
  throw new _handlerGraphql.NotFoundError(`Content model "${modelId}" was not found!`);
211
207
  }
212
208
 
213
- return _objectSpread(_objectSpread({}, model), {}, {
209
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, model), {}, {
214
210
  tenant: model.tenant || getTenant().id,
215
211
  locale: model.locale || getLocale().code
216
212
  });
@@ -257,61 +253,82 @@ const createModelsCrud = params => {
257
253
  }
258
254
 
259
255
  return await updateManager(context, model);
260
- };
256
+ }; // create
257
+
258
+
259
+ const onModelBeforeCreate = (0, _pubsub.createTopic)("cms.onModelBeforeCreate");
260
+ const onModelAfterCreate = (0, _pubsub.createTopic)("cms.onModelAfterCreate"); // create from
261
+
262
+ const onModelBeforeCreateFrom = (0, _pubsub.createTopic)("cms.onModelBeforeCreateFrom");
263
+ const onModelAfterCreateFrom = (0, _pubsub.createTopic)("cms.onModelAfterCreateFrom"); // update
264
+
265
+ const onModelBeforeUpdate = (0, _pubsub.createTopic)("cms.onModelBeforeUpdate");
266
+ const onModelAfterUpdate = (0, _pubsub.createTopic)("cms.onModelAfterUpdate"); // delete
261
267
 
262
- const onBeforeModelCreate = (0, _pubsub.createTopic)();
263
- const onAfterModelCreate = (0, _pubsub.createTopic)();
264
- const onBeforeModelCreateFrom = (0, _pubsub.createTopic)();
265
- const onAfterModelCreateFrom = (0, _pubsub.createTopic)();
266
- const onBeforeModelUpdate = (0, _pubsub.createTopic)();
267
- const onAfterModelUpdate = (0, _pubsub.createTopic)();
268
- const onBeforeModelDelete = (0, _pubsub.createTopic)();
269
- const onAfterModelDelete = (0, _pubsub.createTopic)();
268
+ const onModelBeforeDelete = (0, _pubsub.createTopic)("cms.onModelBeforeDelete");
269
+ const onModelAfterDelete = (0, _pubsub.createTopic)("cms.onModelAfterDelete");
270
+ const onModelInitialize = (0, _pubsub.createTopic)("cms.onModelInitialize");
270
271
  /**
271
272
  * We need to assign some default behaviors.
272
273
  */
273
274
 
274
- (0, _beforeCreate.assignBeforeModelCreate)({
275
- onBeforeModelCreate,
276
- onBeforeModelCreateFrom,
275
+ (0, _beforeCreate.assignModelBeforeCreate)({
276
+ onModelBeforeCreate,
277
+ onModelBeforeCreateFrom,
277
278
  plugins: context.plugins,
278
279
  storageOperations
279
280
  });
280
- (0, _afterCreate.assignAfterModelCreate)({
281
+ (0, _afterCreate.assignModelAfterCreate)({
281
282
  context,
282
- onAfterModelCreate
283
+ onModelAfterCreate
283
284
  });
284
- (0, _beforeUpdate.assignBeforeModelUpdate)({
285
- onBeforeModelUpdate,
285
+ (0, _beforeUpdate.assignModelBeforeUpdate)({
286
+ onModelBeforeUpdate,
286
287
  plugins: context.plugins,
287
288
  storageOperations
288
289
  });
289
- (0, _afterUpdate.assignAfterModelUpdate)({
290
+ (0, _afterUpdate.assignModelAfterUpdate)({
290
291
  context,
291
- onAfterModelUpdate
292
+ onModelAfterUpdate
292
293
  });
293
- (0, _afterCreateFrom.assignAfterModelCreateFrom)({
294
+ (0, _afterCreateFrom.assignModelAfterCreateFrom)({
294
295
  context,
295
- onAfterModelCreateFrom
296
+ onModelAfterCreateFrom
296
297
  });
297
- (0, _beforeDelete.assignBeforeModelDelete)({
298
- onBeforeModelDelete,
298
+ (0, _beforeDelete.assignModelBeforeDelete)({
299
+ onModelBeforeDelete,
299
300
  plugins: context.plugins,
300
301
  storageOperations
301
302
  });
302
- (0, _afterDelete.assignAfterModelDelete)({
303
+ (0, _afterDelete.assignModelAfterDelete)({
303
304
  context,
304
- onAfterModelDelete
305
+ onModelAfterDelete
305
306
  });
306
307
  return {
307
- onBeforeModelCreate,
308
- onAfterModelCreate,
309
- onBeforeModelCreateFrom,
310
- onAfterModelCreateFrom,
311
- onBeforeModelUpdate,
312
- onAfterModelUpdate,
313
- onBeforeModelDelete,
314
- onAfterModelDelete,
308
+ /**
309
+ * Deprecated - will be removed in 5.36.0
310
+ */
311
+ onBeforeModelCreate: onModelBeforeCreate,
312
+ onAfterModelCreate: onModelAfterCreate,
313
+ onBeforeModelCreateFrom: onModelBeforeCreateFrom,
314
+ onAfterModelCreateFrom: onModelAfterCreateFrom,
315
+ onBeforeModelUpdate: onModelBeforeUpdate,
316
+ onAfterModelUpdate: onModelAfterUpdate,
317
+ onBeforeModelDelete: onModelBeforeDelete,
318
+ onAfterModelDelete: onModelAfterDelete,
319
+
320
+ /**
321
+ * Released in 5.34.0
322
+ */
323
+ onModelBeforeCreate,
324
+ onModelAfterCreate,
325
+ onModelBeforeCreateFrom,
326
+ onModelAfterCreateFrom,
327
+ onModelBeforeUpdate,
328
+ onModelAfterUpdate,
329
+ onModelBeforeDelete,
330
+ onModelAfterDelete,
331
+ onModelInitialize,
315
332
  clearModelsCache,
316
333
  getModel,
317
334
  listModels,
@@ -354,7 +371,7 @@ const createModelsCrud = params => {
354
371
  layout: input.layout || [],
355
372
  webinyVersion: context.WEBINY_VERSION
356
373
  };
357
- await onBeforeModelCreate.publish({
374
+ await onModelBeforeCreate.publish({
358
375
  input,
359
376
  model
360
377
  });
@@ -363,7 +380,7 @@ const createModelsCrud = params => {
363
380
  });
364
381
  loaders.listModels.clearAll();
365
382
  await updateManager(context, model);
366
- await onAfterModelCreate.publish({
383
+ await onModelAfterCreate.publish({
367
384
  input,
368
385
  model: createdModel
369
386
  });
@@ -379,14 +396,12 @@ const createModelsCrud = params => {
379
396
  model: initialModel,
380
397
  original
381
398
  } = params;
382
-
383
- const model = _objectSpread(_objectSpread({}, initialModel), {}, {
399
+ const model = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialModel), {}, {
384
400
  tenant: initialModel.tenant || getTenant().id,
385
401
  locale: initialModel.locale || getLocale().code,
386
402
  webinyVersion: context.WEBINY_VERSION
387
403
  });
388
-
389
- await onBeforeModelUpdate.publish({
404
+ await onModelBeforeUpdate.publish({
390
405
  input: {},
391
406
  original,
392
407
  model
@@ -396,7 +411,7 @@ const createModelsCrud = params => {
396
411
  });
397
412
  await updateManager(context, resultModel);
398
413
  loaders.listModels.clearAll();
399
- await onAfterModelUpdate.publish({
414
+ await onModelAfterUpdate.publish({
400
415
  input: {},
401
416
  original,
402
417
  model: resultModel
@@ -441,8 +456,7 @@ const createModelsCrud = params => {
441
456
  }
442
457
 
443
458
  const identity = getIdentity();
444
-
445
- const model = _objectSpread(_objectSpread({}, original), {}, {
459
+ const model = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), {}, {
446
460
  locale: locale.code,
447
461
  group: {
448
462
  id: group.id,
@@ -461,8 +475,7 @@ const createModelsCrud = params => {
461
475
  lockedFields: [],
462
476
  webinyVersion: context.WEBINY_VERSION
463
477
  });
464
-
465
- await onBeforeModelCreateFrom.publish({
478
+ await onModelBeforeCreateFrom.publish({
466
479
  input,
467
480
  model,
468
481
  original
@@ -472,7 +485,7 @@ const createModelsCrud = params => {
472
485
  });
473
486
  loaders.listModels.clearAll();
474
487
  await updateManager(context, model);
475
- await onAfterModelCreateFrom.publish({
488
+ await onModelAfterCreateFrom.publish({
476
489
  input,
477
490
  original,
478
491
  model: createdModel
@@ -518,8 +531,7 @@ const createModelsCrud = params => {
518
531
  }
519
532
 
520
533
  const fields = await (0, _createFieldModels.createFieldModels)(inputData.fields);
521
-
522
- const model = _objectSpread(_objectSpread(_objectSpread({}, original), input), {}, {
534
+ const model = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input), {}, {
523
535
  group,
524
536
  tenant: original.tenant || getTenant().id,
525
537
  locale: original.locale || getLocale().code,
@@ -527,8 +539,7 @@ const createModelsCrud = params => {
527
539
  fields,
528
540
  savedOn: new Date().toISOString()
529
541
  });
530
-
531
- await onBeforeModelUpdate.publish({
542
+ await onModelBeforeUpdate.publish({
532
543
  input,
533
544
  original,
534
545
  model
@@ -537,7 +548,7 @@ const createModelsCrud = params => {
537
548
  model
538
549
  });
539
550
  await updateManager(context, resultModel);
540
- await onAfterModelUpdate.publish({
551
+ await onModelAfterUpdate.publish({
541
552
  input,
542
553
  original,
543
554
  model: resultModel
@@ -548,7 +559,7 @@ const createModelsCrud = params => {
548
559
  async deleteModel(modelId) {
549
560
  await checkModelPermissions("d");
550
561
  const model = await getModel(modelId);
551
- await onBeforeModelDelete.publish({
562
+ await onModelBeforeDelete.publish({
552
563
  model
553
564
  });
554
565
 
@@ -563,12 +574,25 @@ const createModelsCrud = params => {
563
574
  });
564
575
  }
565
576
 
566
- await onAfterModelDelete.publish({
577
+ await onModelAfterDelete.publish({
567
578
  model
568
579
  });
569
580
  managers.delete(model.modelId);
570
581
  },
571
582
 
583
+ async initializeModel(modelId) {
584
+ /**
585
+ * We require that users have write permissions to initialize models.
586
+ * Maybe introduce another permission for it?
587
+ */
588
+ await checkModelPermissions("w");
589
+ const model = await getModel(modelId);
590
+ await onModelInitialize.publish({
591
+ model
592
+ });
593
+ return true;
594
+ },
595
+
572
596
  getModelManager,
573
597
  getEntryManager: async model => {
574
598
  return getModelManager(model);
@@ -1 +1 @@
1
- {"version":3,"names":["featureVersion","semver","coerce","attachStorageIdToFields","fields","map","field","settings","storageId","fieldId","attachStorageIdToModelFields","model","webinyVersion","version","match","compare","createModelsCrud","params","getTenant","getIdentity","getLocale","storageOperations","context","loaders","listModels","DataLoader","models","list","where","tenant","id","locale","code","clearModelsCache","loader","Object","values","clearAll","managers","Map","updateManager","manager","contentModelManagerFactory","set","modelId","checkModelPermissions","check","checkPermissions","rwd","getModelsAsPlugins","plugins","byType","CmsModelPlugin","type","filter","plugin","t","l","contentModel","WEBINY_VERSION","validateModelFields","modelsGet","pluginModel","find","get","NotFoundError","modelsList","databaseModels","load","pluginsModels","concat","permission","filterAsync","validateOwnership","validateModelAccess","getModel","checkOwnership","checkModelAccess","getModelManager","target","has","m","onBeforeModelCreate","createTopic","onAfterModelCreate","onBeforeModelCreateFrom","onAfterModelCreateFrom","onBeforeModelUpdate","onAfterModelUpdate","onBeforeModelDelete","onAfterModelDelete","assignBeforeModelCreate","assignAfterModelCreate","assignBeforeModelUpdate","assignAfterModelUpdate","assignAfterModelCreateFrom","assignBeforeModelDelete","assignAfterModelDelete","createModel","inputData","createdData","CreateContentModelModel","populate","validate","input","toJSON","security","disableAuthorization","group","cms","getGroup","enableAuthorization","createFieldModels","identity","name","description","titleFieldId","createdBy","displayName","createdOn","Date","toISOString","savedOn","lockedFields","layout","publish","createdModel","create","updateModelDirect","initialModel","original","resultModel","update","createModelFrom","data","CreateContentModelModelFrom","i18n","groups","updateModel","updatedData","UpdateContentModelModel","onlyDirty","keys","length","groupData","deleteModel","delete","ex","WebinyError","message","error","getEntryManager","getManagers","getEntryManagers"],"sources":["contentModel.crud.ts"],"sourcesContent":["import {\n CmsContext,\n CmsModel,\n CmsModelContext,\n CmsModelManager,\n CmsModelPermission,\n HeadlessCmsStorageOperations,\n BeforeModelCreateTopicParams,\n AfterModelCreateTopicParams,\n BeforeModelUpdateTopicParams,\n AfterModelUpdateTopicParams,\n BeforeModelDeleteTopicParams,\n AfterModelDeleteTopicParams,\n BeforeModelCreateFromTopicParams,\n AfterModelCreateFromTopicParams,\n CmsModelCreateInput,\n CmsModelUpdateInput,\n CmsModelCreateFromInput,\n CmsModelField\n} from \"~/types\";\nimport DataLoader from \"dataloader\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { contentModelManagerFactory } from \"./contentModel/contentModelManagerFactory\";\nimport {\n CreateContentModelModel,\n CreateContentModelModelFrom,\n UpdateContentModelModel\n} from \"./contentModel/models\";\nimport { createFieldModels } from \"./contentModel/createFieldModels\";\nimport WebinyError from \"@webiny/error\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeModelCreate } from \"./contentModel/beforeCreate\";\nimport { assignBeforeModelUpdate } from \"./contentModel/beforeUpdate\";\nimport { assignBeforeModelDelete } from \"./contentModel/beforeDelete\";\nimport { assignAfterModelCreate } from \"./contentModel/afterCreate\";\nimport { assignAfterModelUpdate } from \"./contentModel/afterUpdate\";\nimport { assignAfterModelDelete } from \"./contentModel/afterDelete\";\nimport { assignAfterModelCreateFrom } from \"./contentModel/afterCreateFrom\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { checkPermissions } from \"~/utils/permissions\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport { checkOwnership, validateOwnership } from \"~/utils/ownership\";\nimport { checkModelAccess, validateModelAccess } from \"~/utils/access\";\nimport { validateModelFields } from \"~/crud/contentModel/validateModelFields\";\nimport semver, { SemVer } from \"semver\";\n\n/**\n * TODO: remove for 5.34.0\n * Required because of the 5.33.0 upgrade.\n * Until the upgrade is done, API will break because there is no storageId assigned.\n */\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst attachStorageIdToFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.map(field => {\n if (field.settings?.fields) {\n field.settings.fields = attachStorageIdToFields(field.settings.fields);\n }\n if (!field.storageId) {\n field.storageId = field.fieldId;\n }\n return field;\n });\n};\n\nconst attachStorageIdToModelFields = (model: CmsModel): CmsModelField[] => {\n if (!model.webinyVersion) {\n return model.fields;\n }\n\n const version = semver.coerce(model.webinyVersion);\n if (!version) {\n return model.fields;\n }\n /**\n * Unfortunately we need to check for beta and next.\n * TODO remove after 5.33.0\n */\n if (model.webinyVersion.match(/beta|next/)) {\n return attachStorageIdToFields(model.fields);\n }\n if (semver.compare(version, featureVersion) >= 0) {\n return model.fields;\n }\n return attachStorageIdToFields(model.fields);\n};\n\nexport interface CreateModelsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\nexport const createModelsCrud = (params: CreateModelsCrudParams): CmsModelContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, context } = params;\n\n const loaders = {\n listModels: new DataLoader(async () => {\n const models = await storageOperations.models.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n return [\n models.map(model => {\n return {\n ...model,\n fields: attachStorageIdToModelFields(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code\n };\n })\n ];\n })\n };\n\n const clearModelsCache = (): void => {\n for (const loader of Object.values(loaders)) {\n loader.clearAll();\n }\n };\n\n const managers = new Map<string, CmsModelManager>();\n const updateManager = async (\n context: CmsContext,\n model: CmsModel\n ): Promise<CmsModelManager> => {\n const manager = await contentModelManagerFactory(context, model);\n managers.set(model.modelId, manager);\n return manager;\n };\n\n const checkModelPermissions = (check: string): Promise<CmsModelPermission> => {\n return checkPermissions(context, \"cms.contentModel\", { rwd: check });\n };\n\n const getModelsAsPlugins = (): CmsModel[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n const models = context.plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n /**\n * We need to filter out models that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModel;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map<CmsModel>(plugin => {\n return {\n ...plugin.contentModel,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n });\n /**\n * Only point where we can truly validate the user model is in the runtime.\n */\n for (const model of models) {\n validateModelFields({\n model,\n plugins: context.plugins\n });\n }\n return models;\n };\n\n const modelsGet = async (modelId: string): Promise<CmsModel> => {\n const pluginModel = getModelsAsPlugins().find(model => model.modelId === modelId);\n\n if (pluginModel) {\n return pluginModel;\n }\n\n const model = await storageOperations.models.get({\n tenant: getTenant().id,\n locale: getLocale().code,\n modelId\n });\n\n if (!model) {\n throw new NotFoundError(`Content model \"${modelId}\" was not found!`);\n }\n\n return {\n ...model,\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code\n };\n };\n\n const modelsList = async (): Promise<CmsModel[]> => {\n const databaseModels = await loaders.listModels.load(\"listModels\");\n\n const pluginsModels = getModelsAsPlugins();\n\n return databaseModels.concat(pluginsModels);\n };\n\n const listModels = async () => {\n const permission = await checkModelPermissions(\"r\");\n const models = await modelsList();\n return filterAsync(models, async model => {\n if (!validateOwnership(context, permission, model)) {\n return false;\n }\n return validateModelAccess(context, model);\n });\n };\n\n const getModel = async (modelId: string): Promise<CmsModel> => {\n const permission = await checkModelPermissions(\"r\");\n\n const model = await modelsGet(modelId);\n\n checkOwnership(context, permission, model);\n await checkModelAccess(context, model);\n\n return model;\n };\n\n const getModelManager: CmsModelContext[\"getModelManager\"] = async (\n target\n ): Promise<CmsModelManager> => {\n const modelId = typeof target === \"string\" ? target : target.modelId;\n if (managers.has(modelId)) {\n return managers.get(modelId) as CmsModelManager;\n }\n const models = await modelsList();\n const model = models.find(m => m.modelId === modelId);\n if (!model) {\n throw new NotFoundError(`There is no content model \"${modelId}\".`);\n }\n return await updateManager(context, model);\n };\n\n const onBeforeModelCreate = createTopic<BeforeModelCreateTopicParams>();\n const onAfterModelCreate = createTopic<AfterModelCreateTopicParams>();\n const onBeforeModelCreateFrom = createTopic<BeforeModelCreateFromTopicParams>();\n const onAfterModelCreateFrom = createTopic<AfterModelCreateFromTopicParams>();\n const onBeforeModelUpdate = createTopic<BeforeModelUpdateTopicParams>();\n const onAfterModelUpdate = createTopic<AfterModelUpdateTopicParams>();\n const onBeforeModelDelete = createTopic<BeforeModelDeleteTopicParams>();\n const onAfterModelDelete = createTopic<AfterModelDeleteTopicParams>();\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeModelCreate({\n onBeforeModelCreate,\n onBeforeModelCreateFrom,\n plugins: context.plugins,\n storageOperations\n });\n assignAfterModelCreate({\n context,\n onAfterModelCreate\n });\n assignBeforeModelUpdate({\n onBeforeModelUpdate,\n plugins: context.plugins,\n storageOperations\n });\n assignAfterModelUpdate({\n context,\n onAfterModelUpdate\n });\n assignAfterModelCreateFrom({\n context,\n onAfterModelCreateFrom\n });\n assignBeforeModelDelete({\n onBeforeModelDelete,\n plugins: context.plugins,\n storageOperations\n });\n assignAfterModelDelete({\n context,\n onAfterModelDelete\n });\n\n return {\n onBeforeModelCreate,\n onAfterModelCreate,\n onBeforeModelCreateFrom,\n onAfterModelCreateFrom,\n onBeforeModelUpdate,\n onAfterModelUpdate,\n onBeforeModelDelete,\n onAfterModelDelete,\n clearModelsCache,\n getModel,\n listModels,\n async createModel(inputData) {\n await checkModelPermissions(\"w\");\n\n const createdData = new CreateContentModelModel().populate(inputData);\n await createdData.validate();\n const input: CmsModelCreateInput = await createdData.toJSON();\n\n context.security.disableAuthorization();\n const group = await context.cms.getGroup(input.group);\n context.security.enableAuthorization();\n if (!group) {\n throw new NotFoundError(`There is no group \"${input.group}\".`);\n }\n\n const fields = await createFieldModels(input.fields);\n\n const identity = getIdentity();\n const model: CmsModel = {\n name: input.name,\n description: input.description || \"\",\n modelId: input.modelId || \"\",\n titleFieldId: \"id\",\n locale: getLocale().code,\n tenant: getTenant().id,\n group: {\n id: group.id,\n name: group.name\n },\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n fields,\n lockedFields: [],\n layout: input.layout || [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n await onBeforeModelCreate.publish({\n input,\n model\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n loaders.listModels.clearAll();\n\n await updateManager(context, model);\n\n await onAfterModelCreate.publish({\n input,\n model: createdModel\n });\n\n return createdModel;\n },\n /**\n * Method does not check for permissions or ownership.\n * @internal\n */\n async updateModelDirect(params) {\n const { model: initialModel, original } = params;\n\n const model: CmsModel = {\n ...initialModel,\n tenant: initialModel.tenant || getTenant().id,\n locale: initialModel.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION\n };\n\n await onBeforeModelUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n loaders.listModels.clearAll();\n\n await onAfterModelUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model: resultModel\n });\n\n return resultModel;\n },\n async createModelFrom(modelId, data) {\n await checkModelPermissions(\"w\");\n /**\n * Get a model record; this will also perform ownership validation.\n */\n const original = await getModel(modelId);\n\n const createdData = new CreateContentModelModelFrom().populate({\n name: data.name,\n modelId: data.modelId,\n description: data.description || original.description,\n group: data.group,\n locale: data.locale\n });\n\n await createdData.validate();\n const input: CmsModelCreateFromInput = await createdData.toJSON();\n\n const locale = await context.i18n.getLocale(input.locale || original.locale);\n if (!locale) {\n throw new NotFoundError(`There is no locale \"${input.locale}\".`);\n }\n /**\n * Use storage operations directly because we cannot get group from different locale via context methods.\n */\n const group = await context.cms.storageOperations.groups.get({\n id: input.group,\n tenant: original.tenant,\n locale: locale.code\n });\n if (!group) {\n throw new NotFoundError(`There is no group \"${input.group}\".`);\n }\n\n const identity = getIdentity();\n const model: CmsModel = {\n ...original,\n locale: locale.code,\n group: {\n id: group.id,\n name: group.name\n },\n name: input.name,\n modelId: input.modelId || \"\",\n description: input.description || \"\",\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n lockedFields: [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n await onBeforeModelCreateFrom.publish({\n input,\n model,\n original\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n loaders.listModels.clearAll();\n\n await updateManager(context, model);\n\n await onAfterModelCreateFrom.publish({\n input,\n original,\n model: createdModel\n });\n\n return createdModel;\n },\n async updateModel(modelId, inputData) {\n await checkModelPermissions(\"w\");\n\n // Get a model record; this will also perform ownership validation.\n const original = await getModel(modelId);\n\n const updatedData = new UpdateContentModelModel().populate(inputData);\n await updatedData.validate();\n\n const input: CmsModelUpdateInput = await updatedData.toJSON({ onlyDirty: true });\n if (Object.keys(input).length === 0) {\n /**\n * We need to return the original if nothing is to be updated.\n */\n return original;\n }\n let group: CmsModel[\"group\"] = {\n id: original.group.id,\n name: original.group.name\n };\n if (input.group) {\n context.security.disableAuthorization();\n const groupData = await context.cms.getGroup(input.group);\n context.security.enableAuthorization();\n if (!groupData) {\n throw new NotFoundError(`There is no group \"${input.group}\".`);\n }\n group = {\n id: groupData.id,\n name: groupData.name\n };\n }\n const fields = await createFieldModels(inputData.fields);\n const model: CmsModel = {\n ...original,\n ...input,\n group,\n tenant: original.tenant || getTenant().id,\n locale: original.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION,\n fields,\n savedOn: new Date().toISOString()\n };\n\n await onBeforeModelUpdate.publish({\n input,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n await onAfterModelUpdate.publish({\n input,\n original,\n model: resultModel\n });\n\n return resultModel;\n },\n async deleteModel(modelId) {\n await checkModelPermissions(\"d\");\n\n const model = await getModel(modelId);\n\n await onBeforeModelDelete.publish({\n model\n });\n\n try {\n await storageOperations.models.delete({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the content model\",\n ex.code || \"CONTENT_MODEL_DELETE_ERROR\",\n {\n error: ex,\n modelId: model.modelId\n }\n );\n }\n\n await onAfterModelDelete.publish({\n model\n });\n\n managers.delete(model.modelId);\n },\n getModelManager,\n getEntryManager: async model => {\n return getModelManager(model);\n },\n getManagers: () => managers,\n getEntryManagers: () => managers\n };\n};\n"],"mappings":";;;;;;;;;;;AAoBA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAGC,eAAA,CAAOC,MAAP,CAAc,QAAd,CAAvB;;AAEA,MAAMC,uBAAuB,GAAIC,MAAD,IAA8C;EAC1E,OAAOA,MAAM,CAACC,GAAP,CAAWC,KAAK,IAAI;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","coerce","attachStorageIdToFields","fields","map","field","settings","storageId","fieldId","attachStorageIdToModelFields","model","webinyVersion","version","match","compare","createModelsCrud","params","getTenant","getIdentity","getLocale","storageOperations","context","loaders","listModels","DataLoader","models","list","where","tenant","id","locale","code","clearModelsCache","loader","Object","values","clearAll","managers","Map","updateManager","manager","contentModelManagerFactory","set","modelId","checkModelPermissions","check","checkPermissions","rwd","getModelsAsPlugins","plugins","byType","CmsModelPlugin","type","filter","plugin","t","l","contentModel","WEBINY_VERSION","validateModelFields","modelsGet","pluginModel","find","get","NotFoundError","modelsList","databaseModels","load","pluginsModels","concat","permission","filterAsync","validateOwnership","validateModelAccess","getModel","checkOwnership","checkModelAccess","getModelManager","target","has","m","onModelBeforeCreate","createTopic","onModelAfterCreate","onModelBeforeCreateFrom","onModelAfterCreateFrom","onModelBeforeUpdate","onModelAfterUpdate","onModelBeforeDelete","onModelAfterDelete","onModelInitialize","assignModelBeforeCreate","assignModelAfterCreate","assignModelBeforeUpdate","assignModelAfterUpdate","assignModelAfterCreateFrom","assignModelBeforeDelete","assignModelAfterDelete","onBeforeModelCreate","onAfterModelCreate","onBeforeModelCreateFrom","onAfterModelCreateFrom","onBeforeModelUpdate","onAfterModelUpdate","onBeforeModelDelete","onAfterModelDelete","createModel","inputData","createdData","CreateContentModelModel","populate","validate","input","toJSON","security","disableAuthorization","group","cms","getGroup","enableAuthorization","createFieldModels","identity","name","description","titleFieldId","createdBy","displayName","createdOn","Date","toISOString","savedOn","lockedFields","layout","publish","createdModel","create","updateModelDirect","initialModel","original","resultModel","update","createModelFrom","data","CreateContentModelModelFrom","i18n","groups","updateModel","updatedData","UpdateContentModelModel","onlyDirty","keys","length","groupData","deleteModel","delete","ex","WebinyError","message","error","initializeModel","getEntryManager","getManagers","getEntryManagers"],"sources":["contentModel.crud.ts"],"sourcesContent":["import {\n CmsContext,\n CmsModel,\n CmsModelContext,\n CmsModelManager,\n CmsModelPermission,\n HeadlessCmsStorageOperations,\n OnModelBeforeCreateTopicParams,\n OnModelAfterCreateTopicParams,\n OnModelBeforeUpdateTopicParams,\n OnModelAfterUpdateTopicParams,\n OnModelBeforeDeleteTopicParams,\n OnModelAfterDeleteTopicParams,\n OnModelInitializeParams,\n OnModelBeforeCreateFromTopicParams,\n OnModelAfterCreateFromTopicParams,\n CmsModelCreateInput,\n CmsModelUpdateInput,\n CmsModelCreateFromInput,\n CmsModelField\n} from \"~/types\";\nimport DataLoader from \"dataloader\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { contentModelManagerFactory } from \"./contentModel/contentModelManagerFactory\";\nimport {\n CreateContentModelModel,\n CreateContentModelModelFrom,\n UpdateContentModelModel\n} from \"./contentModel/models\";\nimport { createFieldModels } from \"./contentModel/createFieldModels\";\nimport WebinyError from \"@webiny/error\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignModelBeforeCreate } from \"./contentModel/beforeCreate\";\nimport { assignModelBeforeUpdate } from \"./contentModel/beforeUpdate\";\nimport { assignModelBeforeDelete } from \"./contentModel/beforeDelete\";\nimport { assignModelAfterCreate } from \"./contentModel/afterCreate\";\nimport { assignModelAfterUpdate } from \"./contentModel/afterUpdate\";\nimport { assignModelAfterDelete } from \"./contentModel/afterDelete\";\nimport { assignModelAfterCreateFrom } from \"./contentModel/afterCreateFrom\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { checkPermissions } from \"~/utils/permissions\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport { checkOwnership, validateOwnership } from \"~/utils/ownership\";\nimport { checkModelAccess, validateModelAccess } from \"~/utils/access\";\nimport { validateModelFields } from \"~/crud/contentModel/validateModelFields\";\nimport semver, { SemVer } from \"semver\";\n\n/**\n * TODO: remove for 5.34.0\n * Required because of the 5.33.0 upgrade.\n * Until the upgrade is done, API will break because there is no storageId assigned.\n */\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst attachStorageIdToFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.map(field => {\n if (field.settings?.fields) {\n field.settings.fields = attachStorageIdToFields(field.settings.fields);\n }\n if (!field.storageId) {\n field.storageId = field.fieldId;\n }\n return field;\n });\n};\n\nconst attachStorageIdToModelFields = (model: CmsModel): CmsModelField[] => {\n if (!model.webinyVersion) {\n return model.fields;\n }\n\n const version = semver.coerce(model.webinyVersion);\n if (!version) {\n return model.fields;\n }\n /**\n * Unfortunately we need to check for beta and next.\n * TODO remove after 5.33.0\n */\n if (model.webinyVersion.match(/beta|next/)) {\n return attachStorageIdToFields(model.fields);\n }\n if (semver.compare(version, featureVersion) >= 0) {\n return model.fields;\n }\n return attachStorageIdToFields(model.fields);\n};\n\nexport interface CreateModelsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\nexport const createModelsCrud = (params: CreateModelsCrudParams): CmsModelContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, context } = params;\n\n const loaders = {\n listModels: new DataLoader(async () => {\n const models = await storageOperations.models.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n return [\n models.map(model => {\n return {\n ...model,\n fields: attachStorageIdToModelFields(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code\n };\n })\n ];\n })\n };\n\n const clearModelsCache = (): void => {\n for (const loader of Object.values(loaders)) {\n loader.clearAll();\n }\n };\n\n const managers = new Map<string, CmsModelManager>();\n const updateManager = async (\n context: CmsContext,\n model: CmsModel\n ): Promise<CmsModelManager> => {\n const manager = await contentModelManagerFactory(context, model);\n managers.set(model.modelId, manager);\n return manager;\n };\n\n const checkModelPermissions = (check: string): Promise<CmsModelPermission> => {\n return checkPermissions(context, \"cms.contentModel\", { rwd: check });\n };\n\n const getModelsAsPlugins = (): CmsModel[] => {\n const tenant = getTenant().id;\n const locale = getLocale().code;\n\n const models = context.plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n /**\n * We need to filter out models that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModel;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map<CmsModel>(plugin => {\n return {\n ...plugin.contentModel,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n });\n /**\n * Only point where we can truly validate the user model is in the runtime.\n */\n for (const model of models) {\n validateModelFields({\n model,\n plugins: context.plugins\n });\n }\n return models;\n };\n\n const modelsGet = async (modelId: string): Promise<CmsModel> => {\n const pluginModel = getModelsAsPlugins().find(model => model.modelId === modelId);\n\n if (pluginModel) {\n return pluginModel;\n }\n\n const model = await storageOperations.models.get({\n tenant: getTenant().id,\n locale: getLocale().code,\n modelId\n });\n\n if (!model) {\n throw new NotFoundError(`Content model \"${modelId}\" was not found!`);\n }\n\n return {\n ...model,\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code\n };\n };\n\n const modelsList = async (): Promise<CmsModel[]> => {\n const databaseModels = await loaders.listModels.load(\"listModels\");\n\n const pluginsModels = getModelsAsPlugins();\n\n return databaseModels.concat(pluginsModels);\n };\n\n const listModels = async () => {\n const permission = await checkModelPermissions(\"r\");\n const models = await modelsList();\n return filterAsync(models, async model => {\n if (!validateOwnership(context, permission, model)) {\n return false;\n }\n return validateModelAccess(context, model);\n });\n };\n\n const getModel = async (modelId: string): Promise<CmsModel> => {\n const permission = await checkModelPermissions(\"r\");\n\n const model = await modelsGet(modelId);\n\n checkOwnership(context, permission, model);\n await checkModelAccess(context, model);\n\n return model;\n };\n\n const getModelManager: CmsModelContext[\"getModelManager\"] = async (\n target\n ): Promise<CmsModelManager> => {\n const modelId = typeof target === \"string\" ? target : target.modelId;\n if (managers.has(modelId)) {\n return managers.get(modelId) as CmsModelManager;\n }\n const models = await modelsList();\n const model = models.find(m => m.modelId === modelId);\n if (!model) {\n throw new NotFoundError(`There is no content model \"${modelId}\".`);\n }\n return await updateManager(context, model);\n };\n\n // create\n const onModelBeforeCreate =\n createTopic<OnModelBeforeCreateTopicParams>(\"cms.onModelBeforeCreate\");\n const onModelAfterCreate = createTopic<OnModelAfterCreateTopicParams>(\"cms.onModelAfterCreate\");\n // create from\n const onModelBeforeCreateFrom = createTopic<OnModelBeforeCreateFromTopicParams>(\n \"cms.onModelBeforeCreateFrom\"\n );\n const onModelAfterCreateFrom = createTopic<OnModelAfterCreateFromTopicParams>(\n \"cms.onModelAfterCreateFrom\"\n );\n // update\n const onModelBeforeUpdate =\n createTopic<OnModelBeforeUpdateTopicParams>(\"cms.onModelBeforeUpdate\");\n const onModelAfterUpdate = createTopic<OnModelAfterUpdateTopicParams>(\"cms.onModelAfterUpdate\");\n // delete\n const onModelBeforeDelete =\n createTopic<OnModelBeforeDeleteTopicParams>(\"cms.onModelBeforeDelete\");\n const onModelAfterDelete = createTopic<OnModelAfterDeleteTopicParams>(\"cms.onModelAfterDelete\");\n\n const onModelInitialize = createTopic<OnModelInitializeParams>(\"cms.onModelInitialize\");\n /**\n * We need to assign some default behaviors.\n */\n assignModelBeforeCreate({\n onModelBeforeCreate,\n onModelBeforeCreateFrom,\n plugins: context.plugins,\n storageOperations\n });\n assignModelAfterCreate({\n context,\n onModelAfterCreate\n });\n assignModelBeforeUpdate({\n onModelBeforeUpdate,\n plugins: context.plugins,\n storageOperations\n });\n assignModelAfterUpdate({\n context,\n onModelAfterUpdate\n });\n assignModelAfterCreateFrom({\n context,\n onModelAfterCreateFrom\n });\n assignModelBeforeDelete({\n onModelBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n assignModelAfterDelete({\n context,\n onModelAfterDelete\n });\n\n return {\n /**\n * Deprecated - will be removed in 5.36.0\n */\n onBeforeModelCreate: onModelBeforeCreate,\n onAfterModelCreate: onModelAfterCreate,\n onBeforeModelCreateFrom: onModelBeforeCreateFrom,\n onAfterModelCreateFrom: onModelAfterCreateFrom,\n onBeforeModelUpdate: onModelBeforeUpdate,\n onAfterModelUpdate: onModelAfterUpdate,\n onBeforeModelDelete: onModelBeforeDelete,\n onAfterModelDelete: onModelAfterDelete,\n /**\n * Released in 5.34.0\n */\n onModelBeforeCreate,\n onModelAfterCreate,\n onModelBeforeCreateFrom,\n onModelAfterCreateFrom,\n onModelBeforeUpdate,\n onModelAfterUpdate,\n onModelBeforeDelete,\n onModelAfterDelete,\n onModelInitialize,\n clearModelsCache,\n getModel,\n listModels,\n async createModel(inputData) {\n await checkModelPermissions(\"w\");\n\n const createdData = new CreateContentModelModel().populate(inputData);\n await createdData.validate();\n const input: CmsModelCreateInput = await createdData.toJSON();\n\n context.security.disableAuthorization();\n const group = await context.cms.getGroup(input.group);\n context.security.enableAuthorization();\n if (!group) {\n throw new NotFoundError(`There is no group \"${input.group}\".`);\n }\n\n const fields = await createFieldModels(input.fields);\n\n const identity = getIdentity();\n const model: CmsModel = {\n name: input.name,\n description: input.description || \"\",\n modelId: input.modelId || \"\",\n titleFieldId: \"id\",\n locale: getLocale().code,\n tenant: getTenant().id,\n group: {\n id: group.id,\n name: group.name\n },\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n fields,\n lockedFields: [],\n layout: input.layout || [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n await onModelBeforeCreate.publish({\n input,\n model\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n loaders.listModels.clearAll();\n\n await updateManager(context, model);\n\n await onModelAfterCreate.publish({\n input,\n model: createdModel\n });\n\n return createdModel;\n },\n /**\n * Method does not check for permissions or ownership.\n * @internal\n */\n async updateModelDirect(params) {\n const { model: initialModel, original } = params;\n\n const model: CmsModel = {\n ...initialModel,\n tenant: initialModel.tenant || getTenant().id,\n locale: initialModel.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION\n };\n\n await onModelBeforeUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n loaders.listModels.clearAll();\n\n await onModelAfterUpdate.publish({\n input: {} as CmsModelUpdateInput,\n original,\n model: resultModel\n });\n\n return resultModel;\n },\n async createModelFrom(modelId, data) {\n await checkModelPermissions(\"w\");\n /**\n * Get a model record; this will also perform ownership validation.\n */\n const original = await getModel(modelId);\n\n const createdData = new CreateContentModelModelFrom().populate({\n name: data.name,\n modelId: data.modelId,\n description: data.description || original.description,\n group: data.group,\n locale: data.locale\n });\n\n await createdData.validate();\n const input: CmsModelCreateFromInput = await createdData.toJSON();\n\n const locale = await context.i18n.getLocale(input.locale || original.locale);\n if (!locale) {\n throw new NotFoundError(`There is no locale \"${input.locale}\".`);\n }\n /**\n * Use storage operations directly because we cannot get group from different locale via context methods.\n */\n const group = await context.cms.storageOperations.groups.get({\n id: input.group,\n tenant: original.tenant,\n locale: locale.code\n });\n if (!group) {\n throw new NotFoundError(`There is no group \"${input.group}\".`);\n }\n\n const identity = getIdentity();\n const model: CmsModel = {\n ...original,\n locale: locale.code,\n group: {\n id: group.id,\n name: group.name\n },\n name: input.name,\n modelId: input.modelId || \"\",\n description: input.description || \"\",\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n lockedFields: [],\n webinyVersion: context.WEBINY_VERSION\n };\n\n await onModelBeforeCreateFrom.publish({\n input,\n model,\n original\n });\n\n const createdModel = await storageOperations.models.create({\n model\n });\n\n loaders.listModels.clearAll();\n\n await updateManager(context, model);\n\n await onModelAfterCreateFrom.publish({\n input,\n original,\n model: createdModel\n });\n\n return createdModel;\n },\n async updateModel(modelId, inputData) {\n await checkModelPermissions(\"w\");\n\n // Get a model record; this will also perform ownership validation.\n const original = await getModel(modelId);\n\n const updatedData = new UpdateContentModelModel().populate(inputData);\n await updatedData.validate();\n\n const input: CmsModelUpdateInput = await updatedData.toJSON({ onlyDirty: true });\n if (Object.keys(input).length === 0) {\n /**\n * We need to return the original if nothing is to be updated.\n */\n return original;\n }\n let group: CmsModel[\"group\"] = {\n id: original.group.id,\n name: original.group.name\n };\n if (input.group) {\n context.security.disableAuthorization();\n const groupData = await context.cms.getGroup(input.group);\n context.security.enableAuthorization();\n if (!groupData) {\n throw new NotFoundError(`There is no group \"${input.group}\".`);\n }\n group = {\n id: groupData.id,\n name: groupData.name\n };\n }\n const fields = await createFieldModels(inputData.fields);\n const model: CmsModel = {\n ...original,\n ...input,\n group,\n tenant: original.tenant || getTenant().id,\n locale: original.locale || getLocale().code,\n webinyVersion: context.WEBINY_VERSION,\n fields,\n savedOn: new Date().toISOString()\n };\n\n await onModelBeforeUpdate.publish({\n input,\n original,\n model\n });\n\n const resultModel = await storageOperations.models.update({\n model\n });\n\n await updateManager(context, resultModel);\n\n await onModelAfterUpdate.publish({\n input,\n original,\n model: resultModel\n });\n\n return resultModel;\n },\n async deleteModel(modelId) {\n await checkModelPermissions(\"d\");\n\n const model = await getModel(modelId);\n\n await onModelBeforeDelete.publish({\n model\n });\n\n try {\n await storageOperations.models.delete({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete the content model\",\n ex.code || \"CONTENT_MODEL_DELETE_ERROR\",\n {\n error: ex,\n modelId: model.modelId\n }\n );\n }\n\n await onModelAfterDelete.publish({\n model\n });\n\n managers.delete(model.modelId);\n },\n async initializeModel(modelId) {\n /**\n * We require that users have write permissions to initialize models.\n * Maybe introduce another permission for it?\n */\n await checkModelPermissions(\"w\");\n\n const model = await getModel(modelId);\n\n await onModelInitialize.publish({ model });\n\n return true;\n },\n getModelManager,\n getEntryManager: async model => {\n return getModelManager(model);\n },\n getManagers: () => managers,\n getEntryManagers: () => managers\n };\n};\n"],"mappings":";;;;;;;;;;;AAqBA;;AAC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1
+ import { OnGroupBeforeCreateTopicParams, HeadlessCmsStorageOperations } from "../../types";
2
2
  import { Topic } from "@webiny/pubsub/types";
3
3
  import { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeGroupCreateParams {
5
- onBeforeCreate: Topic<BeforeGroupCreateTopicParams>;
5
+ onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;
6
6
  plugins: PluginsContainer;
7
7
  storageOperations: HeadlessCmsStorageOperations;
8
8
  }
@@ -1,6 +1,6 @@
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
@@ -17,11 +17,11 @@ var _utils = require("@webiny/utils");
17
17
 
18
18
  const assignBeforeGroupCreate = params => {
19
19
  const {
20
- onBeforeCreate,
20
+ onGroupBeforeCreate,
21
21
  plugins,
22
22
  storageOperations
23
23
  } = params;
24
- onBeforeCreate.subscribe(async params => {
24
+ onGroupBeforeCreate.subscribe(async params => {
25
25
  const {
26
26
  group
27
27
  } = params;
@@ -1 +1 @@
1
- {"version":3,"names":["assignBeforeGroupCreate","params","onBeforeCreate","plugins","storageOperations","subscribe","group","slug","trim","groups","list","where","tenant","locale","length","WebinyError","toSlug","name","generateAlphaNumericId","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","Error"],"sources":["beforeCreate.ts"],"sourcesContent":["import { BeforeGroupCreateTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { toSlug } from \"~/utils/toSlug\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\n\ninterface AssignBeforeGroupCreateParams {\n onBeforeCreate: Topic<BeforeGroupCreateTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupCreate = (params: AssignBeforeGroupCreateParams) => {\n const { onBeforeCreate, plugins, storageOperations } = params;\n\n onBeforeCreate.subscribe(async params => {\n const { group } = params;\n\n if (group.slug && group.slug.trim()) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug: group.slug\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the slug \"${group.slug}\" already exists.`,\n \"SLUG_ALREADY_EXISTS\"\n );\n }\n } else {\n const slug = toSlug(group.name);\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug\n }\n });\n\n if (groups.length === 0) {\n group.slug = slug;\n } else {\n group.slug = `${slug}-${generateAlphaNumericId(8)}`;\n }\n }\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(\n `Cannot create \"${group.slug}\" content model group because one is already registered via a plugin.`\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,cAAF;IAAkBC,OAAlB;IAA2BC;EAA3B,IAAiDH,MAAvD;EAEAC,cAAc,CAACG,SAAf,CAAyB,MAAMJ,MAAN,IAAgB;IACrC,MAAM;MAAEK;IAAF,IAAYL,MAAlB;;IAEA,IAAIK,KAAK,CAACC,IAAN,IAAcD,KAAK,CAACC,IAAN,CAAWC,IAAX,EAAlB,EAAqC;MACjC,MAAMC,MAAM,GAAG,MAAML,iBAAiB,CAACK,MAAlB,CAAyBC,IAAzB,CAA8B;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEN,KAAK,CAACM,MADX;UAEHC,MAAM,EAAEP,KAAK,CAACO,MAFX;UAGHN,IAAI,EAAED,KAAK,CAACC;QAHT;MADwC,CAA9B,CAArB;;MAOA,IAAIE,MAAM,CAACK,MAAP,GAAgB,CAApB,EAAuB;QACnB,MAAM,IAAIC,cAAJ,CACD,4BAA2BT,KAAK,CAACC,IAAK,mBADrC,EAEF,qBAFE,CAAN;MAIH;IACJ,CAdD,MAcO;MACH,MAAMA,IAAI,GAAG,IAAAS,cAAA,EAAOV,KAAK,CAACW,IAAb,CAAb;MACA,MAAMR,MAAM,GAAG,MAAML,iBAAiB,CAACK,MAAlB,CAAyBC,IAAzB,CAA8B;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEN,KAAK,CAACM,MADX;UAEHC,MAAM,EAAEP,KAAK,CAACO,MAFX;UAGHN;QAHG;MADwC,CAA9B,CAArB;;MAQA,IAAIE,MAAM,CAACK,MAAP,KAAkB,CAAtB,EAAyB;QACrBR,KAAK,CAACC,IAAN,GAAaA,IAAb;MACH,CAFD,MAEO;QACHD,KAAK,CAACC,IAAN,GAAc,GAAEA,IAAK,IAAG,IAAAW,6BAAA,EAAuB,CAAvB,CAA0B,EAAlD;MACH;IACJ;;IAED,MAAMC,WAAW,GAAGhB,OAAO,CACtBiB,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBlB,IAAvB,KAAgCD,KAAK,CAACC,IAFpC,CAApB;;IAIA,IAAIY,WAAJ,EAAiB;MACb,MAAM,IAAIO,KAAJ,CACD,kBAAiBpB,KAAK,CAACC,IAAK,uEAD3B,CAAN;IAGH;EACJ,CA3CD;AA4CH,CA/CM"}
1
+ {"version":3,"names":["assignBeforeGroupCreate","params","onGroupBeforeCreate","plugins","storageOperations","subscribe","group","slug","trim","groups","list","where","tenant","locale","length","WebinyError","toSlug","name","generateAlphaNumericId","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","Error"],"sources":["beforeCreate.ts"],"sourcesContent":["import { OnGroupBeforeCreateTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { toSlug } from \"~/utils/toSlug\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\n\ninterface AssignBeforeGroupCreateParams {\n onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupCreate = (params: AssignBeforeGroupCreateParams) => {\n const { onGroupBeforeCreate, plugins, storageOperations } = params;\n\n onGroupBeforeCreate.subscribe(async params => {\n const { group } = params;\n\n if (group.slug && group.slug.trim()) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug: group.slug\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the slug \"${group.slug}\" already exists.`,\n \"SLUG_ALREADY_EXISTS\"\n );\n }\n } else {\n const slug = toSlug(group.name);\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug\n }\n });\n\n if (groups.length === 0) {\n group.slug = slug;\n } else {\n group.slug = `${slug}-${generateAlphaNumericId(8)}`;\n }\n }\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(\n `Cannot create \"${group.slug}\" content model group because one is already registered via a plugin.`\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,mBAAF;IAAuBC,OAAvB;IAAgCC;EAAhC,IAAsDH,MAA5D;EAEAC,mBAAmB,CAACG,SAApB,CAA8B,MAAMJ,MAAN,IAAgB;IAC1C,MAAM;MAA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AK,CAACC,IAAK,uEAD3B,CAAN;IAGH;EACJ,CA3CD;AA4CH,CA/CM"}
@@ -1,8 +1,8 @@
1
1
  import { Topic } from "@webiny/pubsub/types";
2
- import { BeforeGroupDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
2
+ import { OnGroupBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
3
3
  import { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeGroupDeleteParams {
5
- onBeforeDelete: Topic<BeforeGroupDeleteTopicParams>;
5
+ onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;
6
6
  plugins: PluginsContainer;
7
7
  storageOperations: HeadlessCmsStorageOperations;
8
8
  }
@@ -1,6 +1,6 @@
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
@@ -13,11 +13,11 @@ var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
14
14
  const assignBeforeGroupDelete = params => {
15
15
  const {
16
- onBeforeDelete,
16
+ onGroupBeforeDelete,
17
17
  plugins,
18
18
  storageOperations
19
19
  } = params;
20
- onBeforeDelete.subscribe(async params => {
20
+ onGroupBeforeDelete.subscribe(async params => {
21
21
  const {
22
22
  group
23
23
  } = params;
@@ -1 +1 @@
1
- {"version":3,"names":["assignBeforeGroupDelete","params","onBeforeDelete","plugins","storageOperations","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","models","list","where","tenant","locale","items","filter","model","id","length","WebinyError"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { BeforeGroupDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface AssignBeforeGroupDeleteParams {\n onBeforeDelete: Topic<BeforeGroupDeleteTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupDelete = (params: AssignBeforeGroupDeleteParams) => {\n const { onBeforeDelete, plugins, storageOperations } = params;\n\n onBeforeDelete.subscribe(async params => {\n const { group } = params;\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(`Cms Groups defined via plugins cannot be deleted.`);\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: group.tenant,\n locale: group.locale\n }\n });\n const items = models.filter(model => {\n return model.group.id === group.id;\n });\n if (items.length > 0) {\n throw new WebinyError(\n \"Cannot delete this group because there are models that belong to it.\",\n \"BEFORE_DELETE_ERROR\",\n {\n group\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,cAAF;IAAkBC,OAAlB;IAA2BC;EAA3B,IAAiDH,MAAvD;EAEAC,cAAc,CAACG,SAAf,CAAyB,MAAMJ,MAAN,IAAgB;IACrC,MAAM;MAAEK;IAAF,IAAYL,MAAlB;IAEA,MAAMM,WAAW,GAAGJ,OAAO,CACtBK,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBC,IAAvB,KAAgCR,KAAK,CAACQ,IAFpC,CAApB;;IAIA,IAAIP,WAAJ,EAAiB;MACb,MAAM,IAAIQ,KAAJ,CAAW,mDAAX,CAAN;IACH;;IAED,MAAMC,MAAM,GAAG,MAAMZ,iBAAiB,CAACY,MAAlB,CAAyBC,IAAzB,CAA8B;MAC/CC,KAAK,EAAE;QACHC,MAAM,EAAEb,KAAK,CAACa,MADX;QAEHC,MAAM,EAAEd,KAAK,CAACc;MAFX;IADwC,CAA9B,CAArB;IAMA,MAAMC,KAAK,GAAGL,MAAM,CAACM,MAAP,CAAcC,KAAK,IAAI;MACjC,OAAOA,KAAK,CAACjB,KAAN,CAAYkB,EAAZ,KAAmBlB,KAAK,CAACkB,EAAhC;IACH,CAFa,CAAd;;IAGA,IAAIH,KAAK,CAACI,MAAN,GAAe,CAAnB,EAAsB;MAClB,MAAM,IAAIC,cAAJ,CACF,sEADE,EAEF,qBAFE,EAGF;QACIpB;MADJ,CAHE,CAAN;IAOH;EACJ,CA7BD;AA8BH,CAjCM"}
1
+ {"version":3,"names":["assignBeforeGroupDelete","params","onGroupBeforeDelete","plugins","storageOperations","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","models","list","where","tenant","locale","items","filter","model","id","length","WebinyError"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnGroupBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface AssignBeforeGroupDeleteParams {\n onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupDelete = (params: AssignBeforeGroupDeleteParams) => {\n const { onGroupBeforeDelete, plugins, storageOperations } = params;\n\n onGroupBeforeDelete.subscribe(async params => {\n const { group } = params;\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(`Cms Groups defined via plugins cannot be deleted.`);\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: group.tenant,\n locale: group.locale\n }\n });\n const items = models.filter(model => {\n return model.group.id === group.id;\n });\n if (items.length > 0) {\n throw new WebinyError(\n \"Cannot delete this group because there are models that belong to it.\",\n \"BEFORE_DELETE_ERROR\",\n {\n group\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,mBAAF;IAAuBC,OAAvB;IAAgCC;EAAhC,IAAsDH,MAA5D;EAEAC,mBAAmB,CAACG,SAApB,CAA8B,MAAMJ,MAAN,IAAgB;IAC1C,MAAM;MAAEK;IAAF,IAAYL,MAAlB;IAEA,MAAMM,WAAW,GAAGJ,OAAO,CACtBK,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBC,IAAvB,KAAgCR,KAAK,CAACQ,IAFpC,CAApB;;IAIA,IAAIP,WAAJ,EAAiB;MACb,MAAM,IAAIQ,KAAJ,CAAW,mDAAX,CAAN;IACH;;IAED,MAAMC,MAAM,GAAG,MAAMZ,iBAAiB,CAACY,MAAlB,CAAyBC,IAAzB,CAA8B;MAC/CC,KAAK,EAAE;QACHC,MAAM,EAAEb,KAAK,CAACa,MADX;QAEHC,MAAM,EAAEd,KAAK,CAACc;MAFX;IADwC,CAA9B,CAArB;IAMA,MAAMC,KAAK,GAAGL,MAAM,CAACM,MAAP,CAAcC,KAAK,IAAI;MACjC,OAAOA,KAAK,CAACjB,KAAN,CAAYkB,EAAZ,KAAmBlB,KAAK,CAACkB,EAAhC;IACH,CAFa,CAAd;;IAGA,IAAIH,KAAK,CAACI,MAAN,GAAe,CAAnB,EAAsB;MAClB,MAAM,IAAIC,cAAJ,CACF,sEADE,EAEF,qBAFE,EAGF;QACIpB;MADJ,CAHE,CAAN;IAOH;EACJ,CA7BD;AA8BH,CAjCM"}
@@ -1,8 +1,8 @@
1
1
  import { Topic } from "@webiny/pubsub/types";
2
- import { BeforeGroupUpdateTopicParams } from "../../types";
2
+ import { OnGroupBeforeUpdateTopicParams } from "../../types";
3
3
  import { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeGroupUpdateParams {
5
- onBeforeUpdate: Topic<BeforeGroupUpdateTopicParams>;
5
+ onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;
6
6
  plugins: PluginsContainer;
7
7
  }
8
8
  export declare const assignBeforeGroupUpdate: (params: AssignBeforeGroupUpdateParams) => void;
@@ -9,10 +9,10 @@ var _CmsGroupPlugin = require("../../plugins/CmsGroupPlugin");
9
9
 
10
10
  const assignBeforeGroupUpdate = params => {
11
11
  const {
12
- onBeforeUpdate,
12
+ onGroupBeforeUpdate,
13
13
  plugins
14
14
  } = params;
15
- onBeforeUpdate.subscribe(({
15
+ onGroupBeforeUpdate.subscribe(({
16
16
  group
17
17
  }) => {
18
18
  const groupPlugin = plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).find(item => item.contentModelGroup.slug === group.slug);
@@ -1 +1 @@
1
- {"version":3,"names":["assignBeforeGroupUpdate","params","onBeforeUpdate","plugins","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { BeforeGroupUpdateTopicParams } from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface AssignBeforeGroupUpdateParams {\n onBeforeUpdate: Topic<BeforeGroupUpdateTopicParams>;\n plugins: PluginsContainer;\n}\nexport const assignBeforeGroupUpdate = (params: AssignBeforeGroupUpdateParams) => {\n const { onBeforeUpdate, plugins } = params;\n\n onBeforeUpdate.subscribe(({ group }) => {\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n if (!groupPlugin) {\n return;\n }\n throw new Error(`Cms Groups defined via plugins cannot be updated.`);\n });\n};\n"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,cAAF;IAAkBC;EAAlB,IAA8BF,MAApC;EAEAC,cAAc,CAACE,SAAf,CAAyB,CAAC;IAAEC;EAAF,CAAD,KAAe;IACpC,MAAMC,WAAW,GAAGH,OAAO,CACtBI,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBC,IAAvB,KAAgCR,KAAK,CAACQ,IAFpC,CAApB;;IAGA,IAAI,CAACP,WAAL,EAAkB;MACd;IACH;;IACD,MAAM,IAAIQ,KAAJ,CAAW,mDAAX,CAAN;EACH,CARD;AASH,CAZM"}
1
+ {"version":3,"names":["assignBeforeGroupUpdate","params","onGroupBeforeUpdate","plugins","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnGroupBeforeUpdateTopicParams } from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface AssignBeforeGroupUpdateParams {\n onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n plugins: PluginsContainer;\n}\nexport const assignBeforeGroupUpdate = (params: AssignBeforeGroupUpdateParams) => {\n const { onGroupBeforeUpdate, plugins } = params;\n\n onGroupBeforeUpdate.subscribe(({ group }) => {\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n if (!groupPlugin) {\n return;\n }\n throw new Error(`Cms Groups defined via plugins cannot be updated.`);\n });\n};\n"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,uBAAuB,GAAIC,MAAD,IAA2C;EAC9E,MAAM;IAAEC,mBAAF;IAAuBC;EAAvB,IAAmCF,MAAzC;EAEAC,mBAAmB,CAACE,SAApB,CAA8B,CAAC;IAAEC;EAAF,CAAD,KAAe;IACzC,MAAMC,WAAW,GAAGH,OAAO,CACtBI,MADe,CACQC,8BAAA,CAAeC,IADvB,EAEfC,IAFe,CAEVC,IAAI,IAAIA,IAAI,CAACC,iBAAL,CAAuBC,IAAvB,KAAgCR,KAAK,CAACQ,IAFpC,CAApB;;IAGA,IAAI,CAACP,WAAL,EAAkB;MACd;IACH;;IACD,MAAM,IAAIQ,KAAJ,CAAW,mDAAX,CAAN;EACH,CARD;AASH,CAZM"}