@strapi/i18n 0.0.0-next.820adfc37c687bbcc4a213ae6929c541358b71e8 → 0.0.0-next.83367b80833204c0744701aef452a8d8d2ce25b6

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 (422) 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 +727 -0
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -0
  7. package/dist/admin/components/CMHeaderActions.mjs +702 -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 +82 -0
  30. package/dist/admin/components/LocaleListCell.js.map +1 -0
  31. package/dist/admin/components/LocaleListCell.mjs +80 -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 +43 -0
  50. package/dist/admin/contentManagerHooks/listView.js.map +1 -0
  51. package/dist/admin/contentManagerHooks/listView.mjs +41 -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/useI18n.js +78 -0
  58. package/dist/admin/hooks/useI18n.js.map +1 -0
  59. package/dist/admin/hooks/useI18n.mjs +57 -0
  60. package/dist/admin/hooks/useI18n.mjs.map +1 -0
  61. package/dist/admin/index.js +225 -5
  62. package/dist/admin/index.js.map +1 -1
  63. package/dist/admin/index.mjs +201 -5
  64. package/dist/admin/index.mjs.map +1 -1
  65. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +71 -0
  66. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -0
  67. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +69 -0
  68. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -0
  69. package/dist/admin/middlewares/extendCTBInitialData.js +40 -0
  70. package/dist/admin/middlewares/extendCTBInitialData.js.map +1 -0
  71. package/dist/admin/middlewares/extendCTBInitialData.mjs +38 -0
  72. package/dist/admin/middlewares/extendCTBInitialData.mjs.map +1 -0
  73. package/dist/admin/middlewares/rbac-middleware.js +49 -0
  74. package/dist/admin/middlewares/rbac-middleware.js.map +1 -0
  75. package/dist/admin/middlewares/rbac-middleware.mjs +28 -0
  76. package/dist/admin/middlewares/rbac-middleware.mjs.map +1 -0
  77. package/dist/admin/pages/SettingsPage.js +182 -0
  78. package/dist/admin/pages/SettingsPage.js.map +1 -0
  79. package/dist/admin/pages/SettingsPage.mjs +179 -0
  80. package/dist/admin/pages/SettingsPage.mjs.map +1 -0
  81. package/dist/admin/pluginId.js +6 -0
  82. package/dist/admin/pluginId.js.map +1 -0
  83. package/dist/admin/pluginId.mjs +4 -0
  84. package/dist/admin/pluginId.mjs.map +1 -0
  85. package/dist/admin/services/api.js +14 -0
  86. package/dist/admin/services/api.js.map +1 -0
  87. package/dist/admin/services/api.mjs +12 -0
  88. package/dist/admin/services/api.mjs.map +1 -0
  89. package/dist/admin/services/locales.js +72 -0
  90. package/dist/admin/services/locales.js.map +1 -0
  91. package/dist/admin/services/locales.mjs +66 -0
  92. package/dist/admin/services/locales.mjs.map +1 -0
  93. package/dist/admin/services/relations.js +23 -0
  94. package/dist/admin/services/relations.js.map +1 -0
  95. package/dist/admin/services/relations.mjs +21 -0
  96. package/dist/admin/services/relations.mjs.map +1 -0
  97. package/dist/admin/services/settings.js +29 -0
  98. package/dist/admin/services/settings.js.map +1 -0
  99. package/dist/admin/services/settings.mjs +26 -0
  100. package/dist/admin/services/settings.mjs.map +1 -0
  101. package/dist/admin/src/components/CMHeaderActions.d.ts +1 -1
  102. package/dist/admin/src/components/LocaleListCell.d.ts +4 -4
  103. package/dist/admin/src/components/tests/CreateLocale.test.d.ts +1 -0
  104. package/dist/admin/src/components/tests/DeleteLocale.test.d.ts +1 -0
  105. package/dist/admin/src/components/tests/EditLocale.test.d.ts +1 -0
  106. package/dist/admin/src/components/tests/LocaleListCell.test.d.ts +1 -0
  107. package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +1 -1
  108. package/dist/admin/src/pages/tests/SettingsPage.test.d.ts +1 -0
  109. package/dist/admin/src/services/api.d.ts +1 -1
  110. package/dist/admin/src/services/locales.d.ts +1 -1
  111. package/dist/admin/src/services/relations.d.ts +1 -1
  112. package/dist/admin/src/services/settings.d.ts +5 -0
  113. package/dist/admin/src/utils/schemas.d.ts +642 -16
  114. package/dist/admin/tests/server.d.ts +1 -0
  115. package/dist/admin/tests/utils.d.ts +6 -0
  116. package/dist/admin/translations/de.json.js +66 -0
  117. package/dist/admin/translations/de.json.js.map +1 -0
  118. package/dist/admin/translations/de.json.mjs +64 -0
  119. package/dist/admin/translations/de.json.mjs.map +1 -0
  120. package/dist/admin/translations/dk.json.js +66 -0
  121. package/dist/admin/translations/dk.json.js.map +1 -0
  122. package/dist/admin/translations/dk.json.mjs +64 -0
  123. package/dist/admin/translations/dk.json.mjs.map +1 -0
  124. package/dist/admin/translations/en.json.js +83 -0
  125. package/dist/admin/translations/en.json.js.map +1 -0
  126. package/dist/admin/translations/en.json.mjs +81 -0
  127. package/dist/admin/translations/en.json.mjs.map +1 -0
  128. package/dist/admin/translations/es.json.js +66 -0
  129. package/dist/admin/translations/es.json.js.map +1 -0
  130. package/dist/admin/translations/es.json.mjs +64 -0
  131. package/dist/admin/translations/es.json.mjs.map +1 -0
  132. package/dist/admin/translations/fr.json.js +66 -0
  133. package/dist/admin/translations/fr.json.js.map +1 -0
  134. package/dist/admin/translations/fr.json.mjs +64 -0
  135. package/dist/admin/translations/fr.json.mjs.map +1 -0
  136. package/dist/admin/translations/ko.json.js +65 -0
  137. package/dist/admin/translations/ko.json.js.map +1 -0
  138. package/dist/admin/translations/ko.json.mjs +63 -0
  139. package/dist/admin/translations/ko.json.mjs.map +1 -0
  140. package/dist/admin/translations/pl.json.js +66 -0
  141. package/dist/admin/translations/pl.json.js.map +1 -0
  142. package/dist/admin/translations/pl.json.mjs +64 -0
  143. package/dist/admin/translations/pl.json.mjs.map +1 -0
  144. package/dist/admin/translations/ru.json.js +68 -0
  145. package/dist/admin/translations/ru.json.js.map +1 -0
  146. package/dist/admin/translations/ru.json.mjs +66 -0
  147. package/dist/admin/translations/ru.json.mjs.map +1 -0
  148. package/dist/admin/translations/tr.json.js +66 -0
  149. package/dist/admin/translations/tr.json.js.map +1 -0
  150. package/dist/admin/translations/tr.json.mjs +64 -0
  151. package/dist/admin/translations/tr.json.mjs.map +1 -0
  152. package/dist/admin/translations/uk.json.js +82 -0
  153. package/dist/admin/translations/uk.json.js.map +1 -0
  154. package/dist/admin/translations/uk.json.mjs +80 -0
  155. package/dist/admin/translations/uk.json.mjs.map +1 -0
  156. package/dist/admin/translations/zh-Hans.json.js +57 -0
  157. package/dist/admin/translations/zh-Hans.json.js.map +1 -0
  158. package/dist/admin/translations/zh-Hans.json.mjs +55 -0
  159. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -0
  160. package/dist/admin/translations/zh.json.js +66 -0
  161. package/dist/admin/translations/zh.json.js.map +1 -0
  162. package/dist/admin/translations/zh.json.mjs +64 -0
  163. package/dist/admin/translations/zh.json.mjs.map +1 -0
  164. package/dist/admin/utils/baseQuery.js +8 -0
  165. package/dist/admin/utils/baseQuery.js.map +1 -0
  166. package/dist/admin/utils/baseQuery.mjs +6 -0
  167. package/dist/admin/utils/baseQuery.mjs.map +1 -0
  168. package/dist/admin/utils/clean.js +70 -0
  169. package/dist/admin/utils/clean.js.map +1 -0
  170. package/dist/admin/utils/clean.mjs +68 -0
  171. package/dist/admin/utils/clean.mjs.map +1 -0
  172. package/dist/admin/utils/fields.js +34 -0
  173. package/dist/admin/utils/fields.js.map +1 -0
  174. package/dist/admin/utils/fields.mjs +31 -0
  175. package/dist/admin/utils/fields.mjs.map +1 -0
  176. package/dist/admin/utils/getTranslation.js +8 -0
  177. package/dist/admin/utils/getTranslation.js.map +1 -0
  178. package/dist/admin/utils/getTranslation.mjs +6 -0
  179. package/dist/admin/utils/getTranslation.mjs.map +1 -0
  180. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  181. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  182. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  183. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  184. package/dist/admin/utils/schemas.js +74 -0
  185. package/dist/admin/utils/schemas.js.map +1 -0
  186. package/dist/admin/utils/schemas.mjs +72 -0
  187. package/dist/admin/utils/schemas.mjs.map +1 -0
  188. package/dist/admin/utils/strings.js +6 -0
  189. package/dist/admin/utils/strings.js.map +1 -0
  190. package/dist/admin/utils/strings.mjs +4 -0
  191. package/dist/admin/utils/strings.mjs.map +1 -0
  192. package/dist/server/bootstrap.js +79 -0
  193. package/dist/server/bootstrap.js.map +1 -0
  194. package/dist/server/bootstrap.mjs +77 -0
  195. package/dist/server/bootstrap.mjs.map +1 -0
  196. package/dist/server/constants/index.js +29 -0
  197. package/dist/server/constants/index.js.map +1 -0
  198. package/dist/server/constants/index.mjs +25 -0
  199. package/dist/server/constants/index.mjs.map +1 -0
  200. package/dist/server/constants/iso-locales.json.js +2423 -0
  201. package/dist/server/constants/iso-locales.json.js.map +1 -0
  202. package/dist/server/constants/iso-locales.json.mjs +2421 -0
  203. package/dist/server/constants/iso-locales.json.mjs.map +1 -0
  204. package/dist/server/content-types/index.js +10 -0
  205. package/dist/server/content-types/index.js.map +1 -0
  206. package/dist/server/content-types/index.mjs +8 -0
  207. package/dist/server/content-types/index.mjs.map +1 -0
  208. package/dist/server/content-types/locale/index.js +10 -0
  209. package/dist/server/content-types/locale/index.js.map +1 -0
  210. package/dist/server/content-types/locale/index.mjs +8 -0
  211. package/dist/server/content-types/locale/index.mjs.map +1 -0
  212. package/dist/server/content-types/locale/schema.json.js +46 -0
  213. package/dist/server/content-types/locale/schema.json.js.map +1 -0
  214. package/dist/server/content-types/locale/schema.json.mjs +38 -0
  215. package/dist/server/content-types/locale/schema.json.mjs.map +1 -0
  216. package/dist/server/controllers/content-types.js +76 -0
  217. package/dist/server/controllers/content-types.js.map +1 -0
  218. package/dist/server/controllers/content-types.mjs +74 -0
  219. package/dist/server/controllers/content-types.mjs.map +1 -0
  220. package/dist/server/controllers/index.js +16 -0
  221. package/dist/server/controllers/index.js.map +1 -0
  222. package/dist/server/controllers/index.mjs +14 -0
  223. package/dist/server/controllers/index.mjs.map +1 -0
  224. package/dist/server/controllers/iso-locales.js +13 -0
  225. package/dist/server/controllers/iso-locales.js.map +1 -0
  226. package/dist/server/controllers/iso-locales.mjs +11 -0
  227. package/dist/server/controllers/iso-locales.mjs.map +1 -0
  228. package/dist/server/controllers/locales.js +108 -0
  229. package/dist/server/controllers/locales.js.map +1 -0
  230. package/dist/server/controllers/locales.mjs +87 -0
  231. package/dist/server/controllers/locales.mjs.map +1 -0
  232. package/dist/server/controllers/settings.js +24 -0
  233. package/dist/server/controllers/settings.js.map +1 -0
  234. package/dist/server/controllers/settings.mjs +22 -0
  235. package/dist/server/controllers/settings.mjs.map +1 -0
  236. package/dist/server/controllers/validate-locale-creation.js +47 -0
  237. package/dist/server/controllers/validate-locale-creation.js.map +1 -0
  238. package/dist/server/controllers/validate-locale-creation.mjs +45 -0
  239. package/dist/server/controllers/validate-locale-creation.mjs.map +1 -0
  240. package/dist/server/domain/locale.js +11 -0
  241. package/dist/server/domain/locale.js.map +1 -0
  242. package/dist/server/domain/locale.mjs +9 -0
  243. package/dist/server/domain/locale.mjs.map +1 -0
  244. package/dist/server/graphql.js +115 -0
  245. package/dist/server/graphql.js.map +1 -0
  246. package/dist/server/graphql.mjs +113 -0
  247. package/dist/server/graphql.mjs.map +1 -0
  248. package/dist/server/index.js +18 -3460
  249. package/dist/server/index.js.map +1 -1
  250. package/dist/server/index.mjs +17 -3443
  251. package/dist/server/index.mjs.map +1 -1
  252. package/dist/server/register.js +79 -0
  253. package/dist/server/register.js.map +1 -0
  254. package/dist/server/register.mjs +77 -0
  255. package/dist/server/register.mjs.map +1 -0
  256. package/dist/server/routes/admin.js +122 -0
  257. package/dist/server/routes/admin.js.map +1 -0
  258. package/dist/server/routes/admin.mjs +120 -0
  259. package/dist/server/routes/admin.mjs.map +1 -0
  260. package/dist/server/routes/content-api.js +19 -0
  261. package/dist/server/routes/content-api.js.map +1 -0
  262. package/dist/server/routes/content-api.mjs +17 -0
  263. package/dist/server/routes/content-api.mjs.map +1 -0
  264. package/dist/server/routes/index.js +12 -0
  265. package/dist/server/routes/index.js.map +1 -0
  266. package/dist/server/routes/index.mjs +10 -0
  267. package/dist/server/routes/index.mjs.map +1 -0
  268. package/dist/server/routes/validation/locale.js +57 -0
  269. package/dist/server/routes/validation/locale.js.map +1 -0
  270. package/dist/server/routes/validation/locale.mjs +36 -0
  271. package/dist/server/routes/validation/locale.mjs.map +1 -0
  272. package/dist/server/services/ai-localizations.js +28 -0
  273. package/dist/server/services/ai-localizations.js.map +1 -0
  274. package/dist/server/services/ai-localizations.mjs +26 -0
  275. package/dist/server/services/ai-localizations.mjs.map +1 -0
  276. package/dist/server/services/content-types.js +157 -0
  277. package/dist/server/services/content-types.js.map +1 -0
  278. package/dist/server/services/content-types.mjs +155 -0
  279. package/dist/server/services/content-types.mjs.map +1 -0
  280. package/dist/server/services/index.js +26 -0
  281. package/dist/server/services/index.js.map +1 -0
  282. package/dist/server/services/index.mjs +24 -0
  283. package/dist/server/services/index.mjs.map +1 -0
  284. package/dist/server/services/iso-locales.js +12 -0
  285. package/dist/server/services/iso-locales.js.map +1 -0
  286. package/dist/server/services/iso-locales.mjs +10 -0
  287. package/dist/server/services/iso-locales.mjs.map +1 -0
  288. package/dist/server/services/locales.js +114 -0
  289. package/dist/server/services/locales.js.map +1 -0
  290. package/dist/server/services/locales.mjs +112 -0
  291. package/dist/server/services/locales.mjs.map +1 -0
  292. package/dist/server/services/localizations.js +68 -0
  293. package/dist/server/services/localizations.js.map +1 -0
  294. package/dist/server/services/localizations.mjs +66 -0
  295. package/dist/server/services/localizations.mjs.map +1 -0
  296. package/dist/server/services/metrics.js +30 -0
  297. package/dist/server/services/metrics.js.map +1 -0
  298. package/dist/server/services/metrics.mjs +28 -0
  299. package/dist/server/services/metrics.mjs.map +1 -0
  300. package/dist/server/services/permissions/actions.js +136 -0
  301. package/dist/server/services/permissions/actions.js.map +1 -0
  302. package/dist/server/services/permissions/actions.mjs +134 -0
  303. package/dist/server/services/permissions/actions.mjs.map +1 -0
  304. package/dist/server/services/permissions/engine.js +52 -0
  305. package/dist/server/services/permissions/engine.js.map +1 -0
  306. package/dist/server/services/permissions/engine.mjs +50 -0
  307. package/dist/server/services/permissions/engine.mjs.map +1 -0
  308. package/dist/server/services/permissions/sections-builder.js +45 -0
  309. package/dist/server/services/permissions/sections-builder.js.map +1 -0
  310. package/dist/server/services/permissions/sections-builder.mjs +43 -0
  311. package/dist/server/services/permissions/sections-builder.mjs.map +1 -0
  312. package/dist/server/services/permissions.js +14 -0
  313. package/dist/server/services/permissions.js.map +1 -0
  314. package/dist/server/services/permissions.mjs +12 -0
  315. package/dist/server/services/permissions.mjs.map +1 -0
  316. package/dist/server/services/sanitize/index.js +34 -0
  317. package/dist/server/services/sanitize/index.js.map +1 -0
  318. package/dist/server/services/sanitize/index.mjs +32 -0
  319. package/dist/server/services/sanitize/index.mjs.map +1 -0
  320. package/dist/server/services/settings.js +25 -0
  321. package/dist/server/services/settings.js.map +1 -0
  322. package/dist/server/services/settings.mjs +23 -0
  323. package/dist/server/services/settings.mjs.map +1 -0
  324. package/dist/server/src/controllers/index.d.ts +4 -0
  325. package/dist/server/src/controllers/index.d.ts.map +1 -1
  326. package/dist/server/src/controllers/settings.d.ts +7 -0
  327. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  328. package/dist/server/src/index.d.ts +22 -7
  329. package/dist/server/src/index.d.ts.map +1 -1
  330. package/dist/server/src/routes/admin.d.ts.map +1 -1
  331. package/dist/server/src/routes/content-api.d.ts +5 -8
  332. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  333. package/dist/server/src/routes/index.d.ts +3 -7
  334. package/dist/server/src/routes/index.d.ts.map +1 -1
  335. package/dist/server/src/routes/validation/index.d.ts +2 -0
  336. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  337. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  338. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  339. package/dist/server/src/services/ai-localizations.d.ts +8 -0
  340. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  341. package/dist/server/src/services/index.d.ts +15 -0
  342. package/dist/server/src/services/index.d.ts.map +1 -1
  343. package/dist/server/src/services/localizations.d.ts +1 -1
  344. package/dist/server/src/services/localizations.d.ts.map +1 -1
  345. package/dist/server/src/services/settings.d.ts +13 -0
  346. package/dist/server/src/services/settings.d.ts.map +1 -0
  347. package/dist/server/src/utils/index.d.ts +3 -1
  348. package/dist/server/src/utils/index.d.ts.map +1 -1
  349. package/dist/server/src/validation/settings.d.ts +12 -0
  350. package/dist/server/src/validation/settings.d.ts.map +1 -0
  351. package/dist/server/utils/index.js +16 -0
  352. package/dist/server/utils/index.js.map +1 -0
  353. package/dist/server/utils/index.mjs +13 -0
  354. package/dist/server/utils/index.mjs.map +1 -0
  355. package/dist/server/validation/content-types.js +18 -0
  356. package/dist/server/validation/content-types.js.map +1 -0
  357. package/dist/server/validation/content-types.mjs +16 -0
  358. package/dist/server/validation/content-types.mjs.map +1 -0
  359. package/dist/server/validation/locales.js +23 -0
  360. package/dist/server/validation/locales.js.map +1 -0
  361. package/dist/server/validation/locales.mjs +20 -0
  362. package/dist/server/validation/locales.mjs.map +1 -0
  363. package/dist/server/validation/settings.js +11 -0
  364. package/dist/server/validation/settings.js.map +1 -0
  365. package/dist/server/validation/settings.mjs +9 -0
  366. package/dist/server/validation/settings.mjs.map +1 -0
  367. package/dist/shared/contracts/content-manager.d.ts +1 -1
  368. package/dist/shared/contracts/settings.d.ts +40 -0
  369. package/dist/shared/contracts/shared.d.ts +1 -1
  370. package/package.json +18 -14
  371. package/dist/_chunks/SettingsPage-BAx9nmep.mjs +0 -554
  372. package/dist/_chunks/SettingsPage-BAx9nmep.mjs.map +0 -1
  373. package/dist/_chunks/SettingsPage-BTgjb2KS.js +0 -573
  374. package/dist/_chunks/SettingsPage-BTgjb2KS.js.map +0 -1
  375. package/dist/_chunks/de-9eCAqqrB.mjs +0 -66
  376. package/dist/_chunks/de-9eCAqqrB.mjs.map +0 -1
  377. package/dist/_chunks/de-DtWiGdHl.js +0 -66
  378. package/dist/_chunks/de-DtWiGdHl.js.map +0 -1
  379. package/dist/_chunks/dk-2qBjxt-P.mjs +0 -66
  380. package/dist/_chunks/dk-2qBjxt-P.mjs.map +0 -1
  381. package/dist/_chunks/dk-D8C-casx.js +0 -66
  382. package/dist/_chunks/dk-D8C-casx.js.map +0 -1
  383. package/dist/_chunks/en-BKBz3tro.js +0 -81
  384. package/dist/_chunks/en-BKBz3tro.js.map +0 -1
  385. package/dist/_chunks/en-DlXfy6Gy.mjs +0 -81
  386. package/dist/_chunks/en-DlXfy6Gy.mjs.map +0 -1
  387. package/dist/_chunks/es-DS-XFGSw.js +0 -66
  388. package/dist/_chunks/es-DS-XFGSw.js.map +0 -1
  389. package/dist/_chunks/es-DlmMVaBG.mjs +0 -66
  390. package/dist/_chunks/es-DlmMVaBG.mjs.map +0 -1
  391. package/dist/_chunks/fr-3S6ke71d.mjs +0 -66
  392. package/dist/_chunks/fr-3S6ke71d.mjs.map +0 -1
  393. package/dist/_chunks/fr-BTjekDpq.js +0 -66
  394. package/dist/_chunks/fr-BTjekDpq.js.map +0 -1
  395. package/dist/_chunks/index-3yyF237r.js +0 -1644
  396. package/dist/_chunks/index-3yyF237r.js.map +0 -1
  397. package/dist/_chunks/index-B0NijiBB.mjs +0 -1623
  398. package/dist/_chunks/index-B0NijiBB.mjs.map +0 -1
  399. package/dist/_chunks/ko-DmcGUBQ3.js +0 -65
  400. package/dist/_chunks/ko-DmcGUBQ3.js.map +0 -1
  401. package/dist/_chunks/ko-qTjQ8IMw.mjs +0 -65
  402. package/dist/_chunks/ko-qTjQ8IMw.mjs.map +0 -1
  403. package/dist/_chunks/pl-B67TSHqT.mjs +0 -66
  404. package/dist/_chunks/pl-B67TSHqT.mjs.map +0 -1
  405. package/dist/_chunks/pl-Cn5RYonZ.js +0 -66
  406. package/dist/_chunks/pl-Cn5RYonZ.js.map +0 -1
  407. package/dist/_chunks/ru-BMBgVL3s.js +0 -68
  408. package/dist/_chunks/ru-BMBgVL3s.js.map +0 -1
  409. package/dist/_chunks/ru-hagMa57T.mjs +0 -68
  410. package/dist/_chunks/ru-hagMa57T.mjs.map +0 -1
  411. package/dist/_chunks/tr-CarUU76c.js +0 -66
  412. package/dist/_chunks/tr-CarUU76c.js.map +0 -1
  413. package/dist/_chunks/tr-Dw_jmkG-.mjs +0 -66
  414. package/dist/_chunks/tr-Dw_jmkG-.mjs.map +0 -1
  415. package/dist/_chunks/zh-57YM4amO.mjs +0 -66
  416. package/dist/_chunks/zh-57YM4amO.mjs.map +0 -1
  417. package/dist/_chunks/zh-CukOviB0.js +0 -66
  418. package/dist/_chunks/zh-CukOviB0.js.map +0 -1
  419. package/dist/_chunks/zh-Hans-DSHIXAa3.js +0 -57
  420. package/dist/_chunks/zh-Hans-DSHIXAa3.js.map +0 -1
  421. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs +0 -57
  422. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs.map +0 -1
@@ -0,0 +1,26 @@
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
+
13
+ var services = {
14
+ permissions,
15
+ metrics,
16
+ localizations,
17
+ locales,
18
+ sanitize: index,
19
+ 'iso-locales': isoLocales,
20
+ 'content-types': contentTypes,
21
+ aiLocalizations: aiLocalizations.createAILocalizationsService,
22
+ settings: settings.createSettingsService
23
+ };
24
+
25
+ module.exports = services;
26
+ //# 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';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n aiLocalizations: createAILocalizationsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","aiLocalizations","createAILocalizationsService","settings","createSettingsService"],"mappings":";;;;;;;;;;;;AAUA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,cAAAA,KAAAA;IACA,aAAeC,EAAAA,UAAAA;IACf,eAAiBC,EAAAA,YAAAA;IACjBC,eAAiBC,EAAAA,4CAAAA;IACjBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
@@ -0,0 +1,24 @@
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
+
11
+ var services = {
12
+ permissions,
13
+ metrics,
14
+ localizations,
15
+ locales,
16
+ sanitize,
17
+ 'iso-locales': isoLocalesService,
18
+ 'content-types': contentTypes,
19
+ aiLocalizations: createAILocalizationsService,
20
+ settings: createSettingsService
21
+ };
22
+
23
+ export { services as default };
24
+ //# 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';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n aiLocalizations: createAILocalizationsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","aiLocalizations","createAILocalizationsService","settings","createSettingsService"],"mappings":";;;;;;;;;;AAUA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,QAAAA;IACA,aAAeC,EAAAA,iBAAAA;IACf,eAAiBC,EAAAA,YAAAA;IACjBC,eAAiBC,EAAAA,4BAAAA;IACjBC,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locales.js","sources":["../../../server/src/services/locales.ts"],"sourcesContent":["import { isNil } from 'lodash/fp';\nimport { DEFAULT_LOCALE } from '../constants';\nimport { getService, getCoreStore } from '../utils';\n\nconst find = (params: any = {}) =>\n strapi.db.query('plugin::i18n.locale').findMany({ where: params });\n\nconst findById = (id: any) => strapi.db.query('plugin::i18n.locale').findOne({ where: { id } });\n\nconst findByCode = (code: any) =>\n strapi.db.query('plugin::i18n.locale').findOne({ where: { code } });\n\nconst count = (params: any = {}) => strapi.db.query('plugin::i18n.locale').count({ where: params });\n\nconst create = async (locale: any) => {\n const result = await strapi.db.query('plugin::i18n.locale').create({ data: locale });\n\n getService('metrics').sendDidUpdateI18nLocalesEvent();\n\n return result;\n};\n\nconst update = async (params: any, updates: any) => {\n const result = await strapi.db\n .query('plugin::i18n.locale')\n .update({ where: params, data: updates });\n\n getService('metrics').sendDidUpdateI18nLocalesEvent();\n\n return result;\n};\n\nconst deleteFn = async ({ id }: any) => {\n const localeToDelete = await findById(id);\n\n if (localeToDelete) {\n await deleteAllLocalizedEntriesFor({ locale: localeToDelete.code });\n const result = await strapi.db.query('plugin::i18n.locale').delete({ where: { id } });\n\n getService('metrics').sendDidUpdateI18nLocalesEvent();\n\n return result;\n }\n\n return localeToDelete;\n};\n\nconst setDefaultLocale = ({ code }: any) =>\n getCoreStore().set({ key: 'default_locale', value: code });\n\nconst getDefaultLocale = () => getCoreStore().get({ key: 'default_locale' });\n\nconst setIsDefault = async (locales: any) => {\n if (isNil(locales)) {\n return locales;\n }\n\n const actualDefault = await getDefaultLocale();\n\n if (Array.isArray(locales)) {\n return locales.map((locale) => ({ ...locale, isDefault: actualDefault === locale.code }));\n }\n // single locale\n return { ...locales, isDefault: actualDefault === locales.code };\n};\n\nconst initDefaultLocale = async () => {\n const existingLocalesNb = await strapi.db.query('plugin::i18n.locale').count();\n if (existingLocalesNb === 0) {\n await create(DEFAULT_LOCALE);\n await setDefaultLocale({ code: DEFAULT_LOCALE.code });\n }\n};\n\nconst deleteAllLocalizedEntriesFor = async ({ locale }: any) => {\n const { isLocalizedContentType } = getService('content-types');\n\n const localizedModels = Object.values(strapi.contentTypes).filter(isLocalizedContentType);\n\n for (const model of localizedModels) {\n // FIXME: delete many content & their associations\n await strapi.db.query(model.uid).deleteMany({ where: { locale } });\n }\n};\n\nconst locales = () => ({\n find,\n findById,\n findByCode,\n create,\n update,\n count,\n setDefaultLocale,\n getDefaultLocale,\n setIsDefault,\n delete: deleteFn,\n initDefaultLocale,\n});\n\ntype LocaleService = typeof locales;\n\nexport default locales;\nexport type { LocaleService };\n"],"names":["find","params","strapi","db","query","findMany","where","findById","id","findOne","findByCode","code","count","create","locale","result","data","getService","sendDidUpdateI18nLocalesEvent","update","updates","deleteFn","localeToDelete","deleteAllLocalizedEntriesFor","delete","setDefaultLocale","getCoreStore","set","key","value","getDefaultLocale","get","setIsDefault","locales","isNil","actualDefault","Array","isArray","map","isDefault","initDefaultLocale","existingLocalesNb","DEFAULT_LOCALE","isLocalizedContentType","local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AAAA;KACF;;;;"}
@@ -0,0 +1,112 @@
1
+ import { isNil } from 'lodash/fp';
2
+ import { DEFAULT_LOCALE } from '../constants/index.mjs';
3
+ import { getService, getCoreStore } from '../utils/index.mjs';
4
+
5
+ const find = (params = {})=>strapi.db.query('plugin::i18n.locale').findMany({
6
+ where: params
7
+ });
8
+ const findById = (id)=>strapi.db.query('plugin::i18n.locale').findOne({
9
+ where: {
10
+ id
11
+ }
12
+ });
13
+ const findByCode = (code)=>strapi.db.query('plugin::i18n.locale').findOne({
14
+ where: {
15
+ code
16
+ }
17
+ });
18
+ const count = (params = {})=>strapi.db.query('plugin::i18n.locale').count({
19
+ where: params
20
+ });
21
+ const create = async (locale)=>{
22
+ const result = await strapi.db.query('plugin::i18n.locale').create({
23
+ data: locale
24
+ });
25
+ getService('metrics').sendDidUpdateI18nLocalesEvent();
26
+ return result;
27
+ };
28
+ const update = async (params, updates)=>{
29
+ const result = await strapi.db.query('plugin::i18n.locale').update({
30
+ where: params,
31
+ data: updates
32
+ });
33
+ getService('metrics').sendDidUpdateI18nLocalesEvent();
34
+ return result;
35
+ };
36
+ const deleteFn = async ({ id })=>{
37
+ const localeToDelete = await findById(id);
38
+ if (localeToDelete) {
39
+ await deleteAllLocalizedEntriesFor({
40
+ locale: localeToDelete.code
41
+ });
42
+ const result = await strapi.db.query('plugin::i18n.locale').delete({
43
+ where: {
44
+ id
45
+ }
46
+ });
47
+ getService('metrics').sendDidUpdateI18nLocalesEvent();
48
+ return result;
49
+ }
50
+ return localeToDelete;
51
+ };
52
+ const setDefaultLocale = ({ code })=>getCoreStore().set({
53
+ key: 'default_locale',
54
+ value: code
55
+ });
56
+ const getDefaultLocale = ()=>getCoreStore().get({
57
+ key: 'default_locale'
58
+ });
59
+ const setIsDefault = async (locales)=>{
60
+ if (isNil(locales)) {
61
+ return locales;
62
+ }
63
+ const actualDefault = await getDefaultLocale();
64
+ if (Array.isArray(locales)) {
65
+ return locales.map((locale)=>({
66
+ ...locale,
67
+ isDefault: actualDefault === locale.code
68
+ }));
69
+ }
70
+ // single locale
71
+ return {
72
+ ...locales,
73
+ isDefault: actualDefault === locales.code
74
+ };
75
+ };
76
+ const initDefaultLocale = async ()=>{
77
+ const existingLocalesNb = await strapi.db.query('plugin::i18n.locale').count();
78
+ if (existingLocalesNb === 0) {
79
+ await create(DEFAULT_LOCALE);
80
+ await setDefaultLocale({
81
+ code: DEFAULT_LOCALE.code
82
+ });
83
+ }
84
+ };
85
+ const deleteAllLocalizedEntriesFor = async ({ locale })=>{
86
+ const { isLocalizedContentType } = getService('content-types');
87
+ const localizedModels = Object.values(strapi.contentTypes).filter(isLocalizedContentType);
88
+ for (const model of localizedModels){
89
+ // FIXME: delete many content & their associations
90
+ await strapi.db.query(model.uid).deleteMany({
91
+ where: {
92
+ locale
93
+ }
94
+ });
95
+ }
96
+ };
97
+ const locales = ()=>({
98
+ find,
99
+ findById,
100
+ findByCode,
101
+ create,
102
+ update,
103
+ count,
104
+ setDefaultLocale,
105
+ getDefaultLocale,
106
+ setIsDefault,
107
+ delete: deleteFn,
108
+ initDefaultLocale
109
+ });
110
+
111
+ export { locales as default };
112
+ //# sourceMappingURL=locales.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locales.mjs","sources":["../../../server/src/services/locales.ts"],"sourcesContent":["import { isNil } from 'lodash/fp';\nimport { DEFAULT_LOCALE } from '../constants';\nimport { getService, getCoreStore } from '../utils';\n\nconst find = (params: any = {}) =>\n strapi.db.query('plugin::i18n.locale').findMany({ where: params });\n\nconst findById = (id: any) => strapi.db.query('plugin::i18n.locale').findOne({ where: { id } });\n\nconst findByCode = (code: any) =>\n strapi.db.query('plugin::i18n.locale').findOne({ where: { code } });\n\nconst count = (params: any = {}) => strapi.db.query('plugin::i18n.locale').count({ where: params });\n\nconst create = async (locale: any) => {\n const result = await strapi.db.query('plugin::i18n.locale').create({ data: locale });\n\n getService('metrics').sendDidUpdateI18nLocalesEvent();\n\n return result;\n};\n\nconst update = async (params: any, updates: any) => {\n const result = await strapi.db\n .query('plugin::i18n.locale')\n .update({ where: params, data: updates });\n\n getService('metrics').sendDidUpdateI18nLocalesEvent();\n\n return result;\n};\n\nconst deleteFn = async ({ id }: any) => {\n const localeToDelete = await findById(id);\n\n if (localeToDelete) {\n await deleteAllLocalizedEntriesFor({ locale: localeToDelete.code });\n const result = await strapi.db.query('plugin::i18n.locale').delete({ where: { id } });\n\n getService('metrics').sendDidUpdateI18nLocalesEvent();\n\n return result;\n }\n\n return localeToDelete;\n};\n\nconst setDefaultLocale = ({ code }: any) =>\n getCoreStore().set({ key: 'default_locale', value: code });\n\nconst getDefaultLocale = () => getCoreStore().get({ key: 'default_locale' });\n\nconst setIsDefault = async (locales: any) => {\n if (isNil(locales)) {\n return locales;\n }\n\n const actualDefault = await getDefaultLocale();\n\n if (Array.isArray(locales)) {\n return locales.map((locale) => ({ ...locale, isDefault: actualDefault === locale.code }));\n }\n // single locale\n return { ...locales, isDefault: actualDefault === locales.code };\n};\n\nconst initDefaultLocale = async () => {\n const existingLocalesNb = await strapi.db.query('plugin::i18n.locale').count();\n if (existingLocalesNb === 0) {\n await create(DEFAULT_LOCALE);\n await setDefaultLocale({ code: DEFAULT_LOCALE.code });\n }\n};\n\nconst deleteAllLocalizedEntriesFor = async ({ locale }: any) => {\n const { isLocalizedContentType } = getService('content-types');\n\n const localizedModels = Object.values(strapi.contentTypes).filter(isLocalizedContentType);\n\n for (const model of localizedModels) {\n // FIXME: delete many content & their associations\n await strapi.db.query(model.uid).deleteMany({ where: { locale } });\n }\n};\n\nconst locales = () => ({\n find,\n findById,\n findByCode,\n create,\n update,\n count,\n setDefaultLocale,\n getDefaultLocale,\n setIsDefault,\n delete: deleteFn,\n initDefaultLocale,\n});\n\ntype LocaleService = typeof locales;\n\nexport default locales;\nexport type { LocaleService };\n"],"names":["find","params","strapi","db","query","findMany","where","findById","id","findOne","findByCode","code","count","create","locale","result","data","getService","sendDidUpdateI18nLocalesEvent","update","updates","deleteFn","localeToDelete","deleteAllLocalizedEntriesFor","delete","setDefaultLocale","getCoreStore","set","key","value","getDefaultLocale","get","setIsDefault","locales","isNil","actualDefault","Array","isArray","map","isDefault","initDefaultLocale","existingLocalesNb","DEFAULT_LOCALE","isLocalizedContentType","localizedModels","Object","values","contentTypes","filter","model","uid","deleteMany"],"mappings":";;;;AAIA,MAAMA,IAAO,GAAA,CAACC,MAAc,GAAA,EAAE,GAC5BC,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAAC,qBAAA,CAAA,CAAuBC,QAAQ,CAAC;QAAEC,KAAOL,EAAAA;AAAO,KAAA,CAAA;AAElE,MAAMM,QAAAA,GAAW,CAACC,EAAAA,GAAYN,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAAC,qBAAuBK,CAAAA,CAAAA,OAAO,CAAC;QAAEH,KAAO,EAAA;AAAEE,YAAAA;AAAG;AAAE,KAAA,CAAA;AAE7F,MAAME,UAAAA,GAAa,CAACC,IAAAA,GAClBT,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAAC,qBAAuBK,CAAAA,CAAAA,OAAO,CAAC;QAAEH,KAAO,EAAA;AAAEK,YAAAA;AAAK;AAAE,KAAA,CAAA;AAEnE,MAAMC,KAAQ,GAAA,CAACX,MAAc,GAAA,EAAE,GAAKC,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAAC,qBAAA,CAAA,CAAuBQ,KAAK,CAAC;QAAEN,KAAOL,EAAAA;AAAO,KAAA,CAAA;AAEjG,MAAMY,SAAS,OAAOC,MAAAA,GAAAA;IACpB,MAAMC,MAAAA,GAAS,MAAMb,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAAC,qBAAuBS,CAAAA,CAAAA,MAAM,CAAC;QAAEG,IAAMF,EAAAA;AAAO,KAAA,CAAA;AAElFG,IAAAA,UAAAA,CAAW,WAAWC,6BAA6B,EAAA;IAEnD,OAAOH,MAAAA;AACT,CAAA;AAEA,MAAMI,MAAAA,GAAS,OAAOlB,MAAamB,EAAAA,OAA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AAA;AACAM,QAAAA,MAAAA;AACAP,QAAAA,KAAAA;AACAa,QAAAA,gBAAAA;AACAK,QAAAA,gBAAAA;AACAE,QAAAA,YAAAA;QACAR,MAAQH,EAAAA,QAAAA;AACRmB,QAAAA;KACF;;;;"}
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var fp = require('lodash/fp');
4
+ var utils = require('@strapi/utils');
5
+ var index = require('../utils/index.js');
6
+
7
+ /**
8
+ * Update non localized fields of all the related localizations of an entry with the entry values
9
+ */ const syncNonLocalizedAttributes = async (sourceEntry, model)=>{
10
+ const { copyNonLocalizedAttributes } = index.getService('content-types');
11
+ const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);
12
+ if (fp.isEmpty(nonLocalizedAttributes)) {
13
+ return;
14
+ }
15
+ const uid = model.uid;
16
+ const documentId = sourceEntry.documentId;
17
+ const locale = sourceEntry.locale;
18
+ const status = sourceEntry?.publishedAt ? 'published' : 'draft';
19
+ // Find all the entries that need to be updated
20
+ // this is every other entry of the document in the same status but a different locale
21
+ const localeEntriesToUpdate = await strapi.db.query(uid).findMany({
22
+ where: {
23
+ documentId,
24
+ publishedAt: status === 'published' ? {
25
+ $ne: null
26
+ } : null,
27
+ locale: {
28
+ $ne: locale
29
+ }
30
+ },
31
+ select: [
32
+ 'locale',
33
+ 'id'
34
+ ]
35
+ });
36
+ const entryData = await strapi.documents(uid).omitComponentData(nonLocalizedAttributes);
37
+ await utils.async.map(localeEntriesToUpdate, async (entry)=>{
38
+ const transformedData = await strapi.documents.utils.transformData(fp.cloneDeep(nonLocalizedAttributes), {
39
+ uid,
40
+ status,
41
+ locale: entry.locale,
42
+ allowMissingId: true
43
+ });
44
+ // Update or create non localized components for the entry
45
+ const componentData = await strapi.documents(uid).updateComponents(entry, transformedData);
46
+ // Update every other locale entry of this documentId in the same status
47
+ await strapi.db.query(uid).update({
48
+ where: {
49
+ documentId,
50
+ publishedAt: status === 'published' ? {
51
+ $ne: null
52
+ } : null,
53
+ locale: {
54
+ $eq: entry.locale
55
+ }
56
+ },
57
+ // The data we send to the update function is the entry data merged with
58
+ // the updated component data
59
+ data: Object.assign(fp.cloneDeep(entryData), componentData)
60
+ });
61
+ });
62
+ };
63
+ const localizations = ()=>({
64
+ syncNonLocalizedAttributes
65
+ });
66
+
67
+ module.exports = localizations;
68
+ //# sourceMappingURL=localizations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localizations.js","sources":["../../../server/src/services/localizations.ts"],"sourcesContent":["import { cloneDeep, isEmpty } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { getService } from '../utils';\n\n/**\n * Update non localized fields of all the related localizations of an entry with the entry values\n */\nconst syncNonLocalizedAttributes = async (sourceEntry: any, model: Schema.ContentType) => {\n const { copyNonLocalizedAttributes } = getService('content-types');\n\n const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);\n if (isEmpty(nonLocalizedAttributes)) {\n return;\n }\n\n const uid = model.uid;\n const documentId = sourceEntry.documentId;\n const locale = sourceEntry.locale;\n const status = sourceEntry?.publishedAt ? 'published' : 'draft';\n\n // Find all the entries that need to be updated\n // this is every other entry of the document in the same status but a different locale\n const localeEntriesToUpdate = await strapi.db.query(uid).findMany({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $ne: locale },\n },\n select: ['locale', 'id'],\n });\n\n const entryData = await strapi.documents(uid).omitComponentData(nonLocalizedAttributes);\n\n await async.map(localeEntriesToUpdate, async (entry: any) => {\n const transformedData = await strapi.documents.utils.transformData(\n cloneDeep(nonLocalizedAttributes),\n {\n uid,\n status,\n locale: entry.locale,\n allowMissingId: true,\n }\n );\n\n // Update or create non localized components for the entry\n const componentData = await strapi\n .documents(uid)\n .updateComponents(entry, transformedData as any);\n\n // Update every other locale entry of this documentId in the same status\n await strapi.db.query(uid).update({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $eq: entry.locale },\n },\n // The data we send to the update function is the entry data merged with\n // the updated component data\n data: Object.assign(cloneDeep(entryData), componentData),\n });\n });\n};\n\nconst localizations = () => ({\n syncNonLocalizedAttributes,\n});\n\ntype LocalizationsService = typeof localizations;\n\nexport default localizations;\nexport type { LocalizationsService };\n"],"names":["syncNonLocalizedAttributes","sourceEntry","model","copyNonLocalizedAttributes","getService","nonLocalizedAttributes","isEmpty","uid","documentId","locale","status","publishedAt","localeEntriesToUpdate","strapi","db","query","findMany","where","$ne","select","entryData","documents","omitComponentData","async","map","entry","transformedData","utils","transformData","cloneDeep","allowMissingId","componentData","updateComponents","update","$eq","data","Object","assign","localizations"],"mappings":";;;;;;AAMA;;IAGA,MAAMA,0BAA6B,GAAA,OAAOC,WAAkBC,EAAAA,KAAAA,GAAAA;AAC1D,IAAA,MAAM,EAAEC,0BAA0B,EAAE,GAAGC,gBAAW,CAAA,eAAA,CAAA;IAElD,MAAMC,sBAAAA,GAAyBF,2BAA2BD,KAAOD,EAAAA,WAAAA,CAAAA;AACjE,IAAA,IAAIK,WAAQD,sBAAyB,CAAA,EAAA;AACnC,QAAA;AACF;IAEA,MAAME,GAAAA,GAAML,MAAMK,GAAG;IACrB,MAAMC,UAAAA,GAAaP,YAAYO,UAAU;IACzC,MAAMC,MAAAA,GAASR,YAAYQ,MAAM;IACjC,MAAMC,MAAAA,GAAST,WAAaU,EAAAA,WAAAA,GAAc,WAAc,GAAA,OAAA;;;IAIxD,MAAMC,qBAAAA,GAAwB,MAAMC,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAACR,GAAKS,CAAAA,CAAAA,QAAQ,CAAC;QAChEC,KAAO,EAAA;AACLT,YAAAA,UAAAA;AACAG,YAAAA,WAAAA,EAAaD,WAAW,WAAc,GAAA;gBAAEQ,GAAK,EAAA;aAAS,GAAA,IAAA;YACtDT,MAAQ,EAAA;gBAAES,GAAKT,EAAAA;AAAO;AACxB,SAAA;QACAU,MAAQ,EAAA;AAAC,YAAA,QAAA;AAA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+ /**
6
+ * Update non localized fields of all the related localizations of an entry with the entry values
7
+ */ const syncNonLocalizedAttributes = async (sourceEntry, model)=>{
8
+ const { copyNonLocalizedAttributes } = getService('content-types');
9
+ const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);
10
+ if (isEmpty(nonLocalizedAttributes)) {
11
+ return;
12
+ }
13
+ const uid = model.uid;
14
+ const documentId = sourceEntry.documentId;
15
+ const locale = sourceEntry.locale;
16
+ const status = sourceEntry?.publishedAt ? 'published' : 'draft';
17
+ // Find all the entries that need to be updated
18
+ // this is every other entry of the document in the same status but a different locale
19
+ const localeEntriesToUpdate = await strapi.db.query(uid).findMany({
20
+ where: {
21
+ documentId,
22
+ publishedAt: status === 'published' ? {
23
+ $ne: null
24
+ } : null,
25
+ locale: {
26
+ $ne: locale
27
+ }
28
+ },
29
+ select: [
30
+ 'locale',
31
+ 'id'
32
+ ]
33
+ });
34
+ const entryData = await strapi.documents(uid).omitComponentData(nonLocalizedAttributes);
35
+ await async.map(localeEntriesToUpdate, async (entry)=>{
36
+ const transformedData = await strapi.documents.utils.transformData(cloneDeep(nonLocalizedAttributes), {
37
+ uid,
38
+ status,
39
+ locale: entry.locale,
40
+ allowMissingId: true
41
+ });
42
+ // Update or create non localized components for the entry
43
+ const componentData = await strapi.documents(uid).updateComponents(entry, transformedData);
44
+ // Update every other locale entry of this documentId in the same status
45
+ await strapi.db.query(uid).update({
46
+ where: {
47
+ documentId,
48
+ publishedAt: status === 'published' ? {
49
+ $ne: null
50
+ } : null,
51
+ locale: {
52
+ $eq: entry.locale
53
+ }
54
+ },
55
+ // The data we send to the update function is the entry data merged with
56
+ // the updated component data
57
+ data: Object.assign(cloneDeep(entryData), componentData)
58
+ });
59
+ });
60
+ };
61
+ const localizations = ()=>({
62
+ syncNonLocalizedAttributes
63
+ });
64
+
65
+ export { localizations as default };
66
+ //# sourceMappingURL=localizations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localizations.mjs","sources":["../../../server/src/services/localizations.ts"],"sourcesContent":["import { cloneDeep, isEmpty } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { getService } from '../utils';\n\n/**\n * Update non localized fields of all the related localizations of an entry with the entry values\n */\nconst syncNonLocalizedAttributes = async (sourceEntry: any, model: Schema.ContentType) => {\n const { copyNonLocalizedAttributes } = getService('content-types');\n\n const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);\n if (isEmpty(nonLocalizedAttributes)) {\n return;\n }\n\n const uid = model.uid;\n const documentId = sourceEntry.documentId;\n const locale = sourceEntry.locale;\n const status = sourceEntry?.publishedAt ? 'published' : 'draft';\n\n // Find all the entries that need to be updated\n // this is every other entry of the document in the same status but a different locale\n const localeEntriesToUpdate = await strapi.db.query(uid).findMany({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $ne: locale },\n },\n select: ['locale', 'id'],\n });\n\n const entryData = await strapi.documents(uid).omitComponentData(nonLocalizedAttributes);\n\n await async.map(localeEntriesToUpdate, async (entry: any) => {\n const transformedData = await strapi.documents.utils.transformData(\n cloneDeep(nonLocalizedAttributes),\n {\n uid,\n status,\n locale: entry.locale,\n allowMissingId: true,\n }\n );\n\n // Update or create non localized components for the entry\n const componentData = await strapi\n .documents(uid)\n .updateComponents(entry, transformedData as any);\n\n // Update every other locale entry of this documentId in the same status\n await strapi.db.query(uid).update({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $eq: entry.locale },\n },\n // The data we send to the update function is the entry data merged with\n // the updated component data\n data: Object.assign(cloneDeep(entryData), componentData),\n });\n });\n};\n\nconst localizations = () => ({\n syncNonLocalizedAttributes,\n});\n\ntype LocalizationsService = typeof localizations;\n\nexport default localizations;\nexport type { LocalizationsService };\n"],"names":["syncNonLocalizedAttributes","sourceEntry","model","copyNonLocalizedAttributes","getService","nonLocalizedAttributes","isEmpty","uid","documentId","locale","status","publishedAt","localeEntriesToUpdate","strapi","db","query","findMany","where","$ne","select","entryData","documents","omitComponentData","async","map","entry","transformedData","utils","transformData","cloneDeep","allowMissingId","componentData","updateComponents","update","$eq","data","Object","assign","localizations"],"mappings":";;;;AAMA;;IAGA,MAAMA,0BAA6B,GAAA,OAAOC,WAAkBC,EAAAA,KAAAA,GAAAA;AAC1D,IAAA,MAAM,EAAEC,0BAA0B,EAAE,GAAGC,UAAW,CAAA,eAAA,CAAA;IAElD,MAAMC,sBAAAA,GAAyBF,2BAA2BD,KAAOD,EAAAA,WAAAA,CAAAA;AACjE,IAAA,IAAIK,QAAQD,sBAAyB,CAAA,EAAA;AACnC,QAAA;AACF;IAEA,MAAME,GAAAA,GAAML,MAAMK,GAAG;IACrB,MAAMC,UAAAA,GAAaP,YAAYO,UAAU;IACzC,MAAMC,MAAAA,GAASR,YAAYQ,MAAM;IACjC,MAAMC,MAAAA,GAAST,WAAaU,EAAAA,WAAAA,GAAc,WAAc,GAAA,OAAA;;;IAIxD,MAAMC,qBAAAA,GAAwB,MAAMC,MAAOC,CAAAA,EAAE,CAACC,KAAK,CAACR,GAAKS,CAAAA,CAAAA,QAAQ,CAAC;QAChEC,KAAO,EAAA;AACLT,YAAAA,UAAAA;AACAG,YAAAA,WAAAA,EAAaD,WAAW,WAAc,GAAA;gBAAEQ,GAAK,EAAA;aAAS,GAAA,IAAA;YACtDT,MAAQ,EAAA;gBAAES,GAAKT,EAAAA;AAAO;AACxB,SAAA;QACAU,MAAQ,EAAA;AAAC,YAAA,QAAA;AAAU,YAAA;AAAK;AAC1B,KAAA,CAAA;AAEA,IAAA,MAAMC,YAAY,MAAMP,MAAAA,CAAOQ,SAAS,CAACd,GAAAA,CAAAA,CAAKe,iBAAiB,CAACjB,sBAAAA,CAAAA;AAEhE,IAAA,MAAMkB,KAAMC,CAAAA,GAAG,CAACZ,qBAAAA,EAAuB,OAAOa,KAAAA,GAAAA;QAC5C,MAAMC,eAAAA,GAAkB,MAAMb,MAAAA,CAAOQ,SAAS,CAACM,KAAK,CAACC,aAAa,CAChEC,SAAAA,CAAUxB,sBACV,CAAA,EAAA;AACEE,YAAAA,GAAAA;AACAG,YAAAA,MAAAA;AACAD,YAAAA,MAAAA,EAAQgB,MAAMhB,MAAM;YACpBqB,cAAgB,EAAA;AAClB,SAAA,CAAA;;QAIF,MAAMC,aAAAA,GAAgB,MAAMlB,MACzBQ,CAAAA,SAAS,CAACd,GACVyB,CAAAA,CAAAA,gBAAgB,CAACP,KAAOC,EAAAA,eAAAA,CAAAA;;AAG3B,QAAA,MAAMb,OAAOC,EAAE,CAACC,KAAK,CAACR,GAAAA,CAAAA,CAAK0B,MAAM,CAAC;YAChChB,KAAO,EAAA;AACLT,gBAAAA,UAAAA;AACAG,gBAAAA,WAAAA,EAAaD,WAAW,WAAc,GAAA;oBAAEQ,GAAK,EAAA;iBAAS,GAAA,IAAA;gBACtDT,MAAQ,EAAA;AAAEyB,oBAAAA,GAAAA,EAAKT,MAAMhB;AAAO;AAC9B,aAAA;;;AAGA0B,YAAAA,IAAAA,EAAMC,MAAOC,CAAAA,MAAM,CAACR,SAAAA,CAAUT,SAAYW,CAAAA,EAAAA,aAAAA;AAC5C,SAAA,CAAA;AACF,KAAA,CAAA;AACF,CAAA;AAEMO,MAAAA,aAAAA,GAAgB,KAAO;AAC3BtC,QAAAA;KACF;;;;"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ var fp = require('lodash/fp');
4
+ var index = require('../utils/index.js');
5
+
6
+ const sendDidInitializeEvent = async ()=>{
7
+ const { isLocalizedContentType } = index.getService('content-types');
8
+ // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
9
+ const numberOfContentTypes = fp.reduce((sum, contentType)=>isLocalizedContentType(contentType) ? sum + 1 : sum, 0)(strapi.contentTypes);
10
+ await strapi.telemetry.send('didInitializeI18n', {
11
+ groupProperties: {
12
+ numberOfContentTypes
13
+ }
14
+ });
15
+ };
16
+ const sendDidUpdateI18nLocalesEvent = async ()=>{
17
+ const numberOfLocales = await index.getService('locales').count();
18
+ await strapi.telemetry.send('didUpdateI18nLocales', {
19
+ groupProperties: {
20
+ numberOfLocales
21
+ }
22
+ });
23
+ };
24
+ const metrics = ()=>({
25
+ sendDidInitializeEvent,
26
+ sendDidUpdateI18nLocalesEvent
27
+ });
28
+
29
+ module.exports = metrics;
30
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.js","sources":["../../../server/src/services/metrics.ts"],"sourcesContent":["import { reduce } from 'lodash/fp';\nimport { getService } from '../utils';\n\nconst sendDidInitializeEvent = async () => {\n const { isLocalizedContentType } = getService('content-types');\n\n // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n const numberOfContentTypes = reduce(\n (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),\n 0\n )(strapi.contentTypes as any);\n\n await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });\n};\n\nconst sendDidUpdateI18nLocalesEvent = async () => {\n const numberOfLocales = await getService('locales').count();\n\n await strapi.telemetry.send('didUpdateI18nLocales', {\n groupProperties: { numberOfLocales },\n });\n};\n\nconst metrics = () => ({\n sendDidInitializeEvent,\n sendDidUpdateI18nLocalesEvent,\n});\n\ntype MetricsService = typeof metrics;\n\nexport default metrics;\nexport type { MetricsService };\n"],"names":["sendDidInitializeEvent","isLocalizedContentType","getService","numberOfContentTypes","reduce","sum","contentType","strapi","contentTypes","telemetry","send","groupProperties","sendDidUpdateI18nLocalesEvent","numberOfLocales","count","metrics"],"mappings":";;;;;AAGA,MAAMA,sBAAyB,GAAA,UAAA;AAC7B,IAAA,MAAM,EAAEC,sBAAsB,EAAE,GAAGC,gBAAW,CAAA,eAAA,CAAA;;AAG9C,IAAA,MAAMC,oBAAuBC,GAAAA,SAAAA,CAC3B,CAACC,GAAAA,EAAKC,WAAiBL,GAAAA,sBAAAA,CAAuBK,WAAeD,CAAAA,GAAAA,GAAAA,GAAM,CAAIA,GAAAA,GAAAA,EACvE,CACAE,CAAAA,CAAAA,MAAAA,CAAOC,YAAY,CAAA;AAErB,IAAA,MAAMD,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,mBAAqB,EAAA;QAAEC,eAAiB,EAAA;AAAER,YAAAA;AAAqB;AAAE,KAAA,CAAA;AAC/F,CAAA;AAEA,MAAMS,6BAAgC,GAAA,UAAA;AACpC,IAAA,MAAMC,eAAkB,GAAA,MAAMX,gBAAW,CAAA,SAAA,CAAA,CAAWY,KAAK,EAAA;AAEzD,IAAA,MAAMP,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,sBAAwB,EAAA;QAClDC,eAAiB,EAAA;AAAEE,YAAAA;AAAgB;AACrC,KAAA,CAAA;AACF,CAAA;AAEME,MAAAA,OAAAA,GAAU,KAAO;AACrBf,QAAAA,sBAAAA;AACAY,QAAAA;KACF;;;;"}
@@ -0,0 +1,28 @@
1
+ import { reduce } from 'lodash/fp';
2
+ import { getService } from '../utils/index.mjs';
3
+
4
+ const sendDidInitializeEvent = async ()=>{
5
+ const { isLocalizedContentType } = getService('content-types');
6
+ // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
7
+ const numberOfContentTypes = reduce((sum, contentType)=>isLocalizedContentType(contentType) ? sum + 1 : sum, 0)(strapi.contentTypes);
8
+ await strapi.telemetry.send('didInitializeI18n', {
9
+ groupProperties: {
10
+ numberOfContentTypes
11
+ }
12
+ });
13
+ };
14
+ const sendDidUpdateI18nLocalesEvent = async ()=>{
15
+ const numberOfLocales = await getService('locales').count();
16
+ await strapi.telemetry.send('didUpdateI18nLocales', {
17
+ groupProperties: {
18
+ numberOfLocales
19
+ }
20
+ });
21
+ };
22
+ const metrics = ()=>({
23
+ sendDidInitializeEvent,
24
+ sendDidUpdateI18nLocalesEvent
25
+ });
26
+
27
+ export { metrics as default };
28
+ //# sourceMappingURL=metrics.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.mjs","sources":["../../../server/src/services/metrics.ts"],"sourcesContent":["import { reduce } from 'lodash/fp';\nimport { getService } from '../utils';\n\nconst sendDidInitializeEvent = async () => {\n const { isLocalizedContentType } = getService('content-types');\n\n // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n const numberOfContentTypes = reduce(\n (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),\n 0\n )(strapi.contentTypes as any);\n\n await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });\n};\n\nconst sendDidUpdateI18nLocalesEvent = async () => {\n const numberOfLocales = await getService('locales').count();\n\n await strapi.telemetry.send('didUpdateI18nLocales', {\n groupProperties: { numberOfLocales },\n });\n};\n\nconst metrics = () => ({\n sendDidInitializeEvent,\n sendDidUpdateI18nLocalesEvent,\n});\n\ntype MetricsService = typeof metrics;\n\nexport default metrics;\nexport type { MetricsService };\n"],"names":["sendDidInitializeEvent","isLocalizedContentType","getService","numberOfContentTypes","reduce","sum","contentType","strapi","contentTypes","telemetry","send","groupProperties","sendDidUpdateI18nLocalesEvent","numberOfLocales","count","metrics"],"mappings":";;;AAGA,MAAMA,sBAAyB,GAAA,UAAA;AAC7B,IAAA,MAAM,EAAEC,sBAAsB,EAAE,GAAGC,UAAW,CAAA,eAAA,CAAA;;AAG9C,IAAA,MAAMC,oBAAuBC,GAAAA,MAAAA,CAC3B,CAACC,GAAAA,EAAKC,WAAiBL,GAAAA,sBAAAA,CAAuBK,WAAeD,CAAAA,GAAAA,GAAAA,GAAM,CAAIA,GAAAA,GAAAA,EACvE,CACAE,CAAAA,CAAAA,MAAAA,CAAOC,YAAY,CAAA;AAErB,IAAA,MAAMD,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,mBAAqB,EAAA;QAAEC,eAAiB,EAAA;AAAER,YAAAA;AAAqB;AAAE,KAAA,CAAA;AAC/F,CAAA;AAEA,MAAMS,6BAAgC,GAAA,UAAA;AACpC,IAAA,MAAMC,eAAkB,GAAA,MAAMX,UAAW,CAAA,SAAA,CAAA,CAAWY,KAAK,EAAA;AAEzD,IAAA,MAAMP,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,sBAAwB,EAAA;QAClDC,eAAiB,EAAA;AAAEE,YAAAA;AAAgB;AACrC,KAAA,CAAA;AACF,CAAA;AAEME,MAAAA,OAAAA,GAAU,KAAO;AACrBf,QAAAA,sBAAAA;AACAY,QAAAA;KACF;;;;"}