@webiny/api-headless-cms 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2

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 (786) hide show
  1. package/HeadlessCmsEndpointConfig.d.ts +10 -0
  2. package/HeadlessCmsEndpointConfig.js +5 -0
  3. package/HeadlessCmsEndpointConfig.js.map +1 -0
  4. package/HeadlessCmsFeature.d.ts +10 -0
  5. package/HeadlessCmsFeature.js +168 -0
  6. package/HeadlessCmsFeature.js.map +1 -0
  7. package/createCmsRoute.d.ts +24 -0
  8. package/createCmsRoute.js +47 -0
  9. package/createCmsRoute.js.map +1 -0
  10. package/crud/contentEntry/entryDataValidation.js +14 -7
  11. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  12. package/crud/contentEntry/references/validateEntries.d.ts +1 -1
  13. package/crud/contentEntry/references/validateEntries.js +17 -7
  14. package/crud/contentEntry/references/validateEntries.js.map +1 -1
  15. package/domain/contentModel/schemas.d.ts +2 -0
  16. package/domain/contentModel/schemas.js +1 -0
  17. package/domain/contentModel/schemas.js.map +1 -1
  18. package/domain/contentModel/validation/dateExpressions.d.ts +6 -0
  19. package/domain/contentModel/validation/dateExpressions.js +27 -0
  20. package/domain/contentModel/validation/dateExpressions.js.map +1 -0
  21. package/domain/contentModel/validation/modelFields.js +23 -15
  22. package/domain/contentModel/validation/modelFields.js.map +1 -1
  23. package/export/abstractions.d.ts +9 -0
  24. package/export/abstractions.js +6 -0
  25. package/export/abstractions.js.map +1 -0
  26. package/export/crud/exporting.js +8 -2
  27. package/export/crud/exporting.js.map +1 -1
  28. package/export/crud/importing.js +13 -4
  29. package/export/crud/importing.js.map +1 -1
  30. package/export/crud/imports/importGroups.js +23 -23
  31. package/export/crud/imports/importGroups.js.map +1 -1
  32. package/export/crud/imports/importModels.js +25 -22
  33. package/export/crud/imports/importModels.js.map +1 -1
  34. package/export/graphql/index.d.ts +2 -3
  35. package/export/graphql/index.js +6 -10
  36. package/export/graphql/index.js.map +1 -1
  37. package/exports/api/cms/entry.d.ts +5 -0
  38. package/exports/api/cms/entry.js +5 -0
  39. package/exports/api/cms/storage.d.ts +0 -1
  40. package/exports/api/cms/storage.js +0 -1
  41. package/features/ai/DescribeContentModelTool.d.ts +60 -0
  42. package/features/ai/DescribeContentModelTool.js +69 -0
  43. package/features/ai/DescribeContentModelTool.js.map +1 -0
  44. package/features/ai/ListContentModelsTool.d.ts +46 -0
  45. package/features/ai/ListContentModelsTool.js +53 -0
  46. package/features/ai/ListContentModelsTool.js.map +1 -0
  47. package/features/ai/QueryEntriesTool.d.ts +80 -0
  48. package/features/ai/QueryEntriesTool.js +99 -0
  49. package/features/ai/QueryEntriesTool.js.map +1 -0
  50. package/features/ai/feature.d.ts +8 -0
  51. package/features/ai/feature.js +15 -0
  52. package/features/ai/feature.js.map +1 -0
  53. package/features/ai/index.d.ts +4 -0
  54. package/features/ai/index.js +4 -0
  55. package/features/contentEntry/ContentEntriesFeature.js +8 -4
  56. package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
  57. package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +6 -4
  58. package/features/contentEntry/CreateEntry/CreateEntryRepository.js +7 -8
  59. package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
  60. package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +5 -3
  61. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +4 -5
  62. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
  63. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +6 -4
  64. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +7 -8
  65. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
  66. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +5 -5
  67. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +8 -17
  68. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
  69. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.d.ts +2 -0
  70. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.js.map +1 -1
  71. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +6 -4
  72. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +7 -8
  73. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
  74. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +5 -3
  75. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +4 -5
  76. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
  77. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +6 -4
  78. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +9 -11
  79. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
  80. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +5 -3
  81. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +4 -5
  82. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
  83. package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.d.ts +3 -3
  84. package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js +5 -5
  85. package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js.map +1 -1
  86. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +6 -4
  87. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +7 -8
  88. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
  89. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +5 -3
  90. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +4 -5
  91. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
  92. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +6 -4
  93. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +8 -9
  94. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
  95. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +5 -3
  96. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +13 -13
  97. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
  98. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.d.ts +17 -0
  99. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js +83 -0
  100. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  101. package/features/contentEntry/DuplicateEntry/abstractions.d.ts +47 -0
  102. package/features/contentEntry/DuplicateEntry/abstractions.js +5 -0
  103. package/features/contentEntry/DuplicateEntry/abstractions.js.map +1 -0
  104. package/features/contentEntry/DuplicateEntry/events.d.ts +41 -0
  105. package/features/contentEntry/DuplicateEntry/events.js +32 -0
  106. package/features/contentEntry/DuplicateEntry/events.js.map +1 -0
  107. package/features/contentEntry/{UpdateRevision → DuplicateEntry}/feature.d.ts +1 -1
  108. package/features/contentEntry/DuplicateEntry/feature.js +11 -0
  109. package/features/contentEntry/DuplicateEntry/feature.js.map +1 -0
  110. package/features/contentEntry/DuplicateEntry/index.d.ts +2 -0
  111. package/features/contentEntry/DuplicateEntry/index.js +2 -0
  112. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.d.ts +7 -0
  113. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js +12 -0
  114. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js.map +1 -0
  115. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.d.ts +10 -0
  116. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js +25 -0
  117. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js.map +1 -0
  118. package/features/contentEntry/EntryEventPublisher/abstractions.d.ts +16 -0
  119. package/features/contentEntry/EntryEventPublisher/abstractions.js +5 -0
  120. package/features/contentEntry/EntryEventPublisher/abstractions.js.map +1 -0
  121. package/features/contentEntry/EntryEventPublisher/feature.d.ts +4 -0
  122. package/features/contentEntry/EntryEventPublisher/feature.js +11 -0
  123. package/features/contentEntry/EntryEventPublisher/feature.js.map +1 -0
  124. package/features/contentEntry/EntryEventPublisher/index.d.ts +2 -0
  125. package/features/contentEntry/EntryEventPublisher/index.js +2 -0
  126. package/features/contentEntry/EntrySystemField/abstractions.d.ts +14 -0
  127. package/features/contentEntry/EntrySystemField/abstractions.js +5 -0
  128. package/features/contentEntry/EntrySystemField/abstractions.js.map +1 -0
  129. package/features/contentEntry/EntrySystemField/index.d.ts +1 -0
  130. package/features/contentEntry/EntrySystemField/index.js +1 -0
  131. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +6 -4
  132. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +7 -8
  133. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
  134. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.d.ts +3 -1
  135. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +2 -3
  136. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
  137. package/features/contentEntry/GetEntry/GetEntryUseCase.d.ts +3 -1
  138. package/features/contentEntry/GetEntry/GetEntryUseCase.js +2 -3
  139. package/features/contentEntry/GetEntry/GetEntryUseCase.js.map +1 -1
  140. package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.d.ts +3 -1
  141. package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js +2 -3
  142. package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js.map +1 -1
  143. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +6 -4
  144. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +8 -9
  145. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
  146. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.d.ts +3 -1
  147. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +2 -3
  148. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
  149. package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.d.ts +3 -1
  150. package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +2 -3
  151. package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
  152. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +6 -4
  153. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +8 -9
  154. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
  155. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.d.ts +3 -1
  156. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js +2 -3
  157. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js.map +1 -1
  158. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.d.ts +3 -1
  159. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js +1 -3
  160. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js.map +1 -1
  161. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.d.ts +3 -1
  162. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js +2 -3
  163. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js.map +1 -1
  164. package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.d.ts +3 -1
  165. package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +2 -3
  166. package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
  167. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +6 -4
  168. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -8
  169. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
  170. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.d.ts +3 -1
  171. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js +2 -3
  172. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js.map +1 -1
  173. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +6 -4
  174. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +8 -9
  175. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
  176. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.d.ts +3 -1
  177. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +2 -3
  178. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
  179. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +6 -4
  180. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +8 -9
  181. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
  182. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +3 -1
  183. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +2 -3
  184. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
  185. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +6 -4
  186. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -8
  187. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
  188. package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +3 -1
  189. package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +1 -3
  190. package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
  191. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +6 -4
  192. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +8 -9
  193. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
  194. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.d.ts +3 -1
  195. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js +2 -3
  196. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js.map +1 -1
  197. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +6 -4
  198. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -8
  199. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
  200. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +6 -2
  201. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +8 -6
  202. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
  203. package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.d.ts +3 -1
  204. package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js +1 -3
  205. package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js.map +1 -1
  206. package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +6 -4
  207. package/features/contentEntry/ListEntries/ListEntriesRepository.js +8 -9
  208. package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
  209. package/features/contentEntry/ListEntries/ListEntriesUseCase.d.ts +3 -1
  210. package/features/contentEntry/ListEntries/ListEntriesUseCase.js +2 -3
  211. package/features/contentEntry/ListEntries/ListEntriesUseCase.js.map +1 -1
  212. package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.d.ts +3 -1
  213. package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js +1 -3
  214. package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js.map +1 -1
  215. package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.d.ts +3 -1
  216. package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js +1 -3
  217. package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js.map +1 -1
  218. package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +6 -4
  219. package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -8
  220. package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
  221. package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +5 -3
  222. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +13 -7
  223. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
  224. package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +7 -5
  225. package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -9
  226. package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
  227. package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +7 -7
  228. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +13 -16
  229. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
  230. package/features/contentEntry/PublishEntry/abstractions.d.ts +8 -1
  231. package/features/contentEntry/PublishEntry/abstractions.js.map +1 -1
  232. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +8 -4
  233. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +11 -9
  234. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
  235. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +5 -3
  236. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +7 -6
  237. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
  238. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +6 -4
  239. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +7 -8
  240. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
  241. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +5 -3
  242. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +4 -5
  243. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
  244. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +6 -4
  245. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +7 -8
  246. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
  247. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +5 -3
  248. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +7 -6
  249. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
  250. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +7 -5
  251. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +7 -8
  252. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
  253. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +5 -3
  254. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +7 -6
  255. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
  256. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.d.ts +19 -0
  257. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js +70 -0
  258. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js.map +1 -0
  259. package/features/contentEntry/UpdateEntrySystem/abstractions.d.ts +24 -0
  260. package/features/contentEntry/UpdateEntrySystem/abstractions.js +5 -0
  261. package/features/contentEntry/UpdateEntrySystem/abstractions.js.map +1 -0
  262. package/features/contentEntry/UpdateEntrySystem/events.d.ts +29 -0
  263. package/features/contentEntry/UpdateEntrySystem/events.js +23 -0
  264. package/features/contentEntry/UpdateEntrySystem/events.js.map +1 -0
  265. package/features/contentEntry/UpdateEntrySystem/feature.d.ts +4 -0
  266. package/features/contentEntry/UpdateEntrySystem/feature.js +11 -0
  267. package/features/contentEntry/UpdateEntrySystem/feature.js.map +1 -0
  268. package/features/contentEntry/UpdateEntrySystem/index.d.ts +2 -0
  269. package/features/contentEntry/UpdateEntrySystem/index.js +2 -0
  270. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +6 -4
  271. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +6 -7
  272. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
  273. package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.d.ts +3 -1
  274. package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js +2 -3
  275. package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js.map +1 -1
  276. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
  277. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +1 -3
  278. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
  279. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +8 -4
  280. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +41 -16
  281. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
  282. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.d.ts +17 -1
  283. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.js.map +1 -1
  284. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +8 -4
  285. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +23 -18
  286. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
  287. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.d.ts +15 -1
  288. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.js.map +1 -1
  289. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +8 -4
  290. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +18 -15
  291. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
  292. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.d.ts +13 -1
  293. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.js.map +1 -1
  294. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +9 -7
  295. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +18 -20
  296. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
  297. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts +14 -2
  298. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map +1 -1
  299. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +8 -4
  300. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +67 -31
  301. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
  302. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.d.ts +15 -1
  303. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js.map +1 -1
  304. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.d.ts +24 -0
  305. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js +13 -0
  306. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js.map +1 -0
  307. package/features/contentModel/CreateModel/CreateModelRepository.d.ts +5 -6
  308. package/features/contentModel/CreateModel/CreateModelRepository.js +9 -12
  309. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  310. package/features/contentModel/CreateModel/CreateModelUseCase.js +2 -2
  311. package/features/contentModel/CreateModel/CreateModelUseCase.js.map +1 -1
  312. package/features/contentModel/CreateModel/abstractions.d.ts +1 -1
  313. package/features/contentModel/CreateModel/abstractions.js.map +1 -1
  314. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +5 -6
  315. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +9 -12
  316. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  317. package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js +2 -2
  318. package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js.map +1 -1
  319. package/features/contentModel/CreateModelFrom/abstractions.d.ts +1 -1
  320. package/features/contentModel/CreateModelFrom/abstractions.js.map +1 -1
  321. package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +3 -3
  322. package/features/contentModel/DeleteModel/DeleteModelRepository.js +5 -5
  323. package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
  324. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +9 -3
  325. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +36 -18
  326. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
  327. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.d.ts +1 -1
  328. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.js.map +1 -1
  329. package/features/contentModel/ModelToAstConverter/abstractions.d.ts +1 -1
  330. package/features/contentModel/ModelToAstConverter/abstractions.js.map +1 -1
  331. package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +7 -4
  332. package/features/contentModel/UpdateModel/UpdateModelRepository.js +10 -6
  333. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  334. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  335. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +1 -1
  336. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -1
  337. package/features/contentModel/shared/ModelsFetcher.d.ts +9 -8
  338. package/features/contentModel/shared/ModelsFetcher.js +5 -5
  339. package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
  340. package/features/contentModel/shared/PluginModelsProvider.d.ts +9 -5
  341. package/features/contentModel/shared/PluginModelsProvider.js +11 -15
  342. package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
  343. package/features/contentModel/shared/abstractions.d.ts +10 -0
  344. package/features/contentModel/shared/abstractions.js +2 -1
  345. package/features/contentModel/shared/abstractions.js.map +1 -1
  346. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +11 -7
  347. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +19 -19
  348. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
  349. package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.d.ts +6 -2
  350. package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js +9 -8
  351. package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js.map +1 -1
  352. package/features/contentModelGroup/CreateGroup/abstractions.d.ts +1 -1
  353. package/features/contentModelGroup/CreateGroup/abstractions.js.map +1 -1
  354. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +8 -4
  355. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +11 -9
  356. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
  357. package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.d.ts +3 -1
  358. package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -3
  359. package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
  360. package/features/contentModelGroup/GetGroup/GetGroupRepository.d.ts +6 -4
  361. package/features/contentModelGroup/GetGroup/GetGroupRepository.js +9 -9
  362. package/features/contentModelGroup/GetGroup/GetGroupRepository.js.map +1 -1
  363. package/features/contentModelGroup/GetGroup/GetGroupUseCase.d.ts +3 -1
  364. package/features/contentModelGroup/GetGroup/GetGroupUseCase.js +2 -3
  365. package/features/contentModelGroup/GetGroup/GetGroupUseCase.js.map +1 -1
  366. package/features/contentModelGroup/ListGroups/ListGroupsRepository.d.ts +6 -4
  367. package/features/contentModelGroup/ListGroups/ListGroupsRepository.js +9 -9
  368. package/features/contentModelGroup/ListGroups/ListGroupsRepository.js.map +1 -1
  369. package/features/contentModelGroup/ListGroups/ListGroupsUseCase.d.ts +3 -1
  370. package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js +2 -3
  371. package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js.map +1 -1
  372. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +6 -4
  373. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +7 -8
  374. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
  375. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.d.ts +3 -1
  376. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -3
  377. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
  378. package/features/contentModelGroup/shared/PluginGroupsProvider.d.ts +6 -4
  379. package/features/contentModelGroup/shared/PluginGroupsProvider.js +13 -11
  380. package/features/contentModelGroup/shared/PluginGroupsProvider.js.map +1 -1
  381. package/features/contentModelGroup/shared/abstractions.d.ts +10 -0
  382. package/features/contentModelGroup/shared/abstractions.js +2 -1
  383. package/features/contentModelGroup/shared/abstractions.js.map +1 -1
  384. package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.d.ts +2 -2
  385. package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js.map +1 -1
  386. package/features/graphql/fields/base/AssetToGraphQL.d.ts +1 -1
  387. package/features/graphql/fields/base/AssetToGraphQL.js +7 -2
  388. package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -1
  389. package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
  390. package/features/graphql/fields/base/RefToGraphQL.d.ts +1 -1
  391. package/features/graphql/fields/base/RefToGraphQL.js +14 -8
  392. package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
  393. package/features/graphql/fields/base/richText/richTextResolver.d.ts +1 -1
  394. package/features/graphql/fields/base/richText/richTextResolver.js.map +1 -1
  395. package/features/modelBuilder/abstractions.d.ts +4 -0
  396. package/features/modelBuilder/abstractions.js.map +1 -1
  397. package/features/modelBuilder/feature.js +1 -8
  398. package/features/modelBuilder/feature.js.map +1 -1
  399. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +17 -0
  400. package/features/modelBuilder/fields/DataFieldBuilder.js +6 -0
  401. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
  402. package/features/modelBuilder/fields/DateTimeFieldType.js +27 -12
  403. package/features/modelBuilder/fields/DateTimeFieldType.js.map +1 -1
  404. package/features/modelBuilder/fields/TextFieldType.d.ts +3 -1
  405. package/features/modelBuilder/fields/TextFieldType.js +1 -3
  406. package/features/modelBuilder/fields/TextFieldType.js.map +1 -1
  407. package/features/modelBuilder/fields/fieldTypeValidator.d.ts +5 -3
  408. package/features/modelBuilder/models/ModelBuilder.d.ts +8 -0
  409. package/features/modelBuilder/models/ModelBuilder.js +1 -0
  410. package/features/modelBuilder/models/ModelBuilder.js.map +1 -1
  411. package/features/modelBuilder/models/ModelsProvider.d.ts +1 -3
  412. package/features/modelBuilder/models/ModelsProvider.js +2 -7
  413. package/features/modelBuilder/models/ModelsProvider.js.map +1 -1
  414. package/features/modelBuilder/models/PrivateModelBuilder.d.ts +5 -0
  415. package/features/modelBuilder/models/PrivateModelBuilder.js +12 -1
  416. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  417. package/features/shared/abstractions.d.ts +8 -16
  418. package/features/shared/abstractions.js +2 -3
  419. package/features/shared/abstractions.js.map +1 -1
  420. package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.d.ts +8 -0
  421. package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js +5 -0
  422. package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js.map +1 -0
  423. package/features/shared/storageOperations/entry/CreateEntryStorageOperation.d.ts +8 -0
  424. package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js +5 -0
  425. package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js.map +1 -0
  426. package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.d.ts +8 -0
  427. package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js +5 -0
  428. package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js.map +1 -0
  429. package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.d.ts +8 -0
  430. package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js +5 -0
  431. package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js.map +1 -0
  432. package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.d.ts +8 -0
  433. package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js +5 -0
  434. package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js.map +1 -0
  435. package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.d.ts +8 -0
  436. package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js +5 -0
  437. package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js.map +1 -0
  438. package/features/shared/storageOperations/entry/GetEntryStorageOperation.d.ts +8 -0
  439. package/features/shared/storageOperations/entry/GetEntryStorageOperation.js +5 -0
  440. package/features/shared/storageOperations/entry/GetEntryStorageOperation.js.map +1 -0
  441. package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.d.ts +8 -0
  442. package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js +5 -0
  443. package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js.map +1 -0
  444. package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.d.ts +8 -0
  445. package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js +5 -0
  446. package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js.map +1 -0
  447. package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.d.ts +8 -0
  448. package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js +5 -0
  449. package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js.map +1 -0
  450. package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.d.ts +8 -0
  451. package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js +5 -0
  452. package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js.map +1 -0
  453. package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.d.ts +8 -0
  454. package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js +5 -0
  455. package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js.map +1 -0
  456. package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.d.ts +8 -0
  457. package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js +5 -0
  458. package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js.map +1 -0
  459. package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.d.ts +8 -0
  460. package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js +5 -0
  461. package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js.map +1 -0
  462. package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.d.ts +8 -0
  463. package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js +5 -0
  464. package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js.map +1 -0
  465. package/features/shared/storageOperations/entry/ListEntriesStorageOperation.d.ts +8 -0
  466. package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js +5 -0
  467. package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js.map +1 -0
  468. package/features/shared/storageOperations/entry/MoveEntryStorageOperation.d.ts +8 -0
  469. package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js +5 -0
  470. package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js.map +1 -0
  471. package/features/shared/storageOperations/entry/MoveToBinStorageOperation.d.ts +8 -0
  472. package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js +5 -0
  473. package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js.map +1 -0
  474. package/features/shared/storageOperations/entry/PublishEntryStorageOperation.d.ts +8 -0
  475. package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js +5 -0
  476. package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js.map +1 -0
  477. package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.d.ts +8 -0
  478. package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js +5 -0
  479. package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js.map +1 -0
  480. package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.d.ts +8 -0
  481. package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js +5 -0
  482. package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js.map +1 -0
  483. package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.d.ts +8 -0
  484. package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js +5 -0
  485. package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js.map +1 -0
  486. package/features/shared/storageOperations/group/CreateGroupStorageOperation.d.ts +8 -0
  487. package/features/shared/storageOperations/group/CreateGroupStorageOperation.js +5 -0
  488. package/features/shared/storageOperations/group/CreateGroupStorageOperation.js.map +1 -0
  489. package/features/shared/storageOperations/group/DeleteGroupStorageOperation.d.ts +8 -0
  490. package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js +5 -0
  491. package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js.map +1 -0
  492. package/features/shared/storageOperations/group/GetGroupStorageOperation.d.ts +8 -0
  493. package/features/shared/storageOperations/group/GetGroupStorageOperation.js +5 -0
  494. package/features/shared/storageOperations/group/GetGroupStorageOperation.js.map +1 -0
  495. package/features/shared/storageOperations/group/ListGroupsStorageOperation.d.ts +8 -0
  496. package/features/shared/storageOperations/group/ListGroupsStorageOperation.js +5 -0
  497. package/features/shared/storageOperations/group/ListGroupsStorageOperation.js.map +1 -0
  498. package/features/shared/storageOperations/group/UpdateGroupStorageOperation.d.ts +8 -0
  499. package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js +5 -0
  500. package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js.map +1 -0
  501. package/features/shared/storageOperations/index.d.ts +32 -0
  502. package/features/shared/storageOperations/index.js +32 -0
  503. package/features/shared/storageOperations/model/CreateModelStorageOperation.d.ts +8 -0
  504. package/features/shared/storageOperations/model/CreateModelStorageOperation.js +5 -0
  505. package/features/shared/storageOperations/model/CreateModelStorageOperation.js.map +1 -0
  506. package/features/shared/storageOperations/model/DeleteModelStorageOperation.d.ts +8 -0
  507. package/features/shared/storageOperations/model/DeleteModelStorageOperation.js +5 -0
  508. package/features/shared/storageOperations/model/DeleteModelStorageOperation.js.map +1 -0
  509. package/features/shared/storageOperations/model/GetModelStorageOperation.d.ts +8 -0
  510. package/features/shared/storageOperations/model/GetModelStorageOperation.js +5 -0
  511. package/features/shared/storageOperations/model/GetModelStorageOperation.js.map +1 -0
  512. package/features/shared/storageOperations/model/ListModelsStorageOperation.d.ts +8 -0
  513. package/features/shared/storageOperations/model/ListModelsStorageOperation.js +5 -0
  514. package/features/shared/storageOperations/model/ListModelsStorageOperation.js.map +1 -0
  515. package/features/shared/storageOperations/model/UpdateModelStorageOperation.d.ts +8 -0
  516. package/features/shared/storageOperations/model/UpdateModelStorageOperation.js +5 -0
  517. package/features/shared/storageOperations/model/UpdateModelStorageOperation.js.map +1 -0
  518. package/features/validation/abstractions/CmsModelFieldValidator.d.ts +5 -0
  519. package/features/validation/abstractions/CmsModelFieldValidator.js.map +1 -1
  520. package/features/validation/validators/DateGteValidator.d.ts +2 -0
  521. package/features/validation/validators/DateGteValidator.js +12 -2
  522. package/features/validation/validators/DateGteValidator.js.map +1 -1
  523. package/features/validation/validators/DateLteValidator.d.ts +2 -0
  524. package/features/validation/validators/DateLteValidator.js +12 -2
  525. package/features/validation/validators/DateLteValidator.js.map +1 -1
  526. package/features/validation/validators/dateLimit.d.ts +9 -0
  527. package/features/validation/validators/dateLimit.js +18 -0
  528. package/features/validation/validators/dateLimit.js.map +1 -0
  529. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  530. package/fieldConverters/abstractions.d.ts +14 -0
  531. package/fieldConverters/abstractions.js +13 -0
  532. package/fieldConverters/abstractions.js.map +1 -0
  533. package/graphql/CmsGraphQLSchemaFactory.d.ts +8 -0
  534. package/graphql/CmsGraphQLSchemaFactory.js +5 -0
  535. package/graphql/CmsGraphQLSchemaFactory.js.map +1 -0
  536. package/graphql/CmsSchemaExecutor.d.ts +10 -0
  537. package/graphql/CmsSchemaExecutor.js +5 -0
  538. package/graphql/CmsSchemaExecutor.js.map +1 -0
  539. package/graphql/buildSchemaPlugins.d.ts +2 -1
  540. package/graphql/buildSchemaPlugins.js +1 -3
  541. package/graphql/buildSchemaPlugins.js.map +1 -1
  542. package/graphql/checkEndpointAccess.js +5 -2
  543. package/graphql/checkEndpointAccess.js.map +1 -1
  544. package/graphql/createExecutableSchema.d.ts +1 -1
  545. package/graphql/createExecutableSchema.js +1 -1
  546. package/graphql/createExecutableSchema.js.map +1 -1
  547. package/graphql/generateSchema.d.ts +2 -1
  548. package/graphql/generateSchema.js +14 -5
  549. package/graphql/generateSchema.js.map +1 -1
  550. package/graphql/getSchema.js +7 -2
  551. package/graphql/getSchema.js.map +1 -1
  552. package/graphql/scalars/RevisionIdScalarPlugin.d.ts +1 -1
  553. package/graphql/scalars/RevisionIdScalarPlugin.js.map +1 -1
  554. package/graphql/schema/baseContentSchema.d.ts +1 -6
  555. package/graphql/schema/baseContentSchema.js +5 -8
  556. package/graphql/schema/baseContentSchema.js.map +1 -1
  557. package/graphql/schema/baseSchema.d.ts +2 -2
  558. package/graphql/schema/baseSchema.js +3 -18
  559. package/graphql/schema/baseSchema.js.map +1 -1
  560. package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +15 -0
  561. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +25 -0
  562. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -0
  563. package/graphql/schema/cms/createEntryResolver.js +2 -2
  564. package/graphql/schema/cms/createEntryResolver.js.map +1 -1
  565. package/graphql/schema/cms/deleteEntryResolver.js +2 -2
  566. package/graphql/schema/cms/deleteEntryResolver.js.map +1 -1
  567. package/graphql/schema/cms/getEntryResolver.js +2 -2
  568. package/graphql/schema/cms/getEntryResolver.js.map +1 -1
  569. package/graphql/schema/cms/helpers/getModel.d.ts +0 -3
  570. package/graphql/schema/cms/helpers/getModel.js +5 -3
  571. package/graphql/schema/cms/helpers/getModel.js.map +1 -1
  572. package/graphql/schema/cms/listEntriesResolver.js +2 -2
  573. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  574. package/graphql/schema/cms/publishEntryResolver.js +2 -2
  575. package/graphql/schema/cms/publishEntryResolver.js.map +1 -1
  576. package/graphql/schema/cms/resolvers/createEntry.d.ts +3 -2
  577. package/graphql/schema/cms/resolvers/createEntry.js +5 -1
  578. package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
  579. package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +3 -2
  580. package/graphql/schema/cms/resolvers/deleteEntryRevision.js +5 -1
  581. package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
  582. package/graphql/schema/cms/resolvers/getEntry.d.ts +3 -2
  583. package/graphql/schema/cms/resolvers/getEntry.js +5 -1
  584. package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
  585. package/graphql/schema/cms/resolvers/getModel.d.ts +3 -2
  586. package/graphql/schema/cms/resolvers/getModel.js +5 -1
  587. package/graphql/schema/cms/resolvers/getModel.js.map +1 -1
  588. package/graphql/schema/cms/resolvers/listEntries.d.ts +3 -2
  589. package/graphql/schema/cms/resolvers/listEntries.js +5 -1
  590. package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
  591. package/graphql/schema/cms/resolvers/mutationCms.d.ts +3 -2
  592. package/graphql/schema/cms/resolvers/mutationCms.js +5 -1
  593. package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
  594. package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +3 -2
  595. package/graphql/schema/cms/resolvers/publishEntryRevision.js +5 -1
  596. package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
  597. package/graphql/schema/cms/resolvers/queryCms.d.ts +3 -2
  598. package/graphql/schema/cms/resolvers/queryCms.js +5 -1
  599. package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
  600. package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +3 -2
  601. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +5 -1
  602. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
  603. package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +3 -2
  604. package/graphql/schema/cms/resolvers/updateEntryRevision.js +5 -1
  605. package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
  606. package/graphql/schema/cms/typeDefs/mutation.d.ts +3 -2
  607. package/graphql/schema/cms/typeDefs/mutation.js +5 -1
  608. package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
  609. package/graphql/schema/cms/typeDefs/query.d.ts +3 -2
  610. package/graphql/schema/cms/typeDefs/query.js +5 -1
  611. package/graphql/schema/cms/typeDefs/query.js.map +1 -1
  612. package/graphql/schema/cms/typeDefs/responses.d.ts +3 -2
  613. package/graphql/schema/cms/typeDefs/responses.js +5 -1
  614. package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
  615. package/graphql/schema/cms/unpublishEntryResolver.js +2 -2
  616. package/graphql/schema/cms/unpublishEntryResolver.js.map +1 -1
  617. package/graphql/schema/cms/updateEntryResolver.js +2 -2
  618. package/graphql/schema/cms/updateEntryResolver.js.map +1 -1
  619. package/graphql/schema/contentEntries.js +60 -34
  620. package/graphql/schema/contentEntries.js.map +1 -1
  621. package/graphql/schema/contentModelGroups.js +39 -18
  622. package/graphql/schema/contentModelGroups.js.map +1 -1
  623. package/graphql/schema/contentModels.js +32 -15
  624. package/graphql/schema/contentModels.js.map +1 -1
  625. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  626. package/graphql/schema/createFieldResolvers.js.map +1 -1
  627. package/graphql/schema/createManageResolvers.js +7 -3
  628. package/graphql/schema/createManageResolvers.js.map +1 -1
  629. package/graphql/schema/createManageSDL.js +2 -0
  630. package/graphql/schema/createManageSDL.js.map +1 -1
  631. package/graphql/schema/resolvers/manage/resolveCreate.js +5 -3
  632. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  633. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +5 -3
  634. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  635. package/graphql/schema/resolvers/manage/resolveDelete.js +9 -4
  636. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  637. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +5 -3
  638. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
  639. package/graphql/schema/resolvers/manage/resolveDuplicate.d.ts +7 -0
  640. package/graphql/schema/resolvers/manage/resolveDuplicate.js +11 -0
  641. package/graphql/schema/resolvers/manage/resolveDuplicate.js.map +1 -0
  642. package/graphql/schema/resolvers/manage/resolveGet.js +11 -6
  643. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  644. package/graphql/schema/resolvers/manage/resolveGetByIds.js +5 -3
  645. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  646. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +5 -3
  647. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  648. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +5 -3
  649. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
  650. package/graphql/schema/resolvers/manage/resolveList.js +5 -3
  651. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  652. package/graphql/schema/resolvers/manage/resolveListDeleted.js +5 -3
  653. package/graphql/schema/resolvers/manage/resolveListDeleted.js.map +1 -1
  654. package/graphql/schema/resolvers/manage/resolveMove.js +4 -2
  655. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
  656. package/graphql/schema/resolvers/manage/resolvePublish.js +5 -3
  657. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  658. package/graphql/schema/resolvers/manage/resolveRepublish.js +5 -3
  659. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  660. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js +5 -3
  661. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js.map +1 -1
  662. package/graphql/schema/resolvers/manage/resolveUnpublish.js +5 -3
  663. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  664. package/graphql/schema/resolvers/manage/resolveUpdate.js +5 -3
  665. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  666. package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js +5 -3
  667. package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js.map +1 -1
  668. package/graphql/schema/resolvers/manage/resolveValidate.js +5 -3
  669. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -1
  670. package/graphql/schema/resolvers/preview/resolveGet.js +6 -3
  671. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  672. package/graphql/schema/resolvers/preview/resolveList.js +5 -3
  673. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  674. package/graphql/schema/resolvers/read/resolveGet.js +5 -2
  675. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  676. package/graphql/schema/resolvers/read/resolveList.js +5 -3
  677. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  678. package/graphql/schema/resolvers/singular/resolveGet.js +1 -1
  679. package/graphql/schema/resolvers/singular/resolveGet.js.map +1 -1
  680. package/graphql/schema/resolvers/singular/resolveUpdate.js +1 -1
  681. package/graphql/schema/resolvers/singular/resolveUpdate.js.map +1 -1
  682. package/graphql/schema/schemaPlugins.d.ts +2 -1
  683. package/graphql/schema/schemaPlugins.js +2 -4
  684. package/graphql/schema/schemaPlugins.js.map +1 -1
  685. package/index.d.ts +7 -3
  686. package/index.js +4 -2
  687. package/legacy/abstractions.js.map +1 -1
  688. package/package.json +21 -24
  689. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +2 -2
  690. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js +1 -1
  691. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -1
  692. package/plugins/index.d.ts +0 -1
  693. package/plugins/index.js +0 -1
  694. package/types/index.d.ts +0 -1
  695. package/types/modelField.d.ts +11 -0
  696. package/types/types.d.ts +19 -291
  697. package/types/types.js.map +1 -1
  698. package/utils/converters/ConverterCollection.d.ts +2 -2
  699. package/utils/converters/ConverterCollection.js +1 -3
  700. package/utils/converters/ConverterCollection.js.map +1 -1
  701. package/utils/converters/valueKeyFromStorageConverter.d.ts +2 -2
  702. package/utils/converters/valueKeyFromStorageConverter.js +2 -2
  703. package/utils/converters/valueKeyFromStorageConverter.js.map +1 -1
  704. package/utils/converters/valueKeyStorageConverter.js +4 -2
  705. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  706. package/utils/converters/valueKeyToStorageConverter.d.ts +2 -2
  707. package/utils/converters/valueKeyToStorageConverter.js +2 -2
  708. package/utils/converters/valueKeyToStorageConverter.js.map +1 -1
  709. package/utils/createModelField.js +2 -1
  710. package/utils/createModelField.js.map +1 -1
  711. package/utils/createModelSchemaKey.d.ts +8 -0
  712. package/utils/createModelSchemaKey.js +18 -0
  713. package/utils/createModelSchemaKey.js.map +1 -0
  714. package/utils/getSchemaFromFieldPlugins.d.ts +2 -2
  715. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  716. package/utils/isHeadlessCmsReady.d.ts +1 -1
  717. package/utils/isHeadlessCmsReady.js +3 -2
  718. package/utils/isHeadlessCmsReady.js.map +1 -1
  719. package/abstractions/entryHooks/OnEntryBeforeCreate.d.ts +0 -8
  720. package/abstractions/entryHooks/OnEntryBeforeCreate.js +0 -5
  721. package/abstractions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
  722. package/abstractions/entryHooks/index.d.ts +0 -1
  723. package/abstractions/entryHooks/index.js +0 -1
  724. package/abstractions/index.d.ts +0 -1
  725. package/abstractions/index.js +0 -1
  726. package/context.d.ts +0 -3
  727. package/context.js +0 -131
  728. package/context.js.map +0 -1
  729. package/crud/contentEntry.crud.d.ts +0 -6
  730. package/crud/contentEntry.crud.js +0 -307
  731. package/crud/contentEntry.crud.js.map +0 -1
  732. package/crud/contentModel.crud.d.ts +0 -5
  733. package/crud/contentModel.crud.js +0 -77
  734. package/crud/contentModel.crud.js.map +0 -1
  735. package/crud/contentModelGroup.crud.d.ts +0 -5
  736. package/crud/contentModelGroup.crud.js +0 -74
  737. package/crud/contentModelGroup.crud.js.map +0 -1
  738. package/extension.d.ts +0 -3
  739. package/extension.js +0 -19
  740. package/extension.js.map +0 -1
  741. package/extensions/entryHooks/OnEntryBeforeCreate.d.ts +0 -4
  742. package/extensions/entryHooks/OnEntryBeforeCreate.js +0 -21
  743. package/extensions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
  744. package/extensions/entryHooks/index.d.ts +0 -1
  745. package/extensions/entryHooks/index.js +0 -1
  746. package/extensions/index.d.ts +0 -5
  747. package/extensions/index.js +0 -7
  748. package/extensions/index.js.map +0 -1
  749. package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.d.ts +0 -14
  750. package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js +0 -34
  751. package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js.map +0 -1
  752. package/features/contentEntry/UpdateRevision/abstractions.d.ts +0 -10
  753. package/features/contentEntry/UpdateRevision/abstractions.js +0 -5
  754. package/features/contentEntry/UpdateRevision/abstractions.js.map +0 -1
  755. package/features/contentEntry/UpdateRevision/feature.js +0 -11
  756. package/features/contentEntry/UpdateRevision/feature.js.map +0 -1
  757. package/features/contentEntry/UpdateRevision/index.d.ts +0 -1
  758. package/features/contentEntry/UpdateRevision/index.js +0 -1
  759. package/graphql/graphQLHandlerFactory.d.ts +0 -5
  760. package/graphql/graphQLHandlerFactory.js +0 -22
  761. package/graphql/graphQLHandlerFactory.js.map +0 -1
  762. package/graphql/handleRequest.d.ts +0 -11
  763. package/graphql/handleRequest.js +0 -62
  764. package/graphql/handleRequest.js.map +0 -1
  765. package/graphql/index.d.ts +0 -4
  766. package/graphql/index.js +0 -11
  767. package/graphql/index.js.map +0 -1
  768. package/graphql/schema/cms/index.d.ts +0 -2
  769. package/graphql/schema/cms/index.js +0 -25
  770. package/graphql/schema/cms/index.js.map +0 -1
  771. package/parameters/context.d.ts +0 -2
  772. package/parameters/context.js +0 -7
  773. package/parameters/context.js.map +0 -1
  774. package/parameters/header.d.ts +0 -2
  775. package/parameters/header.js +0 -13
  776. package/parameters/header.js.map +0 -1
  777. package/parameters/index.d.ts +0 -3
  778. package/parameters/index.js +0 -3
  779. package/parameters/path.d.ts +0 -2
  780. package/parameters/path.js +0 -12
  781. package/parameters/path.js.map +0 -1
  782. package/plugins/CmsParametersPlugin.d.ts +0 -18
  783. package/plugins/CmsParametersPlugin.js +0 -16
  784. package/plugins/CmsParametersPlugin.js.map +0 -1
  785. package/types/context.d.ts +0 -110
  786. package/types/context.js +0 -0
@@ -1,10 +1,10 @@
1
1
  import { buildFieldsSelection, getErrorMessage, getModel } from "./helpers.js";
2
+ import { CmsSchemaExecutor } from "../../CmsSchemaExecutor.js";
2
3
  const createUnpublishEntryRevisionResolver = ()=>async ({ args, context })=>{
3
4
  const { modelId, revisionId, fields } = args;
4
5
  try {
5
6
  const model = await getModel(context, modelId);
6
7
  const apiType = "manage";
7
- const executeSchema = await context.cms.getExecutableSchema(apiType);
8
8
  const fieldsSelection = buildFieldsSelection(fields);
9
9
  const query = `
10
10
  mutation Unpublish${model.singularApiName}($revisionId: ID!) {
@@ -20,7 +20,7 @@ const createUnpublishEntryRevisionResolver = ()=>async ({ args, context })=>{
20
20
  }
21
21
  }
22
22
  `;
23
- const result = await executeSchema({
23
+ const result = await context.container.resolve(CmsSchemaExecutor).execute(apiType, {
24
24
  query,
25
25
  variables: {
26
26
  revisionId
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/schema/cms/unpublishEntryResolver.js","sources":["../../../../src/graphql/schema/cms/unpublishEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface UnpublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createUnpublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UnpublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for unpublishing entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Unpublish${model.singularApiName}($revisionId: ID!) {\n unpublish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { revisionId }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `unpublish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to unpublish entry\"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"names":["createUnpublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","getModel","apiType","executeSchema","fieldsSelection","buildFieldsSelection","query","result","e","operationName","error","getErrorMessage"],"mappings":";AAWO,MAAMA,uCAAuC,IACzC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAA6D;QACtF,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAE,GAAGJ;QAExC,IAAI;YACA,MAAMK,QAAQ,MAAMC,SAASL,SAASC;YAGtC,MAAMK,UAAuB;YAC7B,MAAMC,gBAAgB,MAAMP,QAAQ,GAAG,CAAC,mBAAmB,CAACM;YAE5D,MAAME,kBAAkBC,qBAAqBN;YAE7C,MAAMO,QAAsB,CAAC;kCACP,EAAEN,MAAM,eAAe,CAAC;6BAC7B,EAAEA,MAAM,eAAe,CAAC;;4BAEzB,EAAEI,gBAAgB;;;;;;;;;YASlC,CAAC;YAED,MAAMG,SAAU,MAAMJ,cAAc;gBAChCG;gBACA,WAAW;oBAAER;gBAAW;YAC5B;YAEA,IAAIS,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GACxC,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASA,OAAO,MAAM,CAAC,GAAG,CAACC,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;oBAChD,MAAM;gBACV;YACJ;YAGJ,MAAMC,gBAAgB,CAAC,SAAS,EAAET,MAAM,eAAe,EAAE;YACzD,OAAOO,OAAO,IAAI,EAAE,CAACE,cAAc,IAAI;gBAAE,MAAM;gBAAM,OAAO;YAAK;QACrE,EAAE,OAAOC,OAAO;YACZ,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASC,gBAAgBD,OAAO;oBAChC,MAAM;gBACV;YACJ;QACJ;IACJ"}
1
+ {"version":3,"file":"graphql/schema/cms/unpublishEntryResolver.js","sources":["../../../../src/graphql/schema/cms/unpublishEntryResolver.ts"],"sourcesContent":["import type { CmsContext, ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\nimport { CmsSchemaExecutor } from \"~/graphql/CmsSchemaExecutor.js\";\n\nexport interface UnpublishEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n fields: string[];\n}\n\nexport const createUnpublishEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UnpublishEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for unpublishing entries.\n const apiType: ApiEndpoint = \"manage\";\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Unpublish${model.singularApiName}($revisionId: ID!) {\n unpublish${model.singularApiName}(revision: $revisionId) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await context.container\n .resolve(CmsSchemaExecutor)\n .execute(apiType, { query, variables: { revisionId } })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `unpublish${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to unpublish entry\"),\n code: \"UNPUBLISH_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"names":["createUnpublishEntryRevisionResolver","args","context","modelId","revisionId","fields","model","getModel","apiType","fieldsSelection","buildFieldsSelection","query","result","CmsSchemaExecutor","e","operationName","error","getErrorMessage"],"mappings":";;AAWO,MAAMA,uCAAuC,IACzC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAA6D;QACtF,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,MAAM,EAAE,GAAGJ;QAExC,IAAI;YACA,MAAMK,QAAQ,MAAMC,SAASL,SAASC;YAGtC,MAAMK,UAAuB;YAE7B,MAAMC,kBAAkBC,qBAAqBL;YAE7C,MAAMM,QAAsB,CAAC;kCACP,EAAEL,MAAM,eAAe,CAAC;6BAC7B,EAAEA,MAAM,eAAe,CAAC;;4BAEzB,EAAEG,gBAAgB;;;;;;;;;YASlC,CAAC;YAED,MAAMG,SAAU,MAAMV,QAAQ,SAAS,CAClC,OAAO,CAACW,mBACR,OAAO,CAACL,SAAS;gBAAEG;gBAAO,WAAW;oBAAEP;gBAAW;YAAE;YAEzD,IAAIQ,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GACxC,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASA,OAAO,MAAM,CAAC,GAAG,CAACE,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;oBAChD,MAAM;gBACV;YACJ;YAGJ,MAAMC,gBAAgB,CAAC,SAAS,EAAET,MAAM,eAAe,EAAE;YACzD,OAAOM,OAAO,IAAI,EAAE,CAACG,cAAc,IAAI;gBAAE,MAAM;gBAAM,OAAO;YAAK;QACrE,EAAE,OAAOC,OAAO;YACZ,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASC,gBAAgBD,OAAO;oBAChC,MAAM;gBACV;YACJ;QACJ;IACJ"}
@@ -1,10 +1,10 @@
1
1
  import { buildFieldsSelection, getErrorMessage, getModel } from "./helpers.js";
2
+ import { CmsSchemaExecutor } from "../../CmsSchemaExecutor.js";
2
3
  const createUpdateEntryRevisionResolver = ()=>async ({ args, context })=>{
3
4
  const { modelId, revisionId, data, fields } = args;
4
5
  try {
5
6
  const model = await getModel(context, modelId);
6
7
  const apiType = "manage";
7
- const executeSchema = await context.cms.getExecutableSchema(apiType);
8
8
  const fieldsSelection = buildFieldsSelection(fields);
9
9
  const query = `
10
10
  mutation Update${model.singularApiName}($revisionId: ID!, $data: ${model.singularApiName}Input!) {
@@ -20,7 +20,7 @@ const createUpdateEntryRevisionResolver = ()=>async ({ args, context })=>{
20
20
  }
21
21
  }
22
22
  `;
23
- const result = await executeSchema({
23
+ const result = await context.container.resolve(CmsSchemaExecutor).execute(apiType, {
24
24
  query,
25
25
  variables: {
26
26
  revisionId,
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/schema/cms/updateEntryResolver.js","sources":["../../../../src/graphql/schema/cms/updateEntryResolver.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\n\nexport interface UpdateEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n data: Record<string, unknown>;\n fields: string[];\n}\n\nexport const createUpdateEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UpdateEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, data, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for updating entries.\n const apiType: ApiEndpoint = \"manage\";\n const executeSchema = await context.cms.getExecutableSchema(apiType);\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Update${model.singularApiName}($revisionId: ID!, $data: ${model.singularApiName}Input!) {\n update${model.singularApiName}(revision: $revisionId, data: $data) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await executeSchema({\n query,\n variables: { revisionId, data }\n })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UPDATE_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `update${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to update entry\"),\n code: \"UPDATE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"names":["createUpdateEntryRevisionResolver","args","context","modelId","revisionId","data","fields","model","getModel","apiType","executeSchema","fieldsSelection","buildFieldsSelection","query","result","e","operationName","error","getErrorMessage"],"mappings":";AAYO,MAAMA,oCAAoC,IACtC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAA0D;QACnF,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGL;QAE9C,IAAI;YACA,MAAMM,QAAQ,MAAMC,SAASN,SAASC;YAGtC,MAAMM,UAAuB;YAC7B,MAAMC,gBAAgB,MAAMR,QAAQ,GAAG,CAAC,mBAAmB,CAACO;YAE5D,MAAME,kBAAkBC,qBAAqBN;YAE7C,MAAMO,QAAsB,CAAC;+BACV,EAAEN,MAAM,eAAe,CAAC,0BAA0B,EAAEA,MAAM,eAAe,CAAC;0BAC/E,EAAEA,MAAM,eAAe,CAAC;;4BAEtB,EAAEI,gBAAgB;;;;;;;;;YASlC,CAAC;YAED,MAAMG,SAAU,MAAMJ,cAAc;gBAChCG;gBACA,WAAW;oBAAET;oBAAYC;gBAAK;YAClC;YAEA,IAAIS,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GACxC,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASA,OAAO,MAAM,CAAC,GAAG,CAACC,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;oBAChD,MAAM;gBACV;YACJ;YAGJ,MAAMC,gBAAgB,CAAC,MAAM,EAAET,MAAM,eAAe,EAAE;YACtD,OAAOO,OAAO,IAAI,EAAE,CAACE,cAAc,IAAI;gBAAE,MAAM;gBAAM,OAAO;YAAK;QACrE,EAAE,OAAOC,OAAO;YACZ,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASC,gBAAgBD,OAAO;oBAChC,MAAM;gBACV;YACJ;QACJ;IACJ"}
1
+ {"version":3,"file":"graphql/schema/cms/updateEntryResolver.js","sources":["../../../../src/graphql/schema/cms/updateEntryResolver.ts"],"sourcesContent":["import type { CmsContext, ApiEndpoint } from \"~/types/index.js\";\nimport type { ExecutionResult } from \"graphql\";\nimport { getModel, getErrorMessage, buildFieldsSelection } from \"./helpers.js\";\nimport { CmsSchemaExecutor } from \"~/graphql/CmsSchemaExecutor.js\";\n\nexport interface UpdateEntryRevisionArgs {\n modelId: string;\n revisionId: string;\n data: Record<string, unknown>;\n fields: string[];\n}\n\nexport const createUpdateEntryRevisionResolver = () => {\n return async ({ args, context }: { args: UpdateEntryRevisionArgs; context: CmsContext }) => {\n const { modelId, revisionId, data, fields } = args;\n\n try {\n const model = await getModel(context, modelId);\n\n // Use manage API for updating entries.\n const apiType: ApiEndpoint = \"manage\";\n\n const fieldsSelection = buildFieldsSelection(fields);\n\n const query = /* GraphQL */ `\n mutation Update${model.singularApiName}($revisionId: ID!, $data: ${model.singularApiName}Input!) {\n update${model.singularApiName}(revision: $revisionId, data: $data) {\n data {\n ${fieldsSelection}\n }\n error {\n message\n code\n data\n }\n }\n }\n `;\n\n const result = (await context.container\n .resolve(CmsSchemaExecutor)\n .execute(apiType, { query, variables: { revisionId, data } })) as ExecutionResult;\n\n if (result.errors && result.errors.length > 0) {\n return {\n data: null,\n error: {\n message: result.errors.map(e => e.message).join(\"; \"),\n code: \"UPDATE_ENTRY_ERROR\"\n }\n };\n }\n\n const operationName = `update${model.singularApiName}`;\n return result.data?.[operationName] || { data: null, error: null };\n } catch (error) {\n return {\n data: null,\n error: {\n message: getErrorMessage(error, \"Failed to update entry\"),\n code: \"UPDATE_ENTRY_ERROR\"\n }\n };\n }\n };\n};\n"],"names":["createUpdateEntryRevisionResolver","args","context","modelId","revisionId","data","fields","model","getModel","apiType","fieldsSelection","buildFieldsSelection","query","result","CmsSchemaExecutor","e","operationName","error","getErrorMessage"],"mappings":";;AAYO,MAAMA,oCAAoC,IACtC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAA0D;QACnF,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGL;QAE9C,IAAI;YACA,MAAMM,QAAQ,MAAMC,SAASN,SAASC;YAGtC,MAAMM,UAAuB;YAE7B,MAAMC,kBAAkBC,qBAAqBL;YAE7C,MAAMM,QAAsB,CAAC;+BACV,EAAEL,MAAM,eAAe,CAAC,0BAA0B,EAAEA,MAAM,eAAe,CAAC;0BAC/E,EAAEA,MAAM,eAAe,CAAC;;4BAEtB,EAAEG,gBAAgB;;;;;;;;;YASlC,CAAC;YAED,MAAMG,SAAU,MAAMX,QAAQ,SAAS,CAClC,OAAO,CAACY,mBACR,OAAO,CAACL,SAAS;gBAAEG;gBAAO,WAAW;oBAAER;oBAAYC;gBAAK;YAAE;YAE/D,IAAIQ,OAAO,MAAM,IAAIA,OAAO,MAAM,CAAC,MAAM,GAAG,GACxC,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASA,OAAO,MAAM,CAAC,GAAG,CAACE,CAAAA,IAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;oBAChD,MAAM;gBACV;YACJ;YAGJ,MAAMC,gBAAgB,CAAC,MAAM,EAAET,MAAM,eAAe,EAAE;YACtD,OAAOM,OAAO,IAAI,EAAE,CAACG,cAAc,IAAI;gBAAE,MAAM;gBAAM,OAAO;YAAK;QACrE,EAAE,OAAOC,OAAO;YACZ,OAAO;gBACH,MAAM;gBACN,OAAO;oBACH,SAASC,gBAAgBD,OAAO;oBAChC,MAAM;gBACV;YACJ;QACJ;IACJ"}
@@ -1,5 +1,4 @@
1
- import error from "@webiny/error";
2
- import { ErrorResponse, Response } from "@webiny/handler-graphql";
1
+ import { ErrorResponse, Response } from "@webiny/api-graphql";
3
2
  import { getEntryTitle } from "../../utils/getEntryTitle.js";
4
3
  import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
5
4
  import { getEntryDescription } from "../../utils/getEntryDescription.js";
@@ -8,6 +7,11 @@ import { entryFieldFromStorageTransform } from "../../utils/entryStorage.js";
8
7
  import { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from "../../constants.js";
9
8
  import NotAuthorizedResponse from "@webiny/api-core/graphql/security/NotAuthorizedResponse.js";
10
9
  import { ListLatestEntriesUseCase } from "../../features/contentEntry/ListEntries/index.js";
10
+ import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
11
+ import { GetLatestEntriesByIdsUseCase } from "../../features/contentEntry/GetLatestEntriesByIds/index.js";
12
+ import { GetPublishedEntriesByIdsUseCase } from "../../features/contentEntry/GetPublishedEntriesByIds/index.js";
13
+ import { GetEntriesByIdsUseCase } from "../../features/contentEntry/GetEntriesByIds/index.js";
14
+ import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
11
15
  const createDate = (date)=>{
12
16
  if (!date) return null;
13
17
  try {
@@ -16,6 +20,16 @@ const createDate = (date)=>{
16
20
  return new Date();
17
21
  }
18
22
  };
23
+ const SEARCH_CANDIDATES_LIMIT = 100;
24
+ const getSearchRank = (title, query)=>{
25
+ const normalizedQuery = query?.trim().toLowerCase();
26
+ if (!normalizedQuery) return 0;
27
+ const normalizedTitle = (title || "").trim().toLowerCase();
28
+ if (normalizedTitle === normalizedQuery) return 0;
29
+ if (normalizedTitle.startsWith(normalizedQuery)) return 1;
30
+ if (normalizedTitle.includes(normalizedQuery)) return 2;
31
+ return 3;
32
+ };
19
33
  const createCmsEntryRecord = (model, entry)=>({
20
34
  id: entry.id,
21
35
  entryId: entry.entryId,
@@ -52,25 +66,28 @@ const createCmsEntryRecord = (model, entry)=>({
52
66
  }
53
67
  });
54
68
  const getFetchMethod = (type, context)=>{
55
- if (!getContentEntriesMethods[type]) throw new error(`Unknown getContentEntries method "${type}". Could not fetch content entries.`, "UNKNOWN_METHOD_ERROR", {
56
- type
57
- });
58
- const methodName = getContentEntriesMethods[type];
59
- if (!context.cms[methodName]) throw new error(`Unknown context.cms method "${methodName}". Could not fetch content entries.`, "UNKNOWN_METHOD_ERROR", {
60
- type,
61
- methodName
62
- });
63
- return context.cms[methodName];
64
- };
65
- const getContentEntriesMethods = {
66
- latest: "getLatestEntriesByIds",
67
- published: "getPublishedEntriesByIds",
68
- exact: "getEntriesByIds"
69
+ if ("latest" === type) return async (model, ids)=>{
70
+ const result = await context.container.resolve(GetLatestEntriesByIdsUseCase).execute(model, ids);
71
+ if (result.isFail()) throw result.error;
72
+ return result.value;
73
+ };
74
+ if ("published" === type) return async (model, ids)=>{
75
+ const result = await context.container.resolve(GetPublishedEntriesByIdsUseCase).execute(model, ids);
76
+ if (result.isFail()) throw result.error;
77
+ return result.value;
78
+ };
79
+ return async (model, ids)=>{
80
+ const result = await context.container.resolve(GetEntriesByIdsUseCase).execute(model, ids);
81
+ if (result.isFail()) throw result.error;
82
+ return result.value;
83
+ };
69
84
  };
70
85
  const getContentEntries = async (params)=>{
71
86
  const { args, context, type } = params;
72
87
  const method = getFetchMethod(type, context);
73
- const models = await context.cms.listModels();
88
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
89
+ if (modelsResult.isFail()) throw modelsResult.error;
90
+ const models = modelsResult.value;
74
91
  const modelsMap = models.reduce((collection, model)=>{
75
92
  collection[model.modelId] = model;
76
93
  return collection;
@@ -98,14 +115,11 @@ const getContentEntries = async (params)=>{
98
115
  };
99
116
  const getContentEntry = async (params)=>{
100
117
  const { args, context, type } = params;
101
- if (!getContentEntriesMethods[type]) throw new error(`Unknown getContentEntry method "${type}". Could not fetch content entry.`, "UNKNOWN_METHOD_ERROR", {
102
- args,
103
- type
104
- });
105
118
  const method = getFetchMethod(type, context);
106
119
  const { modelId, id } = args.entry;
107
- const models = await context.cms.listModels();
108
- const model = models.find((m)=>m.modelId === modelId);
120
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
121
+ if (modelsResult.isFail()) throw modelsResult.error;
122
+ const model = modelsResult.value.find((m)=>m.modelId === modelId);
109
123
  if (!model) return new NotAuthorizedResponse({
110
124
  data: {
111
125
  modelId
@@ -119,8 +133,9 @@ const getContentEntry = async (params)=>{
119
133
  return new Response(createCmsEntryRecord(model, entry));
120
134
  };
121
135
  const createResolveDescription = ()=>async (parent, _, context)=>{
122
- const models = await context.cms.listModels();
123
- const model = models.find(({ modelId })=>parent.model.modelId === modelId);
136
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
137
+ if (modelsResult.isFail()) return null;
138
+ const model = modelsResult.value.find(({ modelId })=>parent.model.modelId === modelId);
124
139
  if (!model) return null;
125
140
  const field = model.fields.find((f)=>f.fieldId === model.descriptionFieldId);
126
141
  if (!field) return null;
@@ -134,12 +149,13 @@ const createResolveDescription = ()=>async (parent, _, context)=>{
134
149
  });
135
150
  };
136
151
  const createContentEntriesSchema = ({ context })=>{
137
- if (!context.cms.MANAGE) {
152
+ const enhancerConfig = context.container.resolve(HeadlessCmsEndpointConfig);
153
+ if ("manage" !== enhancerConfig.type) {
138
154
  const plugin = createCmsGraphQLSchemaPlugin({
139
155
  typeDefs: "",
140
156
  resolvers: {}
141
157
  });
142
- plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;
158
+ plugin.name = `headless-cms.graphql.schema.${enhancerConfig.type}.empty`;
143
159
  return plugin;
144
160
  }
145
161
  const onByMetaFields = ENTRY_META_FIELDS.map((field)=>{
@@ -218,12 +234,15 @@ const createContentEntriesSchema = ({ context })=>{
218
234
  CmsContentEntry: {
219
235
  published: async (parent, _, context)=>{
220
236
  try {
221
- const models = await context.cms.listModels();
222
- const model = models.find(({ modelId })=>parent.model.modelId === modelId);
237
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
238
+ if (modelsResult.isFail()) return null;
239
+ const model = modelsResult.value.find(({ modelId })=>parent.model.modelId === modelId);
223
240
  if (!model) return null;
224
- const [entry] = await context.cms.getPublishedEntriesByIds(model, [
241
+ const result = await context.container.resolve(GetPublishedEntriesByIdsUseCase).execute(model, [
225
242
  parent.id
226
243
  ]);
244
+ if (result.isFail()) return null;
245
+ const entry = result.value[0];
227
246
  if (!entry) return null;
228
247
  return createCmsEntryRecord(model, entry);
229
248
  } catch {
@@ -238,12 +257,15 @@ const createContentEntriesSchema = ({ context })=>{
238
257
  Query: {
239
258
  async searchContentEntries (_, args, context) {
240
259
  const { modelIds, fields, query, limit = 10 } = args;
241
- const models = await context.cms.listModels();
260
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
261
+ if (modelsResult.isFail()) return new ErrorResponse(modelsResult.error);
262
+ const models = modelsResult.value;
263
+ const storageLimit = query ? Math.max(limit, SEARCH_CANDIDATES_LIMIT) : limit;
242
264
  const getters = models.filter((model)=>modelIds.includes(model.modelId)).map(async (model)=>{
243
265
  const listLatest = await context.container.resolve(ListLatestEntriesUseCase);
244
266
  const where = {};
245
267
  const result = await listLatest.execute(model, {
246
- limit,
268
+ limit: storageLimit,
247
269
  where,
248
270
  search: query ? query : void 0,
249
271
  fields: fields || []
@@ -254,7 +276,11 @@ const createContentEntriesSchema = ({ context })=>{
254
276
  });
255
277
  try {
256
278
  const entries = await Promise.all(getters).then((results)=>results.reduce((result, item)=>result.concat(item), []));
257
- return new Response(entries.sort((a, b)=>b.savedOn.getTime() - a.savedOn.getTime()).slice(0, limit));
279
+ return new Response(entries.sort((a, b)=>{
280
+ const rank = getSearchRank(a.title, query) - getSearchRank(b.title, query);
281
+ if (0 !== rank) return rank;
282
+ return b.savedOn.getTime() - a.savedOn.getTime();
283
+ }).slice(0, limit));
258
284
  } catch (ex) {
259
285
  return new ErrorResponse(ex);
260
286
  }
@@ -304,7 +330,7 @@ const createContentEntriesSchema = ({ context })=>{
304
330
  }
305
331
  }
306
332
  });
307
- plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;
333
+ plugin.name = `headless-cms.graphql.schema.${context.container.resolve(HeadlessCmsEndpointConfig).type}.content-entries`;
308
334
  return plugin;
309
335
  };
310
336
  export { createContentEntriesSchema };
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntries method \"${type}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type\n }\n );\n }\n const methodName = getContentEntriesMethods[type] as GetContentEntryMethods;\n if (!context.cms[methodName]) {\n throw new WebinyError(\n `Unknown context.cms method \"${methodName}\". Could not fetch content entries.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n type,\n methodName\n }\n );\n }\n\n return context.cms[methodName];\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nenum GetContentEntryMethods {\n getLatestEntriesByIds = \"getLatestEntriesByIds\",\n getPublishedEntriesByIds = \"getPublishedEntriesByIds\",\n getEntriesByIds = \"getEntriesByIds\"\n}\n\nconst getContentEntriesMethods = {\n latest: \"getLatestEntriesByIds\",\n published: \"getPublishedEntriesByIds\",\n exact: \"getEntriesByIds\"\n};\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const models = await context.cms.listModels();\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n if (!getContentEntriesMethods[type]) {\n throw new WebinyError(\n `Unknown getContentEntry method \"${type}\". Could not fetch content entry.`,\n \"UNKNOWN_METHOD_ERROR\",\n {\n args,\n type\n }\n );\n }\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const models = await context.cms.listModels();\n const model = models.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n if (!context.cms.MANAGE) {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const models = await context.cms.listModels();\n const model = models.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const [entry] = await context.cms.getPublishedEntriesByIds(model, [\n parent.id\n ]);\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const models = await context.cms.listModels();\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => b.savedOn.getTime() - a.savedOn.getTime())\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","getContentEntriesMethods","WebinyError","methodName","getContentEntries","params","args","method","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","result","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","query","limit","listLatest","ListLatestEntriesUseCase","where","undefined","a","b"],"mappings":";;;;;;;;;;AA0BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AA+CA,MAAMC,uBAAuB,CAACC,OAAiBC,QACpC;QACH,IAAIA,MAAM,EAAE;QACZ,SAASA,MAAM,OAAO;QACtB,OAAO;YACH,SAASD,MAAM,OAAO;YACtB,MAAMA,MAAM,IAAI;QACpB;QACA,QAAQC,MAAM,MAAM;QACpB,OAAOC,cAAcF,OAAOC;QAC5B,aAAaE,oBAAoBH,OAAOC;QACxC,OAAOG,cAAcJ,OAAOC;QAK5B,WAAWL,WAAWK,MAAM,SAAS;QACrC,YAAYL,WAAWK,MAAM,UAAU;QACvC,SAASL,WAAWK,MAAM,OAAO;QACjC,WAAWA,MAAM,SAAS;QAC1B,SAASA,MAAM,OAAO;QACtB,YAAYA,MAAM,UAAU;QAC5B,kBAAkBL,WAAWK,MAAM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;oBACzC,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,yBAAwBiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAC/C,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BiC,CAAC,EAAE3B,IAAS,EAAEN,OAAO;oBAClD,OAAOI,kBAAkB;wBACrBE;wBACAN;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEAuC,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEvC,QAAQ,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAE/E,OAAOuC;AACX"}
1
+ {"version":3,"file":"graphql/schema/contentEntries.js","sources":["../../../src/graphql/schema/contentEntries.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/api-graphql\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsEntryListWhere,\n CmsIdentity,\n CmsModel\n} from \"~/types/index.js\";\nimport { getEntryTitle } from \"~/utils/getEntryTitle.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { getEntryDescription } from \"~/utils/getEntryDescription.js\";\nimport { getEntryImage } from \"~/utils/getEntryImage.js\";\nimport { entryFieldFromStorageTransform } from \"~/utils/entryStorage.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/api-graphql/types.js\";\nimport { ENTRY_META_FIELDS, isDateTimeEntryMetaField } from \"~/constants.js\";\nimport NotAuthorizedResponse from \"@webiny/api-core/graphql/security/NotAuthorizedResponse.js\";\nimport { ListLatestEntriesUseCase } from \"~/features/contentEntry/ListEntries/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { GetLatestEntriesByIdsUseCase } from \"~/features/contentEntry/GetLatestEntriesByIds/index.js\";\nimport { GetPublishedEntriesByIdsUseCase } from \"~/features/contentEntry/GetPublishedEntriesByIds/index.js\";\nimport { GetEntriesByIdsUseCase } from \"~/features/contentEntry/GetEntriesByIds/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\n\ninterface EntriesByModel {\n [key: string]: string[];\n}\n\ntype GetContentEntryType = \"latest\" | \"published\" | \"exact\";\n\nconst createDate = (date: string | null): Date | null => {\n if (!date) {\n return null;\n }\n\n try {\n return new Date(date);\n } catch {\n return new Date();\n }\n};\n\n/**\n * How many matches per model `searchContentEntries` reads before ranking them by title.\n */\nconst SEARCH_CANDIDATES_LIMIT = 100;\n\n/**\n * Lower rank comes first: an exact title match, then a title starting with the query,\n * then a title containing it, then entries that matched on some other field.\n */\nconst getSearchRank = (title: string, query?: string): number => {\n const normalizedQuery = query?.trim().toLowerCase();\n if (!normalizedQuery) {\n return 0;\n }\n const normalizedTitle = (title || \"\").trim().toLowerCase();\n if (normalizedTitle === normalizedQuery) {\n return 0;\n } else if (normalizedTitle.startsWith(normalizedQuery)) {\n return 1;\n } else if (normalizedTitle.includes(normalizedQuery)) {\n return 2;\n }\n return 3;\n};\n\ninterface CmsEntryRecord {\n id: string;\n entryId: string;\n model: {\n modelId: string;\n name: string;\n };\n status: string;\n title: string;\n description?: string | null;\n image?: string | null;\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: Date;\n modifiedOn: Date | null;\n savedOn: Date;\n createdBy: CmsIdentity;\n modifiedBy: CmsIdentity | null;\n savedBy: CmsIdentity;\n firstPublishedOn: Date | null;\n lastPublishedOn: Date | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedBy: CmsIdentity | null;\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: Date;\n revisionModifiedOn: Date | null;\n revisionSavedOn: Date;\n revisionCreatedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionSavedBy: CmsIdentity;\n revisionFirstPublishedOn: Date | null;\n revisionLastPublishedOn: Date | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n\n wbyAco_location?: {\n folderId?: string | null;\n };\n}\n\nconst createCmsEntryRecord = (model: CmsModel, entry: CmsEntry): CmsEntryRecord => {\n return {\n id: entry.id,\n entryId: entry.entryId,\n model: {\n modelId: model.modelId,\n name: model.name\n },\n status: entry.status,\n title: getEntryTitle(model, entry),\n description: getEntryDescription(model, entry),\n image: getEntryImage(model, entry),\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: createDate(entry.createdOn)!,\n modifiedOn: createDate(entry.modifiedOn),\n savedOn: createDate(entry.savedOn)!,\n createdBy: entry.createdBy,\n savedBy: entry.savedBy,\n modifiedBy: entry.modifiedBy,\n firstPublishedOn: createDate(entry.firstPublishedOn),\n lastPublishedOn: createDate(entry.lastPublishedOn),\n firstPublishedBy: entry.firstPublishedBy,\n lastPublishedBy: entry.lastPublishedBy,\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: createDate(entry.revisionCreatedOn)!,\n revisionSavedOn: createDate(entry.revisionSavedOn)!,\n revisionModifiedOn: createDate(entry.revisionModifiedOn),\n revisionCreatedBy: entry.revisionCreatedBy,\n revisionModifiedBy: entry.revisionModifiedBy,\n revisionSavedBy: entry.revisionSavedBy,\n revisionFirstPublishedOn: createDate(entry.revisionFirstPublishedOn),\n revisionLastPublishedOn: createDate(entry.revisionLastPublishedOn),\n revisionFirstPublishedBy: entry.revisionFirstPublishedBy,\n revisionLastPublishedBy: entry.revisionLastPublishedBy,\n\n wbyAco_location: {\n folderId: entry.location?.folderId || null\n }\n };\n};\n\ninterface FetchMethod {\n (model: CmsModel, ids: string[]): Promise<CmsEntry[]>;\n}\n\nconst getFetchMethod = (type: GetContentEntryType, context: CmsContext): FetchMethod => {\n if (type === \"latest\") {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetLatestEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n } else if (type === \"published\") {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetPublishedEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n } else {\n return async (model, ids) => {\n const result = await context.container\n .resolve(GetEntriesByIdsUseCase)\n .execute(model, ids);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n };\n }\n};\n\n/**\n * Function to get the list of content entries depending on latest, published or exact GraphQL queries.\n */\ninterface GetContentEntriesParams {\n args: {\n entries: Pick<CmsEntry, \"id\" | \"modelId\">[];\n };\n context: CmsContext;\n type: GetContentEntryType;\n}\n\nconst getContentEntries = async (\n params: GetContentEntriesParams\n): Promise<Response | ErrorResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value;\n\n const modelsMap = models.reduce(\n (collection, model) => {\n collection[model.modelId] = model;\n return collection;\n },\n {} as Record<string, CmsModel>\n );\n\n const argsEntries = args.entries as Pick<CmsEntry, \"id\" | \"modelId\">[];\n\n const entriesByModel = argsEntries.reduce((collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.id)) {\n return collection;\n }\n collection[ref.modelId].push(ref.id);\n return collection;\n }, {} as EntriesByModel);\n\n const getters: Promise<CmsEntry[]>[] = Object.keys(entriesByModel).map(async modelId => {\n return method(modelsMap[modelId], entriesByModel[modelId]);\n });\n\n if (getters.length === 0) {\n return new Response([]);\n }\n\n try {\n const results = await Promise.all(getters);\n\n const entries = results\n .reduce<CmsEntryRecord[]>((collection, items) => {\n return collection.concat(\n items.map(item => {\n const model = modelsMap[item.modelId];\n\n return createCmsEntryRecord(model, item);\n })\n );\n }, [])\n .filter(Boolean);\n\n return new Response(entries);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\n/**\n * Function to fetch a single content entry depending on latest, published or exact GraphQL query.\n */\ninterface GetContentEntryParams {\n args: {\n entry: Pick<CmsEntry, \"id\" | \"modelId\">;\n };\n context: CmsContext;\n type: \"latest\" | \"published\" | \"exact\";\n}\n\nconst getContentEntry = async (\n params: GetContentEntryParams\n): Promise<Response<CmsEntryRecord | null> | NotAuthorizedResponse> => {\n const { args, context, type } = params;\n\n const method = getFetchMethod(type, context);\n\n const { modelId, id } = args.entry;\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const model = modelsResult.value.find(m => m.modelId === modelId);\n\n if (!model) {\n return new NotAuthorizedResponse({\n data: {\n modelId\n }\n });\n }\n\n const result = await method(model, [id]);\n\n const entry = result.shift();\n if (!entry) {\n return new Response(null);\n }\n\n return new Response(createCmsEntryRecord(model, entry));\n};\n/**\n * As we support description field, we need to transform the value from storage.\n */\nconst createResolveDescription = (): GraphQLFieldResolver<any, any, CmsContext> => {\n return async (parent, _, context) => {\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n return null;\n }\n const model = modelsResult.value.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return null;\n }\n const value = parent.description || parent[field.fieldId];\n if (!value) {\n return null;\n }\n return entryFieldFromStorageTransform({\n context,\n model,\n field,\n value\n });\n };\n};\n\ninterface Params {\n context: CmsContext;\n}\n\nexport const createContentEntriesSchema = ({\n context\n}: Params): ICmsGraphQLSchemaPlugin<CmsContext> => {\n const enhancerConfig = context.container.resolve(HeadlessCmsEndpointConfig);\n if (enhancerConfig.type !== \"manage\") {\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: \"\",\n resolvers: {}\n });\n plugin.name = `headless-cms.graphql.schema.${enhancerConfig.type}.empty`;\n return plugin;\n }\n\n const onByMetaFields = ENTRY_META_FIELDS.map(field => {\n const fieldType = isDateTimeEntryMetaField(field) ? \"DateTime\" : \"CmsIdentity\";\n\n return `${field}: ${fieldType}`;\n }).join(\"\\n\");\n\n const plugin = createCmsGraphQLSchemaPlugin({\n // Had to remove /* GraphQL */ because it causes issues with oxfmt formatting.\n typeDefs: `\n type CmsModelMeta {\n modelId: String!\n name: String!\n }\n\n type CmsPublishedContentEntry {\n id: ID!\n entryId: String!\n title: String\n description: String\n image: String\n }\n\n type CmsContentEntry {\n id: ID!\n entryId: String!\n model: CmsModelMeta!\n status: String!\n published: CmsPublishedContentEntry\n title: String!\n description: String\n image: String\n \n ${onByMetaFields}\n \n wbyAco_location: WbyAcoLocation\n }\n\n type CmsContentEntriesResponse {\n data: [CmsContentEntry!]\n error: CmsError\n }\n\n type CmsContentEntryResponse {\n data: CmsContentEntry\n error: CmsError\n }\n\n input CmsModelEntryInput {\n modelId: ID!\n id: ID!\n }\n\n extend type Query {\n # Search content entries for given content models using the query string.\n searchContentEntries(\n modelIds: [ID!]!\n query: String\n fields: [String!]\n limit: Int\n ): CmsContentEntriesResponse!\n\n # Get content entry meta data\n getContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n getLatestContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n getPublishedContentEntry(entry: CmsModelEntryInput!): CmsContentEntryResponse!\n\n # Get content entries meta data\n getContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getLatestContentEntries(entries: [CmsModelEntryInput!]!): CmsContentEntriesResponse!\n getPublishedContentEntries(\n entries: [CmsModelEntryInput!]!\n ): CmsContentEntriesResponse!\n }\n `,\n resolvers: {\n CmsContentEntry: {\n published: async (parent, _, context) => {\n try {\n const modelsResult = await context.container\n .resolve(ListModelsUseCase)\n .execute();\n if (modelsResult.isFail()) {\n return null;\n }\n const model = modelsResult.value.find(({ modelId }) => {\n return parent.model.modelId === modelId;\n });\n if (!model) {\n return null;\n }\n const result = await context.container\n .resolve(GetPublishedEntriesByIdsUseCase)\n .execute(model, [parent.id]);\n if (result.isFail()) {\n return null;\n }\n const entry = result.value[0];\n if (!entry) {\n return null;\n }\n return createCmsEntryRecord(model, entry);\n } catch {\n return null;\n }\n },\n description: createResolveDescription()\n },\n CmsPublishedContentEntry: {\n description: createResolveDescription()\n },\n Query: {\n async searchContentEntries(_, args: any, context) {\n const { modelIds, fields, query, limit = 10 } = args;\n const modelsResult = await context.container\n .resolve(ListModelsUseCase)\n .execute();\n if (modelsResult.isFail()) {\n return new ErrorResponse(modelsResult.error);\n }\n const models = modelsResult.value;\n\n /**\n * Full-text search matches the query against every searchable field, and the storage\n * returns the newest-created matches first. When many entries mention the query somewhere\n * in their content, an older entry whose title is the query falls outside the first `limit`.\n * So when searching, read more candidates than requested, rank them by title, then cut.\n */\n const storageLimit = query ? Math.max(limit, SEARCH_CANDIDATES_LIMIT) : limit;\n\n const getters = models\n .filter(model => modelIds.includes(model.modelId))\n .map(async model => {\n const listLatest =\n await context.container.resolve(ListLatestEntriesUseCase);\n const where: CmsEntryListWhere = {};\n\n const result = await listLatest.execute(model, {\n limit: storageLimit,\n where,\n search: !!query ? query : undefined,\n fields: fields || []\n });\n // TODO figure a better way to handle errors in parallel execution\n if (result.isFail()) {\n throw result.error;\n }\n const { entries } = result.value;\n return entries.map((entry: CmsEntry) => {\n return createCmsEntryRecord(model, entry);\n });\n });\n\n try {\n const entries = await Promise.all(getters).then(results =>\n results.reduce((result, item) => result.concat(item), [])\n );\n\n return new Response(\n entries\n .sort((a, b) => {\n const rank =\n getSearchRank(a.title, query) -\n getSearchRank(b.title, query);\n if (rank !== 0) {\n return rank;\n }\n return b.savedOn.getTime() - a.savedOn.getTime();\n })\n .slice(0, limit)\n );\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n async getContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntry(_, args: any, context) {\n return getContentEntry({\n args,\n context,\n type: \"published\"\n });\n },\n async getContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"exact\"\n });\n },\n async getLatestContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"latest\"\n });\n },\n async getPublishedContentEntries(_, args: any, context) {\n return getContentEntries({\n args,\n context,\n type: \"published\"\n });\n }\n }\n }\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.container.resolve(HeadlessCmsEndpointConfig).type}.content-entries`;\n\n return plugin;\n};\n"],"names":["createDate","date","Date","SEARCH_CANDIDATES_LIMIT","getSearchRank","title","query","normalizedQuery","normalizedTitle","createCmsEntryRecord","model","entry","getEntryTitle","getEntryDescription","getEntryImage","getFetchMethod","type","context","ids","result","GetLatestEntriesByIdsUseCase","GetPublishedEntriesByIdsUseCase","GetEntriesByIdsUseCase","getContentEntries","params","args","method","modelsResult","ListModelsUseCase","models","modelsMap","collection","argsEntries","entriesByModel","ref","getters","Object","modelId","Response","results","Promise","entries","items","item","Boolean","ex","ErrorResponse","getContentEntry","id","m","NotAuthorizedResponse","createResolveDescription","parent","_","field","f","value","entryFieldFromStorageTransform","createContentEntriesSchema","enhancerConfig","HeadlessCmsEndpointConfig","plugin","createCmsGraphQLSchemaPlugin","onByMetaFields","ENTRY_META_FIELDS","fieldType","isDateTimeEntryMetaField","modelIds","fields","limit","storageLimit","Math","listLatest","ListLatestEntriesUseCase","where","undefined","a","b","rank"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAMA,aAAa,CAACC;IAChB,IAAI,CAACA,MACD,OAAO;IAGX,IAAI;QACA,OAAO,IAAIC,KAAKD;IACpB,EAAE,OAAM;QACJ,OAAO,IAAIC;IACf;AACJ;AAKA,MAAMC,0BAA0B;AAMhC,MAAMC,gBAAgB,CAACC,OAAeC;IAClC,MAAMC,kBAAkBD,OAAO,OAAO;IACtC,IAAI,CAACC,iBACD,OAAO;IAEX,MAAMC,kBAAmBH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ACJ;gBACA,MAAM,uBAAsBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAC7C,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,0BAAyBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAChD,OAAO8B,gBAAgB;wBACnBtB;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,mBAAkBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBACzC,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,yBAAwBoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAC/C,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;gBACA,MAAM,4BAA2BoC,CAAC,EAAE5B,IAAS,EAAER,OAAO;oBAClD,OAAOM,kBAAkB;wBACrBE;wBACAR;wBACA,MAAM;oBACV;gBACJ;YACJ;QACJ;IACJ;IAEA4C,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAE5C,QAAQ,SAAS,CAAC,OAAO,CAAC2C,2BAA2B,IAAI,CAAC,gBAAgB,CAAC;IAExH,OAAOC;AACX"}
@@ -1,9 +1,18 @@
1
- import { ErrorResponse, NotFoundError, Response } from "@webiny/handler-graphql";
2
- import { CmsGroupPlugin } from "../../plugins/CmsGroupPlugin.js";
1
+ import { ErrorResponse, NotFoundError, Response } from "@webiny/api-graphql";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
3
3
  import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
4
+ import { GetGroupUseCase } from "../../features/contentModelGroup/GetGroup/index.js";
5
+ import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
6
+ import { CreateGroupUseCase } from "../../features/contentModelGroup/CreateGroup/index.js";
7
+ import { UpdateGroupUseCase } from "../../features/contentModelGroup/UpdateGroup/index.js";
8
+ import { DeleteGroupUseCase } from "../../features/contentModelGroup/DeleteGroup/index.js";
9
+ import { PluginGroupsProvider } from "../../features/contentModelGroup/shared/index.js";
10
+ import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
11
+ import { HeadlessCmsEndpointConfig } from "../../HeadlessCmsEndpointConfig.js";
4
12
  const createGroupsSchema = ({ context })=>{
13
+ const isManage = "manage" === context.container.resolve(HeadlessCmsEndpointConfig).type;
5
14
  let manageSchema = "";
6
- if (context.cms.MANAGE) manageSchema = `
15
+ if (isManage) manageSchema = `
7
16
  input CmsContentModelGroupInput {
8
17
  id: ID
9
18
  name: String!
@@ -42,29 +51,36 @@ const createGroupsSchema = ({ context })=>{
42
51
  }
43
52
  `;
44
53
  let resolvers = {};
45
- if (context.cms.MANAGE) resolvers = {
54
+ if (isManage) resolvers = {
46
55
  CmsContentModelGroup: {
47
56
  contentModels: async (group, _, context)=>{
48
- const models = await context.security.withoutAuthorization(async ()=>context.cms.listModels());
49
- return models.filter((model)=>{
57
+ const result = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
58
+ if (result.isFail()) return [];
59
+ return result.value.filter((model)=>{
50
60
  if (true === model.isPrivate) return false;
51
61
  return model.group === group.slug;
52
62
  });
53
63
  },
54
64
  totalContentModels: async (group, _, context)=>{
55
- const models = await context.security.withoutAuthorization(async ()=>context.cms.listModels());
56
- return models.filter((model)=>{
65
+ const result = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
66
+ if (result.isFail()) return 0;
67
+ return result.value.filter((model)=>{
57
68
  if (true === model.isPrivate) return false;
58
69
  return model.group === group.slug;
59
70
  }).length;
60
71
  },
61
- plugin: async (group, _, context)=>context.plugins.byType(CmsGroupPlugin.type).some((item)=>item.contentModelGroup.id === group.id)
72
+ plugin: async (group, _, context)=>{
73
+ const pluginGroups = await context.container.resolve(PluginGroupsProvider).getGroups();
74
+ return pluginGroups.some((pg)=>pg.id === group.id);
75
+ }
62
76
  },
63
77
  Query: {
64
78
  getContentModelGroup: async (_, args, context)=>{
65
79
  try {
66
80
  const { id } = args;
67
- const group = await context.cms.getGroup(id);
81
+ const result = await context.container.resolve(GetGroupUseCase).execute(id);
82
+ if (result.isFail()) throw result.error;
83
+ const group = result.value;
68
84
  if (group?.isPrivate) throw new NotFoundError(`Cms Group "${id}" was not found!`);
69
85
  return new Response(group);
70
86
  } catch (e) {
@@ -73,8 +89,9 @@ const createGroupsSchema = ({ context })=>{
73
89
  },
74
90
  listContentModelGroups: async (_, __, context)=>{
75
91
  try {
76
- const groups = await context.cms.listGroups();
77
- return new Response(groups.filter((group)=>true !== group.isPrivate));
92
+ const result = await context.container.resolve(ListGroupsUseCase).execute();
93
+ if (result.isFail()) throw result.error;
94
+ return new Response(result.value.filter((group)=>true !== group.isPrivate));
78
95
  } catch (e) {
79
96
  return new ErrorResponse(e);
80
97
  }
@@ -83,23 +100,26 @@ const createGroupsSchema = ({ context })=>{
83
100
  Mutation: {
84
101
  createContentModelGroup: async (_, args, context)=>{
85
102
  try {
86
- const model = await context.cms.createGroup(args.data);
87
- return new Response(model);
103
+ const result = await context.container.resolve(CreateGroupUseCase).execute(args.data);
104
+ if (result.isFail()) throw result.error;
105
+ return new Response(result.value);
88
106
  } catch (e) {
89
107
  return new ErrorResponse(e);
90
108
  }
91
109
  },
92
110
  updateContentModelGroup: async (_, args, context)=>{
93
111
  try {
94
- const group = await context.cms.updateGroup(args.id, args.data);
95
- return new Response(group);
112
+ const result = await context.container.resolve(UpdateGroupUseCase).execute(args.id, args.data);
113
+ if (result.isFail()) throw result.error;
114
+ return new Response(result.value);
96
115
  } catch (e) {
97
116
  return new ErrorResponse(e);
98
117
  }
99
118
  },
100
119
  deleteContentModelGroup: async (_, args, context)=>{
101
120
  try {
102
- await context.cms.deleteGroup(args.id);
121
+ const result = await context.container.resolve(DeleteGroupUseCase).execute(args.id);
122
+ if (result.isFail()) throw result.error;
103
123
  return new Response(true);
104
124
  } catch (e) {
105
125
  return new ErrorResponse(e);
@@ -128,7 +148,8 @@ const createGroupsSchema = ({ context })=>{
128
148
  `,
129
149
  resolvers
130
150
  });
131
- plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;
151
+ const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;
152
+ plugin.name = `headless-cms.graphql.schema.${endpointType}.content-model-groups`;
132
153
  return plugin;
133
154
  };
134
155
  export { createGroupsSchema };
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/handler-graphql\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n let manageSchema = \"\";\n if (context.cms.MANAGE) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (context.cms.MANAGE) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n });\n },\n totalContentModels: async (group, _, context) => {\n const models = await context.security.withoutAuthorization(async () => {\n return context.cms.listModels();\n });\n return models.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n }).length;\n },\n plugin: async (group, _, context: CmsContext): Promise<boolean> => {\n return context.plugins\n .byType<CmsGroupPlugin>(CmsGroupPlugin.type)\n .some(item => item.contentModelGroup.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const group = await context.cms.getGroup(id);\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const groups = await context.cms.listGroups();\n return new Response(groups.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const model = await context.cms.createGroup(args.data);\n return new Response(model);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const group = await context.cms.updateGroup(args.id, args.data);\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n await context.cms.deleteGroup(args.id);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n plugin.name = `headless-cms.graphql.schema.${context.cms.type}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["createGroupsSchema","context","manageSchema","resolvers","group","_","models","model","CmsGroupPlugin","item","args","id","NotFoundError","Response","e","ErrorResponse","__","groups","plugin","createCmsGraphQLSchemaPlugin"],"mappings":";;;AAUO,MAAMA,qBAAqB,CAAC,EAAEC,OAAO,EAAU;IAClD,IAAIC,eAAe;IACnB,IAAID,QAAQ,GAAG,CAAC,MAAM,EAClBC,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqC9B,CAAC;IAGL,IAAIC,YAAmC,CAAC;IAExC,IAAIF,QAAQ,GAAG,CAAC,MAAM,EAClBE,YAAY;QACR,sBAAsB;YAClB,eAAe,OAAOC,OAAOC,GAAGJ;gBAC5B,MAAMK,SAAS,MAAML,QAAQ,QAAQ,CAAC,oBAAoB,CAAC,UAChDA,QAAQ,GAAG,CAAC,UAAU;gBAEjC,OAAOK,OAAO,MAAM,CAACC,CAAAA;oBACjB,IAAIA,AAAoB,SAApBA,MAAM,SAAS,EACf,OAAO;oBAEX,OAAOA,MAAM,KAAK,KAAKH,MAAM,IAAI;gBACrC;YACJ;YACA,oBAAoB,OAAOA,OAAOC,GAAGJ;gBACjC,MAAMK,SAAS,MAAML,QAAQ,QAAQ,CAAC,oBAAoB,CAAC,UAChDA,QAAQ,GAAG,CAAC,UAAU;gBAEjC,OAAOK,OAAO,MAAM,CAACC,CAAAA;oBACjB,IAAIA,AAAoB,SAApBA,MAAM,SAAS,EACf,OAAO;oBAEX,OAAOA,MAAM,KAAK,KAAKH,MAAM,IAAI;gBACrC,GAAG,MAAM;YACb;YACA,QAAQ,OAAOA,OAAOC,GAAGJ,UACdA,QAAQ,OAAO,CACjB,MAAM,CAAiBO,eAA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AC,WAAW,CAACS,KAAK,EAAE;oBACrC,OAAO,IAAIG,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;IACJ;IAGJ,MAAMI,SAASC,6BAA6B;QACxC,UAAwB,CAAC;;;;;;;;;;;;;;;;YAgBrB,EAAEjB,aAAa;QACnB,CAAC;QACDC;IACJ;IAEAe,OAAO,IAAI,GAAG,CAAC,4BAA4B,EAAEjB,QAAQ,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IAEpF,OAAOiB;AACX"}
1
+ {"version":3,"file":"graphql/schema/contentModelGroups.js","sources":["../../../src/graphql/schema/contentModelGroups.ts"],"sourcesContent":["import { ErrorResponse, NotFoundError, Response } from \"@webiny/api-graphql\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport type { Resolvers } from \"@webiny/api-graphql/types.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/index.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\nimport { DeleteGroupUseCase } from \"~/features/contentModelGroup/DeleteGroup/index.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\n\ninterface Params {\n context: CmsContext;\n}\nexport const createGroupsSchema = ({ context }: Params): ICmsGraphQLSchemaPlugin => {\n const isManage = context.container.resolve(HeadlessCmsEndpointConfig).type === \"manage\";\n\n let manageSchema = \"\";\n if (isManage) {\n manageSchema = /* GraphQL */ `\n input CmsContentModelGroupInput {\n id: ID\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n type CmsContentModelGroupResponse {\n data: CmsContentModelGroup\n error: CmsError\n }\n\n type CmsContentModelGroupListResponse {\n data: [CmsContentModelGroup]\n meta: CmsListMeta\n error: CmsError\n }\n\n extend type Query {\n getContentModelGroup(id: ID): CmsContentModelGroupResponse\n listContentModelGroups: CmsContentModelGroupListResponse\n }\n\n extend type Mutation {\n createContentModelGroup(\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n updateContentModelGroup(\n id: ID!\n data: CmsContentModelGroupInput!\n ): CmsContentModelGroupResponse\n\n deleteContentModelGroup(id: ID!): CmsDeleteResponse\n }\n `;\n }\n\n let resolvers: Resolvers<CmsContext> = {};\n\n if (isManage) {\n resolvers = {\n CmsContentModelGroup: {\n contentModels: async (group, _, context) => {\n const result = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (result.isFail()) {\n return [];\n }\n return result.value.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n });\n },\n totalContentModels: async (group, _, context) => {\n const result = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (result.isFail()) {\n return 0;\n }\n return result.value.filter(model => {\n if (model.isPrivate === true) {\n return false;\n }\n return model.group === group.slug;\n }).length;\n },\n plugin: async (group, _, context) => {\n const pluginGroups = await context.container\n .resolve(PluginGroupsProvider)\n .getGroups();\n return pluginGroups.some(pg => pg.id === group.id);\n }\n },\n Query: {\n getContentModelGroup: async (_, args: any, context) => {\n try {\n const { id } = args;\n const result = await context.container.resolve(GetGroupUseCase).execute(id);\n if (result.isFail()) {\n throw result.error;\n }\n const group = result.value;\n if (group?.isPrivate) {\n throw new NotFoundError(`Cms Group \"${id}\" was not found!`);\n }\n return new Response(group);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listContentModelGroups: async (_, __, context) => {\n try {\n const result = await context.container.resolve(ListGroupsUseCase).execute();\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value.filter(group => group.isPrivate !== true));\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n Mutation: {\n createContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(CreateGroupUseCase)\n .execute(args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(UpdateGroupUseCase)\n .execute(args.id, args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteContentModelGroup: async (_, args: any, context) => {\n try {\n const result = await context.container\n .resolve(DeleteGroupUseCase)\n .execute(args.id);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n };\n }\n\n const plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsContentModelGroup {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n name: String!\n contentModels: [CmsContentModel!]\n totalContentModels: Int!\n slug: String!\n description: String\n icon: Icon\n createdBy: CmsIdentity\n\n # Returns true if the content model group is registered via a plugin.\n plugin: Boolean!\n }\n ${manageSchema}\n `,\n resolvers\n });\n\n const endpointType = context.container.resolve(HeadlessCmsEndpointConfig).type;\n plugin.name = `headless-cms.graphql.schema.${endpointType}.content-model-groups`;\n\n return plugin;\n};\n"],"names":["createGroupsSchema","context","isManage","HeadlessCmsEndpointConfig","manageSchema","resolvers","group","_","result","IdentityContext","ListModelsUseCase","model","pluginGroups","PluginGroupsProvider","pg","args","id","GetGroupUseCase","NotFoundError","Response","e","ErrorResponse","__","ListGroupsUseCase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