@webiny/api-headless-cms 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (549) hide show
  1. package/HeadlessCmsFeature.js +17 -38
  2. package/HeadlessCmsFeature.js.map +1 -1
  3. package/createCmsRoute.d.ts +13 -10
  4. package/createCmsRoute.js +40 -18
  5. package/createCmsRoute.js.map +1 -1
  6. package/crud/contentEntry/entryDataValidation.js +44 -11
  7. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  8. package/crud/contentModel/defaultFields.js +3 -2
  9. package/crud/contentModel/defaultFields.js.map +1 -1
  10. package/crud/contentModel/validate/endingAllowed.js +1 -1
  11. package/crud/contentModel/validate/endingAllowed.js.map +1 -1
  12. package/crud/contentModel/validate/pluralApiName.js +1 -1
  13. package/crud/contentModel/validate/pluralApiName.js.map +1 -1
  14. package/crud/contentModel/validate/singularApiName.js +1 -1
  15. package/crud/contentModel/validate/singularApiName.js.map +1 -1
  16. package/crud/contentModel/validation.js +2 -2
  17. package/crud/contentModel/validation.js.map +1 -1
  18. package/domain/contentModel/schemas.d.ts +10 -6
  19. package/domain/contentModel/schemas.js +6 -3
  20. package/domain/contentModel/schemas.js.map +1 -1
  21. package/domain/contentModel/validation/dateExpressions.d.ts +6 -0
  22. package/domain/contentModel/validation/dateExpressions.js +27 -0
  23. package/domain/contentModel/validation/dateExpressions.js.map +1 -0
  24. package/domain/contentModel/validation/endingAllowed.js +1 -1
  25. package/domain/contentModel/validation/endingAllowed.js.map +1 -1
  26. package/domain/contentModel/validation/modelFields.js +4 -2
  27. package/domain/contentModel/validation/modelFields.js.map +1 -1
  28. package/domain/contentModel/validation/pluralApiName.js +1 -1
  29. package/domain/contentModel/validation/pluralApiName.js.map +1 -1
  30. package/domain/contentModel/validation/singularApiName.js +1 -1
  31. package/domain/contentModel/validation/singularApiName.js.map +1 -1
  32. package/export/crud/exporting.js +2 -2
  33. package/export/crud/exporting.js.map +1 -1
  34. package/export/crud/imports/importGroups.js +1 -2
  35. package/export/crud/imports/importGroups.js.map +1 -1
  36. package/export/crud/imports/validateModels.js +1 -1
  37. package/export/crud/imports/validateModels.js.map +1 -1
  38. package/exports/api/cms/entry.d.ts +5 -0
  39. package/exports/api/cms/entry.js +5 -0
  40. package/exports/api/cms/model.d.ts +4 -1
  41. package/exports/api/cms/model.js +2 -0
  42. package/features/ai/DescribeContentModelTool.d.ts +60 -0
  43. package/features/ai/DescribeContentModelTool.js +69 -0
  44. package/features/ai/DescribeContentModelTool.js.map +1 -0
  45. package/features/ai/ListContentModelsTool.d.ts +46 -0
  46. package/features/ai/ListContentModelsTool.js +53 -0
  47. package/features/ai/ListContentModelsTool.js.map +1 -0
  48. package/features/ai/QueryEntriesTool.d.ts +80 -0
  49. package/features/ai/QueryEntriesTool.js +99 -0
  50. package/features/ai/QueryEntriesTool.js.map +1 -0
  51. package/features/ai/feature.d.ts +8 -0
  52. package/features/ai/feature.js +15 -0
  53. package/features/ai/feature.js.map +1 -0
  54. package/features/ai/index.d.ts +4 -0
  55. package/features/ai/index.js +4 -0
  56. package/features/contentEntry/ContentEntriesFeature.js +8 -0
  57. package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
  58. package/features/contentEntry/CreateEntry/CreateEntryRepository.d.ts +4 -2
  59. package/features/contentEntry/CreateEntry/CreateEntryRepository.js +8 -3
  60. package/features/contentEntry/CreateEntry/CreateEntryRepository.js.map +1 -1
  61. package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +2 -2
  62. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +3 -4
  63. package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
  64. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.d.ts +4 -2
  65. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js +8 -3
  66. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromRepository.js.map +1 -1
  67. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.d.ts +2 -4
  68. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +6 -14
  69. package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
  70. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.d.ts +2 -0
  71. package/features/contentEntry/CreateEntryRevisionFrom/abstractions.js.map +1 -1
  72. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.d.ts +4 -2
  73. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js +8 -3
  74. package/features/contentEntry/DeleteEntry/DeleteEntryRepository.js.map +1 -1
  75. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.d.ts +2 -2
  76. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js +2 -2
  77. package/features/contentEntry/DeleteEntry/DeleteEntryUseCase.js.map +1 -1
  78. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.d.ts +3 -1
  79. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js +7 -3
  80. package/features/contentEntry/DeleteEntry/MoveEntryToBinRepository.js.map +1 -1
  81. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.d.ts +2 -2
  82. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +2 -2
  83. package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
  84. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.d.ts +3 -1
  85. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +9 -3
  86. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
  87. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.d.ts +2 -2
  88. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js +2 -2
  89. package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionUseCase.js.map +1 -1
  90. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.d.ts +4 -2
  91. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js +7 -3
  92. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesRepository.js.map +1 -1
  93. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.d.ts +2 -2
  94. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +11 -10
  95. package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
  96. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.d.ts +17 -0
  97. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js +83 -0
  98. package/features/contentEntry/DuplicateEntry/DuplicateEntryUseCase.js.map +1 -0
  99. package/features/contentEntry/DuplicateEntry/abstractions.d.ts +47 -0
  100. package/features/contentEntry/DuplicateEntry/abstractions.js +5 -0
  101. package/features/contentEntry/DuplicateEntry/abstractions.js.map +1 -0
  102. package/features/contentEntry/DuplicateEntry/events.d.ts +41 -0
  103. package/features/contentEntry/DuplicateEntry/events.js +32 -0
  104. package/features/contentEntry/DuplicateEntry/events.js.map +1 -0
  105. package/features/contentEntry/DuplicateEntry/feature.d.ts +4 -0
  106. package/features/contentEntry/DuplicateEntry/feature.js +11 -0
  107. package/features/contentEntry/DuplicateEntry/feature.js.map +1 -0
  108. package/features/contentEntry/DuplicateEntry/index.d.ts +2 -0
  109. package/features/contentEntry/DuplicateEntry/index.js +2 -0
  110. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.d.ts +7 -0
  111. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js +12 -0
  112. package/features/contentEntry/DuplicateEntry/prepareDuplicateValues.js.map +1 -0
  113. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.d.ts +10 -0
  114. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js +25 -0
  115. package/features/contentEntry/EntryEventPublisher/EntryEventPublisher.js.map +1 -0
  116. package/features/contentEntry/EntryEventPublisher/abstractions.d.ts +16 -0
  117. package/features/contentEntry/EntryEventPublisher/abstractions.js +5 -0
  118. package/features/contentEntry/EntryEventPublisher/abstractions.js.map +1 -0
  119. package/features/contentEntry/EntryEventPublisher/feature.d.ts +4 -0
  120. package/features/contentEntry/EntryEventPublisher/feature.js +11 -0
  121. package/features/contentEntry/EntryEventPublisher/feature.js.map +1 -0
  122. package/features/contentEntry/EntryEventPublisher/index.d.ts +2 -0
  123. package/features/contentEntry/EntryEventPublisher/index.js +2 -0
  124. package/features/contentEntry/EntrySystemField/abstractions.d.ts +14 -0
  125. package/features/contentEntry/EntrySystemField/abstractions.js +5 -0
  126. package/features/contentEntry/EntrySystemField/abstractions.js.map +1 -0
  127. package/features/contentEntry/EntrySystemField/index.d.ts +1 -0
  128. package/features/contentEntry/EntrySystemField/index.js +1 -0
  129. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.d.ts +4 -4
  130. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js +8 -11
  131. package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsRepository.js.map +1 -1
  132. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.d.ts +4 -2
  133. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js +7 -3
  134. package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsRepository.js.map +1 -1
  135. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.d.ts +4 -2
  136. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js +7 -3
  137. package/features/contentEntry/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdRepository.js.map +1 -1
  138. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.d.ts +4 -2
  139. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js +7 -3
  140. package/features/contentEntry/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdRepository.js.map +1 -1
  141. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.d.ts +4 -2
  142. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js +7 -3
  143. package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsRepository.js.map +1 -1
  144. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.d.ts +4 -2
  145. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js +7 -3
  146. package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdRepository.js.map +1 -1
  147. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.d.ts +4 -2
  148. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js +7 -3
  149. package/features/contentEntry/GetRevisionById/GetRevisionByIdRepository.js.map +1 -1
  150. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.d.ts +4 -2
  151. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js +7 -3
  152. package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdRepository.js.map +1 -1
  153. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.d.ts +4 -2
  154. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js +7 -3
  155. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesRepository.js.map +1 -1
  156. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +3 -0
  157. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
  158. package/features/contentEntry/ListEntries/ListEntriesRepository.d.ts +4 -2
  159. package/features/contentEntry/ListEntries/ListEntriesRepository.js +7 -3
  160. package/features/contentEntry/ListEntries/ListEntriesRepository.js.map +1 -1
  161. package/features/contentEntry/MoveEntry/MoveEntryRepository.d.ts +4 -2
  162. package/features/contentEntry/MoveEntry/MoveEntryRepository.js +7 -3
  163. package/features/contentEntry/MoveEntry/MoveEntryRepository.js.map +1 -1
  164. package/features/contentEntry/MoveEntry/MoveEntryUseCase.d.ts +2 -2
  165. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js +11 -4
  166. package/features/contentEntry/MoveEntry/MoveEntryUseCase.js.map +1 -1
  167. package/features/contentEntry/PublishEntry/PublishEntryRepository.d.ts +4 -2
  168. package/features/contentEntry/PublishEntry/PublishEntryRepository.js +8 -3
  169. package/features/contentEntry/PublishEntry/PublishEntryRepository.js.map +1 -1
  170. package/features/contentEntry/PublishEntry/PublishEntryUseCase.d.ts +4 -6
  171. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js +11 -13
  172. package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
  173. package/features/contentEntry/PublishEntry/abstractions.d.ts +8 -1
  174. package/features/contentEntry/PublishEntry/abstractions.js.map +1 -1
  175. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.d.ts +4 -2
  176. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js +8 -3
  177. package/features/contentEntry/RepublishEntry/RepublishEntryRepository.js.map +1 -1
  178. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.d.ts +2 -2
  179. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js +5 -3
  180. package/features/contentEntry/RepublishEntry/RepublishEntryUseCase.js.map +1 -1
  181. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.d.ts +4 -2
  182. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js +8 -3
  183. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinRepository.js.map +1 -1
  184. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.d.ts +2 -2
  185. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js +2 -2
  186. package/features/contentEntry/RestoreEntryFromBin/RestoreEntryFromBinUseCase.js.map +1 -1
  187. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.d.ts +4 -2
  188. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js +8 -3
  189. package/features/contentEntry/UnpublishEntry/UnpublishEntryRepository.js.map +1 -1
  190. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.d.ts +2 -2
  191. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js +5 -3
  192. package/features/contentEntry/UnpublishEntry/UnpublishEntryUseCase.js.map +1 -1
  193. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.d.ts +4 -2
  194. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js +8 -3
  195. package/features/contentEntry/UpdateEntry/UpdateEntryRepository.js.map +1 -1
  196. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.d.ts +2 -2
  197. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +5 -3
  198. package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
  199. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.d.ts +19 -0
  200. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js +70 -0
  201. package/features/contentEntry/UpdateEntrySystem/UpdateEntrySystemUseCase.js.map +1 -0
  202. package/features/contentEntry/UpdateEntrySystem/abstractions.d.ts +24 -0
  203. package/features/contentEntry/UpdateEntrySystem/abstractions.js +5 -0
  204. package/features/contentEntry/UpdateEntrySystem/abstractions.js.map +1 -0
  205. package/features/contentEntry/UpdateEntrySystem/events.d.ts +29 -0
  206. package/features/contentEntry/UpdateEntrySystem/events.js +23 -0
  207. package/features/contentEntry/UpdateEntrySystem/events.js.map +1 -0
  208. package/features/contentEntry/UpdateEntrySystem/feature.d.ts +4 -0
  209. package/features/contentEntry/UpdateEntrySystem/feature.js +11 -0
  210. package/features/contentEntry/UpdateEntrySystem/feature.js.map +1 -0
  211. package/features/contentEntry/UpdateEntrySystem/index.d.ts +2 -0
  212. package/features/contentEntry/UpdateEntrySystem/index.js +2 -0
  213. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +2 -2
  214. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -2
  215. package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
  216. package/features/contentEntry/ensureItemIds.d.ts +13 -0
  217. package/features/contentEntry/ensureItemIds.js +22 -0
  218. package/features/contentEntry/ensureItemIds.js.map +1 -0
  219. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
  220. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +8 -2
  221. package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
  222. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +7 -3
  223. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +46 -13
  224. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
  225. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.d.ts +17 -1
  226. package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/abstractions.js.map +1 -1
  227. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.d.ts +5 -3
  228. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js +22 -15
  229. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/CreatePublishEntryDataFactory.js.map +1 -1
  230. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.d.ts +15 -1
  231. package/features/contentEntry/entryDataFactories/CreatePublishEntryDataFactory/abstractions.js.map +1 -1
  232. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.d.ts +5 -3
  233. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js +17 -12
  234. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/CreateRepublishEntryDataFactory.js.map +1 -1
  235. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.d.ts +13 -1
  236. package/features/contentEntry/entryDataFactories/CreateRepublishEntryDataFactory/abstractions.js.map +1 -1
  237. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.d.ts +6 -6
  238. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js +17 -17
  239. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/CreateUnpublishEntryDataFactory.js.map +1 -1
  240. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.d.ts +14 -2
  241. package/features/contentEntry/entryDataFactories/CreateUnpublishEntryDataFactory/abstractions.js.map +1 -1
  242. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +7 -3
  243. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +72 -28
  244. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
  245. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.d.ts +15 -1
  246. package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/abstractions.js.map +1 -1
  247. package/features/contentEntry/entryDataFactories/expiresAt.js +2 -2
  248. package/features/contentEntry/entryDataFactories/expiresAt.js.map +1 -1
  249. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.d.ts +24 -0
  250. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js +13 -0
  251. package/features/contentEntry/entryDataFactories/hasEntryContentChanged.js.map +1 -0
  252. package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.d.ts +14 -0
  253. package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js +32 -0
  254. package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js.map +1 -0
  255. package/features/contentModel/ComponentMapGenerator/abstractions.d.ts +8 -0
  256. package/features/contentModel/ComponentMapGenerator/abstractions.js +5 -0
  257. package/features/contentModel/ComponentMapGenerator/abstractions.js.map +1 -0
  258. package/features/contentModel/ComponentMapGenerator/feature.d.ts +4 -0
  259. package/features/contentModel/ComponentMapGenerator/feature.js +11 -0
  260. package/features/contentModel/ComponentMapGenerator/feature.js.map +1 -0
  261. package/features/contentModel/ComponentMapGenerator/index.d.ts +2 -0
  262. package/features/contentModel/ComponentMapGenerator/index.js +2 -0
  263. package/features/contentModel/ContentModelFeature.js +4 -0
  264. package/features/contentModel/ContentModelFeature.js.map +1 -1
  265. package/features/contentModel/CreateModel/CreateModelRepository.js +1 -2
  266. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  267. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +1 -2
  268. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  269. package/features/contentModel/DeleteModel/DeleteModelRepository.d.ts +4 -2
  270. package/features/contentModel/DeleteModel/DeleteModelRepository.js +7 -3
  271. package/features/contentModel/DeleteModel/DeleteModelRepository.js.map +1 -1
  272. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.d.ts +9 -4
  273. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js +36 -21
  274. package/features/contentModel/DeleteModel/DeleteModelWithEntryCleanup.js.map +1 -1
  275. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.d.ts +1 -1
  276. package/features/contentModel/ModelToAstConverter/ModelToAstConverter.js.map +1 -1
  277. package/features/contentModel/ModelToAstConverter/abstractions.d.ts +1 -1
  278. package/features/contentModel/ModelToAstConverter/abstractions.js.map +1 -1
  279. package/features/contentModel/RefModelsGenerator/RefModelsGenerator.d.ts +19 -0
  280. package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js +56 -0
  281. package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js.map +1 -0
  282. package/features/contentModel/RefModelsGenerator/abstractions.d.ts +11 -0
  283. package/features/contentModel/RefModelsGenerator/abstractions.js +5 -0
  284. package/features/contentModel/RefModelsGenerator/abstractions.js.map +1 -0
  285. package/features/contentModel/RefModelsGenerator/feature.d.ts +4 -0
  286. package/features/contentModel/RefModelsGenerator/feature.js +11 -0
  287. package/features/contentModel/RefModelsGenerator/feature.js.map +1 -0
  288. package/features/contentModel/RefModelsGenerator/index.d.ts +2 -0
  289. package/features/contentModel/RefModelsGenerator/index.js +2 -0
  290. package/features/contentModel/UpdateModel/UpdateModelRepository.d.ts +4 -2
  291. package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -4
  292. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  293. package/features/contentModel/UpdateModel/UpdateModelUseCase.js +2 -2
  294. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  295. package/features/contentModel/UpdateModel/abstractions.d.ts +1 -1
  296. package/features/contentModel/UpdateModel/abstractions.js.map +1 -1
  297. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +5 -2
  298. package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -1
  299. package/features/contentModel/shared/ModelsFetcher.d.ts +6 -5
  300. package/features/contentModel/shared/ModelsFetcher.js.map +1 -1
  301. package/features/contentModel/shared/PluginModelsProvider.d.ts +6 -3
  302. package/features/contentModel/shared/PluginModelsProvider.js +2 -9
  303. package/features/contentModel/shared/PluginModelsProvider.js.map +1 -1
  304. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.d.ts +3 -1
  305. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js +6 -4
  306. package/features/contentModelGroup/CreateGroup/CreateGroupRepository.js.map +1 -1
  307. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.d.ts +4 -2
  308. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js +7 -3
  309. package/features/contentModelGroup/DeleteGroup/DeleteGroupRepository.js.map +1 -1
  310. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.d.ts +4 -2
  311. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js +8 -4
  312. package/features/contentModelGroup/UpdateGroup/UpdateGroupRepository.js.map +1 -1
  313. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -2
  314. package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
  315. package/features/contentModelGroup/UpdateGroup/abstractions.d.ts +1 -1
  316. package/features/contentModelGroup/UpdateGroup/abstractions.js.map +1 -1
  317. package/features/graphql/feature.js +2 -0
  318. package/features/graphql/feature.js.map +1 -1
  319. package/features/graphql/fields/base/AssetToGraphQL.d.ts +26 -0
  320. package/features/graphql/fields/base/AssetToGraphQL.js +153 -0
  321. package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -0
  322. package/features/graphql/fields/base/DynamicZoneToGraphQL.js +12 -2
  323. package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
  324. package/features/graphql/fields/base/ObjectToGraphQL.js +8 -5
  325. package/features/graphql/fields/base/ObjectToGraphQL.js.map +1 -1
  326. package/features/graphql/fields/base/RefToGraphQL.js +24 -10
  327. package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
  328. package/features/modelBuilder/abstractions.d.ts +13 -0
  329. package/features/modelBuilder/abstractions.js.map +1 -1
  330. package/features/modelBuilder/feature.js +3 -8
  331. package/features/modelBuilder/feature.js.map +1 -1
  332. package/features/modelBuilder/fields/AssetFieldType.d.ts +20 -0
  333. package/features/modelBuilder/fields/AssetFieldType.js +46 -0
  334. package/features/modelBuilder/fields/AssetFieldType.js.map +1 -0
  335. package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +3 -1
  336. package/features/modelBuilder/fields/BaseFieldBuilder.js +4 -0
  337. package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -1
  338. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +59 -0
  339. package/features/modelBuilder/fields/DataFieldBuilder.js +11 -1
  340. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
  341. package/features/modelBuilder/fields/DateTimeFieldType.js +27 -12
  342. package/features/modelBuilder/fields/DateTimeFieldType.js.map +1 -1
  343. package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +1 -0
  344. package/features/modelBuilder/fields/DynamicZoneFieldType.js +10 -9
  345. package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
  346. package/features/modelBuilder/fields/UiAlertFieldType.js +2 -1
  347. package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
  348. package/features/modelBuilder/fields/UiSeparatorFieldType.js +2 -1
  349. package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
  350. package/features/modelBuilder/fields/UiTabsFieldType.d.ts +2 -1
  351. package/features/modelBuilder/fields/UiTabsFieldType.js +6 -3
  352. package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -1
  353. package/features/modelBuilder/fields/fieldTypeValidator.d.ts +5 -3
  354. package/features/modelBuilder/fields/resolveAssetUrl.d.ts +35 -0
  355. package/features/modelBuilder/fields/resolveAssetUrl.js +26 -0
  356. package/features/modelBuilder/fields/resolveAssetUrl.js.map +1 -0
  357. package/features/modelBuilder/index.d.ts +1 -1
  358. package/features/modelBuilder/models/BaseModelBuilder.d.ts +3 -1
  359. package/features/modelBuilder/models/BaseModelBuilder.js +7 -0
  360. package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
  361. package/features/modelBuilder/models/ModelBuilder.d.ts +8 -0
  362. package/features/modelBuilder/models/ModelBuilder.js +1 -0
  363. package/features/modelBuilder/models/ModelBuilder.js.map +1 -1
  364. package/features/modelBuilder/models/ModelsProvider.d.ts +1 -3
  365. package/features/modelBuilder/models/ModelsProvider.js +2 -7
  366. package/features/modelBuilder/models/ModelsProvider.js.map +1 -1
  367. package/features/modelBuilder/models/PrivateModelBuilder.d.ts +5 -0
  368. package/features/modelBuilder/models/PrivateModelBuilder.js +13 -1
  369. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  370. package/features/modelBuilder/models/PublicModelBuilder.js +2 -1
  371. package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
  372. package/features/modelStorageSync/ModelStorageSyncTask.d.ts +31 -0
  373. package/features/modelStorageSync/ModelStorageSyncTask.js +66 -0
  374. package/features/modelStorageSync/ModelStorageSyncTask.js.map +1 -0
  375. package/features/modelStorageSync/SyncStorageOnModelUpdate.d.ts +23 -0
  376. package/features/modelStorageSync/SyncStorageOnModelUpdate.js +51 -0
  377. package/features/modelStorageSync/SyncStorageOnModelUpdate.js.map +1 -0
  378. package/features/modelStorageSync/abstractions.d.ts +34 -0
  379. package/features/modelStorageSync/abstractions.js +6 -0
  380. package/features/modelStorageSync/abstractions.js.map +1 -0
  381. package/features/modelStorageSync/feature.d.ts +8 -0
  382. package/features/modelStorageSync/feature.js +13 -0
  383. package/features/modelStorageSync/feature.js.map +1 -0
  384. package/features/modelStorageSync/index.d.ts +2 -0
  385. package/features/modelStorageSync/index.js +2 -0
  386. package/features/runtimeTenant/RuntimeTenant.d.ts +13 -0
  387. package/features/runtimeTenant/RuntimeTenant.js +22 -0
  388. package/features/runtimeTenant/RuntimeTenant.js.map +1 -0
  389. package/features/runtimeTenant/abstractions.d.ts +11 -0
  390. package/features/runtimeTenant/abstractions.js +5 -0
  391. package/features/runtimeTenant/abstractions.js.map +1 -0
  392. package/features/runtimeTenant/index.d.ts +2 -0
  393. package/features/runtimeTenant/index.js +2 -0
  394. package/features/shared/abstractions.d.ts +1 -5
  395. package/features/shared/abstractions.js +1 -2
  396. package/features/shared/abstractions.js.map +1 -1
  397. package/features/sortMapper/SortMapper.js +2 -5
  398. package/features/sortMapper/SortMapper.js.map +1 -1
  399. package/features/storage/fields/CompressedTextStorageTransform.js +1 -1
  400. package/features/storage/fields/CompressedTextStorageTransform.js.map +1 -1
  401. package/features/storage/fields/DateStorageTransform.js +3 -4
  402. package/features/storage/fields/DateStorageTransform.js.map +1 -1
  403. package/features/storage/fields/DynamicZoneStorageTransform.js +2 -2
  404. package/features/storage/fields/DynamicZoneStorageTransform.js.map +1 -1
  405. package/features/storage/fields/JsonStorageTransform.js +1 -1
  406. package/features/storage/fields/JsonStorageTransform.js.map +1 -1
  407. package/features/storage/fields/LongTextStorageTransform.js +1 -1
  408. package/features/storage/fields/LongTextStorageTransform.js.map +1 -1
  409. package/features/storage/fields/ObjectStorageTransform.js +27 -7
  410. package/features/storage/fields/ObjectStorageTransform.js.map +1 -1
  411. package/features/storage/fields/RichTextStorageTransform.js +1 -1
  412. package/features/storage/fields/RichTextStorageTransform.js.map +1 -1
  413. package/features/validation/abstractions/CmsModelFieldValidator.d.ts +5 -0
  414. package/features/validation/abstractions/CmsModelFieldValidator.js.map +1 -1
  415. package/features/validation/validators/DateGteValidator.d.ts +2 -0
  416. package/features/validation/validators/DateGteValidator.js +12 -2
  417. package/features/validation/validators/DateGteValidator.js.map +1 -1
  418. package/features/validation/validators/DateLteValidator.d.ts +2 -0
  419. package/features/validation/validators/DateLteValidator.js +12 -2
  420. package/features/validation/validators/DateLteValidator.js.map +1 -1
  421. package/features/validation/validators/PatternValidator.js +1 -1
  422. package/features/validation/validators/PatternValidator.js.map +1 -1
  423. package/features/validation/validators/dateLimit.d.ts +9 -0
  424. package/features/validation/validators/dateLimit.js +18 -0
  425. package/features/validation/validators/dateLimit.js.map +1 -0
  426. package/features/whereMapper/WhereMapper.js +8 -8
  427. package/features/whereMapper/WhereMapper.js.map +1 -1
  428. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +15 -5
  429. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  430. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +8 -2
  431. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  432. package/graphql/checkEndpointAccess.d.ts +7 -2
  433. package/graphql/checkEndpointAccess.js +2 -4
  434. package/graphql/checkEndpointAccess.js.map +1 -1
  435. package/graphql/getSchema/generateCacheKey.js +1 -1
  436. package/graphql/getSchema/generateCacheKey.js.map +1 -1
  437. package/graphql/scalars/RevisionId.js +1 -1
  438. package/graphql/scalars/RevisionId.js.map +1 -1
  439. package/graphql/schema/cms/CmsBaseErrorTypeFactory.d.ts +1 -0
  440. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js +4 -0
  441. package/graphql/schema/cms/CmsBaseErrorTypeFactory.js.map +1 -1
  442. package/graphql/schema/cms/getEntryResolver.js +3 -2
  443. package/graphql/schema/cms/getEntryResolver.js.map +1 -1
  444. package/graphql/schema/cms/getModelResolver.d.ts +35 -0
  445. package/graphql/schema/cms/getModelResolver.js +49 -0
  446. package/graphql/schema/cms/getModelResolver.js.map +1 -0
  447. package/graphql/schema/cms/helpers/buildFieldsSelection.js +9 -2
  448. package/graphql/schema/cms/helpers/buildFieldsSelection.js.map +1 -1
  449. package/graphql/schema/cms/helpers/expandFieldWildcards.d.ts +2 -0
  450. package/graphql/schema/cms/helpers/expandFieldWildcards.js +13 -0
  451. package/graphql/schema/cms/helpers/expandFieldWildcards.js.map +1 -0
  452. package/graphql/schema/cms/helpers/index.d.ts +1 -0
  453. package/graphql/schema/cms/helpers/index.js +1 -0
  454. package/graphql/schema/cms/helpers/transformWhereToNested.js +39 -17
  455. package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -1
  456. package/graphql/schema/cms/helpers.d.ts +1 -0
  457. package/graphql/schema/cms/helpers.js +1 -0
  458. package/graphql/schema/cms/listEntriesResolver.js +3 -2
  459. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  460. package/graphql/schema/cms/resolvers/createEntry.d.ts +1 -0
  461. package/graphql/schema/cms/resolvers/createEntry.js +4 -0
  462. package/graphql/schema/cms/resolvers/createEntry.js.map +1 -1
  463. package/graphql/schema/cms/resolvers/deleteEntryRevision.d.ts +1 -0
  464. package/graphql/schema/cms/resolvers/deleteEntryRevision.js +4 -0
  465. package/graphql/schema/cms/resolvers/deleteEntryRevision.js.map +1 -1
  466. package/graphql/schema/cms/resolvers/getEntry.d.ts +1 -0
  467. package/graphql/schema/cms/resolvers/getEntry.js +4 -0
  468. package/graphql/schema/cms/resolvers/getEntry.js.map +1 -1
  469. package/graphql/schema/cms/resolvers/getModel.d.ts +9 -0
  470. package/graphql/schema/cms/resolvers/getModel.js +22 -0
  471. package/graphql/schema/cms/resolvers/getModel.js.map +1 -0
  472. package/graphql/schema/cms/resolvers/index.d.ts +1 -0
  473. package/graphql/schema/cms/resolvers/index.js +1 -0
  474. package/graphql/schema/cms/resolvers/listEntries.d.ts +1 -0
  475. package/graphql/schema/cms/resolvers/listEntries.js +4 -0
  476. package/graphql/schema/cms/resolvers/listEntries.js.map +1 -1
  477. package/graphql/schema/cms/resolvers/mutationCms.d.ts +1 -0
  478. package/graphql/schema/cms/resolvers/mutationCms.js +4 -0
  479. package/graphql/schema/cms/resolvers/mutationCms.js.map +1 -1
  480. package/graphql/schema/cms/resolvers/publishEntryRevision.d.ts +1 -0
  481. package/graphql/schema/cms/resolvers/publishEntryRevision.js +4 -0
  482. package/graphql/schema/cms/resolvers/publishEntryRevision.js.map +1 -1
  483. package/graphql/schema/cms/resolvers/queryCms.d.ts +1 -0
  484. package/graphql/schema/cms/resolvers/queryCms.js +4 -0
  485. package/graphql/schema/cms/resolvers/queryCms.js.map +1 -1
  486. package/graphql/schema/cms/resolvers/unpublishEntryRevision.d.ts +1 -0
  487. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js +4 -0
  488. package/graphql/schema/cms/resolvers/unpublishEntryRevision.js.map +1 -1
  489. package/graphql/schema/cms/resolvers/updateEntryRevision.d.ts +1 -0
  490. package/graphql/schema/cms/resolvers/updateEntryRevision.js +4 -0
  491. package/graphql/schema/cms/resolvers/updateEntryRevision.js.map +1 -1
  492. package/graphql/schema/cms/typeDefs/mutation.d.ts +1 -0
  493. package/graphql/schema/cms/typeDefs/mutation.js +4 -0
  494. package/graphql/schema/cms/typeDefs/mutation.js.map +1 -1
  495. package/graphql/schema/cms/typeDefs/query.d.ts +1 -0
  496. package/graphql/schema/cms/typeDefs/query.js +5 -0
  497. package/graphql/schema/cms/typeDefs/query.js.map +1 -1
  498. package/graphql/schema/cms/typeDefs/responses.d.ts +1 -0
  499. package/graphql/schema/cms/typeDefs/responses.js +9 -0
  500. package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
  501. package/graphql/schema/contentEntries.js +19 -4
  502. package/graphql/schema/contentEntries.js.map +1 -1
  503. package/graphql/schema/contentModels.js +33 -0
  504. package/graphql/schema/contentModels.js.map +1 -1
  505. package/graphql/schema/createFieldResolvers.js +1 -1
  506. package/graphql/schema/createFieldResolvers.js.map +1 -1
  507. package/graphql/schema/createManageResolvers.js +3 -1
  508. package/graphql/schema/createManageResolvers.js.map +1 -1
  509. package/graphql/schema/createManageSDL.js +2 -0
  510. package/graphql/schema/createManageSDL.js.map +1 -1
  511. package/graphql/schema/resolvers/manage/resolveDuplicate.d.ts +7 -0
  512. package/graphql/schema/resolvers/manage/resolveDuplicate.js +11 -0
  513. package/graphql/schema/resolvers/manage/resolveDuplicate.js.map +1 -0
  514. package/package.json +24 -25
  515. package/plugins/CmsModelPlugin.js +11 -11
  516. package/plugins/CmsModelPlugin.js.map +1 -1
  517. package/types/fields/dynamicZoneField.d.ts +3 -2
  518. package/types/index.d.ts +0 -1
  519. package/types/model.d.ts +6 -0
  520. package/types/modelField.d.ts +14 -1
  521. package/types/types.d.ts +14 -109
  522. package/types/types.js.map +1 -1
  523. package/utils/caching/Cache.js +1 -1
  524. package/utils/caching/Cache.js.map +1 -1
  525. package/utils/createModelField.js +2 -1
  526. package/utils/createModelField.js.map +1 -1
  527. package/utils/createModelSchemaKey.d.ts +8 -0
  528. package/utils/createModelSchemaKey.js +18 -0
  529. package/utils/createModelSchemaKey.js.map +1 -0
  530. package/utils/date.js +1 -1
  531. package/utils/date.js.map +1 -1
  532. package/utils/entryStorage.js +1 -1
  533. package/utils/entryStorage.js.map +1 -1
  534. package/utils/renderFields.js +1 -1
  535. package/utils/renderFields.js.map +1 -1
  536. package/HeadlessCmsContextualSchema.d.ts +0 -16
  537. package/HeadlessCmsContextualSchema.js +0 -32
  538. package/HeadlessCmsContextualSchema.js.map +0 -1
  539. package/crud/contentEntry.crud.d.ts +0 -6
  540. package/crud/contentEntry.crud.js +0 -336
  541. package/crud/contentEntry.crud.js.map +0 -1
  542. package/crud/contentModel.crud.d.ts +0 -5
  543. package/crud/contentModel.crud.js +0 -79
  544. package/crud/contentModel.crud.js.map +0 -1
  545. package/crud/contentModelGroup.crud.d.ts +0 -5
  546. package/crud/contentModelGroup.crud.js +0 -76
  547. package/crud/contentModelGroup.crud.js.map +0 -1
  548. package/types/context.d.ts +0 -110
  549. package/types/context.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"crud/contentModel/defaultFields.js","sources":["../../../src/crud/contentModel/defaultFields.ts"],"sourcesContent":["import type { CmsModelCreateInput, CmsModelFieldInput } from \"~/types/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\n\nconst createDefaultFields = (): CmsModelFieldInput[] => {\n return [\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n validation: [\n {\n name: \"required\",\n message: \"Title is a required field.\"\n }\n ],\n listValidation: [],\n renderer: {\n name: \"text-input\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"description\",\n type: \"long-text\",\n label: \"Description\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"long-text-text-area\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"image\",\n type: \"file\",\n label: \"Image\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"file-input\"\n },\n settings: {\n imagesOnly: true\n }\n }\n ];\n};\n\n/**\n * We only assign default fields if there are no fields in the model already.\n */\nexport const assignModelDefaultFields = (model: CmsModelCreateInput): void => {\n if (model.fields && model.fields.length !== 0) {\n return;\n }\n\n model.fields = createDefaultFields();\n model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];\n};\n"],"names":["createDefaultFields","generateAlphaNumericLowerCaseId","assignModelDefaultFields","model"],"mappings":";AAGA,MAAMA,sBAAsB,IACjB;QACH;YACI,IAAIC,gCAAgC;YACpC,SAAS;YACT,MAAM;YACN,OAAO;YACP,YAAY;gBACR;oBACI,MAAM;oBACN,SAAS;gBACb;aACH;YACD,gBAAgB,EAAE;YAClB,UAAU;gBACN,MAAM;YACV;QACJ;QACA;YACI,IAAIA,gCAAgC;YACpC,SAAS;YACT,MAAM;YACN,OAAO;YACP,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,UAAU;gBACN,MAAM;YACV;QACJ;QACA;YACI,IAAIA,gCAAgC;YACpC,SAAS;YACT,MAAM;YACN,OAAO;YACP,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,UAAU;gBACN,MAAM;YACV;YACA,UAAU;gBACN,YAAY;YAChB;QACJ;KACH;AAME,MAAMC,2BAA2B,CAACC;IACrC,IAAIA,MAAM,MAAM,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EACnC;IAGJA,MAAM,MAAM,GAAGH;IACfG,MAAM,MAAM,GAAG;QAAC;YAACA,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;SAAC;QAAE;YAACA,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;YAAEA,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;SAAC;KAAC;AACnF"}
1
+ {"version":3,"file":"crud/contentModel/defaultFields.js","sources":["../../../src/crud/contentModel/defaultFields.ts"],"sourcesContent":["import type { CmsModelCreateInput, CmsModelFieldInput } from \"~/types/index.js\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\n\nconst createDefaultFields = (): CmsModelFieldInput[] => {\n return [\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n validation: [\n {\n name: \"required\",\n message: \"Title is a required field.\"\n }\n ],\n listValidation: [],\n renderer: {\n name: \"text-input\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"description\",\n type: \"long-text\",\n label: \"Description\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"long-text-text-area\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"image\",\n type: \"asset\",\n label: \"Image\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"asset-input\"\n },\n tags: [],\n settings: {\n imagesOnly: true\n }\n }\n ];\n};\n\n/**\n * We only assign default fields if there are no fields in the model already.\n */\nexport const assignModelDefaultFields = (model: CmsModelCreateInput): void => {\n if (model.fields && model.fields.length !== 0) {\n return;\n }\n\n model.fields = createDefaultFields();\n model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];\n};\n"],"names":["createDefaultFields","generateAlphaNumericLowerCaseId","assignModelDefaultFields","model"],"mappings":";AAGA,MAAMA,sBAAsB,IACjB;QACH;YACI,IAAIC,gCAAgC;YACpC,SAAS;YACT,MAAM;YACN,OAAO;YACP,YAAY;gBACR;oBACI,MAAM;oBACN,SAAS;gBACb;aACH;YACD,gBAAgB,EAAE;YAClB,UAAU;gBACN,MAAM;YACV;QACJ;QACA;YACI,IAAIA,gCAAgC;YACpC,SAAS;YACT,MAAM;YACN,OAAO;YACP,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,UAAU;gBACN,MAAM;YACV;QACJ;QACA;YACI,IAAIA,gCAAgC;YACpC,SAAS;YACT,MAAM;YACN,OAAO;YACP,YAAY,EAAE;YACd,gBAAgB,EAAE;YAClB,UAAU;gBACN,MAAM;YACV;YACA,MAAM,EAAE;YACR,UAAU;gBACN,YAAY;YAChB;QACJ;KACH;AAME,MAAMC,2BAA2B,CAACC;IACrC,IAAIA,MAAM,MAAM,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EACnC;IAGJA,MAAM,MAAM,GAAGH;IACfG,MAAM,MAAM,GAAG;QAAC;YAACA,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;SAAC;QAAE;YAACA,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;YAAEA,MAAM,MAAM,CAAC,EAAE,CAAC,EAAE;SAAC;KAAC;AACnF"}
@@ -6,7 +6,7 @@ const validateEndingAllowed = (params)=>{
6
6
  input: model.singularApiName,
7
7
  disallowedEnding: disallowedEnding
8
8
  });
9
- if (false === isModelEndingAllowed(model.pluralApiName)) throw new error(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
9
+ else if (false === isModelEndingAllowed(model.pluralApiName)) throw new error(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
10
10
  input: model.pluralApiName,
11
11
  disallowedEnding: disallowedEnding
12
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"crud/contentModel/validate/endingAllowed.js","sources":["../../../../src/crud/contentModel/validate/endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"names":["validateEndingAllowed","params","model","isModelEndingAllowed","WebinyError","disallowedEnding"],"mappings":";;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIE,AAAgD,UAAhDA,qBAAqBD,MAAM,eAAe,GAC1C,MAAM,IAAIE,MACN,CAAC,oCAAoC,EAAEF,MAAM,eAAe,CAAC,iDAAiD,CAAC,EAC/G,8CACA;QACI,OAAOA,MAAM,eAAe;QAC5BG,kBAAgBA;IACpB;IAED,IAAIF,AAA8C,UAA9CA,qBAAqBD,MAAM,aAAa,GAC/C,MAAM,IAAIE,MACN,CAAC,kCAAkC,EAAEF,MAAM,aAAa,CAAC,iDAAiD,CAAC,EAC3G,4CACA;QACI,OAAOA,MAAM,aAAa;QAC1B,kBAAkBG;IACtB;AAGZ"}
1
+ {"version":3,"file":"crud/contentModel/validate/endingAllowed.js","sources":["../../../../src/crud/contentModel/validate/endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"names":["validateEndingAllowed","params","model","isModelEndingAllowed","WebinyError","disallowedEnding"],"mappings":";;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIE,AAAgD,UAAhDA,qBAAqBD,MAAM,eAAe,GAC1C,MAAM,IAAIE,MACN,CAAC,oCAAoC,EAAEF,MAAM,eAAe,CAAC,iDAAiD,CAAC,EAC/G,8CACA;QACI,OAAOA,MAAM,eAAe;QAC5BG,kBAAgBA;IACpB;SAED,IAAIF,AAA8C,UAA9CA,qBAAqBD,MAAM,aAAa,GAC/C,MAAM,IAAIE,MACN,CAAC,kCAAkC,EAAEF,MAAM,aAAa,CAAC,iDAAiD,CAAC,EAC3G,4CACA;QACI,OAAOA,MAAM,aAAa;QAC1B,kBAAkBG;IACtB;AAGZ"}
@@ -4,7 +4,7 @@ const validatePluralApiName = (params)=>{
4
4
  if (existingModel.singularApiName === model.pluralApiName) throw new error(`Content model with singularApiName "${model.pluralApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
5
5
  input: model.pluralApiName
6
6
  });
7
- if (existingModel.pluralApiName === model.pluralApiName) throw new error(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
7
+ else if (existingModel.pluralApiName === model.pluralApiName) throw new error(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
8
8
  input: model.pluralApiName
9
9
  });
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"crud/contentModel/validate/pluralApiName.js","sources":["../../../../src/crud/contentModel/validate/pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"names":["validatePluralApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,aAAa,EACrD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC7E,kCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;IAED,IAAID,cAAc,aAAa,KAAKC,MAAM,aAAa,EAC1D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC3E,gCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;AAGZ"}
1
+ {"version":3,"file":"crud/contentModel/validate/pluralApiName.js","sources":["../../../../src/crud/contentModel/validate/pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"names":["validatePluralApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,aAAa,EACrD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC7E,kCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;SAED,IAAID,cAAc,aAAa,KAAKC,MAAM,aAAa,EAC1D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC3E,gCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;AAGZ"}
@@ -4,7 +4,7 @@ const validateSingularApiName = (params)=>{
4
4
  if (existingModel.singularApiName === model.singularApiName) throw new error(`Content model with singularApiName "${model.singularApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
5
5
  input: model.singularApiName
6
6
  });
7
- if (existingModel.pluralApiName === model.singularApiName) throw new error(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
7
+ else if (existingModel.pluralApiName === model.singularApiName) throw new error(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
8
8
  input: model.singularApiName
9
9
  });
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"crud/contentModel/validate/singularApiName.js","sources":["../../../../src/crud/contentModel/validate/singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"names":["validateSingularApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,eAAe,EACvD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC/E,kCACA;QACI,OAAOA,MAAM,eAAe;IAChC;IAED,IAAID,cAAc,aAAa,KAAKC,MAAM,eAAe,EAC5D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC7E,gCACA;QACI,OAAOA,MAAM,eAAe;IAChC;AAGZ"}
1
+ {"version":3,"file":"crud/contentModel/validate/singularApiName.js","sources":["../../../../src/crud/contentModel/validate/singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"names":["validateSingularApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,eAAe,EACvD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC/E,kCACA;QACI,OAAOA,MAAM,eAAe;IAChC;SAED,IAAID,cAAc,aAAa,KAAKC,MAAM,eAAe,EAC5D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC7E,gCACA;QACI,OAAOA,MAAM,eAAe;IAChC;AAGZ"}
@@ -114,13 +114,13 @@ const refinementPluralValidationMessage = (value)=>({
114
114
  });
115
115
  const refinementModelIdValidation = (value)=>{
116
116
  if (!value) return true;
117
- if (null === value.match(/^[a-zA-Z]/)) return false;
117
+ else if (null === value.match(/^[a-zA-Z]/)) return false;
118
118
  const camelCasedValue = camelCase(value).toLowerCase();
119
119
  return camelCasedValue === value.toLowerCase();
120
120
  };
121
121
  const refinementModelIdValidationMessage = (value)=>{
122
122
  if (!value) return {};
123
- if (null === value.match(/^[a-zA-Z]/)) return {
123
+ else if (null === value.match(/^[a-zA-Z]/)) return {
124
124
  message: `The modelId "${value}" is not valid. It must start with a A-Z or a-z.`
125
125
  };
126
126
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"crud/contentModel/validation.js","sources":["../../../src/crud/contentModel/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst fieldSystemFields: string[] = [\n \"id\",\n \"entryId\",\n \"createdOn\",\n \"modifiedOn\",\n \"publishedOn\",\n \"savedOn\",\n \"deletedOn\",\n \"restoredOn\",\n \"firstPublishedOn\",\n \"lastPublishedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\",\n \"deletedBy\",\n \"restoredBy\",\n \"firstPublishedBy\",\n \"lastPublishedBy\",\n \"revisionCreatedOn\",\n \"revisionModifiedOn\",\n \"revisionSavedOn\",\n \"revisionDeletedOn\",\n \"revisionRestoredOn\",\n \"revisionFirstPublishedOn\",\n \"revisionLastPublishedOn\",\n \"revisionCreatedBy\",\n \"revisionModifiedBy\",\n \"revisionSavedBy\",\n \"revisionDeletedBy\",\n \"revisionRestoredBy\",\n \"revisionFirstPublishedBy\",\n \"revisionLastPublishedBy\",\n \"meta\",\n \"wbyAco_location\"\n];\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str.max(255);\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: `Provided value is not valid - must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Provided value is not valid - must be alphanumeric string.`\n })\n .superRefine((value, ctx) => {\n if (fieldSystemFields.includes(value)) {\n return ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `Field ID \"${value}\" is a reserved keyword, and is not allowed.`\n });\n }\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});\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 refinementModelIdValidation = (value?: string) => {\n if (!value) {\n return true;\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return false;\n }\n const camelCasedValue = camelCase(value).toLowerCase();\n return camelCasedValue === value.toLowerCase();\n};\nconst refinementModelIdValidationMessage = (value?: string) => {\n if (!value) {\n return {};\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return {\n message: `The modelId \"${value}\" is not valid. It must start with a A-Z or a-z.`\n };\n }\n return {\n message: `The modelId \"${value}\" is not valid.`\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 refineModelId = (value: string, ctx: zod.RefinementCtx) => {\n if (!refinementModelIdValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementModelIdValidationMessage(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 });\n};\n\nexport const createModelImportValidation = () => {\n return zod.object({\n name: shortString.min(1).superRefine((value, ctx) => {\n if (value.match(/[a-zA-Z]/) === null) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `The name \"${value}\" is not valid.`\n });\n }\n }),\n modelId: shortString.min(1).superRefine(refineModelId).transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).min(1),\n layout: zod.array(zod.array(zod.any())),\n tags: zod.array(shortString).optional(),\n titleFieldId: shortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.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\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 });\n};\n"],"names":["fieldSystemFields","str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","ctx","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refinementModelIdValidation","camelCasedValue","refinementModelIdValidationMessage","refineSingularApiName","refinePluralApiName","refineModelId","modelIdTransformation","createModelCreateValidation","createModelImportValidation","createModelCreateFromValidation","createModelUpdateValidation"],"mappings":";;;AAIA,MAAMA,oBAA8B;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH,IAAI,GAAG,CAAC;AAC3B,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,CA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C3B,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACrD,IAAIF,OACAY,sBAAsBZ,OAAOE;QAErC;QACA,eAAeP,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACnD,IAAIF,OACAa,oBAAoBb,OAAOE;QAEnC;QACA,aAAaL;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC"}
1
+ {"version":3,"file":"crud/contentModel/validation.js","sources":["../../../src/crud/contentModel/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst fieldSystemFields: string[] = [\n \"id\",\n \"entryId\",\n \"createdOn\",\n \"modifiedOn\",\n \"publishedOn\",\n \"savedOn\",\n \"deletedOn\",\n \"restoredOn\",\n \"firstPublishedOn\",\n \"lastPublishedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\",\n \"deletedBy\",\n \"restoredBy\",\n \"firstPublishedBy\",\n \"lastPublishedBy\",\n \"revisionCreatedOn\",\n \"revisionModifiedOn\",\n \"revisionSavedOn\",\n \"revisionDeletedOn\",\n \"revisionRestoredOn\",\n \"revisionFirstPublishedOn\",\n \"revisionLastPublishedOn\",\n \"revisionCreatedBy\",\n \"revisionModifiedBy\",\n \"revisionSavedBy\",\n \"revisionDeletedBy\",\n \"revisionRestoredBy\",\n \"revisionFirstPublishedBy\",\n \"revisionLastPublishedBy\",\n \"meta\",\n \"wbyAco_location\"\n];\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str.max(255);\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: `Provided value is not valid - must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Provided value is not valid - must be alphanumeric string.`\n })\n .superRefine((value, ctx) => {\n if (fieldSystemFields.includes(value)) {\n return ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `Field ID \"${value}\" is a reserved keyword, and is not allowed.`\n });\n }\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});\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 refinementModelIdValidation = (value?: string) => {\n if (!value) {\n return true;\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return false;\n }\n const camelCasedValue = camelCase(value).toLowerCase();\n return camelCasedValue === value.toLowerCase();\n};\nconst refinementModelIdValidationMessage = (value?: string) => {\n if (!value) {\n return {};\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return {\n message: `The modelId \"${value}\" is not valid. It must start with a A-Z or a-z.`\n };\n }\n return {\n message: `The modelId \"${value}\" is not valid.`\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 refineModelId = (value: string, ctx: zod.RefinementCtx) => {\n if (!refinementModelIdValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementModelIdValidationMessage(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 });\n};\n\nexport const createModelImportValidation = () => {\n return zod.object({\n name: shortString.min(1).superRefine((value, ctx) => {\n if (value.match(/[a-zA-Z]/) === null) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `The name \"${value}\" is not valid.`\n });\n }\n }),\n modelId: shortString.min(1).superRefine(refineModelId).transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).min(1),\n layout: zod.array(zod.array(zod.any())),\n tags: zod.array(shortString).optional(),\n titleFieldId: shortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.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\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 });\n};\n"],"names":["fieldSystemFields","str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","ctx","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refinementModelIdValidation","camelCasedValue","refinementModelIdValidationMessage","refineSingularApiName","refinePluralApiName","refineModelId","modelIdTransformation","createModelCreateValidation","createModelImportValidation","createModelCreateFromValidation","createModelUpdateValidation"],"mappings":";;;AAIA,MAAMA,oBAA8B;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH,IAAI,GAAG,CAAC;AAC3B,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,I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;QACjC,oBAAoBE,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;IAC7C;AAGG,MAAMuB,kCAAkC,IACpC1B,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACoB;QACvC,iBAAiBtB,YAAY,WAAW,CAACmB;QACzC,eAAenB,YAAY,WAAW,CAACoB;QACvC,aAAahB;QACb,OAAOJ;QACPM,MAAAA;IACJ;AAGG,MAAMoB,8BAA8B,IAChC3B,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACrD,IAAIF,OACAY,sBAAsBZ,OAAOE;QAErC;QACA,eAAeP,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACnD,IAAIF,OACAa,oBAAoBb,OAAOE;QAEnC;QACA,aAAaL;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC"}
@@ -33,6 +33,7 @@ export declare const createModelCreateValidation: () => zod.ZodObject<{
33
33
  type: zod.ZodString;
34
34
  tags: zod.ZodDefault<zod.ZodOptional<zod.ZodArray<zod.ZodString>>>;
35
35
  list: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
36
+ disabled: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
36
37
  predefinedValues: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodDefault<zod.ZodObject<{
37
38
  enabled: zod.ZodBoolean;
38
39
  values: zod.ZodDefault<zod.ZodArray<zod.ZodObject<{
@@ -109,20 +110,20 @@ export declare const createModelCreateValidation: () => zod.ZodObject<{
109
110
  rules: zod.ZodPipe<zod.ZodDefault<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
110
111
  type: zod.ZodEnum<{
111
112
  accessControl: "accessControl";
112
- entryValue: "entryValue";
113
+ condition: "condition";
113
114
  }>;
114
115
  target: zod.ZodString;
115
116
  operator: zod.ZodString;
116
117
  value: zod.ZodUnion<readonly [zod.ZodString, zod.ZodNumber, zod.ZodBoolean, zod.ZodNull]>;
117
118
  action: zod.ZodString;
118
119
  }, zod.core.$strip>>>>>>, zod.ZodTransform<{
119
- type: "accessControl" | "entryValue";
120
+ type: "accessControl" | "condition";
120
121
  target: string;
121
122
  operator: string;
122
123
  value: string | number | boolean | null;
123
124
  action: string;
124
125
  }[], {
125
- type: "accessControl" | "entryValue";
126
+ type: "accessControl" | "condition";
126
127
  target: string;
127
128
  operator: string;
128
129
  value: string | number | boolean | null;
@@ -135,6 +136,7 @@ export declare const createModelCreateValidation: () => zod.ZodObject<{
135
136
  descriptionFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
136
137
  imageFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
137
138
  defaultFields: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
139
+ settings: zod.ZodDefault<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodObject<{}, zod.core.$loose>>>>>;
138
140
  }, zod.core.$strip>;
139
141
  export declare const createModelUpdateValidation: () => zod.ZodObject<{
140
142
  name: zod.ZodOptional<zod.ZodString>;
@@ -169,6 +171,7 @@ export declare const createModelUpdateValidation: () => zod.ZodObject<{
169
171
  type: zod.ZodString;
170
172
  tags: zod.ZodDefault<zod.ZodOptional<zod.ZodArray<zod.ZodString>>>;
171
173
  list: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
174
+ disabled: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
172
175
  predefinedValues: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodDefault<zod.ZodObject<{
173
176
  enabled: zod.ZodBoolean;
174
177
  values: zod.ZodDefault<zod.ZodArray<zod.ZodObject<{
@@ -245,20 +248,20 @@ export declare const createModelUpdateValidation: () => zod.ZodObject<{
245
248
  rules: zod.ZodPipe<zod.ZodDefault<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
246
249
  type: zod.ZodEnum<{
247
250
  accessControl: "accessControl";
248
- entryValue: "entryValue";
251
+ condition: "condition";
249
252
  }>;
250
253
  target: zod.ZodString;
251
254
  operator: zod.ZodString;
252
255
  value: zod.ZodUnion<readonly [zod.ZodString, zod.ZodNumber, zod.ZodBoolean, zod.ZodNull]>;
253
256
  action: zod.ZodString;
254
257
  }, zod.core.$strip>>>>>>, zod.ZodTransform<{
255
- type: "accessControl" | "entryValue";
258
+ type: "accessControl" | "condition";
256
259
  target: string;
257
260
  operator: string;
258
261
  value: string | number | boolean | null;
259
262
  action: string;
260
263
  }[], {
261
- type: "accessControl" | "entryValue";
264
+ type: "accessControl" | "condition";
262
265
  target: string;
263
266
  operator: string;
264
267
  value: string | number | boolean | null;
@@ -270,6 +273,7 @@ export declare const createModelUpdateValidation: () => zod.ZodObject<{
270
273
  descriptionFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
271
274
  imageFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
272
275
  tags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
276
+ settings: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodObject<{}, zod.core.$loose>>>>;
273
277
  }, zod.core.$strip>;
274
278
  export declare const createModelCreateFromValidation: () => zod.ZodObject<{
275
279
  name: zod.ZodString;
@@ -35,6 +35,7 @@ const fieldSchema = zod.object({
35
35
  type: shortString,
36
36
  tags: zod.array(shortString).optional().default([]),
37
37
  list: zod.boolean().optional().nullish().transform((value)=>!!value).default(false),
38
+ disabled: zod.boolean().optional().nullish().transform((value)=>!!value).default(false),
38
39
  predefinedValues: zod.object({
39
40
  enabled: zod.boolean(),
40
41
  values: zod.array(zod.object({
@@ -64,7 +65,7 @@ const fieldSchema = zod.object({
64
65
  rules: zod.array(zod.object({
65
66
  type: zod["enum"]([
66
67
  "accessControl",
67
- "entryValue"
68
+ "condition"
68
69
  ]),
69
70
  target: shortString,
70
71
  operator: shortString,
@@ -119,7 +120,8 @@ const createModelCreateValidation = ()=>zod.object({
119
120
  titleFieldId: optionalShortString.nullish(),
120
121
  descriptionFieldId: optionalShortString.nullish(),
121
122
  imageFieldId: optionalShortString.nullish(),
122
- defaultFields: zod.boolean().nullish()
123
+ defaultFields: zod.boolean().nullish(),
124
+ settings: zod.looseObject({}).optional().nullish().default({})
123
125
  });
124
126
  const createModelUpdateValidation = ()=>zod.object({
125
127
  name: optionalShortString,
@@ -137,7 +139,8 @@ const createModelUpdateValidation = ()=>zod.object({
137
139
  titleFieldId: optionalShortString.nullish(),
138
140
  descriptionFieldId: optionalShortString.nullish(),
139
141
  imageFieldId: optionalShortString.nullish(),
140
- tags: zod.array(shortString).optional()
142
+ tags: zod.array(shortString).optional(),
143
+ settings: zod.looseObject({}).optional().nullish()
141
144
  });
142
145
  const createModelCreateFromValidation = ()=>zod.object({
143
146
  name: shortString,
@@ -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\", \"entryValue\"]),\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 });\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 });\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,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AO,CAAC,EAAE;QACzC,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG,KAAK,OAAO,CAAC,EAAE;QAClD,MAAMA,IAAI,KAAK,CAACC,aAAa,QAAQ;QACrC,cAAcE,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,eAAeH,IAAI,OAAO,GAAG,OAAO;IACxC;AAGG,MAAMsB,8BAA8B,IAChCtB,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,OAAOS;YACrD,IAAIT,OACAQ,sBAAsBR,OAAOS;QAErC;QACA,eAAed,oBAAoB,WAAW,CAAC,CAACK,OAAOS;YACnD,IAAIT,OACAU,oBAAoBV,OAAOS;QAEnC;QACA,aAAaZ;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC;AAGG,MAAMsB,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"}
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,qBAAq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@
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"}
@@ -6,7 +6,7 @@ const validateEndingAllowed = (params)=>{
6
6
  input: model.singularApiName,
7
7
  disallowedEnding: disallowedEnding
8
8
  });
9
- if (false === isModelEndingAllowed(model.pluralApiName)) throw new error(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
9
+ else if (false === isModelEndingAllowed(model.pluralApiName)) throw new error(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
10
10
  input: model.pluralApiName,
11
11
  disallowedEnding: disallowedEnding
12
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"domain/contentModel/validation/endingAllowed.js","sources":["../../../../src/domain/contentModel/validation/endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"names":["validateEndingAllowed","params","model","isModelEndingAllowed","WebinyError","disallowedEnding"],"mappings":";;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIE,AAAgD,UAAhDA,qBAAqBD,MAAM,eAAe,GAC1C,MAAM,IAAIE,MACN,CAAC,oCAAoC,EAAEF,MAAM,eAAe,CAAC,iDAAiD,CAAC,EAC/G,8CACA;QACI,OAAOA,MAAM,eAAe;QAC5BG,kBAAgBA;IACpB;IAED,IAAIF,AAA8C,UAA9CA,qBAAqBD,MAAM,aAAa,GAC/C,MAAM,IAAIE,MACN,CAAC,kCAAkC,EAAEF,MAAM,aAAa,CAAC,iDAAiD,CAAC,EAC3G,4CACA;QACI,OAAOA,MAAM,aAAa;QAC1B,kBAAkBG;IACtB;AAGZ"}
1
+ {"version":3,"file":"domain/contentModel/validation/endingAllowed.js","sources":["../../../../src/domain/contentModel/validation/endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"names":["validateEndingAllowed","params","model","isModelEndingAllowed","WebinyError","disallowedEnding"],"mappings":";;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIE,AAAgD,UAAhDA,qBAAqBD,MAAM,eAAe,GAC1C,MAAM,IAAIE,MACN,CAAC,oCAAoC,EAAEF,MAAM,eAAe,CAAC,iDAAiD,CAAC,EAC/G,8CACA;QACI,OAAOA,MAAM,eAAe;QAC5BG,kBAAgBA;IACpB;SAED,IAAIF,AAA8C,UAA9CA,qBAAqBD,MAAM,aAAa,GAC/C,MAAM,IAAIE,MACN,CAAC,kCAAkC,EAAEF,MAAM,aAAa,CAAC,iDAAiD,CAAC,EAC3G,4CACA;QACI,OAAOA,MAAM,aAAa;QAC1B,kBAAkBG;IACtB;AAGZ"}
@@ -8,8 +8,9 @@ import { getBaseFieldType } from "../../../utils/getBaseFieldType.js";
8
8
  import { getContentModelTitleFieldId } from "./fields/titleField.js";
9
9
  import { getContentModelDescriptionFieldId } from "./fields/descriptionField.js";
10
10
  import { getContentModelImageFieldId } from "./fields/imageField.js";
11
+ import { validateDateExpressions } from "./dateExpressions.js";
11
12
  import { buildSchemaPlugins } from "../../../graphql/buildSchemaPlugins.js";
12
- import { HeadlessCms } from "../../../features/shared/abstractions.js";
13
+ import { HeadlessCmsEndpointConfig } from "../../../HeadlessCmsEndpointConfig.js";
13
14
  import { CmsGraphQLSchemaFactory } from "../../../graphql/CmsGraphQLSchemaFactory.js";
14
15
  import { createExecutableSchema } from "../../../graphql/createExecutableSchema.js";
15
16
  import { CmsGraphQLSchemaSorter, CmsModelFieldToGraphQLRegistry } from "../../../features/graphql/index.js";
@@ -78,6 +79,7 @@ const validateFields = (params)=>{
78
79
  fieldIdList.push(field.fieldId);
79
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.`);
80
81
  storageIdList.push(field.storageId);
82
+ validateDateExpressions(field);
81
83
  if (!fieldImpl.validateChildFields) continue;
82
84
  const validateChildFields = createValidateChildFields(registry);
83
85
  fieldImpl.validateChildFields({
@@ -97,7 +99,7 @@ const createGraphQLSchema = async (params)=>{
97
99
  models: models.filter((m)=>m.modelId !== model.modelId).concat([
98
100
  model
99
101
  ]),
100
- type: context.container.resolve(HeadlessCms).type
102
+ type: context.container.resolve(HeadlessCmsEndpointConfig).type
101
103
  });
102
104
  const staticFactories = context.container.resolveAll(CmsGraphQLSchemaFactory);
103
105
  const staticPlugins = [];
@@ -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 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 type { ICmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { buildSchemaPlugins } from \"~/graphql/buildSchemaPlugins.js\";\nimport { HeadlessCms } from \"~/features/shared/abstractions.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 * 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(HeadlessCms).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","validateChildFields","createGraphQLSchema","context","modelsResult","IdentityContext","ListModelsUseCase","models","generatedSchemaPlugins","buildSchemaPlugins","m","HeadlessCms","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":";;;;;;;;;;;;;;;AAuBA,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,MAAM,OAAO,CAAC,gBAAgB,CAAC;YAAEa;SAAQ,CAAC,IAAI,CAAC;IACvE;AACJ;AAEA,MAAMC,4BAA4B,CAC9BC,WAEO,CAAC,EAAEC,MAAM,EAAEC,cAAc,EAAE;QAC9B,IAAID,AAAkB,MAAlBA,OAAO,MAAM,IAAUC,AAA0B,MAA1BA,eAAe,MAAM,EAC5C;QAEJC,eAAe;YACXF;YACAC;YACAF;QAC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C;QAC7E,IAAI,CAACF,KAAK,CAACE,IAAI,EACX,OAAOD;QAEXA,MAAM,CAACC,IAAI,GAAGF,KAAK,CAACE,IAAI;QACxB,OAAOD;IACX,GAAG,CAAC;AAUD,MAAME,sBAAsB,OAAOnC;IACtC,MAAM,EAAEmB,MAAM,EAAEtC,KAAK,EAAEuD,QAAQ,EAAErB,OAAO,EAAE,GAAGf;IAC7C,MAAM,EAAEqC,YAAY,EAAEC,kBAAkB,EAAEC,YAAY,EAAE,GAAG1D;IAK3D,MAAM,EAAEgB,SAAS,EAAE,EAAE,GAAGhB;IAMxB,MAAM2D,gBAAgBzB,QAAQ,SAAS,CAAC,OAAO,CAAC0B;IAChD,MAAMC,UAAU3B,QAAQ,SAAS,CAAC,UAAU,CAAC4B;IAE7C5C,eAAe;QACXF;QACA,gBAAgBuC,UAAU,UAAU,EAAE;QACtC,UAAUI;IACd;IAEA,IAAI3C,OAAO,MAAM,EAAE;QAIf,MAAM+C,SAASC,gBAAgB;YAC3B1B;YACAtC;YACA2D;YACAE;QACJ;QAEA,IAAI;YACAI,YAAIF;QACR,EAAE,OAAO9D,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,OAAOkD,mBAAmBjD;gBAC9B;YACJ;QACJ;IACJ;IAEAD,MAAM,YAAY,GAAGkE,4BAA4BlD,QAAQwC;IACzDxD,MAAM,kBAAkB,GAAGmE,kCAAkCnD,QAAQyC;IACrEzD,MAAM,YAAY,GAAGoE,4BAA4BpD,QAAQ0C;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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,SAAS,CAAC,UAAU,CAAC4B;IAE7C7C,eAAe;QACXF;QACA,gBAAgBwC,UAAU,UAAU,EAAE;QACtC,UAAUI;IACd;IAEA,IAAI5C,OAAO,MAAM,EAAE;QAIf,MAAMgD,SAASC,gBAAgB;YAC3B1B;YACAvC;YACA4D;YACAE;QACJ;QAEA,IAAI;YACAI,YAAIF;QACR,EAAE,OAAO/D,KAAK;YACV,MAAM,IAAI2B,cAAY7B,oBAAoBC,OAAOC;QACrD;QAIA,IAAI;YACA,MAAMiC,oBAAoB;gBACtBC;gBACAnC;YACJ;QACJ,EAAE,OAAOC,KAAK;YACV,MAAM,IAAI2B,cAAY;gBAClB,SACI;gBACJ,MAAM;gBACN,MAAM;oBACF,SAAS5B,MAAM,OAAO;oBACtB,OAAOmD,mBAAmBlD;gBAC9B;YACJ;QACJ;IACJ;IAEAD,MAAM,YAAY,GAAGmE,4BAA4BnD,QAAQyC;IACzDzD,MAAM,kBAAkB,GAAGoE,kCAAkCpD,QAAQ0C;IACrE1D,MAAM,YAAY,GAAGqE,4BAA4BrD,QAAQ2C;AAC7D"}
@@ -4,7 +4,7 @@ const validatePluralApiName = (params)=>{
4
4
  if (existingModel.singularApiName === model.pluralApiName) throw new error(`Content model with singularApiName "${model.pluralApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
5
5
  input: model.pluralApiName
6
6
  });
7
- if (existingModel.pluralApiName === model.pluralApiName) throw new error(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
7
+ else if (existingModel.pluralApiName === model.pluralApiName) throw new error(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
8
8
  input: model.pluralApiName
9
9
  });
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"domain/contentModel/validation/pluralApiName.js","sources":["../../../../src/domain/contentModel/validation/pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"names":["validatePluralApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,aAAa,EACrD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC7E,kCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;IAED,IAAID,cAAc,aAAa,KAAKC,MAAM,aAAa,EAC1D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC3E,gCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;AAGZ"}
1
+ {"version":3,"file":"domain/contentModel/validation/pluralApiName.js","sources":["../../../../src/domain/contentModel/validation/pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"names":["validatePluralApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,aAAa,EACrD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC7E,kCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;SAED,IAAID,cAAc,aAAa,KAAKC,MAAM,aAAa,EAC1D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC3E,gCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;AAGZ"}
@@ -4,7 +4,7 @@ const validateSingularApiName = (params)=>{
4
4
  if (existingModel.singularApiName === model.singularApiName) throw new error(`Content model with singularApiName "${model.singularApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
5
5
  input: model.singularApiName
6
6
  });
7
- if (existingModel.pluralApiName === model.singularApiName) throw new error(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
7
+ else if (existingModel.pluralApiName === model.singularApiName) throw new error(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
8
8
  input: model.singularApiName
9
9
  });
10
10
  };