@webiny/api-headless-cms 5.43.3 → 6.0.0-alpha.1

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 (582) hide show
  1. package/constants.d.ts +1 -1
  2. package/constants.js.map +1 -1
  3. package/context.d.ts +1 -1
  4. package/context.js.map +1 -1
  5. package/crud/AccessControl/AccessControl.d.ts +2 -2
  6. package/crud/AccessControl/AccessControl.js.map +1 -1
  7. package/crud/contentEntry/abstractions/IDeleteEntry.d.ts +1 -1
  8. package/crud/contentEntry/abstractions/IDeleteEntry.js.map +1 -1
  9. package/crud/contentEntry/abstractions/IDeleteEntryOperation.d.ts +1 -1
  10. package/crud/contentEntry/abstractions/IDeleteEntryOperation.js.map +1 -1
  11. package/crud/contentEntry/abstractions/IGetEntriesByIds.d.ts +1 -1
  12. package/crud/contentEntry/abstractions/IGetEntriesByIds.js.map +1 -1
  13. package/crud/contentEntry/abstractions/IGetEntry.d.ts +1 -1
  14. package/crud/contentEntry/abstractions/IGetEntry.js.map +1 -1
  15. package/crud/contentEntry/abstractions/IGetLatestEntriesByIds.d.ts +1 -1
  16. package/crud/contentEntry/abstractions/IGetLatestEntriesByIds.js.map +1 -1
  17. package/crud/contentEntry/abstractions/IGetLatestRevisionByEntryId.d.ts +1 -1
  18. package/crud/contentEntry/abstractions/IGetLatestRevisionByEntryId.js.map +1 -1
  19. package/crud/contentEntry/abstractions/IGetPreviousRevisionByEntryId.d.ts +1 -1
  20. package/crud/contentEntry/abstractions/IGetPreviousRevisionByEntryId.js.map +1 -1
  21. package/crud/contentEntry/abstractions/IGetPublishedEntriesByIds.d.ts +1 -1
  22. package/crud/contentEntry/abstractions/IGetPublishedEntriesByIds.js.map +1 -1
  23. package/crud/contentEntry/abstractions/IGetPublishedRevisionByEntryId.d.ts +1 -1
  24. package/crud/contentEntry/abstractions/IGetPublishedRevisionByEntryId.js.map +1 -1
  25. package/crud/contentEntry/abstractions/IGetRevisionById.d.ts +1 -1
  26. package/crud/contentEntry/abstractions/IGetRevisionById.js.map +1 -1
  27. package/crud/contentEntry/abstractions/IGetRevisionsByEntryId.d.ts +1 -1
  28. package/crud/contentEntry/abstractions/IGetRevisionsByEntryId.js.map +1 -1
  29. package/crud/contentEntry/abstractions/IListEntries.d.ts +2 -2
  30. package/crud/contentEntry/abstractions/IListEntries.js.map +1 -1
  31. package/crud/contentEntry/abstractions/IListEntriesOperation.d.ts +1 -1
  32. package/crud/contentEntry/abstractions/IListEntriesOperation.js.map +1 -1
  33. package/crud/contentEntry/abstractions/IMoveEntryToBinOperation.d.ts +1 -1
  34. package/crud/contentEntry/abstractions/IMoveEntryToBinOperation.js.map +1 -1
  35. package/crud/contentEntry/abstractions/IRestoreEntryFromBin.d.ts +1 -1
  36. package/crud/contentEntry/abstractions/IRestoreEntryFromBin.js.map +1 -1
  37. package/crud/contentEntry/abstractions/IRestoreEntryFromBinOperation.d.ts +1 -1
  38. package/crud/contentEntry/abstractions/IRestoreEntryFromBinOperation.js.map +1 -1
  39. package/crud/contentEntry/afterDelete.d.ts +2 -2
  40. package/crud/contentEntry/afterDelete.js.map +1 -1
  41. package/crud/contentEntry/beforeCreate.d.ts +2 -2
  42. package/crud/contentEntry/beforeCreate.js.map +1 -1
  43. package/crud/contentEntry/beforeUpdate.d.ts +2 -2
  44. package/crud/contentEntry/beforeUpdate.js.map +1 -1
  45. package/crud/contentEntry/entryDataFactories/createEntryData.d.ts +5 -5
  46. package/crud/contentEntry/entryDataFactories/createEntryData.js +1 -1
  47. package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -1
  48. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.d.ts +5 -5
  49. package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -1
  50. package/crud/contentEntry/entryDataFactories/createPublishEntryData.d.ts +4 -4
  51. package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -1
  52. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.d.ts +2 -2
  53. package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -1
  54. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.d.ts +4 -4
  55. package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -1
  56. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.d.ts +4 -4
  57. package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -1
  58. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.d.ts +1 -1
  59. package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js.map +1 -1
  60. package/crud/contentEntry/entryDataValidation.d.ts +1 -1
  61. package/crud/contentEntry/entryDataValidation.js.map +1 -1
  62. package/crud/contentEntry/markLockedFields.d.ts +1 -1
  63. package/crud/contentEntry/markLockedFields.js.map +1 -1
  64. package/crud/contentEntry/referenceFieldsMapping.d.ts +1 -1
  65. package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
  66. package/crud/contentEntry/searchableFields.d.ts +3 -3
  67. package/crud/contentEntry/searchableFields.js +51 -4
  68. package/crud/contentEntry/searchableFields.js.map +1 -1
  69. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntry.d.ts +3 -3
  70. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntry.js.map +1 -1
  71. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperation.d.ts +2 -2
  72. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperation.js.map +1 -1
  73. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperationWithEvents.d.ts +3 -3
  74. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntryOperationWithEvents.js.map +1 -1
  75. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntrySecure.d.ts +3 -3
  76. package/crud/contentEntry/useCases/DeleteEntry/DeleteEntrySecure.js.map +1 -1
  77. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBin.d.ts +3 -3
  78. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBin.js.map +1 -1
  79. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperation.d.ts +2 -2
  80. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperation.js.map +1 -1
  81. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperationWithEvents.d.ts +3 -3
  82. package/crud/contentEntry/useCases/DeleteEntry/MoveEntryToBinOperationWithEvents.js.map +1 -1
  83. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryDelete.d.ts +1 -1
  84. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryDelete.js.map +1 -1
  85. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.d.ts +2 -2
  86. package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.js.map +1 -1
  87. package/crud/contentEntry/useCases/DeleteEntry/index.d.ts +5 -5
  88. package/crud/contentEntry/useCases/DeleteEntry/index.js.map +1 -1
  89. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIds.d.ts +7 -5
  90. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIds.js +6 -2
  91. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIds.js.map +1 -1
  92. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsNotDeleted.d.ts +2 -2
  93. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsNotDeleted.js.map +1 -1
  94. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsSecure.d.ts +3 -3
  95. package/crud/contentEntry/useCases/GetEntriesByIds/GetEntriesByIdsSecure.js.map +1 -1
  96. package/crud/contentEntry/useCases/GetEntriesByIds/index.d.ts +4 -2
  97. package/crud/contentEntry/useCases/GetEntriesByIds/index.js +1 -1
  98. package/crud/contentEntry/useCases/GetEntriesByIds/index.js.map +1 -1
  99. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIds.d.ts +7 -5
  100. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIds.js +6 -2
  101. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIds.js.map +1 -1
  102. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsNotDeleted.d.ts +2 -2
  103. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsNotDeleted.js.map +1 -1
  104. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsSecure.d.ts +3 -3
  105. package/crud/contentEntry/useCases/GetLatestEntriesByIds/GetLatestEntriesByIdsSecure.js.map +1 -1
  106. package/crud/contentEntry/useCases/GetLatestEntriesByIds/index.d.ts +4 -2
  107. package/crud/contentEntry/useCases/GetLatestEntriesByIds/index.js +1 -1
  108. package/crud/contentEntry/useCases/GetLatestEntriesByIds/index.js.map +1 -1
  109. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryId.d.ts +7 -5
  110. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryId.js +7 -2
  111. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryId.js.map +1 -1
  112. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdDeleted.d.ts +2 -2
  113. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdDeleted.js.map +1 -1
  114. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdNotDeleted.d.ts +2 -2
  115. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/GetLatestRevisionByEntryIdNotDeleted.js.map +1 -1
  116. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/index.d.ts +3 -1
  117. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/index.js +1 -1
  118. package/crud/contentEntry/useCases/GetLatestRevisionByEntryId/index.js.map +1 -1
  119. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryId.d.ts +7 -5
  120. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryId.js +7 -2
  121. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryId.js.map +1 -1
  122. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdNotDeleted.d.ts +2 -2
  123. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/GetPreviousRevisionByEntryIdNotDeleted.js.map +1 -1
  124. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/index.d.ts +3 -1
  125. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/index.js +1 -1
  126. package/crud/contentEntry/useCases/GetPreviousRevisionByEntryId/index.js.map +1 -1
  127. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIds.d.ts +7 -5
  128. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIds.js +6 -2
  129. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIds.js.map +1 -1
  130. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsNotDeleted.d.ts +2 -2
  131. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsNotDeleted.js.map +1 -1
  132. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsSecure.d.ts +3 -3
  133. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/GetPublishedEntriesByIdsSecure.js.map +1 -1
  134. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/index.d.ts +4 -2
  135. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/index.js +1 -1
  136. package/crud/contentEntry/useCases/GetPublishedEntriesByIds/index.js.map +1 -1
  137. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryId.d.ts +7 -5
  138. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryId.js +7 -2
  139. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryId.js.map +1 -1
  140. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdNotDeleted.d.ts +2 -2
  141. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdNotDeleted.js.map +1 -1
  142. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/index.d.ts +3 -1
  143. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/index.js +1 -1
  144. package/crud/contentEntry/useCases/GetPublishedRevisionByEntryId/index.js.map +1 -1
  145. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionById.d.ts +7 -5
  146. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionById.js +7 -2
  147. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionById.js.map +1 -1
  148. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionByIdNotDeleted.d.ts +2 -2
  149. package/crud/contentEntry/useCases/GetRevisionById/GetRevisionByIdNotDeleted.js.map +1 -1
  150. package/crud/contentEntry/useCases/GetRevisionById/index.d.ts +3 -1
  151. package/crud/contentEntry/useCases/GetRevisionById/index.js +1 -1
  152. package/crud/contentEntry/useCases/GetRevisionById/index.js.map +1 -1
  153. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryId.d.ts +7 -5
  154. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryId.js +6 -2
  155. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryId.js.map +1 -1
  156. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryIdNotDeleted.d.ts +2 -2
  157. package/crud/contentEntry/useCases/GetRevisionsByEntryId/GetRevisionsByEntryIdNotDeleted.js.map +1 -1
  158. package/crud/contentEntry/useCases/GetRevisionsByEntryId/index.d.ts +4 -2
  159. package/crud/contentEntry/useCases/GetRevisionsByEntryId/index.js +1 -1
  160. package/crud/contentEntry/useCases/GetRevisionsByEntryId/index.js.map +1 -1
  161. package/crud/contentEntry/useCases/ListEntries/GetEntry.d.ts +2 -2
  162. package/crud/contentEntry/useCases/ListEntries/GetEntry.js.map +1 -1
  163. package/crud/contentEntry/useCases/ListEntries/GetEntrySecure.d.ts +4 -4
  164. package/crud/contentEntry/useCases/ListEntries/GetEntrySecure.js.map +1 -1
  165. package/crud/contentEntry/useCases/ListEntries/ListEntries.d.ts +3 -3
  166. package/crud/contentEntry/useCases/ListEntries/ListEntries.js.map +1 -1
  167. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperation.d.ts +12 -5
  168. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperation.js +9 -2
  169. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperation.js.map +1 -1
  170. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationDeleted.d.ts +2 -2
  171. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationDeleted.js.map +1 -1
  172. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationLatest.d.ts +2 -2
  173. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationLatest.js.map +1 -1
  174. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationNotDeleted.d.ts +2 -2
  175. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationNotDeleted.js.map +1 -1
  176. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationPublished.d.ts +2 -2
  177. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationPublished.js.map +1 -1
  178. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithEvents.d.ts +3 -3
  179. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithEvents.js.map +1 -1
  180. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSearchableFields.d.ts +5 -4
  181. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSearchableFields.js +10 -2
  182. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSearchableFields.js.map +1 -1
  183. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSort.d.ts +2 -2
  184. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithSort.js.map +1 -1
  185. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithStatusCheck.d.ts +2 -2
  186. package/crud/contentEntry/useCases/ListEntries/ListEntriesOperationWithStatusCheck.js.map +1 -1
  187. package/crud/contentEntry/useCases/ListEntries/ListEntriesSecure.d.ts +5 -5
  188. package/crud/contentEntry/useCases/ListEntries/ListEntriesSecure.js.map +1 -1
  189. package/crud/contentEntry/useCases/ListEntries/index.d.ts +6 -4
  190. package/crud/contentEntry/useCases/ListEntries/index.js +2 -2
  191. package/crud/contentEntry/useCases/ListEntries/index.js.map +1 -1
  192. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBin.d.ts +3 -3
  193. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBin.js.map +1 -1
  194. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperation.d.ts +7 -5
  195. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperation.js +4 -2
  196. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperation.js.map +1 -1
  197. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperationWithEvents.d.ts +3 -3
  198. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinOperationWithEvents.js.map +1 -1
  199. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinSecure.d.ts +3 -3
  200. package/crud/contentEntry/useCases/RestoreEntryFromBin/RestoreEntryFromBinSecure.js.map +1 -1
  201. package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.d.ts +2 -2
  202. package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.js.map +1 -1
  203. package/crud/contentEntry/useCases/RestoreEntryFromBin/index.d.ts +7 -5
  204. package/crud/contentEntry/useCases/RestoreEntryFromBin/index.js +1 -1
  205. package/crud/contentEntry/useCases/RestoreEntryFromBin/index.js.map +1 -1
  206. package/crud/contentEntry.crud.d.ts +5 -5
  207. package/crud/contentEntry.crud.js +21 -44
  208. package/crud/contentEntry.crud.js.map +1 -1
  209. package/crud/contentModel/beforeCreate.d.ts +2 -2
  210. package/crud/contentModel/beforeCreate.js.map +1 -1
  211. package/crud/contentModel/beforeDelete.d.ts +2 -2
  212. package/crud/contentModel/beforeDelete.js.map +1 -1
  213. package/crud/contentModel/beforeUpdate.d.ts +2 -2
  214. package/crud/contentModel/beforeUpdate.js.map +1 -1
  215. package/crud/contentModel/compatibility/modelApiName.d.ts +1 -1
  216. package/crud/contentModel/compatibility/modelApiName.js.map +1 -1
  217. package/crud/contentModel/contentModelManagerFactory.d.ts +1 -1
  218. package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
  219. package/crud/contentModel/createFieldStorageId.d.ts +1 -1
  220. package/crud/contentModel/createFieldStorageId.js.map +1 -1
  221. package/crud/contentModel/defaultFields.d.ts +1 -1
  222. package/crud/contentModel/defaultFields.js.map +1 -1
  223. package/crud/contentModel/ensureTypeTag.d.ts +1 -1
  224. package/crud/contentModel/ensureTypeTag.js.map +1 -1
  225. package/crud/contentModel/fields/descriptionField.d.ts +1 -1
  226. package/crud/contentModel/fields/descriptionField.js.map +1 -1
  227. package/crud/contentModel/fields/getApplicableFieldById.d.ts +1 -1
  228. package/crud/contentModel/fields/getApplicableFieldById.js.map +1 -1
  229. package/crud/contentModel/fields/imageField.d.ts +1 -1
  230. package/crud/contentModel/fields/imageField.js.map +1 -1
  231. package/crud/contentModel/fields/titleField.d.ts +1 -1
  232. package/crud/contentModel/fields/titleField.js.map +1 -1
  233. package/crud/contentModel/listModelsFromDatabase.d.ts +3 -3
  234. package/crud/contentModel/listModelsFromDatabase.js.map +1 -1
  235. package/crud/contentModel/validate/endingAllowed.d.ts +1 -1
  236. package/crud/contentModel/validate/endingAllowed.js.map +1 -1
  237. package/crud/contentModel/validate/modelId.d.ts +1 -1
  238. package/crud/contentModel/validate/modelId.js.map +1 -1
  239. package/crud/contentModel/validate/pluralApiName.d.ts +1 -1
  240. package/crud/contentModel/validate/pluralApiName.js.map +1 -1
  241. package/crud/contentModel/validate/singularApiName.d.ts +1 -1
  242. package/crud/contentModel/validate/singularApiName.js.map +1 -1
  243. package/crud/contentModel/validateModel.d.ts +1 -1
  244. package/crud/contentModel/validateModel.js.map +1 -1
  245. package/crud/contentModel/validateModelFields.d.ts +1 -1
  246. package/crud/contentModel/validateModelFields.js.map +1 -1
  247. package/crud/contentModel/validation.d.ts +132 -132
  248. package/crud/contentModel.crud.d.ts +5 -5
  249. package/crud/contentModel.crud.js.map +1 -1
  250. package/crud/contentModelGroup/beforeCreate.d.ts +3 -3
  251. package/crud/contentModelGroup/beforeCreate.js.map +1 -1
  252. package/crud/contentModelGroup/beforeDelete.d.ts +3 -3
  253. package/crud/contentModelGroup/beforeDelete.js.map +1 -1
  254. package/crud/contentModelGroup/beforeUpdate.d.ts +3 -3
  255. package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
  256. package/crud/contentModelGroup/listGroupsFromDatabase.d.ts +1 -1
  257. package/crud/contentModelGroup/listGroupsFromDatabase.js.map +1 -1
  258. package/crud/contentModelGroup/validation.d.ts +2 -2
  259. package/crud/contentModelGroup.crud.d.ts +5 -5
  260. package/crud/contentModelGroup.crud.js.map +1 -1
  261. package/crud/system.crud.d.ts +4 -4
  262. package/crud/system.crud.js +10 -0
  263. package/crud/system.crud.js.map +1 -1
  264. package/export/crud/exporting.d.ts +2 -2
  265. package/export/crud/exporting.js.map +1 -1
  266. package/export/crud/importing.d.ts +2 -2
  267. package/export/crud/importing.js.map +1 -1
  268. package/export/crud/imports/importData.d.ts +2 -2
  269. package/export/crud/imports/importData.js.map +1 -1
  270. package/export/crud/imports/importGroups.d.ts +2 -2
  271. package/export/crud/imports/importGroups.js.map +1 -1
  272. package/export/crud/imports/importModels.d.ts +2 -2
  273. package/export/crud/imports/importModels.js.map +1 -1
  274. package/export/crud/imports/validateGroups.d.ts +2 -2
  275. package/export/crud/imports/validateGroups.js.map +1 -1
  276. package/export/crud/imports/validateInput.d.ts +2 -2
  277. package/export/crud/imports/validateInput.js.map +1 -1
  278. package/export/crud/imports/validateModels.d.ts +2 -2
  279. package/export/crud/imports/validateModels.js.map +1 -1
  280. package/export/crud/index.d.ts +1 -1
  281. package/export/crud/index.js.map +1 -1
  282. package/export/crud/sanitize.d.ts +2 -2
  283. package/export/crud/sanitize.js.map +1 -1
  284. package/export/graphql/index.d.ts +1 -1
  285. package/export/graphql/index.js.map +1 -1
  286. package/export/types.d.ts +1 -1
  287. package/export/types.js.map +1 -1
  288. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.d.ts +3 -2
  289. package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
  290. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.d.ts +3 -2
  291. package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
  292. package/fieldConverters/CmsModelObjectFieldConverterPlugin.d.ts +3 -2
  293. package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
  294. package/graphql/buildSchemaPlugins.d.ts +2 -2
  295. package/graphql/buildSchemaPlugins.js.map +1 -1
  296. package/graphql/checkEndpointAccess.d.ts +1 -1
  297. package/graphql/checkEndpointAccess.js.map +1 -1
  298. package/graphql/createExecutableSchema.d.ts +1 -1
  299. package/graphql/createExecutableSchema.js.map +1 -1
  300. package/graphql/createRequestBody.d.ts +1 -1
  301. package/graphql/createRequestBody.js.map +1 -1
  302. package/graphql/generateSchema.d.ts +2 -2
  303. package/graphql/generateSchema.js.map +1 -1
  304. package/graphql/getSchema/generateCacheId.d.ts +3 -3
  305. package/graphql/getSchema/generateCacheId.js.map +1 -1
  306. package/graphql/getSchema/generateCacheKey.d.ts +1 -1
  307. package/graphql/getSchema/generateCacheKey.js.map +1 -1
  308. package/graphql/getSchema.d.ts +4 -4
  309. package/graphql/getSchema.js.map +1 -1
  310. package/graphql/graphQLHandlerFactory.d.ts +1 -1
  311. package/graphql/graphQLHandlerFactory.js.map +1 -1
  312. package/graphql/handleRequest.d.ts +2 -2
  313. package/graphql/handleRequest.js.map +1 -1
  314. package/graphql/index.d.ts +2 -2
  315. package/graphql/index.js.map +1 -1
  316. package/graphql/scalars/RevisionIdScalarPlugin.d.ts +1 -1
  317. package/graphql/scalars/RevisionIdScalarPlugin.js.map +1 -1
  318. package/graphql/schema/baseContentSchema.d.ts +2 -2
  319. package/graphql/schema/baseContentSchema.js.map +1 -1
  320. package/graphql/schema/baseSchema.js +0 -1
  321. package/graphql/schema/baseSchema.js.map +1 -1
  322. package/graphql/schema/contentEntries.d.ts +2 -2
  323. package/graphql/schema/contentEntries.js.map +1 -1
  324. package/graphql/schema/contentModelGroups.d.ts +2 -2
  325. package/graphql/schema/contentModelGroups.js.map +1 -1
  326. package/graphql/schema/contentModels.d.ts +2 -2
  327. package/graphql/schema/contentModels.js.map +1 -1
  328. package/graphql/schema/createFieldResolvers.d.ts +2 -2
  329. package/graphql/schema/createFieldResolvers.js.map +1 -1
  330. package/graphql/schema/createFieldTypePluginRecords.d.ts +2 -2
  331. package/graphql/schema/createFieldTypePluginRecords.js.map +1 -1
  332. package/graphql/schema/createManageSDL.d.ts +2 -2
  333. package/graphql/schema/createManageSDL.js.map +1 -1
  334. package/graphql/schema/createPreviewResolvers.js +0 -5
  335. package/graphql/schema/createPreviewResolvers.js.map +1 -1
  336. package/graphql/schema/createReadResolvers.js +0 -5
  337. package/graphql/schema/createReadResolvers.js.map +1 -1
  338. package/graphql/schema/createReadSDL.d.ts +2 -2
  339. package/graphql/schema/createReadSDL.js +0 -1
  340. package/graphql/schema/createReadSDL.js.map +1 -1
  341. package/graphql/schema/createSingularSDL.d.ts +1 -1
  342. package/graphql/schema/createSingularSDL.js.map +1 -1
  343. package/graphql/schema/resolvers/manage/normalizeGraphQlInput.d.ts +1 -1
  344. package/graphql/schema/resolvers/manage/normalizeGraphQlInput.js.map +1 -1
  345. package/graphql/schema/resolvers/manage/resolveCreate.d.ts +1 -1
  346. package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
  347. package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
  348. package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
  349. package/graphql/schema/resolvers/manage/resolveDelete.d.ts +1 -1
  350. package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
  351. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +1 -1
  352. package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -1
  353. package/graphql/schema/resolvers/manage/resolveGet.d.ts +1 -1
  354. package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
  355. package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
  356. package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
  357. package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
  358. package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
  359. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +1 -1
  360. package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -1
  361. package/graphql/schema/resolvers/manage/resolveList.d.ts +1 -1
  362. package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
  363. package/graphql/schema/resolvers/manage/resolveListDeleted.d.ts +1 -1
  364. package/graphql/schema/resolvers/manage/resolveListDeleted.js.map +1 -1
  365. package/graphql/schema/resolvers/manage/resolveMove.d.ts +1 -1
  366. package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -1
  367. package/graphql/schema/resolvers/manage/resolvePublish.d.ts +1 -1
  368. package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
  369. package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +1 -1
  370. package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
  371. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.d.ts +1 -1
  372. package/graphql/schema/resolvers/manage/resolveRestoreFromBin.js.map +1 -1
  373. package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
  374. package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
  375. package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
  376. package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
  377. package/graphql/schema/resolvers/manage/resolveValidate.d.ts +1 -1
  378. package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -1
  379. package/graphql/schema/resolvers/preview/resolveGet.d.ts +1 -1
  380. package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
  381. package/graphql/schema/resolvers/preview/resolveList.d.ts +1 -1
  382. package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
  383. package/graphql/schema/resolvers/read/resolveGet.d.ts +1 -1
  384. package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
  385. package/graphql/schema/resolvers/read/resolveList.d.ts +1 -1
  386. package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
  387. package/graphql/schema/resolvers/singular/resolveGet.d.ts +1 -1
  388. package/graphql/schema/resolvers/singular/resolveGet.js.map +1 -1
  389. package/graphql/schema/resolvers/singular/resolveUpdate.d.ts +1 -1
  390. package/graphql/schema/resolvers/singular/resolveUpdate.js.map +1 -1
  391. package/graphql/schema/schemaPlugins.d.ts +1 -1
  392. package/graphql/schema/schemaPlugins.js.map +1 -1
  393. package/graphql/system.d.ts +1 -1
  394. package/graphql/system.js.map +1 -1
  395. package/graphqlFields/boolean.d.ts +1 -1
  396. package/graphqlFields/boolean.js.map +1 -1
  397. package/graphqlFields/datetime.d.ts +1 -1
  398. package/graphqlFields/datetime.js.map +1 -1
  399. package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
  400. package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
  401. package/graphqlFields/file.d.ts +1 -1
  402. package/graphqlFields/file.js.map +1 -1
  403. package/graphqlFields/helpers.d.ts +1 -1
  404. package/graphqlFields/helpers.js.map +1 -1
  405. package/graphqlFields/index.d.ts +1 -1
  406. package/graphqlFields/index.js +2 -1
  407. package/graphqlFields/index.js.map +1 -1
  408. package/graphqlFields/json.d.ts +1 -1
  409. package/graphqlFields/json.js.map +1 -1
  410. package/graphqlFields/longText.d.ts +1 -1
  411. package/graphqlFields/longText.js.map +1 -1
  412. package/graphqlFields/number.d.ts +1 -1
  413. package/graphqlFields/number.js.map +1 -1
  414. package/graphqlFields/object.d.ts +1 -1
  415. package/graphqlFields/object.js.map +1 -1
  416. package/graphqlFields/ref.d.ts +1 -1
  417. package/graphqlFields/ref.js.map +1 -1
  418. package/graphqlFields/richText/RichTextPluginsProcessor.d.ts +1 -1
  419. package/graphqlFields/richText/RichTextPluginsProcessor.js.map +1 -1
  420. package/graphqlFields/richText/richTextResolver.d.ts +2 -2
  421. package/graphqlFields/richText/richTextResolver.js.map +1 -1
  422. package/graphqlFields/richText.d.ts +1 -1
  423. package/graphqlFields/richText.js.map +1 -1
  424. package/graphqlFields/searchableJson.d.ts +2 -0
  425. package/graphqlFields/searchableJson.js +60 -0
  426. package/graphqlFields/searchableJson.js.map +1 -0
  427. package/graphqlFields/text.d.ts +1 -1
  428. package/graphqlFields/text.js.map +1 -1
  429. package/htmlRenderer/LexicalRenderer.d.ts +1 -1
  430. package/htmlRenderer/LexicalRenderer.js.map +1 -1
  431. package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -1
  432. package/index.d.ts +3 -3
  433. package/index.js.map +1 -1
  434. package/modelManager/SingletonModelManager.d.ts +1 -1
  435. package/modelManager/SingletonModelManager.js.map +1 -1
  436. package/modelManager/index.d.ts +1 -1
  437. package/modelManager/index.js.map +1 -1
  438. package/package.json +21 -21
  439. package/parameters/header.js.map +1 -1
  440. package/parameters/manual.d.ts +2 -1
  441. package/parameters/manual.js.map +1 -1
  442. package/parameters/path.js.map +1 -1
  443. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +3 -2
  444. package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.js.map +1 -1
  445. package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +1 -1
  446. package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
  447. package/plugins/CmsGroupPlugin.d.ts +1 -1
  448. package/plugins/CmsGroupPlugin.js.map +1 -1
  449. package/plugins/CmsModelFieldConverterPlugin.d.ts +2 -2
  450. package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
  451. package/plugins/CmsModelPlugin.d.ts +1 -1
  452. package/plugins/CmsModelPlugin.js.map +1 -1
  453. package/plugins/CmsParametersPlugin.d.ts +1 -1
  454. package/plugins/CmsParametersPlugin.js.map +1 -1
  455. package/plugins/StorageOperationsCmsModelPlugin.d.ts +1 -1
  456. package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -1
  457. package/plugins/StorageTransformPlugin.d.ts +2 -2
  458. package/plugins/StorageTransformPlugin.js.map +1 -1
  459. package/storage/date.d.ts +1 -1
  460. package/storage/date.js.map +1 -1
  461. package/storage/dynamicZone.js.map +1 -1
  462. package/storage/json.js +34 -5
  463. package/storage/json.js.map +1 -1
  464. package/storage/object.js.map +1 -1
  465. package/types/context.d.ts +7 -7
  466. package/types/context.js.map +1 -1
  467. package/types/fields/dynamicZoneField.d.ts +1 -1
  468. package/types/fields/dynamicZoneField.js.map +1 -1
  469. package/types/fields/objectField.d.ts +1 -1
  470. package/types/fields/objectField.js.map +1 -1
  471. package/types/model.d.ts +3 -3
  472. package/types/model.js.map +1 -1
  473. package/types/modelAst.d.ts +1 -1
  474. package/types/modelAst.js.map +1 -1
  475. package/types/modelField.d.ts +2 -2
  476. package/types/modelField.js.map +1 -1
  477. package/types/modelGroup.d.ts +1 -1
  478. package/types/modelGroup.js.map +1 -1
  479. package/types/plugins.d.ts +6 -6
  480. package/types/plugins.js.map +1 -1
  481. package/types/types.d.ts +20 -43
  482. package/types/types.js.map +1 -1
  483. package/utils/RichTextRenderer.d.ts +2 -2
  484. package/utils/RichTextRenderer.js.map +1 -1
  485. package/utils/caching/Cache.d.ts +1 -1
  486. package/utils/caching/Cache.js.map +1 -1
  487. package/utils/caching/CacheKey.d.ts +2 -2
  488. package/utils/caching/CacheKey.js.map +1 -1
  489. package/utils/contentEntryTraverser/ContentEntryTraverser.d.ts +1 -1
  490. package/utils/contentEntryTraverser/ContentEntryTraverser.js.map +1 -1
  491. package/utils/contentModelAst/CmsModelFieldToAstConverterFromPlugins.d.ts +1 -1
  492. package/utils/contentModelAst/CmsModelFieldToAstConverterFromPlugins.js.map +1 -1
  493. package/utils/contentModelAst/CmsModelFieldToAstFromPlugin.d.ts +1 -1
  494. package/utils/contentModelAst/CmsModelFieldToAstFromPlugin.js.map +1 -1
  495. package/utils/contentModelAst/CmsModelToAstConverter.d.ts +1 -1
  496. package/utils/contentModelAst/CmsModelToAstConverter.js.map +1 -1
  497. package/utils/converters/Converter.d.ts +3 -3
  498. package/utils/converters/Converter.js.map +1 -1
  499. package/utils/converters/ConverterCollection.d.ts +2 -2
  500. package/utils/converters/ConverterCollection.js.map +1 -1
  501. package/utils/converters/valueKeyStorageConverter.d.ts +3 -3
  502. package/utils/converters/valueKeyStorageConverter.js.map +1 -1
  503. package/utils/createModelField.d.ts +1 -1
  504. package/utils/createModelField.js.map +1 -1
  505. package/utils/createTypeFromFields.d.ts +1 -1
  506. package/utils/createTypeFromFields.js.map +1 -1
  507. package/utils/entryStorage.d.ts +8 -1
  508. package/utils/entryStorage.js +37 -4
  509. package/utils/entryStorage.js.map +1 -1
  510. package/utils/getBaseFieldType.d.ts +1 -1
  511. package/utils/getBaseFieldType.js.map +1 -1
  512. package/utils/getEntryDescription.d.ts +1 -1
  513. package/utils/getEntryDescription.js.map +1 -1
  514. package/utils/getEntryImage.d.ts +1 -1
  515. package/utils/getEntryImage.js.map +1 -1
  516. package/utils/getEntryTitle.d.ts +1 -1
  517. package/utils/getEntryTitle.js.map +1 -1
  518. package/utils/getSchemaFromFieldPlugins.d.ts +4 -4
  519. package/utils/getSchemaFromFieldPlugins.js.map +1 -1
  520. package/utils/identity.d.ts +1 -1
  521. package/utils/identity.js.map +1 -1
  522. package/utils/isHeadlessCmsReady.d.ts +1 -1
  523. package/utils/isHeadlessCmsReady.js.map +1 -1
  524. package/utils/modelFieldTraverser/ModelFieldTraverser.d.ts +1 -1
  525. package/utils/modelFieldTraverser/ModelFieldTraverser.js.map +1 -1
  526. package/utils/renderFields.d.ts +1 -1
  527. package/utils/renderFields.js.map +1 -1
  528. package/utils/renderGetFilterFields.d.ts +1 -1
  529. package/utils/renderGetFilterFields.js.map +1 -1
  530. package/utils/renderInputFields.d.ts +1 -1
  531. package/utils/renderInputFields.js.map +1 -1
  532. package/utils/renderListFilterFields.d.ts +1 -1
  533. package/utils/renderListFilterFields.js.map +1 -1
  534. package/utils/renderSortEnum.d.ts +2 -2
  535. package/utils/renderSortEnum.js.map +1 -1
  536. package/validators/dateGte.d.ts +1 -1
  537. package/validators/dateGte.js.map +1 -1
  538. package/validators/dateLte.d.ts +1 -1
  539. package/validators/dateLte.js.map +1 -1
  540. package/validators/gte.d.ts +1 -1
  541. package/validators/gte.js.map +1 -1
  542. package/validators/in.d.ts +1 -1
  543. package/validators/in.js.map +1 -1
  544. package/validators/lte.d.ts +1 -1
  545. package/validators/lte.js.map +1 -1
  546. package/validators/maxLength.d.ts +1 -1
  547. package/validators/maxLength.js.map +1 -1
  548. package/validators/minLength.d.ts +1 -1
  549. package/validators/minLength.js.map +1 -1
  550. package/validators/pattern.d.ts +1 -1
  551. package/validators/pattern.js.map +1 -1
  552. package/validators/patternPlugins/email.d.ts +1 -1
  553. package/validators/patternPlugins/email.js.map +1 -1
  554. package/validators/patternPlugins/index.d.ts +1 -1
  555. package/validators/patternPlugins/index.js.map +1 -1
  556. package/validators/patternPlugins/lowerCase.d.ts +1 -1
  557. package/validators/patternPlugins/lowerCase.js.map +1 -1
  558. package/validators/patternPlugins/lowerCaseSpace.d.ts +1 -1
  559. package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
  560. package/validators/patternPlugins/upperCase.d.ts +1 -1
  561. package/validators/patternPlugins/upperCase.js.map +1 -1
  562. package/validators/patternPlugins/upperCaseSpace.d.ts +1 -1
  563. package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
  564. package/validators/patternPlugins/url.d.ts +1 -1
  565. package/validators/patternPlugins/url.js.map +1 -1
  566. package/validators/required.d.ts +1 -1
  567. package/validators/required.js.map +1 -1
  568. package/validators/timeGte.d.ts +1 -1
  569. package/validators/timeGte.js.map +1 -1
  570. package/validators/timeLte.d.ts +1 -1
  571. package/validators/timeLte.js.map +1 -1
  572. package/validators/unique.d.ts +1 -1
  573. package/validators/unique.js.map +1 -1
  574. package/crud/contentEntry/FullTextSearchFields.d.ts +0 -22
  575. package/crud/contentEntry/FullTextSearchFields.js +0 -109
  576. package/crud/contentEntry/FullTextSearchFields.js.map +0 -1
  577. package/graphql/schema/resolvers/preview/resolveGetById.d.ts +0 -7
  578. package/graphql/schema/resolvers/preview/resolveGetById.js +0 -24
  579. package/graphql/schema/resolvers/preview/resolveGetById.js.map +0 -1
  580. package/graphql/schema/resolvers/read/resolveGetById.d.ts +0 -7
  581. package/graphql/schema/resolvers/read/resolveGetById.js +0 -24
  582. package/graphql/schema/resolvers/read/resolveGetById.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { CmsModel, CmsModelAst, ICmsModelFieldToAst } from "../../types";
1
+ import type { CmsModel, CmsModelAst, ICmsModelFieldToAst } from "../../types";
2
2
  /**
3
3
  * The purpose of this class is to convert the given CmsModel to an AST, which is easier to traverse programmatically.
4
4
  * Using this, we can get information about the structure of the model fields, without understanding how each
@@ -1 +1 @@
1
- {"version":3,"names":["CmsModelToAstConverter","constructor","fieldToAstConverter","toAst","model","type","children","fields","reduce","ast","field","exports"],"sources":["CmsModelToAstConverter.ts"],"sourcesContent":["import { CmsModel, CmsModelAst, CmsModelFieldAstNode, ICmsModelFieldToAst } from \"~/types\";\n\n/**\n * The purpose of this class is to convert the given CmsModel to an AST, which is easier to traverse programmatically.\n * Using this, we can get information about the structure of the model fields, without understanding how each\n * individual model field stores its internal data. This is particularly useful for fields like `dynamicZone` and `object`.\n */\n\nexport class CmsModelToAstConverter {\n private readonly fieldToAstConverter: ICmsModelFieldToAst;\n\n public constructor(fieldToAstConverter: ICmsModelFieldToAst) {\n this.fieldToAstConverter = fieldToAstConverter;\n }\n\n public toAst(model: Pick<CmsModel, \"fields\">): CmsModelAst {\n return {\n type: \"root\",\n children: model.fields.reduce<CmsModelFieldAstNode[]>((ast, field) => {\n return [...ast, this.fieldToAstConverter.toAst(field)];\n }, [])\n };\n }\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,sBAAsB,CAAC;EAGzBC,WAAWA,CAACC,mBAAwC,EAAE;IACzD,IAAI,CAACA,mBAAmB,GAAGA,mBAAmB;EAClD;EAEOC,KAAKA,CAACC,KAA+B,EAAe;IACvD,OAAO;MACHC,IAAI,EAAE,MAAM;MACZC,QAAQ,EAAEF,KAAK,CAACG,MAAM,CAACC,MAAM,CAAyB,CAACC,GAAG,EAAEC,KAAK,KAAK;QAClE,OAAO,CAAC,GAAGD,GAAG,EAAE,IAAI,CAACP,mBAAmB,CAACC,KAAK,CAACO,KAAK,CAAC,CAAC;MAC1D,CAAC,EAAE,EAAE;IACT,CAAC;EACL;AACJ;AAACC,OAAA,CAAAX,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CmsModelToAstConverter","constructor","fieldToAstConverter","toAst","model","type","children","fields","reduce","ast","field","exports"],"sources":["CmsModelToAstConverter.ts"],"sourcesContent":["import type { CmsModel, CmsModelAst, CmsModelFieldAstNode, ICmsModelFieldToAst } from \"~/types\";\n\n/**\n * The purpose of this class is to convert the given CmsModel to an AST, which is easier to traverse programmatically.\n * Using this, we can get information about the structure of the model fields, without understanding how each\n * individual model field stores its internal data. This is particularly useful for fields like `dynamicZone` and `object`.\n */\n\nexport class CmsModelToAstConverter {\n private readonly fieldToAstConverter: ICmsModelFieldToAst;\n\n public constructor(fieldToAstConverter: ICmsModelFieldToAst) {\n this.fieldToAstConverter = fieldToAstConverter;\n }\n\n public toAst(model: Pick<CmsModel, \"fields\">): CmsModelAst {\n return {\n type: \"root\",\n children: model.fields.reduce<CmsModelFieldAstNode[]>((ast, field) => {\n return [...ast, this.fieldToAstConverter.toAst(field)];\n }, [])\n };\n }\n}\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;;AAEO,MAAMA,sBAAsB,CAAC;EAGzBC,WAAWA,CAACC,mBAAwC,EAAE;IACzD,IAAI,CAACA,mBAAmB,GAAGA,mBAAmB;EAClD;EAEOC,KAAKA,CAACC,KAA+B,EAAe;IACvD,OAAO;MACHC,IAAI,EAAE,MAAM;MACZC,QAAQ,EAAEF,KAAK,CAACG,MAAM,CAACC,MAAM,CAAyB,CAACC,GAAG,EAAEC,KAAK,KAAK;QAClE,OAAO,CAAC,GAAGD,GAAG,EAAE,IAAI,CAACP,mBAAmB,CAACC,KAAK,CAACO,KAAK,CAAC,CAAC;MAC1D,CAAC,EAAE,EAAE;IACT,CAAC;EACL;AACJ;AAACC,OAAA,CAAAX,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { CmsEntryValues, CmsModelField } from "../../types";
2
- import { CmsModelFieldConverterPlugin } from "../../plugins";
3
- import { ConverterCollection } from "./ConverterCollection";
1
+ import type { CmsEntryValues, CmsModelField } from "../../types";
2
+ import type { CmsModelFieldConverterPlugin } from "../../plugins";
3
+ import type { ConverterCollection } from "./ConverterCollection";
4
4
  export interface CmsModelFieldWithParent extends CmsModelField {
5
5
  parent?: CmsModelFieldWithParent | null;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","Converter","converters","undefined","constructor","config","type","plugin","setConverterCollection","WebinyError","getConverterCollection","getType","convertToStorage","params","field","value","converterCollection","convertFromStorage","exports"],"sources":["Converter.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryValues, CmsModelField } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport { ConverterCollection } from \"./ConverterCollection\";\n\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\ninterface ConverterConvertParams {\n field: CmsModelFieldWithParent;\n value: any;\n parent?: CmsModelFieldWithParent | null;\n}\nexport interface ConverterConfig {\n type: string;\n plugin: CmsModelFieldConverterPlugin;\n}\nexport class Converter {\n private readonly type: string;\n private readonly plugin: CmsModelFieldConverterPlugin;\n\n private converters: ConverterCollection | undefined = undefined;\n\n public constructor(config: ConverterConfig) {\n this.type = config.type;\n this.plugin = config.plugin;\n }\n\n public setConverterCollection(converters: ConverterCollection): void {\n if (this.converters) {\n throw new WebinyError(\n `Cannot attach converters collection more than once to Converter with type \"${this.type}\".`,\n \"CONVERTER_COLLECTION_ERROR\",\n {\n type: this.type\n }\n );\n }\n this.converters = converters;\n }\n\n public getConverterCollection(): ConverterCollection {\n if (!this.converters) {\n throw new WebinyError(\n `There is no ConverterCollection defined in the converter with type \"${this.type}\".`\n );\n }\n return this.converters;\n }\n\n public getType(): string {\n return this.type;\n }\n\n public convertToStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertToStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n }\n\n public convertFromStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertFromStorage({\n field,\n value,\n converterCollection: this.getConverterCollection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AAC;IACrD,CAAC,CAAC;EACN;AACJ;AAACQ,OAAA,CAAAjB,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","Converter","converters","undefined","constructor","config","type","plugin","setConverterCollection","WebinyError","getConverterCollection","getType","convertToStorage","params","field","value","converterCollection","convertFromStorage","exports"],"sources":["Converter.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryValues, CmsModelField } from \"~/types\";\nimport type { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport type { ConverterCollection } from \"./ConverterCollection\";\n\nexport interface CmsModelFieldWithParent extends CmsModelField {\n parent?: CmsModelFieldWithParent | null;\n}\n\ninterface ConverterConvertParams {\n field: CmsModelFieldWithParent;\n value: any;\n parent?: CmsModelFieldWithParent | null;\n}\nexport interface ConverterConfig {\n type: string;\n plugin: CmsModelFieldConverterPlugin;\n}\nexport class Converter {\n private readonly type: string;\n private readonly plugin: CmsModelFieldConverterPlugin;\n\n private converters: ConverterCollection | undefined = undefined;\n\n public constructor(config: ConverterConfig) {\n this.type = config.type;\n this.plugin = config.plugin;\n }\n\n public setConverterCollection(converters: ConverterCollection): void {\n if (this.converters) {\n throw new WebinyError(\n `Cannot attach converters collection more than once to Converter with type \"${this.type}\".`,\n \"CONVERTER_COLLECTION_ERROR\",\n {\n type: this.type\n }\n );\n }\n this.converters = converters;\n }\n\n public getConverterCollection(): ConverterCollection {\n if (!this.converters) {\n throw new WebinyError(\n `There is no ConverterCollection defined in the converter with type \"${this.type}\".`\n );\n }\n return this.converters;\n }\n\n public getType(): string {\n return this.type;\n }\n\n public convertToStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertToStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n }\n\n public convertFromStorage(params: ConverterConvertParams): CmsEntryValues {\n const { field, value } = params;\n\n return this.plugin.convertFromStorage({\n field,\n value,\n converterCollection: this.getConverterCollection()\n });\n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rD,CAAC,CAAC;EACN;AACJ;AAACQ,OAAA,CAAAjB,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import { Converter } from "./Converter";
2
- import { CmsEntryValues, CmsModelField } from "../../types";
3
- import { PluginsContainer } from "@webiny/plugins";
2
+ import type { CmsEntryValues, CmsModelField } from "../../types";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
4
  export interface CmsModelFieldsWithParent extends CmsModelField {
5
5
  parent?: CmsModelField | null;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_Converter","_plugins","_getBaseFieldType","ConverterCollection","converters","Map","constructor","params","plugins","fieldGraphQLPlugins","byType","fieldConverterPlugins","CmsModelFieldConverterPlugin","type","defaultFieldConverterPlugin","find","pl","getFieldType","undefined","WebinyError","fieldGraphQLPlugin","plugin","fieldType","converter","Converter","addConverter","setConverterCollection","set","getType","getConverter","get","convertToStorage","fields","values","inputValues","attachHasOwnProperty","reduce","output","field","baseType","getBaseFieldType","hasOwnProperty","fieldId","value","convertFromStorage","storageId","Array","isArray","Object","defineProperty","enumerable","writable","property","exports"],"sources":["ConverterCollection.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"./Converter\";\nimport { CmsEntryValues, CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport interface CmsModelFieldsWithParent extends CmsModelField {\n parent?: CmsModelField | null;\n}\n\nexport interface CmsModelConverterCallable {\n (params: ConverterCollectionConvertParams): CmsEntryValues;\n}\n\nexport interface ConverterCollectionConvertParams {\n fields: CmsModelFieldsWithParent[];\n values?: CmsEntryValues;\n}\n\nexport interface ConverterCollectionParams {\n plugins: PluginsContainer;\n}\n\nexport class ConverterCollection {\n private readonly converters: Map<string, Converter> = new Map();\n\n public constructor(params: ConverterCollectionParams) {\n const { plugins } = params;\n const fieldGraphQLPlugins = plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n const fieldConverterPlugins = plugins.byType<CmsModelFieldConverterPlugin>(\n CmsModelFieldConverterPlugin.type\n );\n const defaultFieldConverterPlugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === \"*\"\n );\n if (defaultFieldConverterPlugin === undefined) {\n throw new WebinyError(\n `Missing default field converter plugin.`,\n \"DEFAULT_FIELD_CONVERTER_ERROR\"\n );\n }\n for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {\n const plugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType\n );\n const converter = new Converter({\n type: fieldGraphQLPlugin.fieldType,\n plugin: plugin || defaultFieldConverterPlugin\n });\n\n this.addConverter(converter);\n }\n }\n\n public addConverter(converter: Converter): void {\n converter.setConverterCollection(this);\n this.converters.set(converter.getType(), converter);\n }\n\n public getConverter(type: string): Converter {\n const converter = this.converters.get(type);\n if (converter === undefined) {\n throw new WebinyError(\n `Missing converter for field type \"${type}\".`,\n \"CONVERTER_ERROR\",\n {\n type\n }\n );\n }\n return converter;\n }\n\n public convertToStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n this.attachHasOwnProperty(inputValues);\n\n return fields.reduce<CmsEntryValues>((output, field) => {\n const baseType = getBaseFieldType(field);\n const converter = this.getConverter(baseType);\n if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {\n return output;\n }\n const values = converter.convertToStorage({\n field,\n value: inputValues[field.fieldId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n public convertFromStorage(\n params: ConverterCollectionConvertParams\n ): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n return fields.reduce((output, field) => {\n const baseType = getBaseFieldType(field);\n const converter = this.getConverter(baseType);\n if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {\n return output;\n }\n const values = converter.convertFromStorage({\n field,\n value: inputValues[field.storageId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n /**\n * This method attaches hasOwnProperty when received object was created via Object.create(null) - no inheritance of Object.\n * At that point, hasOwnProperty does not exist, and we need to add it.\n *\n * TODO add more checks if required\n */\n private attachHasOwnProperty(values: CmsEntryValues) {\n if (\n // null or undefined?\n values === null ||\n values === undefined ||\n // not an object?\n typeof values !== \"object\" ||\n // maybe it's an array?\n Array.isArray(values) ||\n // and in the end, check if hasOwnProperty is a function already\n typeof values?.hasOwnProperty === \"function\"\n ) {\n return;\n }\n Object.defineProperty(values, \"hasOwnProperty\", {\n enumerable: false,\n writable: false,\n value: function (property: string) {\n return this[property] !== undefined;\n }\n });\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAH,OAAA;AAmBO,MAAMI,mBAAmB,CAAC;EACZC,UAAU,GAA2B,IAAIC,GAAG,CAAC,CAAC;EAExDC,WAAWA,CAACC,MAAiC,EAAE;IAClD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM;IAC1B,MAAME,mBAAmB,GAAGD,OAAO,CAACE,MAAM,CACtC,4BACJ,CAAC;IACD,MAAMC,qBAAqB,GAAGH,OAAO,CAACE,MAAM,CACxCE,qCAA4B,CAACC,IACjC,CAAC;IACD,MAAMC,2BAA2B,GAAGH,qBAAqB,CAACI,IAAI,CAC1DC,EAAE,IAAIA,EAAE,CAACC,YAAY,CAAC,CAAC,KAAK,GAChC,CAAC;IACD,IAAIH,2BAA2B,KAAKI,SAAS,EAAE;MAC3C,MAAM,IAAIC,cAAW,CACjB,yCAAyC,EACzC,+BACJ,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A,MAAM,KAAKf,SAAS;IACpB;IACA,OAAOe,MAAM,KAAK,QAAQ;IAC1B;IACAa,KAAK,CAACC,OAAO,CAACd,MAAM,CAAC;IACrB;IACA,OAAOA,MAAM,EAAEQ,cAAc,KAAK,UAAU,EAC9C;MACE;IACJ;IACAO,MAAM,CAACC,cAAc,CAAChB,MAAM,EAAE,gBAAgB,EAAE;MAC5CiB,UAAU,EAAE,KAAK;MACjBC,QAAQ,EAAE,KAAK;MACfR,KAAK,EAAE,SAAAA,CAAUS,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAACA,QAAQ,CAAC,KAAKlC,SAAS;MACvC;IACJ,CAAC,CAAC;EACN;AACJ;AAACmC,OAAA,CAAAlD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_Converter","_plugins","_getBaseFieldType","ConverterCollection","converters","Map","constructor","params","plugins","fieldGraphQLPlugins","byType","fieldConverterPlugins","CmsModelFieldConverterPlugin","type","defaultFieldConverterPlugin","find","pl","getFieldType","undefined","WebinyError","fieldGraphQLPlugin","plugin","fieldType","converter","Converter","addConverter","setConverterCollection","set","getType","getConverter","get","convertToStorage","fields","values","inputValues","attachHasOwnProperty","reduce","output","field","baseType","getBaseFieldType","hasOwnProperty","fieldId","value","convertFromStorage","storageId","Array","isArray","Object","defineProperty","enumerable","writable","property","exports"],"sources":["ConverterCollection.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"./Converter\";\nimport type { CmsEntryValues, CmsModelField, CmsModelFieldToGraphQLPlugin } from \"~/types\";\nimport { CmsModelFieldConverterPlugin } from \"~/plugins\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport interface CmsModelFieldsWithParent extends CmsModelField {\n parent?: CmsModelField | null;\n}\n\nexport interface CmsModelConverterCallable {\n (params: ConverterCollectionConvertParams): CmsEntryValues;\n}\n\nexport interface ConverterCollectionConvertParams {\n fields: CmsModelFieldsWithParent[];\n values?: CmsEntryValues;\n}\n\nexport interface ConverterCollectionParams {\n plugins: PluginsContainer;\n}\n\nexport class ConverterCollection {\n private readonly converters: Map<string, Converter> = new Map();\n\n public constructor(params: ConverterCollectionParams) {\n const { plugins } = params;\n const fieldGraphQLPlugins = plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n const fieldConverterPlugins = plugins.byType<CmsModelFieldConverterPlugin>(\n CmsModelFieldConverterPlugin.type\n );\n const defaultFieldConverterPlugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === \"*\"\n );\n if (defaultFieldConverterPlugin === undefined) {\n throw new WebinyError(\n `Missing default field converter plugin.`,\n \"DEFAULT_FIELD_CONVERTER_ERROR\"\n );\n }\n for (const fieldGraphQLPlugin of fieldGraphQLPlugins) {\n const plugin = fieldConverterPlugins.find(\n pl => pl.getFieldType() === fieldGraphQLPlugin.fieldType\n );\n const converter = new Converter({\n type: fieldGraphQLPlugin.fieldType,\n plugin: plugin || defaultFieldConverterPlugin\n });\n\n this.addConverter(converter);\n }\n }\n\n public addConverter(converter: Converter): void {\n converter.setConverterCollection(this);\n this.converters.set(converter.getType(), converter);\n }\n\n public getConverter(type: string): Converter {\n const converter = this.converters.get(type);\n if (converter === undefined) {\n throw new WebinyError(\n `Missing converter for field type \"${type}\".`,\n \"CONVERTER_ERROR\",\n {\n type\n }\n );\n }\n return converter;\n }\n\n public convertToStorage(params: ConverterCollectionConvertParams): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n this.attachHasOwnProperty(inputValues);\n\n return fields.reduce<CmsEntryValues>((output, field) => {\n const baseType = getBaseFieldType(field);\n const converter = this.getConverter(baseType);\n if (inputValues === null || inputValues.hasOwnProperty(field.fieldId) === false) {\n return output;\n }\n const values = converter.convertToStorage({\n field,\n value: inputValues[field.fieldId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n public convertFromStorage(\n params: ConverterCollectionConvertParams\n ): CmsEntryValues | undefined {\n const { fields, values: inputValues } = params;\n if (inputValues === undefined) {\n return undefined;\n }\n\n return fields.reduce((output, field) => {\n const baseType = getBaseFieldType(field);\n const converter = this.getConverter(baseType);\n if (inputValues === null || inputValues.hasOwnProperty(field.storageId) === false) {\n return output;\n }\n const values = converter.convertFromStorage({\n field,\n value: inputValues[field.storageId]\n });\n\n return {\n ...output,\n ...values\n };\n }, {});\n }\n\n /**\n * This method attaches hasOwnProperty when received object was created via Object.create(null) - no inheritance of Object.\n * At that point, hasOwnProperty does not exist, and we need to add it.\n *\n * TODO add more checks if required\n */\n private attachHasOwnProperty(values: CmsEntryValues) {\n if (\n // null or undefined?\n values === null ||\n values === undefined ||\n // not an object?\n typeof values !== \"object\" ||\n // maybe it's an array?\n Array.isArray(values) ||\n // and in the end, check if hasOwnProperty is a function already\n typeof values?.hasOwnProperty === \"function\"\n ) {\n return;\n }\n Object.defineProperty(values, \"hasOwnProperty\", {\n enumerable: false,\n writable: false,\n value: function (property: string) {\n return this[property] !== undefined;\n }\n });\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAH,OAAA;AAmBO,MAAMI,mBAAmB,CAAC;EACZC,UAAU,GAA2B,IAAIC,GAAG,CAAC,CAAC;EAExDC,WAAWA,CAACC,MAAiC,EAAE;IAClD,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM;IAC1B,MAAME,mBAAmB,GAAGD,OAAO,CAACE,MAAM,CACtC,4BACJ,CAAC;IACD,MAAMC,qBAAqB,GAAGH,OAAO,CAACE,MAAM,CACxCE,qCAA4B,CAACC,IACjC,CAAC;IACD,MAAMC,2BAA2B,GAAGH,qBAAqB,CAACI,IAAI,CAC1DC,EAAE,IAAI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ACL,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYE,oBAAoBA,CAACF,MAAsB,EAAE;IACjD;IACI;IACAA,MAAM,KAAK,IAAI,IACfA,MAAM,KAAKf,SAAS;IACpB;IACA,OAAOe,MAAM,KAAK,QAAQ;IAC1B;IACAa,KAAK,CAACC,OAAO,CAACd,MAAM,CAAC;IACrB;IACA,OAAOA,MAAM,EAAEQ,cAAc,KAAK,UAAU,EAC9C;MACE;IACJ;IACAO,MAAM,CAACC,cAAc,CAAChB,MAAM,EAAE,gBAAgB,EAAE;MAC5CiB,UAAU,EAAE,KAAK;MACjBC,QAAQ,EAAE,KAAK;MACfR,KAAK,EAAE,SAAAA,CAAUS,QAAgB,EAAE;QAC/B,OAAO,IAAI,CAACA,QAAQ,CAAC,KAAKlC,SAAS;MACvC;IACJ,CAAC,CAAC;EACN;AACJ;AAACmC,OAAA,CAAAlD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { PluginsContainer } from "@webiny/plugins";
2
- import { CmsModelConverterCallable } from "./ConverterCollection";
3
- import { CmsModel, StorageOperationsCmsModel } from "../../types";
1
+ import type { PluginsContainer } from "@webiny/plugins";
2
+ import type { CmsModelConverterCallable } from "./ConverterCollection";
3
+ import type { CmsModel, StorageOperationsCmsModel } from "../../types";
4
4
  interface Params {
5
5
  /**
6
6
  * We need a model to determine if the conversion feature is enabled.
@@ -1 +1 @@
1
- {"version":3,"names":["_ConverterCollection","require","_semver","_interopRequireDefault","featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","startsWith","match","isFeatureEnabled","disableConversion","process","env","WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE","nodeEnv","NODE_ENV","modelVersion","console","log","modelId","compare","createValueKeyToStorageConverter","params","plugins","values","converters","ConverterCollection","fields","result","convertToStorage","exports","createValueKeyFromStorageConverter","convertFromStorage","createCmsModelFieldConvertersAttachFactory","storageModel","convertValueKeyToStorage","convertValueKeyFromStorage"],"sources":["valueKeyStorageConverter.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsModelConverterCallable,\n ConverterCollection,\n ConverterCollectionConvertParams as BaseConverterCollectionConvertParams\n} from \"~/utils/converters/ConverterCollection\";\nimport { CmsModel, StorageOperationsCmsModel } from \"~/types\";\nimport semver, { SemVer } from \"semver\";\n\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst isBetaOrNext = (model: CmsModel): boolean => {\n if (!model.webinyVersion) {\n return false;\n } else if (model.webinyVersion.startsWith(\"0.0.0\")) {\n return true;\n }\n return model.webinyVersion.match(/next|beta|unstable/) !== null;\n};\n\nconst isFeatureEnabled = (model: CmsModel): boolean => {\n /**\n * In case of disabled webinyVersion value, we disable this feature.\n * This is only for testing...\n */\n const disableConversion = !!process.env.WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE;\n if (model.webinyVersion === \"disable\" || disableConversion) {\n return false;\n }\n /**\n * If is a test environment, always have this turned on.\n */\n const nodeEnv = process.env.NODE_ENV as string;\n if (nodeEnv === \"test\" || nodeEnv === \"disable\" || isBetaOrNext(model)) {\n return true;\n }\n /**\n * Possibility that the version is not defined, this means it is a quite old system where models did not change.\n */\n if (!model.webinyVersion) {\n return false;\n }\n /**\n * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.\n *\n * TODO change if necessary after the update to the system\n */\n const modelVersion = semver.coerce(model.webinyVersion);\n if (!modelVersion) {\n console.log(`Warning: Model \"${model.modelId}\" does not have valid Webiny version set.`);\n return true;\n } else if (semver.compare(modelVersion, featureVersion) === -1) {\n return false;\n }\n return true;\n};\n\ninterface Params {\n /**\n * We need a model to determine if the conversion feature is enabled.\n */\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\n/**\n * In the first call of the converter we do not need the fields property as it will be taken directly from the model.\n */\ninterface ConverterCollectionConvertParams\n extends Omit<BaseConverterCollectionConvertParams, \"fields\"> {\n fields?: BaseConverterCollectionConvertParams[\"fields\"];\n}\n\nexport const createValueKeyToStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertToStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createValueKeyFromStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertFromStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createCmsModelFieldConvertersAttachFactory = (plugins: PluginsContainer) => {\n return (model: StorageOperationsCmsModel | CmsModel): StorageOperationsCmsModel => {\n const storageModel = model as Partial<StorageOperationsCmsModel>;\n if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {\n return storageModel as StorageOperationsCmsModel;\n }\n return {\n ...model,\n convertValueKeyToStorage: createValueKeyToStorageConverter({\n model,\n plugins\n }),\n convertValueKeyFromStorage: createValueKeyFromStorageConverter({\n model,\n plugins\n })\n };\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,oBAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,cAAc,GAAGC,eAAM,CAACC,MAAM,CAAC,QAAQ,CAAW;AAExD,MAAMC,YAAY,GAAIC,KAAe,IAAc;EAC/C,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,KAAK;EAChB,CAAC,MAAM,IAAID,KAAK,CAACC,aAAa,CAACC,UAAU,CAAC,OAAO,CAAC,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AY;IACvB;IACA,OAAO;MACH,GAAG7B,KAAK;MACR8B,wBAAwB,EAAEd,gCAAgC,CAAC;QACvDhB,KAAK;QACLkB;MACJ,CAAC,CAAC;MACFa,0BAA0B,EAAEL,kCAAkC,CAAC;QAC3D1B,KAAK;QACLkB;MACJ,CAAC;IACL,CAAC;EACL,CAAC;AACL,CAAC;AAACO,OAAA,CAAAG,0CAAA,GAAAA,0CAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ConverterCollection","require","_semver","_interopRequireDefault","featureVersion","semver","coerce","isBetaOrNext","model","webinyVersion","startsWith","match","isFeatureEnabled","disableConversion","process","env","WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE","nodeEnv","NODE_ENV","modelVersion","console","log","modelId","compare","createValueKeyToStorageConverter","params","plugins","values","converters","ConverterCollection","fields","result","convertToStorage","exports","createValueKeyFromStorageConverter","convertFromStorage","createCmsModelFieldConvertersAttachFactory","storageModel","convertValueKeyToStorage","convertValueKeyFromStorage"],"sources":["valueKeyStorageConverter.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsModelConverterCallable,\n ConverterCollectionConvertParams as BaseConverterCollectionConvertParams\n} from \"~/utils/converters/ConverterCollection\";\nimport { ConverterCollection } from \"~/utils/converters/ConverterCollection\";\nimport type { CmsModel, StorageOperationsCmsModel } from \"~/types\";\nimport type { SemVer } from \"semver\";\nimport semver from \"semver\";\n\nconst featureVersion = semver.coerce(\"5.33.0\") as SemVer;\n\nconst isBetaOrNext = (model: CmsModel): boolean => {\n if (!model.webinyVersion) {\n return false;\n } else if (model.webinyVersion.startsWith(\"0.0.0\")) {\n return true;\n }\n return model.webinyVersion.match(/next|beta|unstable/) !== null;\n};\n\nconst isFeatureEnabled = (model: CmsModel): boolean => {\n /**\n * In case of disabled webinyVersion value, we disable this feature.\n * This is only for testing...\n */\n const disableConversion = !!process.env.WEBINY_API_TEST_STORAGE_ID_CONVERSION_DISABLE;\n if (model.webinyVersion === \"disable\" || disableConversion) {\n return false;\n }\n /**\n * If is a test environment, always have this turned on.\n */\n const nodeEnv = process.env.NODE_ENV as string;\n if (nodeEnv === \"test\" || nodeEnv === \"disable\" || isBetaOrNext(model)) {\n return true;\n }\n /**\n * Possibility that the version is not defined, this means it is a quite old system where models did not change.\n */\n if (!model.webinyVersion) {\n return false;\n }\n /**\n * In case feature version value is greater than the model version, feature is not enabled as it is an older model with no storageId.\n *\n * TODO change if necessary after the update to the system\n */\n const modelVersion = semver.coerce(model.webinyVersion);\n if (!modelVersion) {\n console.log(`Warning: Model \"${model.modelId}\" does not have valid Webiny version set.`);\n return true;\n } else if (semver.compare(modelVersion, featureVersion) === -1) {\n return false;\n }\n return true;\n};\n\ninterface Params {\n /**\n * We need a model to determine if the conversion feature is enabled.\n */\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\n/**\n * In the first call of the converter we do not need the fields property as it will be taken directly from the model.\n */\ninterface ConverterCollectionConvertParams\n extends Omit<BaseConverterCollectionConvertParams, \"fields\"> {\n fields?: BaseConverterCollectionConvertParams[\"fields\"];\n}\n\nexport const createValueKeyToStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertToStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createValueKeyFromStorageConverter = (params: Params): CmsModelConverterCallable => {\n const { plugins, model } = params;\n\n if (isFeatureEnabled(model) === false) {\n return ({ values }: ConverterCollectionConvertParams) => {\n return values || {};\n };\n }\n\n const converters = new ConverterCollection({\n plugins\n });\n\n return ({ fields, values }: ConverterCollectionConvertParams) => {\n const result = converters.convertFromStorage({\n fields: fields || model.fields,\n values\n });\n return result || {};\n };\n};\n\nexport const createCmsModelFieldConvertersAttachFactory = (plugins: PluginsContainer) => {\n return (model: StorageOperationsCmsModel | CmsModel): StorageOperationsCmsModel => {\n const storageModel = model as Partial<StorageOperationsCmsModel>;\n if (!!storageModel.convertValueKeyToStorage && !!storageModel.convertValueKeyFromStorage) {\n return storageModel as StorageOperationsCmsModel;\n }\n return {\n ...model,\n convertValueKeyToStorage: createValueKeyToStorageConverter({\n model,\n plugins\n }),\n convertValueKeyFromStorage: createValueKeyFromStorageConverter({\n model,\n plugins\n })\n };\n };\n};\n"],"mappings":";;;;;;;AAKA,IAAAA,oBAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,cAAc,GAAGC,eAAM,CAACC,MAAM,CAAC,QAAQ,CAAW;AAExD,MAAMC,YAAY,GAAIC,KAAe,IAAc;EAC/C,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,KAAK;EAChB,CAAC,MAAM,IAAID,KAAK,CAACC,aAAa,CAACC,UAAU,CAAC,OAAO,CAAC,EAAE;IAChD,OAAO,IAAI;EACf;EACA,OAAOF,KAAK,CAACC,aAAa,CAACE,KAAK,CAAC,oBAAoB,CAAC,KAAK,IAAI;AACnE,CAAC;AAED,MAAMC,gBAAgB,GAAIJ,KAAe,IAAc;EACnD;AACJ;AACA;AACA;EACI,MAAMK,iBAAiB,GAAG,CAAC,CAACC,OAAO,CAACC,GAAG,CAACC,6CAA6C;EACrF,IAAIR,KAAK,CAACC,aAAa,KAAK,SAAS,IAAII,iBAAiB,EAAE;IACxD,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI,MAAMI,OAAO,GAAGH,OAAO,CAACC,GAAG,CAACG,QAAkB;EAC9C,IAAID,OAAO,KAAK,MAAM,IAAIA,OAAO,KAAK,SAAS,IAAIV,YAAY,CAACC,KAAK,CAAC,EAAE;IACpE,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACA,KAAK,CAACC,aAAa,EAAE;IACtB,OAAO,KAAK;E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ACrD,OAAOA,MAAM,IAAI,CAAC,CAAC;IACvB,CAAC;EACL;EAEA,MAAMC,UAAU,GAAG,IAAIC,wCAAmB,CAAC;IACvCH;EACJ,CAAC,CAAC;EAEF,OAAO,CAAC;IAAEI,MAAM;IAAEH;EAAyC,CAAC,KAAK;IAC7D,MAAMI,MAAM,GAAGH,UAAU,CAACO,kBAAkB,CAAC;MACzCL,MAAM,EAAEA,MAAM,IAAItB,KAAK,CAACsB,MAAM;MAC9BH;IACJ,CAAC,CAAC;IACF,OAAOI,MAAM,IAAI,CAAC,CAAC;EACvB,CAAC;AACL,CAAC;AAACE,OAAA,CAAAC,kCAAA,GAAAA,kCAAA;AAEK,MAAME,0CAA0C,GAAIV,OAAyB,IAAK;EACrF,OAAQlB,KAA2C,IAAgC;IAC/E,MAAM6B,YAAY,GAAG7B,KAA2C;IAChE,IAAI,CAAC,CAAC6B,YAAY,CAACC,wBAAwB,IAAI,CAAC,CAACD,YAAY,CAACE,0BAA0B,EAAE;MACtF,OAAOF,YAAY;IACvB;IACA,OAAO;MACH,GAAG7B,KAAK;MACR8B,wBAAwB,EAAEd,gCAAgC,CAAC;QACvDhB,KAAK;QACLkB;MACJ,CAAC,CAAC;MACFa,0BAA0B,EAAEL,kCAAkC,CAAC;QAC3D1B,KAAK;QACLkB;MACJ,CAAC;IACL,CAAC;EACL,CAAC;AACL,CAAC;AAACO,OAAA,CAAAG,0CAAA,GAAAA,0CAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsModelField } from "../types";
1
+ import type { CmsModelField } from "../types";
2
2
  export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "storageId" | "fieldId"> {
3
3
  id?: string;
4
4
  fieldId?: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_camelCase","_interopRequireDefault","require","createModelField","params","id","label","fieldId","initialFieldId","storageId","type","tags","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","helpText","placeholderText","renderer","camelCase","exports"],"sources":["createModelField.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport { CmsModelField } from \"~/types\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n id?: string;\n fieldId?: string;\n storageId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n // We are not just spreading `params` because we want to ensure\n // a default value is set for every property of the model field.\n const {\n id,\n label,\n fieldId: initialFieldId,\n storageId,\n type,\n tags,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n },\n helpText = null,\n placeholderText = null,\n renderer = null\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: id ?? fieldId,\n storageId: storageId ?? `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n multipleValues,\n predefinedValues,\n helpText,\n placeholderText,\n renderer\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAUO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;EACA;EACA,MAAM;IACFC,EAAE;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,SAAS;IACTC,IAAI;IACJC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb,CAAC;IACDC,QAAQ,GAAG,IAAI;IACfC,eAAe,GAAG,IAAI;IACtBC,QAAQ,GAAG;EACf,CAAC,GAAGjB,MAAM;EAEV,MAAMG,OAAO,GAAGC,cAAc,GAAG,IAAAc,kBAAS,EAACd,cAAc,CAAC,GAAG,IAAAc,kBAAS,EAAChB,KAAK,CAAC;EAE7E,OAAO;IACHD,EAAE,EAAEA,EAAE,IAAIE,OAAO;IACjBE,SAAS,EAAEA,SAAS,IAAI,GAAGC,IAAI,IAAIH,OAAO,EAAE;IAC5CA,OAAO;IACPD,KAAK;IACLI,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC,gBAAgB;IAChBG,QAAQ;IACRC,eAAe;IACfC;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAApB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_camelCase","_interopRequireDefault","require","createModelField","params","id","label","fieldId","initialFieldId","storageId","type","tags","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","helpText","placeholderText","renderer","camelCase","exports"],"sources":["createModelField.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport type { CmsModelField } from \"~/types\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n id?: string;\n fieldId?: string;\n storageId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n // We are not just spreading `params` because we want to ensure\n // a default value is set for every property of the model field.\n const {\n id,\n label,\n fieldId: initialFieldId,\n storageId,\n type,\n tags,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n },\n helpText = null,\n placeholderText = null,\n renderer = null\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: id ?? fieldId,\n storageId: storageId ?? `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n multipleValues,\n predefinedValues,\n helpText,\n placeholderText,\n renderer\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAUO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;EACA;EACA,MAAM;IACFC,EAAE;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,SAAS;IACTC,IAAI;IACJC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb,CAAC;IACDC,QAAQ,GAAG,IAAI;IACfC,eAAe,GAAG,IAAI;IACtBC,QAAQ,GAAG;EACf,CAAC,GAAGjB,MAAM;EAEV,MAAMG,OAAO,GAAGC,cAAc,GAAG,IAAAc,kBAAS,EAACd,cAAc,CAAC,GAAG,IAAAc,kBAAS,EAAChB,KAAK,CAAC;EAE7E,OAAO;IACHD,EAAE,EAAEA,EAAE,IAAIE,OAAO;IACjBE,SAAS,EAAEA,SAAS,IAAI,GAAGC,IAAI,IAAIH,OAAO,EAAE;IAC5CA,OAAO;IACPD,KAAK;IACLI,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC,gBAAgB;IAChBG,QAAQ;IACRC,eAAe;IACfC;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAApB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
1
+ import type { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from "../types";
2
2
  interface TypeFromFieldParams {
3
3
  typeOfType: "type" | "input";
4
4
  models: CmsModel[];
@@ -1 +1 @@
1
- {"version":3,"names":["_renderFields","require","_renderInputFields","createTypeFromFields","params","typeOfType","model","models","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","singularApiName","typeFields","nestedTypes","replace","RegExp","field","result","renderField","renderInputField","typeDefs","push","length","fieldType","join","exports"],"sources":["createTypeFromFields.ts"],"sourcesContent":["import { renderField } from \"~/utils/renderFields\";\nimport { renderInputField } from \"~/utils/renderInputFields\";\nimport { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\n\ninterface TypeFromFieldParams {\n typeOfType: \"type\" | \"input\";\n models: CmsModel[];\n model: CmsModel;\n type: ApiEndpoint;\n typeNamePrefix: string;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface TypeFromFieldResponse {\n fieldType: string;\n typeDefs: string;\n}\n\nexport const createTypeFromFields = (params: TypeFromFieldParams): TypeFromFieldResponse | null => {\n const { typeOfType, model, models, type, typeNamePrefix, fields, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const mTypeName = model.singularApiName;\n\n const typeFields: string[] = [];\n const nestedTypes: string[] = [];\n\n // Once the loop below starts, we'll be executing a recursive \"object\" type generation.\n // The main trick here is that nested objects don't know who the parent is, and will generate\n // type names using the \"model\", as if they're at the top level:\n // Every time the types are returned, we need to replace the model name in the generated type name\n // with the actual prefix which includes parent field name type.\n const replace = new RegExp(`${mTypeName}_`, \"g\");\n\n for (const field of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field, type, models, model, fieldTypePlugins })\n : renderInputField({ field, models, model, fieldTypePlugins });\n\n if (!result) {\n continue;\n }\n\n const { fields, typeDefs } = result;\n\n typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));\n if (typeDefs) {\n nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));\n }\n }\n\n if (!typeFields.length) {\n typeFields.push(\"_empty: String\");\n }\n\n return {\n fieldType: `${typeNamePrefix}${typeSuffix}`,\n typeDefs: /* GraphQL */ `\n ${nestedTypes.join(\"\\n\")}\n\n ${typeOfType} ${typeNamePrefix}${typeSuffix} {\n ${typeFields.join(\"\\n\")}\n }\\n\n `\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAkBO,MAAME,oBAAoB,GAAI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AQ,EAAE,aAAc;AAChC,cAAcP,WAAW,CAACW,IAAI,CAAC,IAAI,CAAC;AACpC;AACA,cAActB,UAAU,IAAII,cAAc,GAAGG,UAAU;AACvD,kBAAkBG,UAAU,CAACY,IAAI,CAAC,IAAI,CAAC;AACvC;AACA;EACI,CAAC;AACL,CAAC;AAACC,OAAA,CAAAzB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_renderFields","require","_renderInputFields","createTypeFromFields","params","typeOfType","model","models","type","typeNamePrefix","fields","fieldTypePlugins","typeSuffix","mTypeName","singularApiName","typeFields","nestedTypes","replace","RegExp","field","result","renderField","renderInputField","typeDefs","push","length","fieldType","join","exports"],"sources":["createTypeFromFields.ts"],"sourcesContent":["import { renderField } from \"~/utils/renderFields\";\nimport { renderInputField } from \"~/utils/renderInputFields\";\nimport type { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField } from \"~/types\";\n\ninterface TypeFromFieldParams {\n typeOfType: \"type\" | \"input\";\n models: CmsModel[];\n model: CmsModel;\n type: ApiEndpoint;\n typeNamePrefix: string;\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface TypeFromFieldResponse {\n fieldType: string;\n typeDefs: string;\n}\n\nexport const createTypeFromFields = (params: TypeFromFieldParams): TypeFromFieldResponse | null => {\n const { typeOfType, model, models, type, typeNamePrefix, fields, fieldTypePlugins } = params;\n const typeSuffix = typeOfType === \"input\" ? \"Input\" : \"\";\n const mTypeName = model.singularApiName;\n\n const typeFields: string[] = [];\n const nestedTypes: string[] = [];\n\n // Once the loop below starts, we'll be executing a recursive \"object\" type generation.\n // The main trick here is that nested objects don't know who the parent is, and will generate\n // type names using the \"model\", as if they're at the top level:\n // Every time the types are returned, we need to replace the model name in the generated type name\n // with the actual prefix which includes parent field name type.\n const replace = new RegExp(`${mTypeName}_`, \"g\");\n\n for (const field of fields) {\n const result =\n typeOfType === \"type\"\n ? renderField({ field, type, models, model, fieldTypePlugins })\n : renderInputField({ field, models, model, fieldTypePlugins });\n\n if (!result) {\n continue;\n }\n\n const { fields, typeDefs } = result;\n\n typeFields.push(fields.replace(replace, `${typeNamePrefix}_`));\n if (typeDefs) {\n nestedTypes.push(typeDefs.replace(replace, `${typeNamePrefix}_`));\n }\n }\n\n if (!typeFields.length) {\n typeFields.push(\"_empty: String\");\n }\n\n return {\n fieldType: `${typeNamePrefix}${typeSuffix}`,\n typeDefs: /* GraphQL */ `\n ${nestedTypes.join(\"\\n\")}\n\n ${typeOfType} ${typeNamePrefix}${typeSuffix} {\n ${typeFields.join(\"\\n\")}\n }\\n\n `\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAkBO,MAAME,oBAAoB,GAAIC,MAA2B,IAAmC;EAC/F,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC,IAAI;IAAEC,cAAc;IAAEC,MAAM;IAAEC;EAAiB,CAAC,GAAGP,MAAM;EAC5F,MAAMQ,UAAU,GAAGP,UAAU,KAAK,OAAO,GAAG,OAAO,GAAG,EAAE;EACxD,MAAMQ,SAAS,GAAGP,KAAK,CAACQ,eAAe;EAEvC,MAAMC,UAAoB,GAAG,EAAE;EAC/B,MAAMC,WAAqB,GAAG,EAAE;;EAEhC;EACA;EACA;EACA;EACA;EACA,MAAMC,OAAO,GAAG,IAAIC,MAAM,CAAC,GAAGL,SAAS,GAAG,EAAE,GAAG,CAAC;EAEhD,KAAK,MAAMM,KAAK,IAAIT,MAAM,EAAE;IACxB,MAAMU,MAAM,GACRf,UAAU,KAAK,MAAM,GACf,IAAAgB,yBAAW,EAAC;MAAEF,KAAK;MAAEX,IAAI;MAAED,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC,GAC7D,IAAAW,mCAAgB,EAAC;MAAEH,KAAK;MAAEZ,MAAM;MAAED,KAAK;MAAEK;IAAiB,CAAC,CAAC;IAEtE,IAAI,CAACS,MAAM,EAAE;MACT;IACJ;IAEA,MAAM;MAAEV,MAAM;MAAEa;IAAS,CAAC,GAAGH,MAAM;IAEnCL,UAAU,CAACS,IAAI,CAACd,MAAM,CAACO,OAAO,CAACA,OAAO,EAAE,GAAGR,cAAc,GAAG,CAAC,CAAC;IAC9D,IAAIc,QAAQ,EAAE;MACVP,WAAW,CAACQ,IAAI,CAACD,QAAQ,CAACN,OAAO,CAACA,OAAO,EAAE,GAAGR,cAAc,GAAG,CAAC,CAAC;IACrE;EACJ;EAEA,IAAI,CAACM,UAAU,CAACU,MAAM,EAAE;IACpBV,UAAU,CAACS,IAAI,CAAC,gBAAgB,CAAC;EACrC;EAEA,OAAO;IACHE,SAAS,EAAE,GAAGjB,cAAc,GAAGG,UAAU,EAAE;IAC3CW,QAAQ,EAAE,aAAc;AAChC,cAAcP,WAAW,CAACW,IAAI,CAAC,IAAI,CAAC;AACpC;AACA,cAActB,UAAU,IAAII,cAAc,GAAGG,UAAU;AACvD,kBAAkBG,UAAU,CAACY,IAAI,CAAC,IAAI,CAAC;AACvC;AACA;EACI,CAAC;AACL,CAAC;AAACC,OAAA,CAAAzB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { StorageTransformPlugin } from "../plugins/StorageTransformPlugin";
2
- import { CmsContext, CmsEntry, CmsModel, CmsModelField } from "../types";
2
+ import type { CmsContext, CmsEntry, CmsEntryValues, CmsModel, CmsModelField } from "../types";
3
3
  export interface GetStoragePluginFactory {
4
4
  (context: Pick<CmsContext, "plugins">): (fieldType: string) => StorageTransformPlugin<any>;
5
5
  }
@@ -19,4 +19,11 @@ interface EntryFieldFromStorageTransformParams {
19
19
  value: any;
20
20
  }
21
21
  export declare const entryFieldFromStorageTransform: <T = any>(params: EntryFieldFromStorageTransformParams) => Promise<T>;
22
+ export interface ICreateTransformEntryCallable {
23
+ context: Pick<CmsContext, "plugins">;
24
+ }
25
+ export interface ITransformEntryCallable<T extends CmsEntryValues = CmsEntryValues> {
26
+ (model: CmsModel, entry: CmsEntry): Promise<CmsEntry<T>>;
27
+ }
28
+ export declare const createTransformEntryCallable: (params: ICreateTransformEntryCallable) => ITransformEntryCallable;
22
29
  export {};
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getStoragePluginFactory = exports.entryToStorageTransform = exports.entryFromStorageTransform = exports.entryFieldFromStorageTransform = void 0;
7
+ exports.getStoragePluginFactory = exports.entryToStorageTransform = exports.entryFromStorageTransform = exports.entryFieldFromStorageTransform = exports.createTransformEntryCallable = void 0;
8
8
  var _error = _interopRequireDefault(require("@webiny/error"));
9
9
  var _StorageTransformPlugin = require("../plugins/StorageTransformPlugin");
10
10
  var _getBaseFieldType = require("./getBaseFieldType");
@@ -32,15 +32,30 @@ const getStoragePluginFactory = context => {
32
32
  return plugins[fieldType] || defaultStoragePlugin;
33
33
  };
34
34
  };
35
+ exports.getStoragePluginFactory = getStoragePluginFactory;
36
+ const doNotTouchProperty = Symbol("__DO_NOT_TOUCH_AS_WE_USE_IT_TO_SKIP_UNNECESSARY_OPERATIONS");
35
37
 
36
38
  /**
37
39
  * This should be used when transforming the whole entry.
38
40
  */
39
- exports.getStoragePluginFactory = getStoragePluginFactory;
40
41
  const entryStorageTransform = async (context, model, operation, entry) => {
42
+ /**
43
+ * We use this property to skip unnecessary operations.
44
+ */
45
+ // @ts-expect-error
46
+ if (entry[doNotTouchProperty] === operation) {
47
+ return entry;
48
+ }
41
49
  const getStoragePlugin = getStoragePluginFactory(context);
42
50
  const transformedValues = {};
43
51
  for (const field of model.fields) {
52
+ /**
53
+ * We can safely skip fields that are not present in the entry values.
54
+ */
55
+ if (entry.values.hasOwnProperty(field.fieldId) === false) {
56
+ continue;
57
+ }
58
+ const value = entry.values[field.fieldId];
44
59
  const baseType = (0, _getBaseFieldType.getBaseFieldType)(field);
45
60
  const plugin = getStoragePlugin(baseType);
46
61
  // TODO: remove this once plugins are converted into classes
@@ -51,14 +66,23 @@ const entryStorageTransform = async (context, model, operation, entry) => {
51
66
  plugins: context.plugins,
52
67
  model,
53
68
  field,
54
- value: entry.values[field.fieldId],
69
+ value,
55
70
  getStoragePlugin
56
71
  });
57
72
  }
58
- return {
73
+ const result = {
59
74
  ...entry,
60
75
  values: transformedValues
61
76
  };
77
+ /**
78
+ * We need to assign the variable so that we can skip unnecessary operations next time.
79
+ */
80
+ Object.defineProperty(result, doNotTouchProperty, {
81
+ enumerable: false,
82
+ value: operation,
83
+ configurable: true
84
+ });
85
+ return result;
62
86
  };
63
87
 
64
88
  /**
@@ -103,5 +127,14 @@ const entryFieldFromStorageTransform = async params => {
103
127
  });
104
128
  };
105
129
  exports.entryFieldFromStorageTransform = entryFieldFromStorageTransform;
130
+ const createTransformEntryCallable = params => {
131
+ const {
132
+ context
133
+ } = params;
134
+ return async (model, entry) => {
135
+ return entryFromStorageTransform(context, model, entry);
136
+ };
137
+ };
138
+ exports.createTransformEntryCallable = createTransformEntryCallable;
106
139
 
107
140
  //# sourceMappingURL=entryStorage.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_StorageTransformPlugin","_getBaseFieldType","getStoragePluginFactory","context","defaultStoragePlugin","plugins","byType","StorageTransformPlugin","type","reverse","reduce","collection","plugin","fieldType","exports","entryStorageTransform","model","operation","entry","getStoragePlugin","transformedValues","field","fields","baseType","getBaseFieldType","WebinyError","name","fieldId","value","values","entryToStorageTransform","entryFromStorageTransform","entryFieldFromStorageTransform","params","fromStorage"],"sources":["entryStorage.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport { CmsContext, CmsEntry, CmsModel, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport interface GetStoragePluginFactory {\n (context: Pick<CmsContext, \"plugins\">): (fieldType: string) => StorageTransformPlugin<any>;\n}\n\nexport const getStoragePluginFactory: GetStoragePluginFactory = context => {\n let defaultStoragePlugin: StorageTransformPlugin;\n\n const plugins = context.plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n // we reverse plugins because we want to get latest added only\n .reverse()\n .reduce((collection, plugin) => {\n /**\n * Check if it's a default plugin and set it - always override the previous one.\n */\n if (plugin.fieldType === \"*\") {\n defaultStoragePlugin = plugin;\n return collection;\n }\n\n /**\n * We will just set the plugin for given type.\n * The last one will override existing one - so users can override our default ones.\n */\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n return (fieldType: string) => {\n return plugins[fieldType] || defaultStoragePlugin;\n };\n};\n\n/**\n * This should be used when transforming the whole entry.\n */\nconst entryStorageTransform = async (\n context: Pick<CmsContext, \"plugins\">,\n model: CmsModel,\n operation: \"toStorage\" | \"fromStorage\",\n entry: CmsEntry\n): Promise<CmsEntry> => {\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const transformedValues: Record<string, any> = {};\n for (const field of model.fields) {\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin[operation] !== \"function\") {\n throw new WebinyError(\n `Missing \"${operation}\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n transformedValues[field.fieldId] = await plugin[operation]({\n plugins: context.plugins,\n model,\n field,\n value: entry.values[field.fieldId],\n getStoragePlugin\n });\n }\n\n return { ...entry, values: transformedValues };\n};\n\n/**\n * A function that is used in crud to transform entry into the storage type.\n */\nexport const entryToStorageTransform = async (\n context: Pick<CmsContext, \"plugins\">,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"toStorage\", entry);\n};\n\n/**\n * A function that is used to transform the whole entry from storage into its native form.\n */\nexport const entryFromStorageTransform = async (\n context: Pick<CmsContext, \"plugins\">,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"fromStorage\", entry);\n};\n\ninterface EntryFieldFromStorageTransformParams {\n context: Pick<CmsContext, \"plugins\">;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n}\n/*\n * A function that is used to transform a single field from storage\n */\nexport const entryFieldFromStorageTransform = async <T = any>(\n params: EntryFieldFromStorageTransformParams\n): Promise<T> => {\n const { context, model, field, value } = params;\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin.fromStorage !== \"function\") {\n throw new WebinyError(\n `Missing \"fromStorage\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n return plugin.fromStorage({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AAMO,MAAMG,uBAAgD,GAAGC,OAAO,IAAI;EACvE,IAAIC,oBAA4C;EAEhD,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAyBC,8CAAsB,CAACC,IAAI;EAC3D;EAAA,CACCC,OAAO,CAAC,CAAC,CACTC,MAAM,CAAC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC5B;AACZ;AACA;IACY,IAAIA,MAAM,CAACC,SAAS,KAAK,GAAG,EAAE;MAC1BT,oBAAoB,GAAGQ,MAAM;MAC7B,OAAOD,UAAU;IACrB;;IAEA;AACZ;AACA;AACA;IACYA,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAErC,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAA2C,CAAC;EAEpD,OAAQE,SAAiB,IAAK;IA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A,GAAAA,uBAAA;AAGO,MAAMC,yBAAyB,GAAG,MAAAA,CACrC5B,OAAoC,EACpCa,KAAe,EACfE,KAAe,KACK;EACpB,OAAOH,qBAAqB,CAACZ,OAAO,EAAEa,KAAK,EAAE,aAAa,EAAEE,KAAK,CAAC;AACtE,CAAC;AAACJ,OAAA,CAAAiB,yBAAA,GAAAA,yBAAA;AAQF;AACA;AACA;AACO,MAAMC,8BAA8B,GAAG,MAC1CC,MAA4C,IAC/B;EACb,MAAM;IAAE9B,OAAO;IAAEa,KAAK;IAAEK,KAAK;IAAEO;EAAM,CAAC,GAAGK,MAAM;EAC/C,MAAMd,gBAAgB,GAAGjB,uBAAuB,CAACC,OAAO,CAAC;EAEzD,MAAMoB,QAAQ,GAAG,IAAAC,kCAAgB,EAACH,KAAK,CAAC;EACxC,MAAMT,MAAM,GAAGO,gBAAgB,CAACI,QAAQ,CAAC;;EAEzC;EACA,IAAI,OAAOX,MAAM,CAACsB,WAAW,KAAK,UAAU,EAAE;IAC1C,MAAM,IAAIT,cAAW,CACjB,qDAAqDb,MAAM,CAACc,IAAI,qBAAqBH,QAAQ,GACjG,CAAC;EACL;EAEA,OAAOX,MAAM,CAACsB,WAAW,CAAC;IACtB7B,OAAO,EAAEF,OAAO,CAACE,OAAO;IACxBW,KAAK;IACLK,KAAK;IACLO,KAAK;IACLT;EACJ,CAAC,CAAC;AACN,CAAC;AAACL,OAAA,CAAAkB,8BAAA,GAAAA,8BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_StorageTransformPlugin","_getBaseFieldType","getStoragePluginFactory","context","defaultStoragePlugin","plugins","byType","StorageTransformPlugin","type","reverse","reduce","collection","plugin","fieldType","exports","doNotTouchProperty","Symbol","entryStorageTransform","model","operation","entry","getStoragePlugin","transformedValues","field","fields","values","hasOwnProperty","fieldId","value","baseType","getBaseFieldType","WebinyError","name","result","Object","defineProperty","enumerable","configurable","entryToStorageTransform","entryFromStorageTransform","entryFieldFromStorageTransform","params","fromStorage","createTransformEntryCallable"],"sources":["entryStorage.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"~/plugins/StorageTransformPlugin\";\nimport type { CmsContext, CmsEntry, CmsEntryValues, CmsModel, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport interface GetStoragePluginFactory {\n (context: Pick<CmsContext, \"plugins\">): (fieldType: string) => StorageTransformPlugin<any>;\n}\n\nexport const getStoragePluginFactory: GetStoragePluginFactory = context => {\n let defaultStoragePlugin: StorageTransformPlugin;\n\n const plugins = context.plugins\n .byType<StorageTransformPlugin>(StorageTransformPlugin.type)\n // we reverse plugins because we want to get latest added only\n .reverse()\n .reduce((collection, plugin) => {\n /**\n * Check if it's a default plugin and set it - always override the previous one.\n */\n if (plugin.fieldType === \"*\") {\n defaultStoragePlugin = plugin;\n return collection;\n }\n\n /**\n * We will just set the plugin for given type.\n * The last one will override existing one - so users can override our default ones.\n */\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {} as Record<string, StorageTransformPlugin>);\n\n return (fieldType: string) => {\n return plugins[fieldType] || defaultStoragePlugin;\n };\n};\n\nconst doNotTouchProperty = Symbol(\"__DO_NOT_TOUCH_AS_WE_USE_IT_TO_SKIP_UNNECESSARY_OPERATIONS\");\n\n/**\n * This should be used when transforming the whole entry.\n */\nconst entryStorageTransform = async (\n context: Pick<CmsContext, \"plugins\">,\n model: CmsModel,\n operation: \"toStorage\" | \"fromStorage\",\n entry: CmsEntry\n): Promise<CmsEntry> => {\n /**\n * We use this property to skip unnecessary operations.\n */\n // @ts-expect-error\n if (entry[doNotTouchProperty] === operation) {\n return entry;\n }\n\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const transformedValues: Record<string, any> = {};\n for (const field of model.fields) {\n /**\n * We can safely skip fields that are not present in the entry values.\n */\n if (entry.values.hasOwnProperty(field.fieldId) === false) {\n continue;\n }\n const value = entry.values[field.fieldId];\n\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin[operation] !== \"function\") {\n throw new WebinyError(\n `Missing \"${operation}\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n transformedValues[field.fieldId] = await plugin[operation]({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n }\n\n const result = {\n ...entry,\n values: transformedValues\n };\n /**\n * We need to assign the variable so that we can skip unnecessary operations next time.\n */\n Object.defineProperty(result, doNotTouchProperty, {\n enumerable: false,\n value: operation,\n configurable: true\n });\n\n return result;\n};\n\n/**\n * A function that is used in crud to transform entry into the storage type.\n */\nexport const entryToStorageTransform = async (\n context: Pick<CmsContext, \"plugins\">,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"toStorage\", entry);\n};\n\n/**\n * A function that is used to transform the whole entry from storage into its native form.\n */\nexport const entryFromStorageTransform = async (\n context: Pick<CmsContext, \"plugins\">,\n model: CmsModel,\n entry: CmsEntry\n): Promise<CmsEntry> => {\n return entryStorageTransform(context, model, \"fromStorage\", entry);\n};\n\ninterface EntryFieldFromStorageTransformParams {\n context: Pick<CmsContext, \"plugins\">;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n}\n/*\n * A function that is used to transform a single field from storage\n */\nexport const entryFieldFromStorageTransform = async <T = any>(\n params: EntryFieldFromStorageTransformParams\n): Promise<T> => {\n const { context, model, field, value } = params;\n const getStoragePlugin = getStoragePluginFactory(context);\n\n const baseType = getBaseFieldType(field);\n const plugin = getStoragePlugin(baseType);\n\n // TODO: remove this once plugins are converted into classes\n if (typeof plugin.fromStorage !== \"function\") {\n throw new WebinyError(\n `Missing \"fromStorage\" function in storage plugin \"${plugin.name}\" for field type \"${baseType}\"`\n );\n }\n\n return plugin.fromStorage({\n plugins: context.plugins,\n model,\n field,\n value,\n getStoragePlugin\n });\n};\n\nexport interface ICreateTransformEntryCallable {\n context: Pick<CmsContext, \"plugins\">;\n}\n\nexport interface ITransformEntryCallable<T extends CmsEntryValues = CmsEntryValues> {\n (model: CmsModel, entry: CmsEntry): Promise<CmsEntry<T>>;\n}\n\nexport const createTransformEntryCallable = (\n params: ICreateTransformEntryCallable\n): ITransformEntryCallable => {\n const { context } = params;\n\n return async (model, entry) => {\n return entryFromStorageTransform(context, model, entry);\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AAMO,MAAMG,uBAAgD,GAAGC,OAAO,IAAI;EACvE,IAAIC,oBAA4C;EAEhD,MAAMC,OAAO,GAAGF,OAAO,CAACE,OAAO,CAC1BC,MAAM,CAAyBC,8CAAsB,CAACC,IAAI;EAC3D;EAAA,CACCC,OAAO,CAAC,CAAC,CACTC,MAAM,CAAC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC5B;AACZ;AACA;IACY,IAAIA,MAAM,CAACC,SAAS,KAAK,GAAG,EAAE;MAC1BT,oBAAoB,GAAGQ,MAAM;MAC7B,OAAOD,UAAU;IACrB;;IAEA;AACZ;AACA;AACA;IACYA,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAErC,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAA2C,CAAC;EAEpD,OAAQE,SAAiB,IAAK;IAC1B,OAAOR,OAAO,CAACQ,SAAS,CAAC,IAAIT,oBAAoB;EACrD,CAAC;AACL,CAAC;AAACU,OAAA,CAAAZ,uBAAA,GAAAA,uBAAA;AAEF,MAAMa,kBAAkB,GAAGC,MAAM,CAAC,4DAA4D,CAAC;;AAE/F;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,MAAAA,CAC1Bd,OAAoC,EACpCe,KAAe,EACfC,SAAsC,EACtCC,KAAe,KACK;EACpB;AACJ;AACA;EACI;EACA,IAAI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,OAAOmB,yBAAyB,CAACpC,OAAO,EAAEe,KAAK,EAAEE,KAAK,CAAC;EAC3D,CAAC;AACL,CAAC;AAACN,OAAA,CAAA6B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsModelField } from "../types";
1
+ import type { CmsModelField } from "../types";
2
2
  export declare const getBaseFieldType: (field: Pick<CmsModelField, "type">) => string;
@@ -1 +1 @@
1
- {"version":3,"names":["getBaseFieldType","field","type","split","exports"],"sources":["getBaseFieldType.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\n\nexport const getBaseFieldType = (field: Pick<CmsModelField, \"type\">) => {\n return field.type.split(\":\")[0];\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAIC,KAAkC,IAAK;EACpE,OAAOA,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["getBaseFieldType","field","type","split","exports"],"sources":["getBaseFieldType.ts"],"sourcesContent":["import type { CmsModelField } from \"~/types\";\n\nexport const getBaseFieldType = (field: Pick<CmsModelField, \"type\">) => {\n return field.type.split(\":\")[0];\n};\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAIC,KAAkC,IAAK;EACpE,OAAOA,KAAK,CAACC,IAAI,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntry, CmsModel } from "../types";
1
+ import type { CmsEntry, CmsModel } from "../types";
2
2
  export declare function getEntryDescription(model: Pick<CmsModel, "descriptionFieldId" | "fields">, entry: CmsEntry): string;
@@ -1 +1 @@
1
- {"version":3,"names":["getEntryDescription","model","entry","descriptionFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryDescription.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryDescription(\n model: Pick<CmsModel, \"descriptionFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n const descriptionFieldId = field.fieldId;\n return entry.values[descriptionFieldId] || \"\";\n}\n"],"mappings":";;;;;;AAEO,SAASA,mBAAmBA,CAC/BC,KAAsD,EACtDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,kBAAkB,EAAE;IAC3B,OAAO,EAAE;EACb;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,kBAAkB,CAAC;EAC5E,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EACA,MAAMD,kBAAkB,GAAGC,KAAK,CAACI,OAAO;EACxC,OAAON,KAAK,CAACO,MAAM,CAACN,kBAAkB,CAAC,IAAI,EAAE;AACjD","ignoreList":[]}
1
+ {"version":3,"names":["getEntryDescription","model","entry","descriptionFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryDescription.ts"],"sourcesContent":["import type { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryDescription(\n model: Pick<CmsModel, \"descriptionFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.descriptionFieldId) {\n return \"\";\n }\n const field = model.fields.find(f => f.fieldId === model.descriptionFieldId);\n if (!field) {\n return \"\";\n }\n const descriptionFieldId = field.fieldId;\n return entry.values[descriptionFieldId] || \"\";\n}\n"],"mappings":";;;;;;AAEO,SAASA,mBAAmBA,CAC/BC,KAAsD,EACtDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,kBAAkB,EAAE;IAC3B,OAAO,EAAE;EACb;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,kBAAkB,CAAC;EAC5E,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EACA,MAAMD,kBAAkB,GAAGC,KAAK,CAACI,OAAO;EACxC,OAAON,KAAK,CAACO,MAAM,CAACN,kBAAkB,CAAC,IAAI,EAAE;AACjD","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntry, CmsModel } from "../types";
1
+ import type { CmsEntry, CmsModel } from "../types";
2
2
  export declare function getEntryImage(model: Pick<CmsModel, "imageFieldId" | "fields">, entry: CmsEntry): string | null;
@@ -1 +1 @@
1
- {"version":3,"names":["getEntryImage","model","entry","imageFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryImage.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryImage(\n model: Pick<CmsModel, \"imageFieldId\" | \"fields\">,\n entry: CmsEntry\n): string | null {\n if (!model.imageFieldId) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.imageFieldId);\n if (!field) {\n return null;\n }\n const imageFieldId = field.fieldId;\n return entry.values[imageFieldId] || null;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CACzBC,KAAgD,EAChDC,KAAe,EACF;EACb,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAO,IAAI;EACf;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,MAAMD,YAAY,GAAGC,KAAK,CAACI,OAAO;EAClC,OAAON,KAAK,CAACO,MAAM,CAACN,YAAY,CAAC,IAAI,IAAI;AAC7C","ignoreList":[]}
1
+ {"version":3,"names":["getEntryImage","model","entry","imageFieldId","field","fields","find","f","fieldId","values"],"sources":["getEntryImage.ts"],"sourcesContent":["import type { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryImage(\n model: Pick<CmsModel, \"imageFieldId\" | \"fields\">,\n entry: CmsEntry\n): string | null {\n if (!model.imageFieldId) {\n return null;\n }\n const field = model.fields.find(f => f.fieldId === model.imageFieldId);\n if (!field) {\n return null;\n }\n const imageFieldId = field.fieldId;\n return entry.values[imageFieldId] || null;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CACzBC,KAAgD,EAChDC,KAAe,EACF;EACb,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAO,IAAI;EACf;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKP,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACC,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,MAAMD,YAAY,GAAGC,KAAK,CAACI,OAAO;EAClC,OAAON,KAAK,CAACO,MAAM,CAACN,YAAY,CAAC,IAAI,IAAI;AAC7C","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntry, CmsModel } from "../types";
1
+ import type { CmsEntry, CmsModel } from "../types";
2
2
  export declare function getEntryTitle(model: Pick<CmsModel, "titleFieldId" | "fields">, entry: CmsEntry): string;
@@ -1 +1 @@
1
- {"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(\n model: Pick<CmsModel, \"titleFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CACzBC,KAAgD,EAChDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAOD,KAAK,CAACE,EAAE;EACnB;EACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKR,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACE,KAAK,EAAE;IACR,OAAOH,KAAK,CAACE,EAAE;EACnB;EACA,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAAO;EAClC,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAACR,YAAY,CAAC;EAC7C,IAAI,CAACO,UAAU,EAAE;IACb,OAAOR,KAAK,CAACE,EAAE;EACnB;EAEA,MAAM;IAAEQ,OAAO,GAAG,KAAK;IAAED;EAAO,CAAC,GAAGN,KAAK,CAACQ,gBAAgB,IAAI,CAAC,CAAC;EAChE,IAAI,CAACD,OAAO,IAAI,CAACD,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,EAAE;IACxD,OAAOD,UAAU;EACrB;EACA,KAAK,MAAMM,KAAK,IAAIL,MAAM,EAAE;IACxB;IACA,IAAIK,KAAK,CAACA,KAAK,IAAIN,UAAU,EAAE;MAC3B,OAAOM,KAAK,CAACC,KAAK;IACtB;EACJ;EACA,OAAOP,UAAU;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["getEntryTitle","model","entry","titleFieldId","id","field","fields","find","f","fieldId","titleValue","values","enabled","predefinedValues","Array","isArray","value","label"],"sources":["getEntryTitle.ts"],"sourcesContent":["import type { CmsEntry, CmsModel } from \"~/types\";\n\nexport function getEntryTitle(\n model: Pick<CmsModel, \"titleFieldId\" | \"fields\">,\n entry: CmsEntry\n): string {\n if (!model.titleFieldId) {\n return entry.id;\n }\n const field = model.fields.find(f => f.fieldId === model.titleFieldId);\n if (!field) {\n return entry.id;\n }\n const titleFieldId = field.fieldId;\n const titleValue = entry.values[titleFieldId];\n if (!titleValue) {\n return entry.id;\n }\n\n const { enabled = false, values } = field.predefinedValues || {};\n if (!enabled || !values || Array.isArray(values) === false) {\n return titleValue;\n }\n for (const value of values) {\n // needs to be loose because titleValue can be a number and value can be a string - but it must match\n if (value.value == titleValue) {\n return value.label;\n }\n }\n return titleValue;\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CACzBC,KAAgD,EAChDC,KAAe,EACT;EACN,IAAI,CAACD,KAAK,CAACE,YAAY,EAAE;IACrB,OAAOD,KAAK,CAACE,EAAE;EACnB;EACA,MAAMC,KAAK,GAAGJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,KAAKR,KAAK,CAACE,YAAY,CAAC;EACtE,IAAI,CAACE,KAAK,EAAE;IACR,OAAOH,KAAK,CAACE,EAAE;EACnB;EACA,MAAMD,YAAY,GAAGE,KAAK,CAACI,OAAO;EAClC,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAACR,YAAY,CAAC;EAC7C,IAAI,CAACO,UAAU,EAAE;IACb,OAAOR,KAAK,CAACE,EAAE;EACnB;EAEA,MAAM;IAAEQ,OAAO,GAAG,KAAK;IAAED;EAAO,CAAC,GAAGN,KAAK,CAACQ,gBAAgB,IAAI,CAAC,CAAC;EAChE,IAAI,CAACD,OAAO,IAAI,CAACD,MAAM,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,KAAK,KAAK,EAAE;IACxD,OAAOD,UAAU;EACrB;EACA,KAAK,MAAMM,KAAK,IAAIL,MAAM,EAAE;IACxB;IACA,IAAIK,KAAK,CAACA,KAAK,IAAIN,UAAU,EAAE;MAC3B,OAAOM,KAAK,CAACC,KAAK;IACtB;EACJ;EACA,OAAOP,UAAU;AACrB","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { ApiEndpoint, CmsContext, CmsFieldTypePlugins, CmsModel } from "../types";
2
- import { ICmsGraphQLSchemaPlugin } from "../plugins";
3
- import { IGraphQLSchemaPlugin } from "@webiny/handler-graphql";
4
- import { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types";
1
+ import type { ApiEndpoint, CmsContext, CmsFieldTypePlugins, CmsModel } from "../types";
2
+ import type { ICmsGraphQLSchemaPlugin } from "../plugins";
3
+ import type { IGraphQLSchemaPlugin } from "@webiny/handler-graphql";
4
+ import type { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types";
5
5
  interface CreatePluginCallableParams {
6
6
  schema: GraphQLSchemaDefinition<CmsContext>;
7
7
  type: "manage" | "preview" | "read";
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","TYPE_MAP","preview","read","manage","defaultCreatePlugin","schema","type","fieldType","plugin","createCmsGraphQLSchemaPlugin","name","createGraphQLSchemaPluginFromFieldPlugins","params","models","fieldTypePlugins","createPlugin","apiType","plugins","key","fieldTypePlugin","createSchema","push","exports"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import { ApiEndpoint, CmsContext, CmsFieldTypePlugins, CmsModel } from \"~/types\";\nimport { createCmsGraphQLSchemaPlugin, ICmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types\";\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\ninterface CreatePluginCallableParams {\n schema: GraphQLSchemaDefinition<CmsContext>;\n type: \"manage\" | \"preview\" | \"read\";\n fieldType: string;\n}\n\ninterface CreatePluginCallable {\n (params: CreatePluginCallableParams): IGraphQLSchemaPlugin<CmsContext>;\n}\n\nconst defaultCreatePlugin: CreatePluginCallable = ({ schema, type, fieldType }) => {\n const plugin = createCmsGraphQLSchemaPlugin(schema);\n plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldType}`;\n return plugin;\n};\n\ninterface Params {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n createPlugin?: CreatePluginCallable;\n}\nexport const createGraphQLSchemaPluginFromFieldPlugins = (params: Params) => {\n const { models, fieldTypePlugins, type, createPlugin = defaultCreatePlugin } = params;\n\n const apiType = TYPE_MAP[type];\n\n const plugins: ICmsGraphQLSchemaPlugin[] = [];\n for (const key in fieldTypePlugins) {\n const fieldTypePlugin = fieldTypePlugins[key];\n if (!apiType || !fieldTypePlugin[apiType]) {\n continue;\n }\n const createSchema = fieldTypePlugin[apiType].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n continue;\n }\n const schema = createSchema({ models });\n\n // const plugin = createCmsGraphQLSchemaPlugin(schema);\n // plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;\n const plugin = createPlugin({\n schema,\n type,\n fieldType: fieldTypePlugin.fieldType\n });\n plugins.push(plugin);\n }\n return plugins;\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAIA,MAAMC,QAA2C,GAAG;EAChDC,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC;AAYD,MAAMC,mBAAyC,GAAGA,CAAC;EAAEC,MAAM;EAAEC,IAAI;EAAEC;AAAU,CAAC,KAAK;EAC/E,MAAMC,MAAM,GAAG,IAAAC,qCAA4B,EAACJ,MAAM,CAAC;EACnDG,MAAM,CAACE,IAAI,GAAG,+BAA+BJ,IAAI,UAAUC,SAAS,EAAE;EACtE,OAAOC,MAAM;AACjB,CAAC;AAQM,MAAMG,yCAAyC,GAAIC,MAAc,IAAK;EACzE,MAAM;IAAEC,MAAM;IAAEC,gBAAgB;IAAER,IAAI;IAAES,YAAY,GAAGX;EAAoB,CAAC,GAAGQ,MAAM;EAErF,MAAMI,OAAO,GAAGhB,QAAQ,CAACM,IAAI,CAAC;EAE9B,MAAMW,OAAkC,GAAG,EAAE;EAC7C,KAAK,MAAMC,GAAG,IAAIJ,gBAAgB,EAAE;IAChC,MAAMK,eAAe,GAAGL,gBAAgB,CAACI,GAAG,CAAC;IAC7C,IAAI,CAACF,OAAO,IAAI,CAACG,eAAe,CAACH,OAAO,CAAC,EAAE;MACvC;IACJ;IACA,MAAMI,YAAY,GAAGD,eAAe,CAACH,OAAO,CAAC,CAACI,YAAY;IAC1D;IACA,IAAI,CAACA,YAAY,EAAE;MACf;IACJ;IACA,MAAMf,MAAM,GAAGe,YAAY,CAAC;MAAEP;IAAO,CAAC,CAAC;;IAEvC;IACA;IACA,MAAML,MAAM,GAAGO,YAAY,CAAC;MACxBV,MAAM;MACNC,IAAI;MACJC,SAAS,EAAEY,eAAe,CAACZ;IAC/B,CAAC,CAAC;IACFU,OAAO,CAACI,IAAI,CAACb,MAAM,CAAC;EACxB;EACA,OAAOS,OAAO;AAClB,CAAC;AAACK,OAAA,CAAAX,yCAAA,GAAAA,yCAAA","ignoreList":[]}
1
+ {"version":3,"names":["_plugins","require","TYPE_MAP","preview","read","manage","defaultCreatePlugin","schema","type","fieldType","plugin","createCmsGraphQLSchemaPlugin","name","createGraphQLSchemaPluginFromFieldPlugins","params","models","fieldTypePlugins","createPlugin","apiType","plugins","key","fieldTypePlugin","createSchema","push","exports"],"sources":["getSchemaFromFieldPlugins.ts"],"sourcesContent":["import type { ApiEndpoint, CmsContext, CmsFieldTypePlugins, CmsModel } from \"~/types\";\nimport type { ICmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport { createCmsGraphQLSchemaPlugin } from \"~/plugins\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport type { GraphQLSchemaDefinition } from \"@webiny/handler-graphql/types\";\n\nconst TYPE_MAP: Record<string, \"manage\" | \"read\"> = {\n preview: \"read\",\n read: \"read\",\n manage: \"manage\"\n};\n\ninterface CreatePluginCallableParams {\n schema: GraphQLSchemaDefinition<CmsContext>;\n type: \"manage\" | \"preview\" | \"read\";\n fieldType: string;\n}\n\ninterface CreatePluginCallable {\n (params: CreatePluginCallableParams): IGraphQLSchemaPlugin<CmsContext>;\n}\n\nconst defaultCreatePlugin: CreatePluginCallable = ({ schema, type, fieldType }) => {\n const plugin = createCmsGraphQLSchemaPlugin(schema);\n plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldType}`;\n return plugin;\n};\n\ninterface Params {\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n type: ApiEndpoint;\n createPlugin?: CreatePluginCallable;\n}\nexport const createGraphQLSchemaPluginFromFieldPlugins = (params: Params) => {\n const { models, fieldTypePlugins, type, createPlugin = defaultCreatePlugin } = params;\n\n const apiType = TYPE_MAP[type];\n\n const plugins: ICmsGraphQLSchemaPlugin[] = [];\n for (const key in fieldTypePlugins) {\n const fieldTypePlugin = fieldTypePlugins[key];\n if (!apiType || !fieldTypePlugin[apiType]) {\n continue;\n }\n const createSchema = fieldTypePlugin[apiType].createSchema;\n // Render gql types generated by field type plugins\n if (!createSchema) {\n continue;\n }\n const schema = createSchema({ models });\n\n // const plugin = createCmsGraphQLSchemaPlugin(schema);\n // plugin.name = `headless-cms.graphql.schema.${type}.field.${fieldTypePlugin.fieldType}`;\n const plugin = createPlugin({\n schema,\n type,\n fieldType: fieldTypePlugin.fieldType\n });\n plugins.push(plugin);\n }\n return plugins;\n};\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAIA,MAAMC,QAA2C,GAAG;EAChDC,OAAO,EAAE,MAAM;EACfC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC;AAYD,MAAMC,mBAAyC,GAAGA,CAAC;EAAEC,MAAM;EAAEC,IAAI;EAAEC;AAAU,CAAC,KAAK;EAC/E,MAAMC,MAAM,GAAG,IAAAC,qCAA4B,EAACJ,MAAM,CAAC;EACnDG,MAAM,CAACE,IAAI,GAAG,+BAA+BJ,IAAI,UAAUC,SAAS,EAAE;EACtE,OAAOC,MAAM;AACjB,CAAC;AAQM,MAAMG,yCAAyC,GAAIC,MAAc,IAAK;EACzE,MAAM;IAAEC,MAAM;IAAEC,gBAAgB;IAAER,IAAI;IAAES,YAAY,GAAGX;EAAoB,CAAC,GAAGQ,MAAM;EAErF,MAAMI,OAAO,GAAGhB,QAAQ,CAACM,IAAI,CAAC;EAE9B,MAAMW,OAAkC,GAAG,EAAE;EAC7C,KAAK,MAAMC,GAAG,IAAIJ,gBAAgB,EAAE;IAChC,MAAMK,eAAe,GAAGL,gBAAgB,CAACI,GAAG,CAAC;IAC7C,IAAI,CAACF,OAAO,IAAI,CAACG,eAAe,CAACH,OAAO,CAAC,EAAE;MACvC;IACJ;IACA,MAAMI,YAAY,GAAGD,eAAe,CAACH,OAAO,CAAC,CAACI,YAAY;IAC1D;IACA,IAAI,CAACA,YAAY,EAAE;MACf;IACJ;IACA,MAAMf,MAAM,GAAGe,YAAY,CAAC;MAAEP;IAAO,CAAC,CAAC;;IAEvC;IACA;IACA,MAAML,MAAM,GAAGO,YAAY,CAAC;MACxBV,MAAM;MACNC,IAAI;MACJC,SAAS,EAAEY,eAAe,CAACZ;IAC/B,CAAC,CAAC;IACFU,OAAO,CAACI,IAAI,CAACb,MAAM,CAAC;EACxB;EACA,OAAOS,OAAO;AAClB,CAAC;AAACK,OAAA,CAAAX,yCAAA,GAAAA,yCAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { SecurityIdentity } from "@webiny/api-security/types";
1
+ import type { SecurityIdentity } from "@webiny/api-security/types";
2
2
  export declare const getIdentity: <T extends import("@webiny/api-authentication/types").Identity | null>(input: SecurityIdentity | null | undefined, defaultValue?: T | null) => T;
@@ -1 +1 @@
1
- {"version":3,"names":["getIdentity","input","defaultValue","identity","id","displayName","type","exports"],"sources":["identity.ts"],"sourcesContent":["import { SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport const getIdentity = <T extends SecurityIdentity | null>(\n input: SecurityIdentity | null | undefined,\n defaultValue: T | null = null\n): T => {\n const identity = input?.id && input?.displayName && input?.type ? input : defaultValue;\n if (!identity) {\n return null as T;\n }\n return {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n } as T;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,WAAW,GAAGA,CACvBC,KAA0C,EAC1CC,YAAsB,GAAG,IAAI,KACzB;EACJ,MAAMC,QAAQ,GAAGF,KAAK,EAAEG,EAAE,IAAIH,KAAK,EAAEI,WAAW,IAAIJ,KAAK,EAAEK,IAAI,GAAGL,KAAK,GAAGC,YAAY;EACtF,IAAI,CAACC,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,OAAO;IACHC,EAAE,EAAED,QAAQ,CAACC,EAAE;IACfC,WAAW,EAAEF,QAAQ,CAACE,WAAW;IACjCC,IAAI,EAAEH,QAAQ,CAACG;EACnB,CAAC;AACL,CAAC;AAACC,OAAA,CAAAP,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["getIdentity","input","defaultValue","identity","id","displayName","type","exports"],"sources":["identity.ts"],"sourcesContent":["import type { SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport const getIdentity = <T extends SecurityIdentity | null>(\n input: SecurityIdentity | null | undefined,\n defaultValue: T | null = null\n): T => {\n const identity = input?.id && input?.displayName && input?.type ? input : defaultValue;\n if (!identity) {\n return null as T;\n }\n return {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n } as T;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,WAAW,GAAGA,CACvBC,KAA0C,EAC1CC,YAAsB,GAAG,IAAI,KACzB;EACJ,MAAMC,QAAQ,GAAGF,KAAK,EAAEG,EAAE,IAAIH,KAAK,EAAEI,WAAW,IAAIJ,KAAK,EAAEK,IAAI,GAAGL,KAAK,GAAGC,YAAY;EACtF,IAAI,CAACC,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,OAAO;IACHC,EAAE,EAAED,QAAQ,CAACC,EAAE;IACfC,WAAW,EAAEF,QAAQ,CAACE,WAAW;IACjCC,IAAI,EAAEH,QAAQ,CAACG;EACnB,CAAC;AACL,CAAC;AAACC,OAAA,CAAAP,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsContext } from "../types";
1
+ import type { CmsContext } from "../types";
2
2
  export declare const isHeadlessCmsReady: ({ tenancy, i18n }: CmsContext) => Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"names":["isHeadlessCmsReady","tenancy","i18n","tenant","getCurrentTenant","locale","getContentLocale","undefined","exports"],"sources":["isHeadlessCmsReady.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\n\nexport const isHeadlessCmsReady = async ({ tenancy, i18n }: CmsContext): Promise<boolean> => {\n /**\n * In case of a fresh webiny project \"tenant\" and \"locale\" won't be there until the installation is completed.\n */\n const tenant = tenancy.getCurrentTenant();\n if (!tenant) {\n return false;\n }\n\n const locale = i18n.getContentLocale();\n\n return locale !== undefined;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,kBAAkB,GAAG,MAAAA,CAAO;EAAEC,OAAO;EAAEC;AAAiB,CAAC,KAAuB;EACzF;AACJ;AACA;EACI,MAAMC,MAAM,GAAGF,OAAO,CAACG,gBAAgB,CAAC,CAAC;EACzC,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,KAAK;EAChB;EAEA,MAAME,MAAM,GAAGH,IAAI,CAACI,gBAAgB,CAAC,CAAC;EAEtC,OAAOD,MAAM,KAAKE,SAAS;AAC/B,CAAC;AAACC,OAAA,CAAAR,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["isHeadlessCmsReady","tenancy","i18n","tenant","getCurrentTenant","locale","getContentLocale","undefined","exports"],"sources":["isHeadlessCmsReady.ts"],"sourcesContent":["import type { CmsContext } from \"~/types\";\n\nexport const isHeadlessCmsReady = async ({ tenancy, i18n }: CmsContext): Promise<boolean> => {\n /**\n * In case of a fresh webiny project \"tenant\" and \"locale\" won't be there until the installation is completed.\n */\n const tenant = tenancy.getCurrentTenant();\n if (!tenant) {\n return false;\n }\n\n const locale = i18n.getContentLocale();\n\n return locale !== undefined;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,kBAAkB,GAAG,MAAAA,CAAO;EAAEC,OAAO;EAAEC;AAAiB,CAAC,KAAuB;EACzF;AACJ;AACA;EACI,MAAMC,MAAM,GAAGF,OAAO,CAACG,gBAAgB,CAAC,CAAC;EACzC,IAAI,CAACD,MAAM,EAAE;IACT,OAAO,KAAK;EAChB;EAEA,MAAME,MAAM,GAAGH,IAAI,CAACI,gBAAgB,CAAC,CAAC;EAEtC,OAAOD,MAAM,KAAKE,SAAS;AAC/B,CAAC;AAACC,OAAA,CAAAR,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsModelAst, CmsModelField } from "../../types";
1
+ import type { CmsModelAst, CmsModelField } from "../../types";
2
2
  export interface IModelFieldTraverserTraverseOnFieldCallableParams {
3
3
  field: CmsModelField;
4
4
  path: string[];
@@ -1 +1 @@
1
- {"version":3,"names":["nodeHasChildren","node","children","length","ModelFieldTraverser","traverse","modelAst","onField","execute","root","path","field","getFieldFromNode","parent","fieldId","type","exports"],"sources":["ModelFieldTraverser.ts"],"sourcesContent":["import {\n CmsModelAst,\n CmsModelField,\n CmsModelFieldAstNode,\n CmsModelFieldAstNodeField\n} from \"~/types\";\n\nconst nodeHasChildren = (node: CmsModelFieldAstNode) => {\n return node.children.length > 0;\n};\n\ntype IParentNode = CmsModelAst | CmsModelFieldAstNode | null;\n\ninterface IVisitorContext {\n node: CmsModelFieldAstNode;\n parent: IParentNode;\n}\n\nexport interface IModelFieldTraverserTraverseOnFieldCallableParams {\n field: CmsModelField;\n path: string[];\n}\n\nexport interface IModelFieldTraverserTraverseOnFieldCallable {\n (params: IModelFieldTraverserTraverseOnFieldCallableParams): void;\n}\n\nexport interface IModelFieldTraverser {\n traverse(modelAst: CmsModelAst, onField: IModelFieldTraverserTraverseOnFieldCallable): void;\n}\n\nexport class ModelFieldTraverser implements IModelFieldTraverser {\n public traverse(modelAst: CmsModelAst, onField: IModelFieldTraverserTraverseOnFieldCallable) {\n this.execute(modelAst, [], onField);\n }\n\n private execute(\n root: CmsModelAst | CmsModelFieldAstNode,\n path: string[],\n onField: IModelFieldTraverserTraverseOnFieldCallable\n ) {\n for (const node of root.children) {\n const field = this.getFieldFromNode({ node, parent: root });\n onField({\n field,\n path: [...path, field.fieldId]\n });\n\n if (nodeHasChildren(node)) {\n this.execute(node, [...path, field.fieldId], onField);\n }\n }\n }\n\n private getFieldFromNode({ node, parent }: IVisitorContext) {\n if (node.type === \"collection\") {\n return (parent as CmsModelFieldAstNodeField).field;\n }\n\n return (node as CmsModelFieldAstNodeField).field;\n }\n}\n"],"mappings":";;;;;;AAOA,MAAMA,eAAe,GAAIC,IAA0B,IAAK;EACpD,OAAOA,IAAI,CAACC,QAAQ,CAACC,MAAM,GAAG,CAAC;AACnC,CAAC;AAsBM,MAAMC,mBAAmB,CAAiC;EACtDC,QAAQA,CAACC,QAAqB,EAAEC,OAAoD,EAAE;IACzF,IAAI,CAACC,OAAO,CAACF,QAAQ,EAAE,EAAE,EAAEC,OAAO,CAAC;EACvC;EAEQC,OAAOA,CACXC,IAAwC,EACxCC,IAAc,EACdH,OAAoD,EACtD;IACE,KAAK,MAAMN,IAAI,IAAIQ,IAAI,CAACP,QAAQ,EAAE;MAC9B,MAAMS,KAAK,GAAG,IAAI,CAACC,gBAAgB,CAAC;QAAEX,IAAI;QAAEY,MAAM,EAAEJ;MAAK,CAAC,CAAC;MAC3DF,OAAO,CAAC;QACJI,KAAK;QACLD,IAAI,EAAE,CAAC,GAAGA,IAAI,EAAEC,KAAK,CAACG,OAAO;MACjC,CAAC,CAAC;MAEF,IAAId,eAAe,CAACC,IAAI,CAAC,EAAE;QACvB,IAAI,CAACO,OAAO,CAACP,IAAI,EAAE,CAAC,GAAGS,IAAI,EAAEC,KAAK,CAACG,OAAO,CAAC,EAAEP,OAAO,CAAC;MACzD;IACJ;EACJ;EAEQK,gBAAgBA,CAAC;IAAEX,IAAI;IAAEY;EAAwB,CAAC,EAAE;IACxD,IAAIZ,IAAI,CAACc,IAAI,KAAK,YAAY,EAAE;MAC5B,OAAQF,MAAM,CAA+BF,KAAK;IACtD;IAEA,OAAQV,IAAI,CAA+BU,KAAK;EACpD;AACJ;AAACK,OAAA,CAAAZ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["nodeHasChildren","node","children","length","ModelFieldTraverser","traverse","modelAst","onField","execute","root","path","field","getFieldFromNode","parent","fieldId","type","exports"],"sources":["ModelFieldTraverser.ts"],"sourcesContent":["import type {\n CmsModelAst,\n CmsModelField,\n CmsModelFieldAstNode,\n CmsModelFieldAstNodeField\n} from \"~/types\";\n\nconst nodeHasChildren = (node: CmsModelFieldAstNode) => {\n return node.children.length > 0;\n};\n\ntype IParentNode = CmsModelAst | CmsModelFieldAstNode | null;\n\ninterface IVisitorContext {\n node: CmsModelFieldAstNode;\n parent: IParentNode;\n}\n\nexport interface IModelFieldTraverserTraverseOnFieldCallableParams {\n field: CmsModelField;\n path: string[];\n}\n\nexport interface IModelFieldTraverserTraverseOnFieldCallable {\n (params: IModelFieldTraverserTraverseOnFieldCallableParams): void;\n}\n\nexport interface IModelFieldTraverser {\n traverse(modelAst: CmsModelAst, onField: IModelFieldTraverserTraverseOnFieldCallable): void;\n}\n\nexport class ModelFieldTraverser implements IModelFieldTraverser {\n public traverse(modelAst: CmsModelAst, onField: IModelFieldTraverserTraverseOnFieldCallable) {\n this.execute(modelAst, [], onField);\n }\n\n private execute(\n root: CmsModelAst | CmsModelFieldAstNode,\n path: string[],\n onField: IModelFieldTraverserTraverseOnFieldCallable\n ) {\n for (const node of root.children) {\n const field = this.getFieldFromNode({ node, parent: root });\n onField({\n field,\n path: [...path, field.fieldId]\n });\n\n if (nodeHasChildren(node)) {\n this.execute(node, [...path, field.fieldId], onField);\n }\n }\n }\n\n private getFieldFromNode({ node, parent }: IVisitorContext) {\n if (node.type === \"collection\") {\n return (parent as CmsModelFieldAstNodeField).field;\n }\n\n return (node as CmsModelFieldAstNodeField).field;\n }\n}\n"],"mappings":";;;;;;AAOA,MAAMA,eAAe,GAAIC,IAA0B,IAAK;EACpD,OAAOA,IAAI,CAACC,QAAQ,CAACC,MAAM,GAAG,CAAC;AACnC,CAAC;AAsBM,MAAMC,mBAAmB,CAAiC;EACtDC,QAAQA,CAACC,QAAqB,EAAEC,OAAoD,EAAE;IACzF,IAAI,CAACC,OAAO,CAACF,QAAQ,EAAE,EAAE,EAAEC,OAAO,CAAC;EACvC;EAEQC,OAAOA,CACXC,IAAwC,EACxCC,IAAc,EACdH,OAAoD,EACtD;IACE,KAAK,MAAMN,IAAI,IAAIQ,IAAI,CAACP,QAAQ,EAAE;MAC9B,MAAMS,KAAK,GAAG,IAAI,CAACC,gBAAgB,CAAC;QAAEX,IAAI;QAAEY,MAAM,EAAEJ;MAAK,CAAC,CAAC;MAC3DF,OAAO,CAAC;QACJI,KAAK;QACLD,IAAI,EAAE,CAAC,GAAGA,IAAI,EAAEC,KAAK,CAACG,OAAO;MACjC,CAAC,CAAC;MAEF,IAAId,eAAe,CAACC,IAAI,CAAC,EAAE;QACvB,IAAI,CAACO,OAAO,CAACP,IAAI,EAAE,CAAC,GAAGS,IAAI,EAAEC,KAAK,CAACG,OAAO,CAAC,EAAEP,OAAO,CAAC;MACzD;IACJ;EACJ;EAEQK,gBAAgBA,CAAC;IAAEX,IAAI;IAAEY;EAAwB,CAAC,EAAE;IACxD,IAAIZ,IAAI,CAACc,IAAI,KAAK,YAAY,EAAE;MAC5B,OAAQF,MAAM,CAA+BF,KAAK;IACtD;IAEA,OAAQV,IAAI,CAA+BU,KAAK;EACpD;AACJ;AAACK,OAAA,CAAAZ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
1
+ import type { ApiEndpoint, CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
2
2
  interface RenderFieldsParams {
3
3
  models: CmsModel[];
4
4
  model: CmsModel;
@@ -1 +1 @@
1
- {"version":3,"names":["_getBaseFieldType","require","renderFields","models","model","fields","type","fieldTypePlugins","map","field","renderField","filter","Boolean","exports","plugin","getBaseFieldType","Error","createTypeField","defs"],"sources":["renderFields.ts"],"sourcesContent":["import {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n models,\n model,\n fields,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields\n .map(field => renderField({ models, model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends Omit<RenderFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n models,\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n } else if (!plugin[type]) {\n throw new Error(`Missing \"${type}\" plugin for field type \"${field.type}\".`);\n }\n const { createTypeField } = plugin[type] as CmsModelFieldToGraphQLPlugin[\"manage\"];\n const defs = createTypeField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\n fields: defs\n };\n }\n\n return defs;\n};\n"],"mappings":";;;;;;AAQA,IAAAA,iBAAA,GAAAC,OAAA;AAcO,MAAMC,YAA0B,GAAGA,CAAC;EACvCC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,IAAI;EACJC;AACJ,CAAC,KAAgC;EAC7B,OAAOF,MAAM,CACRG,GAAG,CAACC,KAAK,IAAIC,WAAW,CAAC;IAAEP,MAAM;IAAEC,KAAK;IAAEE,IAAI;IAAEG,KAAK;IAAEF;EAAiB,CAAC,CAAC,CAAC,CAC3EI,MAAM,CAACC,OAAO,CAAC;AACxB,CAAC;AAACC,OAAA,CAAAX,YAAA,GAAAA,YAAA;AAMK,MAAMQ,WAAW,GAAGA,CAAC;EACxBP,MAAM;EACNC,KAAK;EACLE,IAAI;EACJG,KAAK;EACLF;AACe,CAAC,KAAqC;EACrD,MAAMO,MAAM,GAAGP,gBAAgB,CAAC,IAAAQ,kCAAgB,EAACN,KAAK,CAAC,CAAC;EACxD,IAAI,CAACK,MAAM,EAAE;IACT;IACA,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,CAACA,MAAM,CAACR,IAAI,CAAC,EAAE;IACtB,MAAM,IAAIU,KAAK,CAAC,YAAYV,IAAI,4BAA4BG,KAAK,CAACH,IAAI,IAAI,CAAC;EAC/E;EACA,MAAM;IAAEW;EAAgB,CAAC,GAAGH,MAAM,CAACR,IAAI,CAA2C;EAClF,MAAMY,IAAI,GAAGD,eAAe,CAAC;IACzBd,MAAM;IACNC,KAAK;IACLK,KAAK;IACLF;EACJ,CAAC,CAAC;EAEF,IAAI,CAACW,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACjC,OAAO;MACHb,MAAM,EAAEa;IACZ,CAAC;EACL;EAEA,OAAOA,IAAI;AACf,CAAC;AAACL,OAAA,CAAAH,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_getBaseFieldType","require","renderFields","models","model","fields","type","fieldTypePlugins","map","field","renderField","filter","Boolean","exports","plugin","getBaseFieldType","Error","createTypeField","defs"],"sources":["renderFields.ts"],"sourcesContent":["import type {\n ApiEndpoint,\n CmsFieldTypePlugins,\n CmsModel,\n CmsModelField,\n CmsModelFieldDefinition,\n CmsModelFieldToGraphQLPlugin\n} from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderFieldsParams {\n models: CmsModel[];\n model: CmsModel;\n fields: CmsModelField[];\n type: ApiEndpoint;\n fieldTypePlugins: CmsFieldTypePlugins;\n}\n\ninterface RenderFields {\n (params: RenderFieldsParams): CmsModelFieldDefinition[];\n}\n\nexport const renderFields: RenderFields = ({\n models,\n model,\n fields,\n type,\n fieldTypePlugins\n}): CmsModelFieldDefinition[] => {\n return fields\n .map(field => renderField({ models, model, type, field, fieldTypePlugins }))\n .filter(Boolean) as CmsModelFieldDefinition[];\n};\n\ninterface RenderFieldParams extends Omit<RenderFieldsParams, \"fields\"> {\n field: CmsModelField;\n}\n\nexport const renderField = ({\n models,\n model,\n type,\n field,\n fieldTypePlugins\n}: RenderFieldParams): CmsModelFieldDefinition | null => {\n const plugin = fieldTypePlugins[getBaseFieldType(field)];\n if (!plugin) {\n // Let's not render the field if it does not exist in the field plugins.\n return null;\n } else if (!plugin[type]) {\n throw new Error(`Missing \"${type}\" plugin for field type \"${field.type}\".`);\n }\n const { createTypeField } = plugin[type] as CmsModelFieldToGraphQLPlugin[\"manage\"];\n const defs = createTypeField({\n models,\n model,\n field,\n fieldTypePlugins\n });\n\n if (!defs) {\n return null;\n } else if (typeof defs === \"string\") {\n return {\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msFieldTypePlugins, CmsModelField } from "../types";
1
+ import type { CmsFieldTypePlugins, CmsModelField } from "../types";
2
2
  interface RenderGetFilterFieldsParams {
3
3
  fields: CmsModelField[];
4
4
  fieldTypePlugins: CmsFieldTypePlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["_getBaseFieldType","require","renderGetFilterFields","fields","fieldTypePlugins","filters","field","baseType","getBaseFieldType","plugin","isSearchable","createGetFilters","read","push","filter","Boolean","join","exports"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ fields, fieldTypePlugins }) => {\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const field of fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n const plugin = fieldTypePlugins[baseType];\n if (!plugin?.isSearchable) {\n continue;\n }\n const createGetFilters = plugin.read?.createGetFilters;\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAUO,MAAMC,qBAA4C,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAAiB,CAAC,KAAK;EAC1F,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMC,KAAK,IAAIH,MAAM,EAAE;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMI,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,MAAM,GAAGL,gBAAgB,CAACG,QAAQ,CAAC;IACzC,IAAI,CAACE,MAAM,EAAEC,YAAY,EAAE;MACvB;IACJ;IACA,MAAMC,gBAAgB,GAAGF,MAAM,CAACG,IAAI,EAAED,gBAAgB;IACtD,IAAI,OAAOA,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAN,OAAO,CAACQ,IAAI,CAACF,gBAAgB,CAAC;MAAEL;IAAM,CAAC,CAAC,CAAC;EAC7C;EAEA,OAAOD,OAAO,CAACS,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAACC,OAAA,CAAAf,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_getBaseFieldType","require","renderGetFilterFields","fields","fieldTypePlugins","filters","field","baseType","getBaseFieldType","plugin","isSearchable","createGetFilters","read","push","filter","Boolean","join","exports"],"sources":["renderGetFilterFields.ts"],"sourcesContent":["import type { CmsFieldTypePlugins, CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\ninterface RenderGetFilterFieldsParams {\n fields: CmsModelField[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\ninterface RenderGetFilterFields {\n (params: RenderGetFilterFieldsParams): string;\n}\n\nexport const renderGetFilterFields: RenderGetFilterFields = ({ fields, fieldTypePlugins }) => {\n const filters: string[] = [\"id: ID\", \"entryId: String\"];\n\n for (const field of fields) {\n // Every time a client updates content model's fields, we check the type of each field. If a field plugin\n // for a particular \"field.type\" doesn't exist on the backend yet, we throw an error. But still, we also\n // want to be careful when accessing the field plugin here too. It is still possible to have a content model\n // that contains a field, for which we don't have a plugin registered on the backend. For example, user\n // could've just removed the plugin from the backend.\n const baseType = getBaseFieldType(field);\n const plugin = fieldTypePlugins[baseType];\n if (!plugin?.isSearchable) {\n continue;\n }\n const createGetFilters = plugin.read?.createGetFilters;\n if (typeof createGetFilters !== \"function\") {\n continue;\n }\n filters.push(createGetFilters({ field }));\n }\n\n return filters.filter(Boolean).join(\"\\n\");\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAUO,MAAMC,qBAA4C,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAAiB,CAAC,KAAK;EAC1F,MAAMC,OAAiB,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC;EAEvD,KAAK,MAAMC,KAAK,IAAIH,MAAM,EAAE;IACxB;IACA;IACA;IACA;IACA;IACA,MAAMI,QAAQ,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IACxC,MAAMG,MAAM,GAAGL,gBAAgB,CAACG,QAAQ,CAAC;IACzC,IAAI,CAACE,MAAM,EAAEC,YAAY,EAAE;MACvB;IACJ;IACA,MAAMC,gBAAgB,GAAGF,MAAM,CAACG,IAAI,EAAED,gBAAgB;IACtD,IAAI,OAAOA,gBAAgB,KAAK,UAAU,EAAE;MACxC;IACJ;IACAN,OAAO,CAACQ,IAAI,CAACF,gBAAgB,CAAC;MAAEL;IAAM,CAAC,CAAC,CAAC;EAC7C;EAEA,OAAOD,OAAO,CAACS,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AAC7C,CAAC;AAACC,OAAA,CAAAf,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
1
+ import type { CmsFieldTypePlugins, CmsModel, CmsModelField, CmsModelFieldDefinition } from "../types";
2
2
  interface RenderInputFieldsParams {
3
3
  models: CmsModel[];
4
4
  model: CmsModel;