@webiny/api-headless-cms 5.17.4 → 5.18.0-beta.3

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 (395) hide show
  1. package/content/contextSetup.js +1 -2
  2. package/content/graphQLHandlerFactory.d.ts +1 -2
  3. package/content/graphQLHandlerFactory.js +12 -4
  4. package/content/plugins/CmsGroupPlugin.d.ts +11 -0
  5. package/content/plugins/{ContentModelGroupPlugin.js → CmsGroupPlugin.js} +4 -5
  6. package/content/plugins/CmsModelPlugin.d.ts +11 -0
  7. package/content/plugins/{ContentModelPlugin.js → CmsModelPlugin.js} +4 -5
  8. package/content/plugins/buildSchemaPlugins.js +1 -2
  9. package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
  10. package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
  11. package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
  12. package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
  13. package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +2 -2
  14. package/content/plugins/crud/contentEntry/entryDataValidation.js +1 -2
  15. package/content/plugins/crud/contentEntry/markLockedFields.d.ts +3 -3
  16. package/content/plugins/crud/contentEntry/markLockedFields.js +10 -7
  17. package/content/plugins/crud/contentEntry.crud.d.ts +12 -4
  18. package/content/plugins/crud/contentEntry.crud.js +807 -757
  19. package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
  20. package/content/plugins/crud/contentModel/afterCreate.js +18 -0
  21. package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
  22. package/content/plugins/crud/contentModel/afterDelete.js +18 -0
  23. package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
  24. package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
  25. package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
  26. package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
  27. package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
  28. package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
  29. package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
  30. package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
  31. package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -2
  32. package/content/plugins/crud/contentModel/contentModelManagerFactory.js +2 -3
  33. package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -2
  34. package/content/plugins/crud/contentModel/createFieldModels.js +2 -3
  35. package/content/plugins/crud/contentModel/idValidation.js +1 -2
  36. package/content/plugins/crud/contentModel/models.js +1 -2
  37. package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -2
  38. package/content/plugins/crud/contentModel/validateLayout.js +1 -2
  39. package/content/plugins/crud/contentModel.crud.d.ts +12 -4
  40. package/content/plugins/crud/contentModel.crud.js +351 -279
  41. package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
  42. package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
  43. package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
  44. package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
  45. package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
  46. package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
  47. package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -4
  48. package/content/plugins/crud/contentModelGroup.crud.js +259 -219
  49. package/content/plugins/crud/index.d.ts +6 -0
  50. package/content/plugins/crud/index.js +96 -0
  51. package/content/plugins/graphqlFields/boolean.js +1 -2
  52. package/content/plugins/graphqlFields/datetime.js +1 -2
  53. package/content/plugins/graphqlFields/file.js +1 -2
  54. package/content/plugins/graphqlFields/index.js +1 -2
  55. package/content/plugins/graphqlFields/longText.js +1 -2
  56. package/content/plugins/graphqlFields/number.js +1 -2
  57. package/content/plugins/graphqlFields/object.js +1 -2
  58. package/content/plugins/graphqlFields/ref.js +22 -11
  59. package/content/plugins/graphqlFields/richText.js +1 -2
  60. package/content/plugins/graphqlFields/text.js +1 -2
  61. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +2 -3
  62. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +1 -2
  63. package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
  64. package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
  65. package/content/plugins/modelManager/index.d.ts +2 -2
  66. package/content/plugins/modelManager/index.js +3 -4
  67. package/content/plugins/schema/baseSchema.js +1 -2
  68. package/content/plugins/schema/contentEntries.js +9 -10
  69. package/content/plugins/schema/contentModelGroups.js +13 -14
  70. package/content/plugins/schema/contentModels.js +9 -10
  71. package/content/plugins/schema/createFieldResolvers.d.ts +2 -2
  72. package/content/plugins/schema/createFieldResolvers.js +14 -20
  73. package/content/plugins/schema/createManageResolvers.d.ts +3 -3
  74. package/content/plugins/schema/createManageResolvers.js +6 -10
  75. package/content/plugins/schema/createManageSDL.d.ts +2 -2
  76. package/content/plugins/schema/createManageSDL.js +5 -6
  77. package/content/plugins/schema/createPreviewResolvers.d.ts +3 -3
  78. package/content/plugins/schema/createPreviewResolvers.js +5 -6
  79. package/content/plugins/schema/createReadResolvers.d.ts +3 -3
  80. package/content/plugins/schema/createReadResolvers.js +5 -6
  81. package/content/plugins/schema/createReadSDL.d.ts +2 -2
  82. package/content/plugins/schema/createReadSDL.js +3 -4
  83. package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +4 -4
  84. package/content/plugins/schema/resolvers/commonFieldResolvers.js +1 -2
  85. package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +1 -1
  86. package/content/plugins/schema/resolvers/manage/resolveCreate.js +3 -4
  87. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
  88. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +3 -4
  89. package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +1 -1
  90. package/content/plugins/schema/resolvers/manage/resolveDelete.js +4 -5
  91. package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +1 -1
  92. package/content/plugins/schema/resolvers/manage/resolveGet.js +3 -4
  93. package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
  94. package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +3 -4
  95. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
  96. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +3 -4
  97. package/content/plugins/schema/resolvers/manage/resolveList.d.ts +1 -1
  98. package/content/plugins/schema/resolvers/manage/resolveList.js +3 -4
  99. package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +1 -1
  100. package/content/plugins/schema/resolvers/manage/resolvePublish.js +3 -4
  101. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +1 -1
  102. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +3 -4
  103. package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +1 -1
  104. package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +3 -4
  105. package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
  106. package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +3 -4
  107. package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
  108. package/content/plugins/schema/resolvers/manage/resolveUpdate.js +3 -4
  109. package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +1 -1
  110. package/content/plugins/schema/resolvers/preview/resolveGet.js +3 -4
  111. package/content/plugins/schema/resolvers/preview/resolveList.d.ts +1 -1
  112. package/content/plugins/schema/resolvers/preview/resolveList.js +3 -4
  113. package/content/plugins/schema/resolvers/read/resolveGet.d.ts +1 -1
  114. package/content/plugins/schema/resolvers/read/resolveGet.js +3 -4
  115. package/content/plugins/schema/resolvers/read/resolveList.d.ts +1 -1
  116. package/content/plugins/schema/resolvers/read/resolveList.js +3 -4
  117. package/content/plugins/schema/schemaPlugins.js +4 -3
  118. package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
  119. package/content/plugins/storage/StorageTransformPlugin.js +36 -0
  120. package/content/plugins/storage/default.d.ts +2 -2
  121. package/content/plugins/storage/default.js +12 -12
  122. package/content/plugins/storage/object.d.ts +2 -2
  123. package/content/plugins/storage/object.js +28 -29
  124. package/content/plugins/utils/createTypeName.js +1 -2
  125. package/content/plugins/utils/entryStorage.d.ts +5 -5
  126. package/content/plugins/utils/entryStorage.js +21 -14
  127. package/content/plugins/utils/getEntryTitle.d.ts +2 -2
  128. package/content/plugins/utils/getEntryTitle.js +1 -2
  129. package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +2 -2
  130. package/content/plugins/utils/getSchemaFromFieldPlugins.js +1 -2
  131. package/content/plugins/utils/pluralizedTypeName.js +1 -2
  132. package/content/plugins/utils/renderFields.d.ts +2 -2
  133. package/content/plugins/utils/renderFields.js +1 -2
  134. package/content/plugins/utils/renderGetFilterFields.d.ts +2 -2
  135. package/content/plugins/utils/renderGetFilterFields.js +1 -2
  136. package/content/plugins/utils/renderInputFields.d.ts +2 -2
  137. package/content/plugins/utils/renderInputFields.js +1 -2
  138. package/content/plugins/utils/renderListFilterFields.d.ts +2 -2
  139. package/content/plugins/utils/renderListFilterFields.js +1 -2
  140. package/content/plugins/utils/renderSortEnum.d.ts +2 -2
  141. package/content/plugins/utils/renderSortEnum.js +1 -2
  142. package/content/plugins/validators/dateGte.js +1 -2
  143. package/content/plugins/validators/dateLte.js +1 -2
  144. package/content/plugins/validators/gte.js +1 -2
  145. package/content/plugins/validators/in.js +1 -2
  146. package/content/plugins/validators/index.js +1 -2
  147. package/content/plugins/validators/lte.js +1 -2
  148. package/content/plugins/validators/maxLength.js +1 -2
  149. package/content/plugins/validators/minLength.js +1 -2
  150. package/content/plugins/validators/pattern.js +1 -2
  151. package/content/plugins/validators/patternPlugins/email.js +1 -2
  152. package/content/plugins/validators/patternPlugins/index.js +1 -2
  153. package/content/plugins/validators/patternPlugins/lowerCase.js +1 -2
  154. package/content/plugins/validators/patternPlugins/upperCase.js +1 -2
  155. package/content/plugins/validators/patternPlugins/url.js +1 -2
  156. package/content/plugins/validators/required.js +1 -2
  157. package/content/plugins/validators/timeGte.js +1 -2
  158. package/content/plugins/validators/timeLte.js +1 -2
  159. package/index.d.ts +12 -0
  160. package/index.js +66 -0
  161. package/migrateCMSPermissions.d.ts +2 -2
  162. package/migrateCMSPermissions.js +1 -2
  163. package/package.json +23 -21
  164. package/plugins/context.js +1 -2
  165. package/plugins/crud/index.d.ts +6 -2
  166. package/plugins/crud/index.js +69 -6
  167. package/plugins/crud/settings.crud.d.ts +10 -4
  168. package/plugins/crud/settings.crud.js +64 -77
  169. package/plugins/crud/system.crud.d.ts +10 -4
  170. package/plugins/crud/system.crud.js +139 -126
  171. package/plugins/graphql/system.js +5 -6
  172. package/plugins/graphql.d.ts +1 -2
  173. package/plugins/graphql.js +49 -50
  174. package/plugins/upgrades/index.js +1 -2
  175. package/plugins/upgrades/v5.5.0/helpers.js +1 -2
  176. package/plugins/upgrades/v5.5.0/index.js +3 -4
  177. package/transformers.js +1 -2
  178. package/types.d.ts +742 -1232
  179. package/types.js +104 -254
  180. package/utils.d.ts +4 -11
  181. package/utils.js +2 -49
  182. package/content/contextSetup.js.map +0 -1
  183. package/content/graphQLHandlerFactory.js.map +0 -1
  184. package/content/index.d.ts +0 -5
  185. package/content/index.js +0 -37
  186. package/content/index.js.map +0 -1
  187. package/content/plugins/ContentModelGroupPlugin.d.ts +0 -7
  188. package/content/plugins/ContentModelGroupPlugin.js.map +0 -1
  189. package/content/plugins/ContentModelPlugin.d.ts +0 -7
  190. package/content/plugins/ContentModelPlugin.js.map +0 -1
  191. package/content/plugins/buildSchemaPlugins.js.map +0 -1
  192. package/content/plugins/crud/contentEntry/afterCreate.hook.d.ts +0 -2
  193. package/content/plugins/crud/contentEntry/afterCreate.hook.js +0 -15
  194. package/content/plugins/crud/contentEntry/afterCreate.hook.js.map +0 -1
  195. package/content/plugins/crud/contentEntry/afterCreateRevisionFrom.hook.d.ts +0 -2
  196. package/content/plugins/crud/contentEntry/afterCreateRevisionFrom.hook.js +0 -15
  197. package/content/plugins/crud/contentEntry/afterCreateRevisionFrom.hook.js.map +0 -1
  198. package/content/plugins/crud/contentEntry/afterDelete.hook.d.ts +0 -2
  199. package/content/plugins/crud/contentEntry/afterDelete.hook.js +0 -15
  200. package/content/plugins/crud/contentEntry/afterDelete.hook.js.map +0 -1
  201. package/content/plugins/crud/contentEntry/afterDeleteRevision.hook.d.ts +0 -2
  202. package/content/plugins/crud/contentEntry/afterDeleteRevision.hook.js +0 -15
  203. package/content/plugins/crud/contentEntry/afterDeleteRevision.hook.js.map +0 -1
  204. package/content/plugins/crud/contentEntry/afterPublish.hook.d.ts +0 -2
  205. package/content/plugins/crud/contentEntry/afterPublish.hook.js +0 -15
  206. package/content/plugins/crud/contentEntry/afterPublish.hook.js.map +0 -1
  207. package/content/plugins/crud/contentEntry/afterRequestChanges.hook.d.ts +0 -2
  208. package/content/plugins/crud/contentEntry/afterRequestChanges.hook.js +0 -15
  209. package/content/plugins/crud/contentEntry/afterRequestChanges.hook.js.map +0 -1
  210. package/content/plugins/crud/contentEntry/afterRequestReview.hook.d.ts +0 -2
  211. package/content/plugins/crud/contentEntry/afterRequestReview.hook.js +0 -15
  212. package/content/plugins/crud/contentEntry/afterRequestReview.hook.js.map +0 -1
  213. package/content/plugins/crud/contentEntry/afterUnpublish.hook.d.ts +0 -2
  214. package/content/plugins/crud/contentEntry/afterUnpublish.hook.js +0 -15
  215. package/content/plugins/crud/contentEntry/afterUnpublish.hook.js.map +0 -1
  216. package/content/plugins/crud/contentEntry/afterUpdate.hook.d.ts +0 -2
  217. package/content/plugins/crud/contentEntry/afterUpdate.hook.js +0 -15
  218. package/content/plugins/crud/contentEntry/afterUpdate.hook.js.map +0 -1
  219. package/content/plugins/crud/contentEntry/beforeCreate.hook.d.ts +0 -2
  220. package/content/plugins/crud/contentEntry/beforeCreate.hook.js +0 -18
  221. package/content/plugins/crud/contentEntry/beforeCreate.hook.js.map +0 -1
  222. package/content/plugins/crud/contentEntry/beforeCreateRevisionFrom.hook.d.ts +0 -2
  223. package/content/plugins/crud/contentEntry/beforeCreateRevisionFrom.hook.js +0 -15
  224. package/content/plugins/crud/contentEntry/beforeCreateRevisionFrom.hook.js.map +0 -1
  225. package/content/plugins/crud/contentEntry/beforeDelete.hook.d.ts +0 -2
  226. package/content/plugins/crud/contentEntry/beforeDelete.hook.js +0 -15
  227. package/content/plugins/crud/contentEntry/beforeDelete.hook.js.map +0 -1
  228. package/content/plugins/crud/contentEntry/beforeDeleteRevision.hook.d.ts +0 -2
  229. package/content/plugins/crud/contentEntry/beforeDeleteRevision.hook.js +0 -15
  230. package/content/plugins/crud/contentEntry/beforeDeleteRevision.hook.js.map +0 -1
  231. package/content/plugins/crud/contentEntry/beforePublish.hook.d.ts +0 -2
  232. package/content/plugins/crud/contentEntry/beforePublish.hook.js +0 -15
  233. package/content/plugins/crud/contentEntry/beforePublish.hook.js.map +0 -1
  234. package/content/plugins/crud/contentEntry/beforeRequestChanges.hook.d.ts +0 -2
  235. package/content/plugins/crud/contentEntry/beforeRequestChanges.hook.js +0 -15
  236. package/content/plugins/crud/contentEntry/beforeRequestChanges.hook.js.map +0 -1
  237. package/content/plugins/crud/contentEntry/beforeRequestReview.hook.d.ts +0 -2
  238. package/content/plugins/crud/contentEntry/beforeRequestReview.hook.js +0 -15
  239. package/content/plugins/crud/contentEntry/beforeRequestReview.hook.js.map +0 -1
  240. package/content/plugins/crud/contentEntry/beforeUnpublish.hook.d.ts +0 -2
  241. package/content/plugins/crud/contentEntry/beforeUnpublish.hook.js +0 -15
  242. package/content/plugins/crud/contentEntry/beforeUnpublish.hook.js.map +0 -1
  243. package/content/plugins/crud/contentEntry/beforeUpdate.hook.d.ts +0 -2
  244. package/content/plugins/crud/contentEntry/beforeUpdate.hook.js +0 -18
  245. package/content/plugins/crud/contentEntry/beforeUpdate.hook.js.map +0 -1
  246. package/content/plugins/crud/contentEntry/entryDataValidation.js.map +0 -1
  247. package/content/plugins/crud/contentEntry/hooks.d.ts +0 -18
  248. package/content/plugins/crud/contentEntry/hooks.js +0 -240
  249. package/content/plugins/crud/contentEntry/hooks.js.map +0 -1
  250. package/content/plugins/crud/contentEntry/markLockedFields.js.map +0 -1
  251. package/content/plugins/crud/contentEntry/runContentEntryLifecycleHooks.d.ts +0 -4
  252. package/content/plugins/crud/contentEntry/runContentEntryLifecycleHooks.js +0 -24
  253. package/content/plugins/crud/contentEntry/runContentEntryLifecycleHooks.js.map +0 -1
  254. package/content/plugins/crud/contentEntry.crud.js.map +0 -1
  255. package/content/plugins/crud/contentModel/afterCreate.hook.d.ts +0 -7
  256. package/content/plugins/crud/contentModel/afterCreate.hook.js +0 -24
  257. package/content/plugins/crud/contentModel/afterCreate.hook.js.map +0 -1
  258. package/content/plugins/crud/contentModel/afterDelete.hook.d.ts +0 -7
  259. package/content/plugins/crud/contentModel/afterDelete.hook.js +0 -24
  260. package/content/plugins/crud/contentModel/afterDelete.hook.js.map +0 -1
  261. package/content/plugins/crud/contentModel/afterUpdate.hook.d.ts +0 -7
  262. package/content/plugins/crud/contentModel/afterUpdate.hook.js +0 -24
  263. package/content/plugins/crud/contentModel/afterUpdate.hook.js.map +0 -1
  264. package/content/plugins/crud/contentModel/beforeCreate.hook.d.ts +0 -7
  265. package/content/plugins/crud/contentModel/beforeCreate.hook.js +0 -137
  266. package/content/plugins/crud/contentModel/beforeCreate.hook.js.map +0 -1
  267. package/content/plugins/crud/contentModel/beforeDelete.hook.d.ts +0 -7
  268. package/content/plugins/crud/contentModel/beforeDelete.hook.js +0 -58
  269. package/content/plugins/crud/contentModel/beforeDelete.hook.js.map +0 -1
  270. package/content/plugins/crud/contentModel/beforeUpdate.hook.d.ts +0 -7
  271. package/content/plugins/crud/contentModel/beforeUpdate.hook.js +0 -141
  272. package/content/plugins/crud/contentModel/beforeUpdate.hook.js.map +0 -1
  273. package/content/plugins/crud/contentModel/contentModelManagerFactory.js.map +0 -1
  274. package/content/plugins/crud/contentModel/createFieldModels.js.map +0 -1
  275. package/content/plugins/crud/contentModel/hooks.d.ts +0 -6
  276. package/content/plugins/crud/contentModel/hooks.js +0 -84
  277. package/content/plugins/crud/contentModel/hooks.js.map +0 -1
  278. package/content/plugins/crud/contentModel/idValidation.js.map +0 -1
  279. package/content/plugins/crud/contentModel/models.js.map +0 -1
  280. package/content/plugins/crud/contentModel/runContentModelLifecycleHooks.d.ts +0 -2
  281. package/content/plugins/crud/contentModel/runContentModelLifecycleHooks.js +0 -24
  282. package/content/plugins/crud/contentModel/runContentModelLifecycleHooks.js.map +0 -1
  283. package/content/plugins/crud/contentModel/validateLayout.js.map +0 -1
  284. package/content/plugins/crud/contentModel.crud.js.map +0 -1
  285. package/content/plugins/crud/contentModelGroup/afterCreate.hook.d.ts +0 -7
  286. package/content/plugins/crud/contentModelGroup/afterCreate.hook.js +0 -24
  287. package/content/plugins/crud/contentModelGroup/afterCreate.hook.js.map +0 -1
  288. package/content/plugins/crud/contentModelGroup/afterDelete.hook.d.ts +0 -8
  289. package/content/plugins/crud/contentModelGroup/afterDelete.hook.js +0 -22
  290. package/content/plugins/crud/contentModelGroup/afterDelete.hook.js.map +0 -1
  291. package/content/plugins/crud/contentModelGroup/afterUpdate.hook.d.ts +0 -7
  292. package/content/plugins/crud/contentModelGroup/afterUpdate.hook.js +0 -26
  293. package/content/plugins/crud/contentModelGroup/afterUpdate.hook.js.map +0 -1
  294. package/content/plugins/crud/contentModelGroup/beforeCreate.hook.d.ts +0 -7
  295. package/content/plugins/crud/contentModelGroup/beforeCreate.hook.js +0 -87
  296. package/content/plugins/crud/contentModelGroup/beforeCreate.hook.js.map +0 -1
  297. package/content/plugins/crud/contentModelGroup/beforeDelete.hook.d.ts +0 -7
  298. package/content/plugins/crud/contentModelGroup/beforeDelete.hook.js +0 -46
  299. package/content/plugins/crud/contentModelGroup/beforeDelete.hook.js.map +0 -1
  300. package/content/plugins/crud/contentModelGroup/beforeUpdate.hook.d.ts +0 -7
  301. package/content/plugins/crud/contentModelGroup/beforeUpdate.hook.js +0 -35
  302. package/content/plugins/crud/contentModelGroup/beforeUpdate.hook.js.map +0 -1
  303. package/content/plugins/crud/contentModelGroup.crud.js.map +0 -1
  304. package/content/plugins/graphqlFields/boolean.js.map +0 -1
  305. package/content/plugins/graphqlFields/datetime.js.map +0 -1
  306. package/content/plugins/graphqlFields/file.js.map +0 -1
  307. package/content/plugins/graphqlFields/index.js.map +0 -1
  308. package/content/plugins/graphqlFields/longText.js.map +0 -1
  309. package/content/plugins/graphqlFields/number.js.map +0 -1
  310. package/content/plugins/graphqlFields/object.js.map +0 -1
  311. package/content/plugins/graphqlFields/ref.js.map +0 -1
  312. package/content/plugins/graphqlFields/richText.js.map +0 -1
  313. package/content/plugins/graphqlFields/text.js.map +0 -1
  314. package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js.map +0 -1
  315. package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js.map +0 -1
  316. package/content/plugins/modelManager/DefaultContentModelManager.d.ts +0 -15
  317. package/content/plugins/modelManager/DefaultContentModelManager.js +0 -63
  318. package/content/plugins/modelManager/DefaultContentModelManager.js.map +0 -1
  319. package/content/plugins/modelManager/index.js.map +0 -1
  320. package/content/plugins/schema/baseSchema.js.map +0 -1
  321. package/content/plugins/schema/contentEntries.js.map +0 -1
  322. package/content/plugins/schema/contentModelGroups.js.map +0 -1
  323. package/content/plugins/schema/contentModels.js.map +0 -1
  324. package/content/plugins/schema/createFieldResolvers.js.map +0 -1
  325. package/content/plugins/schema/createManageResolvers.js.map +0 -1
  326. package/content/plugins/schema/createManageSDL.js.map +0 -1
  327. package/content/plugins/schema/createPreviewResolvers.js.map +0 -1
  328. package/content/plugins/schema/createReadResolvers.js.map +0 -1
  329. package/content/plugins/schema/createReadSDL.js.map +0 -1
  330. package/content/plugins/schema/resolvers/commonFieldResolvers.js.map +0 -1
  331. package/content/plugins/schema/resolvers/manage/resolveCreate.js.map +0 -1
  332. package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js.map +0 -1
  333. package/content/plugins/schema/resolvers/manage/resolveDelete.js.map +0 -1
  334. package/content/plugins/schema/resolvers/manage/resolveGet.js.map +0 -1
  335. package/content/plugins/schema/resolvers/manage/resolveGetByIds.js.map +0 -1
  336. package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js.map +0 -1
  337. package/content/plugins/schema/resolvers/manage/resolveList.js.map +0 -1
  338. package/content/plugins/schema/resolvers/manage/resolvePublish.js.map +0 -1
  339. package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js.map +0 -1
  340. package/content/plugins/schema/resolvers/manage/resolveRequestReview.js.map +0 -1
  341. package/content/plugins/schema/resolvers/manage/resolveUnpublish.js.map +0 -1
  342. package/content/plugins/schema/resolvers/manage/resolveUpdate.js.map +0 -1
  343. package/content/plugins/schema/resolvers/preview/resolveGet.js.map +0 -1
  344. package/content/plugins/schema/resolvers/preview/resolveList.js.map +0 -1
  345. package/content/plugins/schema/resolvers/read/resolveGet.js.map +0 -1
  346. package/content/plugins/schema/resolvers/read/resolveList.js.map +0 -1
  347. package/content/plugins/schema/schemaPlugins.js.map +0 -1
  348. package/content/plugins/storage/default.js.map +0 -1
  349. package/content/plugins/storage/object.js.map +0 -1
  350. package/content/plugins/utils/createTypeName.js.map +0 -1
  351. package/content/plugins/utils/entryStorage.js.map +0 -1
  352. package/content/plugins/utils/getEntryTitle.js.map +0 -1
  353. package/content/plugins/utils/getSchemaFromFieldPlugins.js.map +0 -1
  354. package/content/plugins/utils/pluralizedTypeName.js.map +0 -1
  355. package/content/plugins/utils/renderFields.js.map +0 -1
  356. package/content/plugins/utils/renderGetFilterFields.js.map +0 -1
  357. package/content/plugins/utils/renderInputFields.js.map +0 -1
  358. package/content/plugins/utils/renderListFilterFields.js.map +0 -1
  359. package/content/plugins/utils/renderSortEnum.js.map +0 -1
  360. package/content/plugins/validators/dateGte.js.map +0 -1
  361. package/content/plugins/validators/dateLte.js.map +0 -1
  362. package/content/plugins/validators/gte.js.map +0 -1
  363. package/content/plugins/validators/in.js.map +0 -1
  364. package/content/plugins/validators/index.js.map +0 -1
  365. package/content/plugins/validators/lte.js.map +0 -1
  366. package/content/plugins/validators/maxLength.js.map +0 -1
  367. package/content/plugins/validators/minLength.js.map +0 -1
  368. package/content/plugins/validators/pattern.js.map +0 -1
  369. package/content/plugins/validators/patternPlugins/email.js.map +0 -1
  370. package/content/plugins/validators/patternPlugins/index.js.map +0 -1
  371. package/content/plugins/validators/patternPlugins/lowerCase.js.map +0 -1
  372. package/content/plugins/validators/patternPlugins/upperCase.js.map +0 -1
  373. package/content/plugins/validators/patternPlugins/url.js.map +0 -1
  374. package/content/plugins/validators/required.js.map +0 -1
  375. package/content/plugins/validators/timeGte.js.map +0 -1
  376. package/content/plugins/validators/timeLte.js.map +0 -1
  377. package/migrateCMSPermissions.js.map +0 -1
  378. package/plugins/InstallationPlugin.d.ts +0 -19
  379. package/plugins/InstallationPlugin.js +0 -39
  380. package/plugins/InstallationPlugin.js.map +0 -1
  381. package/plugins/context.js.map +0 -1
  382. package/plugins/crud/index.js.map +0 -1
  383. package/plugins/crud/settings.crud.js.map +0 -1
  384. package/plugins/crud/system.crud.js.map +0 -1
  385. package/plugins/graphql/system.js.map +0 -1
  386. package/plugins/graphql.js.map +0 -1
  387. package/plugins/index.d.ts +0 -2
  388. package/plugins/index.js +0 -25
  389. package/plugins/index.js.map +0 -1
  390. package/plugins/upgrades/index.js.map +0 -1
  391. package/plugins/upgrades/v5.5.0/helpers.js.map +0 -1
  392. package/plugins/upgrades/v5.5.0/index.js.map +0 -1
  393. package/transformers.js.map +0 -1
  394. package/types.js.map +0 -1
  395. package/utils.js.map +0 -1
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.createModelGroupsCrud = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
@@ -17,23 +17,19 @@ var _mdbid = _interopRequireDefault(require("mdbid"));
17
17
 
18
18
  var utils = _interopRequireWildcard(require("../../../utils"));
19
19
 
20
- var _beforeDelete = require("./contentModelGroup/beforeDelete.hook");
21
-
22
- var _beforeCreate = require("./contentModelGroup/beforeCreate.hook");
23
-
24
- var _afterDelete = require("./contentModelGroup/afterDelete.hook");
25
-
26
20
  var _handlerGraphql = require("@webiny/handler-graphql");
27
21
 
28
22
  var _error = _interopRequireDefault(require("@webiny/error"));
29
23
 
30
- var _afterUpdate = require("./contentModelGroup/afterUpdate.hook");
24
+ var _CmsGroupPlugin = require("../CmsGroupPlugin");
25
+
26
+ var _pubsub = require("@webiny/pubsub");
31
27
 
32
- var _beforeUpdate = require("./contentModelGroup/beforeUpdate.hook");
28
+ var _beforeUpdate = require("./contentModelGroup/beforeUpdate");
33
29
 
34
- var _afterCreate = require("./contentModelGroup/afterCreate.hook");
30
+ var _beforeCreate = require("./contentModelGroup/beforeCreate");
35
31
 
36
- var _ContentModelGroupPlugin = require("../ContentModelGroupPlugin");
32
+ var _beforeDelete = require("./contentModelGroup/beforeDelete");
37
33
 
38
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
35
 
@@ -69,243 +65,287 @@ const UpdateContentModelGroupModel = (0, _fields.withFields)({
69
65
  })
70
66
  })();
71
67
 
72
- var _default = () => ({
73
- type: "context",
74
-
75
- async apply(context) {
68
+ const createModelGroupsCrud = params => {
69
+ const {
70
+ getTenant,
71
+ getIdentity,
72
+ getLocale,
73
+ storageOperations,
74
+ context
75
+ } = params;
76
+
77
+ const getGroupsAsPlugins = () => {
78
+ const tenant = getTenant().id;
79
+ const locale = getLocale().code;
80
+ return context.plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type)
76
81
  /**
77
- * If cms is not defined on the context, do not continue, but log it.
82
+ * We need to filter out groups that are not for this tenant or locale.
83
+ * If it does not have tenant or locale define, it is for every locale and tenant
78
84
  */
79
- if (!context.cms) {
80
- return;
81
- }
85
+ .filter(plugin => {
86
+ const {
87
+ tenant: t,
88
+ locale: l
89
+ } = plugin.contentModelGroup;
90
+
91
+ if (t && t !== tenant) {
92
+ return false;
93
+ } else if (l && l !== locale) {
94
+ return false;
95
+ }
82
96
 
83
- const pluginType = "cms-content-model-group-storage-operations-provider";
84
- const providerPlugins = context.plugins.byType(pluginType);
85
- /**
86
- * Storage operations operations for the content model group.
87
- * Contains logic to save the data into the specific storage.
88
- */
97
+ return true;
98
+ }).map(plugin => {
99
+ return _objectSpread(_objectSpread({}, plugin.contentModelGroup), {}, {
100
+ tenant,
101
+ locale,
102
+ webinyVersion: context.WEBINY_VERSION
103
+ });
104
+ });
105
+ };
89
106
 
90
- const providerPlugin = providerPlugins[providerPlugins.length - 1];
107
+ const checkPermissions = check => {
108
+ return utils.checkPermissions(context, "cms.contentModelGroup", {
109
+ rwd: check
110
+ });
111
+ };
91
112
 
92
- if (!providerPlugin) {
93
- throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
94
- type: pluginType
95
- });
113
+ const groupsGet = async id => {
114
+ const groupPlugin = getGroupsAsPlugins().find(group => group.id === id);
115
+
116
+ if (groupPlugin) {
117
+ return groupPlugin;
96
118
  }
97
119
 
98
- const storageOperations = await providerPlugin.provide({
99
- context
100
- });
120
+ const tenant = getTenant().id;
121
+ const locale = getLocale().code;
122
+ let group = null;
101
123
 
102
- const checkPermissions = check => {
103
- return utils.checkPermissions(context, "cms.contentModelGroup", {
104
- rwd: check
124
+ try {
125
+ group = await storageOperations.groups.get({
126
+ tenant,
127
+ locale,
128
+ id
105
129
  });
106
- };
130
+ } catch (ex) {
131
+ throw new _error.default(ex.message, ex.code || "GET_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
132
+ id
133
+ }));
134
+ }
107
135
 
108
- const groupsGet = async id => {
109
- const groupPlugin = context.plugins.byType(_ContentModelGroupPlugin.ContentModelGroupPlugin.type).find(item => item.contentModelGroup.id === id);
136
+ if (!group) {
137
+ throw new _handlerGraphql.NotFoundError(`Cms Group "${id}" was not found!`);
138
+ }
110
139
 
111
- if (groupPlugin) {
112
- return groupPlugin.contentModelGroup;
113
- }
140
+ return _objectSpread(_objectSpread({}, group), {}, {
141
+ tenant: group.tenant || tenant,
142
+ locale: group.locale || locale
143
+ });
144
+ };
145
+
146
+ const groupsList = async params => {
147
+ const {
148
+ where
149
+ } = params || {};
150
+ const tenant = getTenant().id;
151
+ const locale = getLocale().code;
152
+
153
+ try {
154
+ const pluginsGroups = getGroupsAsPlugins();
155
+ const databaseGroups = await storageOperations.groups.list({
156
+ where: _objectSpread(_objectSpread({}, where || {}), {}, {
157
+ tenant: where ? where.tenant : tenant,
158
+ locale: where ? where.locale : locale
159
+ })
160
+ });
161
+ return pluginsGroups.concat(databaseGroups.map(group => {
162
+ return _objectSpread(_objectSpread({}, group), {}, {
163
+ tenant: group.tenant || tenant,
164
+ locale: group.locale || locale
165
+ });
166
+ }));
167
+ } catch (ex) {
168
+ throw new _error.default(ex.message, ex.code || "LIST_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
169
+ where
170
+ }));
171
+ }
172
+ };
173
+
174
+ const onBeforeCreate = (0, _pubsub.createTopic)();
175
+ const onAfterCreate = (0, _pubsub.createTopic)();
176
+ const onBeforeUpdate = (0, _pubsub.createTopic)();
177
+ const onAfterUpdate = (0, _pubsub.createTopic)();
178
+ const onBeforeDelete = (0, _pubsub.createTopic)();
179
+ const onAfterDelete = (0, _pubsub.createTopic)();
180
+ /**
181
+ * We need to assign some default behaviors.
182
+ */
183
+
184
+ (0, _beforeCreate.assignBeforeGroupCreate)({
185
+ onBeforeCreate,
186
+ plugins: context.plugins,
187
+ storageOperations
188
+ });
189
+ (0, _beforeUpdate.assignBeforeGroupUpdate)({
190
+ onBeforeUpdate,
191
+ plugins: context.plugins
192
+ });
193
+ (0, _beforeDelete.assignBeforeGroupDelete)({
194
+ onBeforeDelete,
195
+ plugins: context.plugins,
196
+ storageOperations
197
+ });
198
+ return {
199
+ onBeforeGroupCreate: onBeforeCreate,
200
+ onAfterGroupCreate: onAfterCreate,
201
+ onBeforeGroupUpdate: onBeforeUpdate,
202
+ onAfterGroupUpdate: onAfterUpdate,
203
+ onBeforeGroupDelete: onBeforeDelete,
204
+ onAfterGroupDelete: onAfterDelete,
205
+ getGroup: async id => {
206
+ const permission = await checkPermissions("r");
207
+ const group = await groupsGet(id);
208
+ utils.checkOwnership(context, permission, group);
209
+ utils.validateGroupAccess(context, permission, group);
210
+ return group;
211
+ },
212
+ listGroups: async params => {
213
+ const {
214
+ where
215
+ } = params || {};
216
+ const {
217
+ tenant,
218
+ locale
219
+ } = where || {};
220
+ const permission = await checkPermissions("r");
221
+ const response = await groupsList(_objectSpread(_objectSpread({}, params || {}), {}, {
222
+ where: _objectSpread(_objectSpread({}, where || {}), {}, {
223
+ tenant: tenant || getTenant().id,
224
+ locale: locale || getLocale().code
225
+ })
226
+ }));
227
+ return response.filter(group => {
228
+ if (!utils.validateOwnership(context, permission, group)) {
229
+ return false;
230
+ }
114
231
 
115
- let group = null;
232
+ return utils.validateGroupAccess(context, permission, group);
233
+ });
234
+ },
235
+ createGroup: async inputData => {
236
+ await checkPermissions("w");
237
+ const createdData = new CreateContentModelGroupModel().populate(_objectSpread(_objectSpread({}, inputData), {}, {
238
+ slug: inputData.slug ? utils.toSlug(inputData.slug) : ""
239
+ }));
240
+ await createdData.validate();
241
+ const input = await createdData.toJSON();
242
+ const identity = getIdentity();
243
+ const id = (0, _mdbid.default)();
244
+
245
+ const group = _objectSpread(_objectSpread({}, input), {}, {
246
+ id,
247
+ tenant: getTenant().id,
248
+ locale: getLocale().code,
249
+ createdOn: new Date().toISOString(),
250
+ savedOn: new Date().toISOString(),
251
+ createdBy: {
252
+ id: identity.id,
253
+ displayName: identity.displayName,
254
+ type: identity.type
255
+ },
256
+ webinyVersion: context.WEBINY_VERSION
257
+ });
116
258
 
117
259
  try {
118
- group = await storageOperations.get({
119
- id
260
+ await onBeforeCreate.publish({
261
+ group
262
+ });
263
+ const result = await storageOperations.groups.create({
264
+ input,
265
+ group
120
266
  });
267
+ await onAfterCreate.publish({
268
+ group: result
269
+ });
270
+ return group;
121
271
  } catch (ex) {
122
- throw new _error.default(ex.message, ex.code || "GET_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
123
- id
272
+ throw new _error.default(ex.message || "Could not save data model group.", ex.code || "ERROR_ON_CREATE", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
273
+ group,
274
+ input
124
275
  }));
125
276
  }
277
+ },
278
+ updateGroup: async (id, inputData) => {
279
+ const permission = await checkPermissions("w");
280
+ const original = await groupsGet(id);
281
+ utils.checkOwnership(context, permission, original);
282
+ const input = new UpdateContentModelGroupModel().populate(inputData);
283
+ await input.validate();
284
+ const updatedDataJson = await input.toJSON({
285
+ onlyDirty: true
286
+ });
287
+ /**
288
+ * No need to continue if no values were changed
289
+ */
126
290
 
127
- if (!group) {
128
- throw new _handlerGraphql.NotFoundError(`Content model group "${id}" was not found!`);
291
+ if (Object.keys(updatedDataJson).length === 0) {
292
+ return original;
129
293
  }
130
294
 
131
- return group;
132
- };
133
-
134
- const groupsList = async args => {
135
- const {
136
- where,
137
- limit
138
- } = args || {};
295
+ const group = _objectSpread(_objectSpread(_objectSpread({}, original), updatedDataJson), {}, {
296
+ locale: getLocale().code,
297
+ tenant: getTenant().id,
298
+ savedOn: new Date().toISOString()
299
+ });
139
300
 
140
301
  try {
141
- const pluginsGroups = context.plugins.byType(_ContentModelGroupPlugin.ContentModelGroupPlugin.type).map(plugin => plugin.contentModelGroup);
142
- const databaseGroups = await storageOperations.list({
143
- where,
144
- limit
302
+ await onBeforeUpdate.publish({
303
+ original,
304
+ group
145
305
  });
146
- return [...databaseGroups, ...pluginsGroups];
306
+ const updatedGroup = await storageOperations.groups.update({
307
+ original,
308
+ group,
309
+ input
310
+ });
311
+ await onAfterUpdate.publish({
312
+ original,
313
+ group: updatedGroup
314
+ });
315
+ return updatedGroup;
147
316
  } catch (ex) {
148
- throw new _error.default(ex.message, ex.code || "LIST_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
149
- where,
150
- limit
151
- }));
317
+ throw new _error.default(ex.message, ex.code || "UPDATE_ERROR", {
318
+ error: ex,
319
+ original,
320
+ group,
321
+ input
322
+ });
152
323
  }
153
- };
154
-
155
- const groups = {
156
- operations: storageOperations,
157
- noAuth: () => {
158
- return {
159
- get: groupsGet,
160
- list: groupsList
161
- };
162
- },
163
- get: async id => {
164
- const permission = await checkPermissions("r");
165
- const group = await groupsGet(id);
166
- utils.checkOwnership(context, permission, group);
167
- utils.validateGroupAccess(context, permission, group);
168
- return group;
169
- },
170
- list: async args => {
171
- const permission = await checkPermissions("r");
172
- const response = await groupsList(args);
173
- return response.filter(group => {
174
- if (!utils.validateOwnership(context, permission, group)) {
175
- return false;
176
- }
177
-
178
- return utils.validateGroupAccess(context, permission, group);
324
+ },
325
+ deleteGroup: async id => {
326
+ const permission = await checkPermissions("d");
327
+ const group = await groupsGet(id);
328
+ utils.checkOwnership(context, permission, group);
329
+
330
+ try {
331
+ await onBeforeDelete.publish({
332
+ group
179
333
  });
180
- },
181
- create: async inputData => {
182
- await checkPermissions("w");
183
- const createdData = new CreateContentModelGroupModel().populate(_objectSpread(_objectSpread({}, inputData), {}, {
184
- slug: inputData.slug ? utils.toSlug(inputData.slug) : ""
185
- }));
186
- await createdData.validate();
187
- const input = await createdData.toJSON();
188
- const identity = context.security.getIdentity();
189
- const id = (0, _mdbid.default)();
190
-
191
- const data = _objectSpread(_objectSpread({}, input), {}, {
192
- id,
193
- locale: context.cms.getLocale().code,
194
- createdOn: new Date().toISOString(),
195
- savedOn: new Date().toISOString(),
196
- createdBy: {
197
- id: identity.id,
198
- displayName: identity.displayName,
199
- type: identity.type
200
- }
334
+ await storageOperations.groups.delete({
335
+ group
201
336
  });
202
-
203
- try {
204
- await (0, _beforeCreate.beforeCreateHook)({
205
- context,
206
- storageOperations,
207
- input,
208
- data
209
- });
210
- const group = await storageOperations.create({
211
- input,
212
- data
213
- });
214
- await (0, _afterCreate.afterCreateHook)({
215
- context,
216
- storageOperations,
217
- input,
218
- group
219
- });
220
- return group;
221
- } catch (ex) {
222
- throw new _error.default(ex.message || "Could not save data model group.", ex.code || "ERROR_ON_CREATE", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
223
- data,
224
- input
225
- }));
226
- }
227
- },
228
- update: async (id, inputData) => {
229
- const permission = await checkPermissions("w");
230
- const group = await groupsGet(id);
231
- utils.checkOwnership(context, permission, group);
232
- const input = new UpdateContentModelGroupModel().populate(inputData);
233
- await input.validate();
234
- const updatedDataJson = await input.toJSON({
235
- onlyDirty: true
236
- }); // no need to continue if no values were changed
237
-
238
- if (Object.keys(updatedDataJson).length === 0) {
239
- return group;
240
- }
241
-
242
- const data = Object.assign(updatedDataJson, {
243
- savedOn: new Date().toISOString()
337
+ await onAfterDelete.publish({
338
+ group
244
339
  });
245
-
246
- try {
247
- await (0, _beforeUpdate.beforeUpdateHook)({
248
- context,
249
- storageOperations,
250
- group,
251
- input,
252
- data
253
- });
254
- const updatedGroup = await storageOperations.update({
255
- group,
256
- data,
257
- input
258
- });
259
- await (0, _afterUpdate.afterUpdateHook)({
260
- context,
261
- storageOperations,
262
- group: updatedGroup,
263
- data,
264
- input
265
- });
266
- return updatedGroup;
267
- } catch (ex) {
268
- throw new _error.default(ex.message, ex.code || "UPDATE_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
269
- group,
270
- data,
271
- input
272
- }));
273
- }
274
- },
275
- delete: async id => {
276
- const permission = await checkPermissions("d");
277
- const group = await groupsGet(id);
278
- utils.checkOwnership(context, permission, group);
279
-
280
- try {
281
- await (0, _beforeDelete.beforeDeleteHook)({
282
- context,
283
- storageOperations,
284
- group
285
- });
286
- await storageOperations.delete({
287
- group
288
- });
289
- await (0, _afterDelete.afterDeleteHook)({
290
- context,
291
- storageOperations,
292
- group
293
- });
294
- } catch (ex) {
295
- throw new _error.default(ex.message, ex.code || "DELETE_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
296
- id
297
- }));
298
- }
299
-
300
- return true;
340
+ } catch (ex) {
341
+ throw new _error.default(ex.message, ex.code || "DELETE_ERROR", _objectSpread(_objectSpread({}, ex.data || {}), {}, {
342
+ id
343
+ }));
301
344
  }
302
- };
303
- context.cms = _objectSpread(_objectSpread({}, context.cms || {}), {}, {
304
- groups
305
- });
306
- }
307
345
 
308
- });
346
+ return true;
347
+ }
348
+ };
349
+ };
309
350
 
310
- exports.default = _default;
311
- //# sourceMappingURL=contentModelGroup.crud.js.map
351
+ exports.createModelGroupsCrud = createModelGroupsCrud;
@@ -0,0 +1,6 @@
1
+ import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
2
+ import { CmsContext, HeadlessCmsStorageOperations } from "../../../types";
3
+ export interface Params {
4
+ storageOperations: HeadlessCmsStorageOperations;
5
+ }
6
+ export declare const createContentCruds: (params: Params) => ContextPlugin<CmsContext>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createContentCruds = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _ContextPlugin = require("@webiny/handler/plugins/ContextPlugin");
13
+
14
+ var _contentModelGroup = require("./contentModelGroup.crud");
15
+
16
+ var _contentModel = require("./contentModel.crud");
17
+
18
+ var _contentEntry = require("./contentEntry.crud");
19
+
20
+ var _system = require("../../../plugins/crud/system.crud");
21
+
22
+ var _settings = require("../../../plugins/crud/settings.crud");
23
+
24
+ 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; }
25
+
26
+ 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; }
27
+
28
+ const createContentCruds = params => {
29
+ const {
30
+ storageOperations
31
+ } = params;
32
+ return new _ContextPlugin.ContextPlugin(async context => {
33
+ /**
34
+ * This should never happen in the actual project.
35
+ * It is to make sure that we load setup context before the CRUD init in our internal code.
36
+ */
37
+ if (!context.cms) {
38
+ console.log(`Missing initial "cms" on the context. Make sure that you set it up before creating Content CRUDs.`);
39
+ return;
40
+ }
41
+
42
+ const getLocale = () => {
43
+ return context.i18n.getCurrentLocale();
44
+ };
45
+
46
+ const getIdentity = () => {
47
+ return context.security.getIdentity();
48
+ };
49
+
50
+ const getTenant = () => {
51
+ return context.tenancy.getCurrentTenant();
52
+ };
53
+
54
+ if (storageOperations.plugins && storageOperations.plugins.length > 0) {
55
+ context.plugins.register(storageOperations.plugins);
56
+ }
57
+
58
+ context.cms = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context.cms), (0, _system.createSystemCrud)({
59
+ context,
60
+ getTenant,
61
+ getIdentity,
62
+ storageOperations
63
+ })), (0, _settings.createSettingsCrud)({
64
+ context,
65
+ getTenant,
66
+ getLocale,
67
+ storageOperations
68
+ })), (0, _contentModelGroup.createModelGroupsCrud)({
69
+ context,
70
+ getTenant,
71
+ getLocale,
72
+ getIdentity,
73
+ storageOperations
74
+ })), (0, _contentModel.createModelsCrud)({
75
+ context,
76
+ getLocale,
77
+ getTenant,
78
+ getIdentity,
79
+ storageOperations
80
+ })), (0, _contentEntry.createContentEntryCrud)({
81
+ context,
82
+ getLocale,
83
+ getTenant,
84
+ getIdentity,
85
+ storageOperations
86
+ }));
87
+
88
+ if (!storageOperations.init) {
89
+ return;
90
+ }
91
+
92
+ await storageOperations.init(context.cms);
93
+ });
94
+ };
95
+
96
+ exports.createContentCruds = createContentCruds;
@@ -66,5 +66,4 @@ const plugin = {
66
66
  }
67
67
  };
68
68
  var _default = plugin;
69
- exports.default = _default;
70
- //# sourceMappingURL=boolean.js.map
69
+ exports.default = _default;
@@ -80,5 +80,4 @@ const plugin = {
80
80
  }
81
81
  };
82
82
  var _default = plugin;
83
- exports.default = _default;
84
- //# sourceMappingURL=datetime.js.map
83
+ exports.default = _default;
@@ -46,5 +46,4 @@ const plugin = {
46
46
  }
47
47
  };
48
48
  var _default = plugin;
49
- exports.default = _default;
50
- //# sourceMappingURL=file.js.map
49
+ exports.default = _default;
@@ -27,5 +27,4 @@ var _object = _interopRequireDefault(require("./object"));
27
27
 
28
28
  var _default = () => [_text.default, _ref.default, _number.default, _datetime.default, _boolean.default, _longText.default, _richText.default, _file.default, _object.default];
29
29
 
30
- exports.default = _default;
31
- //# sourceMappingURL=index.js.map
30
+ exports.default = _default;
@@ -59,5 +59,4 @@ const plugin = {
59
59
  }
60
60
  };
61
61
  var _default = plugin;
62
- exports.default = _default;
63
- //# sourceMappingURL=longText.js.map
62
+ exports.default = _default;
@@ -72,5 +72,4 @@ const plugin = {
72
72
  }
73
73
  };
74
74
  var _default = plugin;
75
- exports.default = _default;
76
- //# sourceMappingURL=number.js.map
75
+ exports.default = _default;