@strapi/i18n 0.0.0-experimental.d1602f22dc638a4c3c5084965fd6126fff5e9d4f → 0.0.0-experimental.d19a9dcb5829d725ba4d7c1e7b3ae9c816c26514

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 (426) hide show
  1. package/dist/admin/components/BulkLocaleActionModal.js +262 -0
  2. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -0
  3. package/dist/admin/components/BulkLocaleActionModal.mjs +260 -0
  4. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -0
  5. package/dist/admin/components/CMHeaderActions.js +910 -0
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -0
  7. package/dist/admin/components/CMHeaderActions.mjs +884 -0
  8. package/dist/admin/components/CMHeaderActions.mjs.map +1 -0
  9. package/dist/admin/components/CMListViewModalsAdditionalInformation.js +69 -0
  10. package/dist/admin/components/CMListViewModalsAdditionalInformation.js.map +1 -0
  11. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs +65 -0
  12. package/dist/admin/components/CMListViewModalsAdditionalInformation.mjs.map +1 -0
  13. package/dist/admin/components/CheckboxConfirmation.js +155 -0
  14. package/dist/admin/components/CheckboxConfirmation.js.map +1 -0
  15. package/dist/admin/components/CheckboxConfirmation.mjs +134 -0
  16. package/dist/admin/components/CheckboxConfirmation.mjs.map +1 -0
  17. package/dist/admin/components/CreateLocale.js +395 -0
  18. package/dist/admin/components/CreateLocale.js.map +1 -0
  19. package/dist/admin/components/CreateLocale.mjs +369 -0
  20. package/dist/admin/components/CreateLocale.mjs.map +1 -0
  21. package/dist/admin/components/DeleteLocale.js +90 -0
  22. package/dist/admin/components/DeleteLocale.js.map +1 -0
  23. package/dist/admin/components/DeleteLocale.mjs +69 -0
  24. package/dist/admin/components/DeleteLocale.mjs.map +1 -0
  25. package/dist/admin/components/EditLocale.js +212 -0
  26. package/dist/admin/components/EditLocale.js.map +1 -0
  27. package/dist/admin/components/EditLocale.mjs +190 -0
  28. package/dist/admin/components/EditLocale.mjs.map +1 -0
  29. package/dist/admin/components/LocaleListCell.js +102 -0
  30. package/dist/admin/components/LocaleListCell.js.map +1 -0
  31. package/dist/admin/components/LocaleListCell.mjs +100 -0
  32. package/dist/admin/components/LocaleListCell.mjs.map +1 -0
  33. package/dist/admin/components/LocalePicker.js +105 -0
  34. package/dist/admin/components/LocalePicker.js.map +1 -0
  35. package/dist/admin/components/LocalePicker.mjs +84 -0
  36. package/dist/admin/components/LocalePicker.mjs.map +1 -0
  37. package/dist/admin/components/LocaleTable.js +143 -0
  38. package/dist/admin/components/LocaleTable.js.map +1 -0
  39. package/dist/admin/components/LocaleTable.mjs +122 -0
  40. package/dist/admin/components/LocaleTable.mjs.map +1 -0
  41. package/dist/admin/constants.js +37 -0
  42. package/dist/admin/constants.js.map +1 -0
  43. package/dist/admin/constants.mjs +35 -0
  44. package/dist/admin/constants.mjs.map +1 -0
  45. package/dist/admin/contentManagerHooks/editView.js +109 -0
  46. package/dist/admin/contentManagerHooks/editView.js.map +1 -0
  47. package/dist/admin/contentManagerHooks/editView.mjs +88 -0
  48. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -0
  49. package/dist/admin/contentManagerHooks/listView.js +44 -0
  50. package/dist/admin/contentManagerHooks/listView.js.map +1 -0
  51. package/dist/admin/contentManagerHooks/listView.mjs +42 -0
  52. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -0
  53. package/dist/admin/contentReleasesHooks/releaseDetailsView.js +20 -0
  54. package/dist/admin/contentReleasesHooks/releaseDetailsView.js.map +1 -0
  55. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs +18 -0
  56. package/dist/admin/contentReleasesHooks/releaseDetailsView.mjs.map +1 -0
  57. package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
  58. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  59. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  60. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  61. package/dist/admin/hooks/useI18n.js +78 -0
  62. package/dist/admin/hooks/useI18n.js.map +1 -0
  63. package/dist/admin/hooks/useI18n.mjs +57 -0
  64. package/dist/admin/hooks/useI18n.mjs.map +1 -0
  65. package/dist/admin/index.js +221 -16
  66. package/dist/admin/index.js.map +1 -1
  67. package/dist/admin/index.mjs +203 -15
  68. package/dist/admin/index.mjs.map +1 -1
  69. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +71 -0
  70. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -0
  71. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +69 -0
  72. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -0
  73. package/dist/admin/middlewares/extendCTBInitialData.js +40 -0
  74. package/dist/admin/middlewares/extendCTBInitialData.js.map +1 -0
  75. package/dist/admin/middlewares/extendCTBInitialData.mjs +38 -0
  76. package/dist/admin/middlewares/extendCTBInitialData.mjs.map +1 -0
  77. package/dist/admin/middlewares/rbac-middleware.js +49 -0
  78. package/dist/admin/middlewares/rbac-middleware.js.map +1 -0
  79. package/dist/admin/middlewares/rbac-middleware.mjs +28 -0
  80. package/dist/admin/middlewares/rbac-middleware.mjs.map +1 -0
  81. package/dist/admin/pages/SettingsPage.js +182 -0
  82. package/dist/admin/pages/SettingsPage.js.map +1 -0
  83. package/dist/admin/pages/SettingsPage.mjs +179 -0
  84. package/dist/admin/pages/SettingsPage.mjs.map +1 -0
  85. package/dist/admin/pluginId.js +6 -0
  86. package/dist/admin/pluginId.js.map +1 -0
  87. package/dist/admin/pluginId.mjs +4 -0
  88. package/dist/admin/pluginId.mjs.map +1 -0
  89. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  90. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  91. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  92. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  93. package/dist/admin/services/api.js +15 -0
  94. package/dist/admin/services/api.js.map +1 -0
  95. package/dist/admin/services/api.mjs +13 -0
  96. package/dist/admin/services/api.mjs.map +1 -0
  97. package/dist/admin/services/locales.js +72 -0
  98. package/dist/admin/services/locales.js.map +1 -0
  99. package/dist/admin/services/locales.mjs +66 -0
  100. package/dist/admin/services/locales.mjs.map +1 -0
  101. package/dist/admin/services/relations.js +23 -0
  102. package/dist/admin/services/relations.js.map +1 -0
  103. package/dist/admin/services/relations.mjs +21 -0
  104. package/dist/admin/services/relations.mjs.map +1 -0
  105. package/dist/admin/services/settings.js +29 -0
  106. package/dist/admin/services/settings.js.map +1 -0
  107. package/dist/admin/services/settings.mjs +26 -0
  108. package/dist/admin/services/settings.mjs.map +1 -0
  109. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  110. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  111. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  112. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  113. package/dist/admin/src/services/api.d.ts +1 -1
  114. package/dist/admin/src/services/locales.d.ts +1 -1
  115. package/dist/admin/src/services/relations.d.ts +1 -1
  116. package/dist/admin/src/services/settings.d.ts +5 -0
  117. package/dist/admin/src/utils/schemas.d.ts +642 -16
  118. package/dist/admin/{chunks/de-nEMWvIiY.js → translations/de.json.js} +2 -2
  119. package/dist/admin/translations/de.json.js.map +1 -0
  120. package/dist/admin/{chunks/de-Cm8mYdaO.js → translations/de.json.mjs} +1 -1
  121. package/dist/admin/translations/de.json.mjs.map +1 -0
  122. package/dist/admin/{chunks/dk-CYATLPVe.js → translations/dk.json.js} +2 -2
  123. package/dist/admin/translations/dk.json.js.map +1 -0
  124. package/dist/admin/{chunks/dk-BeUFOegB.js → translations/dk.json.mjs} +1 -1
  125. package/dist/admin/translations/dk.json.mjs.map +1 -0
  126. package/dist/admin/{chunks/en-CG5cUCbD.js → translations/en.json.js} +12 -2
  127. package/dist/admin/translations/en.json.js.map +1 -0
  128. package/dist/admin/{chunks/en-eWSaCeOb.js → translations/en.json.mjs} +11 -1
  129. package/dist/admin/translations/en.json.mjs.map +1 -0
  130. package/dist/admin/{chunks/es-CWsogTGm.js → translations/es.json.js} +2 -2
  131. package/dist/admin/translations/es.json.js.map +1 -0
  132. package/dist/admin/{chunks/es-DqF_IdAc.js → translations/es.json.mjs} +1 -1
  133. package/dist/admin/translations/es.json.mjs.map +1 -0
  134. package/dist/admin/{chunks/fr-CC7UFcYd.js → translations/fr.json.js} +2 -2
  135. package/dist/admin/translations/fr.json.js.map +1 -0
  136. package/dist/admin/{chunks/fr-CyARbZ3c.js → translations/fr.json.mjs} +1 -1
  137. package/dist/admin/translations/fr.json.mjs.map +1 -0
  138. package/dist/admin/{chunks/ko-XwGmfhoq.js → translations/ko.json.js} +2 -2
  139. package/dist/admin/translations/ko.json.js.map +1 -0
  140. package/dist/admin/{chunks/ko-Ax4NSedM.js → translations/ko.json.mjs} +1 -1
  141. package/dist/admin/translations/ko.json.mjs.map +1 -0
  142. package/dist/admin/{chunks/pl-B_vzY_ZB.js → translations/pl.json.js} +2 -2
  143. package/dist/admin/translations/pl.json.js.map +1 -0
  144. package/dist/admin/{chunks/pl-B-aqvMqL.js → translations/pl.json.mjs} +1 -1
  145. package/dist/admin/translations/pl.json.mjs.map +1 -0
  146. package/dist/admin/{chunks/ru-WzHcJV1f.js → translations/ru.json.js} +2 -2
  147. package/dist/admin/translations/ru.json.js.map +1 -0
  148. package/dist/admin/{chunks/ru-VkPjQ-Sk.js → translations/ru.json.mjs} +1 -1
  149. package/dist/admin/translations/ru.json.mjs.map +1 -0
  150. package/dist/admin/{chunks/tr-CcWp6u3w.js → translations/tr.json.js} +2 -2
  151. package/dist/admin/translations/tr.json.js.map +1 -0
  152. package/dist/admin/{chunks/tr-DcTR88c9.js → translations/tr.json.mjs} +1 -1
  153. package/dist/admin/translations/tr.json.mjs.map +1 -0
  154. package/dist/admin/translations/uk.json.js +82 -0
  155. package/dist/admin/translations/uk.json.js.map +1 -0
  156. package/dist/admin/translations/uk.json.mjs +80 -0
  157. package/dist/admin/translations/uk.json.mjs.map +1 -0
  158. package/dist/admin/{chunks/zh-Hans-DnU2bhri.js → translations/zh-Hans.json.js} +2 -2
  159. package/dist/admin/translations/zh-Hans.json.js.map +1 -0
  160. package/dist/admin/{chunks/zh-Hans-L3wsRegj.js → translations/zh-Hans.json.mjs} +1 -1
  161. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  162. package/dist/admin/{chunks/zh-C9So4SGq.js → translations/zh.json.js} +2 -2
  163. package/dist/admin/translations/zh.json.js.map +1 -0
  164. package/dist/admin/{chunks/zh-RZyMiPIs.js → translations/zh.json.mjs} +1 -1
  165. package/dist/admin/translations/zh.json.mjs.map +1 -0
  166. package/dist/admin/utils/baseQuery.js +8 -0
  167. package/dist/admin/utils/baseQuery.js.map +1 -0
  168. package/dist/admin/utils/baseQuery.mjs +6 -0
  169. package/dist/admin/utils/baseQuery.mjs.map +1 -0
  170. package/dist/admin/utils/clean.js +70 -0
  171. package/dist/admin/utils/clean.js.map +1 -0
  172. package/dist/admin/utils/clean.mjs +68 -0
  173. package/dist/admin/utils/clean.mjs.map +1 -0
  174. package/dist/admin/utils/fields.js +34 -0
  175. package/dist/admin/utils/fields.js.map +1 -0
  176. package/dist/admin/utils/fields.mjs +31 -0
  177. package/dist/admin/utils/fields.mjs.map +1 -0
  178. package/dist/admin/utils/getTranslation.js +8 -0
  179. package/dist/admin/utils/getTranslation.js.map +1 -0
  180. package/dist/admin/utils/getTranslation.mjs +6 -0
  181. package/dist/admin/utils/getTranslation.mjs.map +1 -0
  182. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  183. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  184. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  185. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  186. package/dist/admin/utils/schemas.js +74 -0
  187. package/dist/admin/utils/schemas.js.map +1 -0
  188. package/dist/admin/utils/schemas.mjs +72 -0
  189. package/dist/admin/utils/schemas.mjs.map +1 -0
  190. package/dist/admin/utils/strings.js +6 -0
  191. package/dist/admin/utils/strings.js.map +1 -0
  192. package/dist/admin/utils/strings.mjs +4 -0
  193. package/dist/admin/utils/strings.mjs.map +1 -0
  194. package/dist/server/bootstrap.js +81 -0
  195. package/dist/server/bootstrap.js.map +1 -0
  196. package/dist/server/bootstrap.mjs +79 -0
  197. package/dist/server/bootstrap.mjs.map +1 -0
  198. package/dist/server/constants/index.js +29 -0
  199. package/dist/server/constants/index.js.map +1 -0
  200. package/dist/server/constants/index.mjs +25 -0
  201. package/dist/server/constants/index.mjs.map +1 -0
  202. package/dist/server/constants/iso-locales.json.js +2427 -0
  203. package/dist/server/constants/iso-locales.json.js.map +1 -0
  204. package/dist/server/constants/iso-locales.json.mjs +2425 -0
  205. package/dist/server/constants/iso-locales.json.mjs.map +1 -0
  206. package/dist/server/content-types/index.js +10 -0
  207. package/dist/server/content-types/index.js.map +1 -0
  208. package/dist/server/content-types/index.mjs +8 -0
  209. package/dist/server/content-types/index.mjs.map +1 -0
  210. package/dist/server/content-types/locale/index.js +10 -0
  211. package/dist/server/content-types/locale/index.js.map +1 -0
  212. package/dist/server/content-types/locale/index.mjs +8 -0
  213. package/dist/server/content-types/locale/index.mjs.map +1 -0
  214. package/dist/server/content-types/locale/schema.json.js +46 -0
  215. package/dist/server/content-types/locale/schema.json.js.map +1 -0
  216. package/dist/server/content-types/locale/schema.json.mjs +38 -0
  217. package/dist/server/content-types/locale/schema.json.mjs.map +1 -0
  218. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  219. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  220. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  221. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  222. package/dist/server/controllers/content-types.js +76 -0
  223. package/dist/server/controllers/content-types.js.map +1 -0
  224. package/dist/server/controllers/content-types.mjs +74 -0
  225. package/dist/server/controllers/content-types.mjs.map +1 -0
  226. package/dist/server/controllers/index.js +18 -0
  227. package/dist/server/controllers/index.js.map +1 -0
  228. package/dist/server/controllers/index.mjs +16 -0
  229. package/dist/server/controllers/index.mjs.map +1 -0
  230. package/dist/server/controllers/iso-locales.js +13 -0
  231. package/dist/server/controllers/iso-locales.js.map +1 -0
  232. package/dist/server/controllers/iso-locales.mjs +11 -0
  233. package/dist/server/controllers/iso-locales.mjs.map +1 -0
  234. package/dist/server/controllers/locales.js +108 -0
  235. package/dist/server/controllers/locales.js.map +1 -0
  236. package/dist/server/controllers/locales.mjs +87 -0
  237. package/dist/server/controllers/locales.mjs.map +1 -0
  238. package/dist/server/controllers/settings.js +24 -0
  239. package/dist/server/controllers/settings.js.map +1 -0
  240. package/dist/server/controllers/settings.mjs +22 -0
  241. package/dist/server/controllers/settings.mjs.map +1 -0
  242. package/dist/server/controllers/validate-locale-creation.js +47 -0
  243. package/dist/server/controllers/validate-locale-creation.js.map +1 -0
  244. package/dist/server/controllers/validate-locale-creation.mjs +45 -0
  245. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -0
  246. package/dist/server/domain/locale.js +11 -0
  247. package/dist/server/domain/locale.js.map +1 -0
  248. package/dist/server/domain/locale.mjs +9 -0
  249. package/dist/server/domain/locale.mjs.map +1 -0
  250. package/dist/server/graphql.js +115 -0
  251. package/dist/server/graphql.js.map +1 -0
  252. package/dist/server/graphql.mjs +113 -0
  253. package/dist/server/graphql.mjs.map +1 -0
  254. package/dist/server/index.js +10 -3712
  255. package/dist/server/index.js.map +1 -1
  256. package/dist/server/index.mjs +7 -3691
  257. package/dist/server/index.mjs.map +1 -1
  258. package/dist/server/models/ai-localization-job.js +60 -0
  259. package/dist/server/models/ai-localization-job.js.map +1 -0
  260. package/dist/server/models/ai-localization-job.mjs +57 -0
  261. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  262. package/dist/server/register.js +81 -0
  263. package/dist/server/register.js.map +1 -0
  264. package/dist/server/register.mjs +79 -0
  265. package/dist/server/register.mjs.map +1 -0
  266. package/dist/server/routes/admin.js +142 -0
  267. package/dist/server/routes/admin.js.map +1 -0
  268. package/dist/server/routes/admin.mjs +140 -0
  269. package/dist/server/routes/admin.mjs.map +1 -0
  270. package/dist/server/routes/content-api.js +19 -0
  271. package/dist/server/routes/content-api.js.map +1 -0
  272. package/dist/server/routes/content-api.mjs +17 -0
  273. package/dist/server/routes/content-api.mjs.map +1 -0
  274. package/dist/server/routes/index.js +12 -0
  275. package/dist/server/routes/index.js.map +1 -0
  276. package/dist/server/routes/index.mjs +10 -0
  277. package/dist/server/routes/index.mjs.map +1 -0
  278. package/dist/server/routes/validation/locale.js +57 -0
  279. package/dist/server/routes/validation/locale.js.map +1 -0
  280. package/dist/server/routes/validation/locale.mjs +36 -0
  281. package/dist/server/routes/validation/locale.mjs.map +1 -0
  282. package/dist/server/services/ai-localization-jobs.js +64 -0
  283. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  284. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  285. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  286. package/dist/server/services/ai-localizations.js +284 -0
  287. package/dist/server/services/ai-localizations.js.map +1 -0
  288. package/dist/server/services/ai-localizations.mjs +282 -0
  289. package/dist/server/services/ai-localizations.mjs.map +1 -0
  290. package/dist/server/services/content-types.js +157 -0
  291. package/dist/server/services/content-types.js.map +1 -0
  292. package/dist/server/services/content-types.mjs +155 -0
  293. package/dist/server/services/content-types.mjs.map +1 -0
  294. package/dist/server/services/index.js +28 -0
  295. package/dist/server/services/index.js.map +1 -0
  296. package/dist/server/services/index.mjs +26 -0
  297. package/dist/server/services/index.mjs.map +1 -0
  298. package/dist/server/services/iso-locales.js +12 -0
  299. package/dist/server/services/iso-locales.js.map +1 -0
  300. package/dist/server/services/iso-locales.mjs +10 -0
  301. package/dist/server/services/iso-locales.mjs.map +1 -0
  302. package/dist/server/services/locales.js +114 -0
  303. package/dist/server/services/locales.js.map +1 -0
  304. package/dist/server/services/locales.mjs +112 -0
  305. package/dist/server/services/locales.mjs.map +1 -0
  306. package/dist/server/services/localizations.js +68 -0
  307. package/dist/server/services/localizations.js.map +1 -0
  308. package/dist/server/services/localizations.mjs +66 -0
  309. package/dist/server/services/localizations.mjs.map +1 -0
  310. package/dist/server/services/metrics.js +41 -0
  311. package/dist/server/services/metrics.js.map +1 -0
  312. package/dist/server/services/metrics.mjs +39 -0
  313. package/dist/server/services/metrics.mjs.map +1 -0
  314. package/dist/server/services/permissions/actions.js +136 -0
  315. package/dist/server/services/permissions/actions.js.map +1 -0
  316. package/dist/server/services/permissions/actions.mjs +134 -0
  317. package/dist/server/services/permissions/actions.mjs.map +1 -0
  318. package/dist/server/services/permissions/engine.js +52 -0
  319. package/dist/server/services/permissions/engine.js.map +1 -0
  320. package/dist/server/services/permissions/engine.mjs +50 -0
  321. package/dist/server/services/permissions/engine.mjs.map +1 -0
  322. package/dist/server/services/permissions/sections-builder.js +45 -0
  323. package/dist/server/services/permissions/sections-builder.js.map +1 -0
  324. package/dist/server/services/permissions/sections-builder.mjs +43 -0
  325. package/dist/server/services/permissions/sections-builder.mjs.map +1 -0
  326. package/dist/server/services/permissions.js +14 -0
  327. package/dist/server/services/permissions.js.map +1 -0
  328. package/dist/server/services/permissions.mjs +12 -0
  329. package/dist/server/services/permissions.mjs.map +1 -0
  330. package/dist/server/services/sanitize/index.js +34 -0
  331. package/dist/server/services/sanitize/index.js.map +1 -0
  332. package/dist/server/services/sanitize/index.mjs +32 -0
  333. package/dist/server/services/sanitize/index.mjs.map +1 -0
  334. package/dist/server/services/settings.js +25 -0
  335. package/dist/server/services/settings.js.map +1 -0
  336. package/dist/server/services/settings.mjs +23 -0
  337. package/dist/server/services/settings.mjs.map +1 -0
  338. package/dist/server/src/bootstrap.d.ts.map +1 -1
  339. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  340. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  341. package/dist/server/src/controllers/index.d.ts +10 -0
  342. package/dist/server/src/controllers/index.d.ts.map +1 -1
  343. package/dist/server/src/controllers/settings.d.ts +7 -0
  344. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  345. package/dist/server/src/index.d.ts +48 -8
  346. package/dist/server/src/index.d.ts.map +1 -1
  347. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  348. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  349. package/dist/server/src/models/index.d.ts +5 -0
  350. package/dist/server/src/models/index.d.ts.map +1 -0
  351. package/dist/server/src/register.d.ts +1 -1
  352. package/dist/server/src/register.d.ts.map +1 -1
  353. package/dist/server/src/routes/admin.d.ts.map +1 -1
  354. package/dist/server/src/routes/content-api.d.ts +5 -8
  355. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  356. package/dist/server/src/routes/index.d.ts +3 -7
  357. package/dist/server/src/routes/index.d.ts.map +1 -1
  358. package/dist/server/src/routes/validation/index.d.ts +2 -0
  359. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  360. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  361. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  362. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  363. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  364. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  365. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  366. package/dist/server/src/services/index.d.ts +34 -0
  367. package/dist/server/src/services/index.d.ts.map +1 -1
  368. package/dist/server/src/services/metrics.d.ts +1 -0
  369. package/dist/server/src/services/metrics.d.ts.map +1 -1
  370. package/dist/server/src/services/settings.d.ts +13 -0
  371. package/dist/server/src/services/settings.d.ts.map +1 -0
  372. package/dist/server/src/utils/index.d.ts +7 -1
  373. package/dist/server/src/utils/index.d.ts.map +1 -1
  374. package/dist/server/src/validation/settings.d.ts +12 -0
  375. package/dist/server/src/validation/settings.d.ts.map +1 -0
  376. package/dist/server/utils/index.js +16 -0
  377. package/dist/server/utils/index.js.map +1 -0
  378. package/dist/server/utils/index.mjs +13 -0
  379. package/dist/server/utils/index.mjs.map +1 -0
  380. package/dist/server/validation/content-types.js +18 -0
  381. package/dist/server/validation/content-types.js.map +1 -0
  382. package/dist/server/validation/content-types.mjs +16 -0
  383. package/dist/server/validation/content-types.mjs.map +1 -0
  384. package/dist/server/validation/locales.js +23 -0
  385. package/dist/server/validation/locales.js.map +1 -0
  386. package/dist/server/validation/locales.mjs +20 -0
  387. package/dist/server/validation/locales.mjs.map +1 -0
  388. package/dist/server/validation/settings.js +11 -0
  389. package/dist/server/validation/settings.js.map +1 -0
  390. package/dist/server/validation/settings.mjs +9 -0
  391. package/dist/server/validation/settings.mjs.map +1 -0
  392. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  393. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  394. package/dist/shared/contracts/settings.d.ts +40 -0
  395. package/dist/shared/contracts/shared.d.ts.map +1 -0
  396. package/package.json +12 -9
  397. package/dist/admin/chunks/SettingsPage-B6ikxVOg.js +0 -820
  398. package/dist/admin/chunks/SettingsPage-B6ikxVOg.js.map +0 -1
  399. package/dist/admin/chunks/SettingsPage-Kg4GAThm.js +0 -797
  400. package/dist/admin/chunks/SettingsPage-Kg4GAThm.js.map +0 -1
  401. package/dist/admin/chunks/de-Cm8mYdaO.js.map +0 -1
  402. package/dist/admin/chunks/de-nEMWvIiY.js.map +0 -1
  403. package/dist/admin/chunks/dk-BeUFOegB.js.map +0 -1
  404. package/dist/admin/chunks/dk-CYATLPVe.js.map +0 -1
  405. package/dist/admin/chunks/en-CG5cUCbD.js.map +0 -1
  406. package/dist/admin/chunks/en-eWSaCeOb.js.map +0 -1
  407. package/dist/admin/chunks/es-CWsogTGm.js.map +0 -1
  408. package/dist/admin/chunks/es-DqF_IdAc.js.map +0 -1
  409. package/dist/admin/chunks/fr-CC7UFcYd.js.map +0 -1
  410. package/dist/admin/chunks/fr-CyARbZ3c.js.map +0 -1
  411. package/dist/admin/chunks/index-Dch-2xao.js +0 -2035
  412. package/dist/admin/chunks/index-Dch-2xao.js.map +0 -1
  413. package/dist/admin/chunks/index-DyvbIjH9.js +0 -2006
  414. package/dist/admin/chunks/index-DyvbIjH9.js.map +0 -1
  415. package/dist/admin/chunks/ko-Ax4NSedM.js.map +0 -1
  416. package/dist/admin/chunks/ko-XwGmfhoq.js.map +0 -1
  417. package/dist/admin/chunks/pl-B-aqvMqL.js.map +0 -1
  418. package/dist/admin/chunks/pl-B_vzY_ZB.js.map +0 -1
  419. package/dist/admin/chunks/ru-VkPjQ-Sk.js.map +0 -1
  420. package/dist/admin/chunks/ru-WzHcJV1f.js.map +0 -1
  421. package/dist/admin/chunks/tr-CcWp6u3w.js.map +0 -1
  422. package/dist/admin/chunks/tr-DcTR88c9.js.map +0 -1
  423. package/dist/admin/chunks/zh-C9So4SGq.js.map +0 -1
  424. package/dist/admin/chunks/zh-Hans-DnU2bhri.js.map +0 -1
  425. package/dist/admin/chunks/zh-Hans-L3wsRegj.js.map +0 -1
  426. package/dist/admin/chunks/zh-RZyMiPIs.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-localizations.mjs","sources":["../../../server/src/services/ai-localizations.ts"],"sourcesContent":["import type { Core, Modules, Schema, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst isLocalizedAttribute = (attribute: Schema.Attribute.Attribute | undefined): boolean => {\n return (attribute?.pluginOptions as any)?.i18n?.localized === true;\n};\n\nconst createAILocalizationsService = ({ strapi }: { strapi: Core.Strapi }) => {\n // TODO: add a helper function to get the AI server URL\n const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';\n const aiLocalizationJobsService = getService('ai-localization-jobs');\n\n const UNSUPPORTED_ATTRIBUTE_TYPES: Schema.Attribute.Kind[] = ['media', 'relation', 'boolean'];\n const IGNORED_FIELDS = [\n 'id',\n 'documentId',\n 'createdAt',\n 'updatedAt',\n 'updatedBy',\n 'localizations',\n ];\n\n return {\n // Async to avoid changing the signature later (there will be a db check in the future)\n async isEnabled() {\n // Check if user disabled AI features globally\n const isAIEnabled = strapi.config.get('admin.ai.enabled', true);\n if (!isAIEnabled) {\n return false;\n }\n\n // Check if the user's license grants access to AI features\n const hasAccess = strapi.ee.features.isEnabled('cms-ai');\n if (!hasAccess) {\n return false;\n }\n\n const settings = getService('settings');\n const aiSettings = await settings.getSettings();\n if (!aiSettings?.aiLocalizations) {\n return false;\n }\n\n return true;\n },\n\n /**\n * Checks if there are localizations that need to be generated for the given document,\n * and if so, calls the AI service and saves the results to the database.\n * Works for both single and collection types, on create and update.\n */\n async generateDocumentLocalizations({\n model,\n document,\n }: {\n model: UID.ContentType;\n document: Modules.Documents.AnyDocument;\n }) {\n const isFeatureEnabled = await this.isEnabled();\n if (!isFeatureEnabled) {\n return;\n }\n\n const schema = strapi.getModel(model);\n const localeService = getService('locales');\n\n // No localizations needed for content types with i18n disabled\n const isLocalizedContentType = getService('content-types').isLocalizedContentType(schema);\n if (!isLocalizedContentType) {\n return;\n }\n\n // Don't trigger localizations if the update is on a derived locale, only do it on the default\n const defaultLocale = await localeService.getDefaultLocale();\n if (document?.locale !== defaultLocale) {\n return;\n }\n\n const documentId = document.documentId;\n\n if (!documentId) {\n strapi.log.warn(`AI Localizations: missing documentId for ${schema.uid}`);\n return;\n }\n\n const localizedRoots = new Set();\n\n const translateableContent = await traverseEntity(\n ({ key, attribute, parent, path }, { remove }) => {\n if (IGNORED_FIELDS.includes(key)) {\n remove(key);\n return;\n }\n const hasLocalizedOption = attribute && isLocalizedAttribute(attribute);\n if (attribute && UNSUPPORTED_ATTRIBUTE_TYPES.includes(attribute.type)) {\n remove(key);\n return;\n }\n\n // If this field is localized, keep it (and mark as localized root if component/dz)\n if (hasLocalizedOption) {\n // If it's a component/dynamiczone, add to the set\n if (['component', 'dynamiczone'].includes(attribute.type)) {\n localizedRoots.add(path.raw);\n }\n return; // keep\n }\n\n if (parent && localizedRoots.has(parent.path.raw)) {\n // If parent exists in the localized roots set, keep it\n // If this is also a component/dz, propagate the localized root flag\n if (['component', 'dynamiczone'].includes(attribute?.type ?? '')) {\n localizedRoots.add(path.raw);\n }\n return; // keep\n }\n\n // Otherwise, remove the field\n remove(key);\n },\n { schema, getModel: strapi.getModel.bind(strapi) },\n document\n );\n\n if (Object.keys(translateableContent).length === 0) {\n strapi.log.info(\n `AI Localizations: no translatable content for ${schema.uid} document ${documentId}`\n );\n return;\n }\n\n const localesList = await localeService.find();\n const targetLocales = localesList\n .filter((l) => l.code !== document.locale)\n .map((l) => l.code);\n\n if (targetLocales.length === 0) {\n strapi.log.info(\n `AI Localizations: no target locales for ${schema.uid} document ${documentId}`\n );\n return;\n }\n\n await aiLocalizationJobsService.upsertJobForDocument({\n contentType: model,\n documentId,\n sourceLocale: document.locale,\n targetLocales,\n status: 'processing',\n });\n\n let token: string;\n try {\n const tokenData = await strapi.service('admin::user').getAiToken();\n token = tokenData.token;\n } catch (error) {\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'failed',\n });\n\n throw new Error('Failed to retrieve AI token', {\n cause: error instanceof Error ? error : undefined,\n });\n }\n\n /**\n * Provide a schema to the LLM so that we can give it instructions about how to handle each\n * type of attribute. Only keep essential schema data to avoid cluttering the context.\n * Ignore fields that don't need to be localized.\n * TODO: also provide a schema of all the referenced components\n */\n const minimalContentTypeSchema = Object.fromEntries(\n Object.entries(schema.attributes)\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n .filter(([_, attr]) => {\n const isLocalized = isLocalizedAttribute(attr);\n const isSupportedType = !UNSUPPORTED_ATTRIBUTE_TYPES.includes(attr.type);\n return isLocalized && isSupportedType;\n })\n .map(([key, attr]) => {\n const minimalAttribute = { type: attr.type };\n if (attr.type === 'component') {\n (\n minimalAttribute as Schema.Attribute.Component<`${string}.${string}`, boolean>\n ).repeatable = attr.repeatable ?? false;\n }\n return [key, minimalAttribute];\n })\n );\n\n strapi.log.http('Contacting AI Server for localizations generation');\n const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n content: translateableContent,\n sourceLocale: document.locale,\n targetLocales,\n contentTypeSchema: minimalContentTypeSchema,\n }),\n });\n\n if (!response.ok) {\n strapi.log.error(\n `AI Localizations request failed: ${response.status} ${response.statusText}`\n );\n\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'failed',\n });\n\n throw new Error(`AI Localizations request failed: ${response.statusText}`);\n }\n\n const aiResult = await response.json();\n // Get all media field names dynamically from the schema\n const mediaFields = Object.entries(schema.attributes)\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n .filter(([_, attr]) => attr.type === 'media')\n .map(([key]) => key);\n\n try {\n await Promise.all(\n aiResult.localizations.map(async (localization: any) => {\n const { content, locale } = localization;\n\n // Fetch the derived locale document\n const derivedDoc = await strapi.documents(model).findOne({\n documentId,\n locale,\n populate: mediaFields,\n });\n\n // Merge AI content and media fields, works only on first level media fields (root level)\n const mergedData = structuredClone(content);\n for (const field of mediaFields) {\n // Only copy media if not already set in derived locale\n if (!derivedDoc || !derivedDoc[field]) {\n mergedData[field] = document[field];\n } else {\n mergedData[field] = derivedDoc[field];\n }\n }\n\n /**\n * TODO:\n * We should use the document service here, however currently,\n * updating a localized entry marks the source document as modified.\n * @see https://github.com/strapi/strapi/issues/22924\n *\n * Falling back to the query engine to preserve the correct status\n */\n await strapi.db.query(model).update({\n where: { documentId, locale },\n data: mergedData,\n });\n\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'completed',\n });\n })\n );\n } catch (error) {\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'failed',\n });\n strapi.log.error('AI Localizations generation failed', error);\n }\n },\n setupMiddleware() {\n strapi.documents.use(async (context, next) => {\n const result = await next();\n\n const metricsService = strapi.plugin('i18n').service('metrics');\n if (context.action === 'publish') {\n metricsService.sendWithAIEventProperty('didPublishEntry');\n return result;\n }\n\n if (context.action === 'update' || context.action === 'create') {\n metricsService.sendWithAIEventProperty('didSaveEntry');\n }\n\n // Only trigger for the allowed actions\n if (!['create', 'update'].includes(context.action)) {\n return result;\n }\n\n // Check if AI localizations are enabled before triggering\n const isEnabled = await this.isEnabled();\n if (!isEnabled) {\n return result;\n }\n\n // Don't await since localizations should be done in the background without blocking the request\n strapi\n .plugin('i18n')\n .service('ai-localizations')\n .generateDocumentLocalizations({\n model: context.contentType.uid,\n document: result,\n })\n .catch((error: any) => {\n strapi.log.error('AI Localizations generation failed', error);\n });\n\n return result;\n });\n },\n };\n};\n\nexport { createAILocalizationsService };\n"],"names":["isLocalizedAttribute","attribute","pluginOptions","i18n","localized","createAILocalizationsService","strapi","aiServerUrl","process","env","STRAPI_AI_URL","aiLocalizationJobsService","getService","UNSUPPORTED_ATTRIBUTE_TYPES","IGNORED_FIELDS","isEnabled","isAIEnabled","config","get","hasAccess","ee","features","settings","aiSettings","getSettings","aiLocalizations","generateDocumentLocalizations","model","document","isFeatureEnabled","schema","getModel","localeService","isLocalizedContentType","defaultLocale","getDefaultLocale","locale","documentId","log","warn","uid","localizedRoots","Set","translateableContent","traverseEntity","key","parent","path","remove","includes","hasLocalizedOption","type","add","raw","has","bind","Object","keys","length","info","localesList","find","targetLocales","filter","l","code","map","upsertJobForDocument","contentType","sourceLocale","status","token","tokenData","service","getAiToken","error","Error","cause","undefined","minimalContentTypeSchema","fromEntries","entries","attributes","_","attr","isLocalized","isSupportedType","minimalAttribute","repeatable","http","response","fetch","method","headers","Authorization","body","JSON","stringify","content","contentTypeSchema","ok","statusText","aiResult","json","mediaFields","Promise","all","localizations","localization","derivedDoc","documents","findOne","populate","mergedData","structuredClone","field","db","query","update","where","data","setupMiddleware","use","context","next","result","metricsService","plugin","action","sendWithAIEventProperty","catch"],"mappings":";;;AAIA,MAAMA,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OAAO,SAACA,EAAWC,aAAuBC,EAAAA,IAAAA,EAAMC,SAAc,KAAA,IAAA;AAChE,CAAA;AAEA,MAAMC,4BAA+B,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;;AAEvE,IAAA,MAAMC,WAAcC,GAAAA,OAAAA,CAAQC,GAAG,CAACC,aAAa,IAAI,kCAAA;AACjD,IAAA,MAAMC,4BAA4BC,UAAW,CAAA,sBAAA,CAAA;AAE7C,IAAA,MAAMC,2BAAuD,GAAA;AAAC,QAAA,OAAA;AAAS,QAAA,UAAA;AAAY,QAAA;AAAU,KAAA;AAC7F,IAAA,MAAMC,cAAiB,GAAA;AACrB,QAAA,IAAA;AACA,QAAA,YAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA;AACD,KAAA;IAED,OAAO;;QAEL,MAAMC,SAAAA,CAAAA,GAAAA;;AAEJ,YAAA,MAAMC,cAAcV,MAAOW,CAAAA,MAAM,CAACC,GAAG,CAAC,kBAAoB,EAAA,IAAA,CAAA;AAC1D,YAAA,IAAI,CAACF,WAAa,EAAA;gBAChB,OAAO,KAAA;AACT;;AAGA,YAAA,MAAMG,YAAYb,MAAOc,CAAAA,EAAE,CAACC,QAAQ,CAACN,SAAS,CAAC,QAAA,CAAA;AAC/C,YAAA,IAAI,CAACI,SAAW,EAAA;gBACd,OAAO,KAAA;AACT;AAEA,YAAA,MAAMG,WAAWV,UAAW,CAAA,UAAA,CAAA;YAC5B,MAAMW,UAAAA,GAAa,MAAMD,QAAAA,CAASE,WAAW,EAAA;YAC7C,IAAI,CAACD,YAAYE,eAAiB,EAAA;gBAChC,OAAO,KAA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,MAAME,iBAAiBxH,MAAOyH,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQtD,OAAO,CAAC,SAAA,CAAA;gBACrD,IAAIkD,OAAAA,CAAQK,MAAM,KAAK,SAAW,EAAA;AAChCF,oBAAAA,cAAAA,CAAeG,uBAAuB,CAAC,iBAAA,CAAA;oBACvC,OAAOJ,MAAAA;AACT;AAEA,gBAAA,IAAIF,QAAQK,MAAM,KAAK,YAAYL,OAAQK,CAAAA,MAAM,KAAK,QAAU,EAAA;AAC9DF,oBAAAA,cAAAA,CAAeG,uBAAuB,CAAC,cAAA,CAAA;AACzC;;AAGA,gBAAA,IAAI,CAAC;AAAC,oBAAA,QAAA;AAAU,oBAAA;AAAS,iBAAA,CAAChF,QAAQ,CAAC0E,OAAQK,CAAAA,MAAM,CAAG,EAAA;oBAClD,OAAOH,MAAAA;AACT;;AAGA,gBAAA,MAAM9G,SAAY,GAAA,MAAM,IAAI,CAACA,SAAS,EAAA;AACtC,gBAAA,IAAI,CAACA,SAAW,EAAA;oBACd,OAAO8G,MAAAA;AACT;;AAGAvH,gBAAAA,MAAAA,CACGyH,MAAM,CAAC,MAAA,CAAA,CACPtD,OAAO,CAAC,kBAAA,CAAA,CACR/C,6BAA6B,CAAC;oBAC7BC,KAAOgG,EAAAA,OAAAA,CAAQvD,WAAW,CAAC5B,GAAG;oBAC9BZ,QAAUiG,EAAAA;iBAEXK,CAAAA,CAAAA,KAAK,CAAC,CAACvD,KAAAA,GAAAA;AACNrE,oBAAAA,MAAAA,CAAOgC,GAAG,CAACqC,KAAK,CAAC,oCAAsCA,EAAAA,KAAAA,CAAAA;AACzD,iBAAA,CAAA;gBAEF,OAAOkD,MAAAA;AACT,aAAA,CAAA;AACF;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ var _ = require('lodash');
4
+ var fp = require('lodash/fp');
5
+ var utils = require('@strapi/utils');
6
+ var index = require('../utils/index.js');
7
+
8
+ const { isRelationalAttribute, getVisibleAttributes, isTypedAttribute, getScalarAttributes, getRelationalAttributes } = utils.contentTypes;
9
+ const { ApplicationError } = utils.errors;
10
+ const hasLocalizedOption = (modelOrAttribute)=>{
11
+ return fp.prop('pluginOptions.i18n.localized', modelOrAttribute) === true;
12
+ };
13
+ const getValidLocale = async (locale)=>{
14
+ const localesService = index.getService('locales');
15
+ if (fp.isNil(locale)) {
16
+ return localesService.getDefaultLocale();
17
+ }
18
+ const foundLocale = await localesService.findByCode(locale);
19
+ if (!foundLocale) {
20
+ throw new ApplicationError('Locale not found');
21
+ }
22
+ return locale;
23
+ };
24
+ /**
25
+ * Returns whether an attribute is localized or not
26
+ * @param {*} attribute
27
+ * @returns
28
+ */ const isLocalizedAttribute = (attribute)=>{
29
+ return hasLocalizedOption(attribute) || isRelationalAttribute(attribute) || isTypedAttribute(attribute, 'uid');
30
+ };
31
+ /**
32
+ * Returns whether a model is localized or not
33
+ * @param {*} model
34
+ * @returns
35
+ */ const isLocalizedContentType = (model)=>{
36
+ return hasLocalizedOption(model);
37
+ };
38
+ /**
39
+ * Returns the list of attribute names that are not localized
40
+ * @param {object} model
41
+ * @returns {string[]}
42
+ */ const getNonLocalizedAttributes = (model)=>{
43
+ return getVisibleAttributes(model).filter((attrName)=>!isLocalizedAttribute(model.attributes[attrName]));
44
+ };
45
+ const removeId = (value)=>{
46
+ if (typeof value === 'object' && fp.has('id', value)) {
47
+ delete value.id;
48
+ }
49
+ };
50
+ const removeIds = (model)=>(entry)=>removeIdsMut(model, fp.cloneDeep(entry));
51
+ const removeIdsMut = (model, entry)=>{
52
+ if (fp.isNil(entry)) {
53
+ return entry;
54
+ }
55
+ removeId(entry);
56
+ _.forEach(model.attributes, (attr, attrName)=>{
57
+ const value = entry[attrName];
58
+ if (attr.type === 'dynamiczone' && fp.isArray(value)) {
59
+ value.forEach((compo)=>{
60
+ if (fp.has('__component', compo)) {
61
+ const model = strapi.components[compo.__component];
62
+ removeIdsMut(model, compo);
63
+ }
64
+ });
65
+ } else if (attr.type === 'component') {
66
+ const model = strapi.components[attr.component];
67
+ if (fp.isArray(value)) {
68
+ value.forEach((compo)=>removeIdsMut(model, compo));
69
+ } else {
70
+ removeIdsMut(model, value);
71
+ }
72
+ }
73
+ });
74
+ return entry;
75
+ };
76
+ /**
77
+ * Returns a copy of an entry picking only its non localized attributes
78
+ * @param {object} model
79
+ * @param {object} entry
80
+ * @returns {object}
81
+ */ const copyNonLocalizedAttributes = (model, entry)=>{
82
+ const nonLocalizedAttributes = getNonLocalizedAttributes(model);
83
+ return fp.pipe(fp.pick(nonLocalizedAttributes), removeIds(model))(entry);
84
+ };
85
+ /**
86
+ * Returns the list of attribute names that are localized
87
+ * @param {object} model
88
+ * @returns {string[]}
89
+ */ const getLocalizedAttributes = (model)=>{
90
+ return getVisibleAttributes(model).filter((attrName)=>isLocalizedAttribute(model.attributes[attrName]));
91
+ };
92
+ /**
93
+ * Fill non localized fields of an entry if there are nil
94
+ * @param {Object} entry entry to fill
95
+ * @param {Object} relatedEntry values used to fill
96
+ * @param {Object} options
97
+ * @param {Object} options.model corresponding model
98
+ */ const fillNonLocalizedAttributes = (entry, relatedEntry, { model })=>{
99
+ if (fp.isNil(relatedEntry)) {
100
+ return;
101
+ }
102
+ const modelDef = strapi.getModel(model);
103
+ const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);
104
+ _.forEach(relatedEntryCopy, (value, field)=>{
105
+ if (fp.isNil(entry[field])) {
106
+ entry[field] = value;
107
+ }
108
+ });
109
+ };
110
+ /**
111
+ * build the populate param to
112
+ * @param {String} modelUID uid of the model, could be of a content-type or a component
113
+ */ const getNestedPopulateOfNonLocalizedAttributes = (modelUID)=>{
114
+ const schema = strapi.getModel(modelUID);
115
+ const scalarAttributes = getScalarAttributes(schema);
116
+ const nonLocalizedAttributes = getNonLocalizedAttributes(schema);
117
+ const allAttributes = [
118
+ ...scalarAttributes,
119
+ ...nonLocalizedAttributes
120
+ ];
121
+ if (schema.modelType === 'component') {
122
+ // When called recursively on a non localized component we
123
+ // need to explicitly populate that components relations
124
+ allAttributes.push(...getRelationalAttributes(schema));
125
+ }
126
+ const currentAttributesToPopulate = allAttributes.filter((value, index, self)=>{
127
+ return self.indexOf(value) === index && self.lastIndexOf(value) === index;
128
+ });
129
+ const attributesToPopulate = [
130
+ ...currentAttributesToPopulate
131
+ ];
132
+ for (const attrName of currentAttributesToPopulate){
133
+ const attr = schema.attributes[attrName];
134
+ if (attr.type === 'component') {
135
+ const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map((nestedAttr)=>`${attrName}.${nestedAttr}`);
136
+ attributesToPopulate.push(...nestedPopulate);
137
+ } else if (attr.type === 'dynamiczone') {
138
+ attr.components.forEach((componentName)=>{
139
+ const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map((nestedAttr)=>`${attrName}.${nestedAttr}`);
140
+ attributesToPopulate.push(...nestedPopulate);
141
+ });
142
+ }
143
+ }
144
+ return attributesToPopulate;
145
+ };
146
+ const contentTypes = ()=>({
147
+ isLocalizedContentType,
148
+ getValidLocale,
149
+ getLocalizedAttributes,
150
+ getNonLocalizedAttributes,
151
+ copyNonLocalizedAttributes,
152
+ fillNonLocalizedAttributes,
153
+ getNestedPopulateOfNonLocalizedAttributes
154
+ });
155
+
156
+ module.exports = contentTypes;
157
+ //# sourceMappingURL=content-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: any) => (entry: any) => removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (model: any, entry: any) => {\n if (isNil(entry)) {\n return entry;\n }\n\n removeId(entry);\n\n _.forEach(model.attributes, (attr, attrName) => {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n });\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (model: any, entry: any) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n _.forEach(relatedEntryCopy, (value, field) => {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n });\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any) => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","_","forEach","attr","type","isArray","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,kBAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,OAAAA,CAAK,gCAAgCD,gBAAsB,CAAA,KAAA,IAAA;AACpE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,gBAAW,CAAA,SAAA,CAAA;AAElC,IAAA,IAAIC,SAAMH,MAAS,CAAA,E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A,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
@@ -0,0 +1,155 @@
1
+ import _ from 'lodash';
2
+ import { isNil, pipe, pick, prop, cloneDeep, isArray, has } from 'lodash/fp';
3
+ import { contentTypes as contentTypes$1, errors } from '@strapi/utils';
4
+ import { getService } from '../utils/index.mjs';
5
+
6
+ const { isRelationalAttribute, getVisibleAttributes, isTypedAttribute, getScalarAttributes, getRelationalAttributes } = contentTypes$1;
7
+ const { ApplicationError } = errors;
8
+ const hasLocalizedOption = (modelOrAttribute)=>{
9
+ return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;
10
+ };
11
+ const getValidLocale = async (locale)=>{
12
+ const localesService = getService('locales');
13
+ if (isNil(locale)) {
14
+ return localesService.getDefaultLocale();
15
+ }
16
+ const foundLocale = await localesService.findByCode(locale);
17
+ if (!foundLocale) {
18
+ throw new ApplicationError('Locale not found');
19
+ }
20
+ return locale;
21
+ };
22
+ /**
23
+ * Returns whether an attribute is localized or not
24
+ * @param {*} attribute
25
+ * @returns
26
+ */ const isLocalizedAttribute = (attribute)=>{
27
+ return hasLocalizedOption(attribute) || isRelationalAttribute(attribute) || isTypedAttribute(attribute, 'uid');
28
+ };
29
+ /**
30
+ * Returns whether a model is localized or not
31
+ * @param {*} model
32
+ * @returns
33
+ */ const isLocalizedContentType = (model)=>{
34
+ return hasLocalizedOption(model);
35
+ };
36
+ /**
37
+ * Returns the list of attribute names that are not localized
38
+ * @param {object} model
39
+ * @returns {string[]}
40
+ */ const getNonLocalizedAttributes = (model)=>{
41
+ return getVisibleAttributes(model).filter((attrName)=>!isLocalizedAttribute(model.attributes[attrName]));
42
+ };
43
+ const removeId = (value)=>{
44
+ if (typeof value === 'object' && has('id', value)) {
45
+ delete value.id;
46
+ }
47
+ };
48
+ const removeIds = (model)=>(entry)=>removeIdsMut(model, cloneDeep(entry));
49
+ const removeIdsMut = (model, entry)=>{
50
+ if (isNil(entry)) {
51
+ return entry;
52
+ }
53
+ removeId(entry);
54
+ _.forEach(model.attributes, (attr, attrName)=>{
55
+ const value = entry[attrName];
56
+ if (attr.type === 'dynamiczone' && isArray(value)) {
57
+ value.forEach((compo)=>{
58
+ if (has('__component', compo)) {
59
+ const model = strapi.components[compo.__component];
60
+ removeIdsMut(model, compo);
61
+ }
62
+ });
63
+ } else if (attr.type === 'component') {
64
+ const model = strapi.components[attr.component];
65
+ if (isArray(value)) {
66
+ value.forEach((compo)=>removeIdsMut(model, compo));
67
+ } else {
68
+ removeIdsMut(model, value);
69
+ }
70
+ }
71
+ });
72
+ return entry;
73
+ };
74
+ /**
75
+ * Returns a copy of an entry picking only its non localized attributes
76
+ * @param {object} model
77
+ * @param {object} entry
78
+ * @returns {object}
79
+ */ const copyNonLocalizedAttributes = (model, entry)=>{
80
+ const nonLocalizedAttributes = getNonLocalizedAttributes(model);
81
+ return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);
82
+ };
83
+ /**
84
+ * Returns the list of attribute names that are localized
85
+ * @param {object} model
86
+ * @returns {string[]}
87
+ */ const getLocalizedAttributes = (model)=>{
88
+ return getVisibleAttributes(model).filter((attrName)=>isLocalizedAttribute(model.attributes[attrName]));
89
+ };
90
+ /**
91
+ * Fill non localized fields of an entry if there are nil
92
+ * @param {Object} entry entry to fill
93
+ * @param {Object} relatedEntry values used to fill
94
+ * @param {Object} options
95
+ * @param {Object} options.model corresponding model
96
+ */ const fillNonLocalizedAttributes = (entry, relatedEntry, { model })=>{
97
+ if (isNil(relatedEntry)) {
98
+ return;
99
+ }
100
+ const modelDef = strapi.getModel(model);
101
+ const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);
102
+ _.forEach(relatedEntryCopy, (value, field)=>{
103
+ if (isNil(entry[field])) {
104
+ entry[field] = value;
105
+ }
106
+ });
107
+ };
108
+ /**
109
+ * build the populate param to
110
+ * @param {String} modelUID uid of the model, could be of a content-type or a component
111
+ */ const getNestedPopulateOfNonLocalizedAttributes = (modelUID)=>{
112
+ const schema = strapi.getModel(modelUID);
113
+ const scalarAttributes = getScalarAttributes(schema);
114
+ const nonLocalizedAttributes = getNonLocalizedAttributes(schema);
115
+ const allAttributes = [
116
+ ...scalarAttributes,
117
+ ...nonLocalizedAttributes
118
+ ];
119
+ if (schema.modelType === 'component') {
120
+ // When called recursively on a non localized component we
121
+ // need to explicitly populate that components relations
122
+ allAttributes.push(...getRelationalAttributes(schema));
123
+ }
124
+ const currentAttributesToPopulate = allAttributes.filter((value, index, self)=>{
125
+ return self.indexOf(value) === index && self.lastIndexOf(value) === index;
126
+ });
127
+ const attributesToPopulate = [
128
+ ...currentAttributesToPopulate
129
+ ];
130
+ for (const attrName of currentAttributesToPopulate){
131
+ const attr = schema.attributes[attrName];
132
+ if (attr.type === 'component') {
133
+ const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map((nestedAttr)=>`${attrName}.${nestedAttr}`);
134
+ attributesToPopulate.push(...nestedPopulate);
135
+ } else if (attr.type === 'dynamiczone') {
136
+ attr.components.forEach((componentName)=>{
137
+ const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map((nestedAttr)=>`${attrName}.${nestedAttr}`);
138
+ attributesToPopulate.push(...nestedPopulate);
139
+ });
140
+ }
141
+ }
142
+ return attributesToPopulate;
143
+ };
144
+ const contentTypes = ()=>({
145
+ isLocalizedContentType,
146
+ getValidLocale,
147
+ getLocalizedAttributes,
148
+ getNonLocalizedAttributes,
149
+ copyNonLocalizedAttributes,
150
+ fillNonLocalizedAttributes,
151
+ getNestedPopulateOfNonLocalizedAttributes
152
+ });
153
+
154
+ export { contentTypes as default };
155
+ //# sourceMappingURL=content-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-types.mjs","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: any) => (entry: any) => removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (model: any, entry: any) => {\n if (isNil(entry)) {\n return entry;\n }\n\n removeId(entry);\n\n _.forEach(model.attributes, (attr, attrName) => {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n });\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (model: any, entry: any) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n _.forEach(relatedEntryCopy, (value, field) => {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n });\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any) => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","_","forEach","attr","type","isArray","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,cAA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AACvB,gBAAA,MAAMH,cAAiBb,GAAAA,yCAAAA,CAA0CgB,aAAeF,CAAAA,CAAAA,GAAG,CACjF,CAACC,UAAe,GAAA,CAAC,EAAE9C,QAAAA,CAAS,CAAC,EAAE8C,WAAW,CAAC,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,aAAA,CAAA;AACF;AACF;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEMK,MAAAA,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var permissions = require('./permissions.js');
4
+ var metrics = require('./metrics.js');
5
+ var localizations = require('./localizations.js');
6
+ var locales = require('./locales.js');
7
+ var isoLocales = require('./iso-locales.js');
8
+ var contentTypes = require('./content-types.js');
9
+ var index = require('./sanitize/index.js');
10
+ var settings = require('./settings.js');
11
+ var aiLocalizations = require('./ai-localizations.js');
12
+ var aiLocalizationJobs = require('./ai-localization-jobs.js');
13
+
14
+ var services = {
15
+ permissions,
16
+ metrics,
17
+ localizations,
18
+ locales,
19
+ sanitize: index,
20
+ 'iso-locales': isoLocales,
21
+ 'content-types': contentTypes,
22
+ 'ai-localizations': aiLocalizations.createAILocalizationsService,
23
+ 'ai-localization-jobs': aiLocalizationJobs.createAILocalizationJobsService,
24
+ settings: settings.createSettingsService
25
+ };
26
+
27
+ module.exports = services;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import permissions from './permissions';\nimport metrics from './metrics';\nimport localizations from './localizations';\nimport locales from './locales';\nimport isoLocales from './iso-locales';\nimport contentTypes from './content-types';\nimport sanitize from './sanitize';\nimport { createSettingsService } from './settings';\nimport { createAILocalizationsService } from './ai-localizations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n 'ai-localizations': createAILocalizationsService,\n 'ai-localization-jobs': createAILocalizationJobsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAILocalizationJobsService","settings","createSettingsService"],"mappings":";;;;;;;;;;;;;AAWA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,cAAAA,KAAAA;IACA,aAAeC,EAAAA,UAAAA;IACf,eAAiBC,EAAAA,YAAAA;IACjB,kBAAoBC,EAAAA,4CAAAA;IACpB,sBAAwBC,EAAAA,kDAAAA;IACxBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
@@ -0,0 +1,26 @@
1
+ import permissions from './permissions.mjs';
2
+ import metrics from './metrics.mjs';
3
+ import localizations from './localizations.mjs';
4
+ import locales from './locales.mjs';
5
+ import isoLocalesService from './iso-locales.mjs';
6
+ import contentTypes from './content-types.mjs';
7
+ import sanitize from './sanitize/index.mjs';
8
+ import { createSettingsService } from './settings.mjs';
9
+ import { createAILocalizationsService } from './ai-localizations.mjs';
10
+ import { createAILocalizationJobsService } from './ai-localization-jobs.mjs';
11
+
12
+ var services = {
13
+ permissions,
14
+ metrics,
15
+ localizations,
16
+ locales,
17
+ sanitize,
18
+ 'iso-locales': isoLocalesService,
19
+ 'content-types': contentTypes,
20
+ 'ai-localizations': createAILocalizationsService,
21
+ 'ai-localization-jobs': createAILocalizationJobsService,
22
+ settings: createSettingsService
23
+ };
24
+
25
+ export { services as default };
26
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import permissions from './permissions';\nimport metrics from './metrics';\nimport localizations from './localizations';\nimport locales from './locales';\nimport isoLocales from './iso-locales';\nimport contentTypes from './content-types';\nimport sanitize from './sanitize';\nimport { createSettingsService } from './settings';\nimport { createAILocalizationsService } from './ai-localizations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n 'ai-localizations': createAILocalizationsService,\n 'ai-localization-jobs': createAILocalizationJobsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAILocalizationJobsService","settings","createSettingsService"],"mappings":";;;;;;;;;;;AAWA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,QAAAA;IACA,aAAeC,EAAAA,iBAAAA;IACf,eAAiBC,EAAAA,YAAAA;IACjB,kBAAoBC,EAAAA,4BAAAA;IACpB,sBAAwBC,EAAAA,+BAAAA;IACxBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ require('../constants/index.js');
4
+ var isoLocales = require('../constants/iso-locales.json.js');
5
+
6
+ const getIsoLocales = ()=>isoLocales;
7
+ const isoLocalesService = ()=>({
8
+ getIsoLocales
9
+ });
10
+
11
+ module.exports = isoLocalesService;
12
+ //# sourceMappingURL=iso-locales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iso-locales.js","sources":["../../../server/src/services/iso-locales.ts"],"sourcesContent":["import { isoLocales } from '../constants';\n\nconst getIsoLocales = () => isoLocales;\n\nconst isoLocalesService = () => ({\n getIsoLocales,\n});\n\ntype ISOLocalesService = typeof isoLocalesService;\n\nexport default isoLocalesService;\nexport type { ISOLocalesService };\n"],"names":["getIsoLocales","isoLocales","isoLocalesService"],"mappings":";;;;;AAEA,MAAMA,gBAAgB,IAAMC,UAAAA;AAEtBC,MAAAA,iBAAAA,GAAoB,KAAO;AAC/BF,QAAAA;KACF;;;;"}
@@ -0,0 +1,10 @@
1
+ import '../constants/index.mjs';
2
+ import isoLocales from '../constants/iso-locales.json.mjs';
3
+
4
+ const getIsoLocales = ()=>isoLocales;
5
+ const isoLocalesService = ()=>({
6
+ getIsoLocales
7
+ });
8
+
9
+ export { isoLocalesService as default };
10
+ //# sourceMappingURL=iso-locales.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iso-locales.mjs","sources":["../../../server/src/services/iso-locales.ts"],"sourcesContent":["import { isoLocales } from '../constants';\n\nconst getIsoLocales = () => isoLocales;\n\nconst isoLocalesService = () => ({\n getIsoLocales,\n});\n\ntype ISOLocalesService = typeof isoLocalesService;\n\nexport default isoLocalesService;\nexport type { ISOLocalesService };\n"],"names":["getIsoLocales","isoLocales","isoLocalesService"],"mappings":";;;AAEA,MAAMA,gBAAgB,IAAMC,UAAAA;AAEtBC,MAAAA,iBAAAA,GAAoB,KAAO;AAC/BF,QAAAA;KACF;;;;"}
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ var fp = require('lodash/fp');
4
+ var index$1 = require('../constants/index.js');
5
+ var index = require('../utils/index.js');
6
+
7
+ const find = (params = {})=>strapi.db.query('plugin::i18n.locale').findMany({
8
+ where: params
9
+ });
10
+ const findById = (id)=>strapi.db.query('plugin::i18n.locale').findOne({
11
+ where: {
12
+ id
13
+ }
14
+ });
15
+ const findByCode = (code)=>strapi.db.query('plugin::i18n.locale').findOne({
16
+ where: {
17
+ code
18
+ }
19
+ });
20
+ const count = (params = {})=>strapi.db.query('plugin::i18n.locale').count({
21
+ where: params
22
+ });
23
+ const create = async (locale)=>{
24
+ const result = await strapi.db.query('plugin::i18n.locale').create({
25
+ data: locale
26
+ });
27
+ index.getService('metrics').sendDidUpdateI18nLocalesEvent();
28
+ return result;
29
+ };
30
+ const update = async (params, updates)=>{
31
+ const result = await strapi.db.query('plugin::i18n.locale').update({
32
+ where: params,
33
+ data: updates
34
+ });
35
+ index.getService('metrics').sendDidUpdateI18nLocalesEvent();
36
+ return result;
37
+ };
38
+ const deleteFn = async ({ id })=>{
39
+ const localeToDelete = await findById(id);
40
+ if (localeToDelete) {
41
+ await deleteAllLocalizedEntriesFor({
42
+ locale: localeToDelete.code
43
+ });
44
+ const result = await strapi.db.query('plugin::i18n.locale').delete({
45
+ where: {
46
+ id
47
+ }
48
+ });
49
+ index.getService('metrics').sendDidUpdateI18nLocalesEvent();
50
+ return result;
51
+ }
52
+ return localeToDelete;
53
+ };
54
+ const setDefaultLocale = ({ code })=>index.getCoreStore().set({
55
+ key: 'default_locale',
56
+ value: code
57
+ });
58
+ const getDefaultLocale = ()=>index.getCoreStore().get({
59
+ key: 'default_locale'
60
+ });
61
+ const setIsDefault = async (locales)=>{
62
+ if (fp.isNil(locales)) {
63
+ return locales;
64
+ }
65
+ const actualDefault = await getDefaultLocale();
66
+ if (Array.isArray(locales)) {
67
+ return locales.map((locale)=>({
68
+ ...locale,
69
+ isDefault: actualDefault === locale.code
70
+ }));
71
+ }
72
+ // single locale
73
+ return {
74
+ ...locales,
75
+ isDefault: actualDefault === locales.code
76
+ };
77
+ };
78
+ const initDefaultLocale = async ()=>{
79
+ const existingLocalesNb = await strapi.db.query('plugin::i18n.locale').count();
80
+ if (existingLocalesNb === 0) {
81
+ await create(index$1.DEFAULT_LOCALE);
82
+ await setDefaultLocale({
83
+ code: index$1.DEFAULT_LOCALE.code
84
+ });
85
+ }
86
+ };
87
+ const deleteAllLocalizedEntriesFor = async ({ locale })=>{
88
+ const { isLocalizedContentType } = index.getService('content-types');
89
+ const localizedModels = Object.values(strapi.contentTypes).filter(isLocalizedContentType);
90
+ for (const model of localizedModels){
91
+ // FIXME: delete many content & their associations
92
+ await strapi.db.query(model.uid).deleteMany({
93
+ where: {
94
+ locale
95
+ }
96
+ });
97
+ }
98
+ };
99
+ const locales = ()=>({
100
+ find,
101
+ findById,
102
+ findByCode,
103
+ create,
104
+ update,
105
+ count,
106
+ setDefaultLocale,
107
+ getDefaultLocale,
108
+ setIsDefault,
109
+ delete: deleteFn,
110
+ initDefaultLocale
111
+ });
112
+
113
+ module.exports = locales;
114
+ //# sourceMappingURL=locales.js.map