@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
@@ -1,4 +1,4 @@
1
- import { CmsContentModel } from "./types";
1
+ import { CmsModel } from "./types";
2
2
  declare type Group = {
3
3
  [code: string]: string[];
4
4
  };
@@ -13,5 +13,5 @@ declare type CMSPermission = {
13
13
  groups?: Group;
14
14
  models?: Model;
15
15
  };
16
- export declare const migrateCMSPermissions: (permissions: CMSPermission[], getModel: (modelId: string) => Promise<CmsContentModel>) => Promise<CMSPermission[]>;
16
+ export declare const migrateCMSPermissions: (permissions: CMSPermission[], getModel: (modelId: string) => Promise<CmsModel>) => Promise<CMSPermission[]>;
17
17
  export {};
@@ -190,5 +190,4 @@ const setAccessScopeToOwn = (permissions, entity) => {
190
190
  delete permissions[entity].groups; // Remove "models" from content model permission
191
191
 
192
192
  delete permissions[entity].models;
193
- };
194
- //# sourceMappingURL=migrateCMSPermissions.js.map
193
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "5.17.4",
3
+ "version": "5.18.0-beta.3",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "cms:base"
@@ -21,21 +21,23 @@
21
21
  "@babel/runtime": "7.16.3",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
23
  "@graphql-tools/schema": "7.1.5",
24
- "@webiny/api-file-manager": "5.17.4",
25
- "@webiny/api-i18n": "5.17.4",
26
- "@webiny/api-i18n-content": "5.17.4",
27
- "@webiny/api-i18n-ddb": "5.17.4",
28
- "@webiny/api-security": "5.17.4",
29
- "@webiny/api-tenancy": "5.17.4",
30
- "@webiny/api-upgrade": "5.17.4",
31
- "@webiny/error": "5.17.4",
32
- "@webiny/handler": "5.17.4",
33
- "@webiny/handler-aws": "5.17.4",
34
- "@webiny/handler-db": "5.17.4",
35
- "@webiny/handler-graphql": "5.17.4",
36
- "@webiny/handler-http": "5.17.4",
37
- "@webiny/plugins": "5.17.4",
38
- "@webiny/validation": "5.17.4",
24
+ "@webiny/api-file-manager": "5.18.0-beta.3",
25
+ "@webiny/api-i18n": "5.18.0-beta.3",
26
+ "@webiny/api-i18n-content": "5.18.0-beta.3",
27
+ "@webiny/api-i18n-ddb": "5.18.0-beta.3",
28
+ "@webiny/api-security": "5.18.0-beta.3",
29
+ "@webiny/api-tenancy": "5.18.0-beta.3",
30
+ "@webiny/api-upgrade": "5.18.0-beta.3",
31
+ "@webiny/error": "5.18.0-beta.3",
32
+ "@webiny/handler": "5.18.0-beta.3",
33
+ "@webiny/handler-aws": "5.18.0-beta.3",
34
+ "@webiny/handler-db": "5.18.0-beta.3",
35
+ "@webiny/handler-graphql": "5.18.0-beta.3",
36
+ "@webiny/handler-http": "5.18.0-beta.3",
37
+ "@webiny/plugins": "5.18.0-beta.3",
38
+ "@webiny/pubsub": "5.18.0-beta.3",
39
+ "@webiny/utils": "5.18.0-beta.3",
40
+ "@webiny/validation": "5.18.0-beta.3",
39
41
  "boolean": "3.1.4",
40
42
  "commodo-fields-object": "1.0.6",
41
43
  "dataloader": "2.0.0",
@@ -51,10 +53,10 @@
51
53
  "@babel/core": "^7.5.5",
52
54
  "@babel/preset-env": "^7.5.5",
53
55
  "@babel/preset-flow": "^7.0.0",
54
- "@webiny/api-security-so-ddb": "^5.17.4",
55
- "@webiny/api-tenancy-so-ddb": "^5.17.4",
56
- "@webiny/cli": "^5.17.4",
57
- "@webiny/project-utils": "^5.17.4",
56
+ "@webiny/api-security-so-ddb": "^5.18.0-beta.3",
57
+ "@webiny/api-tenancy-so-ddb": "^5.18.0-beta.3",
58
+ "@webiny/cli": "^5.18.0-beta.3",
59
+ "@webiny/project-utils": "^5.18.0-beta.3",
58
60
  "apollo-graphql": "^0.4.1",
59
61
  "get-yarn-workspaces": "^1.0.2",
60
62
  "graphql": "^14.6.0",
@@ -74,5 +76,5 @@
74
76
  "build": "yarn webiny run build",
75
77
  "watch": "yarn webiny run watch"
76
78
  },
77
- "gitHead": "bdfaa377704bf7f51d73561b4c6129f682bf24d2"
79
+ "gitHead": "9c86670476a62348ce391b091bf768e425ab6ee9"
78
80
  }
@@ -31,5 +31,4 @@ var _default = () => {
31
31
  });
32
32
  };
33
33
 
34
- exports.default = _default;
35
- //# sourceMappingURL=context.js.map
34
+ exports.default = _default;
@@ -1,2 +1,6 @@
1
- declare const _default: () => (import("@webiny/handler/plugins/ContextPlugin").ContextPlugin<import("../../types").CmsContext> | import("@webiny/handler/types").ContextPlugin<import("../../types").CmsContext, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>>)[];
2
- export default _default;
1
+ import { CmsContext, HeadlessCmsStorageOperations } from "../../types";
2
+ import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
3
+ export interface Params {
4
+ storageOperations: HeadlessCmsStorageOperations;
5
+ }
6
+ export declare const createAdminCruds: (params: Params) => ContextPlugin<CmsContext>;
@@ -5,13 +5,76 @@ 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.createAdminCruds = void 0;
9
9
 
10
- var _settings = _interopRequireDefault(require("./settings.crud"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
- var _system = _interopRequireDefault(require("./system.crud"));
12
+ var _settings = require("./settings.crud");
13
13
 
14
- var _default = () => [_settings.default, _system.default];
14
+ var _system = require("./system.crud");
15
15
 
16
- exports.default = _default;
17
- //# sourceMappingURL=index.js.map
16
+ var _ContextPlugin = require("@webiny/handler/plugins/ContextPlugin");
17
+
18
+ var _contentModelGroup = require("../../content/plugins/crud/contentModelGroup.crud");
19
+
20
+ 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; }
21
+
22
+ 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; }
23
+
24
+ const createAdminCruds = params => {
25
+ const {
26
+ storageOperations
27
+ } = params;
28
+ return new _ContextPlugin.ContextPlugin(async context => {
29
+ /**
30
+ * This should never happen in the actual project.
31
+ * It is to make sure that we load setup context before the CRUD init in our internal code.
32
+ */
33
+ if (!context.cms) {
34
+ console.log(`Missing initial "cms" on the context. Make sure that you set it up before creating Admin CRUDs.`);
35
+ return;
36
+ }
37
+
38
+ const getLocale = () => {
39
+ return context.i18n.getCurrentLocale();
40
+ };
41
+
42
+ const getIdentity = () => {
43
+ return context.security.getIdentity();
44
+ };
45
+
46
+ const getTenant = () => {
47
+ return context.tenancy.getCurrentTenant();
48
+ };
49
+
50
+ if (storageOperations.plugins && storageOperations.plugins.length > 0) {
51
+ context.plugins.register(storageOperations.plugins);
52
+ }
53
+
54
+ context.cms = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, context.cms), (0, _system.createSystemCrud)({
55
+ context,
56
+ getTenant,
57
+ getIdentity,
58
+ storageOperations
59
+ })), (0, _settings.createSettingsCrud)({
60
+ context,
61
+ getTenant,
62
+ getLocale,
63
+ storageOperations
64
+ })), (0, _contentModelGroup.createModelGroupsCrud)({
65
+ context,
66
+ getTenant,
67
+ getLocale,
68
+ getIdentity,
69
+ storageOperations
70
+ }));
71
+
72
+ if (!storageOperations.init) {
73
+ return;
74
+ }
75
+
76
+ await storageOperations.init(context.cms);
77
+ });
78
+ };
79
+
80
+ exports.createAdminCruds = createAdminCruds;
@@ -1,4 +1,10 @@
1
- import { ContextPlugin } from "@webiny/handler/types";
2
- import { CmsContext } from "../../types";
3
- declare const _default: ContextPlugin<CmsContext, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>, import("@webiny/handler/types").Context<Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>, Record<string, any>>>;
4
- export default _default;
1
+ import { CmsContext, HeadlessCmsStorageOperations, CmsSettingsContext } from "../../types";
2
+ import { Tenant } from "@webiny/api-tenancy/types";
3
+ import { I18NLocale } from "@webiny/api-i18n/types";
4
+ export interface Params {
5
+ getTenant: () => Tenant;
6
+ getLocale: () => I18NLocale;
7
+ storageOperations: HeadlessCmsStorageOperations;
8
+ context: CmsContext;
9
+ }
10
+ export declare const createSettingsCrud: (params: Params) => CmsSettingsContext;
@@ -5,14 +5,12 @@ 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.createSettingsCrud = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
12
  var utils = _interopRequireWildcard(require("../../utils"));
13
13
 
14
- var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
14
  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); }
17
15
 
18
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -21,86 +19,75 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
21
19
 
22
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
21
 
24
- var _default = {
25
- type: "context",
26
- name: "context-settings-crud",
27
- apply: async context => {
28
- /**
29
- * If cms is not defined on the context, do not continue, but log it.
30
- */
31
- if (!context.cms) {
32
- return;
33
- }
34
-
35
- const pluginType = "cms-settings-storage-operations-provider";
36
- const providerPlugins = context.plugins.byType(pluginType);
37
- const providerPlugin = providerPlugins[providerPlugins.length - 1];
38
-
39
- if (!providerPlugin) {
40
- throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
41
- type: pluginType
22
+ const createSettingsCrud = params => {
23
+ const {
24
+ storageOperations,
25
+ context,
26
+ getTenant,
27
+ getLocale
28
+ } = params;
29
+
30
+ const checkPermissions = () => {
31
+ return utils.checkPermissions(context, "cms.settings");
32
+ };
33
+
34
+ return {
35
+ getSettings: async () => {
36
+ await checkPermissions();
37
+ return await storageOperations.settings.get({
38
+ tenant: getTenant().id,
39
+ locale: getLocale().code
40
+ });
41
+ },
42
+ updateModelLastChange: async () => {
43
+ const original = await storageOperations.settings.get({
44
+ tenant: getTenant().id,
45
+ locale: getLocale().code
42
46
  });
43
- }
44
47
 
45
- const storageOperations = await providerPlugin.provide({
46
- context
47
- });
48
+ const settings = _objectSpread(_objectSpread({}, original || {}), {}, {
49
+ contentModelLastChange: new Date(),
50
+ tenant: getTenant().id,
51
+ locale: getLocale().code
52
+ });
48
53
 
49
- const checkPermissions = () => {
50
- return utils.checkPermissions(context, "cms.settings");
51
- };
54
+ if (!original) {
55
+ await storageOperations.settings.create({
56
+ settings
57
+ });
58
+ return;
59
+ }
52
60
 
53
- const settings = {
54
- noAuth: () => {
55
- return {
56
- get: async () => {
57
- return await storageOperations.get();
58
- }
59
- };
60
- },
61
- get: async () => {
62
- await checkPermissions();
63
- return await storageOperations.get();
64
- },
65
- updateContentModelLastChange: async () => {
66
- const data = {
67
- contentModelLastChange: new Date()
68
- };
69
- const settings = await storageOperations.get();
70
-
71
- if (!settings) {
72
- await storageOperations.create(data);
73
- return;
61
+ await storageOperations.settings.update({
62
+ original,
63
+ settings
64
+ });
65
+ },
66
+ getModelLastChange: async () => {
67
+ try {
68
+ const settings = await storageOperations.settings.get({
69
+ tenant: getTenant().id,
70
+ locale: getLocale().code
71
+ });
72
+
73
+ if (!settings || !settings.contentModelLastChange) {
74
+ return new Date();
74
75
  }
75
76
 
76
- await storageOperations.update(data);
77
- },
78
- getContentModelLastChange: async () => {
79
- try {
80
- const settings = await storageOperations.get();
81
-
82
- if (!settings || !settings.contentModelLastChange) {
83
- return new Date();
77
+ return settings.contentModelLastChange;
78
+ } catch (ex) {
79
+ console.log({
80
+ error: {
81
+ message: ex.message,
82
+ code: ex.code || "COULD_NOT_FETCH_CONTENT_MODEL_LAST_CHANGE",
83
+ data: ex
84
84
  }
85
-
86
- return settings.contentModelLastChange;
87
- } catch (ex) {
88
- console.log({
89
- error: {
90
- message: ex.message,
91
- code: ex.code || "COULD_NOT_FETCH_CONTENT_MODEL_LAST_CHANGE",
92
- data: ex
93
- }
94
- });
95
- }
96
-
97
- return new Date();
85
+ });
98
86
  }
99
- };
100
- context.cms = _objectSpread(_objectSpread({}, context.cms || {}), {}, {
101
- settings
102
- });
103
- }
87
+
88
+ return new Date();
89
+ }
90
+ };
104
91
  };
105
- exports.default = _default;
106
- //# sourceMappingURL=settings.crud.js.map
92
+
93
+ exports.createSettingsCrud = createSettingsCrud;
@@ -1,4 +1,10 @@
1
- import { ContextPlugin } from "@webiny/handler/plugins/ContextPlugin";
2
- import { CmsContext } from "../../types";
3
- declare const _default: ContextPlugin<CmsContext>;
4
- export default _default;
1
+ import { CmsContext, CmsSystemContext, HeadlessCmsStorageOperations } from "../../types";
2
+ import { Tenant } from "@webiny/api-tenancy/types";
3
+ import { SecurityIdentity } from "@webiny/api-security/types";
4
+ export interface Params {
5
+ getTenant: () => Tenant;
6
+ storageOperations: HeadlessCmsStorageOperations;
7
+ context: CmsContext;
8
+ getIdentity: () => SecurityIdentity;
9
+ }
10
+ export declare const createSystemCrud: (params: Params) => CmsSystemContext;