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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (786) hide show
  1. package/HeadlessCmsEndpointConfig.d.ts +10 -0
  2. package/HeadlessCmsEndpointConfig.js +5 -0
  3. package/HeadlessCmsEndpointConfig.js.map +1 -0
  4. package/HeadlessCmsFeature.d.ts +10 -0
  5. package/HeadlessCmsFeature.js +168 -0
  6. package/HeadlessCmsFeature.js.map +1 -0
  7. package/createCmsRoute.d.ts +24 -0
  8. package/createCmsRoute.js +47 -0
  9. package/createCmsRoute.js.map +1 -0
  10. package/crud/contentEntry/entryDataValidation.js +14 -7
  11. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  12. package/crud/contentEntry/references/validateEntries.d.ts +1 -1
  13. package/crud/contentEntry/references/validateEntries.js +17 -7
  14. package/crud/contentEntry/references/validateEntries.js.map +1 -1
  15. package/domain/contentModel/schemas.d.ts +2 -0
  16. package/domain/contentModel/schemas.js +1 -0
  17. package/domain/contentModel/schemas.js.map +1 -1
  18. package/domain/contentModel/validation/dateExpressions.d.ts +6 -0
  19. package/domain/contentModel/validation/dateExpressions.js +27 -0
  20. package/domain/contentModel/validation/dateExpressions.js.map +1 -0
  21. package/domain/contentModel/validation/modelFields.js +23 -15
  22. package/domain/contentModel/validation/modelFields.js.map +1 -1
  23. package/export/abstractions.d.ts +9 -0
  24. package/export/abstractions.js +6 -0
  25. package/export/abstractions.js.map +1 -0
  26. package/export/crud/exporting.js +8 -2
  27. package/export/crud/exporting.js.map +1 -1
  28. package/export/crud/importing.js +13 -4
  29. package/export/crud/importing.js.map +1 -1
  30. package/export/crud/imports/importGroups.js +23 -23
  31. package/export/crud/imports/importGroups.js.map +1 -1
  32. package/export/crud/imports/importModels.js +25 -22
  33. package/export/crud/imports/importModels.js.map +1 -1
  34. package/export/graphql/index.d.ts +2 -3
  35. package/export/graphql/index.js +6 -10
  36. package/export/graphql/index.js.map +1 -1
  37. package/exports/api/cms/entry.d.ts +5 -0
  38. package/exports/api/cms/entry.js +5 -0
  39. package/exports/api/cms/storage.d.ts +0 -1
  40. package/exports/api/cms/storage.js +0 -1
  41. package/features/ai/DescribeContentModelTool.d.ts +60 -0
  42. package/features/ai/DescribeContentModelTool.js +69 -0
  43. package/features/ai/DescribeContentModelTool.js.map +1 -0
  44. package/features/ai/ListContentModelsTool.d.ts +46 -0
  45. package/features/ai/ListContentModelsTool.js +53 -0
  46. package/features/ai/ListContentModelsTool.js.map +1 -0
  47. package/features/ai/QueryEntriesTool.d.ts +80 -0
  48. package/features/ai/QueryEntriesTool.js +99 -0
  49. package/features/ai/QueryEntriesTool.js.map +1 -0
  50. package/features/ai/feature.d.ts +8 -0
  51. package/features/ai/feature.js +15 -0
  52. package/features/ai/feature.js.map +1 -0
  53. package/features/ai/index.d.ts +4 -0
  54. package/features/ai/index.js +4 -0
  55. package/features/contentEntry/ContentEntriesFeature.js +8 -4
  56. package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
  57. package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +6 -4
  58. package/features/contentEntry/CreateEntry/CreateEntryRepository.js +7 -8
  59. package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
  60. package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +5 -3
  61. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +4 -5
  62. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
  63. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +6 -4
  64. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +7 -8
  65. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
  66. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +5 -5
  67. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +8 -17
  68. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
  69. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.d.ts +2 -0
  70. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.js.map +1 -1
  71. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +6 -4
  72. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +7 -8
  73. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
  74. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +5 -3
  75. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +4 -5
  76. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
  77. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +6 -4
  78. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +9 -11
  79. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
  80. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +5 -3
  81. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +4 -5
  82. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
  83. package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.d.ts +3 -3
  84. package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js +5 -5
  85. package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js.map +1 -1
  86. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +6 -4
  87. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +7 -8
  88. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
  89. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +5 -3
  90. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +4 -5
  91. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
  92. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +6 -4
  93. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +8 -9
  94. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
  95. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +5 -3
  96. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +13 -13
  97. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
  98. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.d.ts +17 -0
  99. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js +83 -0
  100. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  101. package/features/contentEntry/DuplicateEntry/abstractions.d.ts +47 -0
  102. package/features/contentEntry/DuplicateEntry/abstractions.js +5 -0
  103. package/features/contentEntry/DuplicateEntry/abstractions.js.map +1 -0
  104. package/features/contentEntry/DuplicateEntry/events.d.ts +41 -0
  105. package/features/contentEntry/DuplicateEntry/events.js +32 -0
  106. package/features/contentEntry/DuplicateEntry/events.js.map +1 -0
  107. package/features/contentEntry/{UpdateRevision → DuplicateEntry}/feature.d.ts +1 -1
  108. package/features/contentEntry/DuplicateEntry/feature.js +11 -0
  109. package/features/contentEntry/DuplicateEntry/feature.js.map +1 -0
  110. package/features/contentEntry/DuplicateEntry/index.d.ts +2 -0
  111. package/features/contentEntry/DuplicateEntry/index.js +2 -0
  112. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.d.ts +7 -0
  113. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js +12 -0
  114. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js.map +1 -0
  115. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.d.ts +10 -0
  116. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js +25 -0
  117. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js.map +1 -0
  118. package/features/contentEntry/EntryEventPublisher/abstractions.d.ts +16 -0
  119. package/features/contentEntry/EntryEventPublisher/abstractions.js +5 -0
  120. package/features/contentEntry/EntryEventPublisher/abstractions.js.map +1 -0
  121. package/features/contentEntry/EntryEventPublisher/feature.d.ts +4 -0
  122. package/features/contentEntry/EntryEventPublisher/feature.js +11 -0
  123. package/features/contentEntry/EntryEventPublisher/feature.js.map +1 -0
  124. package/features/contentEntry/EntryEventPublisher/index.d.ts +2 -0
  125. package/features/contentEntry/EntryEventPublisher/index.js +2 -0
  126. package/features/contentEntry/EntrySystemField/abstractions.d.ts +14 -0
  127. package/features/contentEntry/EntrySystemField/abstractions.js +5 -0
  128. package/features/contentEntry/EntrySystemField/abstractions.js.map +1 -0
  129. package/features/contentEntry/EntrySystemField/index.d.ts +1 -0
  130. package/features/contentEntry/EntrySystemField/index.js +1 -0
  131. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +6 -4
  132. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +7 -8
  133. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
  134. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.d.ts +3 -1
  135. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +2 -3
  136. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
  137. package/features/contentEntry/GetEntry/GetEntryUseCase.d.ts +3 -1
  138. package/features/contentEntry/GetEntry/GetEntryUseCase.js +2 -3
  139. package/features/contentEntry/GetEntry/GetEntryUseCase.js.map +1 -1
  140. package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.d.ts +3 -1
  141. package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js +2 -3
  142. package/features/contentEntry/GetEntryById/GetEntryByIdUseCase.js.map +1 -1
  143. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +6 -4
  144. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +8 -9
  145. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
  146. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.d.ts +3 -1
  147. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +2 -3
  148. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
  149. package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.d.ts +3 -1
  150. package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +2 -3
  151. package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
  152. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +6 -4
  153. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +8 -9
  154. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
  155. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.d.ts +3 -1
  156. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js +2 -3
  157. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestDeletedRevisionByEntryIdUseCase.js.map +1 -1
  158. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.d.ts +3 -1
  159. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js +1 -3
  160. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdIncludingDeletedUseCase.js.map +1 -1
  161. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.d.ts +3 -1
  162. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js +2 -3
  163. package/features/contentEntry/GetLatestRevisionByEntryId/variations/GetLatestRevisionByEntryIdUseCase.js.map +1 -1
  164. package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.d.ts +3 -1
  165. package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +2 -3
  166. package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
  167. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +6 -4
  168. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -8
  169. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
  170. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.d.ts +3 -1
  171. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js +2 -3
  172. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdUseCase.js.map +1 -1
  173. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +6 -4
  174. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +8 -9
  175. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
  176. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.d.ts +3 -1
  177. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +2 -3
  178. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
  179. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +6 -4
  180. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +8 -9
  181. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
  182. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +3 -1
  183. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +2 -3
  184. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
  185. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +6 -4
  186. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -8
  187. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
  188. package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +3 -1
  189. package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +1 -3
  190. package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
  191. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +6 -4
  192. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +8 -9
  193. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
  194. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.d.ts +3 -1
  195. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js +2 -3
  196. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js.map +1 -1
  197. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +6 -4
  198. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -8
  199. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
  200. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +6 -2
  201. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +8 -6
  202. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
  203. package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.d.ts +3 -1
  204. package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js +1 -3
  205. package/features/contentEntry/ListEntries/ListDeletedEntriesUseCase.js.map +1 -1
  206. package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +6 -4
  207. package/features/contentEntry/ListEntries/ListEntriesRepository.js +8 -9
  208. package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
  209. package/features/contentEntry/ListEntries/ListEntriesUseCase.d.ts +3 -1
  210. package/features/contentEntry/ListEntries/ListEntriesUseCase.js +2 -3
  211. package/features/contentEntry/ListEntries/ListEntriesUseCase.js.map +1 -1
  212. package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.d.ts +3 -1
  213. package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js +1 -3
  214. package/features/contentEntry/ListEntries/ListLatestEntriesUseCase.js.map +1 -1
  215. package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.d.ts +3 -1
  216. package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js +1 -3
  217. package/features/contentEntry/ListEntries/ListPublishedEntriesUseCase.js.map +1 -1
  218. package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +6 -4
  219. package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -8
  220. package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
  221. package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +5 -3
  222. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +13 -7
  223. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
  224. package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +7 -5
  225. package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -9
  226. package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
  227. package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +7 -7
  228. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +13 -16
  229. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
  230. package/features/contentEntry/PublishEntry/abstractions.d.ts +8 -1
  231. package/features/contentEntry/PublishEntry/abstractions.js.map +1 -1
  232. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +8 -4
  233. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +11 -9
  234. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
  235. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +5 -3
  236. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +7 -6
  237. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
  238. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +6 -4
  239. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +7 -8
  240. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
  241. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +5 -3
  242. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +4 -5
  243. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
  244. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +6 -4
  245. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +7 -8
  246. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
  247. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +5 -3
  248. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +7 -6
  249. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
  250. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +7 -5
  251. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +7 -8
  252. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
  253. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +5 -3
  254. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +7 -6
  255. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
  256. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.d.ts +19 -0
  257. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js +70 -0
  258. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js.map +1 -0
  259. package/features/contentEntry/UpdateEntrySystem/abstractions.d.ts +24 -0
  260. package/features/contentEntry/UpdateEntrySystem/abstractions.js +5 -0
  261. package/features/contentEntry/UpdateEntrySystem/abstractions.js.map +1 -0
  262. package/features/contentEntry/UpdateEntrySystem/events.d.ts +29 -0
  263. package/features/contentEntry/UpdateEntrySystem/events.js +23 -0
  264. package/features/contentEntry/UpdateEntrySystem/events.js.map +1 -0
  265. package/features/contentEntry/UpdateEntrySystem/feature.d.ts +4 -0
  266. package/features/contentEntry/UpdateEntrySystem/feature.js +11 -0
  267. package/features/contentEntry/UpdateEntrySystem/feature.js.map +1 -0
  268. package/features/contentEntry/UpdateEntrySystem/index.d.ts +2 -0
  269. package/features/contentEntry/UpdateEntrySystem/index.js +2 -0
  270. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +6 -4
  271. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +6 -7
  272. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
  273. package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.d.ts +3 -1
  274. package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js +2 -3
  275. package/features/contentEntry/ValidateEntry/ValidateEntryUseCase.js.map +1 -1
  276. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
  277. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +1 -3
  278. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
  279. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +8 -4
  280. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +41 -16
  281. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
  282. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.d.ts +17 -1
  283. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.js.map +1 -1
  284. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +8 -4
  285. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +23 -18
  286. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
  287. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.d.ts +15 -1
  288. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.js.map +1 -1
  289. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +8 -4
  290. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +18 -15
  291. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
  292. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.d.ts +13 -1
  293. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.js.map +1 -1
  294. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +9 -7
  295. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +18 -20
  296. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
  297. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts +14 -2
  298. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map +1 -1
  299. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +8 -4
  300. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +67 -31
  301. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
  302. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.d.ts +15 -1
  303. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js.map +1 -1
  304. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.d.ts +24 -0
  305. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js +13 -0
  306. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js.map +1 -0
  307. package/features/contentModel/CreateModel/CreateModelRepository.d.ts +5 -6
  308. package/features/contentModel/CreateModel/CreateModelRepository.js +9 -12
  309. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  310. package/features/contentModel/CreateModel/CreateModelUseCase.js +2 -2
  311. package/features/contentModel/CreateModel/CreateModelUseCase.js.map +1 -1
  312. package/features/contentModel/CreateModel/abstractions.d.ts +1 -1
  313. package/features/contentModel/CreateModel/abstractions.js.map +1 -1
  314. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.d.ts +5 -6
  315. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +9 -12
  316. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  317. package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js +2 -2
  318. package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js.map +1 -1
  319. package/features/contentModel/CreateModelFrom/abstractions.d.ts +1 -1
  320. package/features/contentModel/CreateModelFrom/abstractions.js.map +1 -1
  321. package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +3 -3
  322. package/features/contentModel/DeleteModel/DeleteModelRepository.js +5 -5
  323. package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
  324. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +9 -3
  325. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +36 -18
  326. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
  327. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.d.ts +1 -1
  328. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.js.map +1 -1
  329. package/features/contentModel/ModelToAstConverter/abstractions.d.ts +1 -1
  330. package/features/contentModel/ModelToAstConverter/abstractions.js.map +1 -1
  331. package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +7 -4
  332. package/features/contentModel/UpdateModel/UpdateModelRepository.js +10 -6
  333. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  334. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  335. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +1 -1
  336. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -1
  337. package/features/contentModel/shared/ModelsFetcher.d.ts +9 -8
  338. package/features/contentModel/shared/ModelsFetcher.js +5 -5
  339. package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
  340. package/features/contentModel/shared/PluginModelsProvider.d.ts +9 -5
  341. package/features/contentModel/shared/PluginModelsProvider.js +11 -15
  342. package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
  343. package/features/contentModel/shared/abstractions.d.ts +10 -0
  344. package/features/contentModel/shared/abstractions.js +2 -1
  345. package/features/contentModel/shared/abstractions.js.map +1 -1
  346. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +11 -7
  347. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +19 -19
  348. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
  349. package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.d.ts +6 -2
  350. package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js +9 -8
  351. package/features/contentModelGroup/CreateGroup/CreateGroupUseCase.js.map +1 -1
  352. package/features/contentModelGroup/CreateGroup/abstractions.d.ts +1 -1
  353. package/features/contentModelGroup/CreateGroup/abstractions.js.map +1 -1
  354. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +8 -4
  355. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +11 -9
  356. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
  357. package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.d.ts +3 -1
  358. package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -3
  359. package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
  360. package/features/contentModelGroup/GetGroup/GetGroupRepository.d.ts +6 -4
  361. package/features/contentModelGroup/GetGroup/GetGroupRepository.js +9 -9
  362. package/features/contentModelGroup/GetGroup/GetGroupRepository.js.map +1 -1
  363. package/features/contentModelGroup/GetGroup/GetGroupUseCase.d.ts +3 -1
  364. package/features/contentModelGroup/GetGroup/GetGroupUseCase.js +2 -3
  365. package/features/contentModelGroup/GetGroup/GetGroupUseCase.js.map +1 -1
  366. package/features/contentModelGroup/ListGroups/ListGroupsRepository.d.ts +6 -4
  367. package/features/contentModelGroup/ListGroups/ListGroupsRepository.js +9 -9
  368. package/features/contentModelGroup/ListGroups/ListGroupsRepository.js.map +1 -1
  369. package/features/contentModelGroup/ListGroups/ListGroupsUseCase.d.ts +3 -1
  370. package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js +2 -3
  371. package/features/contentModelGroup/ListGroups/ListGroupsUseCase.js.map +1 -1
  372. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +6 -4
  373. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +7 -8
  374. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
  375. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.d.ts +3 -1
  376. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -3
  377. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
  378. package/features/contentModelGroup/shared/PluginGroupsProvider.d.ts +6 -4
  379. package/features/contentModelGroup/shared/PluginGroupsProvider.js +13 -11
  380. package/features/contentModelGroup/shared/PluginGroupsProvider.js.map +1 -1
  381. package/features/contentModelGroup/shared/abstractions.d.ts +10 -0
  382. package/features/contentModelGroup/shared/abstractions.js +2 -1
  383. package/features/contentModelGroup/shared/abstractions.js.map +1 -1
  384. package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.d.ts +2 -2
  385. package/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js.map +1 -1
  386. package/features/graphql/fields/base/AssetToGraphQL.d.ts +1 -1
  387. package/features/graphql/fields/base/AssetToGraphQL.js +7 -2
  388. package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -1
  389. package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
  390. package/features/graphql/fields/base/RefToGraphQL.d.ts +1 -1
  391. package/features/graphql/fields/base/RefToGraphQL.js +14 -8
  392. package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
  393. package/features/graphql/fields/base/richText/richTextResolver.d.ts +1 -1
  394. package/features/graphql/fields/base/richText/richTextResolver.js.map +1 -1
  395. package/features/modelBuilder/abstractions.d.ts +4 -0
  396. package/features/modelBuilder/abstractions.js.map +1 -1
  397. package/features/modelBuilder/feature.js +1 -8
  398. package/features/modelBuilder/feature.js.map +1 -1
  399. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +17 -0
  400. package/features/modelBuilder/fields/DataFieldBuilder.js +6 -0
  401. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
  402. package/features/modelBuilder/fields/DateTimeFieldType.js +27 -12
  403. package/features/modelBuilder/fields/DateTimeFieldType.js.map +1 -1
  404. package/features/modelBuilder/fields/TextFieldType.d.ts +3 -1
  405. package/features/modelBuilder/fields/TextFieldType.js +1 -3
  406. package/features/modelBuilder/fields/TextFieldType.js.map +1 -1
  407. package/features/modelBuilder/fields/fieldTypeValidator.d.ts +5 -3
  408. package/features/modelBuilder/models/ModelBuilder.d.ts +8 -0
  409. package/features/modelBuilder/models/ModelBuilder.js +1 -0
  410. package/features/modelBuilder/models/ModelBuilder.js.map +1 -1
  411. package/features/modelBuilder/models/ModelsProvider.d.ts +1 -3
  412. package/features/modelBuilder/models/ModelsProvider.js +2 -7
  413. package/features/modelBuilder/models/ModelsProvider.js.map +1 -1
  414. package/features/modelBuilder/models/PrivateModelBuilder.d.ts +5 -0
  415. package/features/modelBuilder/models/PrivateModelBuilder.js +12 -1
  416. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  417. package/features/shared/abstractions.d.ts +8 -16
  418. package/features/shared/abstractions.js +2 -3
  419. package/features/shared/abstractions.js.map +1 -1
  420. package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.d.ts +8 -0
  421. package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js +5 -0
  422. package/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js.map +1 -0
  423. package/features/shared/storageOperations/entry/CreateEntryStorageOperation.d.ts +8 -0
  424. package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js +5 -0
  425. package/features/shared/storageOperations/entry/CreateEntryStorageOperation.js.map +1 -0
  426. package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.d.ts +8 -0
  427. package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js +5 -0
  428. package/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js.map +1 -0
  429. package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.d.ts +8 -0
  430. package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js +5 -0
  431. package/features/shared/storageOperations/entry/DeleteEntryStorageOperation.js.map +1 -0
  432. package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.d.ts +8 -0
  433. package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js +5 -0
  434. package/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js.map +1 -0
  435. package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.d.ts +8 -0
  436. package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js +5 -0
  437. package/features/shared/storageOperations/entry/GetEntriesByIdsStorageOperation.js.map +1 -0
  438. package/features/shared/storageOperations/entry/GetEntryStorageOperation.d.ts +8 -0
  439. package/features/shared/storageOperations/entry/GetEntryStorageOperation.js +5 -0
  440. package/features/shared/storageOperations/entry/GetEntryStorageOperation.js.map +1 -0
  441. package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.d.ts +8 -0
  442. package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js +5 -0
  443. package/features/shared/storageOperations/entry/GetLatestEntriesByIdsStorageOperation.js.map +1 -0
  444. package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.d.ts +8 -0
  445. package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js +5 -0
  446. package/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js.map +1 -0
  447. package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.d.ts +8 -0
  448. package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js +5 -0
  449. package/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js.map +1 -0
  450. package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.d.ts +8 -0
  451. package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js +5 -0
  452. package/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js.map +1 -0
  453. package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.d.ts +8 -0
  454. package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js +5 -0
  455. package/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js.map +1 -0
  456. package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.d.ts +8 -0
  457. package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js +5 -0
  458. package/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js.map +1 -0
  459. package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.d.ts +8 -0
  460. package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js +5 -0
  461. package/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js.map +1 -0
  462. package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.d.ts +8 -0
  463. package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js +5 -0
  464. package/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js.map +1 -0
  465. package/features/shared/storageOperations/entry/ListEntriesStorageOperation.d.ts +8 -0
  466. package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js +5 -0
  467. package/features/shared/storageOperations/entry/ListEntriesStorageOperation.js.map +1 -0
  468. package/features/shared/storageOperations/entry/MoveEntryStorageOperation.d.ts +8 -0
  469. package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js +5 -0
  470. package/features/shared/storageOperations/entry/MoveEntryStorageOperation.js.map +1 -0
  471. package/features/shared/storageOperations/entry/MoveToBinStorageOperation.d.ts +8 -0
  472. package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js +5 -0
  473. package/features/shared/storageOperations/entry/MoveToBinStorageOperation.js.map +1 -0
  474. package/features/shared/storageOperations/entry/PublishEntryStorageOperation.d.ts +8 -0
  475. package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js +5 -0
  476. package/features/shared/storageOperations/entry/PublishEntryStorageOperation.js.map +1 -0
  477. package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.d.ts +8 -0
  478. package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js +5 -0
  479. package/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js.map +1 -0
  480. package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.d.ts +8 -0
  481. package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js +5 -0
  482. package/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js.map +1 -0
  483. package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.d.ts +8 -0
  484. package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js +5 -0
  485. package/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js.map +1 -0
  486. package/features/shared/storageOperations/group/CreateGroupStorageOperation.d.ts +8 -0
  487. package/features/shared/storageOperations/group/CreateGroupStorageOperation.js +5 -0
  488. package/features/shared/storageOperations/group/CreateGroupStorageOperation.js.map +1 -0
  489. package/features/shared/storageOperations/group/DeleteGroupStorageOperation.d.ts +8 -0
  490. package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js +5 -0
  491. package/features/shared/storageOperations/group/DeleteGroupStorageOperation.js.map +1 -0
  492. package/features/shared/storageOperations/group/GetGroupStorageOperation.d.ts +8 -0
  493. package/features/shared/storageOperations/group/GetGroupStorageOperation.js +5 -0
  494. package/features/shared/storageOperations/group/GetGroupStorageOperation.js.map +1 -0
  495. package/features/shared/storageOperations/group/ListGroupsStorageOperation.d.ts +8 -0
  496. package/features/shared/storageOperations/group/ListGroupsStorageOperation.js +5 -0
  497. package/features/shared/storageOperations/group/ListGroupsStorageOperation.js.map +1 -0
  498. package/features/shared/storageOperations/group/UpdateGroupStorageOperation.d.ts +8 -0
  499. package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js +5 -0
  500. package/features/shared/storageOperations/group/UpdateGroupStorageOperation.js.map +1 -0
  501. package/features/shared/storageOperations/index.d.ts +32 -0
  502. package/features/shared/storageOperations/index.js +32 -0
  503. package/features/shared/storageOperations/model/CreateModelStorageOperation.d.ts +8 -0
  504. package/features/shared/storageOperations/model/CreateModelStorageOperation.js +5 -0
  505. package/features/shared/storageOperations/model/CreateModelStorageOperation.js.map +1 -0
  506. package/features/shared/storageOperations/model/DeleteModelStorageOperation.d.ts +8 -0
  507. package/features/shared/storageOperations/model/DeleteModelStorageOperation.js +5 -0
  508. package/features/shared/storageOperations/model/DeleteModelStorageOperation.js.map +1 -0
  509. package/features/shared/storageOperations/model/GetModelStorageOperation.d.ts +8 -0
  510. package/features/shared/storageOperations/model/GetModelStorageOperation.js +5 -0
  511. package/features/shared/storageOperations/model/GetModelStorageOperation.js.map +1 -0
  512. package/features/shared/storageOperations/model/ListModelsStorageOperation.d.ts +8 -0
  513. package/features/shared/storageOperations/model/ListModelsStorageOperation.js +5 -0
  514. package/features/shared/storageOperations/model/ListModelsStorageOperation.js.map +1 -0
  515. package/features/shared/storageOperations/model/UpdateModelStorageOperation.d.ts +8 -0
  516. package/features/shared/storageOperations/model/UpdateModelStorageOperation.js +5 -0
  517. package/features/shared/storageOperations/model/UpdateModelStorageOperation.js.map +1 -0
  518. package/features/validation/abstractions/CmsModelFieldValidator.d.ts +5 -0
  519. package/features/validation/abstractions/CmsModelFieldValidator.js.map +1 -1
  520. package/features/validation/validators/DateGteValidator.d.ts +2 -0
  521. package/features/validation/validators/DateGteValidator.js +12 -2
  522. package/features/validation/validators/DateGteValidator.js.map +1 -1
  523. package/features/validation/validators/DateLteValidator.d.ts +2 -0
  524. package/features/validation/validators/DateLteValidator.js +12 -2
  525. package/features/validation/validators/DateLteValidator.js.map +1 -1
  526. package/features/validation/validators/dateLimit.d.ts +9 -0
  527. package/features/validation/validators/dateLimit.js +18 -0
  528. package/features/validation/validators/dateLimit.js.map +1 -0
  529. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  530. package/fieldConverters/abstractions.d.ts +14 -0
  531. package/fieldConverters/abstractions.js +13 -0
  532. package/fieldConverters/abstractions.js.map +1 -0
  533. package/graphql/CmsGraphQLSchemaFactory.d.ts +8 -0
  534. package/graphql/CmsGraphQLSchemaFactory.js +5 -0
  535. package/graphql/CmsGraphQLSchemaFactory.js.map +1 -0
  536. package/graphql/CmsSchemaExecutor.d.ts +10 -0
  537. package/graphql/CmsSchemaExecutor.js +5 -0
  538. package/graphql/CmsSchemaExecutor.js.map +1 -0
  539. package/graphql/buildSchemaPlugins.d.ts +2 -1
  540. package/graphql/buildSchemaPlugins.js +1 -3
  541. package/graphql/buildSchemaPlugins.js.map +1 -1
  542. package/graphql/checkEndpointAccess.js +5 -2
  543. package/graphql/checkEndpointAccess.js.map +1 -1
  544. package/graphql/createExecutableSchema.d.ts +1 -1
  545. package/graphql/createExecutableSchema.js +1 -1
  546. package/graphql/createExecutableSchema.js.map +1 -1
  547. package/graphql/generateSchema.d.ts +2 -1
  548. package/graphql/generateSchema.js +14 -5
  549. package/graphql/generateSchema.js.map +1 -1
  550. package/graphql/getSchema.js +7 -2
  551. package/graphql/getSchema.js.map +1 -1
  552. package/graphql/scalars/RevisionIdScalarPlugin.d.ts +1 -1
  553. package/graphql/scalars/RevisionIdScalarPlugin.js.map +1 -1
  554. package/graphql/schema/baseContentSchema.d.ts +1 -6
  555. package/graphql/schema/baseContentSchema.js +5 -8
  556. package/graphql/schema/baseContentSchema.js.map +1 -1
  557. package/graphql/schema/baseSchema.d.ts +2 -2
  558. package/graphql/schema/baseSchema.js +3 -18
  559. package/graphql/schema/baseSchema.js.map +1 -1
  560. package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +15 -0
  561. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +25 -0
  562. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -0
  563. package/graphql/schema/cms/createEntryResolver.js +2 -2
  564. package/graphql/schema/cms/createEntryResolver.js.map +1 -1
  565. package/graphql/schema/cms/deleteEntryResolver.js +2 -2
  566. package/graphql/schema/cms/deleteEntryResolver.js.map +1 -1
  567. package/graphql/schema/cms/getEntryResolver.js +2 -2
  568. package/graphql/schema/cms/getEntryResolver.js.map +1 -1
  569. package/graphql/schema/cms/helpers/getModel.d.ts +0 -3
  570. package/graphql/schema/cms/helpers/getModel.js +5 -3
  571. package/graphql/schema/cms/helpers/getModel.js.map +1 -1
  572. package/graphql/schema/cms/listEntriesResolver.js +2 -2
  573. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  574. package/graphql/schema/cms/publishEntryResolver.js +2 -2
  575. package/graphql/schema/cms/publishEntryResolver.js.map +1 -1
  576. package/graphql/schema/cms/resolvers/createEntry.d.ts +3 -2
  577. package/graphql/schema/cms/resolvers/createEntry.js +5 -1
  578. package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
  579. package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +3 -2
  580. package/graphql/schema/cms/resolvers/deleteEntryRevision.js +5 -1
  581. package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
  582. package/graphql/schema/cms/resolvers/getEntry.d.ts +3 -2
  583. package/graphql/schema/cms/resolvers/getEntry.js +5 -1
  584. package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
  585. package/graphql/schema/cms/resolvers/getModel.d.ts +3 -2
  586. package/graphql/schema/cms/resolvers/getModel.js +5 -1
  587. package/graphql/schema/cms/resolvers/getModel.js.map +1 -1
  588. package/graphql/schema/cms/resolvers/listEntries.d.ts +3 -2
  589. package/graphql/schema/cms/resolvers/listEntries.js +5 -1
  590. package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
  591. package/graphql/schema/cms/resolvers/mutationCms.d.ts +3 -2
  592. package/graphql/schema/cms/resolvers/mutationCms.js +5 -1
  593. package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
  594. package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +3 -2
  595. package/graphql/schema/cms/resolvers/publishEntryRevision.js +5 -1
  596. package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
  597. package/graphql/schema/cms/resolvers/queryCms.d.ts +3 -2
  598. package/graphql/schema/cms/resolvers/queryCms.js +5 -1
  599. package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
  600. package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +3 -2
  601. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +5 -1
  602. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
  603. package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +3 -2
  604. package/graphql/schema/cms/resolvers/updateEntryRevision.js +5 -1
  605. package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
  606. package/graphql/schema/cms/typeDefs/mutation.d.ts +3 -2
  607. package/graphql/schema/cms/typeDefs/mutation.js +5 -1
  608. package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
  609. package/graphql/schema/cms/typeDefs/query.d.ts +3 -2
  610. package/graphql/schema/cms/typeDefs/query.js +5 -1
  611. package/graphql/schema/cms/typeDefs/query.js.map +1 -1
  612. package/graphql/schema/cms/typeDefs/responses.d.ts +3 -2
  613. package/graphql/schema/cms/typeDefs/responses.js +5 -1
  614. package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
  615. package/graphql/schema/cms/unpublishEntryResolver.js +2 -2
  616. package/graphql/schema/cms/unpublishEntryResolver.js.map +1 -1
  617. package/graphql/schema/cms/updateEntryResolver.js +2 -2
  618. package/graphql/schema/cms/updateEntryResolver.js.map +1 -1
  619. package/graphql/schema/contentEntries.js +60 -34
  620. package/graphql/schema/contentEntries.js.map +1 -1
  621. package/graphql/schema/contentModelGroups.js +39 -18
  622. package/graphql/schema/contentModelGroups.js.map +1 -1
  623. package/graphql/schema/contentModels.js +32 -15
  624. package/graphql/schema/contentModels.js.map +1 -1
  625. package/graphql/schema/createFieldResolvers.d.ts +1 -1
  626. package/graphql/schema/createFieldResolvers.js.map +1 -1
  627. package/graphql/schema/createManageResolvers.js +7 -3
  628. package/graphql/schema/createManageResolvers.js.map +1 -1
  629. package/graphql/schema/createManageSDL.js +2 -0
  630. package/graphql/schema/createManageSDL.js.map +1 -1
  631. package/graphql/schema/resolvers/manage/resolveCreate.js +5 -3
  632. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  633. package/graphql/schema/resolvers/manage/resolveCreateFrom.js +5 -3
  634. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  635. package/graphql/schema/resolvers/manage/resolveDelete.js +9 -4
  636. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  637. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +5 -3
  638. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
  639. package/graphql/schema/resolvers/manage/resolveDuplicate.d.ts +7 -0
  640. package/graphql/schema/resolvers/manage/resolveDuplicate.js +11 -0
  641. package/graphql/schema/resolvers/manage/resolveDuplicate.js.map +1 -0
  642. package/graphql/schema/resolvers/manage/resolveGet.js +11 -6
  643. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  644. package/graphql/schema/resolvers/manage/resolveGetByIds.js +5 -3
  645. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  646. package/graphql/schema/resolvers/manage/resolveGetRevisions.js +5 -3
  647. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  648. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +5 -3
  649. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
  650. package/graphql/schema/resolvers/manage/resolveList.js +5 -3
  651. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  652. package/graphql/schema/resolvers/manage/resolveListDeleted.js +5 -3
  653. package/graphql/schema/resolvers/manage/resolveListDeleted.js.map +1 -1
  654. package/graphql/schema/resolvers/manage/resolveMove.js +4 -2
  655. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
  656. package/graphql/schema/resolvers/manage/resolvePublish.js +5 -3
  657. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  658. package/graphql/schema/resolvers/manage/resolveRepublish.js +5 -3
  659. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  660. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js +5 -3
  661. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js.map +1 -1
  662. package/graphql/schema/resolvers/manage/resolveUnpublish.js +5 -3
  663. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  664. package/graphql/schema/resolvers/manage/resolveUpdate.js +5 -3
  665. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  666. package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js +5 -3
  667. package/graphql/schema/resolvers/manage/resolveUpdateRevisionDescription.js.map +1 -1
  668. package/graphql/schema/resolvers/manage/resolveValidate.js +5 -3
  669. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -1
  670. package/graphql/schema/resolvers/preview/resolveGet.js +6 -3
  671. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  672. package/graphql/schema/resolvers/preview/resolveList.js +5 -3
  673. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  674. package/graphql/schema/resolvers/read/resolveGet.js +5 -2
  675. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  676. package/graphql/schema/resolvers/read/resolveList.js +5 -3
  677. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  678. package/graphql/schema/resolvers/singular/resolveGet.js +1 -1
  679. package/graphql/schema/resolvers/singular/resolveGet.js.map +1 -1
  680. package/graphql/schema/resolvers/singular/resolveUpdate.js +1 -1
  681. package/graphql/schema/resolvers/singular/resolveUpdate.js.map +1 -1
  682. package/graphql/schema/schemaPlugins.d.ts +2 -1
  683. package/graphql/schema/schemaPlugins.js +2 -4
  684. package/graphql/schema/schemaPlugins.js.map +1 -1
  685. package/index.d.ts +7 -3
  686. package/index.js +4 -2
  687. package/legacy/abstractions.js.map +1 -1
  688. package/package.json +21 -24
  689. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +2 -2
  690. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js +1 -1
  691. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -1
  692. package/plugins/index.d.ts +0 -1
  693. package/plugins/index.js +0 -1
  694. package/types/index.d.ts +0 -1
  695. package/types/modelField.d.ts +11 -0
  696. package/types/types.d.ts +19 -291
  697. package/types/types.js.map +1 -1
  698. package/utils/converters/ConverterCollection.d.ts +2 -2
  699. package/utils/converters/ConverterCollection.js +1 -3
  700. package/utils/converters/ConverterCollection.js.map +1 -1
  701. package/utils/converters/valueKeyFromStorageConverter.d.ts +2 -2
  702. package/utils/converters/valueKeyFromStorageConverter.js +2 -2
  703. package/utils/converters/valueKeyFromStorageConverter.js.map +1 -1
  704. package/utils/converters/valueKeyStorageConverter.js +4 -2
  705. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  706. package/utils/converters/valueKeyToStorageConverter.d.ts +2 -2
  707. package/utils/converters/valueKeyToStorageConverter.js +2 -2
  708. package/utils/converters/valueKeyToStorageConverter.js.map +1 -1
  709. package/utils/createModelField.js +2 -1
  710. package/utils/createModelField.js.map +1 -1
  711. package/utils/createModelSchemaKey.d.ts +8 -0
  712. package/utils/createModelSchemaKey.js +18 -0
  713. package/utils/createModelSchemaKey.js.map +1 -0
  714. package/utils/getSchemaFromFieldPlugins.d.ts +2 -2
  715. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  716. package/utils/isHeadlessCmsReady.d.ts +1 -1
  717. package/utils/isHeadlessCmsReady.js +3 -2
  718. package/utils/isHeadlessCmsReady.js.map +1 -1
  719. package/abstractions/entryHooks/OnEntryBeforeCreate.d.ts +0 -8
  720. package/abstractions/entryHooks/OnEntryBeforeCreate.js +0 -5
  721. package/abstractions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
  722. package/abstractions/entryHooks/index.d.ts +0 -1
  723. package/abstractions/entryHooks/index.js +0 -1
  724. package/abstractions/index.d.ts +0 -1
  725. package/abstractions/index.js +0 -1
  726. package/context.d.ts +0 -3
  727. package/context.js +0 -131
  728. package/context.js.map +0 -1
  729. package/crud/contentEntry.crud.d.ts +0 -6
  730. package/crud/contentEntry.crud.js +0 -307
  731. package/crud/contentEntry.crud.js.map +0 -1
  732. package/crud/contentModel.crud.d.ts +0 -5
  733. package/crud/contentModel.crud.js +0 -77
  734. package/crud/contentModel.crud.js.map +0 -1
  735. package/crud/contentModelGroup.crud.d.ts +0 -5
  736. package/crud/contentModelGroup.crud.js +0 -74
  737. package/crud/contentModelGroup.crud.js.map +0 -1
  738. package/extension.d.ts +0 -3
  739. package/extension.js +0 -19
  740. package/extension.js.map +0 -1
  741. package/extensions/entryHooks/OnEntryBeforeCreate.d.ts +0 -4
  742. package/extensions/entryHooks/OnEntryBeforeCreate.js +0 -21
  743. package/extensions/entryHooks/OnEntryBeforeCreate.js.map +0 -1
  744. package/extensions/entryHooks/index.d.ts +0 -1
  745. package/extensions/entryHooks/index.js +0 -1
  746. package/extensions/index.d.ts +0 -5
  747. package/extensions/index.js +0 -7
  748. package/extensions/index.js.map +0 -1
  749. package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.d.ts +0 -14
  750. package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js +0 -34
  751. package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js.map +0 -1
  752. package/features/contentEntry/UpdateRevision/abstractions.d.ts +0 -10
  753. package/features/contentEntry/UpdateRevision/abstractions.js +0 -5
  754. package/features/contentEntry/UpdateRevision/abstractions.js.map +0 -1
  755. package/features/contentEntry/UpdateRevision/feature.js +0 -11
  756. package/features/contentEntry/UpdateRevision/feature.js.map +0 -1
  757. package/features/contentEntry/UpdateRevision/index.d.ts +0 -1
  758. package/features/contentEntry/UpdateRevision/index.js +0 -1
  759. package/graphql/graphQLHandlerFactory.d.ts +0 -5
  760. package/graphql/graphQLHandlerFactory.js +0 -22
  761. package/graphql/graphQLHandlerFactory.js.map +0 -1
  762. package/graphql/handleRequest.d.ts +0 -11
  763. package/graphql/handleRequest.js +0 -62
  764. package/graphql/handleRequest.js.map +0 -1
  765. package/graphql/index.d.ts +0 -4
  766. package/graphql/index.js +0 -11
  767. package/graphql/index.js.map +0 -1
  768. package/graphql/schema/cms/index.d.ts +0 -2
  769. package/graphql/schema/cms/index.js +0 -25
  770. package/graphql/schema/cms/index.js.map +0 -1
  771. package/parameters/context.d.ts +0 -2
  772. package/parameters/context.js +0 -7
  773. package/parameters/context.js.map +0 -1
  774. package/parameters/header.d.ts +0 -2
  775. package/parameters/header.js +0 -13
  776. package/parameters/header.js.map +0 -1
  777. package/parameters/index.d.ts +0 -3
  778. package/parameters/index.js +0 -3
  779. package/parameters/path.d.ts +0 -2
  780. package/parameters/path.js +0 -12
  781. package/parameters/path.js.map +0 -1
  782. package/plugins/CmsParametersPlugin.d.ts +0 -18
  783. package/plugins/CmsParametersPlugin.js +0 -16
  784. package/plugins/CmsParametersPlugin.js.map +0 -1
  785. package/types/context.d.ts +0 -110
  786. package/types/context.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"domain/contentModel/schemas.js","sources":["../../../src/domain/contentModel/schemas.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str;\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Must be alphanumeric string.`\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({}),\n rules: zod\n .array(\n zod.object({\n type: zod.enum([\"accessControl\", \"condition\"]),\n target: shortString,\n operator: shortString,\n value: zod.union([zod.string(), zod.number(), zod.boolean(), zod.null()]),\n action: shortString\n })\n )\n .optional()\n .nullish()\n .default([])\n .transform(value => value || [])\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish(),\n settings: zod.looseObject({}).optional().nullish().default({})\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional(),\n settings: zod.looseObject({}).optional().nullish()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n"],"names":["str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refineSingularApiName","ctx","refinePluralApiName","modelIdTransformation","camelCasedValue","createModelCreateValidation","createModelUpdateValidation","createModelCreateFromValidation"],"mappings":";;;AAIA,MAAMA,MAAMC,IAAI,MAAM,GA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
1
+ {"version":3,"file":"domain/contentModel/schemas.js","sources":["../../../src/domain/contentModel/schemas.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str;\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Must be alphanumeric string.`\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n disabled: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({}),\n rules: zod\n .array(\n zod.object({\n type: zod.enum([\"accessControl\", \"condition\"]),\n target: shortString,\n operator: shortString,\n value: zod.union([zod.string(), zod.number(), zod.boolean(), zod.null()]),\n action: shortString\n })\n )\n .optional()\n .nullish()\n .default([])\n .transform(value => value || [])\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish(),\n settings: zod.looseObject({}).optional().nullish().default({})\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional(),\n settings: zod.looseObject({}).optional().nullish()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n"],"names":["str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refineSingularApiName","ctx","refinePluralApiName","modelIdTransformation","camelCasedValue","createModelCreateValidation","createModelUpdateValidation","createModelCreateFromValidation"],"mappings":";;;AAIA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH;AACnB,MAAMI,sBAAsBF,YAAY,QAAQ;AAChD,MAAMG,qBAAqBF,WAAW,QAAQ;AAC9C,MAAMG,6BAA6BF,oBAAoB,OAAO,GAAG,OAAO,CAAC;AACzE,MAAMG,4BAA4BF,mBAAmB,OAAO,GAAG,OAAO,CAAC;AAEvE,MAAMG,OAAOP,IAAAA,WACG,CAAC;IACT,MAAMA,IAAI,MAAM;IAChB,MAAMA,IAAI,MAAM;IAChB,OAAOA,IAAI,MAAM,GAAG,QAAQ;AAChC,GACC,QAAQ,GACR,OAAO,GACP,OAAO,CAAC,MACR,SAAS,CAACQ,CAAAA;IACP,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;QACH,MAAM;QACN,MAAMA;IACV;IAEJ,OAAOA;AACX;AAEJ,MAAMC,cAAcT,IAAI,MAAM,CAAC;IAC3B,IAAIC;IACJ,WAAWD,IAAAA,MACA,GACN,QAAQ,GACR,SAAS,CAAC,IACA;IAEf,SAASC,YACJ,GAAG,CAAC,KACJ,KAAK,CAAC,eAAe;QAClB,SAAS;IACb,GACC,KAAK,CAAC,qBAAqB;QACxB,SAAS;IACb;IACJ,OAAOA;IACP,MAAMK;IACN,aAAaD;IACb,MAAMA;IACN,aAAaA;IACb,MAAMJ;IACN,MAAMD,IAAI,KAAK,CAACC,aAAa,QAAQ,GAAG,OAAO,CAAC,EAAE;IAClD,MAAMD,IAAAA,OACM,GACP,QAAQ,GACR,OAAO,GACP,SAAS,CAACQ,CAAAA,QACA,CAAC,CAACA,OAEZ,OAAO,CAAC;IACb,UAAUR,IAAAA,OACE,GACP,QAAQ,GACR,OAAO,GACP,SAAS,CAACQ,CAAAA,QACA,CAAC,CAACA,OAEZ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,GAAG,OAAO;IACpD;AAGG,MAAMuB,kCAAkC,IACpCvB,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACgB;QACvC,iBAAiBlB,YAAY,WAAW,CAACe;QACzC,eAAef,YAAY,WAAW,CAACiB;QACvC,aAAab;QACb,OAAOJ;QACPM,MAAAA;IACJ"}
@@ -0,0 +1,6 @@
1
+ import type { CmsModelField } from "../../../types/index.js";
2
+ /**
3
+ * A `dateGte`/`dateLte` limit given as `{ expression }` must parse, and is allowed only on a
4
+ * date-only field: on a time or datetime field, "today" has no single meaning.
5
+ */
6
+ export declare const validateDateExpressions: (field: Pick<CmsModelField, "fieldId" | "type" | "settings" | "validation">) => void;
@@ -0,0 +1,27 @@
1
+ import error from "@webiny/error";
2
+ import { isDateExpression } from "@webiny/utils";
3
+ const DATE_LIMIT_VALIDATORS = [
4
+ "dateGte",
5
+ "dateLte"
6
+ ];
7
+ const validateDateExpressions = (field)=>{
8
+ for (const validator of field.validation || []){
9
+ if (!DATE_LIMIT_VALIDATORS.includes(validator.name)) continue;
10
+ const expression = validator.settings?.expression;
11
+ if (null != expression) {
12
+ if ("string" != typeof expression || !isDateExpression(expression)) throw new error(`Field "${field.fieldId}" has an invalid date expression "${expression}" in its "${validator.name}" validator. Use "today", or "today" plus or minus a number of days, months or years, like "today-18y".`, "INVALID_DATE_EXPRESSION", {
13
+ fieldId: field.fieldId,
14
+ validator: validator.name,
15
+ expression
16
+ });
17
+ if ("datetime" !== field.type || field.settings?.type !== "date") throw new error(`Field "${field.fieldId}" uses a date expression in its "${validator.name}" validator, but expressions are only allowed on date-only fields.`, "DATE_EXPRESSION_NOT_ALLOWED", {
18
+ fieldId: field.fieldId,
19
+ validator: validator.name,
20
+ expression
21
+ });
22
+ }
23
+ }
24
+ };
25
+ export { validateDateExpressions };
26
+
27
+ //# sourceMappingURL=dateExpressions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domain/contentModel/validation/dateExpressions.js","sources":["../../../../src/domain/contentModel/validation/dateExpressions.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { isDateExpression } from \"@webiny/utils\";\nimport type { CmsModelField } from \"~/types/index.js\";\n\nconst DATE_LIMIT_VALIDATORS = [\"dateGte\", \"dateLte\"];\n\n/**\n * A `dateGte`/`dateLte` limit given as `{ expression }` must parse, and is allowed only on a\n * date-only field: on a time or datetime field, \"today\" has no single meaning.\n */\nexport const validateDateExpressions = (\n field: Pick<CmsModelField, \"fieldId\" | \"type\" | \"settings\" | \"validation\">\n): void => {\n for (const validator of field.validation || []) {\n if (!DATE_LIMIT_VALIDATORS.includes(validator.name)) {\n continue;\n }\n const expression = validator.settings?.expression;\n if (expression === undefined || expression === null) {\n continue;\n }\n if (typeof expression !== \"string\" || !isDateExpression(expression)) {\n throw new WebinyError(\n `Field \"${field.fieldId}\" has an invalid date expression \"${expression}\" in its \"${validator.name}\" validator. Use \"today\", or \"today\" plus or minus a number of days, months or years, like \"today-18y\".`,\n \"INVALID_DATE_EXPRESSION\",\n { fieldId: field.fieldId, validator: validator.name, expression }\n );\n }\n if (field.type !== \"datetime\" || field.settings?.type !== \"date\") {\n throw new WebinyError(\n `Field \"${field.fieldId}\" uses a date expression in its \"${validator.name}\" validator, but expressions are only allowed on date-only fields.`,\n \"DATE_EXPRESSION_NOT_ALLOWED\",\n { fieldId: field.fieldId, validator: validator.name, expression }\n );\n }\n }\n};\n"],"names":["DATE_LIMIT_VALIDATORS","validateDateExpressions","field","validator","expression","isDateExpression","WebinyError"],"mappings":";;AAIA,MAAMA,wBAAwB;IAAC;IAAW;CAAU;AAM7C,MAAMC,0BAA0B,CACnCC;IAEA,KAAK,MAAMC,aAAaD,MAAM,UAAU,IAAI,EAAE,CAAE;QAC5C,IAAI,CAACF,sBAAsB,QAAQ,CAACG,UAAU,IAAI,GAC9C;QAEJ,MAAMC,aAAaD,UAAU,QAAQ,EAAE;QACvC,IAAIC,QAAAA;YAGJ,IAAI,AAAsB,YAAtB,OAAOA,cAA2B,CAACC,iBAAiBD,aACpD,MAAM,IAAIE,MACN,CAAC,OAAO,EAAEJ,MAAM,OAAO,CAAC,kCAAkC,EAAEE,WAAW,UAAU,EAAED,UAAU,IAAI,CAAC,uGAAuG,CAAC,EAC1M,2BACA;gBAAE,SAASD,MAAM,OAAO;gBAAE,WAAWC,UAAU,IAAI;gBAAEC;YAAW;YAGxE,IAAIF,AAAe,eAAfA,MAAM,IAAI,IAAmBA,MAAM,QAAQ,EAAE,SAAS,QACtD,MAAM,IAAII,MACN,CAAC,OAAO,EAAEJ,MAAM,OAAO,CAAC,iCAAiC,EAAEC,UAAU,IAAI,CAAC,kEAAkE,CAAC,EAC7I,+BACA;gBAAE,SAASD,MAAM,OAAO;gBAAE,WAAWC,UAAU,IAAI;gBAAEC;YAAW;;IAG5E;AACJ"}
@@ -1,14 +1,17 @@
1
1
  import graphql_tag from "graphql-tag";
2
- import { generateAlphaNumericId } from "@webiny/utils";
3
2
  import _webiny_error from "@webiny/error";
3
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
4
+ import { ListModelsUseCase } from "../../../features/contentModel/ListModels/index.js";
4
5
  import { createManageSDL } from "../../../graphql/schema/createManageSDL.js";
5
6
  import { createFieldStorageId } from "../createFieldStorageId.js";
6
7
  import { getBaseFieldType } from "../../../utils/getBaseFieldType.js";
7
8
  import { getContentModelTitleFieldId } from "./fields/titleField.js";
8
9
  import { getContentModelDescriptionFieldId } from "./fields/descriptionField.js";
9
10
  import { getContentModelImageFieldId } from "./fields/imageField.js";
10
- import { CmsGraphQLSchemaPlugin } from "../../../plugins/index.js";
11
+ import { validateDateExpressions } from "./dateExpressions.js";
11
12
  import { buildSchemaPlugins } from "../../../graphql/buildSchemaPlugins.js";
13
+ import { HeadlessCmsEndpointConfig } from "../../../HeadlessCmsEndpointConfig.js";
14
+ import { CmsGraphQLSchemaFactory } from "../../../graphql/CmsGraphQLSchemaFactory.js";
12
15
  import { createExecutableSchema } from "../../../graphql/createExecutableSchema.js";
13
16
  import { CmsGraphQLSchemaSorter, CmsModelFieldToGraphQLRegistry } from "../../../features/graphql/index.js";
14
17
  const extractInvalidField = (model, err)=>{
@@ -76,6 +79,7 @@ const validateFields = (params)=>{
76
79
  fieldIdList.push(field.fieldId);
77
80
  if (storageIdList.includes(field.storageId)) throw new _webiny_error(`Cannot update content model because field "${field.label}" has storageId "${field.storageId}", which is already used.`);
78
81
  storageIdList.push(field.storageId);
82
+ validateDateExpressions(field);
79
83
  if (!fieldImpl.validateChildFields) continue;
80
84
  const validateChildFields = createValidateChildFields(registry);
81
85
  fieldImpl.validateChildFields({
@@ -87,24 +91,28 @@ const validateFields = (params)=>{
87
91
  };
88
92
  const createGraphQLSchema = async (params)=>{
89
93
  const { context, model } = params;
90
- const models = await context.security.withoutAuthorization(async ()=>(await context.cms.listModels()).filter((model)=>true !== model.isPrivate));
91
- const modelPlugins = await buildSchemaPlugins({
94
+ const modelsResult = await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>context.container.resolve(ListModelsUseCase).execute());
95
+ if (modelsResult.isFail()) throw modelsResult.error;
96
+ const models = modelsResult.value.filter((model)=>true !== model.isPrivate);
97
+ const generatedSchemaPlugins = await buildSchemaPlugins({
92
98
  context,
93
99
  models: models.filter((m)=>m.modelId !== model.modelId).concat([
94
100
  model
95
- ])
101
+ ]),
102
+ type: context.container.resolve(HeadlessCmsEndpointConfig).type
103
+ });
104
+ const staticFactories = context.container.resolveAll(CmsGraphQLSchemaFactory);
105
+ const staticPlugins = [];
106
+ for (const factory of staticFactories)staticPlugins.push(...await factory.execute());
107
+ const schemaPlugins = [
108
+ ...staticPlugins,
109
+ ...generatedSchemaPlugins
110
+ ].filter((pl)=>{
111
+ if ("function" == typeof pl.isApplicable) return pl.isApplicable(context);
112
+ return true;
96
113
  });
97
- const plugins = context.plugins.byType(CmsGraphQLSchemaPlugin.type).filter((plugin)=>plugin.isApplicable(context)).reduce((collection, plugin)=>{
98
- const name = plugin.name || `${CmsGraphQLSchemaPlugin.type}-${generateAlphaNumericId(16)}`;
99
- collection[name] = plugin;
100
- return collection;
101
- }, {});
102
- for (const plugin of modelPlugins){
103
- const name = plugin.name || `${plugin.type}-${generateAlphaNumericId(16)}`;
104
- plugins[name] = plugin;
105
- }
106
114
  return createExecutableSchema({
107
- plugins: Object.values(plugins)
115
+ plugins: schemaPlugins
108
116
  });
109
117
  };
110
118
  const extractErrorObject = (error)=>[
@@ -1 +1 @@
1
- {"version":3,"file":"domain/contentModel/validation/modelFields.js","sources":["../../../../src/domain/contentModel/validation/modelFields.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { generateAlphaNumericId } from \"@webiny/utils\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsContext, CmsModel, CmsModelField } from \"~/types/index.js\";\nimport type { ValidateChildFieldsValidate } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js\";\nimport { createManageSDL } from \"~/graphql/schema/createManageSDL.js\";\nimport { createFieldStorageId } from \"../createFieldStorageId.js\";\nimport type { GraphQLError } from \"graphql\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType.js\";\nimport { getContentModelTitleFieldId } from \"./fields/titleField.js\";\nimport { getContentModelDescriptionFieldId } from \"./fields/descriptionField.js\";\nimport { getContentModelImageFieldId } from \"./fields/imageField.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { CmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins.js\";\nimport { createExecutableSchema } from \"~/graphql/createExecutableSchema.js\";\nimport {\n CmsGraphQLSchemaSorter,\n CmsModelFieldToGraphQLRegistry\n} from \"~/features/graphql/index.js\";\n\nconst extractInvalidField = (model: CmsModel, err: GraphQLError) => {\n const sdl = err.source?.body || \"\";\n\n /**\n * Find the invalid type\n */\n const { line: lineNumber } = err.locations\n ? err.locations[0]\n : {\n line: 0\n };\n const sdlLines = sdl.split(\"\\n\");\n let sdlLine;\n let gqlType;\n for (let i = lineNumber; i > 0; i--) {\n if (sdlLine && sdlLine.includes(\"type \")) {\n gqlType = sdlLine.match(/type\\s+(.*?)\\s+{/);\n break;\n }\n\n sdlLine = sdlLines[i];\n }\n\n let invalidField: string | undefined = undefined;\n if (Array.isArray(gqlType)) {\n const fieldRegex = new RegExp(`([^\\\\s+].*?):\\\\s+\\\\[?${gqlType[1]}!?\\\\]?`);\n\n const matched = sdl.match(fieldRegex);\n if (matched) {\n invalidField = matched[1];\n }\n }\n\n let message = `See more details in the browser console.`;\n if (invalidField) {\n message = `Please review the definition of \"${invalidField}\" field.`;\n }\n\n return {\n data: {\n modelId: model.modelId,\n sdl,\n invalidField\n },\n code: \"INVALID_MODEL_DEFINITION\",\n message: [`Model \"${model.modelId}\" was not saved!`, message].join(\"\\n\")\n };\n};\n\nconst createValidateChildFields = (\n registry: CmsModelFieldToGraphQLRegistry.Interface\n): ValidateChildFieldsValidate => {\n return ({ fields, originalFields }) => {\n if (fields.length === 0 && originalFields.length === 0) {\n return;\n }\n validateFields({\n fields,\n originalFields,\n registry\n });\n };\n};\n\ninterface ValidateFieldsParams {\n registry: CmsModelFieldToGraphQLRegistry.Interface;\n fields: CmsModelField[];\n originalFields: CmsModelField[];\n}\n\nconst validateFields = (params: ValidateFieldsParams) => {\n const { registry, fields, originalFields } = params;\n\n const idList: string[] = [];\n const fieldIdList: string[] = [];\n const storageIdList: string[] = [];\n\n for (const field of fields) {\n const baseType = getBaseFieldType(field);\n const fieldImpl = registry.get(baseType);\n\n if (!fieldImpl) {\n throw new Error(\n `Cannot update content model because of the unknown \"${baseType}\" field.`\n );\n }\n /**\n * Check the field's id against existing ones.\n * There cannot be two fields with the same id.\n */\n if (idList.includes(field.id)) {\n throw new WebinyError(\n `Cannot update content model because field \"${\n field.storageId || field.fieldId\n }\" has id \"${field.id}\", which is already used.`\n );\n }\n idList.push(field.id);\n\n const originalField = originalFields.find(f => f.id === field.id);\n /**\n * Field MUST have an fieldId defined.\n */\n if (!field.fieldId) {\n throw new WebinyError(`Field does not have an \"fieldId\" defined.`, \"MISSING_FIELD_ID\", {\n field\n });\n }\n /**\n * If storageId does not match a certain pattern, add that pattern, but only if field is not locked (used) already.\n * This is to avoid errors in the already installed systems.\n *\n * Why are we using the @?\n *\n * It is not part of special characters for the query syntax in the Lucene.\n *\n * Relevant links:\n * https://lucene.apache.org/core/3_4_0/queryparsersyntax.html\n * https://discuss.elastic.co/t/special-characters-in-field-names/10658/3\n * https://discuss.elastic.co/t/illegal-characters-in-elasticsearch-field-names/17196/2\n */\n if (!field.storageId) {\n /**\n * When having an original field, set the storageId to value from the originalField\n */\n if (originalField) {\n field.storageId = originalField.storageId;\n } else {\n field.storageId = createFieldStorageId(field);\n }\n }\n /**\n * Check the field's fieldId against existing ones.\n * There cannot be two fields with the same fieldId - outside world identifier.\n */\n if (fieldIdList.includes(field.fieldId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.storageId}\" has fieldId \"${field.fieldId}\", which is already used.`\n );\n }\n fieldIdList.push(field.fieldId);\n /**\n * Check the field's storageId against the existing ones.\n * There cannot be two fields with the same storageId.\n */\n if (storageIdList.includes(field.storageId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.label}\" has storageId \"${field.storageId}\", which is already used.`\n );\n }\n storageIdList.push(field.storageId);\n /**\n * There might be some plugins which allow child fields.\n * We use this method to validate them as well.\n */\n if (!fieldImpl.validateChildFields) {\n continue;\n }\n const validateChildFields = createValidateChildFields(registry);\n fieldImpl.validateChildFields({\n field,\n originalField,\n validate: validateChildFields\n });\n }\n};\n\ninterface CreateGraphQLSchemaParams {\n context: CmsContext;\n model: CmsModel;\n}\n\nconst createGraphQLSchema = async (params: CreateGraphQLSchemaParams): Promise<any> => {\n const { context, model } = params;\n\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter((model): model is CmsModel => {\n return model.isPrivate !== true;\n });\n });\n\n const modelPlugins = await buildSchemaPlugins({\n context,\n /**\n * Must remove the current model from the list, as we are possibly updating it - there would be two if we didn't.\n */\n models: models.filter(m => m.modelId !== model.modelId).concat([model])\n });\n\n const plugins = context.plugins\n .byType<ICmsGraphQLSchemaPlugin>(CmsGraphQLSchemaPlugin.type)\n .filter(plugin => plugin.isApplicable(context))\n .reduce<Record<string, ICmsGraphQLSchemaPlugin>>((collection, plugin) => {\n const name =\n plugin.name || `${CmsGraphQLSchemaPlugin.type}-${generateAlphaNumericId(16)}`;\n collection[name] = plugin;\n return collection;\n }, {});\n for (const plugin of modelPlugins) {\n const name = plugin.name || `${plugin.type}-${generateAlphaNumericId(16)}`;\n plugins[name] = plugin;\n }\n\n return createExecutableSchema({\n plugins: Object.values(plugins)\n });\n};\n\nconst extractErrorObject = (error: any) => {\n return [\"message\", \"code\", \"data\", \"stack\"].reduce<Record<string, any>>((output, key) => {\n if (!error[key]) {\n return output;\n }\n output[key] = error[key];\n return output;\n }, {});\n};\n\ninterface ValidateModelFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModelFields = async (params: ValidateModelFieldsParams): Promise<void> => {\n const { models, model, original, context } = params;\n const { titleFieldId, descriptionFieldId, imageFieldId } = model;\n\n /**\n * There should be fields/locked fields in either model or data to be updated.\n */\n const { fields = [] } = model;\n\n /**\n * Let's inspect the fields of the received content model. We prevent saving of a content model if it\n * contains a field for which a \"cms-model-field-to-graphql\" plugin does not exist on the backend.\n */\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n const sorters = context.container.resolveAll(CmsGraphQLSchemaSorter);\n\n validateFields({\n fields,\n originalFields: original?.fields || [],\n registry: fieldRegistry\n });\n\n if (fields.length) {\n /**\n * Make sure that this model can be safely converted to a GraphQL SDL\n */\n const schema = createManageSDL({\n models,\n model,\n fieldRegistry,\n sorters\n });\n\n try {\n gql(schema);\n } catch (err) {\n throw new WebinyError(extractInvalidField(model, err));\n }\n /**\n *\n */\n try {\n await createGraphQLSchema({\n context,\n model\n });\n } catch (err) {\n throw new WebinyError({\n message:\n \"Cannot generate GraphQL schema when testing with the given model. Please check the response for more details.\",\n code: \"GRAPHQL_SCHEMA_ERROR\",\n data: {\n modelId: model.modelId,\n error: extractErrorObject(err)\n }\n });\n }\n }\n\n model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n model.descriptionFieldId = getContentModelDescriptionFieldId(fields, descriptionFieldId);\n model.imageFieldId = getContentModelImageFieldId(fields, imageFieldId);\n};\n"],"names":["extractInvalidField","model","err","sdl","lineNumber","sdlLines","sdlLine","gqlType","i","invalidField","Array","fieldRegex","RegExp","matched","message","createValidateChildFields","registry","fields","originalFields","validateFields","params","idList","fieldIdList","storageIdList","field","baseType","getBaseFieldType","fieldImpl","Error","WebinyError","originalField","f","createFieldStorageId","validateChildFields","createGraphQLSchema","context","models","modelPlugins","buildSchemaPlugins","m","plugins","CmsGraphQLSchemaPlugin","plugin","collection","name","generateAlphaNumericId","createExecutableSchema","Object","extractErrorObject","error","output","key","validateModelFields","original","titleFieldId","descriptionFieldId","imageFieldId","fieldRegistry","CmsModelFieldToGraphQLRegistry","sorters","CmsGraphQLSchemaSorter","schema","createManageSDL","gql","getContentModelTitleFieldId","getContentModelDescriptionFieldId","getContentModelImageFieldId"],"mappings":";;;;;;;;;;;;;AAqBA,MAAMA,sBAAsB,CAACC,OAAiBC;IAC1C,MAAMC,MAAMD,IAAI,MAAM,EAAE,QAAQ;IAKhC,MAAM,EAAE,MAAME,UAAU,EAAE,GAAGF,IAAI,SAAS,GACpCA,IAAI,SAAS,CAAC,EAAE,GAChB;QACI,MAAM;IACV;IACN,MAAMG,WAAWF,IAAI,KAAK,CAAC;IAC3B,IAAIG;IACJ,IAAIC;IACJ,IAAK,IAAIC,IAAIJ,YAAYI,IAAI,GAAGA,IAAK;QACjC,IAAIF,WAAWA,QAAQ,QAAQ,CAAC,UAAU;YACtCC,UAAUD,QAAQ,KAAK,CAAC;YACxB;QACJ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C,eAAe;QACXF;QACA,gBAAgBoC,UAAU,UAAU,EAAE;QACtC,UAAUI;IACd;IAEA,IAAIxC,OAAO,MAAM,EAAE;QAIf,MAAM4C,SAASC,gBAAgB;YAC3B1B;YACAnC;YACAwD;YACAE;QACJ;QAEA,IAAI;YACAI,YAAIF;QACR,EAAE,OAAO3D,KAAK;YACV,MAAM,IAAI2B,cAAY7B,oBAAoBC,OAAOC;QACrD;QAIA,IAAI;YACA,MAAMgC,oBAAoB;gBACtBC;gBACAlC;YACJ;QACJ,EAAE,OAAOC,KAAK;YACV,MAAM,IAAI2B,cAAY;gBAClB,SACI;gBACJ,MAAM;gBACN,MAAM;oBACF,SAAS5B,MAAM,OAAO;oBACtB,OAAO+C,mBAAmB9C;gBAC9B;YACJ;QACJ;IACJ;IAEAD,MAAM,YAAY,GAAG+D,4BAA4B/C,QAAQqC;IACzDrD,MAAM,kBAAkB,GAAGgE,kCAAkChD,QAAQsC;IACrEtD,MAAM,YAAY,GAAGiE,4BAA4BjD,QAAQuC;AAC7D"}
1
+ {"version":3,"file":"domain/contentModel/validation/modelFields.js","sources":["../../../../src/domain/contentModel/validation/modelFields.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport WebinyError from \"@webiny/error\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\nimport type { CmsContext, CmsModel, CmsModelField } from \"~/types/index.js\";\nimport type { ValidateChildFieldsValidate } from \"~/features/graphql/fields/abstractions/CmsModelFieldToGraphQL.js\";\nimport { createManageSDL } from \"~/graphql/schema/createManageSDL.js\";\nimport { createFieldStorageId } from \"../createFieldStorageId.js\";\nimport type { GraphQLError } from \"graphql\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType.js\";\nimport { getContentModelTitleFieldId } from \"./fields/titleField.js\";\nimport { getContentModelDescriptionFieldId } from \"./fields/descriptionField.js\";\nimport { getContentModelImageFieldId } from \"./fields/imageField.js\";\nimport { validateDateExpressions } from \"./dateExpressions.js\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins.js\";\nimport { HeadlessCmsEndpointConfig } from \"~/HeadlessCmsEndpointConfig.js\";\nimport { CmsGraphQLSchemaFactory } from \"~/graphql/CmsGraphQLSchemaFactory.js\";\nimport { createExecutableSchema } from \"~/graphql/createExecutableSchema.js\";\nimport {\n CmsGraphQLSchemaSorter,\n CmsModelFieldToGraphQLRegistry\n} from \"~/features/graphql/index.js\";\n\nconst extractInvalidField = (model: CmsModel, err: GraphQLError) => {\n const sdl = err.source?.body || \"\";\n\n /**\n * Find the invalid type\n */\n const { line: lineNumber } = err.locations\n ? err.locations[0]\n : {\n line: 0\n };\n const sdlLines = sdl.split(\"\\n\");\n let sdlLine;\n let gqlType;\n for (let i = lineNumber; i > 0; i--) {\n if (sdlLine && sdlLine.includes(\"type \")) {\n gqlType = sdlLine.match(/type\\s+(.*?)\\s+{/);\n break;\n }\n\n sdlLine = sdlLines[i];\n }\n\n let invalidField: string | undefined = undefined;\n if (Array.isArray(gqlType)) {\n const fieldRegex = new RegExp(`([^\\\\s+].*?):\\\\s+\\\\[?${gqlType[1]}!?\\\\]?`);\n\n const matched = sdl.match(fieldRegex);\n if (matched) {\n invalidField = matched[1];\n }\n }\n\n let message = `See more details in the browser console.`;\n if (invalidField) {\n message = `Please review the definition of \"${invalidField}\" field.`;\n }\n\n return {\n data: {\n modelId: model.modelId,\n sdl,\n invalidField\n },\n code: \"INVALID_MODEL_DEFINITION\",\n message: [`Model \"${model.modelId}\" was not saved!`, message].join(\"\\n\")\n };\n};\n\nconst createValidateChildFields = (\n registry: CmsModelFieldToGraphQLRegistry.Interface\n): ValidateChildFieldsValidate => {\n return ({ fields, originalFields }) => {\n if (fields.length === 0 && originalFields.length === 0) {\n return;\n }\n validateFields({\n fields,\n originalFields,\n registry\n });\n };\n};\n\ninterface ValidateFieldsParams {\n registry: CmsModelFieldToGraphQLRegistry.Interface;\n fields: CmsModelField[];\n originalFields: CmsModelField[];\n}\n\nconst validateFields = (params: ValidateFieldsParams) => {\n const { registry, fields, originalFields } = params;\n\n const idList: string[] = [];\n const fieldIdList: string[] = [];\n const storageIdList: string[] = [];\n\n for (const field of fields) {\n const baseType = getBaseFieldType(field);\n const fieldImpl = registry.get(baseType);\n\n if (!fieldImpl) {\n throw new Error(\n `Cannot update content model because of the unknown \"${baseType}\" field.`\n );\n }\n /**\n * Check the field's id against existing ones.\n * There cannot be two fields with the same id.\n */\n if (idList.includes(field.id)) {\n throw new WebinyError(\n `Cannot update content model because field \"${\n field.storageId || field.fieldId\n }\" has id \"${field.id}\", which is already used.`\n );\n }\n idList.push(field.id);\n\n const originalField = originalFields.find(f => f.id === field.id);\n /**\n * Field MUST have an fieldId defined.\n */\n if (!field.fieldId) {\n throw new WebinyError(`Field does not have an \"fieldId\" defined.`, \"MISSING_FIELD_ID\", {\n field\n });\n }\n /**\n * If storageId does not match a certain pattern, add that pattern, but only if field is not locked (used) already.\n * This is to avoid errors in the already installed systems.\n *\n * Why are we using the @?\n *\n * It is not part of special characters for the query syntax in the Lucene.\n *\n * Relevant links:\n * https://lucene.apache.org/core/3_4_0/queryparsersyntax.html\n * https://discuss.elastic.co/t/special-characters-in-field-names/10658/3\n * https://discuss.elastic.co/t/illegal-characters-in-elasticsearch-field-names/17196/2\n */\n if (!field.storageId) {\n /**\n * When having an original field, set the storageId to value from the originalField\n */\n if (originalField) {\n field.storageId = originalField.storageId;\n } else {\n field.storageId = createFieldStorageId(field);\n }\n }\n /**\n * Check the field's fieldId against existing ones.\n * There cannot be two fields with the same fieldId - outside world identifier.\n */\n if (fieldIdList.includes(field.fieldId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.storageId}\" has fieldId \"${field.fieldId}\", which is already used.`\n );\n }\n fieldIdList.push(field.fieldId);\n /**\n * Check the field's storageId against the existing ones.\n * There cannot be two fields with the same storageId.\n */\n if (storageIdList.includes(field.storageId)) {\n throw new WebinyError(\n `Cannot update content model because field \"${field.label}\" has storageId \"${field.storageId}\", which is already used.`\n );\n }\n storageIdList.push(field.storageId);\n\n validateDateExpressions(field);\n /**\n * There might be some plugins which allow child fields.\n * We use this method to validate them as well.\n */\n if (!fieldImpl.validateChildFields) {\n continue;\n }\n const validateChildFields = createValidateChildFields(registry);\n fieldImpl.validateChildFields({\n field,\n originalField,\n validate: validateChildFields\n });\n }\n};\n\ninterface CreateGraphQLSchemaParams {\n context: CmsContext;\n model: CmsModel;\n}\n\nconst createGraphQLSchema = async (params: CreateGraphQLSchemaParams): Promise<any> => {\n const { context, model } = params;\n\n const modelsResult = await context.container\n .resolve(IdentityContext)\n .withoutAuthorization(async () => {\n return context.container.resolve(ListModelsUseCase).execute();\n });\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value.filter(\n (model): model is CmsModel => model.isPrivate !== true\n );\n\n const generatedSchemaPlugins = await buildSchemaPlugins({\n context,\n /**\n * Must remove the current model from the list, as we are possibly updating it - there would be two if we didn't.\n */\n models: models.filter(m => m.modelId !== model.modelId).concat([model]),\n type: context.container.resolve(HeadlessCmsEndpointConfig).type\n });\n\n /**\n * The base CMS GraphQL types (CmsError, CmsIdentity, entry options, etc.) are provided\n * by the CmsGraphQLSchemaFactory implementations registered in the DI container — mirror\n * generateSchema() so model validation builds against the same complete type set.\n */\n const staticFactories = context.container.resolveAll(CmsGraphQLSchemaFactory);\n const staticPlugins: ICmsGraphQLSchemaPlugin[] = [];\n for (const factory of staticFactories) {\n staticPlugins.push(...(await factory.execute()));\n }\n\n const schemaPlugins = [...staticPlugins, ...generatedSchemaPlugins].filter(pl => {\n if (typeof pl.isApplicable === \"function\") {\n return pl.isApplicable(context);\n }\n return true;\n });\n\n return createExecutableSchema({ plugins: schemaPlugins });\n};\n\nconst extractErrorObject = (error: any) => {\n return [\"message\", \"code\", \"data\", \"stack\"].reduce<Record<string, any>>((output, key) => {\n if (!error[key]) {\n return output;\n }\n output[key] = error[key];\n return output;\n }, {});\n};\n\ninterface ValidateModelFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModelFields = async (params: ValidateModelFieldsParams): Promise<void> => {\n const { models, model, original, context } = params;\n const { titleFieldId, descriptionFieldId, imageFieldId } = model;\n\n /**\n * There should be fields/locked fields in either model or data to be updated.\n */\n const { fields = [] } = model;\n\n /**\n * Let's inspect the fields of the received content model. We prevent saving of a content model if it\n * contains a field for which a \"cms-model-field-to-graphql\" plugin does not exist on the backend.\n */\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n const sorters = context.container.resolveAll(CmsGraphQLSchemaSorter);\n\n validateFields({\n fields,\n originalFields: original?.fields || [],\n registry: fieldRegistry\n });\n\n if (fields.length) {\n /**\n * Make sure that this model can be safely converted to a GraphQL SDL\n */\n const schema = createManageSDL({\n models,\n model,\n fieldRegistry,\n sorters\n });\n\n try {\n gql(schema);\n } catch (err) {\n throw new WebinyError(extractInvalidField(model, err));\n }\n /**\n *\n */\n try {\n await createGraphQLSchema({\n context,\n model\n });\n } catch (err) {\n throw new WebinyError({\n message:\n \"Cannot generate GraphQL schema when testing with the given model. Please check the response for more details.\",\n code: \"GRAPHQL_SCHEMA_ERROR\",\n data: {\n modelId: model.modelId,\n error: extractErrorObject(err)\n }\n });\n }\n }\n\n model.titleFieldId = getContentModelTitleFieldId(fields, titleFieldId);\n model.descriptionFieldId = getContentModelDescriptionFieldId(fields, descriptionFieldId);\n model.imageFieldId = getContentModelImageFieldId(fields, imageFieldId);\n};\n"],"names":["extractInvalidField","model","err","sdl","lineNumber","sdlLines","sdlLine","gqlType","i","invalidField","Array","fieldRegex","RegExp","matched","message","createValidateChildFields","registry","fields","originalFields","validateFields","params","idList","fieldIdList","storageIdList","field","baseType","getBaseFieldType","fieldImpl","Error","WebinyError","originalField","f","createFieldStorageId","validateDateExpressions","validateChildFields","createGraphQLSchema","context","modelsResult","IdentityContext","ListModelsUseCase","models","generatedSchemaPlugins","buildSchemaPlugins","m","HeadlessCmsEndpointConfig","staticFactories","CmsGraphQLSchemaFactory","staticPlugins","factory","schemaPlugins","pl","createExecutableSchema","extractErrorObject","error","output","key","validateModelFields","original","titleFieldId","descriptionFieldId","imageFieldId","fieldRegistry","CmsModelFieldToGraphQLRegistry","sorters","CmsGraphQLSchemaSorter","schema","createManageSDL","gql","getContentModelTitleFieldId","getContentModelDescriptionFieldId","getContentModelImageFieldId"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAMA,sBAAsB,CAACC,OAAiBC;IAC1C,MAAMC,MAAMD,IAAI,MAAM,EAAE,QAAQ;IAKhC,MAAM,EAAE,MAAME,UAAU,EAAE,GAAGF,IAAI,SAAS,GACpCA,IAAI,SAAS,CAAC,EAAE,GAChB;QACI,MAAM;IACV;IACN,MAAMG,WAAWF,IAAI,KAAK,CAAC;IAC3B,IAAIG;IACJ,IAAIC;IACJ,IAAK,IAAIC,IAAIJ,YAAYI,IAAI,GAAGA,IAAK;QACjC,IAAIF,WAAWA,QAAQ,QAAQ,CAAC,UAAU;YACtCC,UAAUD,QAAQ,KAAK,CAAC;YACxB;QACJ;QAEAA,UAAUD,QAAQ,CAACG,EAAE;IACzB;IAEA,IAAIC;IACJ,IAAIC,MAAM,OAAO,CAACH,UAAU;QACxB,MAAMI,aAAa,IAAIC,OAAO,CAAC,qBAAqB,EAAEL,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC;QAExE,MAAMM,UAAUV,IAAI,KAAK,CAACQ;QAC1B,IAAIE,SACAJ,eAAeI,OAAO,CAAC,EAAE;IAEjC;IAEA,IAAIC,UAAU;IACd,IAAIL,cACAK,UAAU,CAAC,iCAAiC,EAAEL,aAAa,QAAQ,CAAC;IAGxE,OAAO;QACH,MAAM;YACF,SAASR,MAAM,OAAO;YACtBE;YACAM;QACJ;QACA,MAAM;QACN,SAAS;YAAC,CAAC,OAAO,EAAER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AAmBlD;gBAC9B;YACJ;QACJ;IACJ;IAEAD,MAAM,YAAY,GAAGmE,4BAA4BnD,QAAQyC;IACzDzD,MAAM,kBAAkB,GAAGoE,kCAAkCpD,QAAQ0C;IACrE1D,MAAM,YAAY,GAAGqE,4BAA4BrD,QAAQ2C;AAC7D"}
@@ -0,0 +1,9 @@
1
+ import type { HeadlessCmsExport, HeadlessCmsImport } from "./types.js";
2
+ export declare const CmsExport: import("@webiny/di").Abstraction<HeadlessCmsExport>;
3
+ export declare namespace CmsExport {
4
+ type Interface = HeadlessCmsExport;
5
+ }
6
+ export declare const CmsImport: import("@webiny/di").Abstraction<HeadlessCmsImport>;
7
+ export declare namespace CmsImport {
8
+ type Interface = HeadlessCmsImport;
9
+ }
@@ -0,0 +1,6 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const CmsExport = createAbstraction("CmsExport");
3
+ const CmsImport = createAbstraction("CmsImport");
4
+ export { CmsExport, CmsImport };
5
+
6
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export/abstractions.js","sources":["../../src/export/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { HeadlessCmsExport, HeadlessCmsImport } from \"./types.js\";\n\nexport const CmsExport = createAbstraction<HeadlessCmsExport>(\"CmsExport\");\n\nexport namespace CmsExport {\n export type Interface = HeadlessCmsExport;\n}\n\nexport const CmsImport = createAbstraction<HeadlessCmsImport>(\"CmsImport\");\n\nexport namespace CmsImport {\n export type Interface = HeadlessCmsImport;\n}\n"],"names":["CmsExport","createAbstraction","CmsImport"],"mappings":";AAGO,MAAMA,YAAYC,kBAAqC;AAMvD,MAAMC,YAAYD,kBAAqC"}
@@ -1,8 +1,14 @@
1
1
  import { sanitizeGroup, sanitizeModel } from "./sanitize.js";
2
+ import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
3
+ import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
2
4
  const createExportStructureContext = (context)=>async (params)=>{
3
5
  const { models: modelIdList } = params;
4
- const groups = (await context.cms.listGroups()).map(sanitizeGroup);
5
- const models = (await context.cms.listModels()).filter((model)=>{
6
+ const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();
7
+ if (groupsResult.isFail()) throw groupsResult.error;
8
+ const groups = groupsResult.value.map(sanitizeGroup);
9
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
10
+ if (modelsResult.isFail()) throw modelsResult.error;
11
+ const models = modelsResult.value.filter((model)=>{
6
12
  if (model.isPrivate) return false;
7
13
  if (!model.fields?.length) return false;
8
14
  if (!modelIdList?.length) return true;
@@ -1 +1 @@
1
- {"version":3,"file":"export/crud/exporting.js","sources":["../../../src/export/crud/exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize.js\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n const groups = (await context.cms.listGroups()).map(sanitizeGroup);\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\n */\n const models = (await context.cms.listModels())\n .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.slug === model.group);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.slug);\n }),\n models\n };\n };\n};\n"],"names":["createExportStructureContext","context","params","modelIdList","groups","sanitizeGroup","models","model","group","sanitizeModel"],"mappings":";AAIO,MAAMA,+BAA+B,CAACC,UAClC,OAAMC;QACT,MAAM,EAAE,QAAQC,WAAW,EAAE,GAAGD;QAChC,MAAME,SAAU,OAAMH,QAAQ,GAAG,CAAC,UAAU,EAAC,EAAG,GAAG,CAACI;QAQpD,MAAMC,SAAU,OAAML,QAAQ,GAAG,CAAC,UAAU,EAAC,EACxC,MAAM,CAACM,CAAAA;YACJ,IAAIA,MAAM,SAAS,EACf,OAAO;YACJ,IAAI,CAACA,MAAM,MAAM,EAAE,QACtB,OAAO;YACJ,IAAI,CAACJ,aAAa,QACrB,OAAO;YAEX,OAAOA,YAAY,QAAQ,CAACI,MAAM,OAAO;QAC7C,GACC,GAAG,CAACA,CAAAA;YACD,MAAMC,QAAQJ,OAAO,IAAI,CAACI,CAAAA,QAASA,MAAM,IAAI,KAAKD,MAAM,KAAK;YAC7D,IAAI,CAACC,OACD,OAAO;YAEX,OAAOC,cAAcD,OAAOD;QAChC,GACC,MAAM,CAAC,CAACA,QACE,CAAC,CAACA;QAGjB,OAAO;YACH,QAAQH,OAAO,MAAM,CAACI,CAAAA,QACXF,OAAO,IAAI,CAACC,CAAAA,QAASA,MAAM,KAAK,KAAKC,MAAM,IAAI;YAE1DF;QACJ;IACJ"}
1
+ {"version":3,"file":"export/crud/exporting.js","sources":["../../../src/export/crud/exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n\n const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();\n if (groupsResult.isFail()) {\n throw groupsResult.error;\n }\n const groups = groupsResult.value.map(sanitizeGroup);\n\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\n */\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n const models = modelsResult.value\n .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.slug === model.group);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.slug);\n }),\n models\n };\n };\n};\n"],"names":["createExportStructureContext","context","params","modelIdList","groupsResult","ListGroupsUseCase","groups","sanitizeGroup","modelsResult","ListModelsUseCase","models","model","group","sanitizeModel"],"mappings":";;;AAMO,MAAMA,+BAA+B,CAACC,UAClC,OAAMC;QACT,MAAM,EAAE,QAAQC,WAAW,EAAE,GAAGD;QAEhC,MAAME,eAAe,MAAMH,QAAQ,SAAS,CAAC,OAAO,CAACI,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,MAAME,SAASF,aAAa,KAAK,CAAC,GAAG,CAACG;QAStC,MAAMC,eAAe,MAAMP,QAAQ,SAAS,CAAC,OAAO,CAACQ,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,MAAME,SAASF,aAAa,KAAK,CAC5B,MAAM,CAACG,CAAAA;YACJ,IAAIA,MAAM,SAAS,EACf,OAAO;YACJ,IAAI,CAACA,MAAM,MAAM,EAAE,QACtB,OAAO;YACJ,IAAI,CAACR,aAAa,QACrB,OAAO;YAEX,OAAOA,YAAY,QAAQ,CAACQ,MAAM,OAAO;QAC7C,GACC,GAAG,CAACA,CAAAA;YACD,MAAMC,QAAQN,OAAO,IAAI,CAACM,CAAAA,QAASA,MAAM,IAAI,KAAKD,MAAM,KAAK;YAC7D,IAAI,CAACC,OACD,OAAO;YAEX,OAAOC,cAAcD,OAAOD;QAChC,GACC,MAAM,CAAC,CAACA,QACE,CAAC,CAACA;QAGjB,OAAO;YACH,QAAQL,OAAO,MAAM,CAACM,CAAAA,QACXF,OAAO,IAAI,CAACC,CAAAA,QAASA,MAAM,KAAK,KAAKC,MAAM,IAAI;YAE1DF;QACJ;IACJ"}
@@ -1,10 +1,19 @@
1
1
  import _webiny_error from "@webiny/error";
2
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
2
3
  import { importData } from "./imports/importData.js";
3
4
  import { validateInput } from "./imports/validateInput.js";
4
- const fetchGroupsAndModels = async (context)=>await context.security.withoutAuthorization(async ()=>({
5
- groups: await context.cms.listGroups(),
6
- models: await context.cms.listModels()
7
- }));
5
+ import { ListGroupsUseCase } from "../../features/contentModelGroup/ListGroups/index.js";
6
+ import { ListModelsUseCase } from "../../features/contentModel/ListModels/index.js";
7
+ const fetchGroupsAndModels = async (context)=>await context.container.resolve(IdentityContext).withoutAuthorization(async ()=>{
8
+ const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();
9
+ if (groupsResult.isFail()) throw groupsResult.error;
10
+ const modelsResult = await context.container.resolve(ListModelsUseCase).execute();
11
+ if (modelsResult.isFail()) throw modelsResult.error;
12
+ return {
13
+ groups: groupsResult.value,
14
+ models: modelsResult.value
15
+ };
16
+ });
8
17
  const createImportCrud = (context)=>({
9
18
  validate: async (params)=>{
10
19
  const { data } = params;
@@ -1 +1 @@
1
- {"version":3,"file":"export/crud/importing.js","sources":["../../../src/export/crud/importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n HeadlessCmsImport,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { importData } from \"./imports/importData.js\";\nimport { validateInput } from \"./imports/validateInput.js\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.security.withoutAuthorization(async () => {\n return {\n groups: await context.cms.listGroups(),\n models: await context.cms.listModels()\n };\n });\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"names":["fetchGroupsAndModels","context","createImportCrud","params","data","groups","models","validated","validateInput","WebinyError","imported","importData","modelError","model","error"],"mappings":";;;AAUA,MAAMA,uBAAuB,OAAOC,UACzB,MAAMA,QAAQ,QAAQ,CAAC,oBAAoB,CAAC,UACxC;YACH,QAAQ,MAAMA,QAAQ,GAAG,CAAC,UAAU;YACpC,QAAQ,MAAMA,QAAQ,GAAG,CAAC,UAAU;QACxC;AAID,MAAMC,mBAAmB,CAACD,UACtB;QACH,UAAU,OAAME;YACZ,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMN,qBAAqBC;YAEtD,MAAMM,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAASA,UAAU,KAAK;YAC5B;YAGJ,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAAS;YACb;QACJ;QACA,WAAW,OAAMJ;YACb,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMN,qBAAqBC;YAEtD,MAAMM,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,MAAM,IAAIE,cAAYF,UAAU,KAAK,EAAE;YAG3C,MAAMG,WAAW,MAAMC,WAAW;gBAC9BV;gBACA,QAAQM,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;YAC5B;YAEA,MAAMK,aAAaF,SAAS,MAAM,CAAC,IAAI,CAACG,CAAAA,QAAS,CAAC,CAACA,MAAM,KAAK;YAC9D,MAAMC,QAAQJ,SAAS,KAAK,IAAIE;YAEhC,OAAO;gBACH,GAAGF,QAAQ;gBACX,SAASI,QAAQ,OAAO;YAC5B;QACJ;IACJ"}
1
+ {"version":3,"file":"export/crud/importing.js","sources":["../../../src/export/crud/importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport type {\n HeadlessCmsImport,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { importData } from \"./imports/importData.js\";\nimport { validateInput } from \"./imports/validateInput.js\";\nimport { ListGroupsUseCase } from \"~/features/contentModelGroup/ListGroups/index.js\";\nimport { ListModelsUseCase } from \"~/features/contentModel/ListModels/index.js\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.container.resolve(IdentityContext).withoutAuthorization(async () => {\n const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();\n if (groupsResult.isFail()) {\n throw groupsResult.error;\n }\n const modelsResult = await context.container.resolve(ListModelsUseCase).execute();\n if (modelsResult.isFail()) {\n throw modelsResult.error;\n }\n return {\n groups: groupsResult.value,\n models: modelsResult.value\n };\n });\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"names":["fetchGroupsAndModels","context","IdentityContext","groupsResult","ListGroupsUseCase","modelsResult","ListModelsUseCase","createImportCrud","params","data","groups","models","validated","validateInput","WebinyError","imported","importData","modelError","model","error"],"mappings":";;;;;;AAaA,MAAMA,uBAAuB,OAAOC,UACzB,MAAMA,QAAQ,SAAS,CAAC,OAAO,CAACC,iBAAiB,oBAAoB,CAAC;QACzE,MAAMC,eAAe,MAAMF,QAAQ,SAAS,CAAC,OAAO,CAACG,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,MAAME,eAAe,MAAMJ,QAAQ,SAAS,CAAC,OAAO,CAACK,mBAAmB,OAAO;QAC/E,IAAID,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;QAE5B,OAAO;YACH,QAAQF,aAAa,KAAK;YAC1B,QAAQE,aAAa,KAAK;QAC9B;IACJ;AAGG,MAAME,mBAAmB,CAACN,UACtB;QACH,UAAU,OAAMO;YACZ,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMX,qBAAqBC;YAEtD,MAAMW,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAASA,UAAU,KAAK;YAC5B;YAGJ,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAAS;YACb;QACJ;QACA,WAAW,OAAMJ;YACb,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMX,qBAAqBC;YAEtD,MAAMW,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,MAAM,IAAIE,cAAYF,UAAU,KAAK,EAAE;YAG3C,MAAMG,WAAW,MAAMC,WAAW;gBAC9Bf;gBACA,QAAQW,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;YAC5B;YAEA,MAAMK,aAAaF,SAAS,MAAM,CAAC,IAAI,CAACG,CAAAA,QAAS,CAAC,CAACA,MAAM,KAAK;YAC9D,MAAMC,QAAQJ,SAAS,KAAK,IAAIE;YAEhC,OAAO;gBACH,GAAGF,QAAQ;gBACX,SAASI,QAAQ,OAAO;YAC5B;QACJ;IACJ"}
@@ -1,4 +1,6 @@
1
1
  import { CmsImportAction } from "../../types.js";
2
+ import { CreateGroupUseCase } from "../../../features/contentModelGroup/CreateGroup/index.js";
3
+ import { UpdateGroupUseCase } from "../../../features/contentModelGroup/UpdateGroup/index.js";
2
4
  const importGroups = async (params)=>{
3
5
  const { context, groups } = params;
4
6
  const results = [];
@@ -21,20 +23,13 @@ const importGroups = async (params)=>{
21
23
  continue;
22
24
  }
23
25
  if (group.action === CmsImportAction.UPDATE) {
24
- try {
25
- const result = await context.cms.updateGroup(group.group.id, {
26
- ...group.group,
27
- icon: group.group.icon ?? void 0,
28
- description: group.group.description || void 0
29
- });
30
- results.push({
31
- action: group.action,
32
- group: {
33
- ...result
34
- },
35
- imported: true
36
- });
37
- } catch (ex) {
26
+ const updateResult = await context.container.resolve(UpdateGroupUseCase).execute(group.group.id, {
27
+ ...group.group,
28
+ icon: group.group.icon ?? void 0,
29
+ description: group.group.description || void 0
30
+ });
31
+ if (updateResult.isFail()) {
32
+ const ex = updateResult.error;
38
33
  results.push({
39
34
  action: group.action,
40
35
  group: group.group,
@@ -48,19 +43,18 @@ const importGroups = async (params)=>{
48
43
  }
49
44
  }
50
45
  });
51
- }
52
- continue;
53
- }
54
- try {
55
- const result = await context.cms.createGroup(group.group);
56
- results.push({
46
+ } else results.push({
57
47
  action: group.action,
58
48
  group: {
59
- ...result
49
+ ...updateResult.value
60
50
  },
61
51
  imported: true
62
52
  });
63
- } catch (ex) {
53
+ continue;
54
+ }
55
+ const createResult = await context.container.resolve(CreateGroupUseCase).execute(group.group);
56
+ if (createResult.isFail()) {
57
+ const ex = createResult.error;
64
58
  results.push({
65
59
  action: group.action,
66
60
  group: group.group,
@@ -74,7 +68,13 @@ const importGroups = async (params)=>{
74
68
  }
75
69
  }
76
70
  });
77
- }
71
+ } else results.push({
72
+ action: group.action,
73
+ group: {
74
+ ...createResult.value
75
+ },
76
+ imported: true
77
+ });
78
78
  }
79
79
  return results;
80
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"export/crud/imports/importGroups.js","sources":["../../../../src/export/crud/imports/importGroups.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsGroupImportResult, ValidCmsGroupResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n}\n\nexport const importGroups = async (params: Params) => {\n const { context, groups } = params;\n\n const results: CmsGroupImportResult[] = [];\n for (const group of groups) {\n if (group.action === CmsImportAction.NONE || group.error) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: group.error || {\n message: \"No action to be ran on the group.\",\n code: \"NO_ACTION\"\n }\n });\n }\n /**\n * Cannot update if the group is created via plugin.\n */\n if (group.action === CmsImportAction.CODE) {\n results.push({\n action: group.action,\n group: group.group,\n imported: true\n });\n continue;\n }\n /**\n * Update the group.\n */\n //\n else if (group.action === CmsImportAction.UPDATE) {\n try {\n const result = await context.cms.updateGroup(group.group.id, {\n ...group.group,\n icon: group.group.icon ?? undefined,\n description: group.group.description || undefined\n });\n results.push({\n action: group.action,\n group: {\n ...result\n },\n imported: true\n });\n } catch (ex) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: ex.code || \"UPDATE_GROUP_ERROR\",\n data: {\n ...ex.data,\n group\n }\n }\n });\n }\n continue;\n }\n /**\n * Create the group\n */\n //\n try {\n const result = await context.cms.createGroup(group.group);\n results.push({\n action: group.action,\n group: {\n ...result\n },\n imported: true\n });\n } catch (ex) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: ex.code || \"CREATE_GROUP_ERROR\",\n data: {\n ...ex.data,\n group\n }\n }\n });\n }\n }\n\n return results;\n};\n"],"names":["importGroups","params","context","groups","results","group","CmsImportAction","result","undefined","ex"],"mappings":";AASO,MAAMA,eAAe,OAAOC;IAC/B,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAE5B,MAAMG,UAAkC,EAAE;IAC1C,KAAK,MAAMC,SAASF,OAAQ;QACxB,IAAIE,MAAM,MAAM,KAAKC,gBAAgB,IAAI,IAAID,MAAM,KAAK,EACpDD,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAOA,MAAM,KAAK;YAClB,UAAU;YACV,OAAOA,MAAM,KAAK,IAAI;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,MAAM;wBACF,GAAGA,GAAG,IAAI;wBACVJ;oBACJ;gBACJ;YACJ;QACJ;IACJ;IAEA,OAAOD;AACX"}
1
+ {"version":3,"file":"export/crud/imports/importGroups.js","sources":["../../../../src/export/crud/imports/importGroups.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsGroupImportResult, ValidCmsGroupResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\nimport { CreateGroupUseCase } from \"~/features/contentModelGroup/CreateGroup/index.js\";\nimport { UpdateGroupUseCase } from \"~/features/contentModelGroup/UpdateGroup/index.js\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n}\n\nexport const importGroups = async (params: Params) => {\n const { context, groups } = params;\n\n const results: CmsGroupImportResult[] = [];\n for (const group of groups) {\n if (group.action === CmsImportAction.NONE || group.error) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: group.error || {\n message: \"No action to be ran on the group.\",\n code: \"NO_ACTION\"\n }\n });\n }\n /**\n * Cannot update if the group is created via plugin.\n */\n if (group.action === CmsImportAction.CODE) {\n results.push({\n action: group.action,\n group: group.group,\n imported: true\n });\n continue;\n }\n /**\n * Update the group.\n */\n //\n else if (group.action === CmsImportAction.UPDATE) {\n const updateResult = await context.container\n .resolve(UpdateGroupUseCase)\n .execute(group.group.id, {\n ...group.group,\n icon: group.group.icon ?? undefined,\n description: group.group.description || undefined\n });\n if (updateResult.isFail()) {\n const ex = updateResult.error;\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: (ex as any).code || \"UPDATE_GROUP_ERROR\",\n data: { ...(ex as any).data, group }\n }\n });\n } else {\n results.push({\n action: group.action,\n group: { ...updateResult.value },\n imported: true\n });\n }\n continue;\n }\n /**\n * Create the group\n */\n const createResult = await context.container\n .resolve(CreateGroupUseCase)\n .execute(group.group);\n if (createResult.isFail()) {\n const ex = createResult.error;\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: (ex as any).code || \"CREATE_GROUP_ERROR\",\n data: { ...(ex as any).data, group }\n }\n });\n } else {\n results.push({\n action: group.action,\n group: { ...createResult.value },\n imported: true\n });\n }\n }\n\n return results;\n};\n"],"names":["importGroups","params","context","groups","results","group","CmsImportAction","updateResult","UpdateGroupUseCase","undefined","ex","createResult","CreateGroupUseCase"],"mappings":";;;AAWO,MAAMA,eAAe,OAAOC;IAC/B,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAE5B,MAAMG,UAAkC,EAAE;IAC1C,KAAK,MAAMC,SAASF,OAAQ;QACxB,IAAIE,MAAM,MAAM,KAAKC,gBAAgB,IAAI,IAAID,MAAM,KAAK,EACpDD,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAOA,MAAM,KAAK;YAClB,UAAU;YACV,OAAOA,MAAM,KAAK,IAAI;gBAClB,SAAS;gBACT,MAAM;YACV;QACJ;QAKJ,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,IAAI,EAAE;YACvCF,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;YACd;YACA;QACJ;QAKK,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,MAAM,EAAE;YAC9C,MAAMC,eAAe,MAAML,QAAQ,SAAS,CACvC,OAAO,CAACM,oBACR,OAAO,CAACH,MAAM,KAAK,CAAC,EAAE,EAAE;gBACrB,GAAGA,MAAM,KAAK;gBACd,MAAMA,MAAM,KAAK,CAAC,IAAI,IAAII;gBAC1B,aAAaJ,MAAM,KAAK,CAAC,WAAW,IAAII;YAC5C;YACJ,IAAIF,aAAa,MAAM,IAAI;gBACvB,MAAMG,KAAKH,aAAa,KAAK;gBAC7BH,QAAQ,IAAI,CAAC;oBACT,QAAQC,MAAM,MAAM;oBACpB,OAAOA,MAAM,KAAK;oBAClB,UAAU;oBACV,OAAO;wBACH,SAASK,GAAG,OAAO;wBACnB,MAAOA,GAAW,IAAI,IAAI;wBAC1B,MAAM;4BAAE,GAAIA,GAAW,IAAI;4BAAEL;wBAAM;oBACvC;gBACJ;YACJ,OACID,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAO;oBAAE,GAAGE,aAAa,KAAK;gBAAC;gBAC/B,UAAU;YACd;YAEJ;QACJ;QAIA,MAAMI,eAAe,MAAMT,QAAQ,SAAS,CACvC,OAAO,CAACU,oBACR,OAAO,CAACP,MAAM,KAAK;QACxB,IAAIM,aAAa,MAAM,IAAI;YACvB,MAAMD,KAAKC,aAAa,KAAK;YAC7BP,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;gBACV,OAAO;oBACH,SAASK,GAAG,OAAO;oBACnB,MAAOA,GAAW,IAAI,IAAI;oBAC1B,MAAM;wBAAE,GAAIA,GAAW,IAAI;wBAAEL;oBAAM;gBACvC;YACJ;QACJ,OACID,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAO;gBAAE,GAAGM,aAAa,KAAK;YAAC;YAC/B,UAAU;QACd;IAER;IAEA,OAAOP;AACX"}
@@ -1,7 +1,12 @@
1
1
  import { CmsImportAction } from "../../types.js";
2
+ import { ListGroupsUseCase } from "../../../features/contentModelGroup/ListGroups/index.js";
3
+ import { UpdateModelUseCase } from "../../../features/contentModel/UpdateModel/index.js";
4
+ import { CreateModelUseCase } from "../../../features/contentModel/CreateModel/index.js";
2
5
  const importModels = async (params)=>{
3
6
  const { context, models } = params;
4
- const groups = await context.cms.listGroups();
7
+ const groupsResult = await context.container.resolve(ListGroupsUseCase).execute();
8
+ if (groupsResult.isFail()) throw groupsResult.error;
9
+ const groups = groupsResult.value;
5
10
  const results = [];
6
11
  for (const model of models){
7
12
  const group = groups.find((group)=>group.slug === model.model.group);
@@ -44,18 +49,9 @@ const importModels = async (params)=>{
44
49
  continue;
45
50
  }
46
51
  if (model.action === CmsImportAction.UPDATE) {
47
- try {
48
- const result = await context.cms.updateModel(model.model.modelId, model.model);
49
- results.push({
50
- action: model.action,
51
- model: {
52
- ...result,
53
- group: group.slug
54
- },
55
- related: model.related,
56
- imported: true
57
- });
58
- } catch (ex) {
52
+ const updateResult = await context.container.resolve(UpdateModelUseCase).execute(model.model.modelId, model.model);
53
+ if (updateResult.isFail()) {
54
+ const ex = updateResult.error;
59
55
  results.push({
60
56
  action: model.action,
61
57
  model: model.model,
@@ -70,21 +66,20 @@ const importModels = async (params)=>{
70
66
  }
71
67
  }
72
68
  });
73
- }
74
- continue;
75
- }
76
- try {
77
- const result = await context.cms.createModel(model.model);
78
- results.push({
69
+ } else results.push({
79
70
  action: model.action,
80
71
  model: {
81
- ...result,
72
+ ...updateResult.value,
82
73
  group: group.slug
83
74
  },
84
75
  related: model.related,
85
76
  imported: true
86
77
  });
87
- } catch (ex) {
78
+ continue;
79
+ }
80
+ const createResult = await context.container.resolve(CreateModelUseCase).execute(model.model);
81
+ if (createResult.isFail()) {
82
+ const ex = createResult.error;
88
83
  results.push({
89
84
  action: model.action,
90
85
  model: model.model,
@@ -99,7 +94,15 @@ const importModels = async (params)=>{
99
94
  }
100
95
  }
101
96
  });
102
- }
97
+ } else results.push({
98
+ action: model.action,
99
+ model: {
100
+ ...createResult.value,
101
+ group: group.slug
102
+ },
103
+ related: model.related,
104
+ imported: true
105
+ });
103
106
  }
104
107
  return results;
105
108
  };