@strapi/content-type-builder 0.0.0 → 5.0.0-beta.7

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 (315) hide show
  1. package/README.md +1 -1
  2. package/dist/_chunks/ListView-BuXQ605A.js +959 -0
  3. package/dist/_chunks/ListView-BuXQ605A.js.map +1 -0
  4. package/dist/_chunks/ListView-C4hI-wBm.mjs +954 -0
  5. package/dist/_chunks/ListView-C4hI-wBm.mjs.map +1 -0
  6. package/dist/_chunks/ar-BYDB75EB.mjs +51 -0
  7. package/dist/_chunks/ar-BYDB75EB.mjs.map +1 -0
  8. package/dist/_chunks/ar-OCxhAFUy.js +51 -0
  9. package/dist/_chunks/ar-OCxhAFUy.js.map +1 -0
  10. package/dist/_chunks/cs-ChL4LaFY.mjs +139 -0
  11. package/dist/_chunks/cs-ChL4LaFY.mjs.map +1 -0
  12. package/dist/_chunks/cs-Ci3js5EC.js +139 -0
  13. package/dist/_chunks/cs-Ci3js5EC.js.map +1 -0
  14. package/dist/_chunks/de-DnlblIOh.js +193 -0
  15. package/dist/_chunks/de-DnlblIOh.js.map +1 -0
  16. package/dist/_chunks/de-DsHQNzp2.mjs +193 -0
  17. package/dist/_chunks/de-DsHQNzp2.mjs.map +1 -0
  18. package/dist/_chunks/dk-BC7NAQR2.mjs +183 -0
  19. package/dist/_chunks/dk-BC7NAQR2.mjs.map +1 -0
  20. package/dist/_chunks/dk-D3XnOjYz.js +183 -0
  21. package/dist/_chunks/dk-D3XnOjYz.js.map +1 -0
  22. package/dist/_chunks/en-BbczxQBr.mjs +216 -0
  23. package/dist/_chunks/en-BbczxQBr.mjs.map +1 -0
  24. package/dist/_chunks/en-BnToboMV.js +216 -0
  25. package/dist/_chunks/en-BnToboMV.js.map +1 -0
  26. package/dist/_chunks/es-BE_zx2_w.mjs +183 -0
  27. package/dist/_chunks/es-BE_zx2_w.mjs.map +1 -0
  28. package/dist/_chunks/es-DL8lez9W.js +183 -0
  29. package/dist/_chunks/es-DL8lez9W.js.map +1 -0
  30. package/dist/_chunks/fr-DnTxugIo.js +75 -0
  31. package/dist/_chunks/fr-DnTxugIo.js.map +1 -0
  32. package/dist/_chunks/fr-lU_OMJma.mjs +75 -0
  33. package/dist/_chunks/fr-lU_OMJma.mjs.map +1 -0
  34. package/dist/_chunks/id-DYuTgqcc.js +166 -0
  35. package/dist/_chunks/id-DYuTgqcc.js.map +1 -0
  36. package/dist/_chunks/id-W1sKBFEw.mjs +166 -0
  37. package/dist/_chunks/id-W1sKBFEw.mjs.map +1 -0
  38. package/dist/_chunks/index-2ofTO2HM.js +6738 -0
  39. package/dist/_chunks/index-2ofTO2HM.js.map +1 -0
  40. package/dist/_chunks/index-CH93OgkC.js +1209 -0
  41. package/dist/_chunks/index-CH93OgkC.js.map +1 -0
  42. package/dist/_chunks/index-CPBF498m.mjs +6701 -0
  43. package/dist/_chunks/index-CPBF498m.mjs.map +1 -0
  44. package/dist/_chunks/index-DmqlavBo.mjs +1183 -0
  45. package/dist/_chunks/index-DmqlavBo.mjs.map +1 -0
  46. package/dist/_chunks/it-D04lb2Wc.mjs +167 -0
  47. package/dist/_chunks/it-D04lb2Wc.mjs.map +1 -0
  48. package/dist/_chunks/it-DS4sM3km.js +167 -0
  49. package/dist/_chunks/it-DS4sM3km.js.map +1 -0
  50. package/dist/_chunks/ja-BHLK_2_g.mjs +50 -0
  51. package/dist/_chunks/ja-BHLK_2_g.mjs.map +1 -0
  52. package/dist/_chunks/ja-BjouJgZf.js +50 -0
  53. package/dist/_chunks/ja-BjouJgZf.js.map +1 -0
  54. package/dist/_chunks/ko-D_71Pdfn.js +183 -0
  55. package/dist/_chunks/ko-D_71Pdfn.js.map +1 -0
  56. package/dist/_chunks/ko-DoNsXHXA.mjs +183 -0
  57. package/dist/_chunks/ko-DoNsXHXA.mjs.map +1 -0
  58. package/dist/_chunks/ms-BtGFDB9t.mjs +163 -0
  59. package/dist/_chunks/ms-BtGFDB9t.mjs.map +1 -0
  60. package/dist/_chunks/ms-Re1pSHmx.js +163 -0
  61. package/dist/_chunks/ms-Re1pSHmx.js.map +1 -0
  62. package/dist/_chunks/nl-BaTAuelQ.mjs +156 -0
  63. package/dist/_chunks/nl-BaTAuelQ.mjs.map +1 -0
  64. package/dist/_chunks/nl-DQjrDEw0.js +156 -0
  65. package/dist/_chunks/nl-DQjrDEw0.js.map +1 -0
  66. package/dist/_chunks/pl-BGwXgwH7.js +193 -0
  67. package/dist/_chunks/pl-BGwXgwH7.js.map +1 -0
  68. package/dist/_chunks/pl-CP2Zgp01.mjs +193 -0
  69. package/dist/_chunks/pl-CP2Zgp01.mjs.map +1 -0
  70. package/dist/_chunks/pt-BR-CCQGwXs0.mjs +193 -0
  71. package/dist/_chunks/pt-BR-CCQGwXs0.mjs.map +1 -0
  72. package/dist/_chunks/pt-BR-DPd5nRnl.js +193 -0
  73. package/dist/_chunks/pt-BR-DPd5nRnl.js.map +1 -0
  74. package/dist/_chunks/pt-CJoUDTHQ.js +51 -0
  75. package/dist/_chunks/pt-CJoUDTHQ.js.map +1 -0
  76. package/dist/_chunks/pt-DMeTMW2x.mjs +51 -0
  77. package/dist/_chunks/pt-DMeTMW2x.mjs.map +1 -0
  78. package/dist/_chunks/ru-C8A_4j0w.js +168 -0
  79. package/dist/_chunks/ru-C8A_4j0w.js.map +1 -0
  80. package/dist/_chunks/ru-DGSjru5m.mjs +168 -0
  81. package/dist/_chunks/ru-DGSjru5m.mjs.map +1 -0
  82. package/dist/_chunks/sk-DVK4HfSC.mjs +167 -0
  83. package/dist/_chunks/sk-DVK4HfSC.mjs.map +1 -0
  84. package/dist/_chunks/sk-raWRcmPT.js +167 -0
  85. package/dist/_chunks/sk-raWRcmPT.js.map +1 -0
  86. package/dist/_chunks/sv-BGb12eW3.mjs +202 -0
  87. package/dist/_chunks/sv-BGb12eW3.mjs.map +1 -0
  88. package/dist/_chunks/sv-BNN71SFE.js +202 -0
  89. package/dist/_chunks/sv-BNN71SFE.js.map +1 -0
  90. package/dist/_chunks/th--u3VqsON.mjs +164 -0
  91. package/dist/_chunks/th--u3VqsON.mjs.map +1 -0
  92. package/dist/_chunks/th-C83Bb_kR.js +164 -0
  93. package/dist/_chunks/th-C83Bb_kR.js.map +1 -0
  94. package/dist/_chunks/tr-BW20CfcO.js +179 -0
  95. package/dist/_chunks/tr-BW20CfcO.js.map +1 -0
  96. package/dist/_chunks/tr-DsUerr-c.mjs +179 -0
  97. package/dist/_chunks/tr-DsUerr-c.mjs.map +1 -0
  98. package/dist/_chunks/uk-Bx5IlOKX.mjs +164 -0
  99. package/dist/_chunks/uk-Bx5IlOKX.mjs.map +1 -0
  100. package/dist/_chunks/uk-VwB0oiuV.js +164 -0
  101. package/dist/_chunks/uk-VwB0oiuV.js.map +1 -0
  102. package/dist/_chunks/zh-BiOCwPJu.js +202 -0
  103. package/dist/_chunks/zh-BiOCwPJu.js.map +1 -0
  104. package/dist/_chunks/zh-CsUDN13W.mjs +202 -0
  105. package/dist/_chunks/zh-CsUDN13W.mjs.map +1 -0
  106. package/dist/_chunks/zh-Hans-CLTLm_nt.js +147 -0
  107. package/dist/_chunks/zh-Hans-CLTLm_nt.js.map +1 -0
  108. package/dist/_chunks/zh-Hans-Cc0M5PXr.mjs +147 -0
  109. package/dist/_chunks/zh-Hans-Cc0M5PXr.mjs.map +1 -0
  110. package/dist/admin/index.js +5 -0
  111. package/dist/admin/index.js.map +1 -0
  112. package/dist/admin/index.mjs +6 -0
  113. package/dist/admin/index.mjs.map +1 -0
  114. package/dist/admin/src/components/AllowedTypesSelect.d.ts +9 -0
  115. package/dist/admin/src/components/AttributeIcon.d.ts +9 -0
  116. package/dist/admin/src/components/AttributeOptions/AttributeList.d.ts +6 -0
  117. package/dist/admin/src/components/AttributeOptions/AttributeOption.d.ts +11 -0
  118. package/dist/admin/src/components/AttributeOptions/AttributeOptions.d.ts +13 -0
  119. package/dist/admin/src/components/AttributeOptions/CustomFieldOption.d.ts +22 -0
  120. package/dist/admin/src/components/AttributeOptions/CustomFieldsList.d.ts +1 -0
  121. package/dist/admin/src/components/AttributeOptions/EmptyAttributes.d.ts +2 -0
  122. package/dist/admin/src/components/AttributeOptions/OptionBoxWrapper.d.ts +4 -0
  123. package/dist/admin/src/components/AutoReloadOverlayBlocker.d.ts +25 -0
  124. package/dist/admin/src/components/BooleanDefaultValueSelect.d.ts +20 -0
  125. package/dist/admin/src/components/BooleanRadioGroup.d.ts +8 -0
  126. package/dist/admin/src/components/BoxWrapper.d.ts +4 -0
  127. package/dist/admin/src/components/CheckboxWithNumberField.d.ts +11 -0
  128. package/dist/admin/src/components/ComponentCard/ComponentCard.d.ts +10 -0
  129. package/dist/admin/src/components/ComponentCard/ComponentIcon/ComponentIcon.d.ts +7 -0
  130. package/dist/admin/src/components/ComponentCard/ComponentIcon/index.d.ts +1 -0
  131. package/dist/admin/src/components/ComponentCard/index.d.ts +1 -0
  132. package/dist/admin/src/components/ComponentList.d.ts +10 -0
  133. package/dist/admin/src/components/ContentTypeBuilderNav/ContentTypeBuilderNav.d.ts +1 -0
  134. package/dist/admin/src/components/ContentTypeBuilderNav/useContentTypeBuilderMenu.d.ts +18 -0
  135. package/dist/admin/src/components/ContentTypeRadioGroup.d.ts +15 -0
  136. package/dist/admin/src/components/CustomRadioGroup/CustomRadioGroup.d.ts +15 -0
  137. package/dist/admin/src/components/CustomRadioGroup/Styles.d.ts +5 -0
  138. package/dist/admin/src/components/CustomRadioGroup/index.d.ts +1 -0
  139. package/dist/admin/src/components/DataManagerProvider/DataManagerProvider.d.ts +6 -0
  140. package/dist/admin/src/components/DataManagerProvider/constants.d.ts +17 -0
  141. package/dist/admin/src/components/DataManagerProvider/reducer.d.ts +12 -0
  142. package/dist/admin/src/components/DataManagerProvider/selectors.d.ts +17 -0
  143. package/dist/admin/src/components/DataManagerProvider/utils/cleanData.d.ts +23 -0
  144. package/dist/admin/src/components/DataManagerProvider/utils/createDataObject.d.ts +2 -0
  145. package/dist/admin/src/components/DataManagerProvider/utils/createModifiedDataSchema.d.ts +6 -0
  146. package/dist/admin/src/components/DataManagerProvider/utils/formatSchemas.d.ts +6 -0
  147. package/dist/admin/src/components/DataManagerProvider/utils/retrieveComponentsFromSchema.d.ts +4 -0
  148. package/dist/admin/src/components/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.d.ts +4 -0
  149. package/dist/admin/src/components/DataManagerProvider/utils/retrieveNestedComponents.d.ts +1 -0
  150. package/dist/admin/src/components/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.d.ts +1 -0
  151. package/dist/admin/src/components/DataManagerProvider/utils/serverRestartWatcher.d.ts +6 -0
  152. package/dist/admin/src/components/DataManagerProvider/utils/validateSchema.d.ts +1 -0
  153. package/dist/admin/src/components/DisplayedType.d.ts +7 -0
  154. package/dist/admin/src/components/DraftAndPublishToggle.d.ts +27 -0
  155. package/dist/admin/src/components/DynamicZoneList.d.ts +10 -0
  156. package/dist/admin/src/components/FormModal/FormModal.d.ts +1 -0
  157. package/dist/admin/src/components/FormModal/attributes/advancedForm.d.ts +416 -0
  158. package/dist/admin/src/components/FormModal/attributes/attributeOptions.d.ts +90 -0
  159. package/dist/admin/src/components/FormModal/attributes/baseForm.d.ts +376 -0
  160. package/dist/admin/src/components/FormModal/attributes/commonBaseForm.d.ts +17 -0
  161. package/dist/admin/src/components/FormModal/attributes/form.d.ts +792 -0
  162. package/dist/admin/src/components/FormModal/attributes/nameField.d.ts +12 -0
  163. package/dist/admin/src/components/FormModal/attributes/types.d.ts +325 -0
  164. package/dist/admin/src/components/FormModal/attributes/validation/common.d.ts +29 -0
  165. package/dist/admin/src/components/FormModal/category/createCategorySchema.d.ts +5 -0
  166. package/dist/admin/src/components/FormModal/category/form.d.ts +20 -0
  167. package/dist/admin/src/components/FormModal/category/regex.d.ts +1 -0
  168. package/dist/admin/src/components/FormModal/component/componentField.d.ts +20 -0
  169. package/dist/admin/src/components/FormModal/component/componentForm.d.ts +25 -0
  170. package/dist/admin/src/components/FormModal/component/createComponentSchema.d.ts +10 -0
  171. package/dist/admin/src/components/FormModal/constants.d.ts +12 -0
  172. package/dist/admin/src/components/FormModal/contentType/contentTypeForm.d.ts +116 -0
  173. package/dist/admin/src/components/FormModal/contentType/createContentTypeSchema.d.ts +24 -0
  174. package/dist/admin/src/components/FormModal/dynamiczoneForm.d.ts +68 -0
  175. package/dist/admin/src/components/FormModal/forms/forms.d.ts +207 -0
  176. package/dist/admin/src/components/FormModal/forms/utils/addItemsToFormSection.d.ts +38 -0
  177. package/dist/admin/src/components/FormModal/forms/utils/createCollectionName.d.ts +2 -0
  178. package/dist/admin/src/components/FormModal/forms/utils/getUsedAttributeNames.d.ts +11 -0
  179. package/dist/admin/src/components/FormModal/reducer.d.ts +4 -0
  180. package/dist/admin/src/components/FormModal/selectors.d.ts +16 -0
  181. package/dist/admin/src/components/FormModal/utils/canEditContentType.d.ts +18 -0
  182. package/dist/admin/src/components/FormModal/utils/createUid.d.ts +4 -0
  183. package/dist/admin/src/components/FormModal/utils/customFieldDefaultOptionsReducer.d.ts +1 -0
  184. package/dist/admin/src/components/FormModal/utils/getAttributesToDisplay.d.ts +3 -0
  185. package/dist/admin/src/components/FormModal/utils/getFormInputNames.d.ts +1 -0
  186. package/dist/admin/src/components/FormModal/utils/relations.d.ts +4 -0
  187. package/dist/admin/src/components/FormModalEndActions.d.ts +42 -0
  188. package/dist/admin/src/components/FormModalHeader.d.ts +18 -0
  189. package/dist/admin/src/components/FormModalNavigationProvider/FormModalNavigationProvider.d.ts +22 -0
  190. package/dist/admin/src/components/FormModalNavigationProvider/constants.d.ts +16 -0
  191. package/dist/admin/src/components/FormModalSubHeader.d.ts +22 -0
  192. package/dist/admin/src/components/GenericInputs.d.ts +57 -0
  193. package/dist/admin/src/components/IconPicker/IconPicker.d.ts +13 -0
  194. package/dist/admin/src/components/IconPicker/constants.d.ts +5 -0
  195. package/dist/admin/src/components/IconPicker/index.d.ts +1 -0
  196. package/dist/admin/src/components/List.d.ts +18 -0
  197. package/dist/admin/src/components/ListRow.d.ts +22 -0
  198. package/dist/admin/src/components/NestedFooter.d.ts +9 -0
  199. package/dist/admin/src/components/PluralName.d.ts +22 -0
  200. package/dist/admin/src/components/Relation/Relation.d.ts +9 -0
  201. package/dist/admin/src/components/Relation/RelationField/RelationField.d.ts +13 -0
  202. package/dist/admin/src/components/Relation/RelationField/RelationTargetPicker/RelationTargetPicker.d.ts +6 -0
  203. package/dist/admin/src/components/Relation/RelationNaturePicker/Components.d.ts +14 -0
  204. package/dist/admin/src/components/Relation/RelationNaturePicker/RelationNaturePicker.d.ts +8 -0
  205. package/dist/admin/src/components/SelectCategory.d.ts +19 -0
  206. package/dist/admin/src/components/SelectComponent.d.ts +19 -0
  207. package/dist/admin/src/components/SelectComponents.d.ts +19 -0
  208. package/dist/admin/src/components/SelectDateType.d.ts +38 -0
  209. package/dist/admin/src/components/SelectNumber.d.ts +42 -0
  210. package/dist/admin/src/components/SingularName.d.ts +17 -0
  211. package/dist/admin/src/components/TabForm.d.ts +9 -0
  212. package/dist/admin/src/components/TextareaEnum.d.ts +20 -0
  213. package/dist/admin/src/components/Tr.d.ts +5 -0
  214. package/dist/admin/src/components/UpperFirst.d.ts +3 -0
  215. package/dist/admin/src/constants.d.ts +6 -0
  216. package/dist/admin/src/contexts/DataManagerContext.d.ts +41 -0
  217. package/dist/admin/src/contexts/FormModalNavigationContext.d.ts +38 -0
  218. package/dist/admin/src/hooks/useDataManager.d.ts +1 -0
  219. package/dist/admin/src/hooks/useFormModalNavigation.d.ts +1 -0
  220. package/dist/admin/src/icons/Curve.d.ts +5 -0
  221. package/dist/admin/src/index.d.ts +16 -0
  222. package/dist/admin/src/pages/App/index.d.ts +2 -0
  223. package/dist/admin/src/pages/ListView/LinkToCMSettingsView.d.ts +10 -0
  224. package/dist/admin/src/pages/ListView/ListView.d.ts +2 -0
  225. package/dist/admin/src/pages/RecursivePath/RecursivePath.d.ts +1 -0
  226. package/dist/admin/src/pluginId.d.ts +1 -0
  227. package/dist/admin/src/reducers.d.ts +3 -0
  228. package/dist/admin/src/types.d.ts +57 -0
  229. package/dist/admin/src/utils/findAttribute.d.ts +2 -0
  230. package/dist/admin/src/utils/formAPI.d.ts +1 -0
  231. package/dist/admin/src/utils/getAttributeDisplayedType.d.ts +1 -0
  232. package/dist/admin/src/utils/getRelationType.d.ts +6 -0
  233. package/dist/admin/src/utils/getTrad.d.ts +1 -0
  234. package/dist/admin/src/utils/getYupInnerErrors.d.ts +7 -0
  235. package/dist/admin/src/utils/index.d.ts +2 -0
  236. package/dist/admin/src/utils/isAllowedContentTypesForRelations.d.ts +2 -0
  237. package/dist/admin/src/utils/makeUnique.d.ts +2 -0
  238. package/dist/admin/src/utils/nameToSlug.d.ts +1 -0
  239. package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
  240. package/dist/admin/src/utils/startsWithANumber.d.ts +1 -0
  241. package/dist/admin/src/utils/toRegressedEnumValue.d.ts +1 -0
  242. package/dist/server/index.js +2312 -0
  243. package/dist/server/index.js.map +1 -0
  244. package/dist/server/index.mjs +2291 -0
  245. package/dist/server/index.mjs.map +1 -0
  246. package/dist/server/src/bootstrap.d.ts +6 -0
  247. package/dist/server/src/bootstrap.d.ts.map +1 -0
  248. package/dist/server/src/config.d.ts +6 -0
  249. package/dist/server/src/config.d.ts.map +1 -0
  250. package/dist/server/src/controllers/builder.d.ts +6 -0
  251. package/dist/server/src/controllers/builder.d.ts.map +1 -0
  252. package/dist/server/src/controllers/component-categories.d.ts +7 -0
  253. package/dist/server/src/controllers/component-categories.d.ts.map +1 -0
  254. package/dist/server/src/controllers/components.d.ts +38 -0
  255. package/dist/server/src/controllers/components.d.ts.map +1 -0
  256. package/dist/server/src/controllers/content-types.d.ts +10 -0
  257. package/dist/server/src/controllers/content-types.d.ts.map +1 -0
  258. package/dist/server/src/controllers/index.d.ts +25 -0
  259. package/dist/server/src/controllers/index.d.ts.map +1 -0
  260. package/dist/server/src/controllers/validation/common.d.ts +25 -0
  261. package/dist/server/src/controllers/validation/common.d.ts.map +1 -0
  262. package/dist/server/src/controllers/validation/component-category.d.ts +5 -0
  263. package/dist/server/src/controllers/validation/component-category.d.ts.map +1 -0
  264. package/dist/server/src/controllers/validation/component.d.ts +25 -0
  265. package/dist/server/src/controllers/validation/component.d.ts.map +1 -0
  266. package/dist/server/src/controllers/validation/content-type.d.ts +36 -0
  267. package/dist/server/src/controllers/validation/content-type.d.ts.map +1 -0
  268. package/dist/server/src/controllers/validation/data-transform.d.ts +4 -0
  269. package/dist/server/src/controllers/validation/data-transform.d.ts.map +1 -0
  270. package/dist/server/src/controllers/validation/model-schema.d.ts +12 -0
  271. package/dist/server/src/controllers/validation/model-schema.d.ts.map +1 -0
  272. package/dist/server/src/controllers/validation/relations.d.ts +16 -0
  273. package/dist/server/src/controllers/validation/relations.d.ts.map +1 -0
  274. package/dist/server/src/controllers/validation/types.d.ts +9 -0
  275. package/dist/server/src/controllers/validation/types.d.ts.map +1 -0
  276. package/dist/server/src/index.d.ts +68 -0
  277. package/dist/server/src/index.d.ts.map +1 -0
  278. package/dist/server/src/routes/admin.d.ts +18 -0
  279. package/dist/server/src/routes/admin.d.ts.map +1 -0
  280. package/dist/server/src/routes/content-api.d.ts +10 -0
  281. package/dist/server/src/routes/content-api.d.ts.map +1 -0
  282. package/dist/server/src/routes/index.d.ts +28 -0
  283. package/dist/server/src/routes/index.d.ts.map +1 -0
  284. package/dist/server/src/services/api-handler.d.ts +15 -0
  285. package/dist/server/src/services/api-handler.d.ts.map +1 -0
  286. package/dist/server/src/services/builder.d.ts +5 -0
  287. package/dist/server/src/services/builder.d.ts.map +1 -0
  288. package/dist/server/src/services/component-categories.d.ts +13 -0
  289. package/dist/server/src/services/component-categories.d.ts.map +1 -0
  290. package/dist/server/src/services/components.d.ts +54 -0
  291. package/dist/server/src/services/components.d.ts.map +1 -0
  292. package/dist/server/src/services/constants.d.ts +19 -0
  293. package/dist/server/src/services/constants.d.ts.map +1 -0
  294. package/dist/server/src/services/content-types.d.ts +60 -0
  295. package/dist/server/src/services/content-types.d.ts.map +1 -0
  296. package/dist/server/src/services/index.d.ts +14 -0
  297. package/dist/server/src/services/index.d.ts.map +1 -0
  298. package/dist/server/src/services/schema-builder/component-builder.d.ts +39 -0
  299. package/dist/server/src/services/schema-builder/component-builder.d.ts.map +1 -0
  300. package/dist/server/src/services/schema-builder/content-type-builder.d.ts +38 -0
  301. package/dist/server/src/services/schema-builder/content-type-builder.d.ts.map +1 -0
  302. package/dist/server/src/services/schema-builder/index.d.ts +78 -0
  303. package/dist/server/src/services/schema-builder/index.d.ts.map +1 -0
  304. package/dist/server/src/services/schema-builder/schema-handler.d.ts +36 -0
  305. package/dist/server/src/services/schema-builder/schema-handler.d.ts.map +1 -0
  306. package/dist/server/src/utils/attributes.d.ts +192 -0
  307. package/dist/server/src/utils/attributes.d.ts.map +1 -0
  308. package/dist/server/src/utils/helpers.d.ts +3 -0
  309. package/dist/server/src/utils/helpers.d.ts.map +1 -0
  310. package/dist/server/src/utils/index.d.ts +15 -0
  311. package/dist/server/src/utils/index.d.ts.map +1 -0
  312. package/dist/server/src/utils/typeguards.d.ts +3 -0
  313. package/dist/server/src/utils/typeguards.d.ts.map +1 -0
  314. package/package.json +91 -3
  315. package/strapi-server.js +3 -0
@@ -0,0 +1,1183 @@
1
+ import { Layout } from "@strapi/icons";
2
+ import produce, { current, produce as produce$1 } from "immer";
3
+ import get from "lodash/get";
4
+ import set from "lodash/set";
5
+ import snakeCase from "lodash/snakeCase";
6
+ import pluralize from "pluralize";
7
+ import slugify from "@sindresorhus/slugify";
8
+ import cloneDeep from "lodash/cloneDeep";
9
+ import * as yup from "yup";
10
+ const __variableDynamicImportRuntimeHelper = (glob, path) => {
11
+ const v = glob[path];
12
+ if (v) {
13
+ return typeof v === "function" ? v() : Promise.resolve(v);
14
+ }
15
+ return new Promise((_, reject) => {
16
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
17
+ });
18
+ };
19
+ const name$1 = "@strapi/content-type-builder";
20
+ const version = "5.0.0-beta.6";
21
+ const description = "Create and manage content types";
22
+ const repository = {
23
+ type: "git",
24
+ url: "git://github.com/strapi/strapi.git"
25
+ };
26
+ const license = "SEE LICENSE IN LICENSE";
27
+ const author = {
28
+ name: "Strapi Solutions SAS",
29
+ email: "hi@strapi.io",
30
+ url: "https://strapi.io"
31
+ };
32
+ const maintainers = [
33
+ {
34
+ name: "Strapi Solutions SAS",
35
+ email: "hi@strapi.io",
36
+ url: "https://strapi.io"
37
+ }
38
+ ];
39
+ const exports = {
40
+ "./strapi-admin": {
41
+ types: "./dist/admin/src/index.d.ts",
42
+ source: "./admin/src/index.ts",
43
+ "import": "./dist/admin/index.mjs",
44
+ require: "./dist/admin/index.js",
45
+ "default": "./dist/admin/index.js"
46
+ },
47
+ "./strapi-server": {
48
+ types: "./dist/server/src/index.d.ts",
49
+ source: "./server/src/index.ts",
50
+ "import": "./dist/server/index.mjs",
51
+ require: "./dist/server/index.js",
52
+ "default": "./dist/server/index.js"
53
+ },
54
+ "./package.json": "./package.json"
55
+ };
56
+ const types = "./dist/index.d.ts";
57
+ const files = [
58
+ "dist/",
59
+ "strapi-server.js"
60
+ ];
61
+ const scripts = {
62
+ build: "pack-up build",
63
+ clean: "run -T rimraf ./dist",
64
+ lint: "run -T eslint .",
65
+ "test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
66
+ "test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
67
+ "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
68
+ "test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
69
+ "test:ts:back": "run -T tsc -p server/tsconfig.eslint.json",
70
+ "test:ts:front": "run -T tsc -p admin/tsconfig.json",
71
+ "test:unit": "run -T jest",
72
+ "test:unit:watch": "run -T jest --watch",
73
+ watch: "pack-up watch"
74
+ };
75
+ const dependencies = {
76
+ "@reduxjs/toolkit": "1.9.7",
77
+ "@sindresorhus/slugify": "1.1.0",
78
+ "@strapi/design-system": "2.0.0-beta.3",
79
+ "@strapi/generators": "5.0.0-beta.6",
80
+ "@strapi/icons": "2.0.0-beta.3",
81
+ "@strapi/utils": "5.0.0-beta.6",
82
+ "date-fns": "2.30.0",
83
+ "fs-extra": "11.2.0",
84
+ immer: "9.0.21",
85
+ lodash: "4.17.21",
86
+ pluralize: "8.0.0",
87
+ qs: "6.11.1",
88
+ "react-intl": "6.6.2",
89
+ "react-redux": "8.1.3",
90
+ yup: "0.32.9"
91
+ };
92
+ const devDependencies = {
93
+ "@strapi/admin": "5.0.0-beta.6",
94
+ "@strapi/pack-up": "5.0.0",
95
+ "@strapi/types": "5.0.0-beta.6",
96
+ "@testing-library/react": "14.0.0",
97
+ "@testing-library/user-event": "14.4.3",
98
+ "@types/fs-extra": "11.0.4",
99
+ "@types/pluralize": "0.0.30",
100
+ koa: "2.15.2",
101
+ "koa-body": "6.0.1",
102
+ react: "^18.2.0",
103
+ "react-dom": "^18.2.0",
104
+ "react-query": "3.39.3",
105
+ "react-router-dom": "6.22.3",
106
+ "styled-components": "6.1.8"
107
+ };
108
+ const peerDependencies = {
109
+ "@strapi/admin": "^5.0.0 || ^5.0.0-beta || ^5.0.0-alpha || ^5.0.0-rc",
110
+ react: "^17.0.0 || ^18.0.0",
111
+ "react-dom": "^17.0.0 || ^18.0.0",
112
+ "react-router-dom": "^6.0.0",
113
+ "styled-components": "^6.0.0"
114
+ };
115
+ const engines = {
116
+ node: ">=18.0.0 <=20.x.x",
117
+ npm: ">=6.0.0"
118
+ };
119
+ const strapi = {
120
+ name: "content-type-builder",
121
+ displayName: "Content Type Builder",
122
+ description: "Modelize the data structure of your API. Create new fields and relations in just a minute. The files are automatically created and updated in your project.",
123
+ kind: "plugin",
124
+ required: true
125
+ };
126
+ const pluginPkg = {
127
+ name: name$1,
128
+ version,
129
+ description,
130
+ repository,
131
+ license,
132
+ author,
133
+ maintainers,
134
+ exports,
135
+ types,
136
+ files,
137
+ scripts,
138
+ dependencies,
139
+ devDependencies,
140
+ peerDependencies,
141
+ engines,
142
+ strapi
143
+ };
144
+ const PERMISSIONS = {
145
+ // This permission regards the main component (App) and is used to tell
146
+ // If the plugin link should be displayed in the menu
147
+ // And also if the plugin is accessible. This use case is found when a user types the url of the
148
+ // plugin directly in the browser
149
+ main: [{ action: "plugin::content-type-builder.read", subject: null }]
150
+ };
151
+ const pluginId = pluginPkg.name.replace(/^@strapi\//i, "");
152
+ const getRelationType = (relation, targetAttribute) => {
153
+ const hasNotTargetAttribute = targetAttribute === void 0 || targetAttribute === null;
154
+ if (relation === "oneToOne" && hasNotTargetAttribute) {
155
+ return "oneWay";
156
+ }
157
+ if (relation === "oneToMany" && hasNotTargetAttribute) {
158
+ return "manyWay";
159
+ }
160
+ return relation;
161
+ };
162
+ const makeUnique = (array) => [...new Set(array)];
163
+ const ADD_ATTRIBUTE = "ContentTypeBuilder/DataManagerProvider/ADD_ATTRIBUTE";
164
+ const ADD_CUSTOM_FIELD_ATTRIBUTE = "ContentTypeBuilder/DataManagerProvider/ADD_CUSTOM_FIELD_ATTRIBUTE";
165
+ const ADD_CREATED_COMPONENT_TO_DYNAMIC_ZONE = "ContentTypeBuilder/DataManagerProvider/ADD_CREATED_COMPONENT_TO_DYNAMIC_ZONE";
166
+ const CHANGE_DYNAMIC_ZONE_COMPONENTS = "ContentTypeBuilder/DataManagerProvider/CHANGE_DYNAMIC_ZONE_COMPONENTS";
167
+ const CREATE_SCHEMA = "ContentTypeBuilder/DataManagerProvider/CREATE_SCHEMA";
168
+ const CREATE_COMPONENT_SCHEMA = "ContentTypeBuilder/DataManagerProvider/CREATE_COMPONENT_SCHEMA";
169
+ const DELETE_NOT_SAVED_TYPE = "ContentTypeBuilder/DataManagerProvider/DELETE_NOT_SAVED_TYPE";
170
+ const EDIT_ATTRIBUTE = "ContentTypeBuilder/DataManagerProvider/EDIT_ATTRIBUTE";
171
+ const EDIT_CUSTOM_FIELD_ATTRIBUTE = "ContentTypeBuilder/DataManagerProvider/EDIT_CUSTOM_FIELD_ATTRIBUTE";
172
+ const GET_DATA_SUCCEEDED = "ContentTypeBuilder/DataManagerProvider/GET_DATA_SUCCEEDED";
173
+ const RELOAD_PLUGIN = "ContentTypeBuilder/DataManagerProvider/RELOAD_PLUGIN";
174
+ const REMOVE_FIELD_FROM_DISPLAYED_COMPONENT = "ContentTypeBuilder/DataManagerProvider/REMOVE_FIELD_FROM_DISPLAYED_COMPONENT";
175
+ const REMOVE_COMPONENT_FROM_DYNAMIC_ZONE = "ContentTypeBuilder/DataManagerProvider/REMOVE_COMPONENT_FROM_DYNAMIC_ZONE";
176
+ const REMOVE_FIELD = "ContentTypeBuilder/DataManagerProvider/REMOVE_FIELD";
177
+ const SET_MODIFIED_DATA = "ContentTypeBuilder/DataManagerProvider/SET_MODIFIED_DATA";
178
+ const UPDATE_SCHEMA = "ContentTypeBuilder/DataManagerProvider/UPDATE_SCHEMA";
179
+ const UPDATE_INITIAL_STATE = "ContentTypeBuilder/DataManagerProvider/UPDATE_INITIAL_STATE";
180
+ const retrieveComponentsFromSchema = (attributes, allComponentsData) => {
181
+ const allComponents = attributes.reduce((acc, current2) => {
182
+ const type = current2.type;
183
+ if (type === "component") {
184
+ const currentComponentName = current2.component;
185
+ acc.push(currentComponentName);
186
+ const currentComponentAttributes = get(
187
+ allComponentsData,
188
+ [currentComponentName, "schema", "attributes"],
189
+ []
190
+ );
191
+ acc.push(...retrieveComponentsFromSchema(currentComponentAttributes, allComponentsData));
192
+ }
193
+ if (type === "dynamiczone") {
194
+ const dynamicZoneComponents = current2.components;
195
+ const componentsFromDZComponents = dynamicZoneComponents.reduce((acc2, currentUid) => {
196
+ const compoAttrs = get(allComponentsData, [currentUid, "schema", "attributes"], []);
197
+ return [...acc2, ...retrieveComponentsFromSchema(compoAttrs, allComponentsData)];
198
+ }, []);
199
+ return [...acc, ...dynamicZoneComponents, ...componentsFromDZComponents];
200
+ }
201
+ return acc;
202
+ }, []);
203
+ return makeUnique(allComponents);
204
+ };
205
+ const initialState$1 = {
206
+ components: {},
207
+ contentTypes: {},
208
+ initialComponents: {},
209
+ initialContentTypes: {},
210
+ initialData: {},
211
+ modifiedData: {
212
+ components: {},
213
+ contentTypes: {}
214
+ },
215
+ reservedNames: {},
216
+ isLoading: true,
217
+ isLoadingForDataToBeSet: true
218
+ };
219
+ const ONE_SIDE_RELATIONS = ["oneWay", "manyWay"];
220
+ const getOppositeRelation = (originalRelation) => {
221
+ if (originalRelation === "manyToOne") {
222
+ return "oneToMany";
223
+ }
224
+ if (originalRelation === "oneToMany") {
225
+ return "manyToOne";
226
+ }
227
+ return originalRelation;
228
+ };
229
+ const findAttributeIndex = (schema, attributeToFind) => {
230
+ return schema.schema.attributes.findIndex(
231
+ ({ name: name2 }) => name2 === attributeToFind
232
+ );
233
+ };
234
+ const reducer$1 = (state = initialState$1, action) => produce(state, (draftState) => {
235
+ switch (action.type) {
236
+ case ADD_ATTRIBUTE: {
237
+ const {
238
+ attributeToSet: { name: name2, ...rest },
239
+ forTarget,
240
+ targetUid
241
+ } = action;
242
+ delete rest.createComponent;
243
+ const pathToDataToEdit = ["component", "contentType"].includes(forTarget) ? [forTarget] : [forTarget, targetUid];
244
+ const currentAttributes = get(
245
+ state,
246
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes"],
247
+ []
248
+ ).slice();
249
+ const updatedAttributes = [...currentAttributes, { ...rest, name: name2 }];
250
+ set(
251
+ draftState,
252
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes"],
253
+ updatedAttributes
254
+ );
255
+ if (action.shouldAddComponentToData) {
256
+ const componentToAddUID = rest.component;
257
+ const componentToAdd = state.components[componentToAddUID];
258
+ const isTemporaryComponent = componentToAdd?.isTemporary;
259
+ const hasComponentAlreadyBeenAdded = state.modifiedData.components?.[componentToAddUID] !== void 0;
260
+ if (isTemporaryComponent || hasComponentAlreadyBeenAdded) {
261
+ break;
262
+ }
263
+ if (!draftState.modifiedData.components) {
264
+ draftState.modifiedData.components = {};
265
+ }
266
+ draftState.modifiedData.components[componentToAddUID] = componentToAdd;
267
+ const nestedComponents = retrieveComponentsFromSchema(
268
+ componentToAdd.schema.attributes,
269
+ state.components
270
+ );
271
+ const nestedComponentsToAddInModifiedData = nestedComponents.filter(
272
+ (compoUID) => {
273
+ return get(state, ["modifiedData", "components", compoUID]) === void 0;
274
+ }
275
+ );
276
+ nestedComponentsToAddInModifiedData.forEach((compoUID) => {
277
+ const compoSchema = get(state, ["components", compoUID], {});
278
+ const isTemporary = compoSchema.isTemporary || false;
279
+ if (!isTemporary) {
280
+ if (!draftState.modifiedData.components) {
281
+ draftState.modifiedData.components = {};
282
+ }
283
+ draftState.modifiedData.components[compoUID] = compoSchema;
284
+ }
285
+ });
286
+ break;
287
+ }
288
+ const isCreatingRelationAttribute = rest.type === "relation";
289
+ if (isCreatingRelationAttribute) {
290
+ const target = rest.target;
291
+ const targetAttribute = rest.targetAttribute || null;
292
+ const relation = rest.relation;
293
+ const relationType = getRelationType(relation, targetAttribute);
294
+ const currentUid = get(state, ["modifiedData", ...pathToDataToEdit, "uid"]);
295
+ if (rest.type === "relation" && relationType !== "oneWay" && relationType !== "manyWay" && target === currentUid) {
296
+ const oppositeAttribute = {
297
+ name: targetAttribute,
298
+ relation: getOppositeRelation(relationType),
299
+ target,
300
+ targetAttribute: name2,
301
+ type: "relation"
302
+ };
303
+ if (rest.private) {
304
+ oppositeAttribute.private = rest.private;
305
+ }
306
+ const attributesToSet = [...updatedAttributes, oppositeAttribute];
307
+ set(
308
+ draftState,
309
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes"],
310
+ attributesToSet
311
+ );
312
+ }
313
+ }
314
+ break;
315
+ }
316
+ case ADD_CREATED_COMPONENT_TO_DYNAMIC_ZONE: {
317
+ const { dynamicZoneTarget, componentsToAdd } = action;
318
+ const dzAttributeIndex = findAttributeIndex(
319
+ state.modifiedData.contentType,
320
+ dynamicZoneTarget
321
+ );
322
+ componentsToAdd.forEach((componentUid) => {
323
+ if (!draftState.modifiedData.contentType?.schema.attributes[dzAttributeIndex].components) {
324
+ draftState.modifiedData.contentType.schema.attributes[dzAttributeIndex].components = [];
325
+ }
326
+ draftState.modifiedData.contentType.schema.attributes[dzAttributeIndex].components.push(
327
+ componentUid
328
+ );
329
+ });
330
+ break;
331
+ }
332
+ case ADD_CUSTOM_FIELD_ATTRIBUTE: {
333
+ const {
334
+ attributeToSet: { name: name2, ...rest },
335
+ forTarget,
336
+ targetUid
337
+ } = action;
338
+ const pathToDataToEdit = ["component", "contentType"].includes(forTarget) ? [forTarget] : [forTarget, targetUid];
339
+ const currentAttributes = get(
340
+ state,
341
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes"],
342
+ []
343
+ ).slice();
344
+ const updatedAttributes = [...currentAttributes, { ...rest, name: name2 }];
345
+ set(
346
+ draftState,
347
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes"],
348
+ updatedAttributes
349
+ );
350
+ break;
351
+ }
352
+ case CHANGE_DYNAMIC_ZONE_COMPONENTS: {
353
+ const { dynamicZoneTarget, newComponents } = action;
354
+ const dzAttributeIndex = findAttributeIndex(
355
+ state.modifiedData.contentType,
356
+ dynamicZoneTarget
357
+ );
358
+ const currentDZComponents = (state.modifiedData.contentType?.schema.attributes[dzAttributeIndex]).components;
359
+ const updatedComponents = makeUnique([...currentDZComponents, ...newComponents]);
360
+ (draftState.modifiedData.contentType?.schema.attributes[dzAttributeIndex]).components = updatedComponents;
361
+ const nestedComponents = retrieveComponentsFromSchema(
362
+ current(draftState.modifiedData.contentType.schema.attributes),
363
+ state.components
364
+ );
365
+ const nestedComponentsToAddInModifiedData = nestedComponents.filter((compoUID) => {
366
+ return get(state, ["modifiedData", "components", compoUID]) === void 0;
367
+ });
368
+ nestedComponentsToAddInModifiedData.forEach((compoUID) => {
369
+ const compoSchema = get(state, ["components", compoUID], {});
370
+ const isTemporary = compoSchema.isTemporary || false;
371
+ if (!isTemporary) {
372
+ if (!draftState.modifiedData.components) {
373
+ draftState.modifiedData.components = {};
374
+ }
375
+ draftState.modifiedData.components[compoUID] = compoSchema;
376
+ }
377
+ });
378
+ break;
379
+ }
380
+ case CREATE_COMPONENT_SCHEMA: {
381
+ const newSchema = {
382
+ uid: action.uid,
383
+ isTemporary: true,
384
+ category: action.componentCategory,
385
+ schema: {
386
+ ...action.data,
387
+ attributes: []
388
+ }
389
+ };
390
+ draftState.components[action.uid] = newSchema;
391
+ if (action.shouldAddComponentToData) {
392
+ draftState.modifiedData.components[action.uid] = newSchema;
393
+ }
394
+ break;
395
+ }
396
+ case CREATE_SCHEMA: {
397
+ const newSchema = {
398
+ uid: action.uid,
399
+ isTemporary: true,
400
+ schema: {
401
+ ...action.data,
402
+ attributes: []
403
+ }
404
+ };
405
+ draftState.contentTypes[action.uid] = newSchema;
406
+ break;
407
+ }
408
+ case EDIT_ATTRIBUTE: {
409
+ const {
410
+ attributeToSet: { name: name2, ...rest },
411
+ forTarget,
412
+ targetUid,
413
+ initialAttribute
414
+ } = action;
415
+ const initialAttributeName = initialAttribute.name;
416
+ const pathToDataToEdit = ["component", "contentType"].includes(forTarget) ? [forTarget] : [forTarget, targetUid];
417
+ const initialAttributeIndex = findAttributeIndex(
418
+ get(state, ["modifiedData", ...pathToDataToEdit]),
419
+ initialAttributeName
420
+ );
421
+ const isEditingRelation = rest.type === "relation";
422
+ if (!isEditingRelation) {
423
+ set(
424
+ draftState,
425
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes", initialAttributeIndex],
426
+ action.attributeToSet
427
+ );
428
+ break;
429
+ }
430
+ const updatedAttributes = get(state, [
431
+ "modifiedData",
432
+ ...pathToDataToEdit,
433
+ "schema",
434
+ "attributes"
435
+ ]).slice();
436
+ const toSet = {
437
+ name: name2,
438
+ relation: rest.relation,
439
+ target: rest.target,
440
+ targetAttribute: rest.targetAttribute,
441
+ type: "relation"
442
+ };
443
+ if (rest.private) {
444
+ toSet.private = rest.private;
445
+ }
446
+ if (rest.pluginOptions) {
447
+ toSet.pluginOptions = rest.pluginOptions;
448
+ }
449
+ const currentAttributeIndex = updatedAttributes.findIndex((value) => {
450
+ return value.name !== void 0 && value.name === initialAttribute.name;
451
+ });
452
+ if (currentAttributeIndex !== -1) {
453
+ updatedAttributes.splice(currentAttributeIndex, 1, toSet);
454
+ }
455
+ let oppositeAttributeNameToRemove = null;
456
+ let oppositeAttributeNameToUpdate = null;
457
+ let oppositeAttributeToCreate = null;
458
+ let initialOppositeAttribute = null;
459
+ const currentUid = get(state, ["modifiedData", ...pathToDataToEdit, "uid"]);
460
+ const didChangeTargetRelation = initialAttribute.target !== rest.target;
461
+ const didCreateInternalRelation = rest.target === currentUid;
462
+ const relationType = getRelationType(rest.relation, rest.targetAttribute);
463
+ const initialRelationType = getRelationType(
464
+ initialAttribute.relation,
465
+ initialAttribute.targetAttribute
466
+ );
467
+ const hadInternalRelation = initialAttribute.target === currentUid;
468
+ const didChangeRelationType = initialRelationType !== relationType;
469
+ const shouldRemoveOppositeAttributeBecauseOfTargetChange = didChangeTargetRelation && !didCreateInternalRelation && hadInternalRelation && isEditingRelation;
470
+ const shouldRemoveOppositeAttributeBecauseOfRelationTypeChange = didChangeRelationType && hadInternalRelation && ["oneWay", "manyWay"].includes(relationType) && isEditingRelation;
471
+ const shouldUpdateOppositeAttributeBecauseOfRelationTypeChange = !ONE_SIDE_RELATIONS.includes(initialRelationType) && !ONE_SIDE_RELATIONS.includes(relationType) && hadInternalRelation && didCreateInternalRelation && isEditingRelation;
472
+ const shouldCreateOppositeAttributeBecauseOfRelationTypeChange = ONE_SIDE_RELATIONS.includes(initialRelationType) && !ONE_SIDE_RELATIONS.includes(relationType) && hadInternalRelation && didCreateInternalRelation && isEditingRelation;
473
+ const shouldCreateOppositeAttributeBecauseOfTargetChange = didChangeTargetRelation && didCreateInternalRelation && !ONE_SIDE_RELATIONS.includes(relationType);
474
+ if (shouldRemoveOppositeAttributeBecauseOfTargetChange || shouldRemoveOppositeAttributeBecauseOfRelationTypeChange) {
475
+ oppositeAttributeNameToRemove = initialAttribute.targetAttribute;
476
+ }
477
+ if (oppositeAttributeNameToRemove) {
478
+ const indexToRemove = updatedAttributes.findIndex(
479
+ (value) => value.name === oppositeAttributeNameToRemove
480
+ );
481
+ updatedAttributes.splice(indexToRemove, 1);
482
+ }
483
+ if (!shouldRemoveOppositeAttributeBecauseOfTargetChange) {
484
+ const initialTargetContentType = get(state, [
485
+ "initialContentTypes",
486
+ initialAttribute.target
487
+ ]);
488
+ if (initialTargetContentType) {
489
+ const oppositeAttributeIndex = findAttributeIndex(
490
+ initialTargetContentType,
491
+ initialAttribute.targetAttribute
492
+ );
493
+ initialOppositeAttribute = get(state, [
494
+ "initialContentTypes",
495
+ initialAttribute.target,
496
+ "schema",
497
+ "attributes",
498
+ oppositeAttributeIndex
499
+ ]);
500
+ }
501
+ }
502
+ if (shouldCreateOppositeAttributeBecauseOfRelationTypeChange || shouldCreateOppositeAttributeBecauseOfTargetChange) {
503
+ oppositeAttributeToCreate = {
504
+ name: rest.targetAttribute,
505
+ relation: getOppositeRelation(relationType),
506
+ target: rest.target,
507
+ targetAttribute: name2,
508
+ type: "relation"
509
+ };
510
+ if (rest.private) {
511
+ oppositeAttributeToCreate.private = rest.private;
512
+ }
513
+ if (initialOppositeAttribute && initialOppositeAttribute.pluginOptions) {
514
+ oppositeAttributeToCreate.pluginOptions = initialOppositeAttribute.pluginOptions;
515
+ }
516
+ const indexOfInitialAttribute = updatedAttributes.findIndex(
517
+ ({ name: name22 }) => name22 === initialAttribute.name
518
+ );
519
+ const indexOfUpdatedAttribute = updatedAttributes.findIndex(
520
+ ({ name: attrName }) => name2 === attrName
521
+ );
522
+ const indexToInsert = (indexOfInitialAttribute === -1 ? indexOfUpdatedAttribute : indexOfInitialAttribute) + 1;
523
+ updatedAttributes.splice(indexToInsert, 0, oppositeAttributeToCreate);
524
+ }
525
+ if (shouldUpdateOppositeAttributeBecauseOfRelationTypeChange) {
526
+ oppositeAttributeNameToUpdate = initialAttribute.targetAttribute;
527
+ oppositeAttributeToCreate = {
528
+ name: rest.targetAttribute,
529
+ relation: getOppositeRelation(relationType),
530
+ target: rest.target,
531
+ targetAttribute: name2,
532
+ type: "relation"
533
+ };
534
+ if (rest.private) {
535
+ oppositeAttributeToCreate.private = rest.private;
536
+ }
537
+ if (initialOppositeAttribute && initialOppositeAttribute.pluginOptions) {
538
+ oppositeAttributeToCreate.pluginOptions = initialOppositeAttribute.pluginOptions;
539
+ }
540
+ if (oppositeAttributeNameToUpdate) {
541
+ const indexToUpdate = updatedAttributes.findIndex(
542
+ ({ name: name22 }) => name22 === oppositeAttributeNameToUpdate
543
+ );
544
+ updatedAttributes.splice(indexToUpdate, 1, oppositeAttributeToCreate);
545
+ }
546
+ }
547
+ set(
548
+ draftState,
549
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes"],
550
+ updatedAttributes
551
+ );
552
+ break;
553
+ }
554
+ case EDIT_CUSTOM_FIELD_ATTRIBUTE: {
555
+ const { forTarget, targetUid, initialAttribute, attributeToSet } = action;
556
+ const initialAttributeName = initialAttribute.name;
557
+ const pathToDataToEdit = ["component", "contentType"].includes(forTarget) ? [forTarget] : [forTarget, targetUid];
558
+ const initialAttributeIndex = findAttributeIndex(
559
+ get(state, ["modifiedData", ...pathToDataToEdit]),
560
+ initialAttributeName
561
+ );
562
+ set(
563
+ draftState,
564
+ ["modifiedData", ...pathToDataToEdit, "schema", "attributes", initialAttributeIndex],
565
+ attributeToSet
566
+ );
567
+ break;
568
+ }
569
+ case GET_DATA_SUCCEEDED: {
570
+ draftState.components = action.components;
571
+ draftState.initialComponents = action.components;
572
+ draftState.initialContentTypes = action.contentTypes;
573
+ draftState.contentTypes = action.contentTypes;
574
+ draftState.reservedNames = action.reservedNames;
575
+ draftState.isLoading = false;
576
+ break;
577
+ }
578
+ case UPDATE_INITIAL_STATE: {
579
+ draftState.initialData = draftState.modifiedData;
580
+ break;
581
+ }
582
+ case UPDATE_INITIAL_STATE: {
583
+ draftState.initialData = draftState.modifiedData;
584
+ break;
585
+ }
586
+ case DELETE_NOT_SAVED_TYPE: {
587
+ draftState.contentTypes = state.initialContentTypes;
588
+ draftState.components = state.initialComponents;
589
+ break;
590
+ }
591
+ case RELOAD_PLUGIN: {
592
+ return initialState$1;
593
+ }
594
+ case REMOVE_COMPONENT_FROM_DYNAMIC_ZONE: {
595
+ const dzAttributeIndex = findAttributeIndex(state.modifiedData.contentType, action.dzName);
596
+ draftState.modifiedData.contentType.schema.attributes[dzAttributeIndex].components.splice(
597
+ action.componentToRemoveIndex,
598
+ 1
599
+ );
600
+ break;
601
+ }
602
+ case REMOVE_FIELD: {
603
+ const { mainDataKey, attributeToRemoveName } = action;
604
+ const pathToAttributes = ["modifiedData", mainDataKey, "schema", "attributes"];
605
+ const attributeToRemoveIndex = findAttributeIndex(
606
+ state.modifiedData[mainDataKey],
607
+ attributeToRemoveName
608
+ );
609
+ const pathToAttributeToRemove = [...pathToAttributes, attributeToRemoveIndex];
610
+ const attributeToRemoveData = get(state, pathToAttributeToRemove);
611
+ const isRemovingRelationAttribute = attributeToRemoveData.type === "relation";
612
+ const canTheAttributeToRemoveHaveARelationWithItself = mainDataKey === "contentType";
613
+ if (isRemovingRelationAttribute && canTheAttributeToRemoveHaveARelationWithItself) {
614
+ const { target, relation, targetAttribute } = attributeToRemoveData;
615
+ const relationType = getRelationType(relation, targetAttribute);
616
+ const uid = state.modifiedData.contentType?.uid;
617
+ const shouldRemoveOppositeAttribute = target === uid && !ONE_SIDE_RELATIONS.includes(relationType);
618
+ if (shouldRemoveOppositeAttribute) {
619
+ const attributes = state.modifiedData[mainDataKey]?.schema.attributes.slice();
620
+ const nextAttributes = attributes.filter((attribute) => {
621
+ if (attribute.name === attributeToRemoveName) {
622
+ return false;
623
+ }
624
+ if (attribute.target === uid && attribute.targetAttribute === attributeToRemoveName) {
625
+ return false;
626
+ }
627
+ return true;
628
+ });
629
+ draftState.modifiedData[mainDataKey].schema.attributes = nextAttributes;
630
+ break;
631
+ }
632
+ }
633
+ const uidFieldsToUpdate = state.modifiedData[mainDataKey].schema.attributes.slice().reduce((acc, current2) => {
634
+ if (current2.type !== "uid") {
635
+ return acc;
636
+ }
637
+ if (current2.targetField !== attributeToRemoveName) {
638
+ return acc;
639
+ }
640
+ acc.push(current2.name);
641
+ return acc;
642
+ }, []);
643
+ uidFieldsToUpdate.forEach((fieldName) => {
644
+ const fieldIndex = findAttributeIndex(state.modifiedData[mainDataKey], fieldName);
645
+ delete draftState.modifiedData[mainDataKey]?.schema.attributes[fieldIndex].targetField;
646
+ });
647
+ draftState.modifiedData[mainDataKey]?.schema.attributes.splice(attributeToRemoveIndex, 1);
648
+ break;
649
+ }
650
+ case REMOVE_FIELD_FROM_DISPLAYED_COMPONENT: {
651
+ const { attributeToRemoveName, componentUid } = action;
652
+ const attributeToRemoveIndex = findAttributeIndex(
653
+ state.modifiedData.components?.[componentUid],
654
+ attributeToRemoveName
655
+ );
656
+ draftState.modifiedData.components?.[componentUid]?.schema?.attributes?.splice(
657
+ attributeToRemoveIndex,
658
+ 1
659
+ );
660
+ break;
661
+ }
662
+ case SET_MODIFIED_DATA: {
663
+ draftState.isLoadingForDataToBeSet = false;
664
+ draftState.initialData = action.schemaToSet;
665
+ draftState.modifiedData = action.schemaToSet;
666
+ if (!action.hasJustCreatedSchema) {
667
+ draftState.components = state.initialComponents;
668
+ draftState.contentTypes = state.initialContentTypes;
669
+ }
670
+ break;
671
+ }
672
+ case UPDATE_SCHEMA: {
673
+ const {
674
+ data: { displayName, category, icon, kind },
675
+ schemaType,
676
+ uid
677
+ } = action;
678
+ draftState.modifiedData[schemaType].schema.displayName = displayName;
679
+ if (action.schemaType === "component") {
680
+ draftState.modifiedData.component.category = category;
681
+ draftState.modifiedData.component.schema.icon = icon;
682
+ const addedComponent = current(draftState.modifiedData.component);
683
+ draftState.components[uid] = addedComponent;
684
+ break;
685
+ }
686
+ draftState.modifiedData.contentType.schema.kind = kind;
687
+ break;
688
+ }
689
+ default:
690
+ return draftState;
691
+ }
692
+ });
693
+ const nameToSlug = (name2) => slugify(name2, { separator: "-" });
694
+ const ON_CHANGE = "ContentTypeBuilder/FormModal/ON_CHANGE";
695
+ const ON_CHANGE_RELATION_TARGET = "ContentTypeBuilder/FormModal/ON_CHANGE_RELATION_TARGET";
696
+ const ON_CHANGE_RELATION_TYPE = "ContentTypeBuilder/FormModal/ON_CHANGE_RELATION_TYPE";
697
+ const RESET_PROPS = "ContentTypeBuilder/FormModal/RESET_PROPS";
698
+ const RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO = "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO";
699
+ const RESET_PROPS_AND_SAVE_CURRENT_DATA = "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SAVE_CURRENT_DATA";
700
+ const RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ = "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ";
701
+ const SET_DATA_TO_EDIT = "ContentTypeBuilder/FormModal/SET_DATA_TO_EDIT";
702
+ const SET_ATTRIBUTE_DATA_SCHEMA = "ContentTypeBuilder/FormModal/SET_ATTRIBUTE_DATA_SCHEMA";
703
+ const SET_CUSTOM_FIELD_DATA_SCHEMA = "ContentTypeBuilder/FormModal/SET_CUSTOM_FIELD_DATA_SCHEMA";
704
+ const SET_DYNAMIC_ZONE_DATA_SCHEMA = "ContentTypeBuilder/FormModal/SET_DYNAMIC_ZONE_DATA_SCHEMA";
705
+ const SET_ERRORS = "ContentTypeBuilder/FormModal/SET_ERRORS";
706
+ const createUid = (name2) => {
707
+ const modelName = nameToSlug(name2);
708
+ return `api::${modelName}.${modelName}`;
709
+ };
710
+ const createComponentUid = (name2, category) => {
711
+ return `${nameToSlug(category)}.${nameToSlug(name2)}`;
712
+ };
713
+ const customFieldDefaultOptionsReducer = (acc, option) => {
714
+ if (option.items) {
715
+ return option.items.reduce(customFieldDefaultOptionsReducer, acc);
716
+ }
717
+ if ("defaultValue" in option) {
718
+ const { name: name2, defaultValue } = option;
719
+ acc.push({ name: name2, defaultValue });
720
+ }
721
+ return acc;
722
+ };
723
+ const shouldPluralizeName = (nature) => ["manyToMany", "oneToMany", "manyWay"].includes(nature) ? 2 : 1;
724
+ const shouldPluralizeTargetAttribute = (nature) => ["manyToMany", "manyToOne"].includes(nature) ? 2 : 1;
725
+ const initialState = {
726
+ formErrors: {},
727
+ modifiedData: {},
728
+ initialData: {},
729
+ componentToCreate: {},
730
+ isCreatingComponentWhileAddingAField: false
731
+ };
732
+ const reducer = (state = initialState, action) => (
733
+ // eslint-disable-next-line consistent-return
734
+ produce$1(state, (draftState) => {
735
+ switch (action.type) {
736
+ case ON_CHANGE: {
737
+ const { keys, value } = action;
738
+ const obj = state.modifiedData;
739
+ const hasDefaultValue = Boolean(obj.default);
740
+ if (hasDefaultValue && keys.length === 1 && keys.includes("type")) {
741
+ const previousType = obj.type;
742
+ if (previousType && ["date", "datetime", "time"].includes(previousType)) {
743
+ delete draftState.modifiedData.default;
744
+ }
745
+ }
746
+ set(draftState, ["modifiedData", ...keys], value);
747
+ break;
748
+ }
749
+ case ON_CHANGE_RELATION_TARGET: {
750
+ const {
751
+ target: {
752
+ oneThatIsCreatingARelationWithAnother,
753
+ selectedContentTypeFriendlyName,
754
+ targetContentTypeAllowedRelations,
755
+ value
756
+ }
757
+ } = action;
758
+ let didChangeRelationTypeBecauseOfRestrictedRelation = false;
759
+ let changedRelationType = null;
760
+ set(draftState, ["modifiedData", "target"], value);
761
+ const modifiedData = state.modifiedData;
762
+ if (Array.isArray(targetContentTypeAllowedRelations)) {
763
+ const currentRelationType = getRelationType(
764
+ modifiedData.relation,
765
+ modifiedData.targetAttribute
766
+ );
767
+ if (!targetContentTypeAllowedRelations.includes(currentRelationType)) {
768
+ const relationToSet = targetContentTypeAllowedRelations[0];
769
+ didChangeRelationTypeBecauseOfRestrictedRelation = true;
770
+ changedRelationType = relationToSet;
771
+ if (relationToSet === "oneWay") {
772
+ set(draftState, ["modifiedData", "relation"], "oneToOne");
773
+ } else if (relationToSet === "manyWay") {
774
+ set(draftState, ["modifiedData", "relation"], "oneToMany");
775
+ } else {
776
+ set(draftState, ["modifiedData", "relation"], relationToSet);
777
+ }
778
+ }
779
+ }
780
+ let nameToSet;
781
+ if (didChangeRelationTypeBecauseOfRestrictedRelation) {
782
+ nameToSet = pluralize(
783
+ snakeCase(nameToSlug(selectedContentTypeFriendlyName)),
784
+ shouldPluralizeName(changedRelationType)
785
+ );
786
+ } else {
787
+ nameToSet = pluralize(
788
+ snakeCase(nameToSlug(selectedContentTypeFriendlyName)),
789
+ shouldPluralizeName(modifiedData.relation)
790
+ );
791
+ }
792
+ set(draftState, ["modifiedData", "name"], nameToSet);
793
+ const currentTargetAttribute = state.modifiedData.targetAttribute;
794
+ if (currentTargetAttribute === null) {
795
+ break;
796
+ }
797
+ if (didChangeRelationTypeBecauseOfRestrictedRelation && ["oneWay", "manyWay"].includes(changedRelationType)) {
798
+ set(draftState, ["modifiedData", "targetAttribute"], null);
799
+ break;
800
+ }
801
+ const targetAttributeToSet = pluralize(
802
+ snakeCase(nameToSlug(oneThatIsCreatingARelationWithAnother)),
803
+ shouldPluralizeTargetAttribute(modifiedData.relation)
804
+ );
805
+ set(draftState, ["modifiedData", "targetAttribute"], targetAttributeToSet);
806
+ break;
807
+ }
808
+ case ON_CHANGE_RELATION_TYPE: {
809
+ const {
810
+ target: { oneThatIsCreatingARelationWithAnother, value }
811
+ } = action;
812
+ const currentName = state.modifiedData.name;
813
+ if (!["oneWay", "manyWay"].includes(value)) {
814
+ set(draftState, ["modifiedData", "relation"], value);
815
+ const currentTargetAttribute = state.modifiedData.targetAttribute;
816
+ set(
817
+ draftState,
818
+ ["modifiedData", "name"],
819
+ pluralize(snakeCase(nameToSlug(currentName)), shouldPluralizeName(value))
820
+ );
821
+ set(
822
+ draftState,
823
+ ["modifiedData", "targetAttribute"],
824
+ pluralize(
825
+ currentTargetAttribute || snakeCase(nameToSlug(oneThatIsCreatingARelationWithAnother)),
826
+ shouldPluralizeTargetAttribute(value)
827
+ )
828
+ );
829
+ break;
830
+ }
831
+ if (value === "oneWay") {
832
+ set(draftState, ["modifiedData", "relation"], "oneToOne");
833
+ set(draftState, ["modifiedData", "targetAttribute"], null);
834
+ set(draftState, ["modifiedData", "name"], pluralize(snakeCase(currentName), 1));
835
+ break;
836
+ }
837
+ set(draftState, ["modifiedData", "relation"], "oneToMany");
838
+ set(draftState, ["modifiedData", "targetAttribute"], null);
839
+ set(draftState, ["modifiedData", "name"], pluralize(snakeCase(currentName), 2));
840
+ break;
841
+ }
842
+ case RESET_PROPS:
843
+ return initialState;
844
+ case RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO: {
845
+ const nextState = {
846
+ ...initialState,
847
+ modifiedData: {
848
+ type: "component",
849
+ repeatable: true,
850
+ ...action.options
851
+ }
852
+ };
853
+ return nextState;
854
+ }
855
+ case RESET_PROPS_AND_SAVE_CURRENT_DATA: {
856
+ const componentToCreate = state.modifiedData.componentToCreate;
857
+ const modifiedData = {
858
+ displayName: componentToCreate.displayName,
859
+ type: "component",
860
+ repeatable: false,
861
+ ...action.options,
862
+ component: createComponentUid(componentToCreate.displayName, componentToCreate.category)
863
+ };
864
+ const nextState = {
865
+ ...initialState,
866
+ componentToCreate,
867
+ modifiedData,
868
+ isCreatingComponentWhileAddingAField: state.modifiedData.createComponent
869
+ };
870
+ return nextState;
871
+ }
872
+ case RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ: {
873
+ const createdDZ = state.modifiedData;
874
+ const dataToSet = {
875
+ ...createdDZ,
876
+ createComponent: true,
877
+ componentToCreate: { type: "component" }
878
+ };
879
+ return { ...initialState, modifiedData: dataToSet };
880
+ }
881
+ case SET_DATA_TO_EDIT: {
882
+ draftState.modifiedData = action.data;
883
+ draftState.initialData = action.data;
884
+ break;
885
+ }
886
+ case SET_ATTRIBUTE_DATA_SCHEMA: {
887
+ const {
888
+ attributeType,
889
+ isEditing,
890
+ modifiedDataToSetForEditing,
891
+ nameToSetForRelation,
892
+ targetUid,
893
+ step,
894
+ options = {}
895
+ } = action;
896
+ if (isEditing) {
897
+ draftState.modifiedData = modifiedDataToSetForEditing;
898
+ draftState.initialData = modifiedDataToSetForEditing;
899
+ break;
900
+ }
901
+ let dataToSet;
902
+ if (attributeType === "component") {
903
+ if (step === "1") {
904
+ dataToSet = {
905
+ type: "component",
906
+ createComponent: true,
907
+ componentToCreate: { type: "component" }
908
+ };
909
+ } else {
910
+ dataToSet = {
911
+ ...options,
912
+ type: "component",
913
+ repeatable: true
914
+ };
915
+ }
916
+ } else if (attributeType === "dynamiczone") {
917
+ dataToSet = {
918
+ ...options,
919
+ type: "dynamiczone",
920
+ components: []
921
+ };
922
+ } else if (attributeType === "text") {
923
+ dataToSet = { ...options, type: "string" };
924
+ } else if (attributeType === "number" || attributeType === "date") {
925
+ dataToSet = options;
926
+ } else if (attributeType === "media") {
927
+ dataToSet = {
928
+ allowedTypes: ["images", "files", "videos", "audios"],
929
+ type: "media",
930
+ multiple: true,
931
+ ...options
932
+ };
933
+ } else if (attributeType === "enumeration") {
934
+ dataToSet = { ...options, type: "enumeration", enum: [] };
935
+ } else if (attributeType === "relation") {
936
+ dataToSet = {
937
+ name: snakeCase(nameToSetForRelation),
938
+ relation: "oneToOne",
939
+ targetAttribute: null,
940
+ target: targetUid,
941
+ type: "relation"
942
+ };
943
+ } else {
944
+ dataToSet = { ...options, type: attributeType, default: null };
945
+ }
946
+ draftState.modifiedData = dataToSet;
947
+ break;
948
+ }
949
+ case SET_CUSTOM_FIELD_DATA_SCHEMA: {
950
+ const { customField, isEditing, modifiedDataToSetForEditing, options = {} } = action;
951
+ if (isEditing) {
952
+ draftState.modifiedData = modifiedDataToSetForEditing;
953
+ draftState.initialData = modifiedDataToSetForEditing;
954
+ break;
955
+ }
956
+ draftState.modifiedData = { ...options, type: customField.type };
957
+ const allOptions = [
958
+ ...customField?.options?.base || [],
959
+ ...customField?.options?.advanced || []
960
+ ];
961
+ const optionDefaults = allOptions.reduce(customFieldDefaultOptionsReducer, []);
962
+ if (optionDefaults.length) {
963
+ optionDefaults.forEach(
964
+ ({ name: name2, defaultValue }) => set(draftState.modifiedData, name2, defaultValue)
965
+ );
966
+ }
967
+ break;
968
+ }
969
+ case SET_DYNAMIC_ZONE_DATA_SCHEMA: {
970
+ draftState.modifiedData = action.attributeToEdit;
971
+ draftState.initialData = action.attributeToEdit;
972
+ break;
973
+ }
974
+ case SET_ERRORS: {
975
+ draftState.formErrors = action.errors;
976
+ break;
977
+ }
978
+ default:
979
+ return draftState;
980
+ }
981
+ })
982
+ );
983
+ const reducers = {
984
+ [`${pluginId}_formModal`]: reducer,
985
+ [`${pluginId}_dataManagerProvider`]: reducer$1
986
+ };
987
+ const formsAPI = {
988
+ components: {
989
+ inputs: {},
990
+ add({ id, component }) {
991
+ if (!this.inputs[id]) {
992
+ this.inputs[id] = component;
993
+ }
994
+ }
995
+ },
996
+ types: {
997
+ attribute: {
998
+ // test: {
999
+ // validators: [],
1000
+ // form: {
1001
+ // advanced: [
1002
+ // /* cb */
1003
+ // ],
1004
+ // base: [
1005
+ // /* cb */
1006
+ // ],
1007
+ // },
1008
+ // },
1009
+ },
1010
+ contentType: {
1011
+ validators: [],
1012
+ form: {
1013
+ advanced: [],
1014
+ base: []
1015
+ }
1016
+ },
1017
+ component: {
1018
+ validators: [],
1019
+ form: {
1020
+ advanced: [],
1021
+ base: []
1022
+ }
1023
+ }
1024
+ },
1025
+ contentTypeSchemaMutations: [],
1026
+ addContentTypeSchemaMutation(cb) {
1027
+ this.contentTypeSchemaMutations.push(cb);
1028
+ },
1029
+ extendContentType({ validator, form: { advanced, base } }) {
1030
+ const { contentType } = this.types;
1031
+ contentType.validators.push(validator);
1032
+ contentType.form.advanced.push(advanced);
1033
+ contentType.form.base.push(base);
1034
+ },
1035
+ extendFields(fields, { validator, form: { advanced, base } }) {
1036
+ const formType = this.types.attribute;
1037
+ fields.forEach((field) => {
1038
+ if (!formType[field]) {
1039
+ formType[field] = {
1040
+ validators: [],
1041
+ form: {
1042
+ advanced: [
1043
+ /* cb */
1044
+ ],
1045
+ base: [
1046
+ /* cb */
1047
+ ]
1048
+ }
1049
+ };
1050
+ }
1051
+ formType[field].validators.push(validator);
1052
+ formType[field].form.advanced.push(advanced);
1053
+ formType[field].form.base.push(base);
1054
+ });
1055
+ },
1056
+ getAdvancedForm(target, props = null) {
1057
+ const sectionsToAdd = get(this.types, [...target, "form", "advanced"], []).reduce(
1058
+ (acc, current2) => {
1059
+ const sections = current2(props);
1060
+ return [...acc, ...sections];
1061
+ },
1062
+ []
1063
+ );
1064
+ return sectionsToAdd;
1065
+ },
1066
+ makeCustomFieldValidator(attributeShape, validator, ...validatorArgs) {
1067
+ if (!validator)
1068
+ return attributeShape;
1069
+ return attributeShape.shape({ options: yup.object().shape(validator(validatorArgs)) });
1070
+ },
1071
+ makeValidator(target, initShape, ...args) {
1072
+ const validators = get(this.types, [...target, "validators"], []);
1073
+ const pluginOptionsShape = validators.reduce((acc, current2) => {
1074
+ const pluginOptionShape = current2(args);
1075
+ return { ...acc, ...pluginOptionShape };
1076
+ }, {});
1077
+ return initShape.shape({ pluginOptions: yup.object().shape(pluginOptionsShape) });
1078
+ },
1079
+ mutateContentTypeSchema(data, initialData) {
1080
+ let enhancedData = cloneDeep(data);
1081
+ const refData = cloneDeep(initialData);
1082
+ this.contentTypeSchemaMutations.forEach((cb) => {
1083
+ enhancedData = cb(enhancedData, refData);
1084
+ });
1085
+ return enhancedData;
1086
+ }
1087
+ };
1088
+ const prefixPluginTranslations = (trad, pluginId2) => {
1089
+ if (!pluginId2) {
1090
+ throw new TypeError("pluginId can't be empty");
1091
+ }
1092
+ return Object.keys(trad).reduce((acc, current2) => {
1093
+ acc[`${pluginId2}.${current2}`] = trad[current2];
1094
+ return acc;
1095
+ }, {});
1096
+ };
1097
+ const name = pluginPkg.strapi.name;
1098
+ const index = {
1099
+ register(app) {
1100
+ app.addReducers(reducers);
1101
+ app.addMenuLink({
1102
+ to: `plugins/${pluginId}`,
1103
+ icon: Layout,
1104
+ intlLabel: {
1105
+ id: `${pluginId}.plugin.name`,
1106
+ defaultMessage: "Content Types Builder"
1107
+ },
1108
+ permissions: PERMISSIONS.main,
1109
+ Component: () => import("./index-CPBF498m.mjs").then((n) => n.i)
1110
+ });
1111
+ app.registerPlugin({
1112
+ id: pluginId,
1113
+ name,
1114
+ // Internal APIs exposed by the CTB for the other plugins to use
1115
+ apis: {
1116
+ forms: formsAPI
1117
+ }
1118
+ });
1119
+ },
1120
+ bootstrap() {
1121
+ },
1122
+ async registerTrads({ locales }) {
1123
+ const importedTrads = await Promise.all(
1124
+ locales.map((locale) => {
1125
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-BYDB75EB.mjs"), "./translations/cs.json": () => import("./cs-ChL4LaFY.mjs"), "./translations/de.json": () => import("./de-DsHQNzp2.mjs"), "./translations/dk.json": () => import("./dk-BC7NAQR2.mjs"), "./translations/en.json": () => import("./en-BbczxQBr.mjs"), "./translations/es.json": () => import("./es-BE_zx2_w.mjs"), "./translations/fr.json": () => import("./fr-lU_OMJma.mjs"), "./translations/id.json": () => import("./id-W1sKBFEw.mjs"), "./translations/it.json": () => import("./it-D04lb2Wc.mjs"), "./translations/ja.json": () => import("./ja-BHLK_2_g.mjs"), "./translations/ko.json": () => import("./ko-DoNsXHXA.mjs"), "./translations/ms.json": () => import("./ms-BtGFDB9t.mjs"), "./translations/nl.json": () => import("./nl-BaTAuelQ.mjs"), "./translations/pl.json": () => import("./pl-CP2Zgp01.mjs"), "./translations/pt-BR.json": () => import("./pt-BR-CCQGwXs0.mjs"), "./translations/pt.json": () => import("./pt-DMeTMW2x.mjs"), "./translations/ru.json": () => import("./ru-DGSjru5m.mjs"), "./translations/sk.json": () => import("./sk-DVK4HfSC.mjs"), "./translations/sv.json": () => import("./sv-BGb12eW3.mjs"), "./translations/th.json": () => import("./th--u3VqsON.mjs"), "./translations/tr.json": () => import("./tr-DsUerr-c.mjs"), "./translations/uk.json": () => import("./uk-Bx5IlOKX.mjs"), "./translations/zh-Hans.json": () => import("./zh-Hans-Cc0M5PXr.mjs"), "./translations/zh.json": () => import("./zh-CsUDN13W.mjs") }), `./translations/${locale}.json`).then(({ default: data }) => {
1126
+ return {
1127
+ data: prefixPluginTranslations(data, pluginId),
1128
+ locale
1129
+ };
1130
+ }).catch(() => {
1131
+ return {
1132
+ data: {},
1133
+ locale
1134
+ };
1135
+ });
1136
+ })
1137
+ );
1138
+ return Promise.resolve(importedTrads);
1139
+ }
1140
+ };
1141
+ export {
1142
+ ADD_CUSTOM_FIELD_ATTRIBUTE as A,
1143
+ CREATE_COMPONENT_SCHEMA as B,
1144
+ CHANGE_DYNAMIC_ZONE_COMPONENTS as C,
1145
+ DELETE_NOT_SAVED_TYPE as D,
1146
+ EDIT_CUSTOM_FIELD_ATTRIBUTE as E,
1147
+ REMOVE_FIELD_FROM_DISPLAYED_COMPONENT as F,
1148
+ GET_DATA_SUCCEEDED as G,
1149
+ REMOVE_FIELD as H,
1150
+ index as I,
1151
+ ON_CHANGE_RELATION_TARGET as O,
1152
+ PERMISSIONS as P,
1153
+ RESET_PROPS as R,
1154
+ SET_DATA_TO_EDIT as S,
1155
+ UPDATE_INITIAL_STATE as U,
1156
+ ON_CHANGE_RELATION_TYPE as a,
1157
+ createUid as b,
1158
+ createComponentUid as c,
1159
+ SET_DYNAMIC_ZONE_DATA_SCHEMA as d,
1160
+ SET_CUSTOM_FIELD_DATA_SCHEMA as e,
1161
+ SET_ATTRIBUTE_DATA_SCHEMA as f,
1162
+ getRelationType as g,
1163
+ SET_ERRORS as h,
1164
+ initialState as i,
1165
+ ON_CHANGE as j,
1166
+ RESET_PROPS_AND_SET_THE_FORM_FOR_ADDING_A_COMPO_TO_A_DZ as k,
1167
+ RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO as l,
1168
+ RESET_PROPS_AND_SAVE_CURRENT_DATA as m,
1169
+ nameToSlug as n,
1170
+ initialState$1 as o,
1171
+ pluginId as p,
1172
+ makeUnique as q,
1173
+ RELOAD_PLUGIN as r,
1174
+ retrieveComponentsFromSchema as s,
1175
+ SET_MODIFIED_DATA as t,
1176
+ ADD_CREATED_COMPONENT_TO_DYNAMIC_ZONE as u,
1177
+ REMOVE_COMPONENT_FROM_DYNAMIC_ZONE as v,
1178
+ UPDATE_SCHEMA as w,
1179
+ EDIT_ATTRIBUTE as x,
1180
+ ADD_ATTRIBUTE as y,
1181
+ CREATE_SCHEMA as z
1182
+ };
1183
+ //# sourceMappingURL=index-DmqlavBo.mjs.map