@strapi/content-type-builder 5.12.1 → 5.12.2

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 (770) hide show
  1. package/dist/admin/components/AllowedTypesSelect.js +78 -0
  2. package/dist/admin/components/AllowedTypesSelect.js.map +1 -0
  3. package/dist/admin/components/AllowedTypesSelect.mjs +76 -0
  4. package/dist/admin/components/AllowedTypesSelect.mjs.map +1 -0
  5. package/dist/admin/components/AttributeIcon.js +72 -0
  6. package/dist/admin/components/AttributeIcon.js.map +1 -0
  7. package/dist/admin/components/AttributeIcon.mjs +70 -0
  8. package/dist/admin/components/AttributeIcon.mjs.map +1 -0
  9. package/dist/admin/components/AttributeOptions/AttributeList.js +31 -0
  10. package/dist/admin/components/AttributeOptions/AttributeList.js.map +1 -0
  11. package/dist/admin/components/AttributeOptions/AttributeList.mjs +29 -0
  12. package/dist/admin/components/AttributeOptions/AttributeList.mjs.map +1 -0
  13. package/dist/admin/components/AttributeOptions/AttributeOption.js +92 -0
  14. package/dist/admin/components/AttributeOptions/AttributeOption.js.map +1 -0
  15. package/dist/admin/components/AttributeOptions/AttributeOption.mjs +90 -0
  16. package/dist/admin/components/AttributeOptions/AttributeOption.mjs.map +1 -0
  17. package/dist/admin/components/AttributeOptions/AttributeOptions.js +71 -0
  18. package/dist/admin/components/AttributeOptions/AttributeOptions.js.map +1 -0
  19. package/dist/admin/components/AttributeOptions/AttributeOptions.mjs +69 -0
  20. package/dist/admin/components/AttributeOptions/AttributeOptions.mjs.map +1 -0
  21. package/dist/admin/components/AttributeOptions/CustomFieldOption.js +58 -0
  22. package/dist/admin/components/AttributeOptions/CustomFieldOption.js.map +1 -0
  23. package/dist/admin/components/AttributeOptions/CustomFieldOption.mjs +56 -0
  24. package/dist/admin/components/AttributeOptions/CustomFieldOption.mjs.map +1 -0
  25. package/dist/admin/components/AttributeOptions/CustomFieldsList.js +54 -0
  26. package/dist/admin/components/AttributeOptions/CustomFieldsList.js.map +1 -0
  27. package/dist/admin/components/AttributeOptions/CustomFieldsList.mjs +52 -0
  28. package/dist/admin/components/AttributeOptions/CustomFieldsList.mjs.map +1 -0
  29. package/dist/admin/components/AttributeOptions/EmptyAttributes.js +123 -0
  30. package/dist/admin/components/AttributeOptions/EmptyAttributes.js.map +1 -0
  31. package/dist/admin/components/AttributeOptions/EmptyAttributes.mjs +101 -0
  32. package/dist/admin/components/AttributeOptions/EmptyAttributes.mjs.map +1 -0
  33. package/dist/admin/components/AttributeOptions/OptionBoxWrapper.js +19 -0
  34. package/dist/admin/components/AttributeOptions/OptionBoxWrapper.js.map +1 -0
  35. package/dist/admin/components/AttributeOptions/OptionBoxWrapper.mjs +17 -0
  36. package/dist/admin/components/AttributeOptions/OptionBoxWrapper.mjs.map +1 -0
  37. package/dist/admin/components/AutoReloadOverlayBlocker.js +212 -0
  38. package/dist/admin/components/AutoReloadOverlayBlocker.js.map +1 -0
  39. package/dist/admin/components/AutoReloadOverlayBlocker.mjs +190 -0
  40. package/dist/admin/components/AutoReloadOverlayBlocker.mjs.map +1 -0
  41. package/dist/admin/components/BooleanDefaultValueSelect.js +54 -0
  42. package/dist/admin/components/BooleanDefaultValueSelect.js.map +1 -0
  43. package/dist/admin/components/BooleanDefaultValueSelect.mjs +52 -0
  44. package/dist/admin/components/BooleanDefaultValueSelect.mjs.map +1 -0
  45. package/dist/admin/components/BooleanRadioGroup.js +27 -0
  46. package/dist/admin/components/BooleanRadioGroup.js.map +1 -0
  47. package/dist/admin/components/BooleanRadioGroup.mjs +25 -0
  48. package/dist/admin/components/BooleanRadioGroup.mjs.map +1 -0
  49. package/dist/admin/components/BoxWrapper.js +44 -0
  50. package/dist/admin/components/BoxWrapper.js.map +1 -0
  51. package/dist/admin/components/BoxWrapper.mjs +42 -0
  52. package/dist/admin/components/BoxWrapper.mjs.map +1 -0
  53. package/dist/admin/components/CheckboxWithNumberField.js +86 -0
  54. package/dist/admin/components/CheckboxWithNumberField.js.map +1 -0
  55. package/dist/admin/components/CheckboxWithNumberField.mjs +84 -0
  56. package/dist/admin/components/CheckboxWithNumberField.mjs.map +1 -0
  57. package/dist/admin/components/ComponentCard/ComponentCard.js +112 -0
  58. package/dist/admin/components/ComponentCard/ComponentCard.js.map +1 -0
  59. package/dist/admin/components/ComponentCard/ComponentCard.mjs +110 -0
  60. package/dist/admin/components/ComponentCard/ComponentCard.mjs.map +1 -0
  61. package/dist/admin/components/ComponentCard/ComponentIcon/ComponentIcon.js +24 -0
  62. package/dist/admin/components/ComponentCard/ComponentIcon/ComponentIcon.js.map +1 -0
  63. package/dist/admin/components/ComponentCard/ComponentIcon/ComponentIcon.mjs +22 -0
  64. package/dist/admin/components/ComponentCard/ComponentIcon/ComponentIcon.mjs.map +1 -0
  65. package/dist/admin/components/ComponentList.js +40 -0
  66. package/dist/admin/components/ComponentList.js.map +1 -0
  67. package/dist/admin/components/ComponentList.mjs +38 -0
  68. package/dist/admin/components/ComponentList.mjs.map +1 -0
  69. package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.js +108 -0
  70. package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.js.map +1 -0
  71. package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.mjs +106 -0
  72. package/dist/admin/components/ContentTypeBuilderNav/ContentTypeBuilderNav.mjs.map +1 -0
  73. package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.js +179 -0
  74. package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.js.map +1 -0
  75. package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.mjs +177 -0
  76. package/dist/admin/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.mjs.map +1 -0
  77. package/dist/admin/components/ContentTypeRadioGroup.js +29 -0
  78. package/dist/admin/components/ContentTypeRadioGroup.js.map +1 -0
  79. package/dist/admin/components/ContentTypeRadioGroup.mjs +27 -0
  80. package/dist/admin/components/ContentTypeRadioGroup.mjs.map +1 -0
  81. package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.js +79 -0
  82. package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.js.map +1 -0
  83. package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.mjs +77 -0
  84. package/dist/admin/components/CustomRadioGroup/CustomRadioGroup.mjs.map +1 -0
  85. package/dist/admin/components/CustomRadioGroup/Styles.js +77 -0
  86. package/dist/admin/components/CustomRadioGroup/Styles.js.map +1 -0
  87. package/dist/admin/components/CustomRadioGroup/Styles.mjs +75 -0
  88. package/dist/admin/components/CustomRadioGroup/Styles.mjs.map +1 -0
  89. package/dist/admin/components/DataManagerProvider/DataManagerProvider.js +520 -0
  90. package/dist/admin/components/DataManagerProvider/DataManagerProvider.js.map +1 -0
  91. package/dist/admin/components/DataManagerProvider/DataManagerProvider.mjs +518 -0
  92. package/dist/admin/components/DataManagerProvider/DataManagerProvider.mjs.map +1 -0
  93. package/dist/admin/components/DataManagerProvider/reducer.js +583 -0
  94. package/dist/admin/components/DataManagerProvider/reducer.js.map +1 -0
  95. package/dist/admin/components/DataManagerProvider/reducer.mjs +579 -0
  96. package/dist/admin/components/DataManagerProvider/reducer.mjs.map +1 -0
  97. package/dist/admin/components/DataManagerProvider/selectors.js +20 -0
  98. package/dist/admin/components/DataManagerProvider/selectors.js.map +1 -0
  99. package/dist/admin/components/DataManagerProvider/selectors.mjs +17 -0
  100. package/dist/admin/components/DataManagerProvider/selectors.mjs.map +1 -0
  101. package/dist/admin/components/DataManagerProvider/utils/cleanData.js +126 -0
  102. package/dist/admin/components/DataManagerProvider/utils/cleanData.js.map +1 -0
  103. package/dist/admin/components/DataManagerProvider/utils/cleanData.mjs +120 -0
  104. package/dist/admin/components/DataManagerProvider/utils/cleanData.mjs.map +1 -0
  105. package/dist/admin/components/DataManagerProvider/utils/createDataObject.js +9 -0
  106. package/dist/admin/components/DataManagerProvider/utils/createDataObject.js.map +1 -0
  107. package/dist/admin/components/DataManagerProvider/utils/createDataObject.mjs +7 -0
  108. package/dist/admin/components/DataManagerProvider/utils/createDataObject.mjs.map +1 -0
  109. package/dist/admin/components/DataManagerProvider/utils/createModifiedDataSchema.js +20 -0
  110. package/dist/admin/components/DataManagerProvider/utils/createModifiedDataSchema.js.map +1 -0
  111. package/dist/admin/components/DataManagerProvider/utils/createModifiedDataSchema.mjs +18 -0
  112. package/dist/admin/components/DataManagerProvider/utils/createModifiedDataSchema.mjs.map +1 -0
  113. package/dist/admin/components/DataManagerProvider/utils/formatSchemas.js +30 -0
  114. package/dist/admin/components/DataManagerProvider/utils/formatSchemas.js.map +1 -0
  115. package/dist/admin/components/DataManagerProvider/utils/formatSchemas.mjs +27 -0
  116. package/dist/admin/components/DataManagerProvider/utils/formatSchemas.mjs.map +1 -0
  117. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsFromSchema.js +46 -0
  118. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsFromSchema.js.map +1 -0
  119. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsFromSchema.mjs +44 -0
  120. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsFromSchema.mjs.map +1 -0
  121. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +38 -0
  122. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js.map +1 -0
  123. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.mjs +35 -0
  124. package/dist/admin/components/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.mjs.map +1 -0
  125. package/dist/admin/components/DataManagerProvider/utils/retrieveNestedComponents.js +45 -0
  126. package/dist/admin/components/DataManagerProvider/utils/retrieveNestedComponents.js.map +1 -0
  127. package/dist/admin/components/DataManagerProvider/utils/retrieveNestedComponents.mjs +43 -0
  128. package/dist/admin/components/DataManagerProvider/utils/retrieveNestedComponents.mjs.map +1 -0
  129. package/dist/admin/components/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +17 -0
  130. package/dist/admin/components/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js.map +1 -0
  131. package/dist/admin/components/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.mjs +15 -0
  132. package/dist/admin/components/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.mjs.map +1 -0
  133. package/dist/admin/components/DataManagerProvider/utils/serverRestartWatcher.js +37 -0
  134. package/dist/admin/components/DataManagerProvider/utils/serverRestartWatcher.js.map +1 -0
  135. package/dist/admin/components/DataManagerProvider/utils/serverRestartWatcher.mjs +35 -0
  136. package/dist/admin/components/DataManagerProvider/utils/serverRestartWatcher.mjs.map +1 -0
  137. package/dist/admin/components/DataManagerProvider/utils/validateSchema.js +9 -0
  138. package/dist/admin/components/DataManagerProvider/utils/validateSchema.js.map +1 -0
  139. package/dist/admin/components/DataManagerProvider/utils/validateSchema.mjs +7 -0
  140. package/dist/admin/components/DataManagerProvider/utils/validateSchema.mjs.map +1 -0
  141. package/dist/admin/components/DisplayedType.js +48 -0
  142. package/dist/admin/components/DisplayedType.js.map +1 -0
  143. package/dist/admin/components/DisplayedType.mjs +46 -0
  144. package/dist/admin/components/DisplayedType.mjs.map +1 -0
  145. package/dist/admin/components/DraftAndPublishToggle.js +86 -0
  146. package/dist/admin/components/DraftAndPublishToggle.js.map +1 -0
  147. package/dist/admin/components/DraftAndPublishToggle.mjs +84 -0
  148. package/dist/admin/components/DraftAndPublishToggle.mjs.map +1 -0
  149. package/dist/admin/components/DynamicZoneList.js +139 -0
  150. package/dist/admin/components/DynamicZoneList.js.map +1 -0
  151. package/dist/admin/components/DynamicZoneList.mjs +137 -0
  152. package/dist/admin/components/DynamicZoneList.mjs.map +1 -0
  153. package/dist/admin/components/FormModal/FormModal.js +931 -0
  154. package/dist/admin/components/FormModal/FormModal.js.map +1 -0
  155. package/dist/admin/components/FormModal/FormModal.mjs +910 -0
  156. package/dist/admin/components/FormModal/FormModal.mjs.map +1 -0
  157. package/dist/admin/components/FormModal/attributes/advancedForm.js +471 -0
  158. package/dist/admin/components/FormModal/attributes/advancedForm.js.map +1 -0
  159. package/dist/admin/components/FormModal/attributes/advancedForm.mjs +469 -0
  160. package/dist/admin/components/FormModal/attributes/advancedForm.mjs.map +1 -0
  161. package/dist/admin/components/FormModal/attributes/attributeOptions.js +97 -0
  162. package/dist/admin/components/FormModal/attributes/attributeOptions.js.map +1 -0
  163. package/dist/admin/components/FormModal/attributes/attributeOptions.mjs +95 -0
  164. package/dist/admin/components/FormModal/attributes/attributeOptions.mjs.map +1 -0
  165. package/dist/admin/components/FormModal/attributes/baseForm.js +482 -0
  166. package/dist/admin/components/FormModal/attributes/baseForm.js.map +1 -0
  167. package/dist/admin/components/FormModal/attributes/baseForm.mjs +480 -0
  168. package/dist/admin/components/FormModal/attributes/baseForm.mjs.map +1 -0
  169. package/dist/admin/components/FormModal/attributes/commonBaseForm.js +17 -0
  170. package/dist/admin/components/FormModal/attributes/commonBaseForm.js.map +1 -0
  171. package/dist/admin/components/FormModal/attributes/commonBaseForm.mjs +15 -0
  172. package/dist/admin/components/FormModal/attributes/commonBaseForm.mjs.map +1 -0
  173. package/dist/admin/components/FormModal/attributes/form.js +12 -0
  174. package/dist/admin/components/FormModal/attributes/form.js.map +1 -0
  175. package/dist/admin/components/FormModal/attributes/form.mjs +10 -0
  176. package/dist/admin/components/FormModal/attributes/form.mjs.map +1 -0
  177. package/dist/admin/components/FormModal/attributes/nameField.js +19 -0
  178. package/dist/admin/components/FormModal/attributes/nameField.js.map +1 -0
  179. package/dist/admin/components/FormModal/attributes/nameField.mjs +17 -0
  180. package/dist/admin/components/FormModal/attributes/nameField.mjs.map +1 -0
  181. package/dist/admin/components/FormModal/attributes/types.js +305 -0
  182. package/dist/admin/components/FormModal/attributes/types.js.map +1 -0
  183. package/dist/admin/components/FormModal/attributes/types.mjs +284 -0
  184. package/dist/admin/components/FormModal/attributes/types.mjs.map +1 -0
  185. package/dist/admin/components/FormModal/attributes/validation/common.js +129 -0
  186. package/dist/admin/components/FormModal/attributes/validation/common.js.map +1 -0
  187. package/dist/admin/components/FormModal/attributes/validation/common.mjs +103 -0
  188. package/dist/admin/components/FormModal/attributes/validation/common.mjs.map +1 -0
  189. package/dist/admin/components/FormModal/category/createCategorySchema.js +43 -0
  190. package/dist/admin/components/FormModal/category/createCategorySchema.js.map +1 -0
  191. package/dist/admin/components/FormModal/category/createCategorySchema.mjs +22 -0
  192. package/dist/admin/components/FormModal/category/createCategorySchema.mjs.map +1 -0
  193. package/dist/admin/components/FormModal/category/form.js +34 -0
  194. package/dist/admin/components/FormModal/category/form.js.map +1 -0
  195. package/dist/admin/components/FormModal/category/form.mjs +32 -0
  196. package/dist/admin/components/FormModal/category/form.mjs.map +1 -0
  197. package/dist/admin/components/FormModal/category/regex.js +6 -0
  198. package/dist/admin/components/FormModal/category/regex.js.map +1 -0
  199. package/dist/admin/components/FormModal/category/regex.mjs +4 -0
  200. package/dist/admin/components/FormModal/category/regex.mjs.map +1 -0
  201. package/dist/admin/components/FormModal/component/componentField.js +40 -0
  202. package/dist/admin/components/FormModal/component/componentField.js.map +1 -0
  203. package/dist/admin/components/FormModal/component/componentField.mjs +38 -0
  204. package/dist/admin/components/FormModal/component/componentField.mjs.map +1 -0
  205. package/dist/admin/components/FormModal/component/componentForm.js +53 -0
  206. package/dist/admin/components/FormModal/component/componentForm.js.map +1 -0
  207. package/dist/admin/components/FormModal/component/componentForm.mjs +51 -0
  208. package/dist/admin/components/FormModal/component/componentForm.mjs.map +1 -0
  209. package/dist/admin/components/FormModal/component/createComponentSchema.js +65 -0
  210. package/dist/admin/components/FormModal/component/createComponentSchema.js.map +1 -0
  211. package/dist/admin/components/FormModal/component/createComponentSchema.mjs +44 -0
  212. package/dist/admin/components/FormModal/component/createComponentSchema.mjs.map +1 -0
  213. package/dist/admin/components/FormModal/contentType/contentTypeForm.js +169 -0
  214. package/dist/admin/components/FormModal/contentType/contentTypeForm.js.map +1 -0
  215. package/dist/admin/components/FormModal/contentType/contentTypeForm.mjs +167 -0
  216. package/dist/admin/components/FormModal/contentType/contentTypeForm.mjs.map +1 -0
  217. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.js +170 -0
  218. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.js.map +1 -0
  219. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.mjs +149 -0
  220. package/dist/admin/components/FormModal/contentType/createContentTypeSchema.mjs.map +1 -0
  221. package/dist/admin/components/FormModal/dynamiczoneForm.js +68 -0
  222. package/dist/admin/components/FormModal/dynamiczoneForm.js.map +1 -0
  223. package/dist/admin/components/FormModal/dynamiczoneForm.mjs +66 -0
  224. package/dist/admin/components/FormModal/dynamiczoneForm.mjs.map +1 -0
  225. package/dist/admin/components/FormModal/forms/forms.js +275 -0
  226. package/dist/admin/components/FormModal/forms/forms.js.map +1 -0
  227. package/dist/admin/components/FormModal/forms/forms.mjs +273 -0
  228. package/dist/admin/components/FormModal/forms/forms.mjs.map +1 -0
  229. package/dist/admin/components/FormModal/forms/utils/addItemsToFormSection.js +21 -0
  230. package/dist/admin/components/FormModal/forms/utils/addItemsToFormSection.js.map +1 -0
  231. package/dist/admin/components/FormModal/forms/utils/addItemsToFormSection.mjs +19 -0
  232. package/dist/admin/components/FormModal/forms/utils/addItemsToFormSection.mjs.map +1 -0
  233. package/dist/admin/components/FormModal/forms/utils/createCollectionName.js +13 -0
  234. package/dist/admin/components/FormModal/forms/utils/createCollectionName.js.map +1 -0
  235. package/dist/admin/components/FormModal/forms/utils/createCollectionName.mjs +11 -0
  236. package/dist/admin/components/FormModal/forms/utils/createCollectionName.mjs.map +1 -0
  237. package/dist/admin/components/FormModal/forms/utils/getUsedAttributeNames.js +10 -0
  238. package/dist/admin/components/FormModal/forms/utils/getUsedAttributeNames.js.map +1 -0
  239. package/dist/admin/components/FormModal/forms/utils/getUsedAttributeNames.mjs +8 -0
  240. package/dist/admin/components/FormModal/forms/utils/getUsedAttributeNames.mjs.map +1 -0
  241. package/dist/admin/components/FormModal/reducer.js +327 -0
  242. package/dist/admin/components/FormModal/reducer.js.map +1 -0
  243. package/dist/admin/components/FormModal/reducer.mjs +323 -0
  244. package/dist/admin/components/FormModal/reducer.mjs.map +1 -0
  245. package/dist/admin/components/FormModal/selectors.js +20 -0
  246. package/dist/admin/components/FormModal/selectors.js.map +1 -0
  247. package/dist/admin/components/FormModal/selectors.mjs +17 -0
  248. package/dist/admin/components/FormModal/selectors.mjs.map +1 -0
  249. package/dist/admin/components/FormModal/utils/canEditContentType.js +32 -0
  250. package/dist/admin/components/FormModal/utils/canEditContentType.js.map +1 -0
  251. package/dist/admin/components/FormModal/utils/canEditContentType.mjs +30 -0
  252. package/dist/admin/components/FormModal/utils/canEditContentType.mjs.map +1 -0
  253. package/dist/admin/components/FormModal/utils/createUid.js +16 -0
  254. package/dist/admin/components/FormModal/utils/createUid.js.map +1 -0
  255. package/dist/admin/components/FormModal/utils/createUid.mjs +13 -0
  256. package/dist/admin/components/FormModal/utils/createUid.mjs.map +1 -0
  257. package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.js +18 -0
  258. package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.js.map +1 -0
  259. package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.mjs +16 -0
  260. package/dist/admin/components/FormModal/utils/customFieldDefaultOptionsReducer.mjs.map +1 -0
  261. package/dist/admin/components/FormModal/utils/getAttributesToDisplay.js +56 -0
  262. package/dist/admin/components/FormModal/utils/getAttributesToDisplay.js.map +1 -0
  263. package/dist/admin/components/FormModal/utils/getAttributesToDisplay.mjs +54 -0
  264. package/dist/admin/components/FormModal/utils/getAttributesToDisplay.mjs.map +1 -0
  265. package/dist/admin/components/FormModal/utils/getFormInputNames.js +17 -0
  266. package/dist/admin/components/FormModal/utils/getFormInputNames.js.map +1 -0
  267. package/dist/admin/components/FormModal/utils/getFormInputNames.mjs +15 -0
  268. package/dist/admin/components/FormModal/utils/getFormInputNames.mjs.map +1 -0
  269. package/dist/admin/components/FormModal/utils/relations.js +15 -0
  270. package/dist/admin/components/FormModal/utils/relations.js.map +1 -0
  271. package/dist/admin/components/FormModal/utils/relations.mjs +12 -0
  272. package/dist/admin/components/FormModal/utils/relations.mjs.map +1 -0
  273. package/dist/admin/components/FormModalEndActions.js +322 -0
  274. package/dist/admin/components/FormModalEndActions.js.map +1 -0
  275. package/dist/admin/components/FormModalEndActions.mjs +320 -0
  276. package/dist/admin/components/FormModalEndActions.mjs.map +1 -0
  277. package/dist/admin/components/FormModalHeader.js +150 -0
  278. package/dist/admin/components/FormModalHeader.js.map +1 -0
  279. package/dist/admin/components/FormModalHeader.mjs +148 -0
  280. package/dist/admin/components/FormModalHeader.mjs.map +1 -0
  281. package/dist/admin/components/FormModalNavigationProvider/FormModalNavigationProvider.js +228 -0
  282. package/dist/admin/components/FormModalNavigationProvider/FormModalNavigationProvider.js.map +1 -0
  283. package/dist/admin/components/FormModalNavigationProvider/FormModalNavigationProvider.mjs +207 -0
  284. package/dist/admin/components/FormModalNavigationProvider/FormModalNavigationProvider.mjs.map +1 -0
  285. package/dist/admin/components/FormModalNavigationProvider/constants.js +21 -0
  286. package/dist/admin/components/FormModalNavigationProvider/constants.js.map +1 -0
  287. package/dist/admin/components/FormModalNavigationProvider/constants.mjs +19 -0
  288. package/dist/admin/components/FormModalNavigationProvider/constants.mjs.map +1 -0
  289. package/dist/admin/components/FormModalSubHeader.js +70 -0
  290. package/dist/admin/components/FormModalSubHeader.js.map +1 -0
  291. package/dist/admin/components/FormModalSubHeader.mjs +67 -0
  292. package/dist/admin/components/FormModalSubHeader.mjs.map +1 -0
  293. package/dist/admin/components/GenericInputs.js +529 -0
  294. package/dist/admin/components/GenericInputs.js.map +1 -0
  295. package/dist/admin/components/GenericInputs.mjs +508 -0
  296. package/dist/admin/components/GenericInputs.mjs.map +1 -0
  297. package/dist/admin/components/IconPicker/IconPicker.js +196 -0
  298. package/dist/admin/components/IconPicker/IconPicker.js.map +1 -0
  299. package/dist/admin/components/IconPicker/IconPicker.mjs +194 -0
  300. package/dist/admin/components/IconPicker/IconPicker.mjs.map +1 -0
  301. package/dist/admin/components/IconPicker/constants.js +155 -0
  302. package/dist/admin/components/IconPicker/constants.js.map +1 -0
  303. package/dist/admin/components/IconPicker/constants.mjs +133 -0
  304. package/dist/admin/components/IconPicker/constants.mjs.map +1 -0
  305. package/dist/admin/components/List.js +243 -0
  306. package/dist/admin/components/List.js.map +1 -0
  307. package/dist/admin/components/List.mjs +241 -0
  308. package/dist/admin/components/List.mjs.map +1 -0
  309. package/dist/admin/components/ListRow.js +164 -0
  310. package/dist/admin/components/ListRow.js.map +1 -0
  311. package/dist/admin/components/ListRow.mjs +161 -0
  312. package/dist/admin/components/ListRow.mjs.map +1 -0
  313. package/dist/admin/components/NestedFooter.js +62 -0
  314. package/dist/admin/components/NestedFooter.js.map +1 -0
  315. package/dist/admin/components/NestedFooter.mjs +60 -0
  316. package/dist/admin/components/NestedFooter.mjs.map +1 -0
  317. package/dist/admin/components/PluralName.js +74 -0
  318. package/dist/admin/components/PluralName.js.map +1 -0
  319. package/dist/admin/components/PluralName.mjs +72 -0
  320. package/dist/admin/components/PluralName.mjs.map +1 -0
  321. package/dist/admin/components/Relation/Relation.js +47 -0
  322. package/dist/admin/components/Relation/Relation.js.map +1 -0
  323. package/dist/admin/components/Relation/Relation.mjs +45 -0
  324. package/dist/admin/components/Relation/Relation.mjs.map +1 -0
  325. package/dist/admin/components/Relation/RelationField/RelationField.js +52 -0
  326. package/dist/admin/components/Relation/RelationField/RelationField.js.map +1 -0
  327. package/dist/admin/components/Relation/RelationField/RelationField.mjs +50 -0
  328. package/dist/admin/components/Relation/RelationField/RelationField.mjs.map +1 -0
  329. package/dist/admin/components/Relation/RelationField/RelationTargetPicker/RelationTargetPicker.js +74 -0
  330. package/dist/admin/components/Relation/RelationField/RelationTargetPicker/RelationTargetPicker.js.map +1 -0
  331. package/dist/admin/components/Relation/RelationField/RelationTargetPicker/RelationTargetPicker.mjs +72 -0
  332. package/dist/admin/components/Relation/RelationField/RelationTargetPicker/RelationTargetPicker.mjs.map +1 -0
  333. package/dist/admin/components/Relation/RelationNaturePicker/Components.js +49 -0
  334. package/dist/admin/components/Relation/RelationNaturePicker/Components.js.map +1 -0
  335. package/dist/admin/components/Relation/RelationNaturePicker/Components.mjs +45 -0
  336. package/dist/admin/components/Relation/RelationNaturePicker/Components.mjs.map +1 -0
  337. package/dist/admin/components/Relation/RelationNaturePicker/RelationNaturePicker.js +149 -0
  338. package/dist/admin/components/Relation/RelationNaturePicker/RelationNaturePicker.js.map +1 -0
  339. package/dist/admin/components/Relation/RelationNaturePicker/RelationNaturePicker.mjs +147 -0
  340. package/dist/admin/components/Relation/RelationNaturePicker/RelationNaturePicker.mjs.map +1 -0
  341. package/dist/admin/components/SelectCategory.js +60 -0
  342. package/dist/admin/components/SelectCategory.js.map +1 -0
  343. package/dist/admin/components/SelectCategory.mjs +58 -0
  344. package/dist/admin/components/SelectCategory.mjs.map +1 -0
  345. package/dist/admin/components/SelectComponent.js +90 -0
  346. package/dist/admin/components/SelectComponent.js.map +1 -0
  347. package/dist/admin/components/SelectComponent.mjs +88 -0
  348. package/dist/admin/components/SelectComponent.mjs.map +1 -0
  349. package/dist/admin/components/SelectComponents.js +70 -0
  350. package/dist/admin/components/SelectComponents.js.map +1 -0
  351. package/dist/admin/components/SelectComponents.mjs +68 -0
  352. package/dist/admin/components/SelectComponents.mjs.map +1 -0
  353. package/dist/admin/components/SelectDateType.js +62 -0
  354. package/dist/admin/components/SelectDateType.js.map +1 -0
  355. package/dist/admin/components/SelectDateType.mjs +60 -0
  356. package/dist/admin/components/SelectDateType.mjs.map +1 -0
  357. package/dist/admin/components/SelectNumber.js +111 -0
  358. package/dist/admin/components/SelectNumber.js.map +1 -0
  359. package/dist/admin/components/SelectNumber.mjs +109 -0
  360. package/dist/admin/components/SelectNumber.mjs.map +1 -0
  361. package/dist/admin/components/SingularName.js +63 -0
  362. package/dist/admin/components/SingularName.js.map +1 -0
  363. package/dist/admin/components/SingularName.mjs +61 -0
  364. package/dist/admin/components/SingularName.mjs.map +1 -0
  365. package/dist/admin/components/TabForm.js +81 -0
  366. package/dist/admin/components/TabForm.js.map +1 -0
  367. package/dist/admin/components/TabForm.mjs +79 -0
  368. package/dist/admin/components/TabForm.mjs.map +1 -0
  369. package/dist/admin/components/TextareaEnum.js +58 -0
  370. package/dist/admin/components/TextareaEnum.js.map +1 -0
  371. package/dist/admin/components/TextareaEnum.mjs +56 -0
  372. package/dist/admin/components/TextareaEnum.mjs.map +1 -0
  373. package/dist/admin/components/Tr.js +48 -0
  374. package/dist/admin/components/Tr.js.map +1 -0
  375. package/dist/admin/components/Tr.mjs +46 -0
  376. package/dist/admin/components/Tr.mjs.map +1 -0
  377. package/dist/admin/components/UpperFirst.js +11 -0
  378. package/dist/admin/components/UpperFirst.js.map +1 -0
  379. package/dist/admin/components/UpperFirst.mjs +9 -0
  380. package/dist/admin/components/UpperFirst.mjs.map +1 -0
  381. package/dist/admin/constants.js +19 -0
  382. package/dist/admin/constants.js.map +1 -0
  383. package/dist/admin/constants.mjs +16 -0
  384. package/dist/admin/constants.mjs.map +1 -0
  385. package/dist/admin/contexts/DataManagerContext.js +9 -0
  386. package/dist/admin/contexts/DataManagerContext.js.map +1 -0
  387. package/dist/admin/contexts/DataManagerContext.mjs +7 -0
  388. package/dist/admin/contexts/DataManagerContext.mjs.map +1 -0
  389. package/dist/admin/contexts/FormModalNavigationContext.js +28 -0
  390. package/dist/admin/contexts/FormModalNavigationContext.js.map +1 -0
  391. package/dist/admin/contexts/FormModalNavigationContext.mjs +7 -0
  392. package/dist/admin/contexts/FormModalNavigationContext.mjs.map +1 -0
  393. package/dist/admin/hooks/useDataManager.js +9 -0
  394. package/dist/admin/hooks/useDataManager.js.map +1 -0
  395. package/dist/admin/hooks/useDataManager.mjs +7 -0
  396. package/dist/admin/hooks/useDataManager.mjs.map +1 -0
  397. package/dist/admin/hooks/useFormModalNavigation.js +9 -0
  398. package/dist/admin/hooks/useFormModalNavigation.js.map +1 -0
  399. package/dist/admin/hooks/useFormModalNavigation.mjs +7 -0
  400. package/dist/admin/hooks/useFormModalNavigation.mjs.map +1 -0
  401. package/dist/admin/icons/Curve.js +46 -0
  402. package/dist/admin/icons/Curve.js.map +1 -0
  403. package/dist/admin/icons/Curve.mjs +44 -0
  404. package/dist/admin/icons/Curve.mjs.map +1 -0
  405. package/dist/admin/index.js +86 -20
  406. package/dist/admin/index.js.map +1 -1
  407. package/dist/admin/index.mjs +85 -17
  408. package/dist/admin/index.mjs.map +1 -1
  409. package/dist/admin/pages/App/index.js +66 -0
  410. package/dist/admin/pages/App/index.js.map +1 -0
  411. package/dist/admin/pages/App/index.mjs +62 -0
  412. package/dist/admin/pages/App/index.mjs.map +1 -0
  413. package/dist/admin/pages/ListView/LinkToCMSettingsView.js +81 -0
  414. package/dist/admin/pages/ListView/LinkToCMSettingsView.js.map +1 -0
  415. package/dist/admin/pages/ListView/LinkToCMSettingsView.mjs +79 -0
  416. package/dist/admin/pages/ListView/LinkToCMSettingsView.mjs.map +1 -0
  417. package/dist/admin/pages/ListView/ListView.js +218 -0
  418. package/dist/admin/pages/ListView/ListView.js.map +1 -0
  419. package/dist/admin/pages/ListView/ListView.mjs +216 -0
  420. package/dist/admin/pages/ListView/ListView.mjs.map +1 -0
  421. package/dist/admin/pluginId.js +6 -0
  422. package/dist/admin/pluginId.js.map +1 -0
  423. package/dist/admin/pluginId.mjs +4 -0
  424. package/dist/admin/pluginId.mjs.map +1 -0
  425. package/dist/admin/reducers.js +13 -0
  426. package/dist/admin/reducers.js.map +1 -0
  427. package/dist/admin/reducers.mjs +11 -0
  428. package/dist/admin/reducers.mjs.map +1 -0
  429. package/dist/admin/{chunks/ar-Df0f0-PT.js → translations/ar.json.js} +3 -1
  430. package/dist/admin/translations/ar.json.js.map +1 -0
  431. package/dist/admin/{chunks/ar-sRW9VFC-.mjs → translations/ar.json.mjs} +1 -1
  432. package/dist/admin/translations/ar.json.mjs.map +1 -0
  433. package/dist/admin/{chunks/cs-DeTwqc7p.js → translations/cs.json.js} +3 -1
  434. package/dist/admin/translations/cs.json.js.map +1 -0
  435. package/dist/admin/{chunks/cs-BpQ26jiq.mjs → translations/cs.json.mjs} +1 -1
  436. package/dist/admin/translations/cs.json.mjs.map +1 -0
  437. package/dist/admin/{chunks/de-BJkS06jF.js → translations/de.json.js} +3 -1
  438. package/dist/admin/translations/de.json.js.map +1 -0
  439. package/dist/admin/{chunks/de-DSxx5_x-.mjs → translations/de.json.mjs} +1 -1
  440. package/dist/admin/translations/de.json.mjs.map +1 -0
  441. package/dist/admin/{chunks/dk-CGm-qVH7.js → translations/dk.json.js} +3 -1
  442. package/dist/admin/translations/dk.json.js.map +1 -0
  443. package/dist/admin/{chunks/dk-BnjVZ7A_.mjs → translations/dk.json.mjs} +1 -1
  444. package/dist/admin/translations/dk.json.mjs.map +1 -0
  445. package/dist/admin/{chunks/en-BJUu34b0.js → translations/en.json.js} +3 -1
  446. package/dist/admin/translations/en.json.js.map +1 -0
  447. package/dist/admin/{chunks/en-Bhut8Yay.mjs → translations/en.json.mjs} +1 -1
  448. package/dist/admin/translations/en.json.mjs.map +1 -0
  449. package/dist/admin/{chunks/es-J8kvHlNy.js → translations/es.json.js} +3 -1
  450. package/dist/admin/translations/es.json.js.map +1 -0
  451. package/dist/admin/{chunks/es-DG8g9igJ.mjs → translations/es.json.mjs} +1 -1
  452. package/dist/admin/translations/es.json.mjs.map +1 -0
  453. package/dist/admin/{chunks/fr-C6y35iY7.js → translations/fr.json.js} +3 -1
  454. package/dist/admin/translations/fr.json.js.map +1 -0
  455. package/dist/admin/{chunks/fr-UpV34MHY.mjs → translations/fr.json.mjs} +1 -1
  456. package/dist/admin/translations/fr.json.mjs.map +1 -0
  457. package/dist/admin/{chunks/id-BvxV6wLP.js → translations/id.json.js} +3 -1
  458. package/dist/admin/translations/id.json.js.map +1 -0
  459. package/dist/admin/{chunks/id-BWM18ljw.mjs → translations/id.json.mjs} +1 -1
  460. package/dist/admin/translations/id.json.mjs.map +1 -0
  461. package/dist/admin/{chunks/it-C_IgFU-G.js → translations/it.json.js} +3 -1
  462. package/dist/admin/translations/it.json.js.map +1 -0
  463. package/dist/admin/{chunks/it-1_vd9gV4.mjs → translations/it.json.mjs} +1 -1
  464. package/dist/admin/{chunks/ms-C3s4kxq6.mjs.map → translations/it.json.mjs.map} +1 -1
  465. package/dist/admin/{chunks/ja-CWo4Qqq6.js → translations/ja.json.js} +3 -1
  466. package/dist/admin/translations/ja.json.js.map +1 -0
  467. package/dist/admin/{chunks/ja-Cx23a2Ui.mjs → translations/ja.json.mjs} +1 -1
  468. package/dist/admin/translations/ja.json.mjs.map +1 -0
  469. package/dist/admin/{chunks/ko-BsByJNEl.js → translations/ko.json.js} +3 -1
  470. package/dist/admin/translations/ko.json.js.map +1 -0
  471. package/dist/admin/{chunks/ko-DC7paEx5.mjs → translations/ko.json.mjs} +1 -1
  472. package/dist/admin/translations/ko.json.mjs.map +1 -0
  473. package/dist/admin/{chunks/ms-DPTzS7SH.js → translations/ms.json.js} +3 -1
  474. package/dist/admin/translations/ms.json.js.map +1 -0
  475. package/dist/admin/{chunks/ms-C3s4kxq6.mjs → translations/ms.json.mjs} +1 -1
  476. package/dist/admin/translations/ms.json.mjs.map +1 -0
  477. package/dist/admin/{chunks/nl-db29QMOx.js → translations/nl.json.js} +3 -1
  478. package/dist/admin/translations/nl.json.js.map +1 -0
  479. package/dist/admin/{chunks/nl-TzvfktV_.mjs → translations/nl.json.mjs} +1 -1
  480. package/dist/admin/translations/nl.json.mjs.map +1 -0
  481. package/dist/admin/{chunks/pl-pYy1djj3.js → translations/pl.json.js} +3 -1
  482. package/dist/admin/translations/pl.json.js.map +1 -0
  483. package/dist/admin/{chunks/pl-BdvupIN_.mjs → translations/pl.json.mjs} +1 -1
  484. package/dist/admin/translations/pl.json.mjs.map +1 -0
  485. package/dist/admin/{chunks/pt-BR-CTPuXGWF.js → translations/pt-BR.json.js} +3 -1
  486. package/dist/admin/translations/pt-BR.json.js.map +1 -0
  487. package/dist/admin/{chunks/pt-BR-DPrVmKeZ.mjs → translations/pt-BR.json.mjs} +1 -1
  488. package/dist/admin/{chunks/dk-CGm-qVH7.js.map → translations/pt-BR.json.mjs.map} +1 -1
  489. package/dist/admin/{chunks/pt-BQmWcdeG.js → translations/pt.json.js} +3 -1
  490. package/dist/admin/translations/pt.json.js.map +1 -0
  491. package/dist/admin/{chunks/pt-BTLIwmCv.mjs → translations/pt.json.mjs} +1 -1
  492. package/dist/admin/translations/pt.json.mjs.map +1 -0
  493. package/dist/admin/{chunks/ru-DQiDXgUV.js → translations/ru.json.js} +3 -1
  494. package/dist/admin/translations/ru.json.js.map +1 -0
  495. package/dist/admin/{chunks/ru-D46no502.mjs → translations/ru.json.mjs} +1 -1
  496. package/dist/admin/translations/ru.json.mjs.map +1 -0
  497. package/dist/admin/{chunks/sk-DrnebmXb.js → translations/sk.json.js} +3 -1
  498. package/dist/admin/translations/sk.json.js.map +1 -0
  499. package/dist/admin/{chunks/sk-Byr_l4Jc.mjs → translations/sk.json.mjs} +1 -1
  500. package/dist/admin/translations/sk.json.mjs.map +1 -0
  501. package/dist/admin/{chunks/sv-CrWlNosi.js → translations/sv.json.js} +3 -1
  502. package/dist/admin/translations/sv.json.js.map +1 -0
  503. package/dist/admin/{chunks/sv-Bbam7IDm.mjs → translations/sv.json.mjs} +1 -1
  504. package/dist/admin/translations/sv.json.mjs.map +1 -0
  505. package/dist/admin/{chunks/th-BbrCkfgX.js → translations/th.json.js} +3 -1
  506. package/dist/admin/translations/th.json.js.map +1 -0
  507. package/dist/admin/{chunks/th-hfS0Wmk_.mjs → translations/th.json.mjs} +1 -1
  508. package/dist/admin/translations/th.json.mjs.map +1 -0
  509. package/dist/admin/{chunks/tr-CHdMj8m6.js → translations/tr.json.js} +3 -1
  510. package/dist/admin/translations/tr.json.js.map +1 -0
  511. package/dist/admin/{chunks/tr-DS7DBOhC.mjs → translations/tr.json.mjs} +1 -1
  512. package/dist/admin/translations/tr.json.mjs.map +1 -0
  513. package/dist/admin/{chunks/uk-felSA_eV.js → translations/uk.json.js} +3 -1
  514. package/dist/admin/translations/uk.json.js.map +1 -0
  515. package/dist/admin/{chunks/uk-CjzmJyt1.mjs → translations/uk.json.mjs} +1 -1
  516. package/dist/admin/translations/uk.json.mjs.map +1 -0
  517. package/dist/admin/{chunks/zh-Hans-lXbNiMp9.js → translations/zh-Hans.json.js} +3 -1
  518. package/dist/admin/{chunks/cs-BpQ26jiq.mjs.map → translations/zh-Hans.json.js.map} +1 -1
  519. package/dist/admin/{chunks/zh-Hans-BElOnuRb.mjs → translations/zh-Hans.json.mjs} +1 -1
  520. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  521. package/dist/admin/{chunks/zh-CWj4avQA.js → translations/zh.json.js} +3 -1
  522. package/dist/admin/translations/zh.json.js.map +1 -0
  523. package/dist/admin/{chunks/zh-BUVXH75-.mjs → translations/zh.json.mjs} +1 -1
  524. package/dist/admin/translations/zh.json.mjs.map +1 -0
  525. package/dist/admin/utils/findAttribute.js +8 -0
  526. package/dist/admin/utils/findAttribute.js.map +1 -0
  527. package/dist/admin/utils/findAttribute.mjs +6 -0
  528. package/dist/admin/utils/findAttribute.mjs.map +1 -0
  529. package/dist/admin/utils/formAPI.js +134 -0
  530. package/dist/admin/utils/formAPI.js.map +1 -0
  531. package/dist/admin/utils/formAPI.mjs +113 -0
  532. package/dist/admin/utils/formAPI.mjs.map +1 -0
  533. package/dist/admin/utils/getAttributeDisplayedType.js +32 -0
  534. package/dist/admin/utils/getAttributeDisplayedType.js.map +1 -0
  535. package/dist/admin/utils/getAttributeDisplayedType.mjs +30 -0
  536. package/dist/admin/utils/getAttributeDisplayedType.mjs.map +1 -0
  537. package/dist/admin/utils/getMaxDepth.js +74 -0
  538. package/dist/admin/utils/getMaxDepth.js.map +1 -0
  539. package/dist/admin/utils/getMaxDepth.mjs +71 -0
  540. package/dist/admin/utils/getMaxDepth.mjs.map +1 -0
  541. package/dist/admin/utils/getRelationType.js +18 -0
  542. package/dist/admin/utils/getRelationType.js.map +1 -0
  543. package/dist/admin/utils/getRelationType.mjs +16 -0
  544. package/dist/admin/utils/getRelationType.mjs.map +1 -0
  545. package/dist/admin/utils/getTrad.js +8 -0
  546. package/dist/admin/utils/getTrad.js.map +1 -0
  547. package/dist/admin/utils/getTrad.mjs +6 -0
  548. package/dist/admin/utils/getTrad.mjs.map +1 -0
  549. package/dist/admin/utils/getYupInnerErrors.js +23 -0
  550. package/dist/admin/utils/getYupInnerErrors.js.map +1 -0
  551. package/dist/admin/utils/getYupInnerErrors.mjs +21 -0
  552. package/dist/admin/utils/getYupInnerErrors.mjs.map +1 -0
  553. package/dist/admin/utils/isAllowedContentTypesForRelations.js +8 -0
  554. package/dist/admin/utils/isAllowedContentTypesForRelations.js.map +1 -0
  555. package/dist/admin/utils/isAllowedContentTypesForRelations.mjs +6 -0
  556. package/dist/admin/utils/isAllowedContentTypesForRelations.mjs.map +1 -0
  557. package/dist/admin/utils/makeUnique.js +8 -0
  558. package/dist/admin/utils/makeUnique.js.map +1 -0
  559. package/dist/admin/utils/makeUnique.mjs +6 -0
  560. package/dist/admin/utils/makeUnique.mjs.map +1 -0
  561. package/dist/admin/utils/nameToSlug.js +10 -0
  562. package/dist/admin/utils/nameToSlug.js.map +1 -0
  563. package/dist/admin/utils/nameToSlug.mjs +8 -0
  564. package/dist/admin/utils/nameToSlug.mjs.map +1 -0
  565. package/dist/admin/utils/parseDateValue.js +17 -0
  566. package/dist/admin/utils/parseDateValue.js.map +1 -0
  567. package/dist/admin/utils/parseDateValue.mjs +15 -0
  568. package/dist/admin/utils/parseDateValue.mjs.map +1 -0
  569. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  570. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  571. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  572. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  573. package/dist/admin/utils/timeFormat.js +38 -0
  574. package/dist/admin/utils/timeFormat.js.map +1 -0
  575. package/dist/admin/utils/timeFormat.mjs +35 -0
  576. package/dist/admin/utils/timeFormat.mjs.map +1 -0
  577. package/dist/admin/utils/toRegressedEnumValue.js +17 -0
  578. package/dist/admin/utils/toRegressedEnumValue.js.map +1 -0
  579. package/dist/admin/utils/toRegressedEnumValue.mjs +15 -0
  580. package/dist/admin/utils/toRegressedEnumValue.mjs.map +1 -0
  581. package/dist/server/bootstrap.js +16 -0
  582. package/dist/server/bootstrap.js.map +1 -0
  583. package/dist/server/bootstrap.mjs +14 -0
  584. package/dist/server/bootstrap.mjs.map +1 -0
  585. package/dist/server/config.js +9 -0
  586. package/dist/server/config.js.map +1 -0
  587. package/dist/server/config.mjs +7 -0
  588. package/dist/server/config.mjs.map +1 -0
  589. package/dist/server/controllers/builder.js +12 -0
  590. package/dist/server/controllers/builder.js.map +1 -0
  591. package/dist/server/controllers/builder.mjs +10 -0
  592. package/dist/server/controllers/builder.mjs.map +1 -0
  593. package/dist/server/controllers/component-categories.js +38 -0
  594. package/dist/server/controllers/component-categories.js.map +1 -0
  595. package/dist/server/controllers/component-categories.mjs +36 -0
  596. package/dist/server/controllers/component-categories.mjs.map +1 -0
  597. package/dist/server/controllers/components.js +144 -0
  598. package/dist/server/controllers/components.js.map +1 -0
  599. package/dist/server/controllers/components.mjs +142 -0
  600. package/dist/server/controllers/components.mjs.map +1 -0
  601. package/dist/server/controllers/content-types.js +142 -0
  602. package/dist/server/controllers/content-types.js.map +1 -0
  603. package/dist/server/controllers/content-types.mjs +140 -0
  604. package/dist/server/controllers/content-types.mjs.map +1 -0
  605. package/dist/server/controllers/index.js +16 -0
  606. package/dist/server/controllers/index.js.map +1 -0
  607. package/dist/server/controllers/index.mjs +14 -0
  608. package/dist/server/controllers/index.mjs.map +1 -0
  609. package/dist/server/controllers/validation/common.js +102 -0
  610. package/dist/server/controllers/validation/common.js.map +1 -0
  611. package/dist/server/controllers/validation/common.mjs +85 -0
  612. package/dist/server/controllers/validation/common.mjs.map +1 -0
  613. package/dist/server/controllers/validation/component-category.js +12 -0
  614. package/dist/server/controllers/validation/component-category.js.map +1 -0
  615. package/dist/server/controllers/validation/component-category.mjs +10 -0
  616. package/dist/server/controllers/validation/component-category.mjs.map +1 -0
  617. package/dist/server/controllers/validation/component.js +68 -0
  618. package/dist/server/controllers/validation/component.js.map +1 -0
  619. package/dist/server/controllers/validation/component.mjs +60 -0
  620. package/dist/server/controllers/validation/component.mjs.map +1 -0
  621. package/dist/server/controllers/validation/content-type.js +153 -0
  622. package/dist/server/controllers/validation/content-type.js.map +1 -0
  623. package/dist/server/controllers/validation/content-type.mjs +149 -0
  624. package/dist/server/controllers/validation/content-type.mjs.map +1 -0
  625. package/dist/server/controllers/validation/data-transform.js +27 -0
  626. package/dist/server/controllers/validation/data-transform.js.map +1 -0
  627. package/dist/server/controllers/validation/data-transform.mjs +24 -0
  628. package/dist/server/controllers/validation/data-transform.mjs.map +1 -0
  629. package/dist/server/controllers/validation/model-schema.js +90 -0
  630. package/dist/server/controllers/validation/model-schema.js.map +1 -0
  631. package/dist/server/controllers/validation/model-schema.mjs +88 -0
  632. package/dist/server/controllers/validation/model-schema.mjs.map +1 -0
  633. package/dist/server/controllers/validation/relations.js +70 -0
  634. package/dist/server/controllers/validation/relations.js.map +1 -0
  635. package/dist/server/controllers/validation/relations.mjs +68 -0
  636. package/dist/server/controllers/validation/relations.mjs.map +1 -0
  637. package/dist/server/controllers/validation/types.js +215 -0
  638. package/dist/server/controllers/validation/types.js.map +1 -0
  639. package/dist/server/controllers/validation/types.mjs +213 -0
  640. package/dist/server/controllers/validation/types.mjs.map +1 -0
  641. package/dist/server/index.js +8 -2654
  642. package/dist/server/index.js.map +1 -1
  643. package/dist/server/index.mjs +5 -2633
  644. package/dist/server/index.mjs.map +1 -1
  645. package/dist/server/routes/admin.js +231 -0
  646. package/dist/server/routes/admin.js.map +1 -0
  647. package/dist/server/routes/admin.mjs +229 -0
  648. package/dist/server/routes/admin.mjs.map +1 -0
  649. package/dist/server/routes/content-api.js +30 -0
  650. package/dist/server/routes/content-api.js.map +1 -0
  651. package/dist/server/routes/content-api.mjs +28 -0
  652. package/dist/server/routes/content-api.mjs.map +1 -0
  653. package/dist/server/routes/index.js +12 -0
  654. package/dist/server/routes/index.js.map +1 -0
  655. package/dist/server/routes/index.mjs +10 -0
  656. package/dist/server/routes/index.mjs.map +1 -0
  657. package/dist/server/services/api-handler.js +109 -0
  658. package/dist/server/services/api-handler.js.map +1 -0
  659. package/dist/server/services/api-handler.mjs +85 -0
  660. package/dist/server/services/api-handler.mjs.map +1 -0
  661. package/dist/server/services/builder.js +81 -0
  662. package/dist/server/services/builder.js.map +1 -0
  663. package/dist/server/services/builder.mjs +75 -0
  664. package/dist/server/services/builder.mjs.map +1 -0
  665. package/dist/server/services/component-categories.js +59 -0
  666. package/dist/server/services/component-categories.js.map +1 -0
  667. package/dist/server/services/component-categories.mjs +56 -0
  668. package/dist/server/services/component-categories.mjs.map +1 -0
  669. package/dist/server/services/components.js +79 -0
  670. package/dist/server/services/components.js.map +1 -0
  671. package/dist/server/services/components.mjs +74 -0
  672. package/dist/server/services/components.mjs.map +1 -0
  673. package/dist/server/services/constants.js +52 -0
  674. package/dist/server/services/constants.js.map +1 -0
  675. package/dist/server/services/constants.mjs +45 -0
  676. package/dist/server/services/constants.mjs.map +1 -0
  677. package/dist/server/services/content-types.js +223 -0
  678. package/dist/server/services/content-types.js.map +1 -0
  679. package/dist/server/services/content-types.mjs +213 -0
  680. package/dist/server/services/content-types.mjs.map +1 -0
  681. package/dist/server/services/index.js +18 -0
  682. package/dist/server/services/index.js.map +1 -0
  683. package/dist/server/services/index.mjs +16 -0
  684. package/dist/server/services/index.mjs.map +1 -0
  685. package/dist/server/services/schema-builder/component-builder.js +114 -0
  686. package/dist/server/services/schema-builder/component-builder.js.map +1 -0
  687. package/dist/server/services/schema-builder/component-builder.mjs +112 -0
  688. package/dist/server/services/schema-builder/component-builder.mjs.map +1 -0
  689. package/dist/server/services/schema-builder/content-type-builder.js +276 -0
  690. package/dist/server/services/schema-builder/content-type-builder.js.map +1 -0
  691. package/dist/server/services/schema-builder/content-type-builder.mjs +274 -0
  692. package/dist/server/services/schema-builder/content-type-builder.mjs.map +1 -0
  693. package/dist/server/services/schema-builder/index.js +145 -0
  694. package/dist/server/services/schema-builder/index.js.map +1 -0
  695. package/dist/server/services/schema-builder/index.mjs +143 -0
  696. package/dist/server/services/schema-builder/index.mjs.map +1 -0
  697. package/dist/server/services/schema-builder/schema-handler.js +250 -0
  698. package/dist/server/services/schema-builder/schema-handler.js.map +1 -0
  699. package/dist/server/services/schema-builder/schema-handler.mjs +248 -0
  700. package/dist/server/services/schema-builder/schema-handler.mjs.map +1 -0
  701. package/dist/server/utils/attributes.js +91 -0
  702. package/dist/server/utils/attributes.js.map +1 -0
  703. package/dist/server/utils/attributes.mjs +85 -0
  704. package/dist/server/utils/attributes.mjs.map +1 -0
  705. package/dist/server/utils/index.js +8 -0
  706. package/dist/server/utils/index.js.map +1 -0
  707. package/dist/server/utils/index.mjs +6 -0
  708. package/dist/server/utils/index.mjs.map +1 -0
  709. package/dist/server/utils/typeguards.js +8 -0
  710. package/dist/server/utils/typeguards.js.map +1 -0
  711. package/dist/server/utils/typeguards.mjs +6 -0
  712. package/dist/server/utils/typeguards.mjs.map +1 -0
  713. package/package.json +5 -5
  714. package/dist/admin/chunks/ListView-Cl-pbcxP.mjs +0 -1184
  715. package/dist/admin/chunks/ListView-Cl-pbcxP.mjs.map +0 -1
  716. package/dist/admin/chunks/ListView-DMZvleUI.js +0 -1186
  717. package/dist/admin/chunks/ListView-DMZvleUI.js.map +0 -1
  718. package/dist/admin/chunks/ar-Df0f0-PT.js.map +0 -1
  719. package/dist/admin/chunks/ar-sRW9VFC-.mjs.map +0 -1
  720. package/dist/admin/chunks/cs-DeTwqc7p.js.map +0 -1
  721. package/dist/admin/chunks/de-BJkS06jF.js.map +0 -1
  722. package/dist/admin/chunks/de-DSxx5_x-.mjs.map +0 -1
  723. package/dist/admin/chunks/dk-BnjVZ7A_.mjs.map +0 -1
  724. package/dist/admin/chunks/en-BJUu34b0.js.map +0 -1
  725. package/dist/admin/chunks/en-Bhut8Yay.mjs.map +0 -1
  726. package/dist/admin/chunks/es-DG8g9igJ.mjs.map +0 -1
  727. package/dist/admin/chunks/es-J8kvHlNy.js.map +0 -1
  728. package/dist/admin/chunks/fr-C6y35iY7.js.map +0 -1
  729. package/dist/admin/chunks/fr-UpV34MHY.mjs.map +0 -1
  730. package/dist/admin/chunks/id-BWM18ljw.mjs.map +0 -1
  731. package/dist/admin/chunks/id-BvxV6wLP.js.map +0 -1
  732. package/dist/admin/chunks/index-BG2mUcnk.js +0 -7788
  733. package/dist/admin/chunks/index-BG2mUcnk.js.map +0 -1
  734. package/dist/admin/chunks/index-DAXXa6S8.mjs +0 -1384
  735. package/dist/admin/chunks/index-DAXXa6S8.mjs.map +0 -1
  736. package/dist/admin/chunks/index-DWAINlnG.js +0 -1421
  737. package/dist/admin/chunks/index-DWAINlnG.js.map +0 -1
  738. package/dist/admin/chunks/index-Knq4Ti8R.mjs +0 -7761
  739. package/dist/admin/chunks/index-Knq4Ti8R.mjs.map +0 -1
  740. package/dist/admin/chunks/it-1_vd9gV4.mjs.map +0 -1
  741. package/dist/admin/chunks/it-C_IgFU-G.js.map +0 -1
  742. package/dist/admin/chunks/ja-CWo4Qqq6.js.map +0 -1
  743. package/dist/admin/chunks/ja-Cx23a2Ui.mjs.map +0 -1
  744. package/dist/admin/chunks/ko-BsByJNEl.js.map +0 -1
  745. package/dist/admin/chunks/ko-DC7paEx5.mjs.map +0 -1
  746. package/dist/admin/chunks/ms-DPTzS7SH.js.map +0 -1
  747. package/dist/admin/chunks/nl-TzvfktV_.mjs.map +0 -1
  748. package/dist/admin/chunks/nl-db29QMOx.js.map +0 -1
  749. package/dist/admin/chunks/pl-BdvupIN_.mjs.map +0 -1
  750. package/dist/admin/chunks/pl-pYy1djj3.js.map +0 -1
  751. package/dist/admin/chunks/pt-BQmWcdeG.js.map +0 -1
  752. package/dist/admin/chunks/pt-BR-CTPuXGWF.js.map +0 -1
  753. package/dist/admin/chunks/pt-BR-DPrVmKeZ.mjs.map +0 -1
  754. package/dist/admin/chunks/pt-BTLIwmCv.mjs.map +0 -1
  755. package/dist/admin/chunks/ru-D46no502.mjs.map +0 -1
  756. package/dist/admin/chunks/ru-DQiDXgUV.js.map +0 -1
  757. package/dist/admin/chunks/sk-Byr_l4Jc.mjs.map +0 -1
  758. package/dist/admin/chunks/sk-DrnebmXb.js.map +0 -1
  759. package/dist/admin/chunks/sv-Bbam7IDm.mjs.map +0 -1
  760. package/dist/admin/chunks/sv-CrWlNosi.js.map +0 -1
  761. package/dist/admin/chunks/th-BbrCkfgX.js.map +0 -1
  762. package/dist/admin/chunks/th-hfS0Wmk_.mjs.map +0 -1
  763. package/dist/admin/chunks/tr-CHdMj8m6.js.map +0 -1
  764. package/dist/admin/chunks/tr-DS7DBOhC.mjs.map +0 -1
  765. package/dist/admin/chunks/uk-CjzmJyt1.mjs.map +0 -1
  766. package/dist/admin/chunks/uk-felSA_eV.js.map +0 -1
  767. package/dist/admin/chunks/zh-BUVXH75-.mjs.map +0 -1
  768. package/dist/admin/chunks/zh-CWj4avQA.js.map +0 -1
  769. package/dist/admin/chunks/zh-Hans-BElOnuRb.mjs.map +0 -1
  770. package/dist/admin/chunks/zh-Hans-lXbNiMp9.js.map +0 -1
@@ -1,2637 +1,9 @@
1
1
  import '@strapi/types';
2
- import _, { get, has } from 'lodash';
3
- import { getOr, snakeCase, isUndefined, has as has$1, flatMap } from 'lodash/fp';
4
- import utils, { errors, strings, contentTypes as contentTypes$2, yup, validateYupSchema } from '@strapi/utils';
5
- import * as path from 'path';
6
- import path__default, { join } from 'path';
7
- import * as fse from 'fs-extra';
8
- import fse__default from 'fs-extra';
9
- import pluralize from 'pluralize';
10
-
11
- var config = {
12
- default: {},
13
- validator () {}
14
- };
15
-
16
- var bootstrap = (async ({ strapi })=>{
17
- const actions = [
18
- {
19
- section: 'plugins',
20
- displayName: 'Read',
21
- uid: 'read',
22
- pluginName: 'content-type-builder'
23
- }
24
- ];
25
- await strapi.service('admin::permission').actionProvider.registerMany(actions);
26
- });
27
-
28
- const { ApplicationError: ApplicationError$3 } = errors;
29
- const isConfigurable = (attribute)=>_.get(attribute, 'configurable', true);
30
- const isRelation = (attribute)=>attribute.type === 'relation';
31
- /**
32
- * Formats a component's attributes
33
- */ const formatAttributes = (model)=>{
34
- const { getVisibleAttributes } = utils.contentTypes;
35
- // only get attributes that can be seen in the CTB
36
- return getVisibleAttributes(model).reduce((acc, key)=>{
37
- acc[key] = formatAttribute(model.attributes[key]);
38
- return acc;
39
- }, {});
40
- };
41
- /**
42
- * Formats a component attribute
43
- */ const formatAttribute = (attribute)=>{
44
- const { configurable, required, autoPopulate, pluginOptions } = attribute;
45
- if (attribute.type === 'media') {
46
- return {
47
- type: 'media',
48
- multiple: !!attribute.multiple,
49
- required: !!required,
50
- configurable: configurable === false ? false : undefined,
51
- private: !!attribute.private,
52
- allowedTypes: attribute.allowedTypes,
53
- pluginOptions
54
- };
55
- }
56
- if (attribute.type === 'relation') {
57
- return {
58
- ...attribute,
59
- type: 'relation',
60
- target: attribute.target,
61
- targetAttribute: attribute.inversedBy || attribute.mappedBy || null,
62
- configurable: configurable === false ? false : undefined,
63
- private: !!attribute.private,
64
- pluginOptions,
65
- // TODO: remove
66
- autoPopulate
67
- };
68
- }
69
- return attribute;
70
- };
71
- // TODO: move to schema builder
72
- const replaceTemporaryUIDs = (uidMap)=>(schema)=>{
73
- return {
74
- ...schema,
75
- attributes: Object.keys(schema.attributes).reduce((acc, key)=>{
76
- const attr = schema.attributes[key];
77
- if (attr.type === 'component') {
78
- if (_.has(uidMap, attr.component)) {
79
- acc[key] = {
80
- ...attr,
81
- component: uidMap[attr.component]
82
- };
83
- return acc;
84
- }
85
- if (!_.has(strapi.components, attr.component)) {
86
- throw new ApplicationError$3('component.notFound');
87
- }
88
- }
89
- if (attr.type === 'dynamiczone' && _.intersection(attr.components, Object.keys(uidMap)).length > 0) {
90
- acc[key] = {
91
- ...attr,
92
- components: attr.components.map((value)=>{
93
- if (_.has(uidMap, value)) return uidMap[value];
94
- if (!_.has(strapi.components, value)) {
95
- throw new ApplicationError$3('component.notFound');
96
- }
97
- return value;
98
- })
99
- };
100
- return acc;
101
- }
102
- acc[key] = attr;
103
- return acc;
104
- }, {})
105
- };
106
- };
107
-
108
- function createSchemaHandler(infos) {
109
- const { category, modelName, plugin, uid, dir, filename, schema } = infos;
110
- const initialState = {
111
- modelName,
112
- plugin,
113
- category,
114
- uid,
115
- dir,
116
- filename,
117
- schema: schema || {
118
- info: {},
119
- options: {},
120
- attributes: {}
121
- }
122
- };
123
- const state = _.cloneDeep(initialState);
124
- // always keep it the same to rollback
125
- Object.freeze(initialState.schema);
126
- let modified = false;
127
- let deleted = false;
128
- return {
129
- get modelName () {
130
- return initialState.modelName;
131
- },
132
- get plugin () {
133
- return initialState.plugin;
134
- },
135
- get category () {
136
- return initialState.category;
137
- },
138
- get kind () {
139
- return _.get(state.schema, 'kind', 'collectionType');
140
- },
141
- get uid () {
142
- return state.uid;
143
- },
144
- get writable () {
145
- return _.get(state, 'plugin') !== 'admin';
146
- },
147
- setUID (val) {
148
- modified = true;
149
- state.uid = val;
150
- return this;
151
- },
152
- setDir (val) {
153
- modified = true;
154
- state.dir = val;
155
- return this;
156
- },
157
- get schema () {
158
- return _.cloneDeep(state.schema);
159
- },
160
- setSchema (val) {
161
- modified = true;
162
- state.schema = _.cloneDeep(val);
163
- return this;
164
- },
165
- // get a particular path inside the schema
166
- get (path) {
167
- return _.get(state.schema, path);
168
- },
169
- // set a particular path inside the schema
170
- set (path, val) {
171
- if (!state.schema) return this;
172
- modified = true;
173
- const value = _.defaultTo(val, _.get(state.schema, path));
174
- _.set(state.schema, path, value);
175
- return this;
176
- },
177
- // delete a particular path inside the schema
178
- unset (path) {
179
- modified = true;
180
- _.unset(state.schema, path);
181
- return this;
182
- },
183
- delete () {
184
- deleted = true;
185
- return this;
186
- },
187
- getAttribute (key) {
188
- return this.get([
189
- 'attributes',
190
- key
191
- ]);
192
- },
193
- setAttribute (key, attribute) {
194
- return this.set([
195
- 'attributes',
196
- key
197
- ], attribute);
198
- },
199
- deleteAttribute (key) {
200
- return this.unset([
201
- 'attributes',
202
- key
203
- ]);
204
- },
205
- setAttributes (newAttributes) {
206
- if (!this.schema) return this;
207
- // delete old configurable attributes
208
- for(const key in this.schema.attributes){
209
- if (isConfigurable(this.schema.attributes[key])) {
210
- this.deleteAttribute(key);
211
- }
212
- }
213
- // set new Attributes
214
- for (const key of Object.keys(newAttributes)){
215
- this.setAttribute(key, newAttributes[key]);
216
- }
217
- return this;
218
- },
219
- removeContentType (uid) {
220
- if (!state.schema) return this;
221
- const attributes = state.schema.attributes;
222
- Object.keys(attributes).forEach((key)=>{
223
- const attribute = attributes[key];
224
- if (attribute.target === uid) {
225
- this.deleteAttribute(key);
226
- }
227
- });
228
- return this;
229
- },
230
- // utils
231
- removeComponent (uid) {
232
- if (!state.schema) return this;
233
- const attributes = state.schema.attributes;
234
- Object.keys(attributes).forEach((key)=>{
235
- const attr = attributes[key];
236
- if (attr.type === 'component' && attr.component === uid) {
237
- this.deleteAttribute(key);
238
- }
239
- if (attr.type === 'dynamiczone' && Array.isArray(attr.components) && attr.components.includes(uid)) {
240
- const updatedComponentList = attributes[key].components.filter((val)=>val !== uid);
241
- this.set([
242
- 'attributes',
243
- key,
244
- 'components'
245
- ], updatedComponentList);
246
- }
247
- });
248
- return this;
249
- },
250
- updateComponent (uid, newUID) {
251
- if (!state.schema) return this;
252
- const attributes = state.schema.attributes;
253
- Object.keys(attributes).forEach((key)=>{
254
- const attr = attributes[key];
255
- if (attr.type === 'component' && attr.component === uid) {
256
- this.set([
257
- 'attributes',
258
- key,
259
- 'component'
260
- ], newUID);
261
- }
262
- if (attr.type === 'dynamiczone' && Array.isArray(attr.components) && attr.components.includes(uid)) {
263
- const updatedComponentList = attr.components.map((val)=>val === uid ? newUID : val);
264
- this.set([
265
- 'attributes',
266
- key,
267
- 'components'
268
- ], updatedComponentList);
269
- }
270
- });
271
- return this;
272
- },
273
- // save the schema to disk
274
- async flush () {
275
- if (!this.writable) {
276
- return;
277
- }
278
- const initialPath = path__default.join(initialState.dir, initialState.filename);
279
- const filePath = path__default.join(state.dir, state.filename);
280
- if (deleted) {
281
- await fse__default.remove(initialPath);
282
- const list = await fse__default.readdir(initialState.dir);
283
- if (list.length === 0) {
284
- await fse__default.remove(initialState.dir);
285
- }
286
- return;
287
- }
288
- if (modified) {
289
- if (!state.schema) return Promise.resolve();
290
- await fse__default.ensureFile(filePath);
291
- await fse__default.writeJSON(filePath, {
292
- kind: state.schema.kind,
293
- collectionName: state.schema.collectionName,
294
- info: state.schema.info,
295
- options: state.schema.options,
296
- pluginOptions: state.schema.pluginOptions,
297
- attributes: state.schema.attributes,
298
- config: state.schema.config
299
- }, {
300
- spaces: 2
301
- });
302
- // remove from oldPath
303
- if (initialPath !== filePath) {
304
- await fse__default.remove(initialPath);
305
- const list = await fse__default.readdir(initialState.dir);
306
- if (list.length === 0) {
307
- await fse__default.remove(initialState.dir);
308
- }
309
- }
310
- return;
311
- }
312
- return Promise.resolve();
313
- },
314
- // reset the schema to its initial value
315
- async rollback () {
316
- if (!this.writable) {
317
- return;
318
- }
319
- const initialPath = path__default.join(initialState.dir, initialState.filename);
320
- const filePath = path__default.join(state.dir, state.filename);
321
- // it was a creation so it needs to be deleted
322
- if (!initialState.uid) {
323
- await fse__default.remove(filePath);
324
- const list = await fse__default.readdir(state.dir);
325
- if (list.length === 0) {
326
- await fse__default.remove(state.dir);
327
- }
328
- return;
329
- }
330
- if (modified || deleted) {
331
- await fse__default.ensureFile(initialPath);
332
- await fse__default.writeJSON(initialPath, initialState.schema, {
333
- spaces: 2
334
- });
335
- // remove
336
- if (initialPath !== filePath) {
337
- await fse__default.remove(filePath);
338
- const list = await fse__default.readdir(state.dir);
339
- if (list.length === 0) {
340
- await fse__default.remove(state.dir);
341
- }
342
- }
343
- }
344
- return Promise.resolve();
345
- }
346
- };
347
- }
348
-
349
- const { ApplicationError: ApplicationError$2 } = errors;
350
- function createComponentBuilder$1() {
351
- return {
352
- createComponentUID ({ category, displayName }) {
353
- return `${strings.nameToSlug(category)}.${strings.nameToSlug(displayName)}`;
354
- },
355
- createNewComponentUIDMap (components) {
356
- return components.reduce((uidMap, component)=>{
357
- uidMap[component.tmpUID] = this.createComponentUID(component);
358
- return uidMap;
359
- }, {});
360
- },
361
- /**
362
- * create a component in the tmpComponent map
363
- */ createComponent (infos) {
364
- const uid = this.createComponentUID(infos);
365
- if (this.components.has(uid)) {
366
- throw new ApplicationError$2('component.alreadyExists');
367
- }
368
- const handler = createSchemaHandler({
369
- dir: path__default.join(strapi.dirs.app.components, strings.nameToSlug(infos.category)),
370
- filename: `${strings.nameToSlug(infos.displayName)}.json`
371
- });
372
- // TODO: create a utility for this
373
- // Duplicate in admin/src/components/FormModal/forms/utils/createCollectionName.ts
374
- const collectionName = `components_${strings.nameToCollectionName(infos.category)}_${strings.nameToCollectionName(pluralize(infos.displayName))}`;
375
- this.components.forEach((compo)=>{
376
- if (compo.schema.collectionName === collectionName) {
377
- throw new ApplicationError$2('component.alreadyExists');
378
- }
379
- });
380
- handler.setUID(uid).set('collectionName', collectionName).set([
381
- 'info',
382
- 'displayName'
383
- ], infos.displayName).set([
384
- 'info',
385
- 'icon'
386
- ], infos.icon).set([
387
- 'info',
388
- 'description'
389
- ], infos.description).set('pluginOptions', infos.pluginOptions).set('config', infos.config).setAttributes(this.convertAttributes(infos.attributes));
390
- if (this.components.size === 0) {
391
- strapi.telemetry.send('didCreateFirstComponent');
392
- } else {
393
- strapi.telemetry.send('didCreateComponent');
394
- }
395
- this.components.set(uid, handler);
396
- return handler;
397
- },
398
- /**
399
- * create a component in the tmpComponent map
400
- */ editComponent (infos) {
401
- const { uid } = infos;
402
- if (!this.components.has(uid)) {
403
- throw new errors.ApplicationError('component.notFound');
404
- }
405
- const component = this.components.get(uid);
406
- const [, nameUID] = uid.split('.');
407
- const newCategory = strings.nameToSlug(infos.category);
408
- const newUID = `${newCategory}.${nameUID}`;
409
- if (newUID !== uid && this.components.has(newUID)) {
410
- throw new errors.ApplicationError('component.edit.alreadyExists');
411
- }
412
- const newDir = path__default.join(strapi.dirs.app.components, newCategory);
413
- const oldAttributes = component.schema.attributes;
414
- const newAttributes = _.omitBy(infos.attributes, (attr, key)=>{
415
- return _.has(oldAttributes, key) && !isConfigurable(oldAttributes[key]);
416
- });
417
- component.setUID(newUID).setDir(newDir).set([
418
- 'info',
419
- 'displayName'
420
- ], infos.displayName).set([
421
- 'info',
422
- 'icon'
423
- ], infos.icon).set([
424
- 'info',
425
- 'description'
426
- ], infos.description).set('pluginOptions', infos.pluginOptions).setAttributes(this.convertAttributes(newAttributes));
427
- if (newUID !== uid) {
428
- this.components.forEach((compo)=>{
429
- compo.updateComponent(uid, newUID);
430
- });
431
- this.contentTypes.forEach((ct)=>{
432
- ct.updateComponent(uid, newUID);
433
- });
434
- }
435
- return component;
436
- },
437
- deleteComponent (uid) {
438
- if (!this.components.has(uid)) {
439
- throw new errors.ApplicationError('component.notFound');
440
- }
441
- this.components.forEach((compo)=>{
442
- compo.removeComponent(uid);
443
- });
444
- this.contentTypes.forEach((ct)=>{
445
- ct.removeComponent(uid);
446
- });
447
- return this.components.get(uid).delete();
448
- }
449
- };
450
- }
451
-
452
- const modelTypes = {
453
- CONTENT_TYPE: 'CONTENT_TYPE',
454
- COMPONENT: 'COMPONENT'
455
- };
456
- const typeKinds = {
457
- SINGLE_TYPE: 'singleType',
458
- COLLECTION_TYPE: 'collectionType'
459
- };
460
- const DEFAULT_TYPES = [
461
- // advanced types
462
- 'media',
463
- // scalar types
464
- 'string',
465
- 'text',
466
- 'richtext',
467
- 'blocks',
468
- 'json',
469
- 'enumeration',
470
- 'password',
471
- 'email',
472
- 'integer',
473
- 'biginteger',
474
- 'float',
475
- 'decimal',
476
- 'date',
477
- 'time',
478
- 'datetime',
479
- 'timestamp',
480
- 'boolean',
481
- 'relation'
482
- ];
483
- const VALID_UID_TARGETS = [
484
- 'string',
485
- 'text'
486
- ];
487
- const coreUids = {
488
- STRAPI_USER: 'admin::user',
489
- PREFIX: 'strapi::'
490
- };
491
- const pluginsUids = {
492
- UPLOAD_FILE: 'plugin::upload.file'
493
- };
494
-
495
- const { ApplicationError: ApplicationError$1 } = errors;
496
- const reuseUnsetPreviousProperties = (newAttribute, oldAttribute)=>{
497
- _.defaults(newAttribute, _.omit(oldAttribute, [
498
- 'configurable',
499
- 'required',
500
- 'private',
501
- 'unique',
502
- 'pluginOptions',
503
- 'inversedBy',
504
- 'mappedBy'
505
- ]));
506
- };
507
- function createComponentBuilder() {
508
- return {
509
- setRelation ({ key, uid, attribute }) {
510
- if (!_.has(attribute, 'target')) {
511
- return;
512
- }
513
- const targetCT = this.contentTypes.get(attribute.target);
514
- const targetAttribute = targetCT.getAttribute(attribute.targetAttribute);
515
- if (!attribute.targetAttribute) {
516
- return;
517
- }
518
- targetCT.setAttribute(attribute.targetAttribute, generateRelation({
519
- key,
520
- attribute,
521
- uid,
522
- targetAttribute
523
- }));
524
- },
525
- unsetRelation (attribute) {
526
- if (!_.has(attribute, 'target')) {
527
- return;
528
- }
529
- const targetCT = this.contentTypes.get(attribute.target);
530
- const targetAttributeName = attribute.inversedBy || attribute.mappedBy;
531
- const targetAttribute = targetCT.getAttribute(targetAttributeName);
532
- if (!targetAttribute) return;
533
- return targetCT.deleteAttribute(targetAttributeName);
534
- },
535
- /**
536
- * Creates a content type in memory to be written to files later on
537
- */ createContentType (infos) {
538
- const uid = createContentTypeUID(infos);
539
- if (this.contentTypes.has(uid)) {
540
- throw new ApplicationError$1('contentType.alreadyExists');
541
- }
542
- const contentType = createSchemaHandler({
543
- modelName: infos.singularName,
544
- dir: path__default.join(strapi.dirs.app.api, infos.singularName, 'content-types', infos.singularName),
545
- filename: `schema.json`
546
- });
547
- this.contentTypes.set(uid, contentType);
548
- // support self referencing content type relation
549
- Object.keys(infos.attributes).forEach((key)=>{
550
- const { target } = infos.attributes[key];
551
- if (target === '__self__') {
552
- infos.attributes[key].target = uid;
553
- }
554
- });
555
- contentType.setUID(uid).set('kind', infos.kind || typeKinds.COLLECTION_TYPE).set('collectionName', infos.collectionName || strings.nameToCollectionName(infos.pluralName)).set('info', {
556
- singularName: infos.singularName,
557
- pluralName: infos.pluralName,
558
- displayName: infos.displayName,
559
- description: infos.description
560
- }).set('options', {
561
- ...infos.options ?? {},
562
- draftAndPublish: infos.draftAndPublish
563
- }).set('pluginOptions', infos.pluginOptions).set('config', infos.config).setAttributes(this.convertAttributes(infos.attributes));
564
- Object.keys(infos.attributes).forEach((key)=>{
565
- const attribute = infos.attributes[key];
566
- if (isRelation(attribute)) {
567
- if ([
568
- 'manyToMany',
569
- 'oneToOne'
570
- ].includes(attribute.relation)) {
571
- if (attribute.target === uid && attribute.targetAttribute !== undefined) {
572
- // self referencing relation
573
- const targetAttribute = infos.attributes[attribute.targetAttribute];
574
- if (targetAttribute.dominant === undefined) {
575
- attribute.dominant = true;
576
- } else {
577
- attribute.dominant = false;
578
- }
579
- } else {
580
- attribute.dominant = true;
581
- }
582
- }
583
- this.setRelation({
584
- key,
585
- uid,
586
- attribute
587
- });
588
- }
589
- });
590
- return contentType;
591
- },
592
- editContentType (infos) {
593
- const { uid } = infos;
594
- if (!this.contentTypes.has(uid)) {
595
- throw new ApplicationError$1('contentType.notFound');
596
- }
597
- const contentType = this.contentTypes.get(uid);
598
- const oldAttributes = contentType.schema.attributes;
599
- const newAttributes = _.omitBy(infos.attributes, (attr, key)=>{
600
- return _.has(oldAttributes, key) && !isConfigurable(oldAttributes[key]);
601
- });
602
- const newKeys = _.difference(Object.keys(newAttributes), Object.keys(oldAttributes));
603
- const deletedKeys = _.difference(Object.keys(oldAttributes), Object.keys(newAttributes));
604
- const remainingKeys = _.intersection(Object.keys(oldAttributes), Object.keys(newAttributes));
605
- // remove old relations
606
- deletedKeys.forEach((key)=>{
607
- const attribute = oldAttributes[key];
608
- const targetAttributeName = attribute.inversedBy || attribute.mappedBy;
609
- // if the old relation has a target attribute. we need to remove it in the target type
610
- if (isConfigurable(attribute) && isRelation(attribute) && !_.isNil(targetAttributeName)) {
611
- this.unsetRelation(attribute);
612
- }
613
- });
614
- remainingKeys.forEach((key)=>{
615
- const oldAttribute = oldAttributes[key];
616
- const newAttribute = newAttributes[key];
617
- if (!isRelation(oldAttribute) && isRelation(newAttribute)) {
618
- return this.setRelation({
619
- key,
620
- uid,
621
- attribute: newAttributes[key]
622
- });
623
- }
624
- if (isRelation(oldAttribute) && !isRelation(newAttribute)) {
625
- return this.unsetRelation(oldAttribute);
626
- }
627
- if (isRelation(oldAttribute) && isRelation(newAttribute)) {
628
- const oldTargetAttributeName = oldAttribute.inversedBy || oldAttribute.mappedBy;
629
- const sameRelation = oldAttribute.relation === newAttribute.relation;
630
- const targetAttributeHasChanged = oldTargetAttributeName !== newAttribute.targetAttribute;
631
- if (!sameRelation || targetAttributeHasChanged) {
632
- this.unsetRelation(oldAttribute);
633
- }
634
- // keep extra options that were set manually on oldAttribute
635
- reuseUnsetPreviousProperties(newAttribute, oldAttribute);
636
- if (oldAttribute.inversedBy) {
637
- newAttribute.dominant = true;
638
- } else if (oldAttribute.mappedBy) {
639
- newAttribute.dominant = false;
640
- }
641
- return this.setRelation({
642
- key,
643
- uid,
644
- attribute: newAttribute
645
- });
646
- }
647
- });
648
- // add new relations
649
- newKeys.forEach((key)=>{
650
- const attribute = newAttributes[key];
651
- if (isRelation(attribute)) {
652
- if ([
653
- 'manyToMany',
654
- 'oneToOne'
655
- ].includes(attribute.relation)) {
656
- if (attribute.target === uid && attribute.targetAttribute !== undefined) {
657
- // self referencing relation
658
- const targetAttribute = newAttributes[attribute.targetAttribute];
659
- if (targetAttribute.dominant === undefined) {
660
- attribute.dominant = true;
661
- } else {
662
- attribute.dominant = false;
663
- }
664
- } else {
665
- attribute.dominant = true;
666
- }
667
- }
668
- this.setRelation({
669
- key,
670
- uid,
671
- attribute
672
- });
673
- }
674
- });
675
- contentType.set('kind', infos.kind || contentType.schema.kind).set([
676
- 'info',
677
- 'displayName'
678
- ], infos.displayName).set([
679
- 'info',
680
- 'description'
681
- ], infos.description).set('options', {
682
- ...infos.options ?? {},
683
- draftAndPublish: infos.draftAndPublish
684
- }).set('pluginOptions', infos.pluginOptions).setAttributes(this.convertAttributes(newAttributes));
685
- return contentType;
686
- },
687
- deleteContentType (uid) {
688
- if (!this.contentTypes.has(uid)) {
689
- throw new ApplicationError$1('contentType.notFound');
690
- }
691
- this.components.forEach((compo)=>{
692
- compo.removeContentType(uid);
693
- });
694
- this.contentTypes.forEach((ct)=>{
695
- ct.removeContentType(uid);
696
- });
697
- return this.contentTypes.get(uid).delete();
698
- }
699
- };
700
- }
701
- /**
702
- * Returns a uid from a content type infos
703
- *
704
- * @param {object} options options
705
- * @param {string} options.singularName content-type singularName
706
- * @returns {string} uid
707
- */ const createContentTypeUID = ({ singularName })=>`api::${singularName}.${singularName}`;
708
- const generateRelation = ({ key, attribute, uid, targetAttribute = {} })=>{
709
- const opts = {
710
- type: 'relation',
711
- target: uid,
712
- autoPopulate: targetAttribute.autoPopulate,
713
- private: targetAttribute.private || undefined,
714
- pluginOptions: targetAttribute.pluginOptions || undefined
715
- };
716
- switch(attribute.relation){
717
- case 'oneToOne':
718
- {
719
- opts.relation = 'oneToOne';
720
- if (attribute.dominant) {
721
- opts.mappedBy = key;
722
- } else {
723
- opts.inversedBy = key;
724
- }
725
- break;
726
- }
727
- case 'oneToMany':
728
- {
729
- opts.relation = 'manyToOne';
730
- opts.inversedBy = key;
731
- break;
732
- }
733
- case 'manyToOne':
734
- {
735
- opts.relation = 'oneToMany';
736
- opts.mappedBy = key;
737
- break;
738
- }
739
- case 'manyToMany':
740
- {
741
- opts.relation = 'manyToMany';
742
- if (attribute.dominant) {
743
- opts.mappedBy = key;
744
- } else {
745
- opts.inversedBy = key;
746
- }
747
- break;
748
- }
749
- }
750
- // we do this just to make sure we have the same key order when writing to files
751
- const { type, relation, target, ...restOptions } = opts;
752
- return {
753
- type,
754
- relation,
755
- target,
756
- ...restOptions
757
- };
758
- };
759
-
760
- /**
761
- * Creates a content type schema builder instance
762
- */ function createBuilder() {
763
- const components = Object.values(strapi.components).map((componentInput)=>({
764
- category: componentInput.category,
765
- modelName: componentInput.modelName,
766
- plugin: componentInput.modelName,
767
- uid: componentInput.uid,
768
- filename: componentInput.__filename__,
769
- dir: join(strapi.dirs.app.components, componentInput.category),
770
- schema: componentInput.__schema__,
771
- config: componentInput.config
772
- }));
773
- const contentTypes = Object.values(strapi.contentTypes).map((contentTypeInput)=>{
774
- const dir = contentTypeInput.plugin ? join(strapi.dirs.app.extensions, contentTypeInput.plugin, 'content-types', contentTypeInput.info.singularName) : join(strapi.dirs.app.api, contentTypeInput.apiName, 'content-types', contentTypeInput.info.singularName);
775
- return {
776
- modelName: contentTypeInput.modelName,
777
- plugin: contentTypeInput.plugin,
778
- uid: contentTypeInput.uid,
779
- filename: 'schema.json',
780
- dir,
781
- schema: contentTypeInput.__schema__,
782
- config: contentTypeInput.config
783
- };
784
- });
785
- return createSchemaBuilder({
786
- components,
787
- contentTypes
788
- });
789
- }
790
- function createSchemaBuilder({ components, contentTypes }) {
791
- const tmpComponents = new Map();
792
- const tmpContentTypes = new Map();
793
- // init temporary ContentTypes
794
- Object.keys(contentTypes).forEach((key)=>{
795
- tmpContentTypes.set(contentTypes[key].uid, createSchemaHandler(contentTypes[key]));
796
- });
797
- // init temporary components
798
- Object.keys(components).forEach((key)=>{
799
- tmpComponents.set(components[key].uid, createSchemaHandler(components[key]));
800
- });
801
- return {
802
- get components () {
803
- return tmpComponents;
804
- },
805
- get contentTypes () {
806
- return tmpContentTypes;
807
- },
808
- /**
809
- * Convert Attributes received from the API to the right syntax
810
- */ convertAttributes (attributes) {
811
- return Object.keys(attributes).reduce((acc, key)=>{
812
- const attribute = attributes[key];
813
- const { configurable, private: isPrivate } = attribute;
814
- const baseProperties = {
815
- private: isPrivate === true ? true : undefined,
816
- configurable: configurable === false ? false : undefined
817
- };
818
- if (attribute.type === 'relation') {
819
- const { target, relation, targetAttribute, dominant, ...restOfProperties } = attribute;
820
- const attr = {
821
- type: 'relation',
822
- relation,
823
- target,
824
- ...restOfProperties,
825
- ...baseProperties
826
- };
827
- acc[key] = attr;
828
- if (target && !this.contentTypes.has(target)) {
829
- throw new errors.ApplicationError(`target: ${target} does not exist`);
830
- }
831
- if (_.isNil(targetAttribute)) {
832
- return acc;
833
- }
834
- if ([
835
- 'oneToOne',
836
- 'manyToMany'
837
- ].includes(relation) && dominant === true) {
838
- attr.inversedBy = targetAttribute;
839
- } else if ([
840
- 'oneToOne',
841
- 'manyToMany'
842
- ].includes(relation) && dominant === false) {
843
- attr.mappedBy = targetAttribute;
844
- } else if ([
845
- 'oneToOne',
846
- 'manyToOne',
847
- 'manyToMany'
848
- ].includes(relation)) {
849
- attr.inversedBy = targetAttribute;
850
- } else if ([
851
- 'oneToMany'
852
- ].includes(relation)) {
853
- attr.mappedBy = targetAttribute;
854
- }
855
- return acc;
856
- }
857
- acc[key] = {
858
- ...attribute,
859
- ...baseProperties
860
- };
861
- return acc;
862
- }, {});
863
- },
864
- ...createComponentBuilder$1(),
865
- ...createComponentBuilder(),
866
- /**
867
- * Write all type to files
868
- */ writeFiles () {
869
- const schemas = [
870
- ...Array.from(tmpComponents.values()),
871
- ...Array.from(tmpContentTypes.values())
872
- ];
873
- return Promise.all(schemas.map((schema)=>schema.flush())).catch((error)=>{
874
- strapi.log.error('Error writing schema files');
875
- strapi.log.error(error);
876
- return this.rollback();
877
- }).catch((error)=>{
878
- strapi.log.error('Error rolling back schema files. You might need to fix your files manually');
879
- strapi.log.error(error);
880
- throw new errors.ApplicationError('Invalid schema edition');
881
- });
882
- },
883
- /**
884
- * rollback all files
885
- */ rollback () {
886
- return Promise.all([
887
- ...Array.from(tmpComponents.values()),
888
- ...Array.from(tmpContentTypes.values())
889
- ].map((schema)=>schema.rollback()));
890
- }
891
- };
892
- }
893
-
894
- const { ApplicationError } = errors;
895
- const isContentTypeVisible = (model)=>getOr(true, 'pluginOptions.content-type-builder.visible', model) === true;
896
- const getRestrictRelationsTo = (contentType)=>{
897
- const { uid } = contentType;
898
- if (uid === coreUids.STRAPI_USER) {
899
- // TODO: replace with an obj { relation: 'x', bidirectional: true|false }
900
- return [
901
- 'oneWay',
902
- 'manyWay'
903
- ];
904
- }
905
- if (uid.startsWith(coreUids.PREFIX) || uid === pluginsUids.UPLOAD_FILE || !isContentTypeVisible(contentType)) {
906
- return [];
907
- }
908
- return null;
909
- };
910
- /**
911
- * Format a contentType info to be used by the front-end
912
- */ const formatContentType = (contentType)=>{
913
- const { uid, kind, modelName, plugin, collectionName, info } = contentType;
914
- return {
915
- uid,
916
- plugin,
917
- apiID: modelName,
918
- schema: {
919
- ...contentTypes$2.getOptions(contentType),
920
- displayName: info.displayName,
921
- singularName: info.singularName,
922
- pluralName: info.pluralName,
923
- description: _.get(info, 'description', ''),
924
- pluginOptions: contentType.pluginOptions,
925
- kind: kind || 'collectionType',
926
- collectionName,
927
- attributes: formatAttributes(contentType),
928
- visible: isContentTypeVisible(contentType),
929
- restrictRelationsTo: getRestrictRelationsTo(contentType)
930
- }
931
- };
932
- };
933
- const createContentTypes = async (contentTypes)=>{
934
- const builder = createBuilder();
935
- const createdContentTypes = [];
936
- for (const contentType of contentTypes){
937
- createdContentTypes.push(await createContentType(contentType, {
938
- defaultBuilder: builder
939
- }));
940
- }
941
- await builder.writeFiles();
942
- return createdContentTypes;
943
- };
944
- /**
945
- * Creates a content type and handle the nested components sent with it
946
- */ const createContentType = async ({ contentType, components }, options = {})=>{
947
- const builder = options.defaultBuilder || createBuilder();
948
- const uidMap = builder.createNewComponentUIDMap(components || []);
949
- const replaceTmpUIDs = replaceTemporaryUIDs(uidMap);
950
- const newContentType = builder.createContentType(replaceTmpUIDs(contentType));
951
- // allow components to target the new contentType
952
- const targetContentType = (infos)=>{
953
- Object.keys(infos.attributes).forEach((key)=>{
954
- const { target } = infos.attributes[key];
955
- if (target === '__contentType__') {
956
- infos.attributes[key].target = newContentType.uid;
957
- }
958
- });
959
- return infos;
960
- };
961
- components?.forEach((component)=>{
962
- const options = replaceTmpUIDs(targetContentType(component));
963
- if (!_.has(component, 'uid')) {
964
- return builder.createComponent(options);
965
- }
966
- return builder.editComponent(options);
967
- });
968
- // generate api skeleton
969
- await generateAPI({
970
- displayName: contentType.displayName || contentType.info.displayName,
971
- singularName: contentType.singularName,
972
- pluralName: contentType.pluralName,
973
- kind: contentType.kind
974
- });
975
- if (!options.defaultBuilder) {
976
- await builder.writeFiles();
977
- }
978
- strapi.eventHub.emit('content-type.create', {
979
- contentType: newContentType
980
- });
981
- return newContentType;
982
- };
983
- /**
984
- * Generate an API skeleton
985
- */ const generateAPI = ({ singularName, kind = 'collectionType', pluralName, displayName })=>{
986
- // eslint-disable-next-line @typescript-eslint/no-var-requires
987
- const strapiGenerators = require('@strapi/generators');
988
- return strapiGenerators.generate('content-type', {
989
- kind,
990
- singularName,
991
- id: singularName,
992
- pluralName,
993
- displayName,
994
- destination: 'new',
995
- bootstrapApi: true,
996
- attributes: []
997
- }, {
998
- dir: strapi.dirs.app.root
999
- });
1000
- };
1001
- /**
1002
- * Edits a contentType and handle the nested contentTypes sent with it
1003
- */ const editContentType = async (uid, { contentType, components = [] })=>{
1004
- const builder = createBuilder();
1005
- const previousSchema = builder.contentTypes.get(uid).schema;
1006
- const previousKind = previousSchema.kind;
1007
- const newKind = contentType.kind || previousKind;
1008
- // Restore non-visible attributes from previous schema
1009
- const previousAttributes = previousSchema.attributes;
1010
- const prevNonVisibleAttributes = contentTypes$2.getNonVisibleAttributes(previousSchema).reduce((acc, key)=>{
1011
- if (key in previousAttributes) {
1012
- acc[key] = previousAttributes[key];
1013
- }
1014
- return acc;
1015
- }, {});
1016
- contentType.attributes = _.merge(prevNonVisibleAttributes, contentType.attributes);
1017
- if (newKind !== previousKind && newKind === 'singleType') {
1018
- const entryCount = await strapi.db.query(uid).count();
1019
- if (entryCount > 1) {
1020
- throw new ApplicationError('You cannot convert a collectionType to a singleType when having multiple entries in DB');
1021
- }
1022
- }
1023
- const uidMap = builder.createNewComponentUIDMap(components);
1024
- const replaceTmpUIDs = replaceTemporaryUIDs(uidMap);
1025
- const updatedContentType = builder.editContentType({
1026
- uid,
1027
- ...replaceTmpUIDs(contentType)
1028
- });
1029
- components.forEach((component)=>{
1030
- if (!_.has(component, 'uid')) {
1031
- return builder.createComponent(replaceTmpUIDs(component));
1032
- }
1033
- return builder.editComponent(replaceTmpUIDs(component));
1034
- });
1035
- if (newKind !== previousKind) {
1036
- const apiHandler = strapi.plugin('content-type-builder').service('api-handler');
1037
- await apiHandler.backup(uid);
1038
- try {
1039
- await apiHandler.clear(uid);
1040
- // generate new api skeleton
1041
- await generateAPI({
1042
- displayName: updatedContentType.schema.info.displayName,
1043
- singularName: updatedContentType.schema.info.singularName,
1044
- pluralName: updatedContentType.schema.info.pluralName,
1045
- kind: updatedContentType.schema.kind
1046
- });
1047
- await builder.writeFiles();
1048
- } catch (error) {
1049
- strapi.log.error(error);
1050
- await apiHandler.rollback(uid);
1051
- }
1052
- return updatedContentType;
1053
- }
1054
- await builder.writeFiles();
1055
- strapi.eventHub.emit('content-type.update', {
1056
- contentType: updatedContentType
1057
- });
1058
- return updatedContentType;
1059
- };
1060
- const deleteContentTypes = async (uids)=>{
1061
- const builder = createBuilder();
1062
- const apiHandler = strapi.plugin('content-type-builder').service('api-handler');
1063
- for (const uid of uids){
1064
- await deleteContentType(uid, builder);
1065
- }
1066
- await builder.writeFiles();
1067
- for (const uid of uids){
1068
- try {
1069
- await apiHandler.clear(uid);
1070
- } catch (error) {
1071
- strapi.log.error(error);
1072
- await apiHandler.rollback(uid);
1073
- }
1074
- }
1075
- };
1076
- /**
1077
- * Deletes a content type and the api files related to it
1078
- */ const deleteContentType = async (uid, defaultBuilder = undefined)=>{
1079
- const builder = defaultBuilder || createBuilder();
1080
- // make a backup
1081
- const apiHandler = strapi.plugin('content-type-builder').service('api-handler');
1082
- await apiHandler.backup(uid);
1083
- const contentType = builder.deleteContentType(uid);
1084
- if (!defaultBuilder) {
1085
- try {
1086
- await builder.writeFiles();
1087
- await apiHandler.clear(uid);
1088
- } catch (error) {
1089
- await apiHandler.rollback(uid);
1090
- }
1091
- }
1092
- strapi.eventHub.emit('content-type.delete', {
1093
- contentType
1094
- });
1095
- return contentType;
1096
- };
1097
-
1098
- var contentTypes$1 = /*#__PURE__*/Object.freeze({
1099
- __proto__: null,
1100
- createContentType: createContentType,
1101
- createContentTypes: createContentTypes,
1102
- deleteContentType: deleteContentType,
1103
- deleteContentTypes: deleteContentTypes,
1104
- editContentType: editContentType,
1105
- formatContentType: formatContentType,
1106
- generateAPI: generateAPI,
1107
- getRestrictRelationsTo: getRestrictRelationsTo,
1108
- isContentTypeVisible: isContentTypeVisible
1109
- });
1110
-
1111
- /**
1112
- * Formats a component attributes
1113
- */ const formatComponent = (component)=>{
1114
- const { uid, modelName, connection, collectionName, info, category } = component;
1115
- return {
1116
- uid,
1117
- category,
1118
- apiId: modelName,
1119
- schema: {
1120
- displayName: get(info, 'displayName'),
1121
- description: get(info, 'description', ''),
1122
- icon: get(info, 'icon'),
1123
- connection,
1124
- collectionName,
1125
- pluginOptions: component.pluginOptions,
1126
- attributes: formatAttributes(component)
1127
- }
1128
- };
1129
- };
1130
- /**
1131
- * Creates a component and handle the nested components sent with it
1132
- */ const createComponent = async ({ component, components = [] })=>{
1133
- const builder = createBuilder();
1134
- const uidMap = builder.createNewComponentUIDMap(components);
1135
- const replaceTmpUIDs = replaceTemporaryUIDs(uidMap);
1136
- const newComponent = builder.createComponent(replaceTmpUIDs(component));
1137
- components.forEach((component)=>{
1138
- if (!has(component, 'uid')) {
1139
- return builder.createComponent(replaceTmpUIDs(component));
1140
- }
1141
- return builder.editComponent(replaceTmpUIDs(component));
1142
- });
1143
- await builder.writeFiles();
1144
- strapi.eventHub.emit('component.create', {
1145
- component: newComponent
1146
- });
1147
- return newComponent;
1148
- };
1149
- const editComponent = async (uid, { component, components = [] })=>{
1150
- const builder = createBuilder();
1151
- const uidMap = builder.createNewComponentUIDMap(components);
1152
- const replaceTmpUIDs = replaceTemporaryUIDs(uidMap);
1153
- const updatedComponent = builder.editComponent({
1154
- uid,
1155
- ...replaceTmpUIDs(component)
1156
- });
1157
- components.forEach((component)=>{
1158
- if (!has(component, 'uid')) {
1159
- return builder.createComponent(replaceTmpUIDs(component));
1160
- }
1161
- return builder.editComponent(replaceTmpUIDs(component));
1162
- });
1163
- await builder.writeFiles();
1164
- strapi.eventHub.emit('component.update', {
1165
- component: updatedComponent
1166
- });
1167
- return updatedComponent;
1168
- };
1169
- const deleteComponent = async (uid)=>{
1170
- const builder = createBuilder();
1171
- const deletedComponent = builder.deleteComponent(uid);
1172
- await builder.writeFiles();
1173
- strapi.eventHub.emit('component.delete', {
1174
- component: deletedComponent
1175
- });
1176
- return deletedComponent;
1177
- };
1178
-
1179
- var components$1 = /*#__PURE__*/Object.freeze({
1180
- __proto__: null,
1181
- createComponent: createComponent,
1182
- deleteComponent: deleteComponent,
1183
- editComponent: editComponent,
1184
- formatComponent: formatComponent
1185
- });
1186
-
1187
- /**
1188
- * Edit a category name and move components to the write folder
1189
- */ const editCategory = async (name, infos)=>{
1190
- const newName = strings.nameToSlug(infos.name);
1191
- // don't do anything the name doesn't change
1192
- if (name === newName) return;
1193
- if (!categoryExists(name)) {
1194
- throw new errors.ApplicationError('category not found');
1195
- }
1196
- if (categoryExists(newName)) {
1197
- throw new errors.ApplicationError('Name already taken');
1198
- }
1199
- const builder = createBuilder();
1200
- builder.components.forEach((component)=>{
1201
- const oldUID = component.uid;
1202
- const newUID = `${newName}.${component.modelName}`;
1203
- // only edit the components in this specific category
1204
- if (component.category !== name) return;
1205
- component.setUID(newUID).setDir(join(strapi.dirs.app.components, newName));
1206
- builder.components.forEach((compo)=>{
1207
- compo.updateComponent(oldUID, newUID);
1208
- });
1209
- builder.contentTypes.forEach((ct)=>{
1210
- ct.updateComponent(oldUID, newUID);
1211
- });
1212
- });
1213
- await builder.writeFiles();
1214
- return newName;
1215
- };
1216
- /**
1217
- * Deletes a category and its components
1218
- */ const deleteCategory = async (name)=>{
1219
- if (!categoryExists(name)) {
1220
- throw new errors.ApplicationError('category not found');
1221
- }
1222
- const builder = createBuilder();
1223
- builder.components.forEach((component)=>{
1224
- if (component.category === name) {
1225
- builder.deleteComponent(component.uid);
1226
- }
1227
- });
1228
- await builder.writeFiles();
1229
- };
1230
- /**
1231
- * Checks if a category exists
1232
- */ const categoryExists = (name)=>{
1233
- const matchingIndex = Object.values(strapi.components).findIndex((component)=>component.category === name);
1234
- return matchingIndex > -1;
1235
- };
1236
-
1237
- var componentCategories$1 = /*#__PURE__*/Object.freeze({
1238
- __proto__: null,
1239
- deleteCategory: deleteCategory,
1240
- editCategory: editCategory
1241
- });
1242
-
1243
- // use snake_case
1244
- const reservedAttributes = [
1245
- // TODO: these need to come from a centralized place so we don't break things accidentally in the future and can share them outside the CTB, for example on Strapi bootstrap prior to schema db sync
1246
- // ID fields
1247
- 'id',
1248
- 'document_id',
1249
- // Creator fields
1250
- 'created_at',
1251
- 'updated_at',
1252
- 'published_at',
1253
- 'created_by_id',
1254
- 'updated_by_id',
1255
- // does not actually conflict because the fields are called *_by_id but we'll leave it to avoid confusion
1256
- 'created_by',
1257
- 'updated_by',
1258
- // Used for Strapi functionality
1259
- 'entry_id',
1260
- 'status',
1261
- 'localizations',
1262
- 'meta',
1263
- 'locale',
1264
- '__component',
1265
- '__contentType',
1266
- // We support ending with * to denote prefixes
1267
- 'strapi*',
1268
- '_strapi*',
1269
- '__strapi*'
1270
- ];
1271
- // use snake_case
1272
- const reservedModels = [
1273
- 'boolean',
1274
- 'date',
1275
- 'date_time',
1276
- 'time',
1277
- 'upload',
1278
- 'document',
1279
- 'then',
1280
- // We support ending with * to denote prefixes
1281
- 'strapi*',
1282
- '_strapi*',
1283
- '__strapi*'
1284
- ];
1285
- const getReservedNames = ()=>{
1286
- return {
1287
- models: reservedModels,
1288
- attributes: reservedAttributes
1289
- };
1290
- };
1291
- // compare snake case to check the actual column names that will be used in the database
1292
- const isReservedModelName = (name)=>{
1293
- const snakeCaseName = snakeCase(name);
1294
- if (reservedModels.includes(snakeCaseName)) {
1295
- return true;
1296
- }
1297
- if (reservedModels.filter((key)=>key.endsWith('*')).map((key)=>key.slice(0, -1)).some((prefix)=>snakeCaseName.startsWith(prefix))) {
1298
- return true;
1299
- }
1300
- return false;
1301
- };
1302
- // compare snake case to check the actual column names that will be used in the database
1303
- const isReservedAttributeName = (name)=>{
1304
- const snakeCaseName = snakeCase(name);
1305
- if (reservedAttributes.includes(snakeCaseName)) {
1306
- return true;
1307
- }
1308
- if (reservedAttributes.filter((key)=>key.endsWith('*')).map((key)=>key.slice(0, -1)).some((prefix)=>snakeCaseName.startsWith(prefix))) {
1309
- return true;
1310
- }
1311
- return false;
1312
- };
1313
-
1314
- var builder$1 = /*#__PURE__*/Object.freeze({
1315
- __proto__: null,
1316
- getReservedNames: getReservedNames,
1317
- isReservedAttributeName: isReservedAttributeName,
1318
- isReservedModelName: isReservedModelName,
1319
- reservedAttributes: reservedAttributes,
1320
- reservedModels: reservedModels
1321
- });
1322
-
1323
- /**
1324
- * Deletes the API folder of a contentType
1325
- */ async function clear(uid) {
1326
- // TODO double check if this is the correct way to get the apiName
1327
- const { apiName, modelName } = strapi.contentTypes[uid];
1328
- const apiFolder = path.join(strapi.dirs.app.api, apiName);
1329
- await recursiveRemoveFiles(apiFolder, createDeleteApiFunction(modelName));
1330
- await deleteBackup(uid);
1331
- }
1332
- /**
1333
- * Backups the API folder of a contentType
1334
- * @param {string} uid content type uid
1335
- */ async function backup(uid) {
1336
- const { apiName } = strapi.contentTypes[uid];
1337
- const apiFolder = path.join(strapi.dirs.app.api, apiName);
1338
- const backupFolder = path.join(strapi.dirs.app.api, '.backup', apiName);
1339
- // backup the api folder
1340
- await fse.copy(apiFolder, backupFolder);
1341
- }
1342
- /**
1343
- * Deletes an API backup folder
1344
- */ async function deleteBackup(uid) {
1345
- const { apiName } = strapi.contentTypes[uid];
1346
- const backupFolder = path.join(strapi.dirs.app.api, '.backup');
1347
- const apiBackupFolder = path.join(strapi.dirs.app.api, '.backup', apiName);
1348
- await fse.remove(apiBackupFolder);
1349
- const list = await fse.readdir(backupFolder);
1350
- if (list.length === 0) {
1351
- await fse.remove(backupFolder);
1352
- }
1353
- }
1354
- /**
1355
- * Rollbacks the API folder of a contentType
1356
- */ async function rollback(uid) {
1357
- const { apiName } = strapi.contentTypes[uid];
1358
- const apiFolder = path.join(strapi.dirs.app.api, apiName);
1359
- const backupFolder = path.join(strapi.dirs.app.api, '.backup', apiName);
1360
- try {
1361
- await fse.access(backupFolder);
1362
- } catch {
1363
- throw new Error('Cannot rollback api that was not backed up');
1364
- }
1365
- await fse.remove(apiFolder);
1366
- await fse.copy(backupFolder, apiFolder);
1367
- await deleteBackup(uid);
1368
- }
1369
- /**
1370
- * Creates a delete function to clear an api folder
1371
- */ const createDeleteApiFunction = (baseName)=>{
1372
- /**
1373
- * Delets a file in an api.
1374
- * Will only update routes.json instead of deleting it if other routes are present
1375
- */ return async (filePath)=>{
1376
- const fileName = path.basename(filePath, path.extname(filePath));
1377
- const isSchemaFile = filePath.endsWith(`${baseName}/schema.json`);
1378
- if (fileName === baseName || isSchemaFile) {
1379
- return fse.remove(filePath);
1380
- }
1381
- };
1382
- };
1383
- /**
1384
- * Deletes a folder recursively using a delete function
1385
- * @param {string} folder folder to delete
1386
- */ const recursiveRemoveFiles = async (folder, deleteFn)=>{
1387
- const filesName = await fse.readdir(folder);
1388
- for (const fileName of filesName){
1389
- const filePath = path.join(folder, fileName);
1390
- const stat = await fse.stat(filePath);
1391
- if (stat.isDirectory()) {
1392
- await recursiveRemoveFiles(filePath, deleteFn);
1393
- } else {
1394
- await deleteFn(filePath);
1395
- }
1396
- }
1397
- const files = await fse.readdir(folder);
1398
- if (files.length === 0) {
1399
- await fse.remove(folder);
1400
- }
1401
- };
1402
-
1403
- var apiHandler = /*#__PURE__*/Object.freeze({
1404
- __proto__: null,
1405
- backup: backup,
1406
- clear: clear,
1407
- rollback: rollback
1408
- });
1409
-
1410
- var services = {
1411
- 'content-types': contentTypes$1,
1412
- components: components$1,
1413
- 'component-categories': componentCategories$1,
1414
- builder: builder$1,
1415
- 'api-handler': apiHandler
1416
- };
1417
-
1418
- function getService(name) {
1419
- return strapi.plugin('content-type-builder').service(name);
1420
- }
1421
-
1422
- var builder = {
1423
- getReservedNames (ctx) {
1424
- ctx.body = getService('builder').getReservedNames();
1425
- }
1426
- };
1427
-
1428
- const validators = {
1429
- required: yup.boolean(),
1430
- unique: yup.boolean(),
1431
- minLength: yup.number().integer().positive(),
1432
- maxLength: yup.number().integer().positive()
1433
- };
1434
- const NAME_REGEX = /^[A-Za-z][_0-9A-Za-z]*$/;
1435
- const COLLECTION_NAME_REGEX = /^[A-Za-z][-_0-9A-Za-z]*$/;
1436
- const CATEGORY_NAME_REGEX = /^[A-Za-z][-_0-9A-Za-z]*$/;
1437
- const ICON_REGEX = /^[A-Za-z0-9][-A-Za-z0-9]*$/;
1438
- const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
1439
- const isValidName = {
1440
- name: 'isValidName',
1441
- message: `\${path} must match the following regex: ${NAME_REGEX}`,
1442
- test: (val)=>val === '' || NAME_REGEX.test(val)
1443
- };
1444
- const isValidIcon = {
1445
- name: 'isValidIcon',
1446
- message: `\${path} is not a valid icon name. Make sure your icon name starts with an alphanumeric character and only includes alphanumeric characters or dashes.`,
1447
- test: (val)=>val === '' || ICON_REGEX.test(val)
1448
- };
1449
- const isValidUID = {
1450
- name: 'isValidUID',
1451
- message: `\${path} must match the following regex: ${UID_REGEX}`,
1452
- test: (val)=>val === '' || UID_REGEX.test(val)
1453
- };
1454
- const isValidCategoryName = {
1455
- name: 'isValidCategoryName',
1456
- message: `\${path} must match the following regex: ${CATEGORY_NAME_REGEX}`,
1457
- test: (val)=>val === '' || CATEGORY_NAME_REGEX.test(val)
1458
- };
1459
- const isValidCollectionName = {
1460
- name: 'isValidCollectionName',
1461
- message: `\${path} must match the following regex: ${COLLECTION_NAME_REGEX}`,
1462
- test: (val)=>val === '' || COLLECTION_NAME_REGEX.test(val)
1463
- };
1464
- const isValidKey = (key)=>({
1465
- name: 'isValidKey',
1466
- message: `Attribute name '${key}' must match the following regex: ${NAME_REGEX}`,
1467
- test: ()=>NAME_REGEX.test(key)
1468
- });
1469
- const isValidEnum = {
1470
- name: 'isValidEnum',
1471
- message: '${path} should not start with number',
1472
- test: (val)=>val === '' || !strings.startsWithANumber(val)
1473
- };
1474
- const areEnumValuesUnique = {
1475
- name: 'areEnumValuesUnique',
1476
- message: '${path} cannot contain duplicate values',
1477
- test (values) {
1478
- const filtered = [
1479
- ...new Set(values)
1480
- ];
1481
- return filtered.length === values.length;
1482
- }
1483
- };
1484
- const isValidRegExpPattern = {
1485
- name: 'isValidRegExpPattern',
1486
- message: '${path} must be a valid RexExp pattern string',
1487
- test: (val)=>val === '' || !!new RegExp(val)
1488
- };
1489
- const isValidDefaultJSON = {
1490
- name: 'isValidDefaultJSON',
1491
- message: '${path} is not a valid JSON',
1492
- test (val) {
1493
- if (val === undefined) {
1494
- return true;
1495
- }
1496
- if (_.isNumber(val) || _.isNull(val) || _.isObject(val) || _.isArray(val)) {
1497
- return true;
1498
- }
1499
- try {
1500
- JSON.parse(val);
1501
- return true;
1502
- } catch (err) {
1503
- return false;
1504
- }
1505
- }
1506
- };
1507
-
1508
- const componentCategorySchema = yup.object({
1509
- name: yup.string().min(3).test(isValidCategoryName).required('name.required')
1510
- }).noUnknown();
1511
- var validateComponentCategory = validateYupSchema(componentCategorySchema);
1512
-
1513
- var componentCategories = {
1514
- async editCategory (ctx) {
1515
- const body = ctx.request.body;
1516
- try {
1517
- await validateComponentCategory(body);
1518
- } catch (error) {
1519
- return ctx.send({
1520
- error
1521
- }, 400);
1522
- }
1523
- const { name } = ctx.params;
1524
- strapi.reload.isWatching = false;
1525
- const componentCategoryService = getService('component-categories');
1526
- const newName = await componentCategoryService.editCategory(name, body);
1527
- setImmediate(()=>strapi.reload());
1528
- ctx.send({
1529
- name: newName
1530
- });
1531
- },
1532
- async deleteCategory (ctx) {
1533
- const { name } = ctx.params;
1534
- strapi.reload.isWatching = false;
1535
- const componentCategoryService = getService('component-categories');
1536
- await componentCategoryService.deleteCategory(name);
1537
- setImmediate(()=>strapi.reload());
1538
- ctx.send({
1539
- name
1540
- });
1541
- }
1542
- };
1543
-
1544
- const maxLengthIsGreaterThanOrEqualToMinLength = {
1545
- name: 'isGreaterThanMin',
1546
- message: 'maxLength must be greater or equal to minLength',
1547
- test (value) {
1548
- const { minLength } = this.parent;
1549
- return !(!_.isUndefined(minLength) && !_.isUndefined(value) && value < minLength);
1550
- }
1551
- };
1552
- const getTypeValidator = (attribute, { types, modelType, attributes })=>{
1553
- return yup.object({
1554
- type: yup.string().oneOf([
1555
- ...types
1556
- ]).required(),
1557
- configurable: yup.boolean().nullable(),
1558
- private: yup.boolean().nullable(),
1559
- pluginOptions: yup.object(),
1560
- ...getTypeShape(attribute, {
1561
- modelType,
1562
- attributes
1563
- })
1564
- });
1565
- };
1566
- const getTypeShape = (attribute, { attributes } = {})=>{
1567
- switch(attribute.type){
1568
- /**
1569
- * complex types
1570
- */ case 'media':
1571
- {
1572
- return {
1573
- multiple: yup.boolean(),
1574
- required: validators.required,
1575
- allowedTypes: yup.array().of(yup.string().oneOf([
1576
- 'images',
1577
- 'videos',
1578
- 'files',
1579
- 'audios'
1580
- ])).min(1)
1581
- };
1582
- }
1583
- case 'uid':
1584
- {
1585
- return {
1586
- required: validators.required,
1587
- targetField: yup.string().oneOf(Object.keys(attributes).filter((key)=>VALID_UID_TARGETS.includes(_.get(attributes[key], 'type')))).nullable(),
1588
- default: yup.string().test('isValidDefaultUID', 'cannot define a default UID if the targetField is set', function(value) {
1589
- const { targetField } = this.parent;
1590
- return !!(_.isNil(targetField) || _.isNil(value));
1591
- }).test(isValidUID),
1592
- minLength: validators.minLength,
1593
- maxLength: validators.maxLength.max(256).test(maxLengthIsGreaterThanOrEqualToMinLength),
1594
- options: yup.object().shape({
1595
- separator: yup.string(),
1596
- lowercase: yup.boolean(),
1597
- decamelize: yup.boolean(),
1598
- customReplacements: yup.array().of(yup.array().of(yup.string()).min(2).max(2)),
1599
- preserveLeadingUnderscore: yup.boolean()
1600
- })
1601
- };
1602
- }
1603
- /**
1604
- * scalar types
1605
- */ case 'string':
1606
- case 'text':
1607
- {
1608
- return {
1609
- default: yup.string(),
1610
- required: validators.required,
1611
- unique: validators.unique,
1612
- minLength: validators.minLength,
1613
- maxLength: validators.maxLength,
1614
- regex: yup.string().test(isValidRegExpPattern)
1615
- };
1616
- }
1617
- case 'richtext':
1618
- {
1619
- return {
1620
- default: yup.string(),
1621
- required: validators.required,
1622
- minLength: validators.minLength,
1623
- maxLength: validators.maxLength
1624
- };
1625
- }
1626
- case 'blocks':
1627
- {
1628
- return {
1629
- required: validators.required
1630
- };
1631
- }
1632
- case 'json':
1633
- {
1634
- return {
1635
- default: yup.mixed().test(isValidDefaultJSON),
1636
- required: validators.required
1637
- };
1638
- }
1639
- case 'enumeration':
1640
- {
1641
- return {
1642
- enum: yup.array().of(yup.string().test(isValidEnum).required()).min(1).test(areEnumValuesUnique).required(),
1643
- default: yup.string().when('enum', (enumVal)=>yup.string().oneOf(enumVal)),
1644
- enumName: yup.string().test(isValidName),
1645
- required: validators.required
1646
- };
1647
- }
1648
- case 'password':
1649
- {
1650
- return {
1651
- required: validators.required,
1652
- minLength: validators.minLength,
1653
- maxLength: validators.maxLength
1654
- };
1655
- }
1656
- case 'email':
1657
- {
1658
- return {
1659
- default: yup.string().email(),
1660
- required: validators.required,
1661
- unique: validators.unique,
1662
- minLength: validators.minLength,
1663
- maxLength: validators.maxLength
1664
- };
1665
- }
1666
- case 'integer':
1667
- {
1668
- return {
1669
- default: yup.number().integer(),
1670
- required: validators.required,
1671
- unique: validators.unique,
1672
- min: yup.number().integer(),
1673
- max: yup.number().integer()
1674
- };
1675
- }
1676
- case 'biginteger':
1677
- {
1678
- return {
1679
- default: yup.string().nullable().matches(/^\d*$/),
1680
- required: validators.required,
1681
- unique: validators.unique,
1682
- min: yup.string().nullable().matches(/^\d*$/),
1683
- max: yup.string().nullable().matches(/^\d*$/)
1684
- };
1685
- }
1686
- case 'float':
1687
- {
1688
- return {
1689
- default: yup.number(),
1690
- required: validators.required,
1691
- unique: validators.unique,
1692
- min: yup.number(),
1693
- max: yup.number()
1694
- };
1695
- }
1696
- case 'decimal':
1697
- {
1698
- return {
1699
- default: yup.number(),
1700
- required: validators.required,
1701
- unique: validators.unique,
1702
- min: yup.number(),
1703
- max: yup.number()
1704
- };
1705
- }
1706
- case 'time':
1707
- case 'datetime':
1708
- case 'date':
1709
- {
1710
- return {
1711
- default: yup.string(),
1712
- required: validators.required,
1713
- unique: validators.unique
1714
- };
1715
- }
1716
- case 'boolean':
1717
- {
1718
- return {
1719
- default: yup.boolean(),
1720
- required: validators.required
1721
- };
1722
- }
1723
- case 'component':
1724
- {
1725
- return {
1726
- required: validators.required,
1727
- repeatable: yup.boolean(),
1728
- // TODO: Add correct server validation for nested components
1729
- component: yup.string().required(),
1730
- min: yup.number(),
1731
- max: yup.number()
1732
- };
1733
- }
1734
- case 'dynamiczone':
1735
- {
1736
- return {
1737
- required: validators.required,
1738
- components: yup.array().of(yup.string().required()).test('isArray', '${path} must be an array', (value)=>Array.isArray(value)).min(1),
1739
- min: yup.number(),
1740
- max: yup.number()
1741
- };
1742
- }
1743
- default:
1744
- {
1745
- return {};
1746
- }
1747
- }
1748
- };
1749
-
1750
- const STRAPI_USER_RELATIONS = [
1751
- 'oneToOne',
1752
- 'oneToMany'
1753
- ];
1754
- const isValidRelation = (validNatures)=>function(value) {
1755
- // NOTE: In case of an undefined value, delegate the check to .required()
1756
- if (value === undefined) {
1757
- return true;
1758
- }
1759
- if (this.parent.target === coreUids.STRAPI_USER) {
1760
- if (!validNatures.includes(value) || !isUndefined(this.parent.targetAttribute)) {
1761
- return this.createError({
1762
- path: this.path,
1763
- message: `must be one of the following values: ${STRAPI_USER_RELATIONS.join(', ')}`
1764
- });
1765
- }
1766
- }
1767
- return validNatures.includes(value) ? true : this.createError({
1768
- path: this.path,
1769
- message: `must be one of the following values: ${validNatures.join(', ')}`
1770
- });
1771
- };
1772
- const getRelationValidator = (attribute, allowedRelations)=>{
1773
- const contentTypesUIDs = Object.keys(strapi.contentTypes).filter((key)=>strapi.contentTypes[key].kind === typeKinds.COLLECTION_TYPE).filter((key)=>!key.startsWith(coreUids.PREFIX) || key === coreUids.STRAPI_USER).concat([
1774
- '__self__',
1775
- '__contentType__'
1776
- ]);
1777
- const base = {
1778
- type: yup.string().oneOf([
1779
- 'relation'
1780
- ]).required(),
1781
- relation: yup.string().test('isValidRelation', isValidRelation(allowedRelations)).required(),
1782
- configurable: yup.boolean().nullable(),
1783
- private: yup.boolean().nullable(),
1784
- pluginOptions: yup.object()
1785
- };
1786
- switch(attribute.relation){
1787
- case 'oneToOne':
1788
- case 'oneToMany':
1789
- case 'manyToOne':
1790
- case 'manyToMany':
1791
- case 'morphOne':
1792
- case 'morphMany':
1793
- {
1794
- return yup.object({
1795
- ...base,
1796
- target: yup.string().oneOf(contentTypesUIDs).required(),
1797
- targetAttribute: yup.string().test(isValidName).nullable()
1798
- });
1799
- }
1800
- case 'morphToOne':
1801
- case 'morphToMany':
1802
- default:
1803
- {
1804
- return yup.object({
1805
- ...base
1806
- });
1807
- }
1808
- }
1809
- };
1810
-
1811
- const createSchema = (types, relations, { modelType } = {})=>{
1812
- const shape = {
1813
- description: yup.string(),
1814
- options: yup.object(),
1815
- pluginOptions: yup.object(),
1816
- collectionName: yup.string().nullable().test(isValidCollectionName),
1817
- attributes: createAttributesValidator({
1818
- types,
1819
- relations,
1820
- modelType
1821
- }),
1822
- draftAndPublish: yup.boolean()
1823
- };
1824
- if (modelType === modelTypes.CONTENT_TYPE) {
1825
- shape.kind = yup.string().oneOf([
1826
- typeKinds.SINGLE_TYPE,
1827
- typeKinds.COLLECTION_TYPE
1828
- ]).nullable();
1829
- }
1830
- return yup.object(shape).noUnknown();
1831
- };
1832
- const createAttributesValidator = ({ types, modelType, relations })=>{
1833
- return yup.lazy((attributes)=>{
1834
- return yup.object().shape(_.mapValues(attributes, (attribute, key)=>{
1835
- if (isForbiddenKey(key)) {
1836
- return forbiddenValidator();
1837
- }
1838
- if (isConflictingKey(key, attributes)) {
1839
- return conflictingKeysValidator(key);
1840
- }
1841
- if (attribute.type === 'relation') {
1842
- return getRelationValidator(attribute, relations).test(isValidKey(key));
1843
- }
1844
- if (_.has(attribute, 'type')) {
1845
- return getTypeValidator(attribute, {
1846
- types,
1847
- modelType,
1848
- attributes
1849
- }).test(isValidKey(key));
1850
- }
1851
- return typeOrRelationValidator;
1852
- })).required('attributes.required');
1853
- });
1854
- };
1855
- const isConflictingKey = (key, attributes)=>{
1856
- const snakeCaseKey = snakeCase(key);
1857
- return Object.keys(attributes).some((existingKey)=>{
1858
- if (existingKey === key) return false; // don't compare against itself
1859
- return snakeCase(existingKey) === snakeCaseKey;
1860
- });
1861
- };
1862
- const isForbiddenKey = (key)=>{
1863
- return getService('builder').isReservedAttributeName(key);
1864
- };
1865
- const forbiddenValidator = ()=>{
1866
- const reservedNames = [
1867
- ...getService('builder').getReservedNames().attributes
1868
- ];
1869
- return yup.mixed().test({
1870
- name: 'forbiddenKeys',
1871
- message: `Attribute keys cannot be one of ${reservedNames.join(', ')}`,
1872
- test: ()=>false
1873
- });
1874
- };
1875
- const conflictingKeysValidator = (key)=>{
1876
- return yup.mixed().test({
1877
- name: 'conflictingKeys',
1878
- message: `Attribute ${key} conflicts with an existing key`,
1879
- test: ()=>false
1880
- });
1881
- };
1882
- const typeOrRelationValidator = yup.object().test({
1883
- name: 'mustHaveTypeOrTarget',
1884
- message: 'Attribute must have either a type or a target',
1885
- test: ()=>false
1886
- });
1887
-
1888
- const hasDefaultAttribute = (attribute)=>{
1889
- return 'default' in attribute;
1890
- };
1891
-
1892
- const removeEmptyDefaults = (data)=>{
1893
- const { attributes } = data || {};
1894
- Object.keys(attributes).forEach((attributeName)=>{
1895
- const attribute = attributes[attributeName];
1896
- if (hasDefaultAttribute(attribute) && attribute.default === '') {
1897
- attribute.default = undefined;
1898
- }
1899
- });
1900
- };
1901
- const removeDeletedUIDTargetFields = (data)=>{
1902
- if (_.has(data, 'attributes')) {
1903
- Object.values(data.attributes).forEach((attribute)=>{
1904
- if (attribute.type === 'uid' && !_.isUndefined(attribute.targetField) && !_.has(data.attributes, attribute.targetField)) {
1905
- attribute.targetField = undefined;
1906
- }
1907
- });
1908
- }
1909
- };
1910
-
1911
- const VALID_RELATIONS$1 = [
1912
- 'oneToOne',
1913
- 'oneToMany'
1914
- ];
1915
- const VALID_TYPES$1 = [
1916
- ...DEFAULT_TYPES,
1917
- 'component',
1918
- 'customField'
1919
- ];
1920
- const componentSchema = createSchema(VALID_TYPES$1, VALID_RELATIONS$1, {
1921
- modelType: modelTypes.COMPONENT
1922
- }).shape({
1923
- displayName: yup.string().min(1).required('displayName.required'),
1924
- icon: yup.string().nullable().test(isValidIcon),
1925
- category: yup.string().nullable().test(isValidCategoryName).required('category.required')
1926
- }).required().noUnknown();
1927
- const nestedComponentSchema = yup.array().of(componentSchema.shape({
1928
- uid: yup.string(),
1929
- tmpUID: yup.string()
1930
- }).test({
1931
- name: 'mustHaveUIDOrTmpUID',
1932
- message: 'Component must have a uid or a tmpUID',
1933
- test (attr) {
1934
- if (_.has(attr, 'uid') && _.has(attr, 'tmpUID')) return false;
1935
- if (!_.has(attr, 'uid') && !_.has(attr, 'tmpUID')) return false;
1936
- return true;
1937
- }
1938
- }).required().noUnknown());
1939
- const componentInputSchema = yup.object({
1940
- component: componentSchema,
1941
- components: nestedComponentSchema
1942
- }).noUnknown();
1943
- const validateComponentInput = validateYupSchema(componentInputSchema);
1944
- const updateComponentInputSchema = yup.object({
1945
- component: componentSchema,
1946
- components: nestedComponentSchema
1947
- }).noUnknown();
1948
- const validateUpdateComponentInput = (data)=>{
1949
- if (_.has(data, 'component') && data.component) {
1950
- removeEmptyDefaults(data.component);
1951
- }
1952
- if (_.has(data, 'components') && Array.isArray(data.components)) {
1953
- data.components.forEach((data)=>{
1954
- if (_.has(data, 'uid')) {
1955
- removeEmptyDefaults(data);
1956
- }
1957
- });
1958
- }
1959
- return validateYupSchema(updateComponentInputSchema)(data);
1960
- };
1961
-
1962
- /**
1963
- * Components controller
1964
- */ var components = {
1965
- /**
1966
- * GET /components handler
1967
- * Returns a list of available components
1968
- * @param {Object} ctx - koa context
1969
- */ async getComponents (ctx) {
1970
- const componentService = getService('components');
1971
- const componentUIDs = Object.keys(strapi.components);
1972
- const data = componentUIDs.map((uid)=>{
1973
- return componentService.formatComponent(strapi.components[uid]);
1974
- });
1975
- ctx.send({
1976
- data
1977
- });
1978
- },
1979
- /**
1980
- * GET /components/:uid
1981
- * Returns a specific component
1982
- * @param {Object} ctx - koa context
1983
- */ async getComponent (ctx) {
1984
- const { uid } = ctx.params;
1985
- const component = strapi.components[uid];
1986
- if (!component) {
1987
- return ctx.send({
1988
- error: 'component.notFound'
1989
- }, 404);
1990
- }
1991
- const componentService = getService('components');
1992
- ctx.send({
1993
- data: componentService.formatComponent(component)
1994
- });
1995
- },
1996
- /**
1997
- * POST /components
1998
- * Creates a component and returns its infos
1999
- * @param {Object} ctx - koa context
2000
- */ async createComponent (ctx) {
2001
- const body = ctx.request.body;
2002
- try {
2003
- await validateComponentInput(body);
2004
- } catch (error) {
2005
- return ctx.send({
2006
- error
2007
- }, 400);
2008
- }
2009
- try {
2010
- strapi.reload.isWatching = false;
2011
- const componentService = getService('components');
2012
- const component = await componentService.createComponent({
2013
- component: body.component,
2014
- components: body.components
2015
- });
2016
- setImmediate(()=>strapi.reload());
2017
- ctx.send({
2018
- data: {
2019
- uid: component.uid
2020
- }
2021
- }, 201);
2022
- } catch (error) {
2023
- strapi.log.error(error);
2024
- ctx.send({
2025
- error: error?.message || 'Unknown error'
2026
- }, 400);
2027
- }
2028
- },
2029
- /**
2030
- * PUT /components/:uid
2031
- * Updates a component and return its infos
2032
- * @param {Object} ctx - koa context - enhanced koa context
2033
- */ async updateComponent (ctx) {
2034
- const { uid } = ctx.params;
2035
- const body = ctx.request.body;
2036
- if (!_.has(strapi.components, uid)) {
2037
- return ctx.send({
2038
- error: 'component.notFound'
2039
- }, 404);
2040
- }
2041
- try {
2042
- await validateUpdateComponentInput(body);
2043
- } catch (error) {
2044
- return ctx.send({
2045
- error
2046
- }, 400);
2047
- }
2048
- try {
2049
- strapi.reload.isWatching = false;
2050
- const componentService = getService('components');
2051
- const component = await componentService.editComponent(uid, {
2052
- component: body.component,
2053
- components: body.components
2054
- });
2055
- setImmediate(()=>strapi.reload());
2056
- ctx.send({
2057
- data: {
2058
- uid: component.uid
2059
- }
2060
- });
2061
- } catch (error) {
2062
- strapi.log.error(error);
2063
- ctx.send({
2064
- error: error?.message || 'Unknown error'
2065
- }, 400);
2066
- }
2067
- },
2068
- /**
2069
- * DELETE /components/:uid
2070
- * Deletes a components and returns its old infos
2071
- * @param {Object} ctx - koa context
2072
- */ async deleteComponent (ctx) {
2073
- const { uid } = ctx.params;
2074
- if (!_.has(strapi.components, uid)) {
2075
- return ctx.send({
2076
- error: 'component.notFound'
2077
- }, 404);
2078
- }
2079
- try {
2080
- strapi.reload.isWatching = false;
2081
- const componentService = getService('components');
2082
- const component = await componentService.deleteComponent(uid);
2083
- setImmediate(()=>strapi.reload());
2084
- ctx.send({
2085
- data: {
2086
- uid: component.uid
2087
- }
2088
- });
2089
- } catch (error) {
2090
- strapi.log.error(error);
2091
- ctx.send({
2092
- error: error?.message || 'Unknown error'
2093
- }, 400);
2094
- }
2095
- }
2096
- };
2097
-
2098
- /* eslint-disable no-template-curly-in-string */ // yup templates need to be in this format
2099
- /**
2100
- * Allowed relation per type kind
2101
- */ const VALID_RELATIONS = {
2102
- [typeKinds.SINGLE_TYPE]: [
2103
- 'oneToOne',
2104
- 'oneToMany',
2105
- 'morphOne',
2106
- 'morphMany',
2107
- 'morphToOne',
2108
- 'morphToMany'
2109
- ],
2110
- [typeKinds.COLLECTION_TYPE]: [
2111
- 'oneToOne',
2112
- 'oneToMany',
2113
- 'manyToOne',
2114
- 'manyToMany',
2115
- 'morphOne',
2116
- 'morphMany',
2117
- 'morphToOne',
2118
- 'morphToMany'
2119
- ]
2120
- };
2121
- /**
2122
- * Allowed types
2123
- */ const VALID_TYPES = [
2124
- ...DEFAULT_TYPES,
2125
- 'uid',
2126
- 'component',
2127
- 'dynamiczone',
2128
- 'customField'
2129
- ];
2130
- /**
2131
- * Returns a yup schema to validate a content type payload
2132
- */ const createContentTypeSchema = (data, { isEdition = false } = {})=>{
2133
- const kind = getOr(typeKinds.COLLECTION_TYPE, 'contentType.kind', data);
2134
- const contentTypeSchema = createSchema(VALID_TYPES, VALID_RELATIONS[kind] || [], {
2135
- modelType: modelTypes.CONTENT_TYPE
2136
- }).shape({
2137
- displayName: yup.string().min(1).required(),
2138
- singularName: yup.string().min(1).test(nameIsAvailable(isEdition)).test(forbiddenContentTypeNameValidator()).isKebabCase().required(),
2139
- pluralName: yup.string().min(1).test(nameIsAvailable(isEdition)).test(nameIsNotExistingCollectionName(isEdition)) // TODO: v5: require singularName to not match a collection name
2140
- .test(forbiddenContentTypeNameValidator()).isKebabCase().required()
2141
- }).test('singularName-not-equal-pluralName', '${path}: singularName and pluralName should be different', (value)=>value.singularName !== value.pluralName);
2142
- return yup.object({
2143
- // FIXME .noUnknown(false) will strip off the unwanted properties without throwing an error
2144
- // Why not having .noUnknown() ? Because we want to be able to add options relatable to EE features
2145
- // without having any reference to them in CE.
2146
- // Why not handle an "options" object in the content-type ? The admin panel needs lots of rework
2147
- // to be able to send this options object instead of top-level attributes.
2148
- // @nathan-pichon 20/02/2023
2149
- contentType: contentTypeSchema.required().noUnknown(false),
2150
- components: nestedComponentSchema
2151
- }).noUnknown();
2152
- };
2153
- /**
2154
- * Validator for content type creation
2155
- */ const validateContentTypeInput = (data)=>{
2156
- return validateYupSchema(createContentTypeSchema(data))(data);
2157
- };
2158
- /**
2159
- * Validator for content type edition
2160
- */ const validateUpdateContentTypeInput = (data)=>{
2161
- if (has$1('contentType', data)) {
2162
- removeEmptyDefaults(data.contentType);
2163
- removeDeletedUIDTargetFields(data.contentType);
2164
- }
2165
- if (has$1('components', data) && Array.isArray(data.components)) {
2166
- data.components.forEach((comp)=>{
2167
- if (has$1('uid', comp)) {
2168
- removeEmptyDefaults(comp);
2169
- }
2170
- });
2171
- }
2172
- return validateYupSchema(createContentTypeSchema(data, {
2173
- isEdition: true
2174
- }))(data);
2175
- };
2176
- const forbiddenContentTypeNameValidator = ()=>{
2177
- const reservedNames = getService('builder').getReservedNames().models;
2178
- return {
2179
- name: 'forbiddenContentTypeName',
2180
- message: `Content Type name cannot be one of ${reservedNames.join(', ')}`,
2181
- test (value) {
2182
- if (typeof value !== 'string') {
2183
- return true;
2184
- }
2185
- return !getService('builder').isReservedModelName(value);
2186
- }
2187
- };
2188
- };
2189
- const nameIsAvailable = (isEdition)=>{
2190
- // TODO TS: if strapi.contentTypes (ie, ContentTypes) works as an ArrayLike and is used like this, we may want to ensure it is typed so that it can be without using as
2191
- const usedNames = flatMap((ct)=>{
2192
- return [
2193
- ct.info?.singularName,
2194
- ct.info?.pluralName
2195
- ];
2196
- })(strapi.contentTypes);
2197
- return {
2198
- name: 'nameAlreadyUsed',
2199
- message: 'contentType: name `${value}` is already being used by another content type.',
2200
- test (value) {
2201
- // don't check on edition
2202
- if (isEdition) return true;
2203
- // ignore if not a string (will be caught in another validator)
2204
- if (typeof value !== 'string') {
2205
- return true;
2206
- }
2207
- // compare snake case to check the actual column names that will be used in the database
2208
- return usedNames.every((usedName)=>snakeCase(usedName) !== snakeCase(value));
2209
- }
2210
- };
2211
- };
2212
- const nameIsNotExistingCollectionName = (isEdition)=>{
2213
- const usedNames = Object.keys(strapi.contentTypes).map((key)=>strapi.contentTypes[key].collectionName);
2214
- return {
2215
- name: 'nameAlreadyUsed',
2216
- message: 'contentType: name `${value}` is already being used by another content type.',
2217
- test (value) {
2218
- // don't check on edition
2219
- if (isEdition) return true;
2220
- // ignore if not a string (will be caught in another validator)
2221
- if (typeof value !== 'string') {
2222
- return true;
2223
- }
2224
- // compare snake case to check the actual column names that will be used in the database
2225
- return usedNames.every((usedName)=>snakeCase(usedName) !== snakeCase(value));
2226
- }
2227
- };
2228
- };
2229
- /**
2230
- * Validates type kind
2231
- */ const kindSchema = yup.string().oneOf([
2232
- typeKinds.SINGLE_TYPE,
2233
- typeKinds.COLLECTION_TYPE
2234
- ]);
2235
- const validateKind = validateYupSchema(kindSchema);
2236
-
2237
- var contentTypes = {
2238
- async getContentTypes (ctx) {
2239
- const { kind } = ctx.query;
2240
- try {
2241
- await validateKind(kind);
2242
- } catch (error) {
2243
- return ctx.send({
2244
- error
2245
- }, 400);
2246
- }
2247
- const contentTypeService = getService('content-types');
2248
- const contentTypes = Object.keys(strapi.contentTypes).filter((uid)=>!kind || _.get(strapi.contentTypes[uid], 'kind', 'collectionType') === kind).map((uid)=>contentTypeService.formatContentType(strapi.contentTypes[uid]));
2249
- ctx.send({
2250
- data: contentTypes
2251
- });
2252
- },
2253
- getContentType (ctx) {
2254
- const { uid } = ctx.params;
2255
- const contentType = strapi.contentTypes[uid];
2256
- if (!contentType) {
2257
- return ctx.send({
2258
- error: 'contentType.notFound'
2259
- }, 404);
2260
- }
2261
- const contentTypeService = getService('content-types');
2262
- ctx.send({
2263
- data: contentTypeService.formatContentType(contentType)
2264
- });
2265
- },
2266
- async createContentType (ctx) {
2267
- const body = ctx.request.body;
2268
- try {
2269
- await validateContentTypeInput(body);
2270
- } catch (error) {
2271
- return ctx.send({
2272
- error
2273
- }, 400);
2274
- }
2275
- try {
2276
- strapi.reload.isWatching = false;
2277
- const contentTypeService = getService('content-types');
2278
- const contentType = await contentTypeService.createContentType({
2279
- contentType: body.contentType,
2280
- components: body.components
2281
- });
2282
- const metricsPayload = {
2283
- eventProperties: {
2284
- kind: contentType.kind
2285
- }
2286
- };
2287
- if (_.isEmpty(strapi.apis)) {
2288
- await strapi.telemetry.send('didCreateFirstContentType', metricsPayload);
2289
- } else {
2290
- await strapi.telemetry.send('didCreateContentType', metricsPayload);
2291
- }
2292
- setImmediate(()=>strapi.reload());
2293
- ctx.send({
2294
- data: {
2295
- uid: contentType.uid
2296
- }
2297
- }, 201);
2298
- } catch (err) {
2299
- strapi.log.error(err);
2300
- await strapi.telemetry.send('didNotCreateContentType', {
2301
- eventProperties: {
2302
- error: err.message || err
2303
- }
2304
- });
2305
- ctx.send({
2306
- error: err.message || 'Unknown error'
2307
- }, 400);
2308
- }
2309
- },
2310
- async updateContentType (ctx) {
2311
- const { uid } = ctx.params;
2312
- const body = ctx.request.body;
2313
- if (!_.has(strapi.contentTypes, uid)) {
2314
- return ctx.send({
2315
- error: 'contentType.notFound'
2316
- }, 404);
2317
- }
2318
- try {
2319
- await validateUpdateContentTypeInput(body);
2320
- } catch (error) {
2321
- return ctx.send({
2322
- error
2323
- }, 400);
2324
- }
2325
- try {
2326
- strapi.reload.isWatching = false;
2327
- const contentTypeService = getService('content-types');
2328
- const component = await contentTypeService.editContentType(uid, {
2329
- contentType: body.contentType,
2330
- components: body.components
2331
- });
2332
- setImmediate(()=>strapi.reload());
2333
- ctx.send({
2334
- data: {
2335
- uid: component.uid
2336
- }
2337
- }, 201);
2338
- } catch (error) {
2339
- strapi.log.error(error);
2340
- ctx.send({
2341
- error: error?.message || 'Unknown error'
2342
- }, 400);
2343
- }
2344
- },
2345
- async deleteContentType (ctx) {
2346
- const { uid } = ctx.params;
2347
- if (!_.has(strapi.contentTypes, uid)) {
2348
- return ctx.send({
2349
- error: 'contentType.notFound'
2350
- }, 404);
2351
- }
2352
- try {
2353
- strapi.reload.isWatching = false;
2354
- const contentTypeService = getService('content-types');
2355
- const component = await contentTypeService.deleteContentType(uid);
2356
- setImmediate(()=>strapi.reload());
2357
- ctx.send({
2358
- data: {
2359
- uid: component.uid
2360
- }
2361
- });
2362
- } catch (error) {
2363
- strapi.log.error(error);
2364
- ctx.send({
2365
- error: error?.message || 'Unknown error'
2366
- }, 400);
2367
- }
2368
- }
2369
- };
2370
-
2371
- const exportObject = {
2372
- builder,
2373
- 'component-categories': componentCategories,
2374
- components,
2375
- 'content-types': contentTypes
2376
- };
2377
-
2378
- var admin = {
2379
- type: 'admin',
2380
- routes: [
2381
- {
2382
- method: 'GET',
2383
- path: '/reserved-names',
2384
- handler: 'builder.getReservedNames',
2385
- config: {
2386
- policies: [
2387
- {
2388
- name: 'admin::hasPermissions',
2389
- config: {
2390
- actions: [
2391
- 'plugin::content-type-builder.read'
2392
- ]
2393
- }
2394
- }
2395
- ]
2396
- }
2397
- },
2398
- {
2399
- method: 'GET',
2400
- path: '/content-types',
2401
- handler: 'content-types.getContentTypes',
2402
- config: {
2403
- policies: [
2404
- {
2405
- name: 'admin::hasPermissions',
2406
- config: {
2407
- actions: [
2408
- 'plugin::content-type-builder.read'
2409
- ]
2410
- }
2411
- }
2412
- ]
2413
- }
2414
- },
2415
- {
2416
- method: 'GET',
2417
- path: '/content-types/:uid',
2418
- handler: 'content-types.getContentType',
2419
- config: {
2420
- policies: [
2421
- {
2422
- name: 'admin::hasPermissions',
2423
- config: {
2424
- actions: [
2425
- 'plugin::content-type-builder.read'
2426
- ]
2427
- }
2428
- }
2429
- ]
2430
- }
2431
- },
2432
- {
2433
- method: 'POST',
2434
- path: '/content-types',
2435
- handler: 'content-types.createContentType',
2436
- config: {
2437
- policies: [
2438
- {
2439
- name: 'admin::hasPermissions',
2440
- config: {
2441
- actions: [
2442
- 'plugin::content-type-builder.read'
2443
- ]
2444
- }
2445
- }
2446
- ]
2447
- }
2448
- },
2449
- {
2450
- method: 'PUT',
2451
- path: '/content-types/:uid',
2452
- handler: 'content-types.updateContentType',
2453
- config: {
2454
- policies: [
2455
- {
2456
- name: 'admin::hasPermissions',
2457
- config: {
2458
- actions: [
2459
- 'plugin::content-type-builder.read'
2460
- ]
2461
- }
2462
- }
2463
- ]
2464
- }
2465
- },
2466
- {
2467
- method: 'DELETE',
2468
- path: '/content-types/:uid',
2469
- handler: 'content-types.deleteContentType',
2470
- config: {
2471
- policies: [
2472
- {
2473
- name: 'admin::hasPermissions',
2474
- config: {
2475
- actions: [
2476
- 'plugin::content-type-builder.read'
2477
- ]
2478
- }
2479
- }
2480
- ]
2481
- }
2482
- },
2483
- {
2484
- method: 'GET',
2485
- path: '/components',
2486
- handler: 'components.getComponents',
2487
- config: {
2488
- policies: [
2489
- {
2490
- name: 'admin::hasPermissions',
2491
- config: {
2492
- actions: [
2493
- 'plugin::content-type-builder.read'
2494
- ]
2495
- }
2496
- }
2497
- ]
2498
- }
2499
- },
2500
- {
2501
- method: 'GET',
2502
- path: '/components/:uid',
2503
- handler: 'components.getComponent',
2504
- config: {
2505
- policies: [
2506
- {
2507
- name: 'admin::hasPermissions',
2508
- config: {
2509
- actions: [
2510
- 'plugin::content-type-builder.read'
2511
- ]
2512
- }
2513
- }
2514
- ]
2515
- }
2516
- },
2517
- {
2518
- method: 'POST',
2519
- path: '/components',
2520
- handler: 'components.createComponent',
2521
- config: {
2522
- policies: [
2523
- {
2524
- name: 'admin::hasPermissions',
2525
- config: {
2526
- actions: [
2527
- 'plugin::content-type-builder.read'
2528
- ]
2529
- }
2530
- }
2531
- ]
2532
- }
2533
- },
2534
- {
2535
- method: 'PUT',
2536
- path: '/components/:uid',
2537
- handler: 'components.updateComponent',
2538
- config: {
2539
- policies: [
2540
- {
2541
- name: 'admin::hasPermissions',
2542
- config: {
2543
- actions: [
2544
- 'plugin::content-type-builder.read'
2545
- ]
2546
- }
2547
- }
2548
- ]
2549
- }
2550
- },
2551
- {
2552
- method: 'DELETE',
2553
- path: '/components/:uid',
2554
- handler: 'components.deleteComponent',
2555
- config: {
2556
- policies: [
2557
- {
2558
- name: 'admin::hasPermissions',
2559
- config: {
2560
- actions: [
2561
- 'plugin::content-type-builder.read'
2562
- ]
2563
- }
2564
- }
2565
- ]
2566
- }
2567
- },
2568
- {
2569
- method: 'PUT',
2570
- path: '/component-categories/:name',
2571
- handler: 'component-categories.editCategory',
2572
- config: {
2573
- policies: [
2574
- {
2575
- name: 'admin::hasPermissions',
2576
- config: {
2577
- actions: [
2578
- 'plugin::content-type-builder.read'
2579
- ]
2580
- }
2581
- }
2582
- ]
2583
- }
2584
- },
2585
- {
2586
- method: 'DELETE',
2587
- path: '/component-categories/:name',
2588
- handler: 'component-categories.deleteCategory',
2589
- config: {
2590
- policies: [
2591
- {
2592
- name: 'admin::hasPermissions',
2593
- config: {
2594
- actions: [
2595
- 'plugin::content-type-builder.read'
2596
- ]
2597
- }
2598
- }
2599
- ]
2600
- }
2601
- }
2602
- ]
2603
- };
2604
-
2605
- var contentApi = {
2606
- type: 'content-api',
2607
- routes: [
2608
- {
2609
- method: 'GET',
2610
- path: '/content-types',
2611
- handler: 'content-types.getContentTypes'
2612
- },
2613
- {
2614
- method: 'GET',
2615
- path: '/content-types/:uid',
2616
- handler: 'content-types.getContentType'
2617
- },
2618
- {
2619
- method: 'GET',
2620
- path: '/components',
2621
- handler: 'components.getComponents'
2622
- },
2623
- {
2624
- method: 'GET',
2625
- path: '/components/:uid',
2626
- handler: 'components.getComponent'
2627
- }
2628
- ]
2629
- };
2630
-
2631
- var routes = {
2632
- admin,
2633
- 'content-api': contentApi
2634
- };
2
+ import config from './config.mjs';
3
+ import bootstrap from './bootstrap.mjs';
4
+ import services from './services/index.mjs';
5
+ import exportObject from './controllers/index.mjs';
6
+ import routes from './routes/index.mjs';
2635
7
 
2636
8
  // eslint-disable-next-line import/no-extraneous-dependencies
2637
9
  var index = (()=>({