@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,8 +1,8 @@
1
1
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
2
- import { CmsContext } from "../../../features/shared/abstractions.js";
3
2
  import { AccessControl } from "../../../features/shared/abstractions.js";
4
3
  import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
4
  import { ModelGroupFactory, PluginGroupsProvider as ProviderAbstraction } from "./abstractions.js";
5
+ import type { CmsGroupPlugin } from "../../../plugins/CmsGroupPlugin.js";
6
6
  import type { CmsGroup } from "../../../types/index.js";
7
7
  /**
8
8
  * PluginGroupsProvider implementation
@@ -13,13 +13,15 @@ import type { CmsGroup } from "../../../types/index.js";
13
13
  */
14
14
  declare class PluginGroupsProviderImpl implements ProviderAbstraction.Interface {
15
15
  private tenantContext;
16
- private cmsContext;
16
+ private pluginGroups;
17
17
  private accessControl;
18
18
  private identityContext;
19
19
  private groupFactories;
20
20
  private cache;
21
- constructor(tenantContext: TenantContext.Interface, cmsContext: CmsContext.Interface, accessControl: AccessControl.Interface, identityContext: IdentityContext.Interface, groupFactories: ModelGroupFactory.Interface[]);
21
+ constructor(tenantContext: TenantContext.Interface, pluginGroups: CmsGroupPlugin[], accessControl: AccessControl.Interface, identityContext: IdentityContext.Interface, groupFactories: ModelGroupFactory.Interface[]);
22
22
  getGroups(): Promise<CmsGroup[]>;
23
23
  }
24
- export declare const PluginGroupsProvider: import("@webiny/di").Implementation<typeof PluginGroupsProviderImpl>;
24
+ export declare const PluginGroupsProvider: typeof PluginGroupsProviderImpl & {
25
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IPluginGroupsProvider>;
26
+ };
25
27
  export {};
@@ -1,15 +1,13 @@
1
- import { createImplementation } from "@webiny/feature/api";
2
1
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
3
- import { AccessControl, CmsContext } from "../../shared/abstractions.js";
2
+ import { AccessControl } from "../../shared/abstractions.js";
4
3
  import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
- import { ModelGroupFactory, PluginGroupsProvider } from "./abstractions.js";
6
- import { CmsGroupPlugin } from "../../../plugins/CmsGroupPlugin.js";
4
+ import { CmsGroupPluginInstance, ModelGroupFactory, PluginGroupsProvider } from "./abstractions.js";
7
5
  import { filterAsync } from "../../../utils/filterAsync.js";
8
6
  import { createCacheKey, createMemoryCache } from "../../../utils/index.js";
9
7
  class PluginGroupsProviderImpl {
10
- constructor(tenantContext, cmsContext, accessControl, identityContext, groupFactories){
8
+ constructor(tenantContext, pluginGroups, accessControl, identityContext, groupFactories){
11
9
  this.tenantContext = tenantContext;
12
- this.cmsContext = cmsContext;
10
+ this.pluginGroups = pluginGroups;
13
11
  this.accessControl = accessControl;
14
12
  this.identityContext = identityContext;
15
13
  this.groupFactories = groupFactories;
@@ -17,10 +15,10 @@ class PluginGroupsProviderImpl {
17
15
  }
18
16
  async getGroups() {
19
17
  const tenant = this.tenantContext.getTenant();
20
- const pluginGroups = this.cmsContext.plugins.byType(CmsGroupPlugin.type);
18
+ const pluginGroups = this.pluginGroups;
21
19
  const cacheKey = createCacheKey({
22
20
  tenant: tenant.id,
23
- identity: this.cmsContext.security.isAuthorizationEnabled() ? this.identityContext.getIdentity()?.id : void 0,
21
+ identity: this.identityContext.isAuthorizationEnabled() ? this.identityContext.getIdentity()?.id : void 0,
24
22
  groups: pluginGroups.map(({ contentModelGroup: group })=>`${group.id}#${group.slug}#${group.savedOn || "unknown"}`).join("/"),
25
23
  codeGroups: this.groupFactories.length
26
24
  });
@@ -51,12 +49,16 @@ class PluginGroupsProviderImpl {
51
49
  });
52
50
  }
53
51
  }
54
- const PluginGroupsProvider_PluginGroupsProvider = createImplementation({
55
- abstraction: PluginGroupsProvider,
52
+ const PluginGroupsProvider_PluginGroupsProvider = PluginGroupsProvider.createImplementation({
56
53
  implementation: PluginGroupsProviderImpl,
57
54
  dependencies: [
58
55
  TenantContext,
59
- CmsContext,
56
+ [
57
+ CmsGroupPluginInstance,
58
+ {
59
+ multiple: true
60
+ }
61
+ ],
60
62
  AccessControl,
61
63
  IdentityContext,
62
64
  [
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentModelGroup/shared/PluginGroupsProvider.js","sources":["../../../../src/features/contentModelGroup/shared/PluginGroupsProvider.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { CmsContext } from \"~/features/shared/abstractions.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { ModelGroupFactory, PluginGroupsProvider as ProviderAbstraction } from \"./abstractions.js\";\nimport { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport { filterAsync } from \"~/utils/filterAsync.js\";\nimport { createCacheKey } from \"~/utils/index.js\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\n\n/**\n * PluginGroupsProvider implementation\n *\n * Fetches groups from CmsGroupPlugin instances.\n * Filters by tenant and applies access control.\n * Results are cached based on tenant + identity + plugin signatures.\n */\nclass PluginGroupsProviderImpl implements ProviderAbstraction.Interface {\n private cache = createMemoryCache<Promise<CmsGroup[]>>();\n\n public constructor(\n private tenantContext: TenantContext.Interface,\n private cmsContext: CmsContext.Interface,\n private accessControl: AccessControl.Interface,\n private identityContext: IdentityContext.Interface,\n private groupFactories: ModelGroupFactory.Interface[]\n ) {}\n\n async getGroups(): Promise<CmsGroup[]> {\n const tenant = this.tenantContext.getTenant();\n const pluginGroups = this.cmsContext.plugins.byType<CmsGroupPlugin>(CmsGroupPlugin.type);\n\n const cacheKey = createCacheKey({\n tenant: tenant.id,\n identity: this.cmsContext.security.isAuthorizationEnabled()\n ? this.identityContext.getIdentity()?.id\n : undefined,\n groups: pluginGroups\n .map(({ contentModelGroup: group }) => {\n return `${group.id}#${group.slug}#${group.savedOn || \"unknown\"}`;\n })\n .join(\"/\"),\n codeGroups: this.groupFactories.length\n });\n\n return this.cache.getOrSet(cacheKey, async (): Promise<CmsGroup[]> => {\n // TODO: once the legacy code plugins are removed, clean this up.\n // Currently, this code makes the new group compatible with the legacy one.\n const codeGroups: CmsGroup[] = await Promise.all(\n this.groupFactories.map(factory => factory.execute())\n ).then(result => {\n return result.flat().map<CmsGroup>(group => ({\n ...group,\n id: group.slug,\n tenant: tenant.id,\n description: \"\"\n }));\n });\n\n const groups = pluginGroups\n // Filter by tenant if specified in plugin\n // If not specified, plugin group is available for all tenants\n .filter(plugin => {\n const { tenant: t } = plugin.contentModelGroup;\n if (t && t !== tenant.id) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant: tenant.id\n };\n });\n\n // Apply access control filtering\n return filterAsync([...codeGroups, ...groups], async (group?: CmsGroup) => {\n if (!group) {\n return false;\n }\n return this.accessControl.canAccessGroup({ group });\n });\n });\n }\n}\n\nexport const PluginGroupsProvider = createImplementation({\n abstraction: ProviderAbstraction,\n implementation: PluginGroupsProviderImpl,\n dependencies: [\n TenantContext,\n CmsContext,\n AccessControl,\n IdentityContext,\n [ModelGroupFactory, { multiple: true }]\n ]\n});\n"],"names":["PluginGroupsProviderImpl","tenantContext","cmsContext","accessControl","identityContext","groupFactories","createMemoryCache","tenant","pluginGroups","CmsGroupPlugin","cacheKey","createCacheKey","undefined","group","codeGroups","Promise","factory","result","groups","plugin","t","filterAsync","PluginGroupsProvider","createImplementation","ProviderAbstraction","TenantContext","CmsContext","AccessControl","IdentityContext","ModelGroupFactory"],"mappings":";;;;;;;;AAmBA,MAAMA;IAGF,YACYC,aAAsC,EACtCC,UAAgC,EAChCC,aAAsC,EACtCC,eAA0C,EAC1CC,cAA6C,CACvD;aALUJ,aAAa,GAAbA;aACAC,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;aACAC,cAAc,GAAdA;aAPJ,KAAK,GAAGC;IAQb;IAEH,MAAM,YAAiC;QACnC,MAAMC,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,MAAMC,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IACJ;AACJ;AAEO,MAAMS,4CAAuBC,qBAAqB;IACrD,aAAaC;IACb,gBAAgBxB;IAChB,cAAc;QACVyB;QACAC;QACAC;QACAC;QACA;YAACC;YAAmB;gBAAE,UAAU;YAAK;SAAE;KAC1C;AACL"}
1
+ {"version":3,"file":"features/contentModelGroup/shared/PluginGroupsProvider.js","sources":["../../../../src/features/contentModelGroup/shared/PluginGroupsProvider.ts"],"sourcesContent":["import { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport {\n CmsGroupPluginInstance,\n ModelGroupFactory,\n PluginGroupsProvider as ProviderAbstraction\n} from \"./abstractions.js\";\nimport type { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\nimport { filterAsync } from \"~/utils/filterAsync.js\";\nimport { createCacheKey } from \"~/utils/index.js\";\nimport { createMemoryCache } from \"~/utils/index.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\n\n/**\n * PluginGroupsProvider implementation\n *\n * Fetches groups from CmsGroupPlugin instances.\n * Filters by tenant and applies access control.\n * Results are cached based on tenant + identity + plugin signatures.\n */\nclass PluginGroupsProviderImpl implements ProviderAbstraction.Interface {\n private cache = createMemoryCache<Promise<CmsGroup[]>>();\n\n public constructor(\n private tenantContext: TenantContext.Interface,\n private pluginGroups: CmsGroupPlugin[],\n private accessControl: AccessControl.Interface,\n private identityContext: IdentityContext.Interface,\n private groupFactories: ModelGroupFactory.Interface[]\n ) {}\n\n async getGroups(): Promise<CmsGroup[]> {\n const tenant = this.tenantContext.getTenant();\n const pluginGroups = this.pluginGroups;\n\n const cacheKey = createCacheKey({\n tenant: tenant.id,\n identity: this.identityContext.isAuthorizationEnabled()\n ? this.identityContext.getIdentity()?.id\n : undefined,\n groups: pluginGroups\n .map(({ contentModelGroup: group }) => {\n return `${group.id}#${group.slug}#${group.savedOn || \"unknown\"}`;\n })\n .join(\"/\"),\n codeGroups: this.groupFactories.length\n });\n\n return this.cache.getOrSet(cacheKey, async (): Promise<CmsGroup[]> => {\n // TODO: once the legacy code plugins are removed, clean this up.\n // Currently, this code makes the new group compatible with the legacy one.\n const codeGroups: CmsGroup[] = await Promise.all(\n this.groupFactories.map(factory => factory.execute())\n ).then(result => {\n return result.flat().map<CmsGroup>(group => ({\n ...group,\n id: group.slug,\n tenant: tenant.id,\n description: \"\"\n }));\n });\n\n const groups = pluginGroups\n // Filter by tenant if specified in plugin\n // If not specified, plugin group is available for all tenants\n .filter(plugin => {\n const { tenant: t } = plugin.contentModelGroup;\n if (t && t !== tenant.id) {\n return false;\n }\n return true;\n })\n .map(plugin => {\n return {\n ...plugin.contentModelGroup,\n tenant: tenant.id\n };\n });\n\n // Apply access control filtering\n return filterAsync([...codeGroups, ...groups], async (group?: CmsGroup) => {\n if (!group) {\n return false;\n }\n return this.accessControl.canAccessGroup({ group });\n });\n });\n }\n}\n\nexport const PluginGroupsProvider = ProviderAbstraction.createImplementation({\n implementation: PluginGroupsProviderImpl,\n dependencies: [\n TenantContext,\n [CmsGroupPluginInstance, { multiple: true }],\n AccessControl,\n IdentityContext,\n [ModelGroupFactory, { multiple: true }]\n ]\n});\n"],"names":["PluginGroupsProviderImpl","tenantContext","pluginGroups","accessControl","identityContext","groupFactories","createMemoryCache","tenant","cacheKey","createCacheKey","undefined","group","codeGroups","Promise","factory","result","groups","plugin","t","filterAsync","PluginGroupsProvider","ProviderAbstraction","TenantContext","CmsGroupPluginInstance","AccessControl","IdentityContext","ModelGroupFactory"],"mappings":";;;;;;AAqBA,MAAMA;IAGF,YACYC,aAAsC,EACtCC,YAA8B,EAC9BC,aAAsC,EACtCC,eAA0C,EAC1CC,cAA6C,CACvD;aALUJ,aAAa,GAAbA;aACAC,YAAY,GAAZA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;aACAC,cAAc,GAAdA;aAPJ,KAAK,GAAGC;IAQb;IAEH,MA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M;YACrD;QACJ;IACJ;AACJ;AAEO,MAAMS,4CAAuBC,qBAAAA,oBAAwC,CAAC;IACzE,gBAAgBrB;IAChB,cAAc;QACVsB;QACA;YAACC;YAAwB;gBAAE,UAAU;YAAK;SAAE;QAC5CC;QACAC;QACA;YAACC;YAAmB;gBAAE,UAAU;YAAK;SAAE;KAC1C;AACL"}
@@ -1,5 +1,15 @@
1
1
  import type { CmsGroup, CmsIcon } from "../../../types/index.js";
2
2
  import type { ICache } from "../../../utils/caching/types.js";
3
+ import type { CmsGroupPlugin } from "../../../plugins/CmsGroupPlugin.js";
4
+ /**
5
+ * Multi-instance DI token holding the code-defined CmsGroupPlugin instances
6
+ * (previously read from the plugins container via byType). PluginGroupsProvider
7
+ * resolves all of these to expose plugin-defined groups.
8
+ */
9
+ export declare const CmsGroupPluginInstance: import("@webiny/di").Abstraction<CmsGroupPlugin>;
10
+ export declare namespace CmsGroupPluginInstance {
11
+ type Interface = CmsGroupPlugin;
12
+ }
3
13
  /**
4
14
  * PluginGroupsProvider provides access to plugin-defined (code) groups.
5
15
  */
@@ -1,7 +1,8 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
+ const CmsGroupPluginInstance = createAbstraction("CmsGroupPluginInstance");
2
3
  const PluginGroupsProvider = createAbstraction("PluginGroupsProvider");
3
4
  const GroupCache = createAbstraction("GroupCache");
4
5
  const ModelGroupFactory = createAbstraction("ModelGroupFactory");
5
- export { GroupCache, ModelGroupFactory, PluginGroupsProvider };
6
+ export { CmsGroupPluginInstance, GroupCache, ModelGroupFactory, PluginGroupsProvider };
6
7
 
7
8
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentModelGroup/shared/abstractions.js","sources":["../../../../src/features/contentModelGroup/shared/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsGroup, CmsIcon } from \"~/types/index.js\";\nimport type { ICache } from \"~/utils/caching/types.js\";\n\n/**\n * PluginGroupsProvider provides access to plugin-defined (code) groups.\n */\nexport interface IPluginGroupsProvider {\n getGroups(): Promise<CmsGroup[]>;\n}\n\nexport const PluginGroupsProvider =\n createAbstraction<IPluginGroupsProvider>(\"PluginGroupsProvider\");\n\nexport namespace PluginGroupsProvider {\n export type Interface = IPluginGroupsProvider;\n}\n\nexport const GroupCache = createAbstraction<ICache<Promise<CmsGroup[]>>>(\"GroupCache\");\n\nexport namespace GroupCache {\n export type Interface = ICache;\n}\n\ninterface IModelGroup {\n slug: string;\n name: string;\n icon: CmsIcon;\n}\n\nexport interface IModelGroupFactory {\n execute(): Promise<IModelGroup[]>;\n}\n\n/** Provide code-defined content model groups. */\nexport const ModelGroupFactory = createAbstraction<IModelGroupFactory>(\"ModelGroupFactory\");\nexport namespace ModelGroupFactory {\n export type Interface = IModelGroupFactory;\n export type Return = Promise<IModelGroup[]>;\n export type Group = IModelGroup;\n}\n"],"names":["PluginGroupsProvider","createAbstraction","GroupCache","ModelGroupFactory"],"mappings":";AAWO,MAAMA,uBACTC,kBAAyC;AAMtC,MAAMC,aAAaD,kBAA+C;AAiBlE,MAAME,oBAAoBF,kBAAsC"}
1
+ {"version":3,"file":"features/contentModelGroup/shared/abstractions.js","sources":["../../../../src/features/contentModelGroup/shared/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsGroup, CmsIcon } from \"~/types/index.js\";\nimport type { ICache } from \"~/utils/caching/types.js\";\nimport type { CmsGroupPlugin } from \"~/plugins/CmsGroupPlugin.js\";\n\n/**\n * Multi-instance DI token holding the code-defined CmsGroupPlugin instances\n * (previously read from the plugins container via byType). PluginGroupsProvider\n * resolves all of these to expose plugin-defined groups.\n */\nexport const CmsGroupPluginInstance = createAbstraction<CmsGroupPlugin>(\"CmsGroupPluginInstance\");\n\nexport namespace CmsGroupPluginInstance {\n export type Interface = CmsGroupPlugin;\n}\n\n/**\n * PluginGroupsProvider provides access to plugin-defined (code) groups.\n */\nexport interface IPluginGroupsProvider {\n getGroups(): Promise<CmsGroup[]>;\n}\n\nexport const PluginGroupsProvider =\n createAbstraction<IPluginGroupsProvider>(\"PluginGroupsProvider\");\n\nexport namespace PluginGroupsProvider {\n export type Interface = IPluginGroupsProvider;\n}\n\nexport const GroupCache = createAbstraction<ICache<Promise<CmsGroup[]>>>(\"GroupCache\");\n\nexport namespace GroupCache {\n export type Interface = ICache;\n}\n\ninterface IModelGroup {\n slug: string;\n name: string;\n icon: CmsIcon;\n}\n\nexport interface IModelGroupFactory {\n execute(): Promise<IModelGroup[]>;\n}\n\n/** Provide code-defined content model groups. */\nexport const ModelGroupFactory = createAbstraction<IModelGroupFactory>(\"ModelGroupFactory\");\nexport namespace ModelGroupFactory {\n export type Interface = IModelGroupFactory;\n export type Return = Promise<IModelGroup[]>;\n export type Group = IModelGroup;\n}\n"],"names":["CmsGroupPluginInstance","createAbstraction","PluginGroupsProvider","GroupCache","ModelGroupFactory"],"mappings":";AAUO,MAAMA,yBAAyBC,kBAAkC;AAajE,MAAMC,uBACTD,kBAAyC;AAMtC,MAAME,aAAaF,kBAA+C;AAiBlE,MAAMG,oBAAoBH,kBAAsC"}
@@ -1,5 +1,5 @@
1
- import type { GraphQLFieldResolver, Resolvers } from "@webiny/handler-graphql/types.js";
2
- import type { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types.js";
1
+ import type { GraphQLFieldResolver, Resolvers } from "@webiny/api-graphql/types.js";
2
+ import type { GraphQLSchemaDefinition } from "@webiny/api-graphql/types.js";
3
3
  import type { CmsModelField, CmsModelFieldType } from "../../../../types/modelField.js";
4
4
  import type { CmsModel } from "../../../../types/model.js";
5
5
  import type { CmsModelFieldDefinition } from "../../../../types/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js","sources":["../../../../../src/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { GraphQLFieldResolver, Resolvers } from \"@webiny/handler-graphql/types.js\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types.js\";\nimport type { CmsModelField, CmsModelFieldType } from \"~/types/modelField.js\";\nimport type { CmsModel } from \"~/types/model.js\";\nimport type { CmsModelFieldDefinition } from \"~/types/types.js\";\nimport type { CmsContext } from \"~/types/types.js\";\n\nexport interface ValidateChildFieldsValidateParams<TField extends CmsModelField = CmsModelField> {\n fields: TField[];\n originalFields: TField[];\n}\n\nexport interface ValidateChildFieldsValidate {\n (params: ValidateChildFieldsValidateParams): void;\n}\n\nexport interface ValidateChildFieldsParams<TField extends CmsModelField = CmsModelField> {\n field: TField;\n originalField?: TField;\n validate: ValidateChildFieldsValidate;\n}\n\nexport interface ValidateChildFields<TField extends CmsModelField = CmsModelField> {\n (params: ValidateChildFieldsParams<TField>): void;\n}\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { GetCmsModelFieldAst } from \"~/types/modelAst.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"./CmsModelFieldToGraphQLRegistry.js\";\n\nexport interface CreateTypeFieldParams<TField extends CmsModelField = CmsModelField> {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nexport interface CreateGetFiltersParams<TField extends CmsModelField = CmsModelField> {\n field: TField;\n}\n\nexport interface CreateListFiltersParams<TField extends CmsModelField = CmsModelField> {\n model: Pick<CmsModel, \"singularApiName\">;\n field: TField;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nexport interface CreateResolverParams<TField extends CmsModelField = CmsModelField> {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: TField;\n createFieldResolvers: any;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nexport type ResolverResult =\n | GraphQLFieldResolver\n | {\n resolver: GraphQLFieldResolver | null;\n typeResolvers: Resolvers<CmsContext>;\n }\n | false;\n\nexport interface CreateSchemaParams {\n models: CmsModel[];\n}\n\nexport interface NormalizeInputParams<TField extends CmsModelField = CmsModelField> {\n model: CmsModel;\n field: TField;\n input: GenericRecord<string> | Array<GenericRecord<string>>;\n}\n\nexport interface ICmsFieldReadApi<TField extends CmsModelField = CmsModelField> {\n createTypeField(params: CreateTypeFieldParams<TField>): CmsModelFieldDefinition | string | null;\n createGetFilters?(params: CreateGetFiltersParams<TField>): string;\n createListFilters?(params: CreateListFiltersParams<TField>): string;\n createResolver?(params: CreateResolverParams<TField>): ResolverResult;\n createSchema?(params: CreateSchemaParams): GraphQLSchemaDefinition<CmsContext>;\n}\n\nexport interface ICmsFieldManageApi<\n TField extends CmsModelField = CmsModelField\n> extends ICmsFieldReadApi<TField> {\n createInputField(\n params: CreateTypeFieldParams<TField>\n ): CmsModelFieldDefinition | string | null;\n normalizeInput?<T>(params: NormalizeInputParams<TField>): Promise<T>;\n}\n\nexport interface ICmsModelFieldToGraphQL<TField extends CmsModelField = CmsModelField> {\n /* Metadata. */\n readonly fieldType: CmsModelFieldType;\n readonly isSearchable: boolean;\n readonly isSortable: boolean;\n readonly isFullTextSearchable: boolean;\n\n /* API surfaces. */\n readonly read: ICmsFieldReadApi<TField>;\n readonly manage: ICmsFieldManageApi<TField>;\n getReadApi(): ICmsFieldReadApi<TField>;\n getManageApi(): ICmsFieldManageApi<TField>;\n\n /* Validation & AST. */\n validateChildFields?: ValidateChildFields<TField>;\n getFieldAst?: GetCmsModelFieldAst<TField>;\n}\n\nexport const CmsModelFieldToGraphQL = createAbstraction<ICmsModelFieldToGraphQL>(\n \"Cms/GraphQL/Schema/ModelField\"\n);\n\nexport namespace CmsModelFieldToGraphQL {\n export type Interface = ICmsModelFieldToGraphQL;\n export type ReadApi<TField extends CmsModelField = CmsModelField> = ICmsFieldReadApi<TField>;\n export type ManageApi<TField extends CmsModelField = CmsModelField> =\n ICmsFieldManageApi<TField>;\n export type TypeFieldParams<TField extends CmsModelField = CmsModelField> =\n CreateTypeFieldParams<TField>;\n export type GetFiltersParams<TField extends CmsModelField = CmsModelField> =\n CreateGetFiltersParams<TField>;\n export type ListFiltersParams<TField extends CmsModelField = CmsModelField> =\n CreateListFiltersParams<TField>;\n export type ResolverParams<TField extends CmsModelField = CmsModelField> =\n CreateResolverParams<TField>;\n export type SchemaParams = CreateSchemaParams;\n export type InputNormalizeParams<TField extends CmsModelField = CmsModelField> =\n NormalizeInputParams<TField>;\n export type Resolver = ResolverResult;\n export type ChildFieldsValidateParams<TField extends CmsModelField = CmsModelField> =\n ValidateChildFieldsParams<TField>;\n export type ChildFieldsValidate<TField extends CmsModelField = CmsModelField> =\n ValidateChildFields<TField>;\n export type ChildFieldsValidateValidate = ValidateChildFieldsValidate;\n}\n"],"names":["CmsModelFieldToGraphQL","createAbstraction"],"mappings":";AA6GO,MAAMA,yBAAyBC,kBAClC"}
1
+ {"version":3,"file":"features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js","sources":["../../../../../src/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { GraphQLFieldResolver, Resolvers } from \"@webiny/api-graphql/types.js\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/api-graphql/types.js\";\nimport type { CmsModelField, CmsModelFieldType } from \"~/types/modelField.js\";\nimport type { CmsModel } from \"~/types/model.js\";\nimport type { CmsModelFieldDefinition } from \"~/types/types.js\";\nimport type { CmsContext } from \"~/types/types.js\";\n\nexport interface ValidateChildFieldsValidateParams<TField extends CmsModelField = CmsModelField> {\n fields: TField[];\n originalFields: TField[];\n}\n\nexport interface ValidateChildFieldsValidate {\n (params: ValidateChildFieldsValidateParams): void;\n}\n\nexport interface ValidateChildFieldsParams<TField extends CmsModelField = CmsModelField> {\n field: TField;\n originalField?: TField;\n validate: ValidateChildFieldsValidate;\n}\n\nexport interface ValidateChildFields<TField extends CmsModelField = CmsModelField> {\n (params: ValidateChildFieldsParams<TField>): void;\n}\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { GetCmsModelFieldAst } from \"~/types/modelAst.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"./CmsModelFieldToGraphQLRegistry.js\";\n\nexport interface CreateTypeFieldParams<TField extends CmsModelField = CmsModelField> {\n models: CmsModel[];\n model: CmsModel;\n field: TField;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nexport interface CreateGetFiltersParams<TField extends CmsModelField = CmsModelField> {\n field: TField;\n}\n\nexport interface CreateListFiltersParams<TField extends CmsModelField = CmsModelField> {\n model: Pick<CmsModel, \"singularApiName\">;\n field: TField;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nexport interface CreateResolverParams<TField extends CmsModelField = CmsModelField> {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: TField;\n createFieldResolvers: any;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nexport type ResolverResult =\n | GraphQLFieldResolver\n | {\n resolver: GraphQLFieldResolver | null;\n typeResolvers: Resolvers<CmsContext>;\n }\n | false;\n\nexport interface CreateSchemaParams {\n models: CmsModel[];\n}\n\nexport interface NormalizeInputParams<TField extends CmsModelField = CmsModelField> {\n model: CmsModel;\n field: TField;\n input: GenericRecord<string> | Array<GenericRecord<string>>;\n}\n\nexport interface ICmsFieldReadApi<TField extends CmsModelField = CmsModelField> {\n createTypeField(params: CreateTypeFieldParams<TField>): CmsModelFieldDefinition | string | null;\n createGetFilters?(params: CreateGetFiltersParams<TField>): string;\n createListFilters?(params: CreateListFiltersParams<TField>): string;\n createResolver?(params: CreateResolverParams<TField>): ResolverResult;\n createSchema?(params: CreateSchemaParams): GraphQLSchemaDefinition<CmsContext>;\n}\n\nexport interface ICmsFieldManageApi<\n TField extends CmsModelField = CmsModelField\n> extends ICmsFieldReadApi<TField> {\n createInputField(\n params: CreateTypeFieldParams<TField>\n ): CmsModelFieldDefinition | string | null;\n normalizeInput?<T>(params: NormalizeInputParams<TField>): Promise<T>;\n}\n\nexport interface ICmsModelFieldToGraphQL<TField extends CmsModelField = CmsModelField> {\n /* Metadata. */\n readonly fieldType: CmsModelFieldType;\n readonly isSearchable: boolean;\n readonly isSortable: boolean;\n readonly isFullTextSearchable: boolean;\n\n /* API surfaces. */\n readonly read: ICmsFieldReadApi<TField>;\n readonly manage: ICmsFieldManageApi<TField>;\n getReadApi(): ICmsFieldReadApi<TField>;\n getManageApi(): ICmsFieldManageApi<TField>;\n\n /* Validation & AST. */\n validateChildFields?: ValidateChildFields<TField>;\n getFieldAst?: GetCmsModelFieldAst<TField>;\n}\n\nexport const CmsModelFieldToGraphQL = createAbstraction<ICmsModelFieldToGraphQL>(\n \"Cms/GraphQL/Schema/ModelField\"\n);\n\nexport namespace CmsModelFieldToGraphQL {\n export type Interface = ICmsModelFieldToGraphQL;\n export type ReadApi<TField extends CmsModelField = CmsModelField> = ICmsFieldReadApi<TField>;\n export type ManageApi<TField extends CmsModelField = CmsModelField> =\n ICmsFieldManageApi<TField>;\n export type TypeFieldParams<TField extends CmsModelField = CmsModelField> =\n CreateTypeFieldParams<TField>;\n export type GetFiltersParams<TField extends CmsModelField = CmsModelField> =\n CreateGetFiltersParams<TField>;\n export type ListFiltersParams<TField extends CmsModelField = CmsModelField> =\n CreateListFiltersParams<TField>;\n export type ResolverParams<TField extends CmsModelField = CmsModelField> =\n CreateResolverParams<TField>;\n export type SchemaParams = CreateSchemaParams;\n export type InputNormalizeParams<TField extends CmsModelField = CmsModelField> =\n NormalizeInputParams<TField>;\n export type Resolver = ResolverResult;\n export type ChildFieldsValidateParams<TField extends CmsModelField = CmsModelField> =\n ValidateChildFieldsParams<TField>;\n export type ChildFieldsValidate<TField extends CmsModelField = CmsModelField> =\n ValidateChildFields<TField>;\n export type ChildFieldsValidateValidate = ValidateChildFieldsValidate;\n}\n"],"names":["CmsModelFieldToGraphQL","createAbstraction"],"mappings":";AA6GO,MAAMA,yBAAyBC,kBAClC"}
@@ -1,6 +1,6 @@
1
1
  import { CmsModelFieldToGraphQL } from "../abstractions/CmsModelFieldToGraphQL.js";
2
2
  import type { CmsModelFieldType } from "../../../../types/modelField.js";
3
- import type { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types.js";
3
+ import type { GraphQLSchemaDefinition } from "@webiny/api-graphql/types.js";
4
4
  import type { CmsContext } from "../../../../types/types.js";
5
5
  declare class ReadApi implements CmsModelFieldToGraphQL.ReadApi {
6
6
  createTypeField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string;
@@ -70,8 +70,11 @@ const baseTypeDefs = `
70
70
  src: String!
71
71
  url: String
72
72
  name: String!
73
- type: String!
73
+ mimeType: String!
74
74
  size: Number!
75
+ # Same as image.width/image.height, kept at the root for 6.4 frontends.
76
+ width: Number
77
+ height: Number
75
78
  image: FmAssetImage
76
79
  document: FmAssetDocument
77
80
  video: FmAssetVideo
@@ -83,8 +86,10 @@ const baseTypeDefs = `
83
86
  # TODO: figure out how to remove this from here, as this is a derived read-only value.
84
87
  url: String
85
88
  name: String!
86
- type: String!
89
+ mimeType: String!
87
90
  size: Number!
91
+ width: Number
92
+ height: Number
88
93
  image: FmAssetImageInput
89
94
  document: FmAssetDocumentInput
90
95
  video: FmAssetVideoInput
@@ -1 +1 @@
1
- {"version":3,"file":"features/graphql/fields/base/AssetToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/AssetToGraphQL.ts"],"sourcesContent":["import { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldType } from \"~/types/modelField.js\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types.js\";\nimport type { CmsContext } from \"~/types/types.js\";\nimport { createGraphQLInputField } from \"./utils/createGraphQLInputField.js\";\nimport { resolveAssetUrl } from \"../../../modelBuilder/fields/resolveAssetUrl.js\";\n\n// --- Image sub-type (self-contained block for future registry extraction) ---\n\nconst imageTypeDefs = /* GraphQL */ `\n type FmAssetCrop {\n top: Number\n left: Number\n bottom: Number\n right: Number\n }\n\n type FmAssetFocalPoint {\n x: Number\n y: Number\n }\n\n type FmAssetImage {\n width: Number\n height: Number\n crop: FmAssetCrop\n focalPoint: FmAssetFocalPoint\n alt: String\n caption: String\n }\n\n input FmAssetCropInput {\n top: Number\n left: Number\n bottom: Number\n right: Number\n }\n\n input FmAssetFocalPointInput {\n x: Number\n y: Number\n }\n\n input FmAssetImageInput {\n width: Number\n height: Number\n crop: FmAssetCropInput\n focalPoint: FmAssetFocalPointInput\n alt: String\n caption: String\n }\n`;\n\n// --- Document sub-type ---\n\nconst documentTypeDefs = /* GraphQL */ `\n type FmAssetDocument {\n pages: Number\n }\n\n input FmAssetDocumentInput {\n pages: Number\n }\n`;\n\n// --- Video sub-type ---\n\nconst videoTypeDefs = /* GraphQL */ `\n type FmAssetVideo {\n autoplay: Boolean\n poster: String\n }\n\n input FmAssetVideoInput {\n autoplay: Boolean\n poster: String\n }\n`;\n\n// --- Base asset type ---\n\nconst baseTypeDefs = /* GraphQL */ `\n type FmAsset {\n id: String!\n src: String!\n url: String\n name: String!\n type: String!\n size: Number!\n image: FmAssetImage\n document: FmAssetDocument\n video: FmAssetVideo\n }\n\n input FmAssetInput {\n id: String!\n src: String!\n # TODO: figure out how to remove this from here, as this is a derived read-only value.\n url: String\n name: String!\n type: String!\n size: Number!\n image: FmAssetImageInput\n document: FmAssetDocumentInput\n video: FmAssetVideoInput\n }\n`;\n\nconst allTypeDefs = [imageTypeDefs, documentTypeDefs, videoTypeDefs, baseTypeDefs].join(\"\\n\");\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n if (field.list) {\n return `${field.fieldId}: [FmAsset]`;\n }\n return `${field.fieldId}: FmAsset`;\n }\n\n public createResolver(): CmsModelFieldToGraphQL.Resolver {\n return {\n resolver: null,\n typeResolvers: {\n FmAsset: {\n url: (parent: any) => resolveAssetUrl(parent)\n }\n }\n };\n }\n\n public createSchema(): GraphQLSchemaDefinition<CmsContext> {\n return {\n typeDefs: allTypeDefs,\n resolvers: {}\n };\n }\n}\n\nclass ManageApi extends ReadApi implements CmsModelFieldToGraphQL.ManageApi {\n public createInputField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n return createGraphQLInputField(field, \"FmAssetInput\");\n }\n}\n\nclass AssetToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"asset\";\n public readonly isSearchable: boolean = false;\n public readonly isSortable: boolean = false;\n public readonly isFullTextSearchable: boolean = false;\n\n public getReadApi(): CmsModelFieldToGraphQL.ReadApi {\n return this.read;\n }\n\n public getManageApi(): CmsModelFieldToGraphQL.ManageApi {\n return this.manage;\n }\n}\n\nexport const AssetFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: AssetToGraphQL,\n dependencies: []\n});\n"],"names":["imageTypeDefs","documentTypeDefs","videoTypeDefs","baseTypeDefs","allTypeDefs","ReadApi","field","parent","resolveAssetUrl","ManageApi","createGraphQLInputField","AssetToGraphQL","AssetFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;AASA,MAAMA,gBAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CrC,CAAC;AAID,MAAMC,mBAAiC,CAAC;;;;;;;;AAQxC,CAAC;AAID,MAAMC,gBAA8B,CAAC;;;;;;;;;;AAUrC,CAAC;AAID,MAAMC,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBpC,CAAC;AAED,MAAMC,cAAc;IAACJ;IAAeC;IAAkBC;IAAeC;CAAa,CAAC,IAAI,CAAC;AAExF,MAAME;IACK,gBAAgB,EAAEC,KAAK,EAA0C,EAAU;QAC9E,IAAIA,MAAM,IAAI,EACV,OAAO,GAAGA,MAAM,OAAO,CAAC,WAAW,CAAC;QAExC,OAAO,GAAGA,MAAM,OAAO,CAAC,SAAS,CAAC;IACtC;IAEO,iBAAkD;QACrD,OAAO;YACH,UAAU;YACV,eAAe;gBACX,SAAS;oBACL,KAAK,CAACC,SAAgBC,gBAAgBD;gBAC1C;YACJ;QACJ;IACJ;IAEO,eAAoD;QACvD,OAAO;YACH,UAAUH;YACV,WAAW,CAAC;QAChB;IACJ;AACJ;AAEA,MAAMK,kBAAkBJ;IACb,iBAAiB,EAAEC,KAAK,EAA0C,EAAU;QAC/E,OAAOI,wBAAwBJ,OAAO;IAC1C;AACJ;AAEA,MAAMK;IASK,aAA6C;QAChD,OAAO,IAAI,CAAC,IAAI;IACpB;IAEO,eAAiD;QACpD,OAAO,IAAI,CAAC,MAAM;IACtB;;aAdgB,IAAI,GAAG,IAAIN;aACX,MAAM,GAAG,IAAII;aAEb,SAAS,GAAsB;aAC/B,YAAY,GAAY;aACxB,UAAU,GAAY;aACtB,oBAAoB,GAAY;;AASpD;AAEO,MAAMG,sBAAsBC,uBAAuB,oBAAoB,CAAC;IAC3E,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/graphql/fields/base/AssetToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/AssetToGraphQL.ts"],"sourcesContent":["import { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldType } from \"~/types/modelField.js\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/api-graphql/types.js\";\nimport type { CmsContext } from \"~/types/types.js\";\nimport { createGraphQLInputField } from \"./utils/createGraphQLInputField.js\";\nimport { resolveAssetUrl } from \"../../../modelBuilder/fields/resolveAssetUrl.js\";\n\n// --- Image sub-type (self-contained block for future registry extraction) ---\n\nconst imageTypeDefs = /* GraphQL */ `\n type FmAssetCrop {\n top: Number\n left: Number\n bottom: Number\n right: Number\n }\n\n type FmAssetFocalPoint {\n x: Number\n y: Number\n }\n\n type FmAssetImage {\n width: Number\n height: Number\n crop: FmAssetCrop\n focalPoint: FmAssetFocalPoint\n alt: String\n caption: String\n }\n\n input FmAssetCropInput {\n top: Number\n left: Number\n bottom: Number\n right: Number\n }\n\n input FmAssetFocalPointInput {\n x: Number\n y: Number\n }\n\n input FmAssetImageInput {\n width: Number\n height: Number\n crop: FmAssetCropInput\n focalPoint: FmAssetFocalPointInput\n alt: String\n caption: String\n }\n`;\n\n// --- Document sub-type ---\n\nconst documentTypeDefs = /* GraphQL */ `\n type FmAssetDocument {\n pages: Number\n }\n\n input FmAssetDocumentInput {\n pages: Number\n }\n`;\n\n// --- Video sub-type ---\n\nconst videoTypeDefs = /* GraphQL */ `\n type FmAssetVideo {\n autoplay: Boolean\n poster: String\n }\n\n input FmAssetVideoInput {\n autoplay: Boolean\n poster: String\n }\n`;\n\n// --- Base asset type ---\n\nconst baseTypeDefs = /* GraphQL */ `\n type FmAsset {\n id: String!\n src: String!\n url: String\n name: String!\n mimeType: String!\n size: Number!\n # Same as image.width/image.height, kept at the root for 6.4 frontends.\n width: Number\n height: Number\n image: FmAssetImage\n document: FmAssetDocument\n video: FmAssetVideo\n }\n\n input FmAssetInput {\n id: String!\n src: String!\n # TODO: figure out how to remove this from here, as this is a derived read-only value.\n url: String\n name: String!\n mimeType: String!\n size: Number!\n width: Number\n height: Number\n image: FmAssetImageInput\n document: FmAssetDocumentInput\n video: FmAssetVideoInput\n }\n`;\n\nconst allTypeDefs = [imageTypeDefs, documentTypeDefs, videoTypeDefs, baseTypeDefs].join(\"\\n\");\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n if (field.list) {\n return `${field.fieldId}: [FmAsset]`;\n }\n return `${field.fieldId}: FmAsset`;\n }\n\n public createResolver(): CmsModelFieldToGraphQL.Resolver {\n return {\n resolver: null,\n typeResolvers: {\n FmAsset: {\n url: (parent: any) => resolveAssetUrl(parent)\n }\n }\n };\n }\n\n public createSchema(): GraphQLSchemaDefinition<CmsContext> {\n return {\n typeDefs: allTypeDefs,\n resolvers: {}\n };\n }\n}\n\nclass ManageApi extends ReadApi implements CmsModelFieldToGraphQL.ManageApi {\n public createInputField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n return createGraphQLInputField(field, \"FmAssetInput\");\n }\n}\n\nclass AssetToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"asset\";\n public readonly isSearchable: boolean = false;\n public readonly isSortable: boolean = false;\n public readonly isFullTextSearchable: boolean = false;\n\n public getReadApi(): CmsModelFieldToGraphQL.ReadApi {\n return this.read;\n }\n\n public getManageApi(): CmsModelFieldToGraphQL.ManageApi {\n return this.manage;\n }\n}\n\nexport const AssetFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: AssetToGraphQL,\n dependencies: []\n});\n"],"names":["imageTypeDefs","documentTypeDefs","videoTypeDefs","baseTypeDefs","allTypeDefs","ReadApi","field","parent","resolveAssetUrl","ManageApi","createGraphQLInputField","AssetToGraphQL","AssetFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;AASA,MAAMA,gBAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CrC,CAAC;AAID,MAAMC,mBAAiC,CAAC;;;;;;;;AAQxC,CAAC;AAID,MAAMC,gBAA8B,CAAC;;;;;;;;;;AAUrC,CAAC;AAID,MAAMC,eAA6B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BpC,CAAC;AAED,MAAMC,cAAc;IAACJ;IAAeC;IAAkBC;IAAeC;CAAa,CAAC,IAAI,CAAC;AAExF,MAAME;IACK,gBAAgB,EAAEC,KAAK,EAA0C,EAAU;QAC9E,IAAIA,MAAM,IAAI,EACV,OAAO,GAAGA,MAAM,OAAO,CAAC,WAAW,CAAC;QAExC,OAAO,GAAGA,MAAM,OAAO,CAAC,SAAS,CAAC;IACtC;IAEO,iBAAkD;QACrD,OAAO;YACH,UAAU;YACV,eAAe;gBACX,SAAS;oBACL,KAAK,CAACC,SAAgBC,gBAAgBD;gBAC1C;YACJ;QACJ;IACJ;IAEO,eAAoD;QACvD,OAAO;YACH,UAAUH;YACV,WAAW,CAAC;QAChB;IACJ;AACJ;AAEA,MAAMK,kBAAkBJ;IACb,iBAAiB,EAAEC,KAAK,EAA0C,EAAU;QAC/E,OAAOI,wBAAwBJ,OAAO;IAC1C;AACJ;AAEA,MAAMK;IASK,aAA6C;QAChD,OAAO,IAAI,CAAC,IAAI;IACpB;IAEO,eAAiD;QACpD,OAAO,IAAI,CAAC,MAAM;IACtB;;aAdgB,IAAI,GAAG,IAAIN;aACX,MAAM,GAAG,IAAII;aAEb,SAAS,GAAsB;aAC/B,YAAY,GAAY;aACxB,UAAU,GAAY;aACtB,oBAAoB,GAAY;;AASpD;AAEO,MAAMG,sBAAsBC,uBAAuB,oBAAoB,CAAC;IAC3E,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"features/graphql/fields/base/DynamicZoneToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/DynamicZoneToGraphQL.ts"],"sourcesContent":["import { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type {\n ApiEndpoint,\n CmsDynamicZoneTemplate,\n CmsModel,\n CmsModelDynamicZoneField,\n CmsModelField,\n CmsModelFieldType,\n CmsModelFieldDefinition\n} from \"~/types/index.js\";\nimport type { ValidateChildFieldsParams } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldAstNode, ICmsModelFieldToAst } from \"~/types/modelAst.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { createTypeName } from \"~/utils/createTypeName.js\";\nimport { createGraphQLInputField } from \"./utils/createGraphQLInputField.js\";\nimport { createTypeDefsForTemplates } from \"./dynamicZone/createTypeDefsForTemplates.js\";\nimport { normalizeDynamicZoneInput } from \"./dynamicZone/normalizeDynamicZoneInput.js\";\n\nconst createUnionTypeName = (model: CmsModel, field: CmsModelField) => {\n return `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n};\n\nconst getFieldTemplates = (field: CmsModelDynamicZoneField): CmsDynamicZoneTemplate[] => {\n if (!Array.isArray(field.settings?.templates)) {\n return [];\n }\n return field.settings.templates;\n};\n\nconst remapTemplateValue = (value: any, typeName: string) => {\n return { ...value, __typename: typeName };\n};\n\nconst createDynamicZoneResolver = (\n endpointType: ApiEndpoint\n): ((params: CmsModelFieldToGraphQL.ResolverParams) => CmsModelFieldToGraphQL.Resolver) => {\n return ({ model, models, field, fieldRegistry, createFieldResolvers, graphQLType }) => {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n\n if (!templates.length) {\n return false;\n }\n\n const resolver = (parent: any) => {\n const value = parent[field.fieldId];\n if (!value) {\n return value;\n }\n\n const typeName = `${graphQLType}_${createTypeName(field.fieldId)}`;\n\n if (field.list && Array.isArray(value)) {\n return value.map(v => {\n const template = templates.find(tpl => tpl.id === v._templateId);\n if (!template) {\n return undefined;\n }\n return remapTemplateValue(v, `${typeName}_${template.gqlTypeName}`);\n });\n }\n\n const template = templates.find(tpl => tpl.id === value._templateId);\n if (!template) {\n return undefined;\n }\n return remapTemplateValue(value, `${typeName}_${template.gqlTypeName}`);\n };\n\n const { templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: endpointType,\n typeOfType: \"type\",\n model,\n fieldRegistry,\n templates\n });\n\n const replace = new RegExp(`${model.singularApiName}_`, \"g\");\n\n const typeResolvers = templateTypes\n .map(templateType => {\n return templateType.replace(replace, `${graphQLType}_`);\n })\n .reduce<Record<string, Record<string, GraphQLFieldResolver>>>(\n (typeResolvers, templateType, index) => {\n return {\n ...typeResolvers,\n ...createFieldResolvers({\n graphQLType: templateType,\n fields: dzField.settings.templates[index].fields\n })\n };\n },\n {}\n );\n\n return {\n resolver,\n typeResolvers\n };\n };\n};\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n if (!templates.length) {\n return null;\n }\n\n const unionTypeName = createUnionTypeName(model, field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"read\",\n typeOfType: \"type\",\n model,\n fieldRegistry,\n templates\n });\n\n const templateIds = templateTypes.map(type => {\n return `extend type ${type} {\n _templateId: ID!\n _id: ID\n }\n `;\n });\n\n typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(\" | \")}`);\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${unionTypeName}!]` : unionTypeName}`,\n typeDefs: typeDefs.concat(templateIds).join(\"\\n\")\n };\n }\n\n public createResolver(\n params: CmsModelFieldToGraphQL.ResolverParams\n ): CmsModelFieldToGraphQL.Resolver {\n return createDynamicZoneResolver(\"read\")(params);\n }\n}\n\nclass ManageApi implements CmsModelFieldToGraphQL.ManageApi {\n public createTypeField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n\n if (!templates.length) {\n return null;\n }\n\n const unionTypeName = createUnionTypeName(model, field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"manage\",\n typeOfType: \"type\",\n model,\n fieldRegistry,\n templates\n });\n\n /* Add _templateId and _id. */\n const templateIds = templateTypes.map(type => {\n return `extend type ${type} {\n _templateId: ID!\n _id: ID\n }\n `;\n });\n\n typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(\" | \")}`);\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${unionTypeName}!]` : unionTypeName}`,\n typeDefs: typeDefs.concat(templateIds).join(\"\\n\")\n };\n }\n\n public createInputField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n\n if (!templates.length) {\n return null;\n }\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"manage\",\n typeOfType: \"input\",\n model,\n fieldRegistry,\n templates\n });\n\n const typeName = `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n\n const inputProperties = templateTypes.map(inputTypeName => {\n const key = inputTypeName.replace(`${typeName}_`, \"\").replace(\"Input\", \"\");\n return [key, inputTypeName];\n });\n\n /**\n * Generate a field input type, similar to this example:\n *\n * input Article_ContentInput {\n * Hero: Article_Content_HeroInput\n * SimpleText: Article_Content_SimpleTextInput\n * }\n */\n typeDefs.push(`input ${typeName}Input {\n ${inputProperties.map(\n ([key, value]) => `\n ${key}: ${value}\n `\n )}\n }`);\n\n /* Extend each template input type with _id. */\n const templateInputIds = templateTypes.map(inputTypeName => {\n return `extend input ${inputTypeName} {\n _id: ID\n }\n `;\n });\n\n return {\n fields: createGraphQLInputField(field, `${typeName}Input`),\n typeDefs: typeDefs.concat(templateInputIds).join(\"\\n\")\n };\n }\n\n public createResolver(\n params: CmsModelFieldToGraphQL.ResolverParams\n ): CmsModelFieldToGraphQL.Resolver {\n return createDynamicZoneResolver(\"manage\")(params);\n }\n\n public async normalizeInput<T>({\n field,\n input\n }: CmsModelFieldToGraphQL.InputNormalizeParams): Promise<T> {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = dzField.settings?.templates || [];\n\n if (Array.isArray(input) && field.list) {\n return input\n .map(value => normalizeDynamicZoneInput(value, templates))\n .filter(Boolean) as T;\n }\n\n return normalizeDynamicZoneInput(input as GenericRecord<string>, templates) as T;\n }\n}\n\nclass DynamicZoneToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"dynamicZone\";\n public readonly isSearchable: boolean = false;\n public readonly isSortable: boolean = false;\n public readonly isFullTextSearchable: boolean = false;\n\n public getReadApi(): CmsModelFieldToGraphQL.ReadApi {\n return this.read;\n }\n\n public getManageApi(): CmsModelFieldToGraphQL.ManageApi {\n return this.manage;\n }\n\n public validateChildFields(params: ValidateChildFieldsParams<CmsModelField>): void {\n const field = params.field as CmsModelDynamicZoneField;\n const originalField = params.originalField as CmsModelDynamicZoneField | undefined;\n\n const getOriginalTemplateFields = (templateId: string) => {\n if (!originalField?.settings?.templates) {\n return [];\n }\n const template = originalField.settings.templates.find(t => t.id === templateId);\n return template?.fields || [];\n };\n\n for (const template of field.settings.templates) {\n params.validate({\n fields: template.fields,\n originalFields: getOriginalTemplateFields(template.id)\n });\n }\n }\n\n public getFieldAst(field: CmsModelField, converter: ICmsModelFieldToAst): CmsModelFieldAstNode {\n const dzField = field as CmsModelDynamicZoneField;\n const { templates = [] } = dzField.settings;\n\n return {\n type: \"field\",\n field,\n children: templates.map(({ fields, ...template }) => {\n return {\n type: \"collection\" as const,\n collection: {\n ...template,\n discriminator: \"_templateId\"\n },\n children: fields.map(f => converter.toAst(f))\n };\n })\n };\n }\n}\n\nexport const DynamicZoneFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: DynamicZoneToGraphQL,\n dependencies: []\n});\n"],"names":["createUnionTypeName","model","field","createTypeName","getFieldTemplates","Array","remapTemplateValue","value","typeName","createDynamicZoneResolver","endpointType","models","fieldRegistry","createFieldResolvers","graphQLType","dzField","templates","resolver","parent","v","template","tpl","templateTypes","createTypeDefsForTemplates","replace","RegExp","typeResolvers","templateType","index","ReadApi","unionTypeName","typeDefs","templateIds","type","params","ManageApi","inputProperties","inputTypeName","key","templateInputIds","createGraphQLInputField","input","normalizeDynamicZoneInput","Boolean","DynamicZoneToGraphQL","originalField","getOriginalTemplateFields","templateId","t","converter","fields","f","DynamicZoneFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;;;AAmBA,MAAMA,sBAAsB,CAACC,OAAiBC,QACnC,GAAGD,MAAM,eAAe,CAAC,CAAC,EAAEE,eAAeD,MAAM,OAAO,GAAG;AAGtE,MAAME,oBAAoB,CAACF;IACvB,IAAI,CAACG,MAAM,OAAO,CAACH,MAAM,QAAQ,EAAE,YAC/B,OAAO,EAAE;IAEb,OAAOA,MAAM,QAAQ,CAAC,SAAS;AACnC;AAEA,MAAMI,qBAAqB,CAACC,OAAYC,WAC7B;QAAE,GAAGD,KAAK;QAAE,YAAYC;IAAS;AAG5C,MAAMC,4BAA4B,CAC9BC,eAEO,CAAC,EAAET,KAAK,EAAEU,MAAM,EAAET,KAAK,EAAEU,aAAa,EAAEC,oBAAoB,EAAEC,WAAW,EAAE;QAC9E,MAAMC,UAAUb;QAChB,MAAMc,YAAYZ,kBAAkBW;QAEpC,IAAI,CAACC,UAAU,MAAM,EACjB,OAAO;QAGX,MAAMC,WAAW,CAACC;YACd,MAAMX,QAAQW,MAAM,CAAChB,MAAM,OAAO,CAAC;YACnC,IAAI,CAACK,OACD,OAAOA;YAGX,MAAMC,WAAW,GAAGM,YAAY,CAAC,EAAEX,eAAeD,MAAM,OAAO,GAAG;YAElE,IAAIA,MAAM,IAAI,IAAIG,MAAM,OAAO,CAACE,QAC5B,OAAOA,MAAM,GAAG,CAACY,CAAAA;gBACb,MAAMC,WAAWJ,UAAU,IAAI,CAACK,CAAAA,MAAOA,IAAI,EAAE,KAAKF,EAAE,WAAW;gBAC/D,IAAI,CAACC,UACD;gBAEJ,OAAOd,mBAAmBa,GAAG,GAAGX,SAAS,CAAC,EAAEY,SAAS,WAAW,EAAE;YACtE;YAGJ,MAAMA,WAAWJ,UAAU,IAAI,CAACK,CAAAA,MAAOA,IAAI,EAAE,KAAKd,MAAM,WAAW;YACnE,IAAI,CAACa,UACD;YAEJ,OAAOd,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BX,OAAO,aAAa;QAE1C,MAAMY,4BAA4B,CAACC;YAC/B,IAAI,CAACF,eAAe,UAAU,WAC1B,OAAO,EAAE;YAEb,MAAMzB,WAAWyB,cAAc,QAAQ,CAAC,SAAS,CAAC,IAAI,CAACG,CAAAA,IAAKA,EAAE,EAAE,KAAKD;YACrE,OAAO3B,UAAU,UAAU,EAAE;QACjC;QAEA,KAAK,MAAMA,YAAYlB,MAAM,QAAQ,CAAC,SAAS,CAC3CgC,OAAO,QAAQ,CAAC;YACZ,QAAQd,SAAS,MAAM;YACvB,gBAAgB0B,0BAA0B1B,SAAS,EAAE;QACzD;IAER;IAEO,YAAYlB,KAAoB,EAAE+C,SAA8B,EAAwB;QAC3F,MAAMlC,UAAUb;QAChB,MAAM,EAAEc,YAAY,EAAE,EAAE,GAAGD,QAAQ,QAAQ;QAE3C,OAAO;YACH,MAAM;YACNb;YACA,UAAUc,UAAU,GAAG,CAAC,CAAC,EAAEkC,MAAM,EAAE,GAAG9B,UAAU,GACrC;oBACH,MAAM;oBACN,YAAY;wBACR,GAAGA,QAAQ;wBACX,eAAe;oBACnB;oBACA,UAAU8B,OAAO,GAAG,CAACC,CAAAA,IAAKF,UAAU,KAAK,CAACE;gBAC9C;QAER;IACJ;;aAtDgB,IAAI,GAAG,IAAItB;aACX,MAAM,GAAG,IAAIM;aAEb,SAAS,GAAsB;aAC/B,YAAY,GAAY;aACxB,UAAU,GAAY;aACtB,oBAAoB,GAAY;;AAiDpD;AAEO,MAAMiB,4BAA4BC,uBAAuB,oBAAoB,CAAC;IACjF,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/graphql/fields/base/DynamicZoneToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/DynamicZoneToGraphQL.ts"],"sourcesContent":["import { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type {\n ApiEndpoint,\n CmsDynamicZoneTemplate,\n CmsModel,\n CmsModelDynamicZoneField,\n CmsModelField,\n CmsModelFieldType,\n CmsModelFieldDefinition\n} from \"~/types/index.js\";\nimport type { ValidateChildFieldsParams } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldAstNode, ICmsModelFieldToAst } from \"~/types/modelAst.js\";\nimport type { GraphQLFieldResolver } from \"@webiny/api-graphql/types.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { createTypeName } from \"~/utils/createTypeName.js\";\nimport { createGraphQLInputField } from \"./utils/createGraphQLInputField.js\";\nimport { createTypeDefsForTemplates } from \"./dynamicZone/createTypeDefsForTemplates.js\";\nimport { normalizeDynamicZoneInput } from \"./dynamicZone/normalizeDynamicZoneInput.js\";\n\nconst createUnionTypeName = (model: CmsModel, field: CmsModelField) => {\n return `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n};\n\nconst getFieldTemplates = (field: CmsModelDynamicZoneField): CmsDynamicZoneTemplate[] => {\n if (!Array.isArray(field.settings?.templates)) {\n return [];\n }\n return field.settings.templates;\n};\n\nconst remapTemplateValue = (value: any, typeName: string) => {\n return { ...value, __typename: typeName };\n};\n\nconst createDynamicZoneResolver = (\n endpointType: ApiEndpoint\n): ((params: CmsModelFieldToGraphQL.ResolverParams) => CmsModelFieldToGraphQL.Resolver) => {\n return ({ model, models, field, fieldRegistry, createFieldResolvers, graphQLType }) => {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n\n if (!templates.length) {\n return false;\n }\n\n const resolver = (parent: any) => {\n const value = parent[field.fieldId];\n if (!value) {\n return value;\n }\n\n const typeName = `${graphQLType}_${createTypeName(field.fieldId)}`;\n\n if (field.list && Array.isArray(value)) {\n return value.map(v => {\n const template = templates.find(tpl => tpl.id === v._templateId);\n if (!template) {\n return undefined;\n }\n return remapTemplateValue(v, `${typeName}_${template.gqlTypeName}`);\n });\n }\n\n const template = templates.find(tpl => tpl.id === value._templateId);\n if (!template) {\n return undefined;\n }\n return remapTemplateValue(value, `${typeName}_${template.gqlTypeName}`);\n };\n\n const { templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: endpointType,\n typeOfType: \"type\",\n model,\n fieldRegistry,\n templates\n });\n\n const replace = new RegExp(`${model.singularApiName}_`, \"g\");\n\n const typeResolvers = templateTypes\n .map(templateType => {\n return templateType.replace(replace, `${graphQLType}_`);\n })\n .reduce<Record<string, Record<string, GraphQLFieldResolver>>>(\n (typeResolvers, templateType, index) => {\n return {\n ...typeResolvers,\n ...createFieldResolvers({\n graphQLType: templateType,\n fields: dzField.settings.templates[index].fields\n })\n };\n },\n {}\n );\n\n return {\n resolver,\n typeResolvers\n };\n };\n};\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n if (!templates.length) {\n return null;\n }\n\n const unionTypeName = createUnionTypeName(model, field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"read\",\n typeOfType: \"type\",\n model,\n fieldRegistry,\n templates\n });\n\n const templateIds = templateTypes.map(type => {\n return `extend type ${type} {\n _templateId: ID!\n _id: ID\n }\n `;\n });\n\n typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(\" | \")}`);\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${unionTypeName}!]` : unionTypeName}`,\n typeDefs: typeDefs.concat(templateIds).join(\"\\n\")\n };\n }\n\n public createResolver(\n params: CmsModelFieldToGraphQL.ResolverParams\n ): CmsModelFieldToGraphQL.Resolver {\n return createDynamicZoneResolver(\"read\")(params);\n }\n}\n\nclass ManageApi implements CmsModelFieldToGraphQL.ManageApi {\n public createTypeField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n\n if (!templates.length) {\n return null;\n }\n\n const unionTypeName = createUnionTypeName(model, field);\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"manage\",\n typeOfType: \"type\",\n model,\n fieldRegistry,\n templates\n });\n\n /* Add _templateId and _id. */\n const templateIds = templateTypes.map(type => {\n return `extend type ${type} {\n _templateId: ID!\n _id: ID\n }\n `;\n });\n\n typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(\" | \")}`);\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${unionTypeName}!]` : unionTypeName}`,\n typeDefs: typeDefs.concat(templateIds).join(\"\\n\")\n };\n }\n\n public createInputField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = getFieldTemplates(dzField);\n\n if (!templates.length) {\n return null;\n }\n\n const { typeDefs, templateTypes } = createTypeDefsForTemplates({\n models,\n field,\n type: \"manage\",\n typeOfType: \"input\",\n model,\n fieldRegistry,\n templates\n });\n\n const typeName = `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n\n const inputProperties = templateTypes.map(inputTypeName => {\n const key = inputTypeName.replace(`${typeName}_`, \"\").replace(\"Input\", \"\");\n return [key, inputTypeName];\n });\n\n /**\n * Generate a field input type, similar to this example:\n *\n * input Article_ContentInput {\n * Hero: Article_Content_HeroInput\n * SimpleText: Article_Content_SimpleTextInput\n * }\n */\n typeDefs.push(`input ${typeName}Input {\n ${inputProperties.map(\n ([key, value]) => `\n ${key}: ${value}\n `\n )}\n }`);\n\n /* Extend each template input type with _id. */\n const templateInputIds = templateTypes.map(inputTypeName => {\n return `extend input ${inputTypeName} {\n _id: ID\n }\n `;\n });\n\n return {\n fields: createGraphQLInputField(field, `${typeName}Input`),\n typeDefs: typeDefs.concat(templateInputIds).join(\"\\n\")\n };\n }\n\n public createResolver(\n params: CmsModelFieldToGraphQL.ResolverParams\n ): CmsModelFieldToGraphQL.Resolver {\n return createDynamicZoneResolver(\"manage\")(params);\n }\n\n public async normalizeInput<T>({\n field,\n input\n }: CmsModelFieldToGraphQL.InputNormalizeParams): Promise<T> {\n const dzField = field as CmsModelDynamicZoneField;\n const templates = dzField.settings?.templates || [];\n\n if (Array.isArray(input) && field.list) {\n return input\n .map(value => normalizeDynamicZoneInput(value, templates))\n .filter(Boolean) as T;\n }\n\n return normalizeDynamicZoneInput(input as GenericRecord<string>, templates) as T;\n }\n}\n\nclass DynamicZoneToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"dynamicZone\";\n public readonly isSearchable: boolean = false;\n public readonly isSortable: boolean = false;\n public readonly isFullTextSearchable: boolean = false;\n\n public getReadApi(): CmsModelFieldToGraphQL.ReadApi {\n return this.read;\n }\n\n public getManageApi(): CmsModelFieldToGraphQL.ManageApi {\n return this.manage;\n }\n\n public validateChildFields(params: ValidateChildFieldsParams<CmsModelField>): void {\n const field = params.field as CmsModelDynamicZoneField;\n const originalField = params.originalField as CmsModelDynamicZoneField | undefined;\n\n const getOriginalTemplateFields = (templateId: string) => {\n if (!originalField?.settings?.templates) {\n return [];\n }\n const template = originalField.settings.templates.find(t => t.id === templateId);\n return template?.fields || [];\n };\n\n for (const template of field.settings.templates) {\n params.validate({\n fields: template.fields,\n originalFields: getOriginalTemplateFields(template.id)\n });\n }\n }\n\n public getFieldAst(field: CmsModelField, converter: ICmsModelFieldToAst): CmsModelFieldAstNode {\n const dzField = field as CmsModelDynamicZoneField;\n const { templates = [] } = dzField.settings;\n\n return {\n type: \"field\",\n field,\n children: templates.map(({ fields, ...template }) => {\n return {\n type: \"collection\" as const,\n collection: {\n ...template,\n discriminator: \"_templateId\"\n },\n children: fields.map(f => converter.toAst(f))\n };\n })\n };\n }\n}\n\nexport const DynamicZoneFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: DynamicZoneToGraphQL,\n dependencies: []\n});\n"],"names":["createUnionTypeName","model","field","createTypeName","getFieldTemplates","Array","remapTemplateValue","value","typeName","createDynamicZoneResolver","endpointType","models","fieldRegistry","createFieldResolvers","graphQLType","dzField","templates","resolver","parent","v","template","tpl","templateTypes","createTypeDefsForTemplates","replace","RegExp","typeResolvers","templateType","index","ReadApi","unionTypeName","typeDefs","templateIds","type","params","ManageApi","inputProperties","inputTypeName","key","templateInputIds","createGraphQLInputField","input","normalizeDynamicZoneInput","Boolean","DynamicZoneToGraphQL","originalField","getOriginalTemplateFields","templateId","t","converter","fields","f","DynamicZoneFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;;;AAmBA,MAAMA,sBAAsB,CAACC,OAAiBC,QACnC,GAAGD,MAAM,eAAe,CAAC,CAAC,EAAEE,eAAeD,MAAM,OAAO,GAAG;AAGtE,MAAME,oBAAoB,CAACF;IACvB,IAAI,CAACG,MAAM,OAAO,CAACH,MAAM,QAAQ,EAAE,YAC/B,OAAO,EAAE;IAEb,OAAOA,MAAM,QAAQ,CAAC,SAAS;AACnC;AAEA,MAAMI,qBAAqB,CAACC,OAAYC,WAC7B;QAAE,GAAGD,KAAK;QAAE,YAAYC;IAAS;AAG5C,MAAMC,4BAA4B,CAC9BC,eAEO,CAAC,EAAET,KAAK,EAAEU,MAAM,EAAET,KAAK,EAAEU,aAAa,EAAEC,oBAAoB,EAAEC,WAAW,EAAE;QAC9E,MAAMC,UAAUb;QAChB,MAAMc,YAAYZ,kBAAkBW;QAEpC,IAAI,CAACC,UAAU,MAAM,EACjB,OAAO;QAGX,MAAMC,WAAW,CAACC;YACd,MAAMX,QAAQW,MAAM,CAAChB,MAAM,OAAO,CAAC;YACnC,IAAI,CAACK,OACD,OAAOA;YAGX,MAAMC,WAAW,GAAGM,YAAY,CAAC,EAAEX,eAAeD,MAAM,OAAO,GAAG;YAElE,IAAIA,MAAM,IAAI,IAAIG,MAAM,OAAO,CAACE,Q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AAY;aACtB,oBAAoB,GAAY;;AAiDpD;AAEO,MAAMiB,4BAA4BC,uBAAuB,oBAAoB,CAAC;IACjF,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
@@ -1,6 +1,6 @@
1
1
  import { CmsModelFieldToGraphQL } from "../abstractions/CmsModelFieldToGraphQL.js";
2
2
  import type { CmsContext, CmsModelField, CmsModelFieldType, CmsModelFieldDefinition } from "../../../../types/index.js";
3
- import type { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types.js";
3
+ import type { GraphQLSchemaDefinition } from "@webiny/api-graphql/types.js";
4
4
  declare class ReadApi implements CmsModelFieldToGraphQL.ReadApi {
5
5
  createTypeField({ model, field, models }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition;
6
6
  createListFilters({ field }: CmsModelFieldToGraphQL.ListFiltersParams): string;
@@ -3,10 +3,11 @@ import { CmsModelFieldToGraphQL } from "../abstractions/CmsModelFieldToGraphQL.j
3
3
  import { createTypeName } from "../../../../utils/createTypeName.js";
4
4
  import { parseIdentifier } from "@webiny/utils";
5
5
  import { createGraphQLInputField } from "./utils/createGraphQLInputField.js";
6
+ import { HeadlessCmsEndpointConfig } from "../../../../HeadlessCmsEndpointConfig.js";
6
7
  import { GetModelUseCase } from "../../../contentModel/GetModel/index.js";
7
8
  import { GetPublishedEntriesByIdsUseCase } from "../../../contentEntry/GetPublishedEntriesByIds/index.js";
8
9
  import { GetLatestEntriesByIdsUseCase } from "../../../contentEntry/GetLatestEntriesByIds/index.js";
9
- import { Logger } from "@webiny/api-core/exports/api/logger.js";
10
+ import { Logger } from "@webiny/api-core/features/logger/index.js";
10
11
  const createUnionTypeName = (model, field)=>`${model.singularApiName}_${createTypeName(field.fieldId)}`;
11
12
  const createListFilters = (fieldId)=>`
12
13
  ${fieldId}: RefFieldWhereInput
@@ -75,7 +76,8 @@ class ReadApi {
75
76
  return parent[field.fieldId];
76
77
  };
77
78
  return async (parent, args, context)=>{
78
- const { cms, container } = context;
79
+ const { container } = context;
80
+ const isReadEndpoint = "read" === container.resolve(HeadlessCmsEndpointConfig).type;
79
81
  const getModel = container.resolve(GetModelUseCase);
80
82
  const getPublishedByIds = container.resolve(GetPublishedEntriesByIdsUseCase);
81
83
  const getLatestByIds = container.resolve(GetLatestEntriesByIdsUseCase);
@@ -97,17 +99,19 @@ class ReadApi {
97
99
  const idList = entriesByModel[modelId];
98
100
  const modelResult = await getModel.execute(modelId);
99
101
  if (modelResult.isFail()) {
100
- logger.error(modelResult.error);
102
+ logger.error({
103
+ error: modelResult.error
104
+ }, "Could not load the referenced model.");
101
105
  return [];
102
106
  }
103
107
  const model = modelResult.value;
104
108
  let entries = [];
105
- if (cms.READ) {
109
+ if (isReadEndpoint) {
106
110
  const getPublishedResult = await getPublishedByIds.execute(model, idList);
107
111
  if (getPublishedResult.isOk()) entries = getPublishedResult.value;
108
112
  } else {
109
- const latestByIdsResult = await getLatestByIds.execute(model, idList);
110
- if (latestByIdsResult.isOk()) entries = latestByIdsResult.value;
113
+ const latestByIsResult = await getLatestByIds.execute(model, idList);
114
+ if (latestByIsResult.isOk()) entries = latestByIsResult.value;
111
115
  }
112
116
  return appendTypename(entries, modelIdToTypeName.get(modelId));
113
117
  });
@@ -117,12 +121,14 @@ class ReadApi {
117
121
  const value = initialValue;
118
122
  const modelResult = await getModel.execute(value.modelId);
119
123
  if (modelResult.isFail()) {
120
- logger.error(modelResult.error);
124
+ logger.error({
125
+ error: modelResult.error
126
+ }, "Could not load the referenced model.");
121
127
  return null;
122
128
  }
123
129
  const model = modelResult.value;
124
130
  let revisions = [];
125
- if (cms.READ) {
131
+ if (isReadEndpoint) {
126
132
  const publishedByIdsResult = await getPublishedByIds.execute(model, [
127
133
  value.entryId
128
134
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"features/graphql/fields/base/RefToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/RefToGraphQL.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsModel,\n CmsModelField,\n CmsModelFieldType,\n CmsModelFieldDefinition\n} from \"~/types/index.js\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types.js\";\nimport { createTypeName } from \"~/utils/createTypeName.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createGraphQLInputField } from \"./utils/createGraphQLInputField.js\";\nimport { GetModelUseCase } from \"~/features/contentModel/GetModel/index.js\";\nimport { GetPublishedEntriesByIdsUseCase } from \"~/features/contentEntry/GetPublishedEntriesByIds/index.js\";\nimport { GetLatestEntriesByIdsUseCase } from \"~/features/contentEntry/GetLatestEntriesByIds/index.js\";\nimport { Logger } from \"@webiny/api-core/exports/api/logger.js\";\n\ninterface RefFieldValue {\n /**\n * `id` is optional for backwards compatibility with records created before this property was introduced.\n */\n id?: string;\n entryId: string;\n modelId: string;\n}\n\nconst createUnionTypeName = (model: CmsModel, field: CmsModelField) => {\n return `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n};\n\nconst createListFilters = (fieldId: string): string => {\n return `\n ${fieldId}: RefFieldWhereInput\n `;\n};\n\nconst createFilteringTypeDef = () => {\n return `\n input RefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n modelId: String\n modelId_not: String\n modelId_in: [String!]\n modelId_not_in: [String!]\n }\n `;\n};\n\nconst appendTypename = (entries: CmsEntry[], typename: string): CmsEntry[] => {\n return entries.map(item => {\n return {\n ...item,\n __typename: typename\n };\n });\n};\n\nconst getFieldModels = (field: CmsModelField): Pick<CmsModel, \"modelId\">[] => {\n if (!field.settings || Array.isArray(field.settings.models) === false) {\n return [];\n }\n return field.settings.models as Pick<CmsModel, \"modelId\">[];\n};\n\nconst modelIdToTypeName = new Map<string, string>();\n\ninterface GetModelParams {\n models: CmsModel[];\n modelId: string;\n}\n\nconst getModel = (params: GetModelParams): CmsModel => {\n const { models, modelId } = params;\n const model = models.find(item => item.modelId === modelId);\n if (model) {\n return model;\n }\n throw new WebinyError(\n `Could not find model with ID \"${modelId}\" in the list of models.`,\n \"MODEL_NOT_FOUND\",\n { modelId }\n );\n};\n\nconst getModelSingularApiName = (params: GetModelParams): string => {\n return getModel(params).singularApiName;\n};\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({\n model,\n field,\n models\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition {\n const fieldModels = field.settings?.models || [];\n const gqlType =\n fieldModels.length > 1\n ? createUnionTypeName(model, field)\n : getModelSingularApiName({ models, modelId: fieldModels[0].modelId });\n const typeDefs =\n fieldModels.length > 1\n ? `union ${gqlType} = ${getFieldModels(field)\n .map(({ modelId }) => getModelSingularApiName({ models, modelId }))\n .join(\" | \")}`\n : \"\";\n\n return {\n fields:\n field.fieldId +\n `(populate: Boolean = true): ${field.list ? `[${gqlType}!]` : gqlType}`,\n typeDefs\n };\n }\n\n public createListFilters({ field }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createListFilters(field.fieldId);\n }\n\n public createResolver({\n field,\n models\n }: CmsModelFieldToGraphQL.ResolverParams): CmsModelFieldToGraphQL.Resolver {\n const fieldModels = field.settings?.models || [];\n for (const item of fieldModels) {\n modelIdToTypeName.set(\n item.modelId,\n getModelSingularApiName({ models, modelId: item.modelId })\n );\n }\n\n const getValue = (parent: any): RefFieldValue | RefFieldValue[] => {\n if (parent.values) {\n return parent.values[field.fieldId];\n }\n return parent[field.fieldId];\n };\n\n /* @ts-expect-error Mixed return types for createResolver. */\n return async (parent: CmsEntry, args: any, context: CmsContext) => {\n const { cms, container } = context;\n\n const getModel = container.resolve(GetModelUseCase);\n const getPublishedByIds = container.resolve(GetPublishedEntriesByIdsUseCase);\n const getLatestByIds = container.resolve(GetLatestEntriesByIdsUseCase);\n const logger = container.resolve(Logger);\n\n const initialValue = getValue(parent);\n\n if (!initialValue) {\n return null;\n }\n if (args.populate === false) {\n return initialValue;\n }\n\n if (field.list) {\n const referenceFieldValues = initialValue as RefFieldValue[];\n if (\n Array.isArray(referenceFieldValues) === false ||\n referenceFieldValues.length === 0\n ) {\n return [];\n }\n\n const entriesByModel = referenceFieldValues.reduce<Record<string, string[]>>(\n (collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.entryId) === true) {\n return collection;\n }\n collection[ref.modelId].push(ref.entryId);\n return collection;\n },\n {}\n );\n\n const getters = Object.keys(entriesByModel).map(async modelId => {\n const idList = entriesByModel[modelId];\n const modelResult = await getModel.execute(modelId);\n if (modelResult.isFail()) {\n logger.error(modelResult.error);\n return [];\n }\n const model = modelResult.value;\n\n let entries: CmsEntry[] = [];\n if (cms.READ) {\n const getPublishedResult = await getPublishedByIds.execute(model, idList);\n if (getPublishedResult.isOk()) {\n entries = getPublishedResult.value;\n }\n } else {\n const latestByIdsResult = await getLatestByIds.execute(model, idList);\n if (latestByIdsResult.isOk()) {\n entries = latestByIdsResult.value;\n }\n }\n return appendTypename(entries, modelIdToTypeName.get(modelId)!);\n });\n\n const references = await Promise.all(getters).then((results: CmsEntry[][]) => {\n return results.reduce((result, item) => {\n return result.concat(item);\n }, []);\n });\n\n return referenceFieldValues\n .map(v => {\n return references.find(ref => ref.entryId === v.entryId);\n })\n .filter(Boolean);\n }\n\n const value = initialValue as RefFieldValue;\n const modelResult = await getModel.execute(value.modelId);\n if (modelResult.isFail()) {\n logger.error(modelResult.error);\n return null;\n }\n const model = modelResult.value;\n\n let revisions: CmsEntry[] = [];\n if (cms.READ) {\n const publishedByIdsResult = await getPublishedByIds.execute(model, [\n value.entryId\n ]);\n if (publishedByIdsResult.isOk()) {\n revisions = publishedByIdsResult.value;\n }\n } else {\n const latestByIdsResult = await getLatestByIds.execute(model, [value.entryId]);\n if (latestByIdsResult.isOk()) {\n revisions = latestByIdsResult.value;\n }\n }\n\n if (!revisions || revisions.length === 0) {\n return null;\n }\n return {\n ...revisions[0],\n __typename: modelIdToTypeName.get(value.modelId)\n };\n };\n }\n\n public createSchema(): GraphQLSchemaDefinition<CmsContext> {\n return {\n typeDefs: createFilteringTypeDef(),\n resolvers: {}\n };\n }\n}\n\nclass ManageApi implements CmsModelFieldToGraphQL.ManageApi {\n public createTypeField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n if (field.list) {\n return `${field.fieldId}: [RefField!]`;\n }\n return `${field.fieldId}: RefField`;\n }\n\n public createInputField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n return createGraphQLInputField(field, \"RefFieldInput\");\n }\n\n public createListFilters({ field }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createListFilters(field.fieldId);\n }\n\n public createSchema(): GraphQLSchemaDefinition<CmsContext> {\n return {\n typeDefs: /* GraphQL */ `\n type RefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n\n input RefFieldInput {\n modelId: String!\n id: RevisionId!\n }\n\n ${createFilteringTypeDef()}\n `,\n resolvers: {\n RefField: {\n entryId: (parent: RefFieldValue) => {\n const { id } = parseIdentifier(parent.entryId || parent.id);\n return id;\n },\n id: (parent: RefFieldValue) => {\n return parent.id || parent.entryId;\n }\n }\n }\n };\n }\n}\n\nclass RefToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"ref\";\n public readonly isSearchable: boolean = true;\n public readonly isSortable: boolean = false;\n public readonly isFullTextSearchable: boolean = false;\n\n public getReadApi(): CmsModelFieldToGraphQL.ReadApi {\n return this.read;\n }\n\n public getManageApi(): CmsModelFieldToGraphQL.ManageApi {\n return this.manage;\n }\n}\n\nexport const RefFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: RefToGraphQL,\n dependencies: []\n});\n"],"names":["createUnionTypeName","model","field","createTypeName","createListFilters","fieldId","createFilteringTypeDef","appendTypename","entries","typename","item","getFieldModels","Array","modelIdToTypeName","Map","getModel","params","models","modelId","WebinyError","getModelSingularApiName","ReadApi","fieldModels","gqlType","typeDefs","getValue","parent","args","context","cms","container","GetModelUseCase","getPublishedByIds","GetPublishedEntriesByIdsUseCase","getLatestByIds","GetLatestEntriesByIdsUseCase","logger","Logger","initialValue","referenceFieldValues","entriesByModel","collection","ref","getters","Object","idList","modelResult","getPublishedResult","latestByIdsResult","references","Promise","results","result","v","Boolean","value","revisions","publishedByIdsResult","ManageApi","createGraphQLInputField","id","parseIdentifier","RefToGraphQL","RefFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;;;;;;;AA4BA,MAAMA,sBAAsB,CAACC,OAAiBC,QACnC,GAAGD,MAAM,eAAe,CAAC,CAAC,EAAEE,eAAeD,MAAM,OAAO,GAAG;AAGtE,MAAME,oBAAoB,CAACC,UAChB,CAAC;QACJ,EAAEA,QAAQ;IACd,CAAC;AAGL,MAAMC,yBAAyB,IACpB,CAAC;;;;;;;;;;;;;;;IAeR,CAAC;AAGL,MAAMC,iBAAiB,CAACC,SAAqBC,WAClCD,QAAQ,GAAG,CAACE,CAAAA,OACR;YACH,GAAGA,IAAI;YACP,YAAYD;QAChB;AAIR,MAAME,iBAAiB,CAACT;IACpB,IAAI,CAACA,MAAM,QAAQ,IAAIU,AAAyC,UAAzCA,MAAM,OAAO,CAACV,MAAM,QAAQ,CAAC,MAAM,GACtD,OAAO,EAAE;IAEb,OAAOA,MAAM,QAAQ,CAAC,MAAM;AAChC;AAEA,MAAMW,oBAAoB,IAAIC;AAO9B,MAAMC,wBAAW,CAACC;IACd,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;IAC5B,MAAMf,QAAQgB,OAAO,IAAI,CAACP,CAAAA,OAAQA,KAAK,OAAO,KAAKQ;IACnD,IAAIjB,OACA,OAAOA;IAEX,MAAM,IAAIkB,MACN,CAAC,8BAA8B,EAAED,QAAQ,wBA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efToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/RefToGraphQL.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type {\n CmsContext,\n CmsEntry,\n CmsModel,\n CmsModelField,\n CmsModelFieldType,\n CmsModelFieldDefinition\n} from \"~/types/index.js\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/api-graphql/types.js\";\nimport { createTypeName } from \"~/utils/createTypeName.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createGraphQLInputField } from \"./utils/createGraphQLInputField.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\nimport { GetModelUseCase } from \"~/features/contentModel/GetModel/index.js\";\nimport { GetPublishedEntriesByIdsUseCase } from \"~/features/contentEntry/GetPublishedEntriesByIds/index.js\";\nimport { GetLatestEntriesByIdsUseCase } from \"~/features/contentEntry/GetLatestEntriesByIds/index.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\ninterface RefFieldValue {\n /**\n * `id` is optional for backwards compatibility with records created before this property was introduced.\n */\n id?: string;\n entryId: string;\n modelId: string;\n}\n\nconst createUnionTypeName = (model: CmsModel, field: CmsModelField) => {\n return `${model.singularApiName}_${createTypeName(field.fieldId)}`;\n};\n\nconst createListFilters = (fieldId: string): string => {\n return `\n ${fieldId}: RefFieldWhereInput\n `;\n};\n\nconst createFilteringTypeDef = () => {\n return `\n input RefFieldWhereInput {\n id: String\n id_not: String\n id_in: [String!]\n id_not_in: [String]\n entryId: String\n entryId_not: String\n entryId_in: [String!]\n entryId_not_in: [String!]\n modelId: String\n modelId_not: String\n modelId_in: [String!]\n modelId_not_in: [String!]\n }\n `;\n};\n\nconst appendTypename = (entries: CmsEntry[], typename: string): CmsEntry[] => {\n return entries.map(item => {\n return {\n ...item,\n __typename: typename\n };\n });\n};\n\nconst getFieldModels = (field: CmsModelField): Pick<CmsModel, \"modelId\">[] => {\n if (!field.settings || Array.isArray(field.settings.models) === false) {\n return [];\n }\n return field.settings.models as Pick<CmsModel, \"modelId\">[];\n};\n\nconst modelIdToTypeName = new Map<string, string>();\n\ninterface GetModelParams {\n models: CmsModel[];\n modelId: string;\n}\n\nconst getModel = (params: GetModelParams): CmsModel => {\n const { models, modelId } = params;\n const model = models.find(item => item.modelId === modelId);\n if (model) {\n return model;\n }\n throw new WebinyError(\n `Could not find model with ID \"${modelId}\" in the list of models.`,\n \"MODEL_NOT_FOUND\",\n { modelId }\n );\n};\n\nconst getModelSingularApiName = (params: GetModelParams): string => {\n return getModel(params).singularApiName;\n};\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({\n model,\n field,\n models\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition {\n const fieldModels = field.settings?.models || [];\n const gqlType =\n fieldModels.length > 1\n ? createUnionTypeName(model, field)\n : getModelSingularApiName({ models, modelId: fieldModels[0].modelId });\n const typeDefs =\n fieldModels.length > 1\n ? `union ${gqlType} = ${getFieldModels(field)\n .map(({ modelId }) => getModelSingularApiName({ models, modelId }))\n .join(\" | \")}`\n : \"\";\n\n return {\n fields:\n field.fieldId +\n `(populate: Boolean = true): ${field.list ? `[${gqlType}!]` : gqlType}`,\n typeDefs\n };\n }\n\n public createListFilters({ field }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createListFilters(field.fieldId);\n }\n\n public createResolver({\n field,\n models\n }: CmsModelFieldToGraphQL.ResolverParams): CmsModelFieldToGraphQL.Resolver {\n const fieldModels = field.settings?.models || [];\n for (const item of fieldModels) {\n modelIdToTypeName.set(\n item.modelId,\n getModelSingularApiName({ models, modelId: item.modelId })\n );\n }\n\n const getValue = (parent: any): RefFieldValue | RefFieldValue[] => {\n if (parent.values) {\n return parent.values[field.fieldId];\n }\n return parent[field.fieldId];\n };\n\n return async (parent: CmsEntry, args: any, context: CmsContext) => {\n const { container } = context;\n const isReadEndpoint = container.resolve(HeadlessCmsEndpointConfig).type === \"read\";\n\n const getModel = container.resolve(GetModelUseCase);\n const getPublishedByIds = container.resolve(GetPublishedEntriesByIdsUseCase);\n const getLatestByIds = container.resolve(GetLatestEntriesByIdsUseCase);\n const logger = container.resolve(Logger);\n\n const initialValue = getValue(parent);\n\n if (!initialValue) {\n return null;\n }\n if (args.populate === false) {\n return initialValue;\n }\n\n if (field.list) {\n const referenceFieldValues = initialValue as RefFieldValue[];\n if (\n Array.isArray(referenceFieldValues) === false ||\n referenceFieldValues.length === 0\n ) {\n return [];\n }\n\n const entriesByModel = referenceFieldValues.reduce(\n (collection, ref) => {\n if (!collection[ref.modelId]) {\n collection[ref.modelId] = [];\n } else if (collection[ref.modelId].includes(ref.entryId) === true) {\n return collection;\n }\n collection[ref.modelId].push(ref.entryId);\n return collection;\n },\n {} as Record<string, string[]>\n );\n\n const getters = Object.keys(entriesByModel).map(async modelId => {\n const idList = entriesByModel[modelId];\n const modelResult = await getModel.execute(modelId);\n if (modelResult.isFail()) {\n logger.error(\n { error: modelResult.error },\n \"Could not load the referenced model.\"\n );\n return [];\n }\n const model = modelResult.value;\n\n let entries: CmsEntry[] = [];\n if (isReadEndpoint) {\n const getPublishedResult = await getPublishedByIds.execute(model, idList);\n if (getPublishedResult.isOk()) {\n entries = getPublishedResult.value;\n }\n } else {\n const latestByIsResult = await getLatestByIds.execute(model, idList);\n if (latestByIsResult.isOk()) {\n entries = latestByIsResult.value;\n }\n }\n return appendTypename(entries, modelIdToTypeName.get(modelId)!);\n });\n\n const references = await Promise.all(getters).then((results: CmsEntry[][]) => {\n return results.reduce((result, item) => {\n return result.concat(item);\n }, []);\n });\n\n return referenceFieldValues\n .map(v => {\n return references.find(ref => ref.entryId === v.entryId);\n })\n .filter(Boolean);\n }\n\n const value = initialValue as RefFieldValue;\n const modelResult = await getModel.execute(value.modelId);\n if (modelResult.isFail()) {\n logger.error({ error: modelResult.error }, \"Could not load the referenced model.\");\n return null;\n }\n const model = modelResult.value;\n\n let revisions: CmsEntry[] = [];\n if (isReadEndpoint) {\n const publishedByIdsResult = await getPublishedByIds.execute(model, [\n value.entryId\n ]);\n if (publishedByIdsResult.isOk()) {\n revisions = publishedByIdsResult.value;\n }\n } else {\n const latestByIdsResult = await getLatestByIds.execute(model, [value.entryId]);\n if (latestByIdsResult.isOk()) {\n revisions = latestByIdsResult.value;\n }\n }\n\n if (!revisions || revisions.length === 0) {\n return null;\n }\n return {\n ...revisions[0],\n __typename: modelIdToTypeName.get(value.modelId)\n };\n };\n }\n\n public createSchema(): GraphQLSchemaDefinition<CmsContext> {\n return {\n typeDefs: createFilteringTypeDef(),\n resolvers: {}\n };\n }\n}\n\nclass ManageApi implements CmsModelFieldToGraphQL.ManageApi {\n public createTypeField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n if (field.list) {\n return `${field.fieldId}: [RefField!]`;\n }\n return `${field.fieldId}: RefField`;\n }\n\n public createInputField({ field }: CmsModelFieldToGraphQL.TypeFieldParams): string {\n return createGraphQLInputField(field, \"RefFieldInput\");\n }\n\n public createListFilters({ field }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createListFilters(field.fieldId);\n }\n\n public createSchema(): GraphQLSchemaDefinition<CmsContext> {\n return {\n typeDefs: /* GraphQL */ `\n type RefField {\n modelId: String!\n entryId: ID!\n id: ID!\n }\n\n input RefFieldInput {\n modelId: String!\n id: RevisionId!\n }\n\n ${createFilteringTypeDef()}\n `,\n resolvers: {\n RefField: {\n entryId: (parent: RefFieldValue) => {\n const { id } = parseIdentifier(parent.entryId || parent.id);\n return id;\n },\n id: (parent: RefFieldValue) => {\n return parent.id || parent.entryId;\n }\n }\n }\n };\n }\n}\n\nclass RefToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"ref\";\n public readonly isSearchable: boolean = true;\n public readonly isSortable: boolean = false;\n public readonly isFullTextSearchable: boolean = false;\n\n public getReadApi(): CmsModelFieldToGraphQL.ReadApi {\n return this.read;\n }\n\n public getManageApi(): CmsModelFieldToGraphQL.ManageApi {\n return this.manage;\n }\n}\n\nexport const RefFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: RefToGraphQL,\n dependencies: []\n});\n"],"names":["createUnionTypeName","model","field","createTypeName","createListFilters","fieldId","createFilteringTypeDef","appendTypename","entries","typename","item","getFieldModels","Array","modelIdToTypeName","Map","getModel","params","models","modelId","WebinyError","getModelSingularApiName","ReadApi","fieldModels","gqlType","typeDefs","getValue","parent","args","context","container","isReadEndpoint","HeadlessCmsEndpointConfig","GetModelUseCase","getPublishedByIds","GetPublishedEntriesByIdsUseCase","getLatestByIds","GetLatestEntriesByIdsUseCase","logger","Logger","initialValue","referenceFieldValues","entriesByModel","collection","ref","getters","Object","idList","modelResult","getPublishedResult","latestByIsResult","references","Promise","results","result","v","Boolean","value","revisions","publishedByIdsResult","latestByIdsResult","ManageApi","createGraphQLInputField","id","parseIdentifier","RefToGraphQL","RefFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;;;;;;;;AA6BA,MAAMA,sBAAsB,CAACC,OAAiBC,QACnC,GAAGD,MAAM,eAAe,CAAC,CAAC,EAAEE,eAAeD,MAAM,OAAO,GAAG;AAGtE,MAAME,oBAAoB,CAACC,UAChB,CAAC;QACJ,EAAEA,QAAQ;IACd,CAAC;AAGL,MAAMC,yBAAyB,IACpB,CAAC;;;;;;;;;;;;;;;IAeR,CAAC;AAGL,MAAMC,iBAAiB,CAACC,SAAqBC,WAClCD,QAAQ,GAAG,CAACE,CAAAA,OACR;YACH,GAAGA,IAAI;YACP,YAAYD;QAChB;AAIR,MAAME,iBAAiB,CAACT;IACpB,IAAI,CAACA,MAAM,QAAQ,IAAIU,AAAyC,UAAzCA,MAAM,OAAO,CAACV,MAAM,QAAQ,CAAC,MAAM,GACtD,OAAO,EAAE;IAEb,OAAOA,MAAM,QAAQ,CAAC,MAAM;AAChC;AA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;IASK,aAA6C;QAChD,OAAO,IAAI,CAAC,IAAI;IACpB;IAEO,eAAiD;QACpD,OAAO,IAAI,CAAC,MAAM;IACtB;;aAdgB,IAAI,GAAG,IAAI3C;aACX,MAAM,GAAG,IAAIuC;aAEb,SAAS,GAAsB;aAC/B,YAAY,GAAY;aACxB,UAAU,GAAY;aACtB,oBAAoB,GAAY;;AASpD;AAEO,MAAMK,oBAAoBC,uBAAuB,oBAAoB,CAAC;IACzE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -1,4 +1,4 @@
1
- import type { GraphQLFieldResolver } from "@webiny/handler-graphql/types.js";
1
+ import type { GraphQLFieldResolver } from "@webiny/api-graphql/types.js";
2
2
  import type { CmsModelField } from "../../../../../types/index.js";
3
3
  interface ResolverArgs {
4
4
  format?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"features/graphql/fields/base/richText/richTextResolver.js","sources":["../../../../../../src/features/graphql/fields/base/richText/richTextResolver.ts"],"sourcesContent":["import type { GraphQLFieldResolver } from \"@webiny/handler-graphql/types.js\";\nimport type { CmsModelField } from \"~/types/index.js\";\n\ninterface ResolverArgs {\n format?: string;\n}\n\ninterface RichTextContents {\n state: string;\n html: string;\n}\n\nexport const createRichTextResolver = (\n field: CmsModelField\n): GraphQLFieldResolver<any, ResolverArgs> => {\n return async (entry, args) => {\n const rawValue = entry[field.fieldId] as RichTextContents;\n const outputFormat = args.format;\n\n /* If `lexical` state is requested explicitly. */\n if (outputFormat === \"lexical\") {\n if (field.list) {\n return (rawValue as unknown as RichTextContents[]).map(value => value.state);\n }\n return rawValue?.state ?? null;\n }\n\n /* Otherwise return HTML. */\n if (field.list) {\n return (rawValue as unknown as RichTextContents[]).map(value => value?.html ?? null);\n }\n\n return rawValue?.html ?? null;\n };\n};\n"],"names":["createRichTextResolver","field","entry","args","rawValue","outputFormat","value"],"mappings":"AAYO,MAAMA,yBAAyB,CAClCC,QAEO,OAAOC,OAAOC;QACjB,MAAMC,WAAWF,KAAK,CAACD,MAAM,OAAO,CAAC;QACrC,MAAMI,eAAeF,KAAK,MAAM;QAGhC,IAAIE,AAAiB,cAAjBA,cAA4B;YAC5B,IAAIJ,MAAM,IAAI,EACV,OAAQG,SAA2C,GAAG,CAACE,CAAAA,QAASA,MAAM,KAAK;YAE/E,OAAOF,UAAU,SAAS;QAC9B;QAGA,IAAIH,MAAM,IAAI,EACV,OAAQG,SAA2C,GAAG,CAACE,CAAAA,QAASA,OAAO,QAAQ;QAGnF,OAAOF,UAAU,QAAQ;IAC7B"}
1
+ {"version":3,"file":"features/graphql/fields/base/richText/richTextResolver.js","sources":["../../../../../../src/features/graphql/fields/base/richText/richTextResolver.ts"],"sourcesContent":["import type { GraphQLFieldResolver } from \"@webiny/api-graphql/types.js\";\nimport type { CmsModelField } from \"~/types/index.js\";\n\ninterface ResolverArgs {\n format?: string;\n}\n\ninterface RichTextContents {\n state: string;\n html: string;\n}\n\nexport const createRichTextResolver = (\n field: CmsModelField\n): GraphQLFieldResolver<any, ResolverArgs> => {\n return async (entry, args) => {\n const rawValue = entry[field.fieldId] as RichTextContents;\n const outputFormat = args.format;\n\n /* If `lexical` state is requested explicitly. */\n if (outputFormat === \"lexical\") {\n if (field.list) {\n return (rawValue as unknown as RichTextContents[]).map(value => value.state);\n }\n return rawValue?.state ?? null;\n }\n\n /* Otherwise return HTML. */\n if (field.list) {\n return (rawValue as unknown as RichTextContents[]).map(value => value?.html ?? null);\n }\n\n return rawValue?.html ?? null;\n };\n};\n"],"names":["createRichTextResolver","field","entry","args","rawValue","outputFormat","value"],"mappings":"AAYO,MAAMA,yBAAyB,CAClCC,QAEO,OAAOC,OAAOC;QACjB,MAAMC,WAAWF,KAAK,CAACD,MAAM,OAAO,CAAC;QACrC,MAAMI,eAAeF,KAAK,MAAM;QAGhC,IAAIE,AAAiB,cAAjBA,cAA4B;YAC5B,IAAIJ,MAAM,IAAI,EACV,OAAQG,SAA2C,GAAG,CAACE,CAAAA,QAASA,MAAM,KAAK;YAE/E,OAAOF,UAAU,SAAS;QAC9B;QAGA,IAAIH,MAAM,IAAI,EACV,OAAQG,SAA2C,GAAG,CAACE,CAAAA,QAASA,OAAO,QAAQ;QAGnF,OAAOF,UAAU,QAAQ;IAC7B"}
@@ -8,6 +8,10 @@ import type { IModelBuilderPrivateInput, IModelBuilderPublicInput } from "./mode
8
8
  export interface IModelSettings {
9
9
  aiEntryWizard?: boolean;
10
10
  previewPath?: string;
11
+ /**
12
+ * Set via `builder.private({ lifecycleEvents: false })`. Only honored for private models.
13
+ */
14
+ lifecycleEvents?: boolean;
11
15
  [key: string]: any;
12
16
  }
13
17
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"features/modelBuilder/abstractions.js","sources":["../../../src/features/modelBuilder/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { PrivateModelBuilder } from \"./models/PrivateModelBuilder.js\";\nimport type { PublicModelBuilder } from \"./models/PublicModelBuilder.js\";\nimport type { IModelBuilderPrivateInput, IModelBuilderPublicInput } from \"./models/ModelBuilder.js\";\n\n/**\n * Augmentable model settings interface.\n * External packages can extend this via module augmentation.\n */\nexport interface IModelSettings {\n aiEntryWizard?: boolean;\n previewPath?: string;\n [key: string]: any;\n}\n\n/**\n * Augmentable field builder registry. Provides access to all registered field types.\n */\nexport interface IFieldBuilderRegistry {\n /**\n * Mark the next field creation as an extension.\n * When extending, the registry will create a temporary builder marked with _extendMode,\n * and BaseModelBuilder will merge its operations into the existing field.\n */\n extend(): this;\n\n // Field types will be added via module augmentation by field type implementations\n // Example: text(): ITextFieldBuilder;\n}\n\n/**\n * @internal Do not export this abstraction. We don't want external developers to use it.\n */\nexport const FieldBuilderRegistry =\n createAbstraction<FieldBuilderRegistry.Interface>(\"FieldBuilderRegistry\");\n\nexport namespace FieldBuilderRegistry {\n export interface Interface extends IFieldBuilderRegistry {}\n}\n\n/**\n * Unified Model abstraction\n * External developers implement this to provide both public and private models\n */\n\nexport interface IModelBuilder {\n private(input: IModelBuilderPrivateInput): PrivateModelBuilder;\n public(input: IModelBuilderPublicInput): PublicModelBuilder;\n}\n\nexport interface IModelFactory {\n execute(builder: IModelBuilder): Promise<PrivateModelBuilder[] | PublicModelBuilder[]>;\n}\n\n/** Provide code-defined content models. */\nexport const ModelFactory = createAbstraction<IModelFactory>(\"Cms/ModelFactory\");\nexport namespace ModelFactory {\n export type Interface = IModelFactory;\n export type Return = Promise<PrivateModelBuilder[] | PublicModelBuilder[]>;\n export type Builder = IModelBuilder;\n export type FieldBuilder = FieldBuilderRegistry.Interface;\n}\n"],"names":["FieldBuilderRegistry","createAbstraction","ModelFactory"],"mappings":";AAiCO,MAAMA,uBACTC,kBAAkD;AAqB/C,MAAMC,eAAeD,kBAAiC"}
1
+ {"version":3,"file":"features/modelBuilder/abstractions.js","sources":["../../../src/features/modelBuilder/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { PrivateModelBuilder } from \"./models/PrivateModelBuilder.js\";\nimport type { PublicModelBuilder } from \"./models/PublicModelBuilder.js\";\nimport type { IModelBuilderPrivateInput, IModelBuilderPublicInput } from \"./models/ModelBuilder.js\";\n\n/**\n * Augmentable model settings interface.\n * External packages can extend this via module augmentation.\n */\nexport interface IModelSettings {\n aiEntryWizard?: boolean;\n previewPath?: string;\n /**\n * Set via `builder.private({ lifecycleEvents: false })`. Only honored for private models.\n */\n lifecycleEvents?: boolean;\n [key: string]: any;\n}\n\n/**\n * Augmentable field builder registry. Provides access to all registered field types.\n */\nexport interface IFieldBuilderRegistry {\n /**\n * Mark the next field creation as an extension.\n * When extending, the registry will create a temporary builder marked with _extendMode,\n * and BaseModelBuilder will merge its operations into the existing field.\n */\n extend(): this;\n\n // Field types will be added via module augmentation by field type implementations\n // Example: text(): ITextFieldBuilder;\n}\n\n/**\n * @internal Do not export this abstraction. We don't want external developers to use it.\n */\nexport const FieldBuilderRegistry =\n createAbstraction<FieldBuilderRegistry.Interface>(\"FieldBuilderRegistry\");\n\nexport namespace FieldBuilderRegistry {\n export interface Interface extends IFieldBuilderRegistry {}\n}\n\n/**\n * Unified Model abstraction\n * External developers implement this to provide both public and private models\n */\n\nexport interface IModelBuilder {\n private(input: IModelBuilderPrivateInput): PrivateModelBuilder;\n public(input: IModelBuilderPublicInput): PublicModelBuilder;\n}\n\nexport interface IModelFactory {\n execute(builder: IModelBuilder): Promise<PrivateModelBuilder[] | PublicModelBuilder[]>;\n}\n\n/** Provide code-defined content models. */\nexport const ModelFactory = createAbstraction<IModelFactory>(\"Cms/ModelFactory\");\nexport namespace ModelFactory {\n export type Interface = IModelFactory;\n export type Return = Promise<PrivateModelBuilder[] | PublicModelBuilder[]>;\n export type Builder = IModelBuilder;\n export type FieldBuilder = FieldBuilderRegistry.Interface;\n}\n"],"names":["FieldBuilderRegistry","createAbstraction","ModelFactory"],"mappings":";AAqCO,MAAMA,uBACTC,kBAAkD;AAqB/C,MAAMC,eAAeD,kBAAiC"}
@@ -14,7 +14,6 @@ import { DateTimeFieldType } from "./fields/DateTimeFieldType.js";
14
14
  import { JsonFieldType } from "./fields/JsonFieldType.js";
15
15
  import { SearchableJsonFieldType } from "./fields/SearchableJsonFieldType.js";
16
16
  import { FieldBuilderRegistry as external_abstractions_js_FieldBuilderRegistry, ModelFactory } from "./abstractions.js";
17
- import { AccessControl } from "../shared/abstractions.js";
18
17
  import { ModelsProvider } from "./models/abstractions.js";
19
18
  import { ModelsProvider as ModelsProvider_js_ModelsProvider } from "./models/ModelsProvider.js";
20
19
  import { UiSeparatorFieldType } from "./fields/UiSeparatorFieldType.js";
@@ -40,13 +39,7 @@ const ModelBuilderFeature = createFeature({
40
39
  container.register(UiAlertFieldType);
41
40
  container.register(UiTabsFieldType);
42
41
  container.register(FieldBuilderRegistry).inSingletonScope();
43
- container.registerFactory(ModelsProvider, ()=>{
44
- let accessControl;
45
- try {
46
- accessControl = container.resolve(AccessControl);
47
- } catch {}
48
- return new ModelsProvider_js_ModelsProvider(()=>container.resolveAll(ModelFactory), container.resolve(external_abstractions_js_FieldBuilderRegistry), accessControl);
49
- });
42
+ container.registerFactory(ModelsProvider, ()=>new ModelsProvider_js_ModelsProvider(()=>container.resolveAll(ModelFactory), container.resolve(external_abstractions_js_FieldBuilderRegistry)));
50
43
  }
51
44
  });
52
45
  export { ModelBuilderFeature };