@webiny/api-headless-cms 6.6.0-alpha.1 → 6.6.0-alpha.11

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 (463) hide show
  1. package/HeadlessCmsFeature.js +13 -37
  2. package/HeadlessCmsFeature.js.map +1 -1
  3. package/createCmsRoute.d.ts +3 -5
  4. package/createCmsRoute.js +26 -14
  5. package/createCmsRoute.js.map +1 -1
  6. package/crud/contentEntry/entryDataValidation.js +17 -11
  7. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  8. package/crud/contentModel/validate/endingAllowed.js +1 -1
  9. package/crud/contentModel/validate/endingAllowed.js.map +1 -1
  10. package/crud/contentModel/validate/pluralApiName.js +1 -1
  11. package/crud/contentModel/validate/pluralApiName.js.map +1 -1
  12. package/crud/contentModel/validate/singularApiName.js +1 -1
  13. package/crud/contentModel/validate/singularApiName.js.map +1 -1
  14. package/crud/contentModel/validation.js +2 -2
  15. package/crud/contentModel/validation.js.map +1 -1
  16. package/domain/contentModel/schemas.d.ts +2 -0
  17. package/domain/contentModel/schemas.js +1 -0
  18. package/domain/contentModel/schemas.js.map +1 -1
  19. package/domain/contentModel/validation/dateExpressions.d.ts +6 -0
  20. package/domain/contentModel/validation/dateExpressions.js +27 -0
  21. package/domain/contentModel/validation/dateExpressions.js.map +1 -0
  22. package/domain/contentModel/validation/endingAllowed.js +1 -1
  23. package/domain/contentModel/validation/endingAllowed.js.map +1 -1
  24. package/domain/contentModel/validation/modelFields.js +4 -2
  25. package/domain/contentModel/validation/modelFields.js.map +1 -1
  26. package/domain/contentModel/validation/pluralApiName.js +1 -1
  27. package/domain/contentModel/validation/pluralApiName.js.map +1 -1
  28. package/domain/contentModel/validation/singularApiName.js +1 -1
  29. package/domain/contentModel/validation/singularApiName.js.map +1 -1
  30. package/export/crud/exporting.js +2 -2
  31. package/export/crud/exporting.js.map +1 -1
  32. package/export/crud/imports/importGroups.js +1 -2
  33. package/export/crud/imports/importGroups.js.map +1 -1
  34. package/export/crud/imports/validateModels.js +1 -1
  35. package/export/crud/imports/validateModels.js.map +1 -1
  36. package/exports/api/cms/entry.d.ts +5 -0
  37. package/exports/api/cms/entry.js +5 -0
  38. package/features/ai/DescribeContentModelTool.d.ts +11 -6
  39. package/features/ai/DescribeContentModelTool.js +21 -12
  40. package/features/ai/DescribeContentModelTool.js.map +1 -1
  41. package/features/ai/ListContentModelsTool.d.ts +11 -6
  42. package/features/ai/ListContentModelsTool.js +21 -12
  43. package/features/ai/ListContentModelsTool.js.map +1 -1
  44. package/features/ai/QueryEntriesTool.d.ts +14 -9
  45. package/features/ai/QueryEntriesTool.js +20 -11
  46. package/features/ai/QueryEntriesTool.js.map +1 -1
  47. package/features/ai/feature.d.ts +2 -2
  48. package/features/ai/feature.js.map +1 -1
  49. package/features/contentEntry/ContentEntriesFeature.js +8 -0
  50. package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
  51. package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +4 -2
  52. package/features/contentEntry/CreateEntry/CreateEntryRepository.js +8 -3
  53. package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
  54. package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +2 -2
  55. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +3 -4
  56. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
  57. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +4 -2
  58. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +8 -3
  59. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
  60. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +2 -4
  61. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +6 -14
  62. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
  63. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.d.ts +2 -0
  64. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.js.map +1 -1
  65. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +4 -2
  66. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +8 -3
  67. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
  68. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +2 -2
  69. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +2 -2
  70. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
  71. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +3 -1
  72. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +7 -3
  73. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
  74. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +2 -2
  75. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +2 -2
  76. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
  77. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +3 -1
  78. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +9 -3
  79. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
  80. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +2 -2
  81. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +2 -2
  82. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
  83. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +4 -2
  84. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +7 -3
  85. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
  86. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +2 -2
  87. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +11 -10
  88. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
  89. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.d.ts +17 -0
  90. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js +83 -0
  91. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  92. package/features/contentEntry/DuplicateEntry/abstractions.d.ts +47 -0
  93. package/features/contentEntry/DuplicateEntry/abstractions.js +5 -0
  94. package/features/contentEntry/DuplicateEntry/abstractions.js.map +1 -0
  95. package/features/contentEntry/DuplicateEntry/events.d.ts +41 -0
  96. package/features/contentEntry/DuplicateEntry/events.js +32 -0
  97. package/features/contentEntry/DuplicateEntry/events.js.map +1 -0
  98. package/features/contentEntry/DuplicateEntry/feature.d.ts +4 -0
  99. package/features/contentEntry/DuplicateEntry/feature.js +11 -0
  100. package/features/contentEntry/DuplicateEntry/feature.js.map +1 -0
  101. package/features/contentEntry/DuplicateEntry/index.d.ts +2 -0
  102. package/features/contentEntry/DuplicateEntry/index.js +2 -0
  103. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.d.ts +7 -0
  104. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js +12 -0
  105. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js.map +1 -0
  106. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.d.ts +10 -0
  107. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js +25 -0
  108. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js.map +1 -0
  109. package/features/contentEntry/EntryEventPublisher/abstractions.d.ts +16 -0
  110. package/features/contentEntry/EntryEventPublisher/abstractions.js +5 -0
  111. package/features/contentEntry/EntryEventPublisher/abstractions.js.map +1 -0
  112. package/features/contentEntry/EntryEventPublisher/feature.d.ts +4 -0
  113. package/features/contentEntry/EntryEventPublisher/feature.js +11 -0
  114. package/features/contentEntry/EntryEventPublisher/feature.js.map +1 -0
  115. package/features/contentEntry/EntryEventPublisher/index.d.ts +2 -0
  116. package/features/contentEntry/EntryEventPublisher/index.js +2 -0
  117. package/features/contentEntry/EntrySystemField/abstractions.d.ts +14 -0
  118. package/features/contentEntry/EntrySystemField/abstractions.js +5 -0
  119. package/features/contentEntry/EntrySystemField/abstractions.js.map +1 -0
  120. package/features/contentEntry/EntrySystemField/index.d.ts +1 -0
  121. package/features/contentEntry/EntrySystemField/index.js +1 -0
  122. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +4 -4
  123. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +8 -11
  124. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
  125. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +4 -2
  126. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +7 -3
  127. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
  128. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +4 -2
  129. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +7 -3
  130. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
  131. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +4 -2
  132. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -3
  133. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
  134. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +4 -2
  135. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +7 -3
  136. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
  137. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +4 -2
  138. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +7 -3
  139. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
  140. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +4 -2
  141. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -3
  142. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
  143. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +4 -2
  144. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +7 -3
  145. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
  146. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +4 -2
  147. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -3
  148. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
  149. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +3 -0
  150. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
  151. package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +4 -2
  152. package/features/contentEntry/ListEntries/ListEntriesRepository.js +7 -3
  153. package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
  154. package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +4 -2
  155. package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -3
  156. package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
  157. package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +2 -2
  158. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +11 -4
  159. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
  160. package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +4 -2
  161. package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -3
  162. package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
  163. package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +4 -6
  164. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +11 -13
  165. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
  166. package/features/contentEntry/PublishEntry/abstractions.d.ts +8 -1
  167. package/features/contentEntry/PublishEntry/abstractions.js.map +1 -1
  168. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +4 -2
  169. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +8 -3
  170. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
  171. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +2 -2
  172. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +5 -3
  173. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
  174. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +4 -2
  175. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +8 -3
  176. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
  177. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +2 -2
  178. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +2 -2
  179. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
  180. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +4 -2
  181. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +8 -3
  182. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
  183. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +2 -2
  184. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +5 -3
  185. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
  186. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +4 -2
  187. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +8 -3
  188. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
  189. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +2 -2
  190. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +5 -3
  191. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
  192. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.d.ts +19 -0
  193. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js +70 -0
  194. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js.map +1 -0
  195. package/features/contentEntry/UpdateEntrySystem/abstractions.d.ts +24 -0
  196. package/features/contentEntry/UpdateEntrySystem/abstractions.js +5 -0
  197. package/features/contentEntry/UpdateEntrySystem/abstractions.js.map +1 -0
  198. package/features/contentEntry/UpdateEntrySystem/events.d.ts +29 -0
  199. package/features/contentEntry/UpdateEntrySystem/events.js +23 -0
  200. package/features/contentEntry/UpdateEntrySystem/events.js.map +1 -0
  201. package/features/contentEntry/UpdateEntrySystem/feature.d.ts +4 -0
  202. package/features/contentEntry/UpdateEntrySystem/feature.js +11 -0
  203. package/features/contentEntry/UpdateEntrySystem/feature.js.map +1 -0
  204. package/features/contentEntry/UpdateEntrySystem/index.d.ts +2 -0
  205. package/features/contentEntry/UpdateEntrySystem/index.js +2 -0
  206. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +2 -2
  207. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -2
  208. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
  209. package/features/contentEntry/ensureItemIds.d.ts +13 -0
  210. package/features/contentEntry/ensureItemIds.js +22 -0
  211. package/features/contentEntry/ensureItemIds.js.map +1 -0
  212. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
  213. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +8 -2
  214. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
  215. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +7 -3
  216. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +46 -13
  217. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
  218. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.d.ts +17 -1
  219. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.js.map +1 -1
  220. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +5 -3
  221. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +22 -15
  222. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
  223. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.d.ts +15 -1
  224. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.js.map +1 -1
  225. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +5 -3
  226. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +17 -12
  227. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
  228. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.d.ts +13 -1
  229. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.js.map +1 -1
  230. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +6 -6
  231. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +17 -17
  232. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
  233. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts +14 -2
  234. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map +1 -1
  235. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +7 -3
  236. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +72 -28
  237. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
  238. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.d.ts +15 -1
  239. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js.map +1 -1
  240. package/features/contentEntry/entryDataFactories/expiresAt.js +2 -2
  241. package/features/contentEntry/entryDataFactories/expiresAt.js.map +1 -1
  242. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.d.ts +24 -0
  243. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js +13 -0
  244. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js.map +1 -0
  245. package/features/contentModel/CreateModel/CreateModelRepository.js +1 -2
  246. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  247. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +1 -2
  248. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  249. package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +4 -2
  250. package/features/contentModel/DeleteModel/DeleteModelRepository.js +7 -3
  251. package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
  252. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +9 -4
  253. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +36 -21
  254. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
  255. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.d.ts +1 -1
  256. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.js.map +1 -1
  257. package/features/contentModel/ModelToAstConverter/abstractions.d.ts +1 -1
  258. package/features/contentModel/ModelToAstConverter/abstractions.js.map +1 -1
  259. package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +4 -2
  260. package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -4
  261. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  262. package/features/contentModel/UpdateModel/UpdateModelUseCase.js +2 -2
  263. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  264. package/features/contentModel/UpdateModel/abstractions.d.ts +1 -1
  265. package/features/contentModel/UpdateModel/abstractions.js.map +1 -1
  266. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +4 -3
  267. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -1
  268. package/features/contentModel/shared/ModelsFetcher.d.ts +6 -5
  269. package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
  270. package/features/contentModel/shared/PluginModelsProvider.d.ts +6 -3
  271. package/features/contentModel/shared/PluginModelsProvider.js +2 -9
  272. package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
  273. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +4 -2
  274. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +7 -3
  275. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
  276. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +4 -2
  277. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +8 -4
  278. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
  279. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -2
  280. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
  281. package/features/contentModelGroup/UpdateGroup/abstractions.d.ts +1 -1
  282. package/features/contentModelGroup/UpdateGroup/abstractions.js.map +1 -1
  283. package/features/graphql/fields/base/AssetToGraphQL.js +7 -2
  284. package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -1
  285. package/features/graphql/fields/base/DynamicZoneToGraphQL.js +7 -1
  286. package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
  287. package/features/graphql/fields/base/ObjectToGraphQL.js +6 -3
  288. package/features/graphql/fields/base/ObjectToGraphQL.js.map +1 -1
  289. package/features/graphql/fields/base/RefToGraphQL.js +24 -10
  290. package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
  291. package/features/modelBuilder/abstractions.d.ts +5 -2
  292. package/features/modelBuilder/abstractions.js.map +1 -1
  293. package/features/modelBuilder/feature.js +1 -8
  294. package/features/modelBuilder/feature.js.map +1 -1
  295. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +17 -0
  296. package/features/modelBuilder/fields/DataFieldBuilder.js +6 -0
  297. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
  298. package/features/modelBuilder/fields/DateTimeFieldType.js +27 -12
  299. package/features/modelBuilder/fields/DateTimeFieldType.js.map +1 -1
  300. package/features/modelBuilder/fields/fieldTypeValidator.d.ts +5 -3
  301. package/features/modelBuilder/models/ModelBuilder.d.ts +8 -0
  302. package/features/modelBuilder/models/ModelBuilder.js +1 -0
  303. package/features/modelBuilder/models/ModelBuilder.js.map +1 -1
  304. package/features/modelBuilder/models/ModelsProvider.d.ts +1 -3
  305. package/features/modelBuilder/models/ModelsProvider.js +2 -7
  306. package/features/modelBuilder/models/ModelsProvider.js.map +1 -1
  307. package/features/modelBuilder/models/PrivateModelBuilder.d.ts +5 -0
  308. package/features/modelBuilder/models/PrivateModelBuilder.js +12 -1
  309. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  310. package/features/modelStorageSync/ModelStorageSyncTask.d.ts +31 -0
  311. package/features/modelStorageSync/ModelStorageSyncTask.js +66 -0
  312. package/features/modelStorageSync/ModelStorageSyncTask.js.map +1 -0
  313. package/features/modelStorageSync/SyncStorageOnModelUpdate.d.ts +23 -0
  314. package/features/modelStorageSync/SyncStorageOnModelUpdate.js +55 -0
  315. package/features/modelStorageSync/SyncStorageOnModelUpdate.js.map +1 -0
  316. package/features/modelStorageSync/abstractions.d.ts +34 -0
  317. package/features/modelStorageSync/abstractions.js +6 -0
  318. package/features/modelStorageSync/abstractions.js.map +1 -0
  319. package/features/modelStorageSync/feature.d.ts +8 -0
  320. package/features/modelStorageSync/feature.js +13 -0
  321. package/features/modelStorageSync/feature.js.map +1 -0
  322. package/features/modelStorageSync/index.d.ts +2 -0
  323. package/features/modelStorageSync/index.js +2 -0
  324. package/features/runtimeTenant/RuntimeTenant.d.ts +13 -0
  325. package/features/runtimeTenant/RuntimeTenant.js +22 -0
  326. package/features/runtimeTenant/RuntimeTenant.js.map +1 -0
  327. package/features/runtimeTenant/abstractions.d.ts +11 -0
  328. package/features/runtimeTenant/abstractions.js +5 -0
  329. package/features/runtimeTenant/abstractions.js.map +1 -0
  330. package/features/runtimeTenant/index.d.ts +2 -0
  331. package/features/runtimeTenant/index.js +2 -0
  332. package/features/shared/abstractions.d.ts +1 -5
  333. package/features/shared/abstractions.js +1 -2
  334. package/features/shared/abstractions.js.map +1 -1
  335. package/features/storage/fields/CompressedTextStorageTransform.js +1 -1
  336. package/features/storage/fields/CompressedTextStorageTransform.js.map +1 -1
  337. package/features/storage/fields/DateStorageTransform.js +3 -4
  338. package/features/storage/fields/DateStorageTransform.js.map +1 -1
  339. package/features/storage/fields/DynamicZoneStorageTransform.js +2 -2
  340. package/features/storage/fields/DynamicZoneStorageTransform.js.map +1 -1
  341. package/features/storage/fields/JsonStorageTransform.js +1 -1
  342. package/features/storage/fields/JsonStorageTransform.js.map +1 -1
  343. package/features/storage/fields/LongTextStorageTransform.js +1 -1
  344. package/features/storage/fields/LongTextStorageTransform.js.map +1 -1
  345. package/features/storage/fields/ObjectStorageTransform.js +27 -7
  346. package/features/storage/fields/ObjectStorageTransform.js.map +1 -1
  347. package/features/storage/fields/RichTextStorageTransform.js +1 -1
  348. package/features/storage/fields/RichTextStorageTransform.js.map +1 -1
  349. package/features/validation/abstractions/CmsModelFieldValidator.d.ts +5 -0
  350. package/features/validation/abstractions/CmsModelFieldValidator.js.map +1 -1
  351. package/features/validation/validators/DateGteValidator.d.ts +2 -0
  352. package/features/validation/validators/DateGteValidator.js +12 -2
  353. package/features/validation/validators/DateGteValidator.js.map +1 -1
  354. package/features/validation/validators/DateLteValidator.d.ts +2 -0
  355. package/features/validation/validators/DateLteValidator.js +12 -2
  356. package/features/validation/validators/DateLteValidator.js.map +1 -1
  357. package/features/validation/validators/PatternValidator.js +1 -1
  358. package/features/validation/validators/PatternValidator.js.map +1 -1
  359. package/features/validation/validators/dateLimit.d.ts +9 -0
  360. package/features/validation/validators/dateLimit.js +18 -0
  361. package/features/validation/validators/dateLimit.js.map +1 -0
  362. package/features/whereMapper/WhereMapper.js +3 -5
  363. package/features/whereMapper/WhereMapper.js.map +1 -1
  364. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +15 -5
  365. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  366. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +8 -2
  367. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  368. package/graphql/checkEndpointAccess.d.ts +7 -2
  369. package/graphql/checkEndpointAccess.js +2 -4
  370. package/graphql/checkEndpointAccess.js.map +1 -1
  371. package/graphql/getSchema/generateCacheKey.js +1 -1
  372. package/graphql/getSchema/generateCacheKey.js.map +1 -1
  373. package/graphql/scalars/RevisionId.js +1 -1
  374. package/graphql/scalars/RevisionId.js.map +1 -1
  375. package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +1 -0
  376. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +4 -0
  377. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -1
  378. package/graphql/schema/cms/resolvers/createEntry.d.ts +1 -0
  379. package/graphql/schema/cms/resolvers/createEntry.js +4 -0
  380. package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
  381. package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +1 -0
  382. package/graphql/schema/cms/resolvers/deleteEntryRevision.js +4 -0
  383. package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
  384. package/graphql/schema/cms/resolvers/getEntry.d.ts +1 -0
  385. package/graphql/schema/cms/resolvers/getEntry.js +4 -0
  386. package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
  387. package/graphql/schema/cms/resolvers/getModel.d.ts +1 -0
  388. package/graphql/schema/cms/resolvers/getModel.js +4 -0
  389. package/graphql/schema/cms/resolvers/getModel.js.map +1 -1
  390. package/graphql/schema/cms/resolvers/listEntries.d.ts +1 -0
  391. package/graphql/schema/cms/resolvers/listEntries.js +4 -0
  392. package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
  393. package/graphql/schema/cms/resolvers/mutationCms.d.ts +1 -0
  394. package/graphql/schema/cms/resolvers/mutationCms.js +4 -0
  395. package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
  396. package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +1 -0
  397. package/graphql/schema/cms/resolvers/publishEntryRevision.js +4 -0
  398. package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
  399. package/graphql/schema/cms/resolvers/queryCms.d.ts +1 -0
  400. package/graphql/schema/cms/resolvers/queryCms.js +4 -0
  401. package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
  402. package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +1 -0
  403. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +4 -0
  404. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
  405. package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +1 -0
  406. package/graphql/schema/cms/resolvers/updateEntryRevision.js +4 -0
  407. package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
  408. package/graphql/schema/cms/typeDefs/mutation.d.ts +1 -0
  409. package/graphql/schema/cms/typeDefs/mutation.js +4 -0
  410. package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
  411. package/graphql/schema/cms/typeDefs/query.d.ts +1 -0
  412. package/graphql/schema/cms/typeDefs/query.js +4 -0
  413. package/graphql/schema/cms/typeDefs/query.js.map +1 -1
  414. package/graphql/schema/cms/typeDefs/responses.d.ts +1 -0
  415. package/graphql/schema/cms/typeDefs/responses.js +4 -0
  416. package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
  417. package/graphql/schema/contentEntries.js +19 -4
  418. package/graphql/schema/contentEntries.js.map +1 -1
  419. package/graphql/schema/contentModels.js +2 -0
  420. package/graphql/schema/contentModels.js.map +1 -1
  421. package/graphql/schema/createFieldResolvers.js +1 -1
  422. package/graphql/schema/createFieldResolvers.js.map +1 -1
  423. package/graphql/schema/createManageResolvers.js +3 -1
  424. package/graphql/schema/createManageResolvers.js.map +1 -1
  425. package/graphql/schema/createManageSDL.js +2 -0
  426. package/graphql/schema/createManageSDL.js.map +1 -1
  427. package/graphql/schema/resolvers/manage/resolveDuplicate.d.ts +7 -0
  428. package/graphql/schema/resolvers/manage/resolveDuplicate.js +11 -0
  429. package/graphql/schema/resolvers/manage/resolveDuplicate.js.map +1 -0
  430. package/package.json +24 -24
  431. package/plugins/CmsModelPlugin.js +9 -10
  432. package/plugins/CmsModelPlugin.js.map +1 -1
  433. package/types/index.d.ts +0 -1
  434. package/types/modelField.d.ts +11 -0
  435. package/types/types.d.ts +14 -109
  436. package/types/types.js.map +1 -1
  437. package/utils/caching/Cache.js +1 -1
  438. package/utils/caching/Cache.js.map +1 -1
  439. package/utils/createModelField.js +2 -1
  440. package/utils/createModelField.js.map +1 -1
  441. package/utils/createModelSchemaKey.d.ts +8 -0
  442. package/utils/createModelSchemaKey.js +18 -0
  443. package/utils/createModelSchemaKey.js.map +1 -0
  444. package/utils/date.js +1 -1
  445. package/utils/date.js.map +1 -1
  446. package/utils/entryStorage.js +1 -1
  447. package/utils/entryStorage.js.map +1 -1
  448. package/utils/renderFields.js +1 -1
  449. package/utils/renderFields.js.map +1 -1
  450. package/HeadlessCmsContextualSchema.d.ts +0 -16
  451. package/HeadlessCmsContextualSchema.js +0 -32
  452. package/HeadlessCmsContextualSchema.js.map +0 -1
  453. package/crud/contentEntry.crud.d.ts +0 -6
  454. package/crud/contentEntry.crud.js +0 -336
  455. package/crud/contentEntry.crud.js.map +0 -1
  456. package/crud/contentModel.crud.d.ts +0 -5
  457. package/crud/contentModel.crud.js +0 -79
  458. package/crud/contentModel.crud.js.map +0 -1
  459. package/crud/contentModelGroup.crud.d.ts +0 -5
  460. package/crud/contentModelGroup.crud.js +0 -76
  461. package/crud/contentModelGroup.crud.js.map +0 -1
  462. package/types/context.d.ts +0 -110
  463. package/types/context.js +0 -0
@@ -5,6 +5,7 @@ import { PluginGroupsProvider } from "../../../features/contentModelGroup/shared
5
5
  import { DeleteGroupStorageOperation } from "../../../features/shared/storageOperations/group/DeleteGroupStorageOperation.js";
6
6
  import { ListModelsStorageOperation } from "../../../features/shared/storageOperations/model/ListModelsStorageOperation.js";
7
7
  import type { CmsGroup } from "../../../types/index.js";
8
+ import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
8
9
  /**
9
10
  * DeleteGroupRepository - Validates and performs group deletion.
10
11
  *
@@ -19,8 +20,9 @@ declare class DeleteGroupRepositoryImpl implements RepositoryAbstraction.Interfa
19
20
  private pluginGroupsProvider;
20
21
  private deleteGroup;
21
22
  private listModels;
22
- constructor(groupCache: GroupCache.Interface, pluginGroupsProvider: PluginGroupsProvider.Interface, deleteGroup: DeleteGroupStorageOperation.Interface, listModels: ListModelsStorageOperation.Interface);
23
- execute(group: CmsGroup): Promise<Result<void, RepositoryAbstraction.Error>>;
23
+ private runtimeTenant;
24
+ constructor(groupCache: GroupCache.Interface, pluginGroupsProvider: PluginGroupsProvider.Interface, deleteGroup: DeleteGroupStorageOperation.Interface, listModels: ListModelsStorageOperation.Interface, runtimeTenant: RuntimeTenant.Interface);
25
+ execute(initialGroup: CmsGroup): Promise<Result<void, RepositoryAbstraction.Error>>;
24
26
  }
25
27
  export declare const DeleteGroupRepository: typeof DeleteGroupRepositoryImpl & {
26
28
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IDeleteGroupRepository>;
@@ -4,14 +4,17 @@ import { GroupCache, PluginGroupsProvider } from "../shared/abstractions.js";
4
4
  import { GroupCannotDeleteCodeDefinedError, GroupHasModelsError, GroupPersistenceError } from "../../../domain/contentModelGroup/errors.js";
5
5
  import { DeleteGroupStorageOperation } from "../../shared/storageOperations/group/DeleteGroupStorageOperation.js";
6
6
  import { ListModelsStorageOperation } from "../../shared/storageOperations/model/ListModelsStorageOperation.js";
7
+ import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
7
8
  class DeleteGroupRepositoryImpl {
8
- constructor(groupCache, pluginGroupsProvider, deleteGroup, listModels){
9
+ constructor(groupCache, pluginGroupsProvider, deleteGroup, listModels, runtimeTenant){
9
10
  this.groupCache = groupCache;
10
11
  this.pluginGroupsProvider = pluginGroupsProvider;
11
12
  this.deleteGroup = deleteGroup;
12
13
  this.listModels = listModels;
14
+ this.runtimeTenant = runtimeTenant;
13
15
  }
14
- async execute(group) {
16
+ async execute(initialGroup) {
17
+ const group = this.runtimeTenant.assign(initialGroup);
15
18
  try {
16
19
  const pluginGroups = await this.pluginGroupsProvider.getGroups();
17
20
  const isPluginGroup = pluginGroups.some((pg)=>pg.slug === group.slug);
@@ -39,7 +42,8 @@ const DeleteGroupRepository_DeleteGroupRepository = DeleteGroupRepository.create
39
42
  GroupCache,
40
43
  PluginGroupsProvider,
41
44
  DeleteGroupStorageOperation,
42
- ListModelsStorageOperation
45
+ ListModelsStorageOperation,
46
+ RuntimeTenant
43
47
  ]
44
48
  });
45
49
  export { DeleteGroupRepository_DeleteGroupRepository as DeleteGroupRepository };
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js","sources":["../../../../src/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteGroupRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { GroupCache } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { GroupCannotDeleteCodeDefinedError } from \"~/domain/contentModelGroup/errors.js\";\nimport { GroupHasModelsError } from \"~/domain/contentModelGroup/errors.js\";\nimport { GroupPersistenceError } from \"~/domain/contentModelGroup/errors.js\";\nimport { DeleteGroupStorageOperation } from \"~/features/shared/storageOperations/group/DeleteGroupStorageOperation.js\";\nimport { ListModelsStorageOperation } from \"~/features/shared/storageOperations/model/ListModelsStorageOperation.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\n\n/**\n * DeleteGroupRepository - Validates and performs group deletion.\n *\n * Responsibilities:\n * - Check if group is plugin-based (cannot delete)\n * - Check if models reference this group (cannot delete)\n * - Persist deletion to storage\n * - Clear GroupCache after successful deletion\n */\nclass DeleteGroupRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private groupCache: GroupCache.Interface,\n private pluginGroupsProvider: PluginGroupsProvider.Interface,\n private deleteGroup: DeleteGroupStorageOperation.Interface,\n private listModels: ListModelsStorageOperation.Interface\n ) {}\n\n async execute(group: CmsGroup): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Check if this is a plugin-based group (cannot be deleted)\n const pluginGroups = await this.pluginGroupsProvider.getGroups();\n const isPluginGroup = pluginGroups.some(pg => pg.slug === group.slug);\n\n if (isPluginGroup) {\n return Result.fail(new GroupCannotDeleteCodeDefinedError(group.id));\n }\n\n // Check if any models reference this group\n const models = await this.listModels.execute({\n where: {\n tenant: group.tenant\n }\n });\n\n const items = models.filter(model => model.group === group.slug);\n if (items.length > 0) {\n return Result.fail(new GroupHasModelsError());\n }\n\n // Perform deletion\n await this.deleteGroup.execute({ group });\n\n // Clear cache\n this.groupCache.clear();\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new GroupPersistenceError(error as Error));\n }\n }\n}\n\nexport const DeleteGroupRepository = RepositoryAbstraction.createImplementation({\n implementation: DeleteGroupRepositoryImpl,\n dependencies: [\n GroupCache,\n PluginGroupsProvider,\n DeleteGroupStorageOperation,\n ListModelsStorageOperation\n ]\n});\n"],"names":["DeleteGroupRepositoryImpl","groupCache","pluginGroupsProvider","deleteGroup","listModels","group","pluginGroups","isPluginGroup","pg","Result","GroupCannotDeleteCodeDefinedError","models","items","model","GroupHasModelsError","error","GroupPersistenceError","DeleteGroupRepository","RepositoryAbstraction","GroupCache","PluginGroupsProvider","DeleteGroupStorageOperation","ListModelsStorageOperation"],"mappings":";;;;;;AAoBA,MAAMA;IACF,YACYC,UAAgC,EAChCC,oBAAoD,EACpDC,WAAkD,EAClDC,UAAgD,CAC1D;aAJUH,UAAU,GAAVA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAe,EAAsD;QAC/E,IAAI;YAEA,MAAMC,eAAe,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS;YAC9D,MAAMC,gBAAgBD,aAAa,IAAI,CAACE,CAAAA,KAAMA,GAAG,IAAI,KAAKH,MAAM,IAAI;YAEpE,IAAIE,eACA,OAAOE,OAAO,IAAI,CAAC,IAAIC,kCAAkCL,MAAM,EAAE;YAIrE,MAAMM,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBACzC,OAAO;oBACH,QAAQN,MAAM,MAAM;gBACxB;YACJ;YAEA,MAAMO,QAAQD,OAAO,MAAM,CAACE,CAAAA,QAASA,MAAM,KAAK,KAAKR,MAAM,IAAI;YAC/D,IAAIO,MAAM,MAAM,GAAG,GACf,OAAOH,OAAO,IAAI,CAAC,IAAIK;YAI3B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAAET;YAAM;YAGvC,IAAI,CAAC,UAAU,CAAC,KAAK;YAErB,OAAOI,OAAO,EAAE;QACpB,EAAE,OAAOM,OAAO;YACZ,OAAON,OAAO,IAAI,CAAC,IAAIO,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js","sources":["../../../../src/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteGroupRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { GroupCache } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { GroupCannotDeleteCodeDefinedError } from \"~/domain/contentModelGroup/errors.js\";\nimport { GroupHasModelsError } from \"~/domain/contentModelGroup/errors.js\";\nimport { GroupPersistenceError } from \"~/domain/contentModelGroup/errors.js\";\nimport { DeleteGroupStorageOperation } from \"~/features/shared/storageOperations/group/DeleteGroupStorageOperation.js\";\nimport { ListModelsStorageOperation } from \"~/features/shared/storageOperations/model/ListModelsStorageOperation.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * DeleteGroupRepository - Validates and performs group deletion.\n *\n * Responsibilities:\n * - Check if group is plugin-based (cannot delete)\n * - Check if models reference this group (cannot delete)\n * - Persist deletion to storage\n * - Clear GroupCache after successful deletion\n */\nclass DeleteGroupRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private groupCache: GroupCache.Interface,\n private pluginGroupsProvider: PluginGroupsProvider.Interface,\n private deleteGroup: DeleteGroupStorageOperation.Interface,\n private listModels: ListModelsStorageOperation.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute(initialGroup: CmsGroup): Promise<Result<void, RepositoryAbstraction.Error>> {\n const group = this.runtimeTenant.assign(initialGroup);\n\n try {\n // Check if this is a plugin-based group (cannot be deleted)\n const pluginGroups = await this.pluginGroupsProvider.getGroups();\n const isPluginGroup = pluginGroups.some(pg => pg.slug === group.slug);\n\n if (isPluginGroup) {\n return Result.fail(new GroupCannotDeleteCodeDefinedError(group.id));\n }\n\n // Check if any models reference this group\n const models = await this.listModels.execute({\n where: {\n tenant: group.tenant\n }\n });\n\n const items = models.filter(model => model.group === group.slug);\n if (items.length > 0) {\n return Result.fail(new GroupHasModelsError());\n }\n\n // Perform deletion\n await this.deleteGroup.execute({ group });\n\n // Clear cache\n this.groupCache.clear();\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new GroupPersistenceError(error as Error));\n }\n }\n}\n\nexport const DeleteGroupRepository = RepositoryAbstraction.createImplementation({\n implementation: DeleteGroupRepositoryImpl,\n dependencies: [\n GroupCache,\n PluginGroupsProvider,\n DeleteGroupStorageOperation,\n ListModelsStorageOperation,\n RuntimeTenant\n ]\n});\n"],"names":["DeleteGroupRepositoryImpl","groupCache","pluginGroupsProvider","deleteGroup","listModels","runtimeTenant","initialGroup","group","pluginGroups","isPluginGroup","pg","Result","GroupCannotDeleteCodeDefinedError","models","items","model","GroupHasModelsError","error","GroupPersistenceError","DeleteGroupRepository","RepositoryAbstraction","GroupCache","PluginGroupsProvider","DeleteGroupStorageOperation","ListModelsStorageOperation","RuntimeTenant"],"mappings":";;;;;;;AAqBA,MAAMA;IACF,YACYC,UAAgC,EAChCC,oBAAoD,EACpDC,WAAkD,EAClDC,UAAgD,EAChDC,aAAsC,CAChD;aALUJ,UAAU,GAAVA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;aACAC,UAAU,GAAVA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAAsD;QACtF,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACD;QAExC,IAAI;YAEA,MAAME,eAAe,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS;YAC9D,MAAMC,gBAAgBD,aAAa,IAAI,CAACE,CAAAA,KAAMA,GAAG,IAAI,KAAKH,MAAM,IAAI;YAEpE,IAAIE,eACA,OAAOE,OAAO,IAAI,CAAC,IAAIC,kCAAkCL,MAAM,EAAE;YAIrE,MAAMM,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBACzC,OAAO;oBACH,QAAQN,MAAM,MAAM;gBACxB;YACJ;YAEA,MAAMO,QAAQD,OAAO,MAAM,CAACE,CAAAA,QAASA,MAAM,KAAK,KAAKR,MAAM,IAAI;YAC/D,IAAIO,MAAM,MAAM,GAAG,GACf,OAAOH,OAAO,IAAI,CAAC,IAAIK;YAI3B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAAET;YAAM;YAGvC,IAAI,CAAC,UAAU,CAAC,KAAK;YAErB,OAAOI,OAAO,EAAE;QACpB,EAAE,OAAOM,OAAO;YACZ,OAAON,OAAO,IAAI,CAAC,IAAIO,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBpB;IAChB,cAAc;QACVqB;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -4,6 +4,7 @@ import { GroupCache } from "../../../features/contentModelGroup/shared/abstracti
4
4
  import { PluginGroupsProvider } from "../../../features/contentModelGroup/shared/abstractions.js";
5
5
  import { UpdateGroupStorageOperation } from "../../../features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
6
6
  import type { CmsGroup } from "../../../types/index.js";
7
+ import { RuntimeTenant } from "../../../features/runtimeTenant/abstractions.js";
7
8
  /**
8
9
  * UpdateGroupRepository - Validates and persists group updates.
9
10
  *
@@ -16,8 +17,9 @@ declare class UpdateGroupRepositoryImpl implements RepositoryAbstraction.Interfa
16
17
  private groupCache;
17
18
  private pluginGroupsProvider;
18
19
  private updateGroup;
19
- constructor(groupCache: GroupCache.Interface, pluginGroupsProvider: PluginGroupsProvider.Interface, updateGroup: UpdateGroupStorageOperation.Interface);
20
- execute(group: CmsGroup): Promise<Result<void, RepositoryAbstraction.Error>>;
20
+ private runtimeTenant;
21
+ constructor(groupCache: GroupCache.Interface, pluginGroupsProvider: PluginGroupsProvider.Interface, updateGroup: UpdateGroupStorageOperation.Interface, runtimeTenant: RuntimeTenant.Interface);
22
+ execute(initialGroup: CmsGroup): Promise<Result<CmsGroup, RepositoryAbstraction.Error>>;
21
23
  }
22
24
  export declare const UpdateGroupRepository: typeof UpdateGroupRepositoryImpl & {
23
25
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUpdateGroupRepository>;
@@ -3,13 +3,16 @@ import { UpdateGroupRepository } from "./abstractions.js";
3
3
  import { GroupCache, PluginGroupsProvider } from "../shared/abstractions.js";
4
4
  import { GroupCannotUpdateCodeDefinedError, GroupPersistenceError } from "../../../domain/contentModelGroup/errors.js";
5
5
  import { UpdateGroupStorageOperation } from "../../shared/storageOperations/group/UpdateGroupStorageOperation.js";
6
+ import { RuntimeTenant } from "../../runtimeTenant/abstractions.js";
6
7
  class UpdateGroupRepositoryImpl {
7
- constructor(groupCache, pluginGroupsProvider, updateGroup){
8
+ constructor(groupCache, pluginGroupsProvider, updateGroup, runtimeTenant){
8
9
  this.groupCache = groupCache;
9
10
  this.pluginGroupsProvider = pluginGroupsProvider;
10
11
  this.updateGroup = updateGroup;
12
+ this.runtimeTenant = runtimeTenant;
11
13
  }
12
- async execute(group) {
14
+ async execute(initialGroup) {
15
+ const group = this.runtimeTenant.assign(initialGroup);
13
16
  try {
14
17
  const pluginGroups = await this.pluginGroupsProvider.getGroups();
15
18
  const isPluginGroup = pluginGroups.some((pg)=>pg.slug === group.slug);
@@ -18,7 +21,7 @@ class UpdateGroupRepositoryImpl {
18
21
  group
19
22
  });
20
23
  this.groupCache.clear();
21
- return Result.ok();
24
+ return Result.ok(group);
22
25
  } catch (error) {
23
26
  return Result.fail(new GroupPersistenceError(error));
24
27
  }
@@ -29,7 +32,8 @@ const UpdateGroupRepository_UpdateGroupRepository = UpdateGroupRepository.create
29
32
  dependencies: [
30
33
  GroupCache,
31
34
  PluginGroupsProvider,
32
- UpdateGroupStorageOperation
35
+ UpdateGroupStorageOperation,
36
+ RuntimeTenant
33
37
  ]
34
38
  });
35
39
  export { UpdateGroupRepository_UpdateGroupRepository as UpdateGroupRepository };
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js","sources":["../../../../src/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateGroupRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { GroupCache } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { GroupCannotUpdateCodeDefinedError } from \"~/domain/contentModelGroup/errors.js\";\nimport { GroupPersistenceError } from \"~/domain/contentModelGroup/errors.js\";\nimport { UpdateGroupStorageOperation } from \"~/features/shared/storageOperations/group/UpdateGroupStorageOperation.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\n\n/**\n * UpdateGroupRepository - Validates and persists group updates.\n *\n * Responsibilities:\n * - Check if group is plugin-based (cannot update)\n * - Persist updates to storage\n * - Clear GroupCache after successful update\n */\nclass UpdateGroupRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private groupCache: GroupCache.Interface,\n private pluginGroupsProvider: PluginGroupsProvider.Interface,\n private updateGroup: UpdateGroupStorageOperation.Interface\n ) {}\n\n async execute(group: CmsGroup): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n // Check if this is a plugin-based group (cannot be updated)\n const pluginGroups = await this.pluginGroupsProvider.getGroups();\n const isPluginGroup = pluginGroups.some(pg => pg.slug === group.slug);\n\n if (isPluginGroup) {\n return Result.fail(new GroupCannotUpdateCodeDefinedError(group.id));\n }\n\n // Persist updates\n await this.updateGroup.execute({ group });\n\n // Clear cache\n this.groupCache.clear();\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new GroupPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateGroupRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateGroupRepositoryImpl,\n dependencies: [GroupCache, PluginGroupsProvider, UpdateGroupStorageOperation]\n});\n"],"names":["UpdateGroupRepositoryImpl","groupCache","pluginGroupsProvider","updateGroup","group","pluginGroups","isPluginGroup","pg","Result","GroupCannotUpdateCodeDefinedError","error","GroupPersistenceError","UpdateGroupRepository","RepositoryAbstraction","GroupCache","PluginGroupsProvider","UpdateGroupStorageOperation"],"mappings":";;;;;AAiBA,MAAMA;IACF,YACYC,UAAgC,EAChCC,oBAAoD,EACpDC,WAAkD,CAC5D;aAHUF,UAAU,GAAVA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QAAQC,KAAe,EAAsD;QAC/E,IAAI;YAEA,MAAMC,eAAe,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS;YAC9D,MAAMC,gBAAgBD,aAAa,IAAI,CAACE,CAAAA,KAAMA,GAAG,IAAI,KAAKH,MAAM,IAAI;YAEpE,IAAIE,eACA,OAAOE,OAAO,IAAI,CAAC,IAAIC,kCAAkCL,MAAM,EAAE;YAIrE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAAEA;YAAM;YAGvC,IAAI,CAAC,UAAU,CAAC,KAAK;YAErB,OAAOI,OAAO,EAAE;QACpB,EAAE,OAAOE,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBb;IAChB,cAAc;QAACc;QAAYC;QAAsBC;KAA4B;AACjF"}
1
+ {"version":3,"file":"features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js","sources":["../../../../src/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateGroupRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { GroupCache } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { PluginGroupsProvider } from \"~/features/contentModelGroup/shared/abstractions.js\";\nimport { GroupCannotUpdateCodeDefinedError } from \"~/domain/contentModelGroup/errors.js\";\nimport { GroupPersistenceError } from \"~/domain/contentModelGroup/errors.js\";\nimport { UpdateGroupStorageOperation } from \"~/features/shared/storageOperations/group/UpdateGroupStorageOperation.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\nimport { RuntimeTenant } from \"~/features/runtimeTenant/abstractions.js\";\n\n/**\n * UpdateGroupRepository - Validates and persists group updates.\n *\n * Responsibilities:\n * - Check if group is plugin-based (cannot update)\n * - Persist updates to storage\n * - Clear GroupCache after successful update\n */\nclass UpdateGroupRepositoryImpl implements RepositoryAbstraction.Interface {\n public constructor(\n private groupCache: GroupCache.Interface,\n private pluginGroupsProvider: PluginGroupsProvider.Interface,\n private updateGroup: UpdateGroupStorageOperation.Interface,\n private runtimeTenant: RuntimeTenant.Interface\n ) {}\n\n async execute(initialGroup: CmsGroup): Promise<Result<CmsGroup, RepositoryAbstraction.Error>> {\n const group = this.runtimeTenant.assign(initialGroup);\n\n try {\n // Check if this is a plugin-based group (cannot be updated)\n const pluginGroups = await this.pluginGroupsProvider.getGroups();\n const isPluginGroup = pluginGroups.some(pg => pg.slug === group.slug);\n\n if (isPluginGroup) {\n return Result.fail(new GroupCannotUpdateCodeDefinedError(group.id));\n }\n\n // Persist updates\n await this.updateGroup.execute({ group });\n\n // Clear cache\n this.groupCache.clear();\n\n return Result.ok(group);\n } catch (error) {\n return Result.fail(new GroupPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateGroupRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateGroupRepositoryImpl,\n dependencies: [GroupCache, PluginGroupsProvider, UpdateGroupStorageOperation, RuntimeTenant]\n});\n"],"names":["UpdateGroupRepositoryImpl","groupCache","pluginGroupsProvider","updateGroup","runtimeTenant","initialGroup","group","pluginGroups","isPluginGroup","pg","Result","GroupCannotUpdateCodeDefinedError","error","GroupPersistenceError","UpdateGroupRepository","RepositoryAbstraction","GroupCache","PluginGroupsProvider","UpdateGroupStorageOperation","RuntimeTenant"],"mappings":";;;;;;AAkBA,MAAMA;IACF,YACYC,UAAgC,EAChCC,oBAAoD,EACpDC,WAAkD,EAClDC,aAAsC,CAChD;aAJUH,UAAU,GAAVA;aACAC,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QAAQC,YAAsB,EAA0D;QAC1F,MAAMC,QAAQ,IAAI,CAAC,aAAa,CAAC,MAAM,CAACD;QAExC,IAAI;YAEA,MAAME,eAAe,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS;YAC9D,MAAMC,gBAAgBD,aAAa,IAAI,CAACE,CAAAA,KAAMA,GAAG,IAAI,KAAKH,MAAM,IAAI;YAEpE,IAAIE,eACA,OAAOE,OAAO,IAAI,CAAC,IAAIC,kCAAkCL,MAAM,EAAE;YAIrE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAAEA;YAAM;YAGvC,IAAI,CAAC,UAAU,CAAC,KAAK;YAErB,OAAOI,OAAO,EAAE,CAACJ;QACrB,EAAE,OAAOM,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,sBAAsBD;QACjD;IACJ;AACJ;AAEO,MAAME,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBf;IAChB,cAAc;QAACgB;QAAYC;QAAsBC;QAA6BC;KAAc;AAChG"}
@@ -59,9 +59,9 @@ class UpdateGroupUseCaseImpl {
59
59
  }
60
60
  await this.eventPublisher.publish(new GroupAfterUpdateEvent({
61
61
  original,
62
- group
62
+ group: result.value
63
63
  }));
64
- return Result.ok(group);
64
+ return Result.ok(result.value);
65
65
  } catch (error) {
66
66
  await this.eventPublisher.publish(new GroupUpdateErrorEvent({
67
67
  input,
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js","sources":["../../../../src/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateGroupUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { UpdateGroupRepository } from \"./abstractions.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { GroupBeforeUpdateEvent } from \"./events.js\";\nimport { GroupAfterUpdateEvent } from \"./events.js\";\nimport { GroupUpdateErrorEvent } from \"./events.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport {\n GroupNotAuthorizedError,\n GroupValidationError\n} from \"~/domain/contentModelGroup/errors.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { createGroupUpdateValidation } from \"~/domain/contentModelGroup/validation.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\nimport type { CmsGroupUpdateInput } from \"~/types/index.js\";\n\n/**\n * UpdateGroupUseCase - Orchestrates group updates.\n *\n * Responsibilities:\n * - Fetch original group\n * - Access control checks\n * - Validate input (Zod)\n * - Skip if no changes\n * - Merge changes\n * - Publish before event\n * - Delegate to repository\n * - Publish after event or error event\n */\nclass UpdateGroupUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EventPublisher.Interface,\n private repository: UpdateGroupRepository.Interface,\n private getGroupUseCase: GetGroupUseCase.Interface,\n private accessControl: AccessControl.Interface,\n private tenantContext: TenantContext.Interface\n ) {}\n\n async execute(\n groupId: string,\n input: CmsGroupUpdateInput\n ): Promise<Result<CmsGroup, UseCaseAbstraction.Error>> {\n // Initial access control check\n const canAccess = await this.accessControl.canAccessGroup({ rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(new GroupNotAuthorizedError());\n }\n\n // Fetch original group\n const getResult = await this.getGroupUseCase.execute(groupId);\n if (getResult.isFail()) {\n return Result.fail(getResult.error);\n }\n const original = getResult.value;\n\n // Access control check on original group\n const canAccessGroup = await this.accessControl.canAccessGroup({ group: original });\n if (!canAccessGroup) {\n return Result.fail(new GroupNotAuthorizedError());\n }\n\n // Validate input\n const validationResult = await createGroupUpdateValidation().safeParseAsync(input);\n if (!validationResult.success) {\n const zodError = createZodError(validationResult.error);\n return Result.fail(\n new GroupValidationError(zodError.message, zodError.data!.invalidFields)\n );\n }\n const data = validationResult.data;\n\n // Skip if no changes\n if (Object.keys(data).length === 0) {\n return Result.ok(original);\n }\n\n // Merge changes\n const tenant = this.tenantContext.getTenant();\n const group: CmsGroup = {\n ...original,\n ...data,\n tenant: tenant.id,\n savedOn: new Date().toISOString()\n };\n\n try {\n // Publish before event\n await this.eventPublisher.publish(\n new GroupBeforeUpdateEvent({\n original,\n group\n })\n );\n\n // Persist via repository\n const result = await this.repository.execute(group);\n if (result.isFail()) {\n // Publish error event\n await this.eventPublisher.publish(\n new GroupUpdateErrorEvent({\n input,\n original,\n group,\n error: result.error\n })\n );\n return Result.fail(result.error);\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new GroupAfterUpdateEvent({\n original,\n group\n })\n );\n\n return Result.ok(group);\n } catch (error) {\n // Publish error event for unexpected errors\n await this.eventPublisher.publish(\n new GroupUpdateErrorEvent({\n input,\n original,\n group,\n error: error as Error\n })\n );\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const UpdateGroupUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateGroupUseCaseImpl,\n dependencies: [\n EventPublisher,\n UpdateGroupRepository,\n GetGroupUseCase,\n AccessControl,\n TenantContext\n ]\n});\n"],"names":["UpdateGroupUseCaseImpl","eventPublisher","repository","getGroupUseCase","accessControl","tenantContext","groupId","input","canAccess","Result","GroupNotAuthorizedError","getResult","original","canAccessGroup","validationResult","createGroupUpdateValidation","zodError","createZodError","GroupValidationError","data","Object","tenant","group","Date","GroupBeforeUpdateEvent","result","GroupUpdateErrorEvent","GroupAfterUpdateEvent","error","UpdateGroupUseCase","UseCaseAbstraction","EventPublisher","UpdateGroupRepository","GetGroupUseCase","AccessControl","TenantContext"],"mappings":";;;;;;;;;;AAgCA,MAAMA;IACF,YACYC,cAAwC,EACxCC,UAA2C,EAC3CC,eAA0C,EAC1CC,aAAsC,EACtCC,aAAsC,CAChD;aALUJ,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;aACAC,aAAa,GAAbA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QACFC,OAAe,EACfC,KAA0B,EACyB;QAEnD,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAE,KAAK;QAAI;QACrE,IAAI,CAACA,WACD,OAAOC,OAAO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MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,sBAAsB;gBACtBf;gBACAU;YACJ;YAGJ,OAAOb,OAAO,EAAE,CAACa;QACrB,EAAE,OAAOM,OAAO;YAEZ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIF,sBAAsB;gBACtBnB;gBACAK;gBACAU;gBACA,OAAOM;YACX;YAEJ,OAAOnB,OAAO,IAAI,CAACmB;QACvB;IACJ;AACJ;AAEO,MAAMC,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgB9B;IAChB,cAAc;QACV+B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js","sources":["../../../../src/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateGroupUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { UpdateGroupRepository } from \"./abstractions.js\";\nimport { GetGroupUseCase } from \"~/features/contentModelGroup/GetGroup/abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport { GroupBeforeUpdateEvent } from \"./events.js\";\nimport { GroupAfterUpdateEvent } from \"./events.js\";\nimport { GroupUpdateErrorEvent } from \"./events.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport {\n GroupNotAuthorizedError,\n GroupValidationError\n} from \"~/domain/contentModelGroup/errors.js\";\nimport { createZodError } from \"@webiny/utils\";\nimport { createGroupUpdateValidation } from \"~/domain/contentModelGroup/validation.js\";\nimport type { CmsGroup } from \"~/types/index.js\";\nimport type { CmsGroupUpdateInput } from \"~/types/index.js\";\n\n/**\n * UpdateGroupUseCase - Orchestrates group updates.\n *\n * Responsibilities:\n * - Fetch original group\n * - Access control checks\n * - Validate input (Zod)\n * - Skip if no changes\n * - Merge changes\n * - Publish before event\n * - Delegate to repository\n * - Publish after event or error event\n */\nclass UpdateGroupUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EventPublisher.Interface,\n private repository: UpdateGroupRepository.Interface,\n private getGroupUseCase: GetGroupUseCase.Interface,\n private accessControl: AccessControl.Interface,\n private tenantContext: TenantContext.Interface\n ) {}\n\n async execute(\n groupId: string,\n input: CmsGroupUpdateInput\n ): Promise<Result<CmsGroup, UseCaseAbstraction.Error>> {\n // Initial access control check\n const canAccess = await this.accessControl.canAccessGroup({ rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(new GroupNotAuthorizedError());\n }\n\n // Fetch original group\n const getResult = await this.getGroupUseCase.execute(groupId);\n if (getResult.isFail()) {\n return Result.fail(getResult.error);\n }\n const original = getResult.value;\n\n // Access control check on original group\n const canAccessGroup = await this.accessControl.canAccessGroup({ group: original });\n if (!canAccessGroup) {\n return Result.fail(new GroupNotAuthorizedError());\n }\n\n // Validate input\n const validationResult = await createGroupUpdateValidation().safeParseAsync(input);\n if (!validationResult.success) {\n const zodError = createZodError(validationResult.error);\n return Result.fail(\n new GroupValidationError(zodError.message, zodError.data!.invalidFields)\n );\n }\n const data = validationResult.data;\n\n // Skip if no changes\n if (Object.keys(data).length === 0) {\n return Result.ok(original);\n }\n\n // Merge changes\n const tenant = this.tenantContext.getTenant();\n const group: CmsGroup = {\n ...original,\n ...data,\n tenant: tenant.id,\n savedOn: new Date().toISOString()\n };\n\n try {\n // Publish before event\n await this.eventPublisher.publish(\n new GroupBeforeUpdateEvent({\n original,\n group\n })\n );\n\n // Persist via repository\n const result = await this.repository.execute(group);\n if (result.isFail()) {\n // Publish error event\n await this.eventPublisher.publish(\n new GroupUpdateErrorEvent({\n input,\n original,\n group,\n error: result.error\n })\n );\n return Result.fail(result.error);\n }\n\n // The repository stamps the current tenant, so publish and return what it stored.\n await this.eventPublisher.publish(\n new GroupAfterUpdateEvent({\n original,\n group: result.value\n })\n );\n\n return Result.ok(result.value);\n } catch (error) {\n // Publish error event for unexpected errors\n await this.eventPublisher.publish(\n new GroupUpdateErrorEvent({\n input,\n original,\n group,\n error: error as Error\n })\n );\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const UpdateGroupUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateGroupUseCaseImpl,\n dependencies: [\n EventPublisher,\n UpdateGroupRepository,\n GetGroupUseCase,\n AccessControl,\n TenantContext\n ]\n});\n"],"names":["UpdateGroupUseCaseImpl","eventPublisher","repository","getGroupUseCase","accessControl","tenantContext","groupId","input","canAccess","Result","GroupNotAuthorizedError","getResult","original","canAccessGroup","validationResult","createGroupUpdateValidation","zodError","createZodError","GroupValidationError","data","Object","tenant","group","Date","GroupBeforeUpdateEvent","result","GroupUpdateErrorEvent","GroupAfterUpdateEvent","error","UpdateGroupUseCase","UseCaseAbstraction","EventPublisher","UpdateGroupRepository","GetGroupUseCase","AccessControl","TenantContext"],"mappings":";;;;;;;;;;AAgCA,MAAMA;IACF,YACYC,cAAwC,EACxCC,UAA2C,EAC3CC,eAA0C,EAC1CC,aAAsC,EACtCC,aAAsC,CAChD;aALUJ,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;aACAC,aAAa,GAAbA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,QACFC,OAAe,EACfC,KAA0B,EACyB;QAEnD,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAE,KAAK;QAAI;QACrE,IAAI,CAACA,WACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAI3B,MAAMC,YAAY,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAACL;QACrD,IAAIK,UAAU,MAAM,IAChB,OAAOF,OAAO,IAAI,CAACE,UAAU,KAAK;QAEtC,MAAMC,WAAWD,UAAU,KAAK;QAGhC,MAAME,iBAAiB,MAAM,IAAI,CAAC,aAAa,CAAC,cAA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tBnB;gBACAK;gBACAU;gBACA,OAAOM;YACX;YAEJ,OAAOnB,OAAO,IAAI,CAACmB;QACvB;IACJ;AACJ;AAEO,MAAMC,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgB9B;IAChB,cAAc;QACV+B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -27,7 +27,7 @@ export declare namespace UpdateGroupUseCase {
27
27
  * UpdateGroupRepository - Persists group updates to storage.
28
28
  */
29
29
  export interface IUpdateGroupRepository {
30
- execute(group: CmsGroup): Promise<Result<void, RepositoryError>>;
30
+ execute(group: CmsGroup): Promise<Result<CmsGroup, RepositoryError>>;
31
31
  }
32
32
  export interface IUpdateGroupRepositoryErrors {
33
33
  cannotUpdate: GroupCannotUpdateCodeDefinedError;
@@ -1 +1 @@
1
- {"version":3,"file":"features/contentModelGroup/UpdateGroup/abstractions.js","sources":["../../../../src/features/contentModelGroup/UpdateGroup/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { CmsGroup, CmsGroupUpdateInput } from \"~/types/index.js\";\nimport type {\n GroupCannotUpdateCodeDefinedError,\n GroupPersistenceError,\n GroupValidationError\n} from \"~/domain/contentModelGroup/errors.js\";\nimport {\n GroupNotAuthorizedError,\n type GroupNotFoundError\n} from \"~/domain/contentModelGroup/errors.js\";\n\n/**\n * UpdateGroup Use Case\n */\nexport interface IUpdateGroupUseCase {\n execute(groupId: string, input: CmsGroupUpdateInput): Promise<Result<CmsGroup, UseCaseError>>;\n}\n\nexport interface IUpdateGroupUseCaseErrors {\n notFound: GroupNotFoundError;\n notAuthorized: GroupNotAuthorizedError;\n validation: GroupValidationError;\n repository: RepositoryError;\n}\n\ntype UseCaseError = IUpdateGroupUseCaseErrors[keyof IUpdateGroupUseCaseErrors];\n\n/** Update a content model group. */\nexport const UpdateGroupUseCase = createAbstraction<IUpdateGroupUseCase>(\"UpdateGroupUseCase\");\n\nexport namespace UpdateGroupUseCase {\n export type Interface = IUpdateGroupUseCase;\n export type Input = CmsGroupUpdateInput;\n\n export type Error = UseCaseError;\n export type Return = Promise<Result<CmsGroup, UseCaseError>>;\n}\n\n/**\n * UpdateGroupRepository - Persists group updates to storage.\n */\nexport interface IUpdateGroupRepository {\n execute(group: CmsGroup): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface IUpdateGroupRepositoryErrors {\n cannotUpdate: GroupCannotUpdateCodeDefinedError;\n storage: GroupPersistenceError;\n}\n\ntype RepositoryError = IUpdateGroupRepositoryErrors[keyof IUpdateGroupRepositoryErrors];\n\nexport const UpdateGroupRepository =\n createAbstraction<IUpdateGroupRepository>(\"UpdateGroupRepository\");\n\nexport namespace UpdateGroupRepository {\n export type Interface = IUpdateGroupRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UpdateGroupUseCase","createAbstraction","UpdateGroupRepository"],"mappings":";AA6BO,MAAMA,qBAAqBC,kBAAuC;AAwBlE,MAAMC,wBACTD,kBAA0C"}
1
+ {"version":3,"file":"features/contentModelGroup/UpdateGroup/abstractions.js","sources":["../../../../src/features/contentModelGroup/UpdateGroup/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type { CmsGroup, CmsGroupUpdateInput } from \"~/types/index.js\";\nimport type {\n GroupCannotUpdateCodeDefinedError,\n GroupPersistenceError,\n GroupValidationError\n} from \"~/domain/contentModelGroup/errors.js\";\nimport {\n GroupNotAuthorizedError,\n type GroupNotFoundError\n} from \"~/domain/contentModelGroup/errors.js\";\n\n/**\n * UpdateGroup Use Case\n */\nexport interface IUpdateGroupUseCase {\n execute(groupId: string, input: CmsGroupUpdateInput): Promise<Result<CmsGroup, UseCaseError>>;\n}\n\nexport interface IUpdateGroupUseCaseErrors {\n notFound: GroupNotFoundError;\n notAuthorized: GroupNotAuthorizedError;\n validation: GroupValidationError;\n repository: RepositoryError;\n}\n\ntype UseCaseError = IUpdateGroupUseCaseErrors[keyof IUpdateGroupUseCaseErrors];\n\n/** Update a content model group. */\nexport const UpdateGroupUseCase = createAbstraction<IUpdateGroupUseCase>(\"UpdateGroupUseCase\");\n\nexport namespace UpdateGroupUseCase {\n export type Interface = IUpdateGroupUseCase;\n export type Input = CmsGroupUpdateInput;\n\n export type Error = UseCaseError;\n export type Return = Promise<Result<CmsGroup, UseCaseError>>;\n}\n\n/**\n * UpdateGroupRepository - Persists group updates to storage.\n */\nexport interface IUpdateGroupRepository {\n execute(group: CmsGroup): Promise<Result<CmsGroup, RepositoryError>>;\n}\n\nexport interface IUpdateGroupRepositoryErrors {\n cannotUpdate: GroupCannotUpdateCodeDefinedError;\n storage: GroupPersistenceError;\n}\n\ntype RepositoryError = IUpdateGroupRepositoryErrors[keyof IUpdateGroupRepositoryErrors];\n\nexport const UpdateGroupRepository =\n createAbstraction<IUpdateGroupRepository>(\"UpdateGroupRepository\");\n\nexport namespace UpdateGroupRepository {\n export type Interface = IUpdateGroupRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UpdateGroupUseCase","createAbstraction","UpdateGroupRepository"],"mappings":";AA6BO,MAAMA,qBAAqBC,kBAAuC;AAwBlE,MAAMC,wBACTD,kBAA0C"}
@@ -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/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 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"}
@@ -68,6 +68,7 @@ class ReadApi {
68
68
  });
69
69
  const templateIds = templateTypes.map((type)=>`extend type ${type} {
70
70
  _templateId: ID!
71
+ _id: ID
71
72
  }
72
73
  `);
73
74
  typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(" | ")}`);
@@ -97,6 +98,7 @@ class ManageApi {
97
98
  });
98
99
  const templateIds = templateTypes.map((type)=>`extend type ${type} {
99
100
  _templateId: ID!
101
+ _id: ID
100
102
  }
101
103
  `);
102
104
  typeDefs.unshift(`union ${unionTypeName} = ${templateTypes.join(" | ")}`);
@@ -131,9 +133,13 @@ class ManageApi {
131
133
  ${key}: ${value}
132
134
  `)}
133
135
  }`);
136
+ const templateInputIds = templateTypes.map((inputTypeName)=>`extend input ${inputTypeName} {
137
+ _id: ID
138
+ }
139
+ `);
134
140
  return {
135
141
  fields: createGraphQLInputField(field, `${typeName}Input`),
136
- typeDefs: typeDefs.join("\n")
142
+ typeDefs: typeDefs.concat(templateInputIds).join("\n")
137
143
  };
138
144
  }
139
145
  createResolver(params) {
@@ -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/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 }\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. */\n const templateIds = templateTypes.map(type => {\n return `extend type ${type} {\n _templateId: 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 return {\n fields: createGraphQLInputField(field, `${typeName}Input`),\n typeDefs: typeDefs.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","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,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MjC,UAAUb;QAChB,MAAM,EAAEc,YAAY,EAAE,EAAE,GAAGD,QAAQ,QAAQ;QAE3C,OAAO;YACH,MAAM;YACNb;YACA,UAAUc,UAAU,GAAG,CAAC,CAAC,EAAEiC,MAAM,EAAE,GAAG7B,UAAU,GACrC;oBACH,MAAM;oBACN,YAAY;wBACR,GAAGA,QAAQ;wBACX,eAAe;oBACnB;oBACA,UAAU6B,OAAO,GAAG,CAACC,CAAAA,IAAKF,UAAU,KAAK,CAACE;gBAC9C;QAER;IACJ;;aAtDgB,IAAI,GAAG,IAAIrB;aACX,MAAM,GAAG,IAAIM;aAEb,SAAS,GAAsB;aAC/B,YAAY,GAAY;aACxB,UAAU,GAAY;aACtB,oBAAoB,GAAY;;AAiDpD;AAEO,MAAMgB,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":";;;;;A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AAE;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"}
@@ -74,9 +74,10 @@ class ReadApi {
74
74
  fieldRegistry,
75
75
  endpointType: "read"
76
76
  });
77
+ const itemIdTypeDef = `\nextend type ${fieldType} {\n _id: ID\n}\n`;
77
78
  return {
78
79
  fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,
79
- typeDefs: `${typeDefs}${childTypeDefs}`
80
+ typeDefs: `${typeDefs}${childTypeDefs}${itemIdTypeDef}`
80
81
  };
81
82
  }
82
83
  createResolver({ field, createFieldResolvers, graphQLType }) {
@@ -118,9 +119,10 @@ class ManageApi {
118
119
  fieldRegistry,
119
120
  endpointType: "manage"
120
121
  });
122
+ const itemIdTypeDef = `\nextend type ${fieldType} {\n _id: ID\n}\n`;
121
123
  return {
122
124
  fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,
123
- typeDefs: `${typeDefs}\n${childTypeDefs}`
125
+ typeDefs: `${typeDefs}\n${childTypeDefs}${itemIdTypeDef}`
124
126
  };
125
127
  }
126
128
  createInputField({ models, model, field, fieldRegistry }) {
@@ -139,9 +141,10 @@ class ManageApi {
139
141
  });
140
142
  if (!result) return null;
141
143
  const { fieldType, typeDefs } = result;
144
+ const itemIdTypeDef = `\nextend input ${fieldType} {\n _id: ID\n}\n`;
142
145
  return {
143
146
  fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,
144
- typeDefs
147
+ typeDefs: `${typeDefs}${itemIdTypeDef}`
145
148
  };
146
149
  }
147
150
  createResolver({ graphQLType, field, createFieldResolvers }) {
@@ -1 +1 @@
1
- {"version":3,"file":"features/graphql/fields/base/ObjectToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/ObjectToGraphQL.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst.js\";\nimport { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"../abstractions/CmsModelFieldToGraphQLRegistry.js\";\nimport type {\n CmsModel,\n CmsModelField,\n CmsModelFieldType,\n CmsModelFieldDefinition,\n CmsModelObjectField\n} from \"~/types/index.js\";\nimport type { ValidateChildFieldsParams } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldAstNode, ICmsModelFieldToAst } from \"~/types/modelAst.js\";\nimport { createTypeFromFields } from \"~/utils/createTypeFromFields.js\";\n\ninterface CreateTypeNameParams {\n model: Pick<CmsModel, \"singularApiName\">;\n parents?: string[];\n field: CmsModelField;\n}\n\nconst createTypeName = (params: CreateTypeNameParams): string => {\n const { model, parents = [], field } = params;\n return [model.singularApiName]\n .concat(parents)\n .concat([field.fieldId])\n .filter(Boolean)\n .map(id => {\n return upperFirst(id);\n })\n .join(\"_\");\n};\n\ninterface CreateChildTypeDefsParams {\n model: Pick<CmsModel, \"singularApiName\">;\n field: CmsModelField;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n endpointType: \"manage\" | \"read\";\n}\n\nconst createChildTypeDefs = (params: CreateChildTypeDefsParams): string => {\n const { field, fieldRegistry, model, endpointType } = params;\n const fields = field.settings?.fields || [];\n\n const typeName = createTypeName({\n model,\n field,\n parents: field.settings?.parents\n });\n\n const filters = fields\n .map(child => {\n const fieldImpl = fieldRegistry.get(child.type);\n if (!fieldImpl) {\n return null;\n }\n const api = endpointType === \"manage\" ? fieldImpl.manage : fieldImpl.read;\n const createListFilters = api.createListFilters;\n if (!createListFilters) {\n return null;\n }\n\n const filters = createListFilters({\n model,\n field: {\n ...child,\n settings: {\n ...child.settings,\n parents: (child.settings?.parents || []).concat([field.fieldId])\n }\n },\n fieldRegistry\n });\n if (!filters) {\n return null;\n }\n return filters;\n })\n .filter(Boolean)\n .join(\"\\n\");\n return `input ${typeName}WhereInput {\n ${filters || \"_empty: String\"}\n }\\n`;\n};\n\nconst createObjectListFilters = (\n field: CmsModelField,\n model: Pick<CmsModel, \"singularApiName\">\n): string => {\n const typeName = createTypeName({\n model,\n field,\n parents: field.settings?.parents\n });\n return `${field.fieldId}: ${typeName}WhereInput`;\n};\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({\n field,\n models,\n model,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const result = createTypeFromFields({\n models,\n typeOfType: \"type\",\n model,\n type: \"read\",\n typeNamePrefix: createTypeName({\n model,\n field,\n parents: field.settings?.parents\n }),\n fields: field.settings?.fields || [],\n fieldRegistry\n });\n\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n const childTypeDefs = createChildTypeDefs({\n model,\n field,\n fieldRegistry,\n endpointType: \"read\"\n });\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,\n typeDefs: `${typeDefs}${childTypeDefs}`\n };\n }\n\n public createResolver({\n field,\n createFieldResolvers,\n graphQLType\n }: CmsModelFieldToGraphQL.ResolverParams): CmsModelFieldToGraphQL.Resolver {\n if (!field.settings?.fields || field.settings.fields.length === 0) {\n return false;\n }\n\n const fieldType = `${graphQLType}_${upperFirst(field.fieldId)}`;\n\n const typeResolvers =\n createFieldResolvers({\n graphQLType: fieldType,\n fields: field.settings.fields\n }) || {};\n\n return {\n resolver: null,\n typeResolvers\n };\n }\n\n public createListFilters({ field, model }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createObjectListFilters(field, model);\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 result = createTypeFromFields({\n typeOfType: \"type\",\n models,\n model,\n type: \"manage\",\n typeNamePrefix: createTypeName({\n model,\n field,\n parents: field.settings?.parents\n }),\n fields: field.settings?.fields || [],\n fieldRegistry\n });\n\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n const childTypeDefs = createChildTypeDefs({\n model,\n field,\n fieldRegistry,\n endpointType: \"manage\"\n });\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,\n typeDefs: `${typeDefs}\\n${childTypeDefs}`\n };\n }\n\n public createInputField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const result = createTypeFromFields({\n typeOfType: \"input\",\n models,\n model,\n type: \"manage\",\n typeNamePrefix: createTypeName({\n model,\n field,\n parents: field.settings?.parents\n }),\n fields: field.settings?.fields || [],\n fieldRegistry\n });\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,\n typeDefs\n };\n }\n\n public createResolver({\n graphQLType,\n field,\n createFieldResolvers\n }: CmsModelFieldToGraphQL.ResolverParams): CmsModelFieldToGraphQL.Resolver {\n if (!field.settings?.fields || field.settings.fields.length === 0) {\n return false;\n }\n const fieldType = `${graphQLType}_${upperFirst(field.fieldId)}`;\n const typeResolvers = createFieldResolvers({\n graphQLType: fieldType,\n fields: field.settings.fields\n });\n return {\n resolver: null,\n typeResolvers: typeResolvers || {}\n };\n }\n\n public createListFilters({ field, model }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createObjectListFilters(field, model);\n }\n}\n\nclass ObjectToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"object\";\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 CmsModelObjectField;\n const originalField = params.originalField as CmsModelObjectField | undefined;\n params.validate({\n fields: field.settings?.fields ?? [],\n originalFields: originalField?.settings?.fields || []\n });\n }\n\n public getFieldAst(field: CmsModelField, converter: ICmsModelFieldToAst): CmsModelFieldAstNode {\n const objectField = field as CmsModelObjectField;\n const { fields = [], ...settings } = objectField.settings;\n return {\n type: \"field\",\n field: {\n ...objectField,\n settings: settings || {}\n },\n children: fields.map(f => converter.toAst(f))\n };\n }\n}\n\nexport const ObjectFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: ObjectToGraphQL,\n dependencies: []\n});\n"],"names":["createTypeName","params","model","parents","field","Boolean","id","upperFirst","createChildTypeDefs","fieldRegistry","endpointType","fields","typeName","filters","child","fieldImpl","api","createListFilters","createObjectListFilters","ReadApi","models","result","createTypeFromFields","fieldType","typeDefs","childTypeDefs","createFieldResolvers","graphQLType","typeResolvers","ManageApi","ObjectToGraphQL","originalField","converter","objectField","settings","f","ObjectFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;AAoBA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,EAAEC,KAAK,EAAE,GAAGH;IACvC,OAAO;QAACC,MAAM,eAAe;KAAC,CACzB,MAAM,CAACC,SACP,MAAM,CAAC;QAACC,MAAM,OAAO;KAAC,EACtB,MAAM,CAACC,SACP,GAAG,CAACC,CAAAA,KACMC,WAAWD,KAErB,IAAI,CAAC;AACd;AASA,MAAME,sBAAsB,CAACP;IACzB,MAAM,EAAEG,KAAK,EAAEK,aAAa,EAAEP,KAAK,EAAEQ,YAAY,EAAE,GAAGT;IACtD,MAAMU,SAASP,MAAM,QAAQ,EAAE,UAAU,EAAE;IAE3C,MAAMQ,WAAWZ,eAAe;QAC5BE;QACAE;QACA,SAASA,MAAM,QAAQ,EAAE;IAC7B;IAEA,MAAMS,UAAUF,OACX,GAAG,CAACG,CAAAA;QACD,MAAMC,YAAYN,cAAc,GAAG,CAACK,MAAM,IAAI;QAC9C,IAAI,CAACC,WACD,OAAO;QAEX,MAAMC,MAAMN,AAAiB,aAAjBA,eAA4BK,UAAU,MAAM,GAAGA,UAAU,IAAI;QACzE,MAAME,oBAAoBD,IAAI,iBAAiB;QAC/C,IAAI,CAACC,mBACD,OAAO;QAGX,MAAMJ,UAAUI,kBAAkB;YAC9Bf;YACA,OAAO;gBACH,GAAGY,KAAK;gBACR,UAAU;oBACN,GAAGA,MAAM,QAAQ;oBACjB,SAAUA,AAAAA,CAAAA,MAAM,QAAQ,EAAE,WAAW,EAAC,EAAG,MAAM,CAAC;wBAACV,MAAM,OAAO;qBAA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;YACA,UAAUvB,OAAO,GAAG,CAACwB,CAAAA,IAAKH,UAAU,KAAK,CAACG;QAC9C;IACJ;;aApCgB,IAAI,GAAG,IAAIhB;aACX,MAAM,GAAG,IAAIU;aAEb,SAAS,GAAsB;aAC/B,YAAY,GAAY;aACxB,UAAU,GAAY;aACtB,oBAAoB,GAAY;;AA+BpD;AAEO,MAAMO,uBAAuBC,uBAAuB,oBAAoB,CAAC;IAC5E,gBAAgBP;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/graphql/fields/base/ObjectToGraphQL.js","sources":["../../../../../src/features/graphql/fields/base/ObjectToGraphQL.ts"],"sourcesContent":["import upperFirst from \"lodash/upperFirst.js\";\nimport { CmsModelFieldToGraphQL } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"../abstractions/CmsModelFieldToGraphQLRegistry.js\";\nimport type {\n CmsModel,\n CmsModelField,\n CmsModelFieldType,\n CmsModelFieldDefinition,\n CmsModelObjectField\n} from \"~/types/index.js\";\nimport type { ValidateChildFieldsParams } from \"../abstractions/CmsModelFieldToGraphQL.js\";\nimport type { CmsModelFieldAstNode, ICmsModelFieldToAst } from \"~/types/modelAst.js\";\nimport { createTypeFromFields } from \"~/utils/createTypeFromFields.js\";\n\ninterface CreateTypeNameParams {\n model: Pick<CmsModel, \"singularApiName\">;\n parents?: string[];\n field: CmsModelField;\n}\n\nconst createTypeName = (params: CreateTypeNameParams): string => {\n const { model, parents = [], field } = params;\n return [model.singularApiName]\n .concat(parents)\n .concat([field.fieldId])\n .filter(Boolean)\n .map(id => {\n return upperFirst(id);\n })\n .join(\"_\");\n};\n\ninterface CreateChildTypeDefsParams {\n model: Pick<CmsModel, \"singularApiName\">;\n field: CmsModelField;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n endpointType: \"manage\" | \"read\";\n}\n\nconst createChildTypeDefs = (params: CreateChildTypeDefsParams): string => {\n const { field, fieldRegistry, model, endpointType } = params;\n const fields = field.settings?.fields || [];\n\n const typeName = createTypeName({\n model,\n field,\n parents: field.settings?.parents\n });\n\n const filters = fields\n .map(child => {\n const fieldImpl = fieldRegistry.get(child.type);\n if (!fieldImpl) {\n return null;\n }\n const api = endpointType === \"manage\" ? fieldImpl.manage : fieldImpl.read;\n const createListFilters = api.createListFilters;\n if (!createListFilters) {\n return null;\n }\n\n const filters = createListFilters({\n model,\n field: {\n ...child,\n settings: {\n ...child.settings,\n parents: (child.settings?.parents || []).concat([field.fieldId])\n }\n },\n fieldRegistry\n });\n if (!filters) {\n return null;\n }\n return filters;\n })\n .filter(Boolean)\n .join(\"\\n\");\n return `input ${typeName}WhereInput {\n ${filters || \"_empty: String\"}\n }\\n`;\n};\n\nconst createObjectListFilters = (\n field: CmsModelField,\n model: Pick<CmsModel, \"singularApiName\">\n): string => {\n const typeName = createTypeName({\n model,\n field,\n parents: field.settings?.parents\n });\n return `${field.fieldId}: ${typeName}WhereInput`;\n};\n\nclass ReadApi implements CmsModelFieldToGraphQL.ReadApi {\n public createTypeField({\n field,\n models,\n model,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const result = createTypeFromFields({\n models,\n typeOfType: \"type\",\n model,\n type: \"read\",\n typeNamePrefix: createTypeName({\n model,\n field,\n parents: field.settings?.parents\n }),\n fields: field.settings?.fields || [],\n fieldRegistry\n });\n\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n const childTypeDefs = createChildTypeDefs({\n model,\n field,\n fieldRegistry,\n endpointType: \"read\"\n });\n\n const itemIdTypeDef = `\\nextend type ${fieldType} {\\n _id: ID\\n}\\n`;\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,\n typeDefs: `${typeDefs}${childTypeDefs}${itemIdTypeDef}`\n };\n }\n\n public createResolver({\n field,\n createFieldResolvers,\n graphQLType\n }: CmsModelFieldToGraphQL.ResolverParams): CmsModelFieldToGraphQL.Resolver {\n if (!field.settings?.fields || field.settings.fields.length === 0) {\n return false;\n }\n\n const fieldType = `${graphQLType}_${upperFirst(field.fieldId)}`;\n\n const typeResolvers =\n createFieldResolvers({\n graphQLType: fieldType,\n fields: field.settings.fields\n }) || {};\n\n return {\n resolver: null,\n typeResolvers\n };\n }\n\n public createListFilters({ field, model }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createObjectListFilters(field, model);\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 result = createTypeFromFields({\n typeOfType: \"type\",\n models,\n model,\n type: \"manage\",\n typeNamePrefix: createTypeName({\n model,\n field,\n parents: field.settings?.parents\n }),\n fields: field.settings?.fields || [],\n fieldRegistry\n });\n\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n const childTypeDefs = createChildTypeDefs({\n model,\n field,\n fieldRegistry,\n endpointType: \"manage\"\n });\n\n const itemIdTypeDef = `\\nextend type ${fieldType} {\\n _id: ID\\n}\\n`;\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,\n typeDefs: `${typeDefs}\\n${childTypeDefs}${itemIdTypeDef}`\n };\n }\n\n public createInputField({\n models,\n model,\n field,\n fieldRegistry\n }: CmsModelFieldToGraphQL.TypeFieldParams): CmsModelFieldDefinition | null {\n const result = createTypeFromFields({\n typeOfType: \"input\",\n models,\n model,\n type: \"manage\",\n typeNamePrefix: createTypeName({\n model,\n field,\n parents: field.settings?.parents\n }),\n fields: field.settings?.fields || [],\n fieldRegistry\n });\n if (!result) {\n return null;\n }\n const { fieldType, typeDefs } = result;\n\n const itemIdTypeDef = `\\nextend input ${fieldType} {\\n _id: ID\\n}\\n`;\n\n return {\n fields: `${field.fieldId}: ${field.list ? `[${fieldType}!]` : fieldType}`,\n typeDefs: `${typeDefs}${itemIdTypeDef}`\n };\n }\n\n public createResolver({\n graphQLType,\n field,\n createFieldResolvers\n }: CmsModelFieldToGraphQL.ResolverParams): CmsModelFieldToGraphQL.Resolver {\n if (!field.settings?.fields || field.settings.fields.length === 0) {\n return false;\n }\n const fieldType = `${graphQLType}_${upperFirst(field.fieldId)}`;\n const typeResolvers = createFieldResolvers({\n graphQLType: fieldType,\n fields: field.settings.fields\n });\n return {\n resolver: null,\n typeResolvers: typeResolvers || {}\n };\n }\n\n public createListFilters({ field, model }: CmsModelFieldToGraphQL.ListFiltersParams): string {\n return createObjectListFilters(field, model);\n }\n}\n\nclass ObjectToGraphQL implements CmsModelFieldToGraphQL.Interface {\n public readonly read = new ReadApi();\n public readonly manage = new ManageApi();\n\n public readonly fieldType: CmsModelFieldType = \"object\";\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 CmsModelObjectField;\n const originalField = params.originalField as CmsModelObjectField | undefined;\n params.validate({\n fields: field.settings?.fields ?? [],\n originalFields: originalField?.settings?.fields || []\n });\n }\n\n public getFieldAst(field: CmsModelField, converter: ICmsModelFieldToAst): CmsModelFieldAstNode {\n const objectField = field as CmsModelObjectField;\n const { fields = [], ...settings } = objectField.settings;\n return {\n type: \"field\",\n field: {\n ...objectField,\n settings: settings || {}\n },\n children: fields.map(f => converter.toAst(f))\n };\n }\n}\n\nexport const ObjectFieldToGraphQL = CmsModelFieldToGraphQL.createImplementation({\n implementation: ObjectToGraphQL,\n dependencies: []\n});\n"],"names":["createTypeName","params","model","parents","field","Boolean","id","upperFirst","createChildTypeDefs","fieldRegistry","endpointType","fields","typeName","filters","child","fieldImpl","api","createListFilters","createObjectListFilters","ReadApi","models","result","createTypeFromFields","fieldType","typeDefs","childTypeDefs","itemIdTypeDef","createFieldResolvers","graphQLType","typeResolvers","ManageApi","ObjectToGraphQL","originalField","converter","objectField","settings","f","ObjectFieldToGraphQL","CmsModelFieldToGraphQL"],"mappings":";;;AAoBA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,EAAEC,KAAK,EAAE,GAAGH;IACvC,OAAO;QAACC,MAAM,eAAe;KAAC,CACzB,MAAM,CAACC,SACP,MAAM,CAAC;QAACC,MAAM,OAAO;KAAC,EACtB,MAAM,CAACC,SACP,GAAG,CAACC,CAAAA,KACMC,WAAWD,KAErB,IAAI,CAAC;AACd;AASA,MAAME,sBAAsB,CAACP;IACzB,MAAM,EAAEG,KAAK,EAAEK,aAAa,EAAEP,KAAK,EAAEQ,YAAY,EAAE,GAAGT;IACtD,MAAMU,SAASP,MAAM,QAAQ,EAAE,UAAU,EAAE;IAE3C,MAAMQ,WAAWZ,eAAe;QAC5BE;QACAE;QACA,SAASA,MAAM,QAAQ,EAAE;IAC7B;IAEA,MAAMS,UAAUF,OACX,GAAG,CAACG,CAAAA;QACD,MAAMC,YAAYN,cAAc,GAAG,CAACK,MAAM,IAAI;QAC9C,IAAI,CAACC,WACD,OAAO;QAEX,MAAMC,MAAMN,AAAiB,aAAjBA,eAA4BK,UAAU,MAAM,GAAGA,UAAU,IAAI;QACzE,MAAME,oBAAoBD,IAAI,iBAAiB;QAC/C,IAAI,CAACC,mBACD,OAAO;QAGX,MAAMJ,UAAUI,kBAAkB;YAC9Bf;YACA,OAAO;gBACH,GAAGY,KAAK;gBACR,UAAU;oBACN,GAAGA,MAAM,QAAQ;oBACjB,SAAUA,AAAAA,CAAAA,MAAM,QAAQ,EAAE,WAAW,EAAC,EAAG,MAAM,CAAC;wBAACV,MAAM,OAAO;qBAAC;gBACnE;YACJ;YACAK;QACJ;QACA,IAAI,CAACI,SACD,OAAO;QAEX,OAAOA;IACX,GACC,MAAM,CAACR,SACP,IAAI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