@webiny/api-headless-cms 0.0.0-unstable.de38392959 → 0.0.0-unstable.e0bfc55d5a

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 (806) hide show
  1. package/constants.d.ts +18 -6
  2. package/constants.js +29 -16
  3. package/constants.js.map +1 -1
  4. package/context.d.ts +1 -1
  5. package/context.js +61 -32
  6. package/context.js.map +1 -1
  7. package/crud/AccessControl/AccessControl.d.ts +98 -0
  8. package/crud/AccessControl/AccessControl.js +542 -0
  9. package/crud/AccessControl/AccessControl.js.map +1 -0
  10. package/crud/AccessControl/README.md +47 -0
  11. package/crud/AccessControl/groups-own.png +0 -0
  12. package/crud/AccessControl/models-own.png +0 -0
  13. package/crud/contentEntry/abstractions/IDeleteEntry.d.ts +4 -0
  14. package/crud/contentEntry/abstractions/IDeleteEntry.js +7 -0
  15. package/crud/contentEntry/abstractions/IDeleteEntry.js.map +1 -0
  16. package/crud/contentEntry/abstractions/IDeleteEntryOperation.d.ts +4 -0
  17. package/crud/contentEntry/abstractions/IDeleteEntryOperation.js +7 -0
  18. package/crud/contentEntry/abstractions/IDeleteEntryOperation.js.map +1 -0
  19. package/crud/contentEntry/abstractions/IGetEntriesByIds.d.ts +4 -0
  20. package/crud/contentEntry/abstractions/IGetEntriesByIds.js +7 -0
  21. package/crud/contentEntry/abstractions/IGetEntriesByIds.js.map +1 -0
  22. package/crud/contentEntry/abstractions/IGetEntry.d.ts +4 -0
  23. package/crud/contentEntry/abstractions/IGetEntry.js +7 -0
  24. package/crud/contentEntry/abstractions/IGetEntry.js.map +1 -0
  25. package/crud/contentEntry/abstractions/IGetLatestEntriesByIds.d.ts +4 -0
  26. package/crud/contentEntry/abstractions/IGetLatestEntriesByIds.js +7 -0
  27. package/crud/contentEntry/abstractions/IGetLatestEntriesByIds.js.map +1 -0
  28. package/crud/contentEntry/abstractions/IGetLatestRevisionByEntryId.d.ts +4 -0
  29. package/crud/contentEntry/abstractions/IGetLatestRevisionByEntryId.js +7 -0
  30. package/crud/contentEntry/abstractions/IGetLatestRevisionByEntryId.js.map +1 -0
  31. package/crud/contentEntry/abstractions/IGetPreviousRevisionByEntryId.d.ts +4 -0
  32. package/crud/contentEntry/abstractions/IGetPreviousRevisionByEntryId.js +7 -0
  33. package/crud/contentEntry/abstractions/IGetPreviousRevisionByEntryId.js.map +1 -0
  34. package/crud/contentEntry/abstractions/IGetPublishedEntriesByIds.d.ts +4 -0
  35. package/crud/contentEntry/abstractions/IGetPublishedEntriesByIds.js +7 -0
  36. package/crud/contentEntry/abstractions/IGetPublishedEntriesByIds.js.map +1 -0
  37. package/crud/contentEntry/abstractions/IGetPublishedRevisionByEntryId.d.ts +4 -0
  38. package/crud/contentEntry/abstractions/IGetPublishedRevisionByEntryId.js +7 -0
  39. package/crud/contentEntry/abstractions/IGetPublishedRevisionByEntryId.js.map +1 -0
  40. package/crud/contentEntry/abstractions/IGetRevisionById.d.ts +4 -0
  41. package/crud/contentEntry/abstractions/IGetRevisionById.js +7 -0
  42. package/crud/contentEntry/abstractions/IGetRevisionById.js.map +1 -0
  43. package/crud/contentEntry/abstractions/IGetRevisionsByEntryId.d.ts +4 -0
  44. package/crud/contentEntry/abstractions/IGetRevisionsByEntryId.js +7 -0
  45. package/crud/contentEntry/abstractions/IGetRevisionsByEntryId.js.map +1 -0
  46. package/crud/contentEntry/abstractions/IListEntries.d.ts +4 -0
  47. package/crud/contentEntry/abstractions/IListEntries.js +7 -0
  48. package/crud/contentEntry/abstractions/IListEntries.js.map +1 -0
  49. package/crud/contentEntry/abstractions/IListEntriesOperation.d.ts +4 -0
  50. package/crud/contentEntry/abstractions/IListEntriesOperation.js +7 -0
  51. package/crud/contentEntry/abstractions/IListEntriesOperation.js.map +1 -0
  52. package/crud/contentEntry/abstractions/IMoveEntryToBinOperation.d.ts +4 -0
  53. package/crud/contentEntry/abstractions/IMoveEntryToBinOperation.js +7 -0
  54. package/crud/contentEntry/abstractions/IMoveEntryToBinOperation.js.map +1 -0
  55. package/crud/contentEntry/abstractions/IRestoreEntryFromBin.d.ts +4 -0
  56. package/crud/contentEntry/abstractions/IRestoreEntryFromBin.js +7 -0
  57. package/crud/contentEntry/abstractions/IRestoreEntryFromBin.js.map +1 -0
  58. package/crud/contentEntry/abstractions/IRestoreEntryFromBinOperation.d.ts +4 -0
  59. package/crud/contentEntry/abstractions/IRestoreEntryFromBinOperation.js +7 -0
  60. package/crud/contentEntry/abstractions/IRestoreEntryFromBinOperation.js.map +1 -0
  61. package/crud/contentEntry/abstractions/index.d.ts +16 -0
  62. package/crud/contentEntry/abstractions/index.js +183 -0
  63. package/crud/contentEntry/abstractions/index.js.map +1 -0
  64. package/crud/contentEntry/afterDelete.d.ts +6 -2
  65. package/crud/contentEntry/afterDelete.js +15 -1
  66. package/crud/contentEntry/afterDelete.js.map +1 -1
  67. package/crud/contentEntry/beforeCreate.d.ts +2 -2
  68. package/crud/contentEntry/beforeCreate.js.map +1 -1
  69. package/crud/contentEntry/beforeUpdate.d.ts +2 -2
  70. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  71. package/crud/contentEntry/entryDataFactories/createEntryData.d.ts +8 -8
  72. package/crud/contentEntry/entryDataFactories/createEntryData.js +30 -4
  73. package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -1
  74. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.d.ts +8 -6
  75. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js +54 -11
  76. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -1
  77. package/crud/contentEntry/entryDataFactories/createPublishEntryData.d.ts +5 -5
  78. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js +22 -20
  79. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -1
  80. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.d.ts +3 -3
  81. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js +18 -16
  82. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -1
  83. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.d.ts +5 -5
  84. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js +10 -8
  85. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -1
  86. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.d.ts +5 -5
  87. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js +8 -0
  88. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -1
  89. package/crud/contentEntry/entryDataFactories/index.js.map +1 -1
  90. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.d.ts +1 -1
  91. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js.map +1 -1
  92. package/crud/contentEntry/entryDataFactories/statuses.js +3 -6
  93. package/crud/contentEntry/entryDataFactories/statuses.js.map +1 -1
  94. package/crud/contentEntry/entryDataValidation.d.ts +2 -2
  95. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  96. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  97. package/crud/contentEntry/markLockedFields.js.map +1 -1
  98. package/crud/contentEntry/referenceFieldsMapping.d.ts +1 -1
  99. package/crud/contentEntry/referenceFieldsMapping.js +10 -10
  100. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  101. package/crud/contentEntry/searchableFields.d.ts +2 -2
  102. package/crud/contentEntry/searchableFields.js.map +1 -1
  103. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntry.d.ts +10 -0
  104. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntry.js +58 -0
  105. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntry.js.map +1 -0
  106. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperation.d.ts +7 -0
  107. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperation.js +17 -0
  108. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperation.js.map +1 -0
  109. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperationWithEvents.d.ts +9 -0
  110. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperationWithEvents.js +45 -0
  111. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperationWithEvents.js.map +1 -0
  112. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntrySecure.d.ts +9 -0
  113. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntrySecure.js +22 -0
  114. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntrySecure.js.map +1 -0
  115. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBin.d.ts +10 -0
  116. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBin.js +33 -0
  117. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBin.js.map +1 -0
  118. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperation.d.ts +7 -0
  119. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperation.js +17 -0
  120. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperation.js.map +1 -0
  121. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperationWithEvents.d.ts +9 -0
  122. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperationWithEvents.js +45 -0
  123. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperationWithEvents.js.map +1 -0
  124. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryDelete.d.ts +6 -0
  125. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryDelete.js +21 -0
  126. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryDelete.js.map +1 -0
  127. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.d.ts +9 -0
  128. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.js +54 -0
  129. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.js.map +1 -0
  130. package/crud/contentEntry/useCases/DeleteEntry/index.d.ts +28 -0
  131. package/crud/contentEntry/useCases/DeleteEntry/index.js +42 -0
  132. package/crud/contentEntry/useCases/DeleteEntry/index.js.map +1 -0
  133. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIds.d.ts +9 -0
  134. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIds.js +21 -0
  135. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIds.js.map +1 -0
  136. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsNotDeleted.d.ts +7 -0
  137. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsNotDeleted.js +18 -0
  138. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsNotDeleted.js.map +1 -0
  139. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsSecure.d.ts +9 -0
  140. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsSecure.js +28 -0
  141. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsSecure.js.map +1 -0
  142. package/crud/contentEntry/useCases/GetEntriesByIds/index.d.ts +13 -0
  143. package/crud/contentEntry/useCases/GetEntriesByIds/index.js +20 -0
  144. package/crud/contentEntry/useCases/GetEntriesByIds/index.js.map +1 -0
  145. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIds.d.ts +9 -0
  146. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIds.js +21 -0
  147. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIds.js.map +1 -0
  148. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsNotDeleted.d.ts +7 -0
  149. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsNotDeleted.js +18 -0
  150. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsNotDeleted.js.map +1 -0
  151. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsSecure.d.ts +9 -0
  152. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsSecure.js +28 -0
  153. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsSecure.js.map +1 -0
  154. package/crud/contentEntry/useCases/GetLatestEntriesByIds/index.d.ts +13 -0
  155. package/crud/contentEntry/useCases/GetLatestEntriesByIds/index.js +20 -0
  156. package/crud/contentEntry/useCases/GetLatestEntriesByIds/index.js.map +1 -0
  157. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryId.d.ts +9 -0
  158. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryId.js +22 -0
  159. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryId.js.map +1 -0
  160. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdDeleted.d.ts +7 -0
  161. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdDeleted.js +21 -0
  162. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdDeleted.js.map +1 -0
  163. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdNotDeleted.d.ts +7 -0
  164. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdNotDeleted.js +21 -0
  165. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdNotDeleted.js.map +1 -0
  166. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/index.d.ts +15 -0
  167. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/index.js +22 -0
  168. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/index.js.map +1 -0
  169. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryId.d.ts +9 -0
  170. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryId.js +22 -0
  171. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryId.js.map +1 -0
  172. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdNotDeleted.d.ts +7 -0
  173. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdNotDeleted.js +21 -0
  174. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdNotDeleted.js.map +1 -0
  175. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/index.d.ts +11 -0
  176. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/index.js +18 -0
  177. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/index.js.map +1 -0
  178. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIds.d.ts +9 -0
  179. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIds.js +21 -0
  180. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIds.js.map +1 -0
  181. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsNotDeleted.d.ts +7 -0
  182. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsNotDeleted.js +18 -0
  183. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsNotDeleted.js.map +1 -0
  184. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsSecure.d.ts +9 -0
  185. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsSecure.js +28 -0
  186. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsSecure.js.map +1 -0
  187. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/index.d.ts +13 -0
  188. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/index.js +20 -0
  189. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/index.js.map +1 -0
  190. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryId.d.ts +9 -0
  191. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryId.js +22 -0
  192. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryId.js.map +1 -0
  193. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdNotDeleted.d.ts +7 -0
  194. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdNotDeleted.js +21 -0
  195. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdNotDeleted.js.map +1 -0
  196. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/index.d.ts +11 -0
  197. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/index.js +18 -0
  198. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/index.js.map +1 -0
  199. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionById.d.ts +9 -0
  200. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionById.js +22 -0
  201. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionById.js.map +1 -0
  202. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionByIdNotDeleted.d.ts +7 -0
  203. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionByIdNotDeleted.js +21 -0
  204. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionByIdNotDeleted.js.map +1 -0
  205. package/crud/contentEntry/useCases/GetRevisionById/index.d.ts +11 -0
  206. package/crud/contentEntry/useCases/GetRevisionById/index.js +18 -0
  207. package/crud/contentEntry/useCases/GetRevisionById/index.js.map +1 -0
  208. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryId.d.ts +9 -0
  209. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryId.js +21 -0
  210. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryId.js.map +1 -0
  211. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryIdNotDeleted.d.ts +7 -0
  212. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryIdNotDeleted.js +18 -0
  213. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryIdNotDeleted.js.map +1 -0
  214. package/crud/contentEntry/useCases/GetRevisionsByEntryId/index.d.ts +13 -0
  215. package/crud/contentEntry/useCases/GetRevisionsByEntryId/index.js +18 -0
  216. package/crud/contentEntry/useCases/GetRevisionsByEntryId/index.js.map +1 -0
  217. package/crud/contentEntry/useCases/ListEntries/GetEntry.d.ts +7 -0
  218. package/crud/contentEntry/useCases/ListEntries/GetEntry.js +29 -0
  219. package/crud/contentEntry/useCases/ListEntries/GetEntry.js.map +1 -0
  220. package/crud/contentEntry/useCases/ListEntries/GetEntrySecure.d.ts +11 -0
  221. package/crud/contentEntry/useCases/ListEntries/GetEntrySecure.js +38 -0
  222. package/crud/contentEntry/useCases/ListEntries/GetEntrySecure.js.map +1 -0
  223. package/crud/contentEntry/useCases/ListEntries/ListEntries.d.ts +7 -0
  224. package/crud/contentEntry/useCases/ListEntries/ListEntries.js +62 -0
  225. package/crud/contentEntry/useCases/ListEntries/ListEntries.js.map +1 -0
  226. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperation.d.ts +14 -0
  227. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperation.js +24 -0
  228. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperation.js.map +1 -0
  229. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationDeleted.d.ts +7 -0
  230. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationDeleted.js +24 -0
  231. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationDeleted.js.map +1 -0
  232. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationLatest.d.ts +7 -0
  233. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationLatest.js +25 -0
  234. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationLatest.js.map +1 -0
  235. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationNotDeleted.d.ts +7 -0
  236. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationNotDeleted.js +24 -0
  237. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationNotDeleted.js.map +1 -0
  238. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationPublished.d.ts +7 -0
  239. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationPublished.js +24 -0
  240. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationPublished.js.map +1 -0
  241. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithEvents.d.ts +9 -0
  242. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithEvents.js +22 -0
  243. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithEvents.js.map +1 -0
  244. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSearchableFields.d.ts +8 -0
  245. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSearchableFields.js +27 -0
  246. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSearchableFields.js.map +1 -0
  247. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSort.d.ts +8 -0
  248. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSort.js +26 -0
  249. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSort.js.map +1 -0
  250. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithStatusCheck.d.ts +7 -0
  251. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithStatusCheck.js +36 -0
  252. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithStatusCheck.js.map +1 -0
  253. package/crud/contentEntry/useCases/ListEntries/ListEntriesSecure.d.ts +11 -0
  254. package/crud/contentEntry/useCases/ListEntries/ListEntriesSecure.js +41 -0
  255. package/crud/contentEntry/useCases/ListEntries/ListEntriesSecure.js.map +1 -0
  256. package/crud/contentEntry/useCases/ListEntries/index.d.ts +26 -0
  257. package/crud/contentEntry/useCases/ListEntries/index.js +61 -0
  258. package/crud/contentEntry/useCases/ListEntries/index.js.map +1 -0
  259. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBin.d.ts +10 -0
  260. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBin.js +37 -0
  261. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBin.js.map +1 -0
  262. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperation.d.ts +9 -0
  263. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperation.js +19 -0
  264. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperation.js.map +1 -0
  265. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperationWithEvents.d.ts +9 -0
  266. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperationWithEvents.js +42 -0
  267. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperationWithEvents.js.map +1 -0
  268. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinSecure.d.ts +9 -0
  269. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinSecure.js +22 -0
  270. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinSecure.js.map +1 -0
  271. package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.d.ts +9 -0
  272. package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.js +53 -0
  273. package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.js.map +1 -0
  274. package/crud/contentEntry/useCases/RestoreEntryFromBin/index.d.ts +25 -0
  275. package/crud/contentEntry/useCases/RestoreEntryFromBin/index.js +24 -0
  276. package/crud/contentEntry/useCases/RestoreEntryFromBin/index.js.map +1 -0
  277. package/crud/contentEntry/useCases/index.d.ts +11 -0
  278. package/crud/contentEntry/useCases/index.js +128 -0
  279. package/crud/contentEntry/useCases/index.js.map +1 -0
  280. package/crud/contentEntry.crud.d.ts +6 -8
  281. package/crud/contentEntry.crud.js +304 -357
  282. package/crud/contentEntry.crud.js.map +1 -1
  283. package/crud/contentModel/beforeCreate.d.ts +2 -2
  284. package/crud/contentModel/beforeCreate.js.map +1 -1
  285. package/crud/contentModel/beforeDelete.d.ts +3 -5
  286. package/crud/contentModel/beforeDelete.js +49 -15
  287. package/crud/contentModel/beforeDelete.js.map +1 -1
  288. package/crud/contentModel/beforeUpdate.d.ts +2 -2
  289. package/crud/contentModel/beforeUpdate.js.map +1 -1
  290. package/crud/contentModel/compatibility/modelApiName.d.ts +1 -1
  291. package/crud/contentModel/compatibility/modelApiName.js.map +1 -1
  292. package/crud/contentModel/contentModelManagerFactory.d.ts +2 -2
  293. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  294. package/crud/contentModel/createFieldStorageId.d.ts +1 -1
  295. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  296. package/crud/contentModel/defaultFields.d.ts +1 -1
  297. package/crud/contentModel/defaultFields.js.map +1 -1
  298. package/crud/contentModel/ensureTypeTag.d.ts +1 -1
  299. package/crud/contentModel/ensureTypeTag.js.map +1 -1
  300. package/crud/contentModel/fields/descriptionField.d.ts +6 -2
  301. package/crud/contentModel/fields/descriptionField.js +14 -28
  302. package/crud/contentModel/fields/descriptionField.js.map +1 -1
  303. package/crud/contentModel/fields/getApplicableFieldById.d.ts +2 -0
  304. package/crud/contentModel/fields/getApplicableFieldById.js +15 -0
  305. package/crud/contentModel/fields/getApplicableFieldById.js.map +1 -0
  306. package/crud/contentModel/fields/imageField.d.ts +2 -2
  307. package/crud/contentModel/fields/imageField.js +9 -28
  308. package/crud/contentModel/fields/imageField.js.map +1 -1
  309. package/crud/contentModel/fields/titleField.d.ts +6 -2
  310. package/crud/contentModel/fields/titleField.js +14 -43
  311. package/crud/contentModel/fields/titleField.js.map +1 -1
  312. package/crud/contentModel/listModelsFromDatabase.d.ts +3 -3
  313. package/crud/contentModel/listModelsFromDatabase.js.map +1 -1
  314. package/crud/contentModel/validate/endingAllowed.d.ts +1 -1
  315. package/crud/contentModel/validate/endingAllowed.js.map +1 -1
  316. package/crud/contentModel/validate/isModelEndingAllowed.js +1 -2
  317. package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -1
  318. package/crud/contentModel/validate/modelId.d.ts +1 -1
  319. package/crud/contentModel/validate/modelId.js.map +1 -1
  320. package/crud/contentModel/validate/pluralApiName.d.ts +1 -1
  321. package/crud/contentModel/validate/pluralApiName.js.map +1 -1
  322. package/crud/contentModel/validate/singularApiName.d.ts +1 -1
  323. package/crud/contentModel/validate/singularApiName.js.map +1 -1
  324. package/crud/contentModel/validateModel.d.ts +1 -1
  325. package/crud/contentModel/validateModel.js.map +1 -1
  326. package/crud/contentModel/validateModelFields.d.ts +1 -1
  327. package/crud/contentModel/validateModelFields.js +1 -1
  328. package/crud/contentModel/validateModelFields.js.map +1 -1
  329. package/crud/contentModel/validateStorageId.d.ts +1 -0
  330. package/crud/contentModel/validateStorageId.js +19 -0
  331. package/crud/contentModel/validateStorageId.js.map +1 -0
  332. package/crud/contentModel/validation.d.ts +197 -176
  333. package/crud/contentModel/validation.js +5 -5
  334. package/crud/contentModel/validation.js.map +1 -1
  335. package/crud/contentModel.crud.d.ts +6 -6
  336. package/crud/contentModel.crud.js +76 -37
  337. package/crud/contentModel.crud.js.map +1 -1
  338. package/crud/contentModelGroup/beforeCreate.d.ts +3 -3
  339. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  340. package/crud/contentModelGroup/beforeDelete.d.ts +3 -3
  341. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  342. package/crud/contentModelGroup/beforeUpdate.d.ts +3 -3
  343. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  344. package/crud/contentModelGroup/listGroupsFromDatabase.d.ts +1 -1
  345. package/crud/contentModelGroup/listGroupsFromDatabase.js.map +1 -1
  346. package/crud/contentModelGroup/validation.d.ts +1 -1
  347. package/crud/contentModelGroup/validation.js.map +1 -1
  348. package/crud/contentModelGroup.crud.d.ts +6 -6
  349. package/crud/contentModelGroup.crud.js +17 -28
  350. package/crud/contentModelGroup.crud.js.map +1 -1
  351. package/crud/system.crud.d.ts +4 -4
  352. package/crud/system.crud.js +10 -0
  353. package/crud/system.crud.js.map +1 -1
  354. package/export/crud/exporting.d.ts +2 -2
  355. package/export/crud/exporting.js.map +1 -1
  356. package/export/crud/importing.d.ts +2 -2
  357. package/export/crud/importing.js.map +1 -1
  358. package/export/crud/imports/importData.d.ts +2 -2
  359. package/export/crud/imports/importData.js.map +1 -1
  360. package/export/crud/imports/importGroups.d.ts +2 -2
  361. package/export/crud/imports/importGroups.js.map +1 -1
  362. package/export/crud/imports/importModels.d.ts +2 -2
  363. package/export/crud/imports/importModels.js.map +1 -1
  364. package/export/crud/imports/validateGroups.d.ts +2 -2
  365. package/export/crud/imports/validateGroups.js.map +1 -1
  366. package/export/crud/imports/validateInput.d.ts +2 -2
  367. package/export/crud/imports/validateInput.js.map +1 -1
  368. package/export/crud/imports/validateModels.d.ts +2 -2
  369. package/export/crud/imports/validateModels.js.map +1 -1
  370. package/export/crud/index.d.ts +1 -1
  371. package/export/crud/index.js.map +1 -1
  372. package/export/crud/sanitize.d.ts +3 -3
  373. package/export/crud/sanitize.js +2 -1
  374. package/export/crud/sanitize.js.map +1 -1
  375. package/export/graphql/index.d.ts +1 -1
  376. package/export/graphql/index.js +1 -1
  377. package/export/graphql/index.js.map +1 -1
  378. package/export/index.js.map +1 -1
  379. package/export/types.d.ts +5 -5
  380. package/export/types.js +1 -2
  381. package/export/types.js.map +1 -1
  382. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +5 -3
  383. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  384. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +3 -2
  385. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +23 -65
  386. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  387. package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +3 -2
  388. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +2 -2
  389. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  390. package/fieldConverters/index.d.ts +3 -0
  391. package/fieldConverters/index.js +4 -0
  392. package/fieldConverters/index.js.map +1 -1
  393. package/graphql/buildSchemaPlugins.d.ts +3 -3
  394. package/graphql/buildSchemaPlugins.js.map +1 -1
  395. package/graphql/checkEndpointAccess.d.ts +1 -1
  396. package/graphql/checkEndpointAccess.js.map +1 -1
  397. package/graphql/createExecutableSchema.d.ts +2 -2
  398. package/graphql/createExecutableSchema.js +14 -7
  399. package/graphql/createExecutableSchema.js.map +1 -1
  400. package/graphql/createRequestBody.d.ts +1 -1
  401. package/graphql/createRequestBody.js.map +1 -1
  402. package/graphql/formatErrorPayload.js.map +1 -1
  403. package/graphql/generateSchema.d.ts +2 -2
  404. package/graphql/generateSchema.js +6 -1
  405. package/graphql/generateSchema.js.map +1 -1
  406. package/graphql/getSchema/generateCacheId.d.ts +10 -0
  407. package/graphql/getSchema/generateCacheId.js +17 -0
  408. package/graphql/getSchema/generateCacheId.js.map +1 -0
  409. package/graphql/getSchema/generateCacheKey.d.ts +10 -0
  410. package/graphql/getSchema/generateCacheKey.js +34 -0
  411. package/graphql/getSchema/generateCacheKey.js.map +1 -0
  412. package/graphql/getSchema.d.ts +4 -4
  413. package/graphql/getSchema.js +13 -50
  414. package/graphql/getSchema.js.map +1 -1
  415. package/graphql/graphQLHandlerFactory.d.ts +2 -2
  416. package/graphql/graphQLHandlerFactory.js.map +1 -1
  417. package/graphql/handleRequest.d.ts +2 -2
  418. package/graphql/handleRequest.js +8 -1
  419. package/graphql/handleRequest.js.map +1 -1
  420. package/graphql/index.d.ts +4 -3
  421. package/graphql/index.js +1 -1
  422. package/graphql/index.js.map +1 -1
  423. package/graphql/scalars/RevisionId.d.ts +2 -0
  424. package/graphql/scalars/RevisionId.js +26 -0
  425. package/graphql/scalars/RevisionId.js.map +1 -0
  426. package/graphql/scalars/RevisionIdScalarPlugin.d.ts +2 -0
  427. package/graphql/scalars/RevisionIdScalarPlugin.js +18 -0
  428. package/graphql/scalars/RevisionIdScalarPlugin.js.map +1 -0
  429. package/graphql/schema/baseContentSchema.d.ts +3 -3
  430. package/graphql/schema/baseContentSchema.js +1 -7
  431. package/graphql/schema/baseContentSchema.js.map +1 -1
  432. package/graphql/schema/baseSchema.js +12 -5
  433. package/graphql/schema/baseSchema.js.map +1 -1
  434. package/graphql/schema/contentEntries.d.ts +3 -3
  435. package/graphql/schema/contentEntries.js +3 -4
  436. package/graphql/schema/contentEntries.js.map +1 -1
  437. package/graphql/schema/contentModelGroups.d.ts +3 -3
  438. package/graphql/schema/contentModelGroups.js +1 -1
  439. package/graphql/schema/contentModelGroups.js.map +1 -1
  440. package/graphql/schema/contentModels.d.ts +4 -5
  441. package/graphql/schema/contentModels.js +21 -5
  442. package/graphql/schema/contentModels.js.map +1 -1
  443. package/graphql/schema/createFieldResolvers.d.ts +2 -2
  444. package/graphql/schema/createFieldResolvers.js +1 -3
  445. package/graphql/schema/createFieldResolvers.js.map +1 -1
  446. package/graphql/schema/createFieldTypePluginRecords.d.ts +2 -2
  447. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -1
  448. package/graphql/schema/createManageResolvers.d.ts +1 -2
  449. package/graphql/schema/createManageResolvers.js +24 -49
  450. package/graphql/schema/createManageResolvers.js.map +1 -1
  451. package/graphql/schema/createManageSDL.d.ts +2 -2
  452. package/graphql/schema/createManageSDL.js +14 -5
  453. package/graphql/schema/createManageSDL.js.map +1 -1
  454. package/graphql/schema/createPreviewResolvers.d.ts +1 -2
  455. package/graphql/schema/createPreviewResolvers.js +4 -7
  456. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  457. package/graphql/schema/createReadResolvers.d.ts +1 -2
  458. package/graphql/schema/createReadResolvers.js +4 -7
  459. package/graphql/schema/createReadResolvers.js.map +1 -1
  460. package/graphql/schema/createReadSDL.d.ts +2 -2
  461. package/graphql/schema/createReadSDL.js +6 -7
  462. package/graphql/schema/createReadSDL.js.map +1 -1
  463. package/graphql/schema/createSingularResolvers.d.ts +12 -0
  464. package/graphql/schema/createSingularResolvers.js +56 -0
  465. package/graphql/schema/createSingularResolvers.js.map +1 -0
  466. package/graphql/schema/createSingularSDL.d.ts +12 -0
  467. package/graphql/schema/createSingularSDL.js +95 -0
  468. package/graphql/schema/createSingularSDL.js.map +1 -0
  469. package/graphql/schema/resolvers/manage/normalizeGraphQlInput.d.ts +7 -0
  470. package/graphql/schema/resolvers/manage/normalizeGraphQlInput.js +59 -0
  471. package/graphql/schema/resolvers/manage/normalizeGraphQlInput.js.map +1 -0
  472. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +2 -2
  473. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  474. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +2 -2
  475. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  476. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -2
  477. package/graphql/schema/resolvers/manage/resolveDelete.js +2 -1
  478. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  479. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +2 -2
  480. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
  481. package/graphql/schema/resolvers/manage/resolveGet.d.ts +2 -2
  482. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  483. package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +2 -2
  484. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  485. package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +2 -2
  486. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  487. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +2 -2
  488. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
  489. package/graphql/schema/resolvers/manage/resolveList.d.ts +2 -2
  490. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  491. package/graphql/schema/resolvers/manage/resolveListDeleted.d.ts +4 -0
  492. package/graphql/schema/resolvers/manage/resolveListDeleted.js +20 -0
  493. package/graphql/schema/resolvers/manage/resolveListDeleted.js.map +1 -0
  494. package/graphql/schema/resolvers/manage/resolveMove.d.ts +2 -2
  495. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
  496. package/graphql/schema/resolvers/manage/resolvePublish.d.ts +2 -2
  497. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  498. package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +2 -2
  499. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  500. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.d.ts +7 -0
  501. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js +20 -0
  502. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js.map +1 -0
  503. package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +2 -2
  504. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  505. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +2 -2
  506. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  507. package/graphql/schema/resolvers/manage/resolveValidate.d.ts +2 -2
  508. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -1
  509. package/graphql/schema/resolvers/preview/resolveGet.d.ts +2 -2
  510. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  511. package/graphql/schema/resolvers/preview/resolveList.d.ts +2 -2
  512. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  513. package/graphql/schema/resolvers/read/resolveGet.d.ts +2 -2
  514. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  515. package/graphql/schema/resolvers/read/resolveList.d.ts +2 -2
  516. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  517. package/graphql/schema/resolvers/singular/resolveGet.d.ts +7 -0
  518. package/graphql/schema/resolvers/singular/resolveGet.js +21 -0
  519. package/graphql/schema/resolvers/singular/resolveGet.js.map +1 -0
  520. package/graphql/schema/resolvers/singular/resolveUpdate.d.ts +8 -0
  521. package/graphql/schema/resolvers/singular/resolveUpdate.js +21 -0
  522. package/graphql/schema/resolvers/singular/resolveUpdate.js.map +1 -0
  523. package/graphql/schema/schemaPlugins.d.ts +3 -3
  524. package/graphql/schema/schemaPlugins.js +32 -11
  525. package/graphql/schema/schemaPlugins.js.map +1 -1
  526. package/graphql/system.d.ts +1 -1
  527. package/graphql/system.js +2 -1
  528. package/graphql/system.js.map +1 -1
  529. package/graphqlFields/boolean.d.ts +1 -1
  530. package/graphqlFields/boolean.js.map +1 -1
  531. package/graphqlFields/datetime.d.ts +1 -1
  532. package/graphqlFields/datetime.js.map +1 -1
  533. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  534. package/graphqlFields/dynamicZone/dynamicZoneField.js +62 -8
  535. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  536. package/graphqlFields/dynamicZone/index.d.ts +0 -1
  537. package/graphqlFields/dynamicZone/index.js +0 -7
  538. package/graphqlFields/dynamicZone/index.js.map +1 -1
  539. package/graphqlFields/file.d.ts +1 -1
  540. package/graphqlFields/file.js.map +1 -1
  541. package/graphqlFields/helpers.d.ts +1 -1
  542. package/graphqlFields/helpers.js.map +1 -1
  543. package/graphqlFields/index.d.ts +1 -1
  544. package/graphqlFields/index.js +2 -1
  545. package/graphqlFields/index.js.map +1 -1
  546. package/graphqlFields/json.d.ts +1 -1
  547. package/graphqlFields/json.js.map +1 -1
  548. package/graphqlFields/longText.d.ts +1 -1
  549. package/graphqlFields/longText.js.map +1 -1
  550. package/graphqlFields/number.d.ts +1 -1
  551. package/graphqlFields/number.js.map +1 -1
  552. package/graphqlFields/object.d.ts +2 -2
  553. package/graphqlFields/object.js +14 -0
  554. package/graphqlFields/object.js.map +1 -1
  555. package/graphqlFields/ref.d.ts +1 -1
  556. package/graphqlFields/ref.js +1 -1
  557. package/graphqlFields/ref.js.map +1 -1
  558. package/graphqlFields/richText/RichTextPluginsProcessor.d.ts +2 -2
  559. package/graphqlFields/richText/RichTextPluginsProcessor.js.map +1 -1
  560. package/graphqlFields/richText/richTextResolver.d.ts +2 -2
  561. package/graphqlFields/richText/richTextResolver.js +4 -19
  562. package/graphqlFields/richText/richTextResolver.js.map +1 -1
  563. package/graphqlFields/richText.d.ts +1 -1
  564. package/graphqlFields/richText.js.map +1 -1
  565. package/graphqlFields/searchableJson.d.ts +2 -0
  566. package/graphqlFields/searchableJson.js +60 -0
  567. package/graphqlFields/searchableJson.js.map +1 -0
  568. package/graphqlFields/text.d.ts +1 -1
  569. package/graphqlFields/text.js.map +1 -1
  570. package/htmlRenderer/LexicalRenderer.d.ts +1 -1
  571. package/htmlRenderer/LexicalRenderer.js.map +1 -1
  572. package/htmlRenderer/createLexicalHTMLRenderer.js +1 -1
  573. package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -1
  574. package/index.d.ts +13 -7
  575. package/index.js +67 -7
  576. package/index.js.map +1 -1
  577. package/modelManager/DefaultCmsModelManager.d.ts +11 -10
  578. package/modelManager/DefaultCmsModelManager.js +16 -13
  579. package/modelManager/DefaultCmsModelManager.js.map +1 -1
  580. package/modelManager/SingletonModelManager.d.ts +12 -0
  581. package/modelManager/SingletonModelManager.js +48 -0
  582. package/modelManager/SingletonModelManager.js.map +1 -0
  583. package/modelManager/index.d.ts +2 -1
  584. package/modelManager/index.js +16 -1
  585. package/modelManager/index.js.map +1 -1
  586. package/package.json +37 -38
  587. package/parameters/context.js.map +1 -1
  588. package/parameters/header.js.map +1 -1
  589. package/parameters/index.js.map +1 -1
  590. package/parameters/manual.d.ts +2 -1
  591. package/parameters/manual.js.map +1 -1
  592. package/parameters/path.js.map +1 -1
  593. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +9 -0
  594. package/plugins/{CmsGraphQLSchemaPlugin.js → CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js} +5 -1
  595. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -0
  596. package/plugins/CmsGraphQLSchemaPlugin/index.d.ts +1 -0
  597. package/plugins/CmsGraphQLSchemaPlugin/index.js +18 -0
  598. package/plugins/CmsGraphQLSchemaPlugin/index.js.map +1 -0
  599. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +1 -1
  600. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
  601. package/plugins/CmsGroupPlugin.d.ts +9 -1
  602. package/plugins/CmsGroupPlugin.js +17 -1
  603. package/plugins/CmsGroupPlugin.js.map +1 -1
  604. package/plugins/CmsModelFieldConverterPlugin.d.ts +5 -2
  605. package/plugins/CmsModelFieldConverterPlugin.js +4 -0
  606. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  607. package/plugins/CmsModelPlugin.d.ts +30 -10
  608. package/plugins/CmsModelPlugin.js +101 -19
  609. package/plugins/CmsModelPlugin.js.map +1 -1
  610. package/plugins/CmsParametersPlugin.d.ts +3 -3
  611. package/plugins/CmsParametersPlugin.js.map +1 -1
  612. package/plugins/CmsRichTextRendererPlugin.d.ts +6 -6
  613. package/plugins/CmsRichTextRendererPlugin.js.map +1 -1
  614. package/plugins/StorageOperationsCmsModelPlugin.d.ts +1 -1
  615. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -1
  616. package/plugins/StorageTransformPlugin.d.ts +6 -2
  617. package/plugins/StorageTransformPlugin.js +9 -1
  618. package/plugins/StorageTransformPlugin.js.map +1 -1
  619. package/plugins/index.js.map +1 -1
  620. package/storage/date.d.ts +3 -0
  621. package/storage/date.js +119 -0
  622. package/storage/date.js.map +1 -0
  623. package/storage/default.js.map +1 -1
  624. package/storage/dynamicZone.d.ts +2 -0
  625. package/storage/dynamicZone.js +157 -0
  626. package/storage/dynamicZone.js.map +1 -0
  627. package/storage/index.js +7 -1
  628. package/storage/index.js.map +1 -1
  629. package/storage/json.js +34 -5
  630. package/storage/json.js.map +1 -1
  631. package/storage/object.js +16 -12
  632. package/storage/object.js.map +1 -1
  633. package/types/context.d.ts +146 -0
  634. package/types/context.js +7 -0
  635. package/types/context.js.map +1 -0
  636. package/types/fields/dynamicZoneField.d.ts +23 -0
  637. package/types/fields/dynamicZoneField.js +7 -0
  638. package/types/fields/dynamicZoneField.js.map +1 -0
  639. package/types/fields/objectField.d.ts +13 -0
  640. package/types/fields/objectField.js +7 -0
  641. package/types/fields/objectField.js.map +1 -0
  642. package/types/identity.d.ts +19 -0
  643. package/types/identity.js +7 -0
  644. package/types/identity.js.map +1 -0
  645. package/types/index.d.ts +10 -0
  646. package/types/index.js +117 -0
  647. package/types/index.js.map +1 -0
  648. package/types/model.d.ts +199 -0
  649. package/types/model.js +7 -0
  650. package/types/model.js.map +1 -0
  651. package/types/modelAst.d.ts +39 -0
  652. package/types/modelAst.js +7 -0
  653. package/types/modelAst.js.map +1 -0
  654. package/types/modelField.d.ts +330 -0
  655. package/types/modelField.js +7 -0
  656. package/types/modelField.js.map +1 -0
  657. package/types/modelGroup.d.ts +77 -0
  658. package/types/modelGroup.js +7 -0
  659. package/types/modelGroup.js.map +1 -0
  660. package/types/plugins.d.ts +365 -0
  661. package/types/plugins.js +7 -0
  662. package/types/plugins.js.map +1 -0
  663. package/{types.d.ts → types/types.d.ts} +295 -1215
  664. package/{types.js → types/types.js} +18 -119
  665. package/types/types.js.map +1 -0
  666. package/utils/RichTextRenderer.d.ts +10 -0
  667. package/utils/RichTextRenderer.js +33 -0
  668. package/utils/RichTextRenderer.js.map +1 -0
  669. package/utils/caching/Cache.d.ts +5 -2
  670. package/utils/caching/Cache.js +4 -7
  671. package/utils/caching/Cache.js.map +1 -1
  672. package/utils/caching/CacheKey.d.ts +2 -1
  673. package/utils/caching/CacheKey.js +5 -17
  674. package/utils/caching/CacheKey.js.map +1 -1
  675. package/utils/caching/index.js.map +1 -1
  676. package/utils/caching/types.d.ts +3 -1
  677. package/utils/caching/types.js +7 -0
  678. package/utils/caching/types.js.map +1 -1
  679. package/utils/contentEntryTraverser/ContentEntryTraverser.d.ts +13 -0
  680. package/utils/contentEntryTraverser/ContentEntryTraverser.js +97 -0
  681. package/utils/contentEntryTraverser/ContentEntryTraverser.js.map +1 -0
  682. package/utils/contentModelAst/CmsModelFieldToAstConverterFromPlugins.d.ts +6 -0
  683. package/utils/contentModelAst/CmsModelFieldToAstConverterFromPlugins.js +23 -0
  684. package/utils/contentModelAst/CmsModelFieldToAstConverterFromPlugins.js.map +1 -0
  685. package/utils/contentModelAst/CmsModelFieldToAstFromPlugin.d.ts +7 -0
  686. package/utils/contentModelAst/CmsModelFieldToAstFromPlugin.js +22 -0
  687. package/utils/contentModelAst/CmsModelFieldToAstFromPlugin.js.map +1 -0
  688. package/utils/contentModelAst/CmsModelToAstConverter.d.ts +11 -0
  689. package/utils/contentModelAst/CmsModelToAstConverter.js +28 -0
  690. package/utils/contentModelAst/CmsModelToAstConverter.js.map +1 -0
  691. package/utils/contentModelAst/index.d.ts +3 -0
  692. package/utils/contentModelAst/index.js +40 -0
  693. package/utils/contentModelAst/index.js.map +1 -0
  694. package/utils/converters/Converter.d.ts +3 -3
  695. package/utils/converters/Converter.js.map +1 -1
  696. package/utils/converters/ConverterCollection.d.ts +2 -2
  697. package/utils/converters/ConverterCollection.js.map +1 -1
  698. package/utils/converters/valueKeyStorageConverter.d.ts +3 -3
  699. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  700. package/utils/createModelField.d.ts +7 -0
  701. package/utils/createModelField.js +51 -0
  702. package/utils/createModelField.js.map +1 -0
  703. package/utils/createTypeFromFields.d.ts +1 -1
  704. package/utils/createTypeFromFields.js.map +1 -1
  705. package/utils/createTypeName.js.map +1 -1
  706. package/utils/date.js.map +1 -1
  707. package/utils/entryStorage.d.ts +13 -1
  708. package/utils/entryStorage.js +37 -3
  709. package/utils/entryStorage.js.map +1 -1
  710. package/utils/filterAsync.js.map +1 -1
  711. package/utils/getBaseFieldType.d.ts +1 -1
  712. package/utils/getBaseFieldType.js.map +1 -1
  713. package/utils/getEntryDescription.d.ts +1 -1
  714. package/utils/getEntryDescription.js.map +1 -1
  715. package/utils/getEntryImage.d.ts +1 -1
  716. package/utils/getEntryImage.js.map +1 -1
  717. package/utils/getEntryTitle.d.ts +1 -1
  718. package/utils/getEntryTitle.js.map +1 -1
  719. package/utils/getSchemaFromFieldPlugins.d.ts +6 -6
  720. package/utils/getSchemaFromFieldPlugins.js +5 -4
  721. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  722. package/utils/identity.d.ts +1 -1
  723. package/utils/identity.js.map +1 -1
  724. package/utils/incrementEntryIdVersion.js.map +1 -1
  725. package/utils/index.d.ts +1 -0
  726. package/utils/index.js +11 -0
  727. package/utils/index.js.map +1 -1
  728. package/utils/isHeadlessCmsReady.d.ts +2 -0
  729. package/utils/isHeadlessCmsReady.js +23 -0
  730. package/utils/isHeadlessCmsReady.js.map +1 -0
  731. package/utils/modelFieldTraverser/ModelFieldTraverser.d.ts +16 -0
  732. package/utils/modelFieldTraverser/ModelFieldTraverser.js +41 -0
  733. package/utils/modelFieldTraverser/ModelFieldTraverser.js.map +1 -0
  734. package/utils/modelFieldTraverser/index.d.ts +1 -0
  735. package/utils/modelFieldTraverser/index.js +18 -0
  736. package/utils/modelFieldTraverser/index.js.map +1 -0
  737. package/utils/renderFields.d.ts +1 -1
  738. package/utils/renderFields.js +2 -0
  739. package/utils/renderFields.js.map +1 -1
  740. package/utils/renderGetFilterFields.d.ts +1 -1
  741. package/utils/renderGetFilterFields.js.map +1 -1
  742. package/utils/renderInputFields.d.ts +1 -1
  743. package/utils/renderInputFields.js.map +1 -1
  744. package/utils/renderListFilterFields.d.ts +1 -1
  745. package/utils/renderListFilterFields.js.map +1 -1
  746. package/utils/renderSortEnum.d.ts +2 -2
  747. package/utils/renderSortEnum.js.map +1 -1
  748. package/utils/toSlug.js.map +1 -1
  749. package/validators/dateGte.d.ts +1 -1
  750. package/validators/dateGte.js.map +1 -1
  751. package/validators/dateLte.d.ts +1 -1
  752. package/validators/dateLte.js.map +1 -1
  753. package/validators/gte.d.ts +1 -1
  754. package/validators/gte.js.map +1 -1
  755. package/validators/in.d.ts +1 -1
  756. package/validators/in.js.map +1 -1
  757. package/validators/index.js.map +1 -1
  758. package/validators/lte.d.ts +1 -1
  759. package/validators/lte.js.map +1 -1
  760. package/validators/maxLength.d.ts +1 -1
  761. package/validators/maxLength.js.map +1 -1
  762. package/validators/minLength.d.ts +1 -1
  763. package/validators/minLength.js.map +1 -1
  764. package/validators/pattern.d.ts +1 -1
  765. package/validators/pattern.js.map +1 -1
  766. package/validators/patternPlugins/email.d.ts +1 -1
  767. package/validators/patternPlugins/email.js +1 -1
  768. package/validators/patternPlugins/email.js.map +1 -1
  769. package/validators/patternPlugins/index.d.ts +1 -1
  770. package/validators/patternPlugins/index.js.map +1 -1
  771. package/validators/patternPlugins/lowerCase.d.ts +1 -1
  772. package/validators/patternPlugins/lowerCase.js.map +1 -1
  773. package/validators/patternPlugins/lowerCaseSpace.d.ts +1 -1
  774. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  775. package/validators/patternPlugins/upperCase.d.ts +1 -1
  776. package/validators/patternPlugins/upperCase.js.map +1 -1
  777. package/validators/patternPlugins/upperCaseSpace.d.ts +1 -1
  778. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  779. package/validators/patternPlugins/url.d.ts +1 -1
  780. package/validators/patternPlugins/url.js.map +1 -1
  781. package/validators/required.d.ts +1 -1
  782. package/validators/required.js.map +1 -1
  783. package/validators/timeGte.d.ts +1 -1
  784. package/validators/timeGte.js.map +1 -1
  785. package/validators/timeLte.d.ts +1 -1
  786. package/validators/timeLte.js.map +1 -1
  787. package/validators/unique.d.ts +1 -1
  788. package/validators/unique.js.map +1 -1
  789. package/graphqlFields/dynamicZone/dynamicZoneStorage.d.ts +0 -3
  790. package/graphqlFields/dynamicZone/dynamicZoneStorage.js +0 -111
  791. package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +0 -1
  792. package/plugins/CmsGraphQLSchemaPlugin.d.ts +0 -5
  793. package/plugins/CmsGraphQLSchemaPlugin.js.map +0 -1
  794. package/types.js.map +0 -1
  795. package/utils/access.d.ts +0 -9
  796. package/utils/access.js +0 -26
  797. package/utils/access.js.map +0 -1
  798. package/utils/permissions/EntriesPermissions.d.ts +0 -4
  799. package/utils/permissions/EntriesPermissions.js +0 -11
  800. package/utils/permissions/EntriesPermissions.js.map +0 -1
  801. package/utils/permissions/ModelGroupsPermissions.d.ts +0 -9
  802. package/utils/permissions/ModelGroupsPermissions.js +0 -50
  803. package/utils/permissions/ModelGroupsPermissions.js.map +0 -1
  804. package/utils/permissions/ModelsPermissions.d.ts +0 -22
  805. package/utils/permissions/ModelsPermissions.js +0 -90
  806. package/utils/permissions/ModelsPermissions.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { HeadlessCmsStorageOperations, OnGroupBeforeCreateTopicParams } from "../../types";
2
- import { Topic } from "@webiny/pubsub/types";
3
- import { PluginsContainer } from "@webiny/plugins";
1
+ import type { HeadlessCmsStorageOperations, OnGroupBeforeCreateTopicParams } from "../../types";
2
+ import type { Topic } from "@webiny/pubsub/types";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeGroupCreateParams {
5
5
  onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;
6
6
  plugins: PluginsContainer;
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_toSlug","_CmsGroupPlugin","_utils","assignBeforeGroupCreate","params","onGroupBeforeCreate","plugins","storageOperations","subscribe","group","id","groups","list","where","tenant","locale","length","WebinyError","slug","trim","toSlug","name","generateAlphaNumericId","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","Error","exports"],"sources":["beforeCreate.ts"],"sourcesContent":["import { HeadlessCmsStorageOperations, OnGroupBeforeCreateTopicParams } from \"~/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { toSlug } from \"~/utils/toSlug\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\n\ninterface AssignBeforeGroupCreateParams {\n onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupCreate = (params: AssignBeforeGroupCreateParams) => {\n const { onGroupBeforeCreate, plugins, storageOperations } = params;\n\n onGroupBeforeCreate.subscribe(async params => {\n const { group } = params;\n\n if (group.id) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n id: group.id\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the id \"${group.id}\" already exists.`,\n \"ID_ALREADY_EXISTS\"\n );\n }\n }\n\n if (group.slug && group.slug.trim()) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug: group.slug\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the slug \"${group.slug}\" already exists.`,\n \"SLUG_ALREADY_EXISTS\"\n );\n }\n } else {\n const slug = toSlug(group.name);\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug\n }\n });\n\n if (groups.length === 0) {\n group.slug = slug;\n } else {\n group.slug = `${slug}-${generateAlphaNumericId(8)}`;\n }\n }\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(\n `Cannot create \"${group.slug}\" content model group because one is already registered via a plugin.`\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAOO,MAAMI,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC,OAAO;IAAEC;EAAkB,CAAC,GAAGH,MAAM;EAElEC,mBAAmB,CAACG,SAAS,CAAC,MAAMJ,MAAM,IAAI;IAC1C,MAAM;MAAEK;IAAM,CAAC,GAAGL,MAAM;IAExB,IAAIK,KAAK,CAACC,EAAE,EAAE;MACV,MAAMC,MAAM,GAAG,MAAMJ,iBAAiB,CAACI,MAAM,CAACC,IAAI,CAAC;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEL,KAAK,CAACK,MAAM;UACpBC,MAAM,EAAEN,KAAK,CAACM,MAAM;UACpBL,EAAE,EAAED,KAAK,CAACC;QACd;MACJ,CAAC,CAAC;MACF,IAAIC,MAAM,CAACK,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAIC,cAAW,CAChB,0BAAyBR,KAAK,CAACC,EAAG,mBAAkB,EACrD,mBACJ,CAAC;MACL;IACJ;IAEA,IAAID,KAAK,CAACS,IAAI,IAAIT,KAAK,CAACS,IAAI,CAACC,IAAI,CAAC,CAAC,EAAE;MACjC,MAAMR,MAAM,GAAG,MAAMJ,iBAAiB,CAACI,MAAM,CAACC,IAAI,CAAC;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEL,KAAK,CAACK,MAAM;UACpBC,MAAM,EAAEN,KAAK,CAACM,MAAM;UACpBG,IAAI,EAAET,KAAK,CAACS;QAChB;MACJ,CAAC,CAAC;MACF,IAAIP,MAAM,CAACK,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAIC,cAAW,CAChB,4BAA2BR,KAAK,CAACS,IAAK,mBAAkB,EACzD,qBACJ,CAAC;MACL;IACJ,CAAC,MAAM;MACH,MAAMA,IAAI,GAAG,IAAAE,cAAM,EAACX,KAAK,CAACY,IAAI,CAAC;MAC/B,MAAMV,MAAM,GAAG,MAAMJ,iBAAiB,CAACI,MAAM,CAACC,IAAI,CAAC;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEL,KAAK,CAACK,MAAM;UACpBC,MAAM,EAAEN,KAAK,CAACM,MAAM;UACpBG;QACJ;MACJ,CAAC,CAAC;MAEF,IAAIP,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;QACrBP,KAAK,CAACS,IAAI,GAAGA,IAAI;MACrB,CAAC,MAAM;QACHT,KAAK,CAACS,IAAI,GAAI,GAAEA,IAAK,IAAG,IAAAI,6BAAsB,EAAC,CAAC,CAAE,EAAC;MACvD;IACJ;IAEA,MAAMC,WAAW,GAAGjB,OAAO,CACtBkB,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,iBAAiB,CAACX,IAAI,KAAKT,KAAK,CAACS,IAAI,CAAC;IAE7D,IAAIK,WAAW,EAAE;MACb,MAAM,IAAIO,KAAK,CACV,kBAAiBrB,KAAK,CAACS,IAAK,uEACjC,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAA5B,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_toSlug","_CmsGroupPlugin","_utils","assignBeforeGroupCreate","params","onGroupBeforeCreate","plugins","storageOperations","subscribe","group","id","groups","list","where","tenant","locale","length","WebinyError","slug","trim","toSlug","name","generateAlphaNumericId","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","Error","exports"],"sources":["beforeCreate.ts"],"sourcesContent":["import type { HeadlessCmsStorageOperations, OnGroupBeforeCreateTopicParams } from \"~/types\";\nimport type { Topic } from \"@webiny/pubsub/types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { toSlug } from \"~/utils/toSlug\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\n\ninterface AssignBeforeGroupCreateParams {\n onGroupBeforeCreate: Topic<OnGroupBeforeCreateTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupCreate = (params: AssignBeforeGroupCreateParams) => {\n const { onGroupBeforeCreate, plugins, storageOperations } = params;\n\n onGroupBeforeCreate.subscribe(async params => {\n const { group } = params;\n\n if (group.id) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n id: group.id\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the id \"${group.id}\" already exists.`,\n \"ID_ALREADY_EXISTS\"\n );\n }\n }\n\n if (group.slug && group.slug.trim()) {\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug: group.slug\n }\n });\n if (groups.length > 0) {\n throw new WebinyError(\n `Cms Group with the slug \"${group.slug}\" already exists.`,\n \"SLUG_ALREADY_EXISTS\"\n );\n }\n } else {\n const slug = toSlug(group.name);\n const groups = await storageOperations.groups.list({\n where: {\n tenant: group.tenant,\n locale: group.locale,\n slug\n }\n });\n\n if (groups.length === 0) {\n group.slug = slug;\n } else {\n group.slug = `${slug}-${generateAlphaNumericId(8)}`;\n }\n }\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(\n `Cannot create \"${group.slug}\" content model group because one is already registered via a plugin.`\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAOO,MAAMI,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC,OAAO;IAAEC;EAAkB,CAAC,GAAGH,MAAM;EAElEC,mBAAmB,CAACG,SAAS,CAAC,MAAMJ,MAAM,IAAI;IAC1C,MAAM;MAAEK;IAAM,CAAC,GAAGL,MAAM;IAExB,IAAIK,KAAK,CAACC,EAAE,EAAE;MACV,MAAMC,MAAM,GAAG,MAAMJ,iBAAiB,CAACI,MAAM,CAACC,IAAI,CAAC;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEL,KAAK,CAACK,MAAM;UACpBC,MAAM,EAAEN,KAAK,CAACM,MAAM;UACpBL,EAAE,EAAED,KAAK,CAACC;QACd;MACJ,CAAC,CAAC;MACF,IAAIC,MAAM,CAACK,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAIC,cAAW,CACjB,0BAA0BR,KAAK,CAACC,EAAE,mBAAmB,EACrD,mBACJ,CAAC;MACL;IACJ;IAEA,IAAID,KAAK,CAACS,IAAI,IAAIT,KAAK,CAACS,IAAI,CAACC,IAAI,CAAC,CAAC,EAAE;MACjC,MAAMR,MAAM,GAAG,MAAMJ,iBAAiB,CAACI,MAAM,CAACC,IAAI,CAAC;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEL,KAAK,CAACK,MAAM;UACpBC,MAAM,EAAEN,KAAK,CAACM,MAAM;UACpBG,IAAI,EAAET,KAAK,CAACS;QAChB;MACJ,CAAC,CAAC;MACF,IAAIP,MAAM,CAACK,MAAM,GAAG,CAAC,EAAE;QACnB,MAAM,IAAIC,cAAW,CACjB,4BAA4BR,KAAK,CAACS,IAAI,mBAAmB,EACzD,qBACJ,CAAC;MACL;IACJ,CAAC,MAAM;MACH,MAAMA,IAAI,GAAG,IAAAE,cAAM,EAACX,KAAK,CAACY,IAAI,CAAC;MAC/B,MAAMV,MAAM,GAAG,MAAMJ,iBAAiB,CAACI,MAAM,CAACC,IAAI,CAAC;QAC/CC,KAAK,EAAE;UACHC,MAAM,EAAEL,KAAK,CAACK,MAAM;UACpBC,MAAM,EAAEN,KAAK,CAACM,MAAM;UACpBG;QACJ;MACJ,CAAC,CAAC;MAEF,IAAIP,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;QACrBP,KAAK,CAACS,IAAI,GAAGA,IAAI;MACrB,CAAC,MAAM;QACHT,KAAK,CAACS,IAAI,GAAG,GAAGA,IAAI,IAAI,IAAAI,6BAAsB,EAAC,CAAC,CAAC,EAAE;MACvD;IACJ;IAEA,MAAMC,WAAW,GAAGjB,OAAO,CACtBkB,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,iBAAiB,CAACX,IAAI,KAAKT,KAAK,CAACS,IAAI,CAAC;IAE7D,IAAIK,WAAW,EAAE;MACb,MAAM,IAAIO,KAAK,CACX,kBAAkBrB,KAAK,CAACS,IAAI,uEAChC,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAA5B,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Topic } from "@webiny/pubsub/types";
2
- import { OnGroupBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
3
- import { PluginsContainer } from "@webiny/plugins";
1
+ import type { Topic } from "@webiny/pubsub/types";
2
+ import type { OnGroupBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from "../../types";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeGroupDeleteParams {
5
5
  onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;
6
6
  plugins: PluginsContainer;
@@ -1 +1 @@
1
- {"version":3,"names":["_CmsGroupPlugin","require","_error","_interopRequireDefault","assignBeforeGroupDelete","params","onGroupBeforeDelete","plugins","storageOperations","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","models","list","where","tenant","locale","items","filter","model","id","length","WebinyError","exports"],"sources":["beforeDelete.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnGroupBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface AssignBeforeGroupDeleteParams {\n onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupDelete = (params: AssignBeforeGroupDeleteParams) => {\n const { onGroupBeforeDelete, plugins, storageOperations } = params;\n\n onGroupBeforeDelete.subscribe(async params => {\n const { group } = params;\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(`Cms Groups defined via plugins cannot be deleted.`);\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: group.tenant,\n locale: group.locale\n }\n });\n const items = models.filter(model => {\n return model.group.id === group.id;\n });\n if (items.length > 0) {\n throw new WebinyError(\n \"Cannot delete this group because there are models that belong to it.\",\n \"BEFORE_DELETE_ERROR\",\n {\n group\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAOO,MAAMG,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC,OAAO;IAAEC;EAAkB,CAAC,GAAGH,MAAM;EAElEC,mBAAmB,CAACG,SAAS,CAAC,MAAMJ,MAAM,IAAI;IAC1C,MAAM;MAAEK;IAAM,CAAC,GAAGL,MAAM;IAExB,MAAMM,WAAW,GAAGJ,OAAO,CACtBK,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,iBAAiB,CAACC,IAAI,KAAKR,KAAK,CAACQ,IAAI,CAAC;IAE7D,IAAIP,WAAW,EAAE;MACb,MAAM,IAAIQ,KAAK,CAAE,mDAAkD,CAAC;IACxE;IAEA,MAAMC,MAAM,GAAG,MAAMZ,iBAAiB,CAACY,MAAM,CAACC,IAAI,CAAC;MAC/CC,KAAK,EAAE;QACHC,MAAM,EAAEb,KAAK,CAACa,MAAM;QACpBC,MAAM,EAAEd,KAAK,CAACc;MAClB;IACJ,CAAC,CAAC;IACF,MAAMC,KAAK,GAAGL,MAAM,CAACM,MAAM,CAACC,KAAK,IAAI;MACjC,OAAOA,KAAK,CAACjB,KAAK,CAACkB,EAAE,KAAKlB,KAAK,CAACkB,EAAE;IACtC,CAAC,CAAC;IACF,IAAIH,KAAK,CAACI,MAAM,GAAG,CAAC,EAAE;MAClB,MAAM,IAAIC,cAAW,CACjB,sEAAsE,EACtE,qBAAqB,EACrB;QACIpB;MACJ,CACJ,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAACqB,OAAA,CAAA3B,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_CmsGroupPlugin","require","_error","_interopRequireDefault","assignBeforeGroupDelete","params","onGroupBeforeDelete","plugins","storageOperations","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","models","list","where","tenant","locale","items","filter","model","id","length","WebinyError","exports"],"sources":["beforeDelete.ts"],"sourcesContent":["import type { Topic } from \"@webiny/pubsub/types\";\nimport type { OnGroupBeforeDeleteTopicParams, HeadlessCmsStorageOperations } from \"~/types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport WebinyError from \"@webiny/error\";\n\ninterface AssignBeforeGroupDeleteParams {\n onGroupBeforeDelete: Topic<OnGroupBeforeDeleteTopicParams>;\n plugins: PluginsContainer;\n storageOperations: HeadlessCmsStorageOperations;\n}\nexport const assignBeforeGroupDelete = (params: AssignBeforeGroupDeleteParams) => {\n const { onGroupBeforeDelete, plugins, storageOperations } = params;\n\n onGroupBeforeDelete.subscribe(async params => {\n const { group } = params;\n\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n\n if (groupPlugin) {\n throw new Error(`Cms Groups defined via plugins cannot be deleted.`);\n }\n\n const models = await storageOperations.models.list({\n where: {\n tenant: group.tenant,\n locale: group.locale\n }\n });\n const items = models.filter(model => {\n return model.group.id === group.id;\n });\n if (items.length > 0) {\n throw new WebinyError(\n \"Cannot delete this group because there are models that belong to it.\",\n \"BEFORE_DELETE_ERROR\",\n {\n group\n }\n );\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAOO,MAAMG,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC,OAAO;IAAEC;EAAkB,CAAC,GAAGH,MAAM;EAElEC,mBAAmB,CAACG,SAAS,CAAC,MAAMJ,MAAM,IAAI;IAC1C,MAAM;MAAEK;IAAM,CAAC,GAAGL,MAAM;IAExB,MAAMM,WAAW,GAAGJ,OAAO,CACtBK,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,iBAAiB,CAACC,IAAI,KAAKR,KAAK,CAACQ,IAAI,CAAC;IAE7D,IAAIP,WAAW,EAAE;MACb,MAAM,IAAIQ,KAAK,CAAC,mDAAmD,CAAC;IACxE;IAEA,MAAMC,MAAM,GAAG,MAAMZ,iBAAiB,CAACY,MAAM,CAACC,IAAI,CAAC;MAC/CC,KAAK,EAAE;QACHC,MAAM,EAAEb,KAAK,CAACa,MAAM;QACpBC,MAAM,EAAEd,KAAK,CAACc;MAClB;IACJ,CAAC,CAAC;IACF,MAAMC,KAAK,GAAGL,MAAM,CAACM,MAAM,CAACC,KAAK,IAAI;MACjC,OAAOA,KAAK,CAACjB,KAAK,CAACkB,EAAE,KAAKlB,KAAK,CAACkB,EAAE;IACtC,CAAC,CAAC;IACF,IAAIH,KAAK,CAACI,MAAM,GAAG,CAAC,EAAE;MAClB,MAAM,IAAIC,cAAW,CACjB,sEAAsE,EACtE,qBAAqB,EACrB;QACIpB;MACJ,CACJ,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAACqB,OAAA,CAAA3B,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { Topic } from "@webiny/pubsub/types";
2
- import { OnGroupBeforeUpdateTopicParams } from "../../types";
3
- import { PluginsContainer } from "@webiny/plugins";
1
+ import type { Topic } from "@webiny/pubsub/types";
2
+ import type { OnGroupBeforeUpdateTopicParams } from "../../types";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
4
  interface AssignBeforeGroupUpdateParams {
5
5
  onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;
6
6
  plugins: PluginsContainer;
@@ -1 +1 @@
1
- {"version":3,"names":["_CmsGroupPlugin","require","assignBeforeGroupUpdate","params","onGroupBeforeUpdate","plugins","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","exports"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { OnGroupBeforeUpdateTopicParams } from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface AssignBeforeGroupUpdateParams {\n onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n plugins: PluginsContainer;\n}\nexport const assignBeforeGroupUpdate = (params: AssignBeforeGroupUpdateParams) => {\n const { onGroupBeforeUpdate, plugins } = params;\n\n onGroupBeforeUpdate.subscribe(({ group }) => {\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n if (!groupPlugin) {\n return;\n }\n throw new Error(`Cms Groups defined via plugins cannot be updated.`);\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAE/CC,mBAAmB,CAACE,SAAS,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAK;IACzC,MAAMC,WAAW,GAAGH,OAAO,CACtBI,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,iBAAiB,CAACC,IAAI,KAAKR,KAAK,CAACQ,IAAI,CAAC;IAC7D,IAAI,CAACP,WAAW,EAAE;MACd;IACJ;IACA,MAAM,IAAIQ,KAAK,CAAE,mDAAkD,CAAC;EACxE,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAf,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_CmsGroupPlugin","require","assignBeforeGroupUpdate","params","onGroupBeforeUpdate","plugins","subscribe","group","groupPlugin","byType","CmsGroupPlugin","type","find","item","contentModelGroup","slug","Error","exports"],"sources":["beforeUpdate.ts"],"sourcesContent":["import type { Topic } from \"@webiny/pubsub/types\";\nimport type { OnGroupBeforeUpdateTopicParams } from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface AssignBeforeGroupUpdateParams {\n onGroupBeforeUpdate: Topic<OnGroupBeforeUpdateTopicParams>;\n plugins: PluginsContainer;\n}\nexport const assignBeforeGroupUpdate = (params: AssignBeforeGroupUpdateParams) => {\n const { onGroupBeforeUpdate, plugins } = params;\n\n onGroupBeforeUpdate.subscribe(({ group }) => {\n const groupPlugin = plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .find(item => item.contentModelGroup.slug === group.slug);\n if (!groupPlugin) {\n return;\n }\n throw new Error(`Cms Groups defined via plugins cannot be updated.`);\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAOO,MAAMC,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAE/CC,mBAAmB,CAACE,SAAS,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAK;IACzC,MAAMC,WAAW,GAAGH,OAAO,CACtBI,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,iBAAiB,CAACC,IAAI,KAAKR,KAAK,CAACQ,IAAI,CAAC;IAC7D,IAAI,CAACP,WAAW,EAAE;MACd;IACJ;IACA,MAAM,IAAIQ,KAAK,CAAC,mDAAmD,CAAC;EACxE,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAf,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { HeadlessCmsStorageOperations } from "../../types";
1
+ import type { HeadlessCmsStorageOperations } from "../../types";
2
2
  interface Params {
3
3
  storageOperations: HeadlessCmsStorageOperations;
4
4
  tenant: string;
@@ -1 +1 @@
1
- {"version":3,"names":["listGroupsFromDatabase","params","storageOperations","tenant","locale","groups","list","where","exports"],"sources":["listGroupsFromDatabase.ts"],"sourcesContent":["import { HeadlessCmsStorageOperations } from \"~/types\";\n\ninterface Params {\n storageOperations: HeadlessCmsStorageOperations;\n tenant: string;\n locale: string;\n}\n\nexport const listGroupsFromDatabase = async (params: Params) => {\n const { storageOperations, tenant, locale } = params;\n\n return await storageOperations.groups.list({\n where: {\n tenant,\n locale\n }\n });\n};\n"],"mappings":";;;;;;AAQO,MAAMA,sBAAsB,GAAG,MAAOC,MAAc,IAAK;EAC5D,MAAM;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEpD,OAAO,MAAMC,iBAAiB,CAACG,MAAM,CAACC,IAAI,CAAC;IACvCC,KAAK,EAAE;MACHJ,MAAM;MACNC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAR,sBAAA,GAAAA,sBAAA"}
1
+ {"version":3,"names":["listGroupsFromDatabase","params","storageOperations","tenant","locale","groups","list","where","exports"],"sources":["listGroupsFromDatabase.ts"],"sourcesContent":["import type { HeadlessCmsStorageOperations } from \"~/types\";\n\ninterface Params {\n storageOperations: HeadlessCmsStorageOperations;\n tenant: string;\n locale: string;\n}\n\nexport const listGroupsFromDatabase = async (params: Params) => {\n const { storageOperations, tenant, locale } = params;\n\n return await storageOperations.groups.list({\n where: {\n tenant,\n locale\n }\n });\n};\n"],"mappings":";;;;;;AAQO,MAAMA,sBAAsB,GAAG,MAAOC,MAAc,IAAK;EAC5D,MAAM;IAAEC,iBAAiB;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEpD,OAAO,MAAMC,iBAAiB,CAACG,MAAM,CAACC,IAAI,CAAC;IACvCC,KAAK,EAAE;MACHJ,MAAM;MACNC;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACI,OAAA,CAAAR,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -6,9 +6,9 @@ export declare const createGroupCreateValidation: () => zod.ZodObject<{
6
6
  description: zod.ZodEffects<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>, string, string | null | undefined>;
7
7
  icon: zod.ZodString;
8
8
  }, "strip", zod.ZodTypeAny, {
9
- description: string;
10
9
  name: string;
11
10
  slug: string;
11
+ description: string;
12
12
  icon: string;
13
13
  id?: string | null | undefined;
14
14
  }, {
@@ -1 +1 @@
1
- {"version":3,"names":["_zod","_interopRequireDefault","require","_toSlug","str","zod","string","trim","name","max","description","optional","nullish","icon","min","createGroupCreateValidation","object","id","slug","transform","value","toSlug","exports","createGroupUpdateValidation"],"sources":["validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { toSlug } from \"~/utils/toSlug\";\n\nconst str = zod.string().trim();\n\nconst name = str.max(100);\nconst description = str.max(255).optional().nullish();\nconst icon = str.min(1).max(255);\n\nexport const createGroupCreateValidation = () => {\n return zod.object({\n id: str.optional().nullish(),\n name: name.min(1),\n slug: str\n .max(100)\n .optional()\n .transform(value => {\n return value ? toSlug(value) : \"\";\n }),\n description: description.transform(value => {\n return value || \"\";\n }),\n icon\n });\n};\n\nexport const createGroupUpdateValidation = () => {\n return zod.object({\n name: name.optional(),\n description,\n icon: icon.optional()\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,GAAG,GAAGC,YAAG,CAACC,MAAM,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;AAE/B,MAAMC,IAAI,GAAGJ,GAAG,CAACK,GAAG,CAAC,GAAG,CAAC;AACzB,MAAMC,WAAW,GAAGN,GAAG,CAACK,GAAG,CAAC,GAAG,CAAC,CAACE,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;AACrD,MAAMC,IAAI,GAAGT,GAAG,CAACU,GAAG,CAAC,CAAC,CAAC,CAACL,GAAG,CAAC,GAAG,CAAC;AAEzB,MAAMM,2BAA2B,GAAGA,CAAA,KAAM;EAC7C,OAAOV,YAAG,CAACW,MAAM,CAAC;IACdC,EAAE,EAAEb,GAAG,CAACO,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC;IAC5BJ,IAAI,EAAEA,IAAI,CAACM,GAAG,CAAC,CAAC,CAAC;IACjBI,IAAI,EAAEd,GAAG,CACJK,GAAG,CAAC,GAAG,CAAC,CACRE,QAAQ,CAAC,CAAC,CACVQ,SAAS,CAACC,KAAK,IAAI;MAChB,OAAOA,KAAK,GAAG,IAAAC,cAAM,EAACD,KAAK,CAAC,GAAG,EAAE;IACrC,CAAC,CAAC;IACNV,WAAW,EAAEA,WAAW,CAACS,SAAS,CAACC,KAAK,IAAI;MACxC,OAAOA,KAAK,IAAI,EAAE;IACtB,CAAC,CAAC;IACFP;EACJ,CAAC,CAAC;AACN,CAAC;AAACS,OAAA,CAAAP,2BAAA,GAAAA,2BAAA;AAEK,MAAMQ,2BAA2B,GAAGA,CAAA,KAAM;EAC7C,OAAOlB,YAAG,CAACW,MAAM,CAAC;IACdR,IAAI,EAAEA,IAAI,CAACG,QAAQ,CAAC,CAAC;IACrBD,WAAW;IACXG,IAAI,EAAEA,IAAI,CAACF,QAAQ,CAAC;EACxB,CAAC,CAAC;AACN,CAAC;AAACW,OAAA,CAAAC,2BAAA,GAAAA,2BAAA"}
1
+ {"version":3,"names":["_zod","_interopRequireDefault","require","_toSlug","str","zod","string","trim","name","max","description","optional","nullish","icon","min","createGroupCreateValidation","object","id","slug","transform","value","toSlug","exports","createGroupUpdateValidation"],"sources":["validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { toSlug } from \"~/utils/toSlug\";\n\nconst str = zod.string().trim();\n\nconst name = str.max(100);\nconst description = str.max(255).optional().nullish();\nconst icon = str.min(1).max(255);\n\nexport const createGroupCreateValidation = () => {\n return zod.object({\n id: str.optional().nullish(),\n name: name.min(1),\n slug: str\n .max(100)\n .optional()\n .transform(value => {\n return value ? toSlug(value) : \"\";\n }),\n description: description.transform(value => {\n return value || \"\";\n }),\n icon\n });\n};\n\nexport const createGroupUpdateValidation = ()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AW;IACXG,IAAI,EAAEA,IAAI,CAACF,QAAQ,CAAC;EACxB,CAAC,CAAC;AACN,CAAC;AAACW,OAAA,CAAAC,2BAAA,GAAAA,2BAAA","ignoreList":[]}
@@ -1,13 +1,13 @@
1
- import { CmsContext, CmsGroupContext, HeadlessCmsStorageOperations } from "../types";
2
- import { Tenant } from "@webiny/api-tenancy/types";
3
- import { I18NLocale } from "@webiny/api-i18n/types";
4
- import { SecurityIdentity } from "@webiny/api-security/types";
5
- import { ModelGroupsPermissions } from "../utils/permissions/ModelGroupsPermissions";
1
+ import type { CmsContext, CmsGroupContext, HeadlessCmsStorageOperations } from "../types";
2
+ import type { Tenant } from "@webiny/api-tenancy/types";
3
+ import type { I18NLocale } from "@webiny/api-i18n/types";
4
+ import type { SecurityIdentity } from "@webiny/api-security/types";
5
+ import type { AccessControl } from "./AccessControl/AccessControl";
6
6
  export interface CreateModelGroupsCrudParams {
7
7
  getTenant: () => Tenant;
8
8
  getLocale: () => I18NLocale;
9
9
  storageOperations: HeadlessCmsStorageOperations;
10
- modelGroupsPermissions: ModelGroupsPermissions;
10
+ accessControl: AccessControl;
11
11
  context: CmsContext;
12
12
  getIdentity: () => SecurityIdentity;
13
13
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.createModelGroupsCrud = void 0;
8
8
  var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _handlerGraphql = require("@webiny/handler-graphql");
9
10
  var _CmsGroupPlugin = require("../plugins/CmsGroupPlugin");
10
11
  var _pubsub = require("@webiny/pubsub");
11
12
  var _beforeUpdate = require("./contentModelGroup/beforeUpdate");
@@ -16,29 +17,20 @@ var _utils = require("@webiny/utils");
16
17
  var _filterAsync = require("../utils/filterAsync");
17
18
  var _utils2 = require("../utils");
18
19
  var _listGroupsFromDatabase = require("./contentModelGroup/listGroupsFromDatabase");
19
- var _handlerGraphql = require("@webiny/handler-graphql");
20
20
  const createModelGroupsCrud = params => {
21
21
  const {
22
22
  getTenant,
23
23
  getIdentity,
24
24
  getLocale,
25
25
  storageOperations,
26
- modelGroupsPermissions,
26
+ accessControl,
27
27
  context
28
28
  } = params;
29
29
  const filterGroup = async group => {
30
30
  if (!group) {
31
31
  return false;
32
32
  }
33
- const ownsGroup = await modelGroupsPermissions.ensure({
34
- owns: group.createdBy
35
- }, {
36
- throw: false
37
- });
38
- if (!ownsGroup) {
39
- return false;
40
- }
41
- return await modelGroupsPermissions.canAccessGroup({
33
+ return accessControl.canAccessGroup({
42
34
  group
43
35
  });
44
36
  };
@@ -157,9 +149,7 @@ const createModelGroupsCrud = params => {
157
149
  * CRUD Methods
158
150
  */
159
151
  const getGroup = async id => {
160
- await modelGroupsPermissions.ensure({
161
- rwd: "r"
162
- });
152
+ await accessControl.ensureCanAccessGroup();
163
153
  const groups = await context.security.withoutAuthorization(async () => {
164
154
  return fetchGroups(getTenant().id, getLocale().code);
165
155
  });
@@ -167,10 +157,7 @@ const createModelGroupsCrud = params => {
167
157
  if (!group) {
168
158
  throw new _handlerGraphql.NotFoundError(`Cms Group "${id}" was not found!`);
169
159
  }
170
- await modelGroupsPermissions.ensure({
171
- owns: group.createdBy
172
- });
173
- await modelGroupsPermissions.ensureCanAccessGroup({
160
+ await accessControl.ensureCanAccessGroup({
174
161
  group
175
162
  });
176
163
  return group;
@@ -183,13 +170,11 @@ const createModelGroupsCrud = params => {
183
170
  tenant,
184
171
  locale
185
172
  } = where || {};
186
- await modelGroupsPermissions.ensure({
187
- rwd: "r"
188
- });
173
+ await accessControl.ensureCanAccessGroup();
189
174
  return fetchGroups(tenant || getTenant().id, locale || getLocale().code);
190
175
  };
191
176
  const createGroup = async input => {
192
- await modelGroupsPermissions.ensure({
177
+ await accessControl.ensureCanAccessGroup({
193
178
  rwd: "w"
194
179
  });
195
180
  const result = await (0, _validation.createGroupCreateValidation)().safeParseAsync(input);
@@ -213,6 +198,10 @@ const createModelGroupsCrud = params => {
213
198
  },
214
199
  webinyVersion: context.WEBINY_VERSION
215
200
  };
201
+ await accessControl.ensureCanAccessGroup({
202
+ group,
203
+ rwd: "w"
204
+ });
216
205
  try {
217
206
  await onGroupBeforeCreate.publish({
218
207
  group
@@ -239,12 +228,12 @@ const createModelGroupsCrud = params => {
239
228
  }
240
229
  };
241
230
  const updateGroup = async (id, input) => {
242
- await modelGroupsPermissions.ensure({
231
+ await accessControl.ensureCanAccessGroup({
243
232
  rwd: "w"
244
233
  });
245
234
  const original = await getGroup(id);
246
- await modelGroupsPermissions.ensure({
247
- owns: original.createdBy
235
+ await accessControl.ensureCanAccessGroup({
236
+ group: original
248
237
  });
249
238
  const result = await (0, _validation.createGroupUpdateValidation)().safeParseAsync(input);
250
239
  if (!result.success) {
@@ -295,12 +284,12 @@ const createModelGroupsCrud = params => {
295
284
  }
296
285
  };
297
286
  const deleteGroup = async id => {
298
- await modelGroupsPermissions.ensure({
287
+ await accessControl.ensureCanAccessGroup({
299
288
  rwd: "d"
300
289
  });
301
290
  const group = await getGroup(id);
302
- await modelGroupsPermissions.ensure({
303
- owns: group.createdBy
291
+ await accessControl.ensureCanAccessGroup({
292
+ group
304
293
  });
305
294
  try {
306
295
  await onGroupBeforeDelete.publish({
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_CmsGroupPlugin","_pubsub","_beforeUpdate","_beforeCreate","_beforeDelete","_validation","_utils","_filterAsync","_utils2","_listGroupsFromDatabase","_handlerGraphql","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","modelGroupsPermissions","context","filterGroup","group","ownsGroup","ensure","owns","createdBy","throw","canAccessGroup","listDatabaseGroupsCache","createMemoryCache","listFilteredDatabaseGroupsCache","listPluginGroupsCache","clearGroupsCache","clear","fetchPluginGroups","tenant","locale","pluginGroups","plugins","byType","CmsGroupPlugin","type","cacheKey","createCacheKey","identity","security","isAuthorizationEnabled","id","undefined","groups","map","contentModelGroup","slug","savedOn","join","getOrSet","filter","plugin","t","l","webinyVersion","WEBINY_VERSION","filterAsync","fetchGroups","databaseGroups","listGroupsFromDatabase","filteredCacheKey","dbCacheKey","get","concat","onGroupBeforeCreate","createTopic","onGroupAfterCreate","onGroupCreateError","onGroupBeforeUpdate","onGroupAfterUpdate","onGroupUpdateError","onGroupBeforeDelete","onGroupAfterDelete","onGroupDeleteError","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","getGroup","rwd","withoutAuthorization","code","find","NotFoundError","ensureCanAccessGroup","listGroups","where","createGroup","input","result","createGroupCreateValidation","safeParseAsync","success","createZodError","error","data","mdbid","createdOn","Date","toISOString","displayName","publish","create","ex","WebinyError","message","updateGroup","original","createGroupUpdateValidation","Object","keys","length","updatedGroup","update","deleteGroup","delete","benchmark","measure","exports"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsContext,\n CmsGroup,\n CmsGroupContext,\n HeadlessCmsStorageOperations,\n OnGroupAfterCreateTopicParams,\n OnGroupAfterDeleteTopicParams,\n OnGroupAfterUpdateTopicParams,\n OnGroupBeforeCreateTopicParams,\n OnGroupBeforeDeleteTopicParams,\n OnGroupBeforeUpdateTopicParams,\n OnGroupCreateErrorTopicParams,\n OnGroupDeleteErrorTopicParams,\n OnGroupUpdateErrorTopicParams\n} from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeGroupUpdate } from \"./contentModelGroup/beforeUpdate\";\nimport { assignBeforeGroupCreate } from \"./contentModelGroup/beforeCreate\";\nimport { assignBeforeGroupDelete } from \"./contentModelGroup/beforeDelete\";\nimport {\n createGroupCreateValidation,\n createGroupUpdateValidation\n} from \"~/crud/contentModelGroup/validation\";\nimport { createZodError, mdbid } from \"@webiny/utils\";\nimport { ModelGroupsPermissions } from \"~/utils/permissions/ModelGroupsPermissions\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport { createCacheKey, createMemoryCache } from \"~/utils\";\nimport { listGroupsFromDatabase } from \"~/crud/contentModelGroup/listGroupsFromDatabase\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n modelGroupsPermissions: ModelGroupsPermissions;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const {\n getTenant,\n getIdentity,\n getLocale,\n storageOperations,\n modelGroupsPermissions,\n context\n } = params;\n\n const filterGroup = async (group?: CmsGroup) => {\n if (!group) {\n return false;\n }\n const ownsGroup = await modelGroupsPermissions.ensure(\n { owns: group.createdBy },\n { throw: false }\n );\n\n if (!ownsGroup) {\n return false;\n }\n\n return await modelGroupsPermissions.canAccessGroup({\n group\n });\n };\n\n const listDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listFilteredDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listPluginGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n listPluginGroupsCache.clear();\n listDatabaseGroupsCache.clear();\n listFilteredDatabaseGroupsCache.clear();\n };\n\n const fetchPluginGroups = (tenant: string, locale: string): Promise<CmsGroup[]> => {\n const pluginGroups = context.plugins.byType<CmsGroupPlugin>(CmsGroupPlugin.type);\n\n const cacheKey = createCacheKey({\n tenant,\n locale,\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined,\n groups: pluginGroups\n .map(({ contentModelGroup: group }) => {\n return `${group.id}#${group.slug}#${group.savedOn || \"unknown\"}`;\n })\n .join(\"/\")\n });\n\n return listPluginGroupsCache.getOrSet(cacheKey, async (): Promise<CmsGroup[]> => {\n const groups = pluginGroups\n /**\n * We need to filter out groups that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModelGroup;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n });\n return filterAsync(groups, filterGroup);\n });\n };\n\n const fetchGroups = async (tenant: string, locale: string) => {\n const pluginGroups = await fetchPluginGroups(tenant, locale);\n /**\n * Maybe we can cache based on permissions, not the identity id?\n *\n * TODO: @adrian please check if possible.\n */\n const cacheKey = createCacheKey({\n tenant,\n locale\n });\n const databaseGroups = await listDatabaseGroupsCache.getOrSet(cacheKey, async () => {\n return await listGroupsFromDatabase({\n storageOperations,\n tenant,\n locale\n });\n });\n const filteredCacheKey = createCacheKey({\n dbCacheKey: cacheKey.get(),\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined\n });\n\n const groups = await listFilteredDatabaseGroupsCache.getOrSet(\n filteredCacheKey,\n async () => {\n return filterAsync(databaseGroups, filterGroup);\n }\n );\n\n return groups.concat(pluginGroups);\n };\n\n /**\n * Create\n */\n const onGroupBeforeCreate =\n createTopic<OnGroupBeforeCreateTopicParams>(\"cms.onGroupBeforeCreate\");\n const onGroupAfterCreate = createTopic<OnGroupAfterCreateTopicParams>(\"cms.onGroupAfterCreate\");\n const onGroupCreateError = createTopic<OnGroupCreateErrorTopicParams>(\"cms.onGroupCreateError\");\n /**\n * Update\n */\n const onGroupBeforeUpdate =\n createTopic<OnGroupBeforeUpdateTopicParams>(\"cms.onGroupBeforeUpdate\");\n const onGroupAfterUpdate = createTopic<OnGroupAfterUpdateTopicParams>(\"cms.onGroupAfterUpdate\");\n const onGroupUpdateError = createTopic<OnGroupUpdateErrorTopicParams>(\"cms.onGroupUpdateError\");\n /**\n * Delete\n */\n const onGroupBeforeDelete =\n createTopic<OnGroupBeforeDeleteTopicParams>(\"cms.onGroupBeforeDelete\");\n const onGroupAfterDelete = createTopic<OnGroupAfterDeleteTopicParams>(\"cms.onGroupAfterDelete\");\n const onGroupDeleteError = createTopic<OnGroupDeleteErrorTopicParams>(\"cms.onGroupDeleteError\");\n\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeGroupCreate({\n onGroupBeforeCreate,\n plugins: context.plugins,\n storageOperations\n });\n assignBeforeGroupUpdate({\n onGroupBeforeUpdate,\n plugins: context.plugins\n });\n assignBeforeGroupDelete({\n onGroupBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n /**\n * CRUD Methods\n */\n const getGroup: CmsGroupContext[\"getGroup\"] = async id => {\n await modelGroupsPermissions.ensure({ rwd: \"r\" });\n\n const groups = await context.security.withoutAuthorization(async () => {\n return fetchGroups(getTenant().id, getLocale().code);\n });\n const group = groups.find(group => group.id === id);\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n\n await modelGroupsPermissions.ensure({ owns: group.createdBy });\n await modelGroupsPermissions.ensureCanAccessGroup({\n group\n });\n\n return group;\n };\n\n const listGroups: CmsGroupContext[\"listGroups\"] = async params => {\n const { where } = params || {};\n\n const { tenant, locale } = where || {};\n\n await modelGroupsPermissions.ensure({ rwd: \"r\" });\n\n return fetchGroups(tenant || getTenant().id, locale || getLocale().code);\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n await modelGroupsPermissions.ensure({ rwd: \"w\" });\n\n const result = await createGroupCreateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n const identity = getIdentity();\n\n const id = data.id || mdbid();\n const group: CmsGroup = {\n ...data,\n id,\n tenant: getTenant().id,\n locale: getLocale().code,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n webinyVersion: context.WEBINY_VERSION\n };\n try {\n await onGroupBeforeCreate.publish({\n group\n });\n\n const result = await storageOperations.groups.create({\n group\n });\n\n clearGroupsCache();\n\n await onGroupAfterCreate.publish({\n group: result\n });\n\n return group;\n } catch (ex) {\n await onGroupCreateError.publish({\n input,\n group,\n error: ex\n });\n throw new WebinyError(\n ex.message || \"Could not save data model group.\",\n ex.code || \"ERROR_ON_CREATE\",\n {\n ...(ex.data || {}),\n group,\n input\n }\n );\n }\n };\n const updateGroup: CmsGroupContext[\"updateGroup\"] = async (id, input) => {\n await modelGroupsPermissions.ensure({ rwd: \"w\" });\n\n const original = await getGroup(id);\n\n await modelGroupsPermissions.ensure({ owns: original.createdBy });\n\n const result = await createGroupUpdateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n /**\n * No need to continue if no values were changed\n */\n if (Object.keys(data).length === 0) {\n return original;\n }\n\n const group: CmsGroup = {\n ...original,\n ...data,\n locale: getLocale().code,\n tenant: getTenant().id,\n savedOn: new Date().toISOString()\n };\n\n try {\n await onGroupBeforeUpdate.publish({\n original,\n group\n });\n\n const updatedGroup = await storageOperations.groups.update({\n group\n });\n clearGroupsCache();\n\n await onGroupAfterUpdate.publish({\n original,\n group: updatedGroup\n });\n\n return updatedGroup;\n } catch (ex) {\n await onGroupUpdateError.publish({\n input,\n original,\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"UPDATE_ERROR\", {\n error: ex,\n original,\n group,\n input\n });\n }\n };\n const deleteGroup: CmsGroupContext[\"deleteGroup\"] = async id => {\n await modelGroupsPermissions.ensure({ rwd: \"d\" });\n\n const group = await getGroup(id);\n\n await modelGroupsPermissions.ensure({ owns: group.createdBy });\n\n try {\n await onGroupBeforeDelete.publish({\n group\n });\n\n await storageOperations.groups.delete({ group });\n clearGroupsCache();\n\n await onGroupAfterDelete.publish({\n group\n });\n } catch (ex) {\n await onGroupDeleteError.publish({\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"DELETE_ERROR\", {\n ...(ex.data || {}),\n id\n });\n }\n\n return true;\n };\n\n return {\n onGroupBeforeCreate,\n onGroupAfterCreate,\n onGroupCreateError,\n onGroupBeforeUpdate,\n onGroupAfterUpdate,\n onGroupUpdateError,\n onGroupBeforeDelete,\n onGroupAfterDelete,\n onGroupDeleteError,\n clearGroupsCache,\n getGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.getGroup\", async () => {\n return getGroup(id);\n });\n },\n listGroups: async params => {\n return context.benchmark.measure(\"headlessCms.crud.groups.listGroups\", async () => {\n return listGroups(params);\n });\n },\n createGroup: async input => {\n return context.benchmark.measure(\"headlessCms.crud.groups.createGroup\", async () => {\n return createGroup(input);\n });\n },\n updateGroup: async (id, input) => {\n return context.benchmark.measure(\"headlessCms.crud.groups.updateGroup\", async () => {\n return updateGroup(id, input);\n });\n },\n deleteGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.deleteGroup\", async () => {\n return deleteGroup(id);\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAgBA,IAAAC,eAAA,GAAAD,OAAA;AAIA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAIA,IAAAO,MAAA,GAAAP,OAAA;AAEA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,uBAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAWO,MAAMY,qBAAqB,GAAIC,MAAmC,IAAsB;EAC3F,MAAM;IACFC,SAAS;IACTC,WAAW;IACXC,SAAS;IACTC,iBAAiB;IACjBC,sBAAsB;IACtBC;EACJ,CAAC,GAAGN,MAAM;EAEV,MAAMO,WAAW,GAAG,MAAOC,KAAgB,IA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AAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAO9B,WAAW,CAACC,KAAK,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDkB,WAAW,EAAE,MAAAA,CAAOhE,EAAE,EAAE8C,KAAK,KAAK;MAC9B,OAAO1E,OAAO,CAACsG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOX,WAAW,CAAChE,EAAE,EAAE8C,KAAK,CAAC;MACjC,CAAC,CAAC;IACN,CAAC;IACD0B,WAAW,EAAE,MAAMxE,EAAE,IAAI;MACrB,OAAO5B,OAAO,CAACsG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOH,WAAW,CAACxE,EAAE,CAAC;MAC1B,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC4E,OAAA,CAAA/G,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_handlerGraphql","_CmsGroupPlugin","_pubsub","_beforeUpdate","_beforeCreate","_beforeDelete","_validation","_utils","_filterAsync","_utils2","_listGroupsFromDatabase","createModelGroupsCrud","params","getTenant","getIdentity","getLocale","storageOperations","accessControl","context","filterGroup","group","canAccessGroup","listDatabaseGroupsCache","createMemoryCache","listFilteredDatabaseGroupsCache","listPluginGroupsCache","clearGroupsCache","clear","fetchPluginGroups","tenant","locale","pluginGroups","plugins","byType","CmsGroupPlugin","type","cacheKey","createCacheKey","identity","security","isAuthorizationEnabled","id","undefined","groups","map","contentModelGroup","slug","savedOn","join","getOrSet","filter","plugin","t","l","webinyVersion","WEBINY_VERSION","filterAsync","fetchGroups","databaseGroups","listGroupsFromDatabase","filteredCacheKey","dbCacheKey","get","concat","onGroupBeforeCreate","createTopic","onGroupAfterCreate","onGroupCreateError","onGroupBeforeUpdate","onGroupAfterUpdate","onGroupUpdateError","onGroupBeforeDelete","onGroupAfterDelete","onGroupDeleteError","assignBeforeGroupCreate","assignBeforeGroupUpdate","assignBeforeGroupDelete","getGroup","ensureCanAccessGroup","withoutAuthorization","code","find","NotFoundError","listGroups","where","createGroup","input","rwd","result","createGroupCreateValidation","safeParseAsync","success","createZodError","error","data","mdbid","createdOn","Date","toISOString","createdBy","displayName","publish","create","ex","WebinyError","message","updateGroup","original","createGroupUpdateValidation","Object","keys","length","updatedGroup","update","deleteGroup","delete","benchmark","measure","exports"],"sources":["contentModelGroup.crud.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type {\n CmsContext,\n CmsGroup,\n CmsGroupContext,\n HeadlessCmsStorageOperations,\n OnGroupAfterCreateTopicParams,\n OnGroupAfterDeleteTopicParams,\n OnGroupAfterUpdateTopicParams,\n OnGroupBeforeCreateTopicParams,\n OnGroupBeforeDeleteTopicParams,\n OnGroupBeforeUpdateTopicParams,\n OnGroupCreateErrorTopicParams,\n OnGroupDeleteErrorTopicParams,\n OnGroupUpdateErrorTopicParams\n} from \"~/types\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin\";\nimport type { Tenant } from \"@webiny/api-tenancy/types\";\nimport type { I18NLocale } from \"@webiny/api-i18n/types\";\nimport type { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { assignBeforeGroupUpdate } from \"./contentModelGroup/beforeUpdate\";\nimport { assignBeforeGroupCreate } from \"./contentModelGroup/beforeCreate\";\nimport { assignBeforeGroupDelete } from \"./contentModelGroup/beforeDelete\";\nimport {\n createGroupCreateValidation,\n createGroupUpdateValidation\n} from \"~/crud/contentModelGroup/validation\";\nimport { createZodError, mdbid } from \"@webiny/utils\";\nimport { filterAsync } from \"~/utils/filterAsync\";\nimport { createCacheKey, createMemoryCache } from \"~/utils\";\nimport { listGroupsFromDatabase } from \"~/crud/contentModelGroup/listGroupsFromDatabase\";\nimport type { AccessControl } from \"./AccessControl/AccessControl\";\n\nexport interface CreateModelGroupsCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n accessControl: AccessControl;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\n\nexport const createModelGroupsCrud = (params: CreateModelGroupsCrudParams): CmsGroupContext => {\n const { getTenant, getIdentity, getLocale, storageOperations, accessControl, context } = params;\n\n const filterGroup = async (group?: CmsGroup) => {\n if (!group) {\n return false;\n }\n\n return accessControl.canAccessGroup({ group });\n };\n\n const listDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listFilteredDatabaseGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const listPluginGroupsCache = createMemoryCache<Promise<CmsGroup[]>>();\n const clearGroupsCache = (): void => {\n listPluginGroupsCache.clear();\n listDatabaseGroupsCache.clear();\n listFilteredDatabaseGroupsCache.clear();\n };\n\n const fetchPluginGroups = (tenant: string, locale: string): Promise<CmsGroup[]> => {\n const pluginGroups = context.plugins.byType<CmsGroupPlugin>(CmsGroupPlugin.type);\n\n const cacheKey = createCacheKey({\n tenant,\n locale,\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined,\n groups: pluginGroups\n .map(({ contentModelGroup: group }) => {\n return `${group.id}#${group.slug}#${group.savedOn || \"unknown\"}`;\n })\n .join(\"/\")\n });\n\n return listPluginGroupsCache.getOrSet(cacheKey, async (): Promise<CmsGroup[]> => {\n const groups = pluginGroups\n /**\n * We need to filter out groups that are not for this tenant or locale.\n * If it does not have tenant or locale define, it is for every locale and tenant\n */\n .filter(plugin => {\n const { tenant: t, locale: l } = plugin.contentModelGroup;\n if (t && t !== tenant) {\n return false;\n } else if (l && l !== locale) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant,\n locale,\n webinyVersion: context.WEBINY_VERSION\n };\n });\n return filterAsync(groups, filterGroup);\n });\n };\n\n const fetchGroups = async (tenant: string, locale: string) => {\n const pluginGroups = await fetchPluginGroups(tenant, locale);\n /**\n * Maybe we can cache based on permissions, not the identity id?\n *\n * TODO: @adrian please check if possible.\n */\n const cacheKey = createCacheKey({\n tenant,\n locale\n });\n const databaseGroups = await listDatabaseGroupsCache.getOrSet(cacheKey, async () => {\n return await listGroupsFromDatabase({\n storageOperations,\n tenant,\n locale\n });\n });\n const filteredCacheKey = createCacheKey({\n dbCacheKey: cacheKey.get(),\n identity: context.security.isAuthorizationEnabled() ? getIdentity()?.id : undefined\n });\n\n const groups = await listFilteredDatabaseGroupsCache.getOrSet(\n filteredCacheKey,\n async () => {\n return filterAsync(databaseGroups, filterGroup);\n }\n );\n\n return groups.concat(pluginGroups);\n };\n\n /**\n * Create\n */\n const onGroupBeforeCreate =\n createTopic<OnGroupBeforeCreateTopicParams>(\"cms.onGroupBeforeCreate\");\n const onGroupAfterCreate = createTopic<OnGroupAfterCreateTopicParams>(\"cms.onGroupAfterCreate\");\n const onGroupCreateError = createTopic<OnGroupCreateErrorTopicParams>(\"cms.onGroupCreateError\");\n /**\n * Update\n */\n const onGroupBeforeUpdate =\n createTopic<OnGroupBeforeUpdateTopicParams>(\"cms.onGroupBeforeUpdate\");\n const onGroupAfterUpdate = createTopic<OnGroupAfterUpdateTopicParams>(\"cms.onGroupAfterUpdate\");\n const onGroupUpdateError = createTopic<OnGroupUpdateErrorTopicParams>(\"cms.onGroupUpdateError\");\n /**\n * Delete\n */\n const onGroupBeforeDelete =\n createTopic<OnGroupBeforeDeleteTopicParams>(\"cms.onGroupBeforeDelete\");\n const onGroupAfterDelete = createTopic<OnGroupAfterDeleteTopicParams>(\"cms.onGroupAfterDelete\");\n const onGroupDeleteError = createTopic<OnGroupDeleteErrorTopicParams>(\"cms.onGroupDeleteError\");\n\n /**\n * We need to assign some default behaviors.\n */\n assignBeforeGroupCreate({\n onGroupBeforeCreate,\n plugins: context.plugins,\n storageOperations\n });\n assignBeforeGroupUpdate({\n onGroupBeforeUpdate,\n plugins: context.plugins\n });\n assignBeforeGroupDelete({\n onGroupBeforeDelete,\n plugins: context.plugins,\n storageOperations\n });\n /**\n * CRUD Methods\n */\n const getGroup: CmsGroupContext[\"getGroup\"] = async id => {\n await accessControl.ensureCanAccessGroup();\n\n const groups = await context.security.withoutAuthorization(async () => {\n return fetchGroups(getTenant().id, getLocale().code);\n });\n const group = groups.find(group => group.id === id);\n if (!group) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n\n await accessControl.ensureCanAccessGroup({ group });\n\n return group;\n };\n\n const listGroups: CmsGroupContext[\"listGroups\"] = async params => {\n const { where } = params || {};\n\n const { tenant, locale } = where || {};\n\n await accessControl.ensureCanAccessGroup();\n\n return fetchGroups(tenant || getTenant().id, locale || getLocale().code);\n };\n\n const createGroup: CmsGroupContext[\"createGroup\"] = async input => {\n await accessControl.ensureCanAccessGroup({ rwd: \"w\" });\n\n const result = await createGroupCreateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n const identity = getIdentity();\n\n const id = data.id || mdbid();\n const group: CmsGroup = {\n ...data,\n id,\n tenant: getTenant().id,\n locale: getLocale().code,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n webinyVersion: context.WEBINY_VERSION\n };\n\n await accessControl.ensureCanAccessGroup({ group, rwd: \"w\" });\n\n try {\n await onGroupBeforeCreate.publish({\n group\n });\n\n const result = await storageOperations.groups.create({\n group\n });\n\n clearGroupsCache();\n\n await onGroupAfterCreate.publish({\n group: result\n });\n\n return group;\n } catch (ex) {\n await onGroupCreateError.publish({\n input,\n group,\n error: ex\n });\n throw new WebinyError(\n ex.message || \"Could not save data model group.\",\n ex.code || \"ERROR_ON_CREATE\",\n {\n ...(ex.data || {}),\n group,\n input\n }\n );\n }\n };\n const updateGroup: CmsGroupContext[\"updateGroup\"] = async (id, input) => {\n await accessControl.ensureCanAccessGroup({ rwd: \"w\" });\n\n const original = await getGroup(id);\n\n await accessControl.ensureCanAccessGroup({ group: original });\n\n const result = await createGroupUpdateValidation().safeParseAsync(input);\n\n if (!result.success) {\n throw createZodError(result.error);\n }\n const data = result.data;\n\n /**\n * No need to continue if no values were changed\n */\n if (Object.keys(data).length === 0) {\n return original;\n }\n\n const group: CmsGroup = {\n ...original,\n ...data,\n locale: getLocale().code,\n tenant: getTenant().id,\n savedOn: new Date().toISOString()\n };\n\n try {\n await onGroupBeforeUpdate.publish({\n original,\n group\n });\n\n const updatedGroup = await storageOperations.groups.update({\n group\n });\n clearGroupsCache();\n\n await onGroupAfterUpdate.publish({\n original,\n group: updatedGroup\n });\n\n return updatedGroup;\n } catch (ex) {\n await onGroupUpdateError.publish({\n input,\n original,\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"UPDATE_ERROR\", {\n error: ex,\n original,\n group,\n input\n });\n }\n };\n const deleteGroup: CmsGroupContext[\"deleteGroup\"] = async id => {\n await accessControl.ensureCanAccessGroup({ rwd: \"d\" });\n\n const group = await getGroup(id);\n\n await accessControl.ensureCanAccessGroup({ group });\n\n try {\n await onGroupBeforeDelete.publish({\n group\n });\n\n await storageOperations.groups.delete({ group });\n clearGroupsCache();\n\n await onGroupAfterDelete.publish({\n group\n });\n } catch (ex) {\n await onGroupDeleteError.publish({\n group,\n error: ex\n });\n throw new WebinyError(ex.message, ex.code || \"DELETE_ERROR\", {\n ...(ex.data || {}),\n id\n });\n }\n\n return true;\n };\n\n return {\n onGroupBeforeCreate,\n onGroupAfterCreate,\n onGroupCreateError,\n onGroupBeforeUpdate,\n onGroupAfterUpdate,\n onGroupUpdateError,\n onGroupBeforeDelete,\n onGroupAfterDelete,\n onGroupDeleteError,\n clearGroupsCache,\n getGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.getGroup\", async () => {\n return getGroup(id);\n });\n },\n listGroups: async params => {\n return context.benchmark.measure(\"headlessCms.crud.groups.listGroups\", async () => {\n return listGroups(params);\n });\n },\n createGroup: async input => {\n return context.benchmark.measure(\"headlessCms.crud.groups.createGroup\", async () => {\n return createGroup(input);\n });\n },\n updateGroup: async (id, input) => {\n return context.benchmark.measure(\"headlessCms.crud.groups.updateGroup\", async () => {\n return updateGroup(id, input);\n });\n },\n deleteGroup: async id => {\n return context.benchmark.measure(\"headlessCms.crud.groups.deleteGroup\", async () => {\n return deleteGroup(id);\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAgBA,IAAAE,eAAA,GAAAF,OAAA;AAIA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAIA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,uBAAA,GAAAX,OAAA;AAYO,MAAMY,qBAAqB,GAAIC,MAAmC,IAAsB;EAC3F,MAAM;IAAEC,SAAS;IAAEC,WAAW;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC,aAAa;IAAEC;EAAQ,CAAC,GAAGN,MAAM;EAE/F,MAAMO,WAAW,GAAG,MAAOC,KAAgB,IAAK;IAC5C,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,KAAK;IAChB;IAEA,OAAOH,aAAa,CAACI,cAAc,CAAC;MAAED;IAAM,CAAC,CAAC;EAClD,CAAC;EAED,MAAME,uBAAuB,GAAG,IAAAC,yBAAiB,EAAsB,CAAC;EACxE,MAAMC,+BAA+B,GAAG,IAAAD,yBAAiB,EAAsB,CAAC;EAChF,MAAME,qBAAqB,GAAG,IAAAF,yBAAiB,EAAsB,CAAC;EACtE,MAAMG,gBAAgB,GAAGA,CAAA,KAAY;IACjCD,qBAAqB,CAACE,KAAK,CAAC,CAAC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AAkB;IAClBC,mBAAmB;IACnBC,kBAAkB;IAClBC,kBAAkB;IAClBC,mBAAmB;IACnBC,kBAAkB;IAClBC,kBAAkB;IAClB/C,gBAAgB;IAChBmD,QAAQ,EAAE,MAAMpC,EAAE,IAAI;MAClB,OAAOvB,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,kCAAkC,EAAE,YAAY;QAC7E,OAAOxC,QAAQ,CAACpC,EAAE,CAAC;MACvB,CAAC,CAAC;IACN,CAAC;IACD0C,UAAU,EAAE,MAAMvE,MAAM,IAAI;MACxB,OAAOM,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,oCAAoC,EAAE,YAAY;QAC/E,OAAOlC,UAAU,CAACvE,MAAM,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDyE,WAAW,EAAE,MAAMC,KAAK,IAAI;MACxB,OAAOpE,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOhC,WAAW,CAACC,KAAK,CAAC;MAC7B,CAAC,CAAC;IACN,CAAC;IACDoB,WAAW,EAAE,MAAAA,CAAOjE,EAAE,EAAE6C,KAAK,KAAK;MAC9B,OAAOpE,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOX,WAAW,CAACjE,EAAE,EAAE6C,KAAK,CAAC;MACjC,CAAC,CAAC;IACN,CAAC;IACD4B,WAAW,EAAE,MAAMzE,EAAE,IAAI;MACrB,OAAOvB,OAAO,CAACkG,SAAS,CAACC,OAAO,CAAC,qCAAqC,EAAE,YAAY;QAChF,OAAOH,WAAW,CAACzE,EAAE,CAAC;MAC1B,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC6E,OAAA,CAAA3G,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { CmsContext, CmsSystemContext, HeadlessCmsStorageOperations } from "../types";
2
- import { Tenant } from "@webiny/api-tenancy/types";
3
- import { SecurityIdentity } from "@webiny/api-security/types";
4
- import { I18NLocale } from "@webiny/api-i18n/types";
1
+ import type { CmsContext, CmsSystemContext, HeadlessCmsStorageOperations } from "../types";
2
+ import type { Tenant } from "@webiny/api-tenancy/types";
3
+ import type { SecurityIdentity } from "@webiny/api-security/types";
4
+ import type { I18NLocale } from "@webiny/api-i18n/types";
5
5
  interface CreateSystemCrudParams {
6
6
  getTenant: () => Tenant;
7
7
  getLocale: () => I18NLocale;
@@ -107,6 +107,16 @@ const createSystemCrud = params => {
107
107
  tenant: getTenant().id,
108
108
  locale: getLocale().code
109
109
  });
110
+
111
+ /**
112
+ * TODO: Implement this event in a better way, because this is easy to overlook and forget to update
113
+ * when new apps are added and have their own installers.
114
+ *
115
+ * Headless CMS is the last app that has an installer. Once its installation is finished,
116
+ * we need to notify the system that tenant is now ready to use, because many external plugins
117
+ * insert initial tenant data into various apps, copy data from other tenants, etc.
118
+ */
119
+ await context.tenancy.onTenantAfterInstall.publish({});
110
120
  } catch (ex) {
111
121
  await onSystemInstallError.publish({
112
122
  error: ex,
@@ -1 +1 @@
1
- {"version":3,"names":["_apiSecurity","require","_error","_interopRequireDefault","_pubsub","initialContentModelGroup","name","slug","description","icon","createSystemCrud","params","getTenant","getLocale","storageOperations","context","getIdentity","onSystemBeforeInstall","createTopic","onSystemAfterInstall","onSystemInstallError","getVersion","system","get","tenant","id","version","setVersion","original","create","update","getSystemVersion","setSystemVersion","installSystem","identity","NotAuthorizedError","publish","locale","code","cms","createGroup","ex","WebinyError","message","group","WEBINY_VERSION","error","data","exports"],"sources":["system.crud.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport WebinyError from \"@webiny/error\";\nimport {\n OnSystemAfterInstallTopicParams,\n OnSystemBeforeInstallTopicParams,\n CmsContext,\n CmsSystem,\n CmsSystemContext,\n HeadlessCmsStorageOperations,\n OnSystemInstallErrorTopicParams\n} from \"~/types\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\n\nconst initialContentModelGroup = {\n name: \"Ungrouped\",\n slug: \"ungrouped\",\n description: \"A generic content model group\",\n icon: \"fas/star\"\n};\n\ninterface CreateSystemCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\nexport const createSystemCrud = (params: CreateSystemCrudParams): CmsSystemContext => {\n const { getTenant, getLocale, storageOperations, context, getIdentity } = params;\n\n const onSystemBeforeInstall = createTopic<OnSystemBeforeInstallTopicParams>(\n \"cms.onSystemBeforeInstall\"\n );\n const onSystemAfterInstall = createTopic<OnSystemAfterInstallTopicParams>(\n \"cms.onSystemAfterInstall\"\n );\n\n const onSystemInstallError = createTopic<OnSystemInstallErrorTopicParams>(\n \"cms.onSystemInstallError\"\n );\n\n const getVersion = async () => {\n if (!getTenant()) {\n return null;\n }\n\n const system = await storageOperations.system.get({\n tenant: getTenant().id\n });\n\n return system?.version || null;\n };\n\n const setVersion = async (version: string) => {\n const original = await storageOperations.system.get({\n tenant: getTenant().id\n });\n const system: CmsSystem = {\n ...(original || {}),\n version,\n tenant: getTenant().id\n };\n if (!original) {\n await storageOperations.system.create({\n system\n });\n return;\n }\n await storageOperations.system.update({\n system\n });\n };\n\n return {\n /**\n * Lifecycle Events.\n */\n onSystemBeforeInstall,\n onSystemAfterInstall,\n onSystemInstallError,\n getSystemVersion: getVersion,\n setSystemVersion: setVersion,\n installSystem: async (): Promise<void> => {\n const identity = getIdentity();\n if (!identity) {\n throw new NotAuthorizedError();\n }\n\n const version = await getVersion();\n if (version) {\n return;\n }\n try {\n /**\n * First trigger before install event.\n */\n await onSystemBeforeInstall.publish({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n\n /**\n * Add default content model group.\n */\n try {\n await context.cms.createGroup(initialContentModelGroup);\n } catch (ex) {\n throw new WebinyError(\n ex.message,\n \"CMS_INSTALLATION_CONTENT_MODEL_GROUP_ERROR\",\n {\n group: initialContentModelGroup\n }\n );\n }\n\n const system: CmsSystem = {\n version: context.WEBINY_VERSION,\n tenant: getTenant().id\n };\n /**\n * We need to create the system data.\n */\n await storageOperations.system.create({\n system\n });\n /**\n * And trigger after install event.\n */\n await onSystemAfterInstall.publish({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n } catch (ex) {\n await onSystemInstallError.publish({\n error: ex,\n tenant: getTenant().id,\n locale: getLocale().code\n });\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAYA,IAAAG,OAAA,GAAAH,OAAA;AAGA,MAAMI,wBAAwB,GAAG;EAC7BC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,WAAW;EACjBC,WAAW,EAAE,+BAA+B;EAC5CC,IAAI,EAAE;AACV,CAAC;AASM,MAAMC,gBAAgB,GAAIC,MAA8B,IAAuB;EAClF,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC,iBAAiB;IAAEC,OAAO;IAAEC;EAAY,CAAC,GAAGL,MAAM;EAEhF,MAAMM,qBAAqB,GAAG,IAAAC,mBAAW,EACrC,2BACJ,CAAC;EACD,MAAMC,oBAAoB,GAAG,IAAAD,mBAAW,EACpC,0BACJ,CAAC;EAED,MAAME,oBAAoB,GAAG,IAAAF,mBAAW,EACpC,0BACJ,CAAC;EAED,MAAMG,UAAU,GAAG,MAAAA,CAAA,KAAY;IAC3B,IAAI,CAACT,SAAS,CAAC,CAAC,EAAE;MACd,OAAO,IAAI;IACf;IAEA,MAAMU,MAAM,GAAG,MAAMR,iBAAiB,CAACQ,MAAM,CAACC,GAAG,CAAC;MAC9CC,MAAM,EAAEZ,SAAS,CAAC,CAAC,CAACa;IACx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WAAW,CAACnC,wBAAwB,CAAC;QAC3D,CAAC,CAAC,OAAOoC,EAAE,EAAE;UACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,EACV,4CAA4C,EAC5C;YACIC,KAAK,EAAEvC;UACX,CACJ,CAAC;QACL;QAEA,MAAMiB,MAAiB,GAAG;UACtBI,OAAO,EAAEX,OAAO,CAAC8B,cAAc;UAC/BrB,MAAM,EAAEZ,SAAS,CAAC,CAAC,CAACa;QACxB,CAAC;QACD;AAChB;AACA;QACgB,MAAMX,iBAAiB,CAACQ,MAAM,CAACO,MAAM,CAAC;UAClCP;QACJ,CAAC,CAAC;QACF;AAChB;AACA;QACgB,MAAMH,oBAAoB,CAACiB,OAAO,CAAC;UAC/BZ,MAAM,EAAEZ,SAAS,CAAC,CAAC,CAACa,EAAE;UACtBY,MAAM,EAAExB,SAAS,CAAC,CAAC,CAACyB;QACxB,CAAC,CAAC;MACN,CAAC,CAAC,OAAOG,EAAE,EAAE;QACT,MAAMrB,oBAAoB,CAACgB,OAAO,CAAC;UAC/BU,KAAK,EAAEL,EAAE;UACTjB,MAAM,EAAEZ,SAAS,CAAC,CAAC,CAACa,EAAE;UACtBY,MAAM,EAAExB,SAAS,CAAC,CAAC,CAACyB;QACxB,CAAC,CAAC;QACF,MAAM,IAAII,cAAW,CAACD,EAAE,CAACE,OAAO,EAAEF,EAAE,CAACH,IAAI,EAAEG,EAAE,CAACM,IAAI,CAAC;MACvD;IACJ;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAtC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_apiSecurity","require","_error","_interopRequireDefault","_pubsub","initialContentModelGroup","name","slug","description","icon","createSystemCrud","params","getTenant","getLocale","storageOperations","context","getIdentity","onSystemBeforeInstall","createTopic","onSystemAfterInstall","onSystemInstallError","getVersion","system","get","tenant","id","version","setVersion","original","create","update","getSystemVersion","setSystemVersion","installSystem","identity","NotAuthorizedError","publish","locale","code","cms","createGroup","ex","WebinyError","message","group","WEBINY_VERSION","tenancy","onTenantAfterInstall","error","data","exports"],"sources":["system.crud.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n OnSystemAfterInstallTopicParams,\n OnSystemBeforeInstallTopicParams,\n CmsContext,\n CmsSystem,\n CmsSystemContext,\n HeadlessCmsStorageOperations,\n OnSystemInstallErrorTopicParams\n} from \"~/types\";\nimport type { Tenant } from \"@webiny/api-tenancy/types\";\nimport type { SecurityIdentity } from \"@webiny/api-security/types\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport type { I18NLocale } from \"@webiny/api-i18n/types\";\n\nconst initialContentModelGroup = {\n name: \"Ungrouped\",\n slug: \"ungrouped\",\n description: \"A generic content model group\",\n icon: \"fas/star\"\n};\n\ninterface CreateSystemCrudParams {\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n storageOperations: HeadlessCmsStorageOperations;\n context: CmsContext;\n getIdentity: () => SecurityIdentity;\n}\nexport const createSystemCrud = (params: CreateSystemCrudParams): CmsSystemContext => {\n const { getTenant, getLocale, storageOperations, context, getIdentity } = params;\n\n const onSystemBeforeInstall = createTopic<OnSystemBeforeInstallTopicParams>(\n \"cms.onSystemBeforeInstall\"\n );\n const onSystemAfterInstall = createTopic<OnSystemAfterInstallTopicParams>(\n \"cms.onSystemAfterInstall\"\n );\n\n const onSystemInstallError = createTopic<OnSystemInstallErrorTopicParams>(\n \"cms.onSystemInstallError\"\n );\n\n const getVersion = async () => {\n if (!getTenant()) {\n return null;\n }\n\n const system = await storageOperations.system.get({\n tenant: getTenant().id\n });\n\n return system?.version || null;\n };\n\n const setVersion = async (version: string) => {\n const original = await storageOperations.system.get({\n tenant: getTenant().id\n });\n const system: CmsSystem = {\n ...(original || {}),\n version,\n tenant: getTenant().id\n };\n if (!original) {\n await storageOperations.system.create({\n system\n });\n return;\n }\n await storageOperations.system.update({\n system\n });\n };\n\n return {\n /**\n * Lifecycle Events.\n */\n onSystemBeforeInstall,\n onSystemAfterInstall,\n onSystemInstallError,\n getSystemVersion: getVersion,\n setSystemVersion: setVersion,\n installSystem: async (): Promise<void> => {\n const identity = getIdentity();\n if (!identity) {\n throw new NotAuthorizedError();\n }\n\n const version = await getVersion();\n if (version) {\n return;\n }\n try {\n /**\n * First trigger before install event.\n */\n await onSystemBeforeInstall.publish({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n\n /**\n * Add default content model group.\n */\n try {\n await context.cms.createGroup(initialContentModelGroup);\n } catch (ex) {\n throw new WebinyError(\n ex.message,\n \"CMS_INSTALLATION_CONTENT_MODEL_GROUP_ERROR\",\n {\n group: initialContentModelGroup\n }\n );\n }\n\n const system: CmsSystem = {\n version: context.WEBINY_VERSION,\n tenant: getTenant().id\n };\n /**\n * We need to create the system data.\n */\n await storageOperations.system.create({\n system\n });\n /**\n * And trigger after install event.\n */\n await onSystemAfterInstall.publish({\n tenant: getTenant().id,\n locale: getLocale().code\n });\n\n /**\n * TODO: Implement this event in a better way, because this is easy to overlook and forget to update\n * when new apps are added and have their own installers.\n *\n * Headless CMS is the last app that has an installer. Once its installation is finished,\n * we need to notify the system that tenant is now ready to use, because many external plugins\n * insert initial tenant data into various apps, copy data from other tenants, etc.\n */\n await context.tenancy.onTenantAfterInstall.publish({});\n } catch (ex) {\n await onSystemInstallError.publish({\n error: ex,\n tenant: getTenant().id,\n locale: getLocale().code\n });\n throw new WebinyError(ex.message, ex.code, ex.data);\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAYA,IAAAG,OAAA,GAAAH,OAAA;AAGA,MAAMI,wBAAwB,GAAG;EAC7BC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,WAAW;EACjBC,WAAW,EAAE,+BAA+B;EAC5CC,IAAI,EAAE;AACV,CAAC;AASM,MAAMC,gBAAgB,GAAIC,MAA8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,CAAC,CAAC,OAAOK,EAAE,EAAE;QACT,MAAMrB,oBAAoB,CAACgB,OAAO,CAAC;UAC/BY,KAAK,EAAEP,EAAE;UACTjB,MAAM,EAAEZ,SAAS,CAAC,CAAC,CAACa,EAAE;UACtBY,MAAM,EAAExB,SAAS,CAAC,CAAC,CAACyB;QACxB,CAAC,CAAC;QACF,MAAM,IAAII,cAAW,CAACD,EAAE,CAACE,OAAO,EAAEF,EAAE,CAACH,IAAI,EAAEG,EAAE,CAACQ,IAAI,CAAC;MACvD;IACJ;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAxC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { HeadlessCmsExportStructure } from "../types";
2
- import { CmsContext } from "../../types";
1
+ import type { HeadlessCmsExportStructure } from "../types";
2
+ import type { CmsContext } from "../../types";
3
3
  export declare const createExportStructureContext: (context: CmsContext) => HeadlessCmsExportStructure;
@@ -1 +1 @@
1
- {"version":3,"names":["_sanitize","require","createExportStructureContext","context","params","models","modelIdList","groups","cms","listGroups","map","sanitizeGroup","listModels","filter","model","isPrivate","fields","length","includes","modelId","group","find","id","sanitizeModel","some","exports"],"sources":["exporting.ts"],"sourcesContent":["import { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types\";\nimport { CmsContext } from \"~/types\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n const groups = (await context.cms.listGroups()).map(sanitizeGroup);\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\n */\n const models = (await context.cms.listModels())\n .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.id === model.group.id);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.id);\n }),\n models\n };\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,4BAA4B,GAAIC,OAAmB,IAAiC;EAC7F,OAAO,MAAMC,MAAM,IAAI;IACnB,MAAM;MAAEC,MAAM,EAAEC;IAAY,CAAC,GAAGF,MAAM;IACtC,MAAMG,MAAM,GAAG,CAAC,MAAMJ,OAAO,CAACK,GAAG,CAACC,UAAU,CAAC,CAAC,EAAEC,GAAG,CAACC,uBAAa,CAAC;IAClE;AACR;AACA;AACA;AACA;AACA;AACA;IACQ,MAAMN,MAAM,GAAG,CAAC,MAAMF,OAAO,CAACK,GAAG,CAACI,UAAU,CAAC,CAAC,EACzCC,MAAM,CAACC,KAAK,IAAI;MACb,IAAIA,KAAK,CAACC,SAAS,EAAE;QACjB,OAAO,KAAK;MAChB,CAAC,MAAM,IAAI,CAACD,KAAK,CAACE,MAAM,EAAEC,MAAM,EAAE;QAC9B,OAAO,KAAK;MAChB,CAAC,MAAM,IAAI,CAACX,WAAW,EAAEW,MAAM,EAAE;QAC7B,OAAO,IAAI;MACf;MACA,OAAOX,WAAW,CAACY,QAAQ,CAACJ,KAAK,CAACK,OAAO,CAAC;IAC9C,CAAC,CAAC,CACDT,GAAG,CAACI,KAAK,IAAI;MACV,MAAMM,KAAK,GAAGb,MAAM,CAACc,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,EAAE,KAAKR,KAAK,CAACM,KAAK,CAACE,EAAE,CAAC;MAC/D,IAAI,CAACF,KAAK,EAAE;QACR,OAAO,IAAI;MACf;MACA,OAAO,IAAAG,uBAAa,EAACH,KAAK,EAAEN,KAAK,CAAC;IACtC,CAAC,CAAC,CACDD,MAAM,CAAEC,KAAK,IAAiC;MAC3C,OAAO,CAAC,CAACA,KAAK;IAClB,CAAC,CAAC;IAEN,OAAO;MACHP,MAAM,EAAEA,MAAM,CAACM,MAAM,CAACO,KAAK,IAAI;QAC3B,OAAOf,MAAM,CAACmB,IAAI,CAACV,KAAK,IAAIA,KAAK,CAACM,KAAK,KAAKA,KAAK,CAACE,EAAE,CAAC;MACzD,CAAC,CAAC;MACFjB;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAACoB,OAAA,CAAAvB,4BAAA,GAAAA,4BAAA"}
1
+ {"version":3,"names":["_sanitize","require","createExportStructureContext","context","params","models","modelIdList","groups","cms","listGroups","map","sanitizeGroup","listModels","filter","model","isPrivate","fields","length","includes","modelId","group","find","id","sanitizeModel","some","exports"],"sources":["exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types\";\nimport type { CmsContext } from \"~/types\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n const groups = (await context.cms.listGroups()).map(sanitizeGroup);\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\n */\n const models = (await context.cms.listModels())\n .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.id === model.group.id);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.id);\n }),\n models\n };\n };\n};\n"],"mappings":";;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,4BAA4B,GAAIC,OAAmB,IAAiC;EAC7F,OAAO,MAAMC,MAAM,IAAI;IACnB,MAAM;MAAEC,MAAM,EAAEC;IAAY,CAA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,3 +1,3 @@
1
- import { HeadlessCmsImport } from "../types";
2
- import { CmsContext } from "../../types";
1
+ import type { HeadlessCmsImport } from "../types";
2
+ import type { CmsContext } from "../../types";
3
3
  export declare const createImportCrud: (context: CmsContext) => HeadlessCmsImport;
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_importData","_validateInput","fetchGroupsAndModels","context","security","withoutAuthorization","groups","cms","listGroups","models","listModels","createImportCrud","validate","params","data","validated","validateInput","error","message","structure","WebinyError","imported","importData","modelError","find","model","exports"],"sources":["importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { HeadlessCmsImport, ValidCmsGroupResult, ValidCmsModelResult } from \"~/export/types\";\nimport { CmsContext } from \"~/types\";\nimport { importData } from \"./imports/importData\";\nimport { validateInput } from \"./imports/validateInput\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.security.withoutAuthorization(async () => {\n return {\n groups: await context.cms.listGroups(),\n models: await context.cms.listModels()\n };\n });\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAA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ClCV,MAAM;QACNG,MAAM;QACNK;MACJ,CAAC,CAAC;MACF,IAAIC,SAAS,CAACE,KAAK,EAAE;QACjB,MAAM,IAAIG,cAAW,CAACL,SAAS,CAACE,KAAK,EAAE,kBAAkB,CAAC;MAC9D;MAEA,MAAMI,QAAQ,GAAG,MAAM,IAAAC,sBAAU,EAAC;QAC9BnB,OAAO;QACPG,MAAM,EAAES,SAAS,CAACT,MAA+B;QACjDG,MAAM,EAAEM,SAAS,CAACN;MACtB,CAAC,CAAC;MAEF,MAAMc,UAAU,GAAGF,QAAQ,CAACZ,MAAM,CAACe,IAAI,CAACC,KAAK,IAAI,CAAC,CAACA,KAAK,CAACR,KAAK,CAAC;MAC/D,MAAMA,KAAK,GAAGI,QAAQ,CAACJ,KAAK,IAAIM,UAAU;MAE1C,OAAO;QACH,GAAGF,QAAQ;QACXH,OAAO,EAAED,KAAK,GAAG,IAAI,GAAG;MAC5B,CAAC;IACL;EACJ,CAAC;AACL,CAAC;AAACS,OAAA,CAAAf,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_importData","_validateInput","fetchGroupsAndModels","context","security","withoutAuthorization","groups","cms","listGroups","models","listModels","createImportCrud","validate","params","data","validated","validateInput","error","message","structure","WebinyError","imported","importData","modelError","find","model","exports"],"sources":["importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { HeadlessCmsImport, ValidCmsGroupResult, ValidCmsModelResult } from \"~/export/types\";\nimport type { CmsContext } from \"~/types\";\nimport { importData } from \"./imports/importData\";\nimport { validateInput } from \"./imports/validateInput\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.security.withoutAuthorization(async () => {\n return {\n groups: await context.cms.listGroups(),\n models: await context.cms.listModels()\n };\n });\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,oBAAoB,GAAG,MAAOC,OAAmB,IAAK;EACxD,OAAO,MAAMA,OAAO,CAACC,QAAQ,CAACC,oBAAoB,CAAC,YAAY;IAC3D,OAAO;MACHC,MAAM,EAAE,MAAMH,OAAO,CAACI,GAAG,CAACC,UAAU,CAAC,CAAC;MACtCC,MAAM,EAAE,MAAMN,OAAO,CAACI,GAAG,CAACG,UAAU,CAAC;IACzC,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAEM,MAAMC,gBAAgB,GAAIR,OAAmB,IAAwB;EACxE,OAAO;IACHS,QAAQ,EAAE,MAAMC,MAAM,IAAI;MACtB,MAAM;QAAEC;MAAK,CAAC,GAAGD,MAAM;MAEvB,MAAM;QAAEP,MAAM;QAAEG;MAAO,CAAC,GAAG,MAAMP,oBAAoB,CAACC,OAAO,CAAC;MAE9D,MAAMY,SAAS,GAAG,MAAM,IAAAC,4BAAa,EAAC;QAClCV,MAAM;QACNG,MAAM;QACNK;MACJ,CAAC,CAAC;MACF,IAAIC,SAAS,CAACE,KAAK,EAAE;QACjB,OAAO;UACHX,MAAM,EAAES,SAAS,CAACT,MAAM;UACxBG,MAAM,EAAEM,SAAS,CAACN,MAAM;UACxBS,OAAO,EAAEH,SAAS,CAACE;QACvB,CAAC;MACL;MAEA,OAAO;QACHX,MAAM,EAAES,SAAS,CAACT,MAAM;QACxBG,MAAM,EAAEM,SAAS,CAACN,MAAM;QACxBS,OAAO,EAAE;MACb,CAAC;IACL,CAAC;IACDC,SAAS,EAAE,MAAMN,MAAM,IAAI;MACvB,MAAM;QAAEC;MAAK,CAAC,GAAGD,MAAM;MAEvB,MAAM;QAAEP,MAAM;QAAEG;MAAO,CAAC,GAAG,MAAMP,oBAAoB,CAACC,OAAO,CAAC;MAE9D,MAAMY,SAAS,GAAG,MAAM,IAAAC,4BAAa,EAAC;QAClCV,MAAM;QACNG,MAAM;QACNK;MACJ,CAAC,CAAC;MACF,IAAIC,SAAS,CAACE,KAAK,EAAE;QACjB,MAAM,IAAIG,cAAW,CAACL,SAAS,CAACE,KAAK,EAAE,kBAAkB,CAAC;MAC9D;MAEA,MAAMI,QAAQ,GAAG,MAAM,IAAAC,sBAAU,EAAC;QAC9BnB,OAAO;QACPG,MAAM,EAAES,SAAS,CAACT,MAA+B;QACjDG,MAAM,EAAEM,SAAS,CAACN;MACtB,CAAC,CAAC;MAEF,MAAMc,UAAU,GAAGF,QAAQ,CAACZ,MAAM,CAACe,IAAI,CAACC,KAAK,IAAI,CAAC,CAACA,KAAK,CAACR,KAAK,CAAC;MAC/D,MAAMA,KAAK,GAAGI,QAAQ,CAACJ,KAAK,IAAIM,UAAU;MAE1C,OAAO;QACH,GAAGF,QAAQ;QACXH,OAAO,EAAED,KAAK,GAAG,IAAI,GAAG;MAC5B,CAAC;IACL;EACJ,CAAC;AACL,CAAC;AAACS,OAAA,CAAAf,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { CmsGroupImportResult, CmsModelImportResult, ValidCmsGroupResult, ValidCmsModelResult } from "../../types";
2
- import { CmsContext } from "../../../types";
1
+ import type { CmsGroupImportResult, CmsModelImportResult, ValidCmsGroupResult, ValidCmsModelResult } from "../../types";
2
+ import type { CmsContext } from "../../../types";
3
3
  interface Params {
4
4
  context: CmsContext;
5
5
  groups: ValidCmsGroupResult[];
@@ -1 +1 @@
1
- {"version":3,"names":["_importGroups","require","_importModels","getGroup","params","validated","imported","target","group","find","id","validatedGroup","importData","context","groups","importGroups","models","importModels","map","model","exports"],"sources":["importData.ts"],"sourcesContent":["import {\n CmsGroupImportResult,\n CmsModelImportResult,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types\";\nimport { CmsContext } from \"~/types\";\nimport { importGroups } from \"./importGroups\";\nimport { importModels } from \"./importModels\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n models: ValidCmsModelResult[];\n}\n\ninterface Response {\n groups: CmsGroupImportResult[];\n models: CmsModelImportResult[];\n error?: string;\n}\n\ninterface GetGroupParams {\n validated: ValidCmsGroupResult[];\n imported: CmsGroupImportResult[];\n target: string;\n}\n\nconst getGroup = (params: GetGroupParams) => {\n const { validated, imported, target } = params;\n const group = imported.find(group => {\n return group.group.id === target;\n });\n if (group) {\n return group.group.id;\n }\n const validatedGroup = validated.find(group => {\n return group.group.id === target || group.target === target;\n });\n return validatedGroup?.target || validatedGroup?.group.id;\n};\n\nexport const importData = async (params: Params): Promise<Response> => {\n const { context } = params;\n\n const groups = await importGroups(params);\n\n const models = await importModels({\n context,\n models: params.models.map(model => {\n const group = getGroup({\n validated: params.groups,\n imported: groups,\n target: model.model.group\n });\n return {\n ...model,\n group: group || model.model.group\n };\n })\n });\n\n return {\n groups,\n models\n };\n};\n"],"mappings":";;;;;;AAOA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAoBA,MAAME,QAAQ,GAAIC,MAAsB,IAAK;EACzC,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAC9C,MAAMI,KAAK,GAAGF,QAAQ,CAACG,IAAI,CAACD,KAAK,IAAI;IACjC,OAAOA,KAAK,CAACA,KAAK,CAACE,EAAE,KAAKH,MAAM;EACpC,CAAC,CAAC;EACF,IAAIC,KAAK,EAAE;IACP,OAAOA,KAAK,CAACA,KAAK,CAACE,EAAE;EACzB;EACA,MAAMC,cAAc,GAAGN,SAAS,CAACI,IAAI,CAACD,KAAK,IAAI;IAC3C,OAAOA,KAAK,CAACA,KAAK,CAACE,EAAE,KAAKH,MAAM,IAAIC,KAAK,CAACD,MAAM,KAAKA,MAAM;EAC/D,CAAC,CAAC;EACF,OAAOI,cAAc,EAAEJ,MAAM,IAAII,cAAc,EAAEH,KAAK,CAACE,EAAE;AAC7D,CAAC;AAEM,MAAME,UAAU,GAAG,MAAOR,MAAc,IAAwB;EACnE,MAAM;IAAES;EAAQ,CAAC,GAAGT,MAAM;EAE1B,MAAMU,MAAM,GAAG,MAAM,IAAAC,0BAAY,EAACX,MAAM,CAAC;EAEzC,MAAMY,MAAM,GAAG,MAAM,IAAAC,0BAAY,EAAC;IAC9BJ,OAAO;IACPG,MAAM,EAAEZ,MAAM,CAACY,MAAM,CAACE,GAAG,CAACC,KAAK,IAAI;MAC/B,MAAMX,KAAK,GAAGL,QAAQ,CAAC;QACnBE,SAAS,EAAED,MAAM,CAACU,MAAM;QACxBR,QAAQ,EAAEQ,MAAM;QAChBP,MAAM,EAAEY,KAAK,CAACA,KAAK,CAACX;MACxB,CAAC,CAAC;MACF,OAAO;QACH,GAAGW,KAAK;QACRX,KAAK,EAAEA,KAAK,IAAIW,KAAK,CAACA,KAAK,CAACX;MAChC,CAAC;IACL,CAAC;EACL,CAAC,CAAC;EAEF,OAAO;IACHM,MAAM;IACNE;EACJ,CAAC;AACL,CAAC;AAACI,OAAA,CAAAR,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_importGroups","require","_importModels","getGroup","params","validated","imported","target","group","find","id","validatedGroup","importData","context","groups","importGroups","models","importModels","map","model","exports"],"sources":["importData.ts"],"sourcesContent":["import type {\n CmsGroupImportResult,\n CmsModelImportResult,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types\";\nimport type { CmsContext } from \"~/types\";\nimport { importGroups } from \"./importGroups\";\nimport { importModels } from \"./importModels\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n models: ValidCmsModelResult[];\n}\n\ninterface Response {\n groups: CmsGroupImportResult[];\n models: CmsModelImportResult[];\n error?: string;\n}\n\ninterface GetGroupParams {\n validated: ValidCmsGroupResult[];\n imported: CmsGroupImportResult[];\n target: string;\n}\n\nconst getGroup = (params: GetGroupParams) => {\n const { validated, imported, target } = params;\n const group = imported.find(group => {\n return group.group.id === target;\n });\n if (group) {\n return group.group.id;\n }\n const validatedGroup = validated.find(group => {\n return group.group.id === target || group.target === target;\n });\n return validatedGroup?.target || validatedGroup?.group.id;\n};\n\nexport const importData = async (params: Params): Promise<Response> => {\n const { context } = params;\n\n const groups = await importGroups(params);\n\n const models = await importModels({\n context,\n models: params.models.map(model => {\n const group = getGroup({\n validated: params.groups,\n imported: groups,\n target: model.model.group\n });\n return {\n ...model,\n group: group || model.model.group\n };\n })\n });\n\n return {\n groups,\n models\n };\n};\n"],"mappings":";;;;;;AAOA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAoBA,MAAME,QAAQ,GAAIC,MAAsB,IAAK;EACzC,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAC9C,MAAMI,KAAK,GAAGF,QAAQ,CAACG,IAAI,CAACD,KAAK,IAAI;IACjC,OAAOA,KAAK,CAACA,KAAK,CAACE,EAAE,KAAKH,MAAM;EACpC,CAAC,CAAC;EACF,IAAIC,KAAK,EAAE;IACP,OAAOA,KAAK,CAACA,KAAK,CAACE,EAAE;EACzB;EACA,MAAMC,cAAc,GAAGN,SAAS,CAACI,IAAI,CAACD,KAAK,IAAI;IAC3C,OAAOA,KAAK,CAACA,KAAK,CAACE,EAAE,KAAKH,MAAM,IAAIC,KAAK,CAACD,MAAM,KAAKA,MAAM;EAC/D,CAAC,CAAC;EACF,OAAOI,cAAc,EAAEJ,MAAM,IAAII,cAAc,EAAEH,KAAK,CAACE,EAAE;AAC7D,CAAC;AAEM,MAAME,UAAU,GAAG,MAAOR,MAAc,IAAwB;EACnE,MAAM;IAAES;EAAQ,CAAC,GAAGT,MAAM;EAE1B,MAAMU,MAAM,GAAG,MAAM,IAAAC,0BAAY,EAACX,MAAM,CAAC;EAEzC,MAAMY,MAAM,GAAG,MAAM,IAAAC,0BAAY,EAAC;IAC9BJ,OAAO;IACPG,MAAM,EAAEZ,MAAM,CAACY,MAAM,CAACE,GAAG,CAACC,KAAK,IAAI;MAC/B,MAAMX,KAAK,GAAGL,QAAQ,CAAC;QACnBE,SAAS,EAAED,MAAM,CAACU,MAAM;QACxBR,QAAQ,EAAEQ,MAAM;QAChBP,MAAM,EAAEY,KAAK,CAACA,KAAK,CAACX;MACxB,CAAC,CAAC;MACF,OAAO;QACH,GAAGW,KAAK;QACRX,KAAK,EAAEA,KAAK,IAAIW,KAAK,CAACA,KAAK,CAACX;MAChC,CAAC;IACL,CAAC;EACL,CAAC,CAAC;EAEF,OAAO;IACHM,MAAM;IACNE;EACJ,CAAC;AACL,CAAC;AAACI,OAAA,CAAAR,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { CmsContext } from "../../../types";
2
- import { CmsGroupImportResult, ValidCmsGroupResult } from "../../types";
1
+ import type { CmsContext } from "../../../types";
2
+ import type { CmsGroupImportResult, ValidCmsGroupResult } from "../../types";
3
3
  interface Params {
4
4
  context: CmsContext;
5
5
  groups: ValidCmsGroupResult[];