@strapi/i18n 0.0.0-next.965570e6e12a33ad098ddb3174a9750fddb03be2 → 0.0.0-next.96a532b33a712f19b498ed0a82a84752247cd899

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 (111) hide show
  1. package/dist/admin/components/CMHeaderActions.js +116 -1
  2. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  3. package/dist/admin/components/CMHeaderActions.mjs +119 -5
  4. package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
  5. package/dist/admin/components/CreateLocale.js +1 -1
  6. package/dist/admin/components/CreateLocale.js.map +1 -1
  7. package/dist/admin/components/CreateLocale.mjs +1 -1
  8. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  9. package/dist/admin/components/EditLocale.js +1 -1
  10. package/dist/admin/components/EditLocale.js.map +1 -1
  11. package/dist/admin/components/EditLocale.mjs +1 -1
  12. package/dist/admin/components/EditLocale.mjs.map +1 -1
  13. package/dist/admin/components/LocaleListCell.js +65 -45
  14. package/dist/admin/components/LocaleListCell.js.map +1 -1
  15. package/dist/admin/components/LocaleListCell.mjs +66 -46
  16. package/dist/admin/components/LocaleListCell.mjs.map +1 -1
  17. package/dist/admin/components/LocalePicker.js +18 -11
  18. package/dist/admin/components/LocalePicker.js.map +1 -1
  19. package/dist/admin/components/LocalePicker.mjs +19 -12
  20. package/dist/admin/components/LocalePicker.mjs.map +1 -1
  21. package/dist/admin/contentManagerHooks/editView.js +6 -3
  22. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  23. package/dist/admin/contentManagerHooks/editView.mjs +7 -4
  24. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  25. package/dist/admin/contentManagerHooks/listView.js +2 -1
  26. package/dist/admin/contentManagerHooks/listView.js.map +1 -1
  27. package/dist/admin/contentManagerHooks/listView.mjs +2 -1
  28. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
  29. package/dist/admin/index.js +1 -0
  30. package/dist/admin/index.js.map +1 -1
  31. package/dist/admin/index.mjs +2 -1
  32. package/dist/admin/index.mjs.map +1 -1
  33. package/dist/admin/pages/SettingsPage.js +121 -46
  34. package/dist/admin/pages/SettingsPage.js.map +1 -1
  35. package/dist/admin/pages/SettingsPage.mjs +124 -30
  36. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  37. package/dist/admin/services/api.js +2 -1
  38. package/dist/admin/services/api.js.map +1 -1
  39. package/dist/admin/services/api.mjs +2 -1
  40. package/dist/admin/services/api.mjs.map +1 -1
  41. package/dist/admin/services/settings.js +29 -0
  42. package/dist/admin/services/settings.js.map +1 -0
  43. package/dist/admin/services/settings.mjs +26 -0
  44. package/dist/admin/services/settings.mjs.map +1 -0
  45. package/dist/admin/src/components/CMHeaderActions.d.ts +7 -1
  46. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  47. package/dist/admin/src/services/api.d.ts +1 -1
  48. package/dist/admin/src/services/locales.d.ts +1 -1
  49. package/dist/admin/src/services/relations.d.ts +1 -1
  50. package/dist/admin/src/services/settings.d.ts +5 -0
  51. package/dist/admin/translations/en.json.js +7 -0
  52. package/dist/admin/translations/en.json.js.map +1 -1
  53. package/dist/admin/translations/en.json.mjs +7 -0
  54. package/dist/admin/translations/en.json.mjs.map +1 -1
  55. package/dist/admin/utils/clean.js +2 -2
  56. package/dist/admin/utils/clean.js.map +1 -1
  57. package/dist/admin/utils/clean.mjs +2 -2
  58. package/dist/admin/utils/clean.mjs.map +1 -1
  59. package/dist/server/constants/iso-locales.json.js +4 -0
  60. package/dist/server/constants/iso-locales.json.js.map +1 -1
  61. package/dist/server/constants/iso-locales.json.mjs +4 -0
  62. package/dist/server/constants/iso-locales.json.mjs.map +1 -1
  63. package/dist/server/controllers/index.js +3 -1
  64. package/dist/server/controllers/index.js.map +1 -1
  65. package/dist/server/controllers/index.mjs +3 -1
  66. package/dist/server/controllers/index.mjs.map +1 -1
  67. package/dist/server/controllers/settings.js +24 -0
  68. package/dist/server/controllers/settings.js.map +1 -0
  69. package/dist/server/controllers/settings.mjs +22 -0
  70. package/dist/server/controllers/settings.mjs.map +1 -0
  71. package/dist/server/routes/admin.js +20 -0
  72. package/dist/server/routes/admin.js.map +1 -1
  73. package/dist/server/routes/admin.mjs +20 -0
  74. package/dist/server/routes/admin.mjs.map +1 -1
  75. package/dist/server/services/ai-localizations.js +143 -0
  76. package/dist/server/services/ai-localizations.js.map +1 -0
  77. package/dist/server/services/ai-localizations.mjs +141 -0
  78. package/dist/server/services/ai-localizations.mjs.map +1 -0
  79. package/dist/server/services/index.js +5 -1
  80. package/dist/server/services/index.js.map +1 -1
  81. package/dist/server/services/index.mjs +5 -1
  82. package/dist/server/services/index.mjs.map +1 -1
  83. package/dist/server/services/settings.js +25 -0
  84. package/dist/server/services/settings.js.map +1 -0
  85. package/dist/server/services/settings.mjs +23 -0
  86. package/dist/server/services/settings.mjs.map +1 -0
  87. package/dist/server/src/controllers/index.d.ts +4 -0
  88. package/dist/server/src/controllers/index.d.ts.map +1 -1
  89. package/dist/server/src/controllers/settings.d.ts +7 -0
  90. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  91. package/dist/server/src/index.d.ts +23 -0
  92. package/dist/server/src/index.d.ts.map +1 -1
  93. package/dist/server/src/routes/admin.d.ts.map +1 -1
  94. package/dist/server/src/services/ai-localizations.d.ts +17 -0
  95. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  96. package/dist/server/src/services/index.d.ts +19 -0
  97. package/dist/server/src/services/index.d.ts.map +1 -1
  98. package/dist/server/src/services/settings.d.ts +13 -0
  99. package/dist/server/src/services/settings.d.ts.map +1 -0
  100. package/dist/server/src/utils/index.d.ts +5 -1
  101. package/dist/server/src/utils/index.d.ts.map +1 -1
  102. package/dist/server/src/validation/settings.d.ts +12 -0
  103. package/dist/server/src/validation/settings.d.ts.map +1 -0
  104. package/dist/server/utils/index.js.map +1 -1
  105. package/dist/server/utils/index.mjs.map +1 -1
  106. package/dist/server/validation/settings.js +11 -0
  107. package/dist/server/validation/settings.js.map +1 -0
  108. package/dist/server/validation/settings.mjs +9 -0
  109. package/dist/server/validation/settings.mjs.map +1 -0
  110. package/dist/shared/contracts/settings.d.ts +40 -0
  111. package/package.json +9 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-localizations.js","sources":["../../../server/src/services/ai-localizations.ts"],"sourcesContent":["import type { Core, Modules, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { getService } from '../utils';\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\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 future flag is enabled\n const isFutureFlagEnabled = strapi.features.future.isEnabled('unstableAILocalizations');\n if (!isFutureFlagEnabled) {\n return false;\n }\n\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 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 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 isFeatureEnabled = await this.isEnabled();\n if (!isFeatureEnabled) {\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 // Extract only the localized content from the document\n const translateableContent = await traverseEntity(\n ({ key, attribute }, { remove }) => {\n const hasLocalizedOption = attribute?.pluginOptions?.i18n?.localized === true;\n // Only keep fields that actually need to be localized\n // TODO: remove blocks from this list once the AI server can handle it reliably\n if (!hasLocalizedOption || ['media', 'blocks'].includes(attribute.type)) {\n remove(key);\n }\n },\n { schema, getModel: strapi.getModel.bind(strapi) },\n document\n );\n\n // Call the AI server to get the localized content\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 let token: string;\n try {\n const tokenData = await strapi.service('admin::user').getAiToken();\n token = tokenData.token;\n } catch (error) {\n throw new Error('Failed to retrieve AI token', {\n cause: error instanceof Error ? error : undefined,\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 }),\n });\n\n if (!response.ok) {\n strapi.log.error(\n `AI Localizations request failed: ${response.status} ${response.statusText}`\n );\n throw new Error(`AI Localizations request failed: ${response.statusText}`);\n }\n\n const aiResult = await response.json();\n\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.allSettled(\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\n const mergedData = { ...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 return strapi.documents(model).update({\n documentId,\n locale,\n fields: [],\n data: mergedData,\n });\n })\n );\n } catch (error) {\n strapi.log.error('AI Localizations generation failed', error);\n }\n },\n };\n};\n\nexport { createAILocalizationsService };\n"],"names":["createAILocalizationsService","strapi","aiServerUrl","process","env","STRAPI_AI_URL","isEnabled","isFutureFlagEnabled","features","future","isAIEnabled","config","get","hasAccess","ee","generateDocumentLocalizations","model","document","schema","getModel","localeService","getService","isLocalizedContentType","defaultLocale","getDefaultLocale","locale","isFeatureEnabled","documentId","log","warn","uid","translateableContent","traverseEntity","key","attribute","remove","hasLocalizedOption","pluginOptions","i18n","localized","includes","type","bind","localesList","find","targetLocales","filter","l","code","map","length","info","token","tokenData","service","getAiToken","error","Error","cause","undefined","http","response","fetch","method","headers","Authorization","body","JSON","stringify","content","sourceLocale","ok","status","statusText","aiResult","json","mediaFields","Object","entries","attributes","_","attr","Promise","allSettled","localizations","localization","derivedDoc","documents","findOne","populate","mergedData","field","update","fields","data"],"mappings":";;;;;AAIA,MAAMA,4BAA+B,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;;AAEvE,IAAA,MAAMC,WAAcC,GAAAA,OAAAA,CAAQC,GAAG,CAACC,aAAa,IAAI,kCAAA;IAEjD,OAAO;;QAEL,MAAMC,SAAAA,CAAAA,GAAAA;;AAEJ,YAAA,MAAMC,sBAAsBN,MAAOO,CAAAA,QAAQ,CAACC,MAAM,CAACH,SAAS,CAAC,yBAAA,CAAA;AAC7D,YAAA,IAAI,CAACC,mBAAqB,EAAA;gBACxB,OAAO,KAAA;AACT;;AAGA,YAAA,MAAMG,cAAcT,MAAOU,CAAAA,MAAM,CAACC,GAAG,CAAC,kBAAoB,EAAA,IAAA,CAAA;AAC1D,YAAA,IAAI,CAACF,WAAa,EAAA;gBAChB,O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KAAAA,CAAAA,CAAOwE,OAAO,CAAC;AACvD7D,wBAAAA,UAAAA;AACAF,wBAAAA,MAAAA;wBACAgE,QAAUb,EAAAA;AACZ,qBAAA,CAAA;;AAGA,oBAAA,MAAMc,UAAa,GAAA;AAAE,wBAAA,GAAGrB;AAAQ,qBAAA;oBAChC,KAAK,MAAMsB,SAASf,WAAa,CAAA;;AAE/B,wBAAA,IAAI,CAACU,UAAc,IAAA,CAACA,UAAU,CAACK,MAAM,EAAE;AACrCD,4BAAAA,UAAU,CAACC,KAAAA,CAAM,GAAG1E,QAAQ,CAAC0E,KAAM,CAAA;yBAC9B,MAAA;AACLD,4BAAAA,UAAU,CAACC,KAAAA,CAAM,GAAGL,UAAU,CAACK,KAAM,CAAA;AACvC;AACF;AAEA,oBAAA,OAAO1F,MAAOsF,CAAAA,SAAS,CAACvE,KAAAA,CAAAA,CAAO4E,MAAM,CAAC;AACpCjE,wBAAAA,UAAAA;AACAF,wBAAAA,MAAAA;AACAoE,wBAAAA,MAAAA,EAAQ,EAAE;wBACVC,IAAMJ,EAAAA;AACR,qBAAA,CAAA;AACF,iBAAA,CAAA,CAAA;AAEJ,aAAA,CAAE,OAAOlC,KAAO,EAAA;AACdvD,gBAAAA,MAAAA,CAAO2B,GAAG,CAAC4B,KAAK,CAAC,oCAAsCA,EAAAA,KAAAA,CAAAA;AACzD;AACF;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,141 @@
1
+ import { traverseEntity } from '@strapi/utils';
2
+ import { getService } from '../utils/index.mjs';
3
+
4
+ const createAILocalizationsService = ({ strapi })=>{
5
+ // TODO: add a helper function to get the AI server URL
6
+ const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';
7
+ return {
8
+ // Async to avoid changing the signature later (there will be a db check in the future)
9
+ async isEnabled () {
10
+ // Check if future flag is enabled
11
+ const isFutureFlagEnabled = strapi.features.future.isEnabled('unstableAILocalizations');
12
+ if (!isFutureFlagEnabled) {
13
+ return false;
14
+ }
15
+ // Check if user disabled AI features globally
16
+ const isAIEnabled = strapi.config.get('admin.ai.enabled', true);
17
+ if (!isAIEnabled) {
18
+ return false;
19
+ }
20
+ // Check if the user's license grants access to AI features
21
+ const hasAccess = strapi.ee.features.isEnabled('cms-ai');
22
+ if (!hasAccess) {
23
+ return false;
24
+ }
25
+ return true;
26
+ },
27
+ /**
28
+ * Checks if there are localizations that need to be generated for the given document,
29
+ * and if so, calls the AI service and saves the results to the database.
30
+ * Works for both single and collection types, on create and update.
31
+ */ async generateDocumentLocalizations ({ model, document }) {
32
+ const schema = strapi.getModel(model);
33
+ const localeService = getService('locales');
34
+ // No localizations needed for content types with i18n disabled
35
+ const isLocalizedContentType = getService('content-types').isLocalizedContentType(schema);
36
+ if (!isLocalizedContentType) {
37
+ return;
38
+ }
39
+ // Don't trigger localizations if the update is on a derived locale, only do it on the default
40
+ const defaultLocale = await localeService.getDefaultLocale();
41
+ if (document.locale !== defaultLocale) {
42
+ return;
43
+ }
44
+ const isFeatureEnabled = await this.isEnabled();
45
+ if (!isFeatureEnabled) {
46
+ return;
47
+ }
48
+ const documentId = document.documentId;
49
+ if (!documentId) {
50
+ strapi.log.warn(`AI Localizations: missing documentId for ${schema.uid}`);
51
+ return;
52
+ }
53
+ // Extract only the localized content from the document
54
+ const translateableContent = await traverseEntity(({ key, attribute }, { remove })=>{
55
+ const hasLocalizedOption = attribute?.pluginOptions?.i18n?.localized === true;
56
+ // Only keep fields that actually need to be localized
57
+ // TODO: remove blocks from this list once the AI server can handle it reliably
58
+ if (!hasLocalizedOption || [
59
+ 'media',
60
+ 'blocks'
61
+ ].includes(attribute.type)) {
62
+ remove(key);
63
+ }
64
+ }, {
65
+ schema,
66
+ getModel: strapi.getModel.bind(strapi)
67
+ }, document);
68
+ // Call the AI server to get the localized content
69
+ const localesList = await localeService.find();
70
+ const targetLocales = localesList.filter((l)=>l.code !== document.locale).map((l)=>l.code);
71
+ if (targetLocales.length === 0) {
72
+ strapi.log.info(`AI Localizations: no target locales for ${schema.uid} document ${documentId}`);
73
+ return;
74
+ }
75
+ let token;
76
+ try {
77
+ const tokenData = await strapi.service('admin::user').getAiToken();
78
+ token = tokenData.token;
79
+ } catch (error) {
80
+ throw new Error('Failed to retrieve AI token', {
81
+ cause: error instanceof Error ? error : undefined
82
+ });
83
+ }
84
+ strapi.log.http('Contacting AI Server for localizations generation');
85
+ const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {
86
+ method: 'POST',
87
+ headers: {
88
+ 'Content-Type': 'application/json',
89
+ Authorization: `Bearer ${token}`
90
+ },
91
+ body: JSON.stringify({
92
+ content: translateableContent,
93
+ sourceLocale: document.locale,
94
+ targetLocales
95
+ })
96
+ });
97
+ if (!response.ok) {
98
+ strapi.log.error(`AI Localizations request failed: ${response.status} ${response.statusText}`);
99
+ throw new Error(`AI Localizations request failed: ${response.statusText}`);
100
+ }
101
+ const aiResult = await response.json();
102
+ // Get all media field names dynamically from the schema
103
+ const mediaFields = Object.entries(schema.attributes)// eslint-disable-next-line @typescript-eslint/no-unused-vars
104
+ .filter(([_, attr])=>attr.type === 'media').map(([key])=>key);
105
+ try {
106
+ await Promise.allSettled(aiResult.localizations.map(async (localization)=>{
107
+ const { content, locale } = localization;
108
+ // Fetch the derived locale document
109
+ const derivedDoc = await strapi.documents(model).findOne({
110
+ documentId,
111
+ locale,
112
+ populate: mediaFields
113
+ });
114
+ // Merge AI content and media fields
115
+ const mergedData = {
116
+ ...content
117
+ };
118
+ for (const field of mediaFields){
119
+ // Only copy media if not already set in derived locale
120
+ if (!derivedDoc || !derivedDoc[field]) {
121
+ mergedData[field] = document[field];
122
+ } else {
123
+ mergedData[field] = derivedDoc[field];
124
+ }
125
+ }
126
+ return strapi.documents(model).update({
127
+ documentId,
128
+ locale,
129
+ fields: [],
130
+ data: mergedData
131
+ });
132
+ }));
133
+ } catch (error) {
134
+ strapi.log.error('AI Localizations generation failed', error);
135
+ }
136
+ }
137
+ };
138
+ };
139
+
140
+ export { createAILocalizationsService };
141
+ //# sourceMappingURL=ai-localizations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-localizations.mjs","sources":["../../../server/src/services/ai-localizations.ts"],"sourcesContent":["import type { Core, Modules, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { getService } from '../utils';\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\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 future flag is enabled\n const isFutureFlagEnabled = strapi.features.future.isEnabled('unstableAILocalizations');\n if (!isFutureFlagEnabled) {\n return false;\n }\n\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 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 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 isFeatureEnabled = await this.isEnabled();\n if (!isFeatureEnabled) {\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 // Extract only the localized content from the document\n const translateableContent = await traverseEntity(\n ({ key, attribute }, { remove }) => {\n const hasLocalizedOption = attribute?.pluginOptions?.i18n?.localized === true;\n // Only keep fields that actually need to be localized\n // TODO: remove blocks from this list once the AI server can handle it reliably\n if (!hasLocalizedOption || ['media', 'blocks'].includes(attribute.type)) {\n remove(key);\n }\n },\n { schema, getModel: strapi.getModel.bind(strapi) },\n document\n );\n\n // Call the AI server to get the localized content\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 let token: string;\n try {\n const tokenData = await strapi.service('admin::user').getAiToken();\n token = tokenData.token;\n } catch (error) {\n throw new Error('Failed to retrieve AI token', {\n cause: error instanceof Error ? error : undefined,\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 }),\n });\n\n if (!response.ok) {\n strapi.log.error(\n `AI Localizations request failed: ${response.status} ${response.statusText}`\n );\n throw new Error(`AI Localizations request failed: ${response.statusText}`);\n }\n\n const aiResult = await response.json();\n\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.allSettled(\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\n const mergedData = { ...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 return strapi.documents(model).update({\n documentId,\n locale,\n fields: [],\n data: mergedData,\n });\n })\n );\n } catch (error) {\n strapi.log.error('AI Localizations generation failed', error);\n }\n },\n };\n};\n\nexport { createAILocalizationsService };\n"],"names":["createAILocalizationsService","strapi","aiServerUrl","process","env","STRAPI_AI_URL","isEnabled","isFutureFlagEnabled","features","future","isAIEnabled","config","get","hasAccess","ee","generateDocumentLocalizations","model","document","schema","getModel","localeService","getService","isLocalizedContentType","defaultLocale","getDefaultLocale","locale","isFeatureEnabled","documentId","log","warn","uid","translateableContent","traverseEntity","key","attribute","remove","hasLocalizedOption","pluginOptions","i18n","localized","includes","type","bind","localesList","find","targetLocales","filter","l","code","map","length","info","token","tokenData","service","getAiToken","error","Error","cause","undefined","http","response","fetch","method","headers","Authorization","body","JSON","stringify","content","sourceLocale","ok","status","statusText","aiResult","json","mediaFields","Object","entries","attributes","_","attr","Promise","allSettled","localizations","localization","derivedDoc","documents","findOne","populate","mergedData","field","update","fields","data"],"mappings":";;;AAIA,MAAMA,4BAA+B,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;;AAEvE,IAAA,MAAMC,WAAcC,GAAAA,OAAAA,CAAQC,GAAG,CAACC,aAAa,IAAI,kCAAA;IAEjD,OAAO;;QAEL,MAAMC,SAAAA,CAAAA,GAAAA;;AAEJ,YAAA,MAAMC,sBAAsBN,MAAOO,CAAAA,QAAQ,CAACC,MAAM,CAACH,SAAS,CAAC,yBAAA,CAAA;AAC7D,YAAA,IAAI,CAACC,mBAAqB,EAAA;gBACxB,OAAO,KAAA;AACT;;AAGA,YAAA,MAAMG,cAAcT,MAAOU,CAAAA,MAAM,CAACC,GAAG,CAAC,kBAAoB,EAAA,IAAA,CAAA;AAC1D,YAAA,IAAI,CAACF,WAAa,EAAA;gBAChB,OAAO,KAAA;AACT;;AAGA,YAAA,MAAMG,YAAYZ,MAAOa,CAAAA,EAAE,CAACN,QAAQ,CAACF,SAAS,CAAC,QAAA,CAAA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BAAA,CAAA;;AAGA,oBAAA,MAAMc,UAAa,GAAA;AAAE,wBAAA,GAAGrB;AAAQ,qBAAA;oBAChC,KAAK,MAAMsB,SAASf,WAAa,CAAA;;AAE/B,wBAAA,IAAI,CAACU,UAAc,IAAA,CAACA,UAAU,CAACK,MAAM,EAAE;AACrCD,4BAAAA,UAAU,CAACC,KAAAA,CAAM,GAAG1E,QAAQ,CAAC0E,KAAM,CAAA;yBAC9B,MAAA;AACLD,4BAAAA,UAAU,CAACC,KAAAA,CAAM,GAAGL,UAAU,CAACK,KAAM,CAAA;AACvC;AACF;AAEA,oBAAA,OAAO1F,MAAOsF,CAAAA,SAAS,CAACvE,KAAAA,CAAAA,CAAO4E,MAAM,CAAC;AACpCjE,wBAAAA,UAAAA;AACAF,wBAAAA,MAAAA;AACAoE,wBAAAA,MAAAA,EAAQ,EAAE;wBACVC,IAAMJ,EAAAA;AACR,qBAAA,CAAA;AACF,iBAAA,CAAA,CAAA;AAEJ,aAAA,CAAE,OAAOlC,KAAO,EAAA;AACdvD,gBAAAA,MAAAA,CAAO2B,GAAG,CAAC4B,KAAK,CAAC,oCAAsCA,EAAAA,KAAAA,CAAAA;AACzD;AACF;AACF,KAAA;AACF;;;;"}
@@ -7,6 +7,8 @@ var locales = require('./locales.js');
7
7
  var isoLocales = require('./iso-locales.js');
8
8
  var contentTypes = require('./content-types.js');
9
9
  var index = require('./sanitize/index.js');
10
+ var settings = require('./settings.js');
11
+ var aiLocalizations = require('./ai-localizations.js');
10
12
 
11
13
  var services = {
12
14
  permissions,
@@ -15,7 +17,9 @@ var services = {
15
17
  locales,
16
18
  sanitize: index,
17
19
  'iso-locales': isoLocales,
18
- 'content-types': contentTypes
20
+ 'content-types': contentTypes,
21
+ 'ai-localizations': aiLocalizations.createAILocalizationsService,
22
+ settings: settings.createSettingsService
19
23
  };
20
24
 
21
25
  module.exports = services;
@@ -1 +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';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes"],"mappings":";;;;;;;;;;AAQA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,cAAAA,KAAAA;IACA,aAAeC,EAAAA,UAAAA;IACf,eAAiBC,EAAAA;AACnB,CAAE;;;;"}
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 'ai-localizations': createAILocalizationsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","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;IACjB,kBAAoBC,EAAAA,4CAAAA;IACpBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
@@ -5,6 +5,8 @@ import locales from './locales.mjs';
5
5
  import isoLocalesService from './iso-locales.mjs';
6
6
  import contentTypes from './content-types.mjs';
7
7
  import sanitize from './sanitize/index.mjs';
8
+ import { createSettingsService } from './settings.mjs';
9
+ import { createAILocalizationsService } from './ai-localizations.mjs';
8
10
 
9
11
  var services = {
10
12
  permissions,
@@ -13,7 +15,9 @@ var services = {
13
15
  locales,
14
16
  sanitize,
15
17
  'iso-locales': isoLocalesService,
16
- 'content-types': contentTypes
18
+ 'content-types': contentTypes,
19
+ 'ai-localizations': createAILocalizationsService,
20
+ settings: createSettingsService
17
21
  };
18
22
 
19
23
  export { services as default };
@@ -1 +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';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes"],"mappings":";;;;;;;;AAQA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,QAAAA;IACA,aAAeC,EAAAA,iBAAAA;IACf,eAAiBC,EAAAA;AACnB,CAAE;;;;"}
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 'ai-localizations': createAILocalizationsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","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;IACjB,kBAAoBC,EAAAA,4BAAAA;IACpBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const createSettingsService = ({ strapi })=>{
4
+ const settings = strapi.store({
5
+ type: 'plugin',
6
+ name: 'i18n',
7
+ key: 'settings'
8
+ });
9
+ async function getSettings() {
10
+ const res = await settings.get({});
11
+ return res;
12
+ }
13
+ function setSettings(value) {
14
+ return settings.set({
15
+ value
16
+ });
17
+ }
18
+ return {
19
+ getSettings,
20
+ setSettings
21
+ };
22
+ };
23
+
24
+ exports.createSettingsService = createSettingsService;
25
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sources":["../../../server/src/services/settings.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { Settings } from '../validation/settings';\n\nconst createSettingsService = ({ strapi }: { strapi: Core.Strapi }) => {\n const settings = strapi.store!({ type: 'plugin', name: 'i18n', key: 'settings' });\n\n async function getSettings() {\n const res = (await settings.get({})) as Settings | null;\n\n return res;\n }\n\n function setSettings(value: Settings) {\n return settings.set({ value });\n }\n\n return {\n getSettings,\n setSettings,\n };\n};\n\nexport { createSettingsService };\nexport type SettingsService = ReturnType<typeof createSettingsService>;\n"],"names":["createSettingsService","strapi","settings","store","type","name","key","getSettings","res","get","setSettings","value","set"],"mappings":";;AAGA,MAAMA,qBAAwB,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;IAChE,MAAMC,QAAAA,GAAWD,MAAOE,CAAAA,KAAK,CAAE;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA,MAAA;QAAQC,GAAK,EAAA;AAAW,KAAA,CAAA;IAE/E,eAAeC,WAAAA,GAAAA;AACb,QAAA,MAAMC,GAAO,GAAA,MAAMN,QAASO,CAAAA,GAAG,CAAC,EAAC,CAAA;QAEjC,OAAOD,GAAAA;AACT;AAEA,IAAA,SAASE,YAAYC,KAAe,EAAA;QAClC,OAAOT,QAAAA,CAASU,GAAG,CAAC;AAAED,YAAAA;AAAM,SAAA,CAAA;AAC9B;IAEA,OAAO;AACLJ,QAAAA,WAAAA;AACAG,QAAAA;AACF,KAAA;AACF;;;;"}
@@ -0,0 +1,23 @@
1
+ const createSettingsService = ({ strapi })=>{
2
+ const settings = strapi.store({
3
+ type: 'plugin',
4
+ name: 'i18n',
5
+ key: 'settings'
6
+ });
7
+ async function getSettings() {
8
+ const res = await settings.get({});
9
+ return res;
10
+ }
11
+ function setSettings(value) {
12
+ return settings.set({
13
+ value
14
+ });
15
+ }
16
+ return {
17
+ getSettings,
18
+ setSettings
19
+ };
20
+ };
21
+
22
+ export { createSettingsService };
23
+ //# sourceMappingURL=settings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.mjs","sources":["../../../server/src/services/settings.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { Settings } from '../validation/settings';\n\nconst createSettingsService = ({ strapi }: { strapi: Core.Strapi }) => {\n const settings = strapi.store!({ type: 'plugin', name: 'i18n', key: 'settings' });\n\n async function getSettings() {\n const res = (await settings.get({})) as Settings | null;\n\n return res;\n }\n\n function setSettings(value: Settings) {\n return settings.set({ value });\n }\n\n return {\n getSettings,\n setSettings,\n };\n};\n\nexport { createSettingsService };\nexport type SettingsService = ReturnType<typeof createSettingsService>;\n"],"names":["createSettingsService","strapi","settings","store","type","name","key","getSettings","res","get","setSettings","value","set"],"mappings":"AAGA,MAAMA,qBAAwB,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;IAChE,MAAMC,QAAAA,GAAWD,MAAOE,CAAAA,KAAK,CAAE;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA,MAAA;QAAQC,GAAK,EAAA;AAAW,KAAA,CAAA;IAE/E,eAAeC,WAAAA,GAAAA;AACb,QAAA,MAAMC,GAAO,GAAA,MAAMN,QAASO,CAAAA,GAAG,CAAC,EAAC,CAAA;QAEjC,OAAOD,GAAAA;AACT;AAEA,IAAA,SAASE,YAAYC,KAAe,EAAA;QAClC,OAAOT,QAAAA,CAASU,GAAG,CAAC;AAAED,YAAAA;AAAM,SAAA,CAAA;AAC9B;IAEA,OAAO;AACLJ,QAAAA,WAAAA;AACAG,QAAAA;AACF,KAAA;AACF;;;;"}
@@ -5,6 +5,10 @@ declare const _default: {
5
5
  'content-types': {
6
6
  getNonLocalizedAttributes(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
7
7
  };
8
+ settings: {
9
+ updateSettings(ctx: import("koa").Context): Promise<void>;
10
+ getSettings(ctx: import("koa").Context): Promise<void>;
11
+ };
8
12
  };
9
13
  export default _default;
10
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;AAIA,wBAIE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,wBAKE"}
@@ -0,0 +1,7 @@
1
+ import type { Context } from 'koa';
2
+ declare const _default: {
3
+ updateSettings(ctx: Context): Promise<void>;
4
+ getSettings(ctx: Context): Promise<void>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;;wBAMP,OAAO;qBAYV,OAAO;;AAbhC,wBAkBE"}
@@ -33,6 +33,10 @@ declare const _default: () => {
33
33
  'content-types': {
34
34
  getNonLocalizedAttributes(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
35
35
  };
36
+ settings: {
37
+ updateSettings(ctx: import("koa").Context): Promise<void>;
38
+ getSettings(ctx: import("koa").Context): Promise<void>;
39
+ };
36
40
  };
37
41
  contentTypes: {
38
42
  locale: {
@@ -146,6 +150,25 @@ declare const _default: () => {
146
150
  fillNonLocalizedAttributes: (entry: any, relatedEntry: any, { model }: any) => void;
147
151
  getNestedPopulateOfNonLocalizedAttributes: (modelUID: any) => string[];
148
152
  };
153
+ 'ai-localizations': ({ strapi }: {
154
+ strapi: import("@strapi/types/dist/core").Strapi;
155
+ }) => {
156
+ isEnabled(): Promise<boolean>;
157
+ generateDocumentLocalizations({ model, document, }: {
158
+ model: import("@strapi/types/dist/uid").ContentType;
159
+ document: import("@strapi/types/dist/modules/documents").AnyDocument;
160
+ }): Promise<void>;
161
+ };
162
+ settings: ({ strapi }: {
163
+ strapi: import("@strapi/types/dist/core").Strapi;
164
+ }) => {
165
+ getSettings: () => Promise<import("yup/lib/object").AssertsShape<{
166
+ aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
167
+ }> | null>;
168
+ setSettings: (value: import("yup/lib/object").AssertsShape<{
169
+ aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
170
+ }>) => Promise<void>;
171
+ };
149
172
  };
150
173
  };
151
174
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wBAOG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wBAOG"}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/admin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wBA4EE"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/admin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wBA4FE"}
@@ -0,0 +1,17 @@
1
+ import type { Core, Modules, UID } from '@strapi/types';
2
+ declare const createAILocalizationsService: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => {
5
+ isEnabled(): Promise<boolean>;
6
+ /**
7
+ * Checks if there are localizations that need to be generated for the given document,
8
+ * and if so, calls the AI service and saves the results to the database.
9
+ * Works for both single and collection types, on create and update.
10
+ */
11
+ generateDocumentLocalizations({ model, document, }: {
12
+ model: UID.ContentType;
13
+ document: Modules.Documents.AnyDocument;
14
+ }): Promise<void>;
15
+ };
16
+ export { createAILocalizationsService };
17
+ //# sourceMappingURL=ai-localizations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-localizations.d.ts","sourceRoot":"","sources":["../../../../server/src/services/ai-localizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIxD,QAAA,MAAM,4BAA4B,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;;IA4BrE;;;;OAIG;wDAIA;QACD,KAAK,EAAE,IAAI,WAAW,CAAC;QACvB,QAAQ,EAAE,QAAQ,SAAS,CAAC,WAAW,CAAC;KACzC;CAkIJ,CAAC;AAEF,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
@@ -76,6 +76,25 @@ declare const _default: {
76
76
  fillNonLocalizedAttributes: (entry: any, relatedEntry: any, { model }: any) => void;
77
77
  getNestedPopulateOfNonLocalizedAttributes: (modelUID: any) => string[];
78
78
  };
79
+ 'ai-localizations': ({ strapi }: {
80
+ strapi: import("@strapi/types/dist/core").Strapi;
81
+ }) => {
82
+ isEnabled(): Promise<boolean>;
83
+ generateDocumentLocalizations({ model, document, }: {
84
+ model: import("@strapi/types/dist/uid").ContentType;
85
+ document: import("@strapi/types/dist/modules/documents").AnyDocument;
86
+ }): Promise<void>;
87
+ };
88
+ settings: ({ strapi }: {
89
+ strapi: import("@strapi/types/dist/core").Strapi;
90
+ }) => {
91
+ getSettings: () => Promise<import("yup/lib/object").AssertsShape<{
92
+ aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
93
+ }> | null>;
94
+ setSettings: (value: import("yup/lib/object").AssertsShape<{
95
+ aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
96
+ }>) => Promise<void>;
97
+ };
79
98
  };
80
99
  export default _default;
81
100
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wBAQE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,wBAUE"}
@@ -0,0 +1,13 @@
1
+ import type { Core } from '@strapi/types';
2
+ import type { Settings } from '../validation/settings';
3
+ declare const createSettingsService: ({ strapi }: {
4
+ strapi: Core.Strapi;
5
+ }) => {
6
+ getSettings: () => Promise<import("yup/lib/object").AssertsShape<{
7
+ aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
8
+ }> | null>;
9
+ setSettings: (value: Settings) => Promise<void>;
10
+ };
11
+ export { createSettingsService };
12
+ export type SettingsService = ReturnType<typeof createSettingsService>;
13
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../server/src/services/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,QAAA,MAAM,qBAAqB,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;;;;yBASpC,QAAQ;CAQrC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -5,14 +5,18 @@ import type { MetricsService } from '../services/metrics';
5
5
  import type { ISOLocalesService } from '../services/iso-locales';
6
6
  import type { LocalizationsService } from '../services/localizations';
7
7
  import type { SanitizeService } from '../services/sanitize';
8
+ import type { SettingsService } from '../services/settings';
9
+ import type { createAILocalizationsService } from '../services/ai-localizations';
8
10
  type S = {
9
11
  permissions: PermissionsService;
10
12
  metrics: MetricsService;
11
13
  locales: LocaleService;
12
14
  localizations: LocalizationsService;
15
+ settings: SettingsService;
13
16
  ['iso-locales']: ISOLocalesService;
14
17
  ['content-types']: ContentTypesService;
15
18
  sanitize: SanitizeService;
19
+ ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;
16
20
  };
17
21
  declare const getCoreStore: () => {
18
22
  get(params?: Partial<{
@@ -38,6 +42,6 @@ declare const getCoreStore: () => {
38
42
  tag?: string | undefined;
39
43
  }> | undefined): Promise<void>;
40
44
  };
41
- declare const getService: <T extends keyof S>(name: T) => ReturnType<S[T]>;
45
+ declare const getService: <T extends keyof S>(name: T) => S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T];
42
46
  export { getService, getCoreStore };
43
47
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,KAAK,CAAC,GAAG;IACP,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,oBAAoB,CAAC;IACpC,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACnC,CAAC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACvC,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;CAEjB,CAAC;AAGF,QAAA,MAAM,UAAU,4BAA6B,CAAC,KAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAE/D,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src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E,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { yup } from '@strapi/utils';
2
+ declare const settingsSchema: import("yup/lib/object").OptionalObjectSchema<{
3
+ aiLocalizations: yup.BooleanSchema<boolean, Record<string, any>, boolean>;
4
+ }, Record<string, any>, import("yup/lib/object").TypeOfShape<{
5
+ aiLocalizations: yup.BooleanSchema<boolean, Record<string, any>, boolean>;
6
+ }>>;
7
+ declare const _default: (body: unknown, errorMessage?: string | undefined) => Promise<import("yup/lib/object").AssertsShape<{
8
+ aiLocalizations: yup.BooleanSchema<boolean, Record<string, any>, boolean>;
9
+ }>>;
10
+ export default _default;
11
+ export type Settings = yup.InferType<typeof settingsSchema>;
12
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../server/src/validation/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,eAAe,CAAC;AAEvD,QAAA,MAAM,cAAc;;;;GAElB,CAAC;;;;AAEH,wBAAiD;AAEjD,MAAM,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(name: T): ReturnType<S[T]> => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":";;AAkBA,MAAMA,YAAe,GAAA,IAAA;IACnB,OAAOC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA;AAAO,KAAA,CAAA;AACrD;AAEA;AACA,MAAMC,aAAa,CAAoBD,IAAAA,GAAAA;AACrC,IAAA,OAAOH,MAAOK,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAACH,IAAAA,CAAAA;AACvC;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\nimport type { SettingsService } from '../services/settings';\nimport type { createAILocalizationsService } from '../services/ai-localizations';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n settings: SettingsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(\n name: T\n): S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T] => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":";;AAsBA,MAAMA,YAAe,GAAA,IAAA;IACnB,OAAOC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA;AAAO,KAAA,CAAA;AACrD;AAEA;AACA,MAAMC,aAAa,CACjBD,IAAAA,GAAAA;AAEA,IAAA,OAAOH,MAAOK,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAACH,IAAAA,CAAAA;AACvC;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(name: T): ReturnType<S[T]> => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":"AAkBA,MAAMA,YAAe,GAAA,IAAA;IACnB,OAAOC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA;AAAO,KAAA,CAAA;AACrD;AAEA;AACA,MAAMC,aAAa,CAAoBD,IAAAA,GAAAA;AACrC,IAAA,OAAOH,MAAOK,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAACH,IAAAA,CAAAA;AACvC;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\nimport type { SettingsService } from '../services/settings';\nimport type { createAILocalizationsService } from '../services/ai-localizations';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n settings: SettingsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(\n name: T\n): S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T] => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":"AAsBA,MAAMA,YAAe,GAAA,IAAA;IACnB,OAAOC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA;AAAO,KAAA,CAAA;AACrD;AAEA;AACA,MAAMC,aAAa,CACjBD,IAAAA,GAAAA;AAEA,IAAA,OAAOH,MAAOK,CAAAA,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAACH,IAAAA,CAAAA;AACvC;;;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var utils = require('@strapi/utils');
4
+
5
+ const settingsSchema = utils.yup.object({
6
+ aiLocalizations: utils.yup.boolean().default(false)
7
+ });
8
+ var validateSettings = utils.validateYupSchema(settingsSchema);
9
+
10
+ module.exports = validateSettings;
11
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sources":["../../../server/src/validation/settings.ts"],"sourcesContent":["import { yup, validateYupSchema } from '@strapi/utils';\n\nconst settingsSchema = yup.object({\n aiLocalizations: yup.boolean().default(false),\n});\n\nexport default validateYupSchema(settingsSchema);\n\nexport type Settings = yup.InferType<typeof settingsSchema>;\n"],"names":["settingsSchema","yup","object","aiLocalizations","boolean","default","validateYupSchema"],"mappings":";;;;AAEA,MAAMA,cAAAA,GAAiBC,SAAIC,CAAAA,MAAM,CAAC;AAChCC,IAAAA,eAAAA,EAAiBF,SAAIG,CAAAA,OAAO,EAAGC,CAAAA,OAAO,CAAC,KAAA;AACzC,CAAA,CAAA;AAEA,uBAAeC,wBAAkBN,cAAgB,CAAA;;;;"}
@@ -0,0 +1,9 @@
1
+ import { yup, validateYupSchema } from '@strapi/utils';
2
+
3
+ const settingsSchema = yup.object({
4
+ aiLocalizations: yup.boolean().default(false)
5
+ });
6
+ var validateSettings = validateYupSchema(settingsSchema);
7
+
8
+ export { validateSettings as default };
9
+ //# sourceMappingURL=settings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.mjs","sources":["../../../server/src/validation/settings.ts"],"sourcesContent":["import { yup, validateYupSchema } from '@strapi/utils';\n\nconst settingsSchema = yup.object({\n aiLocalizations: yup.boolean().default(false),\n});\n\nexport default validateYupSchema(settingsSchema);\n\nexport type Settings = yup.InferType<typeof settingsSchema>;\n"],"names":["settingsSchema","yup","object","aiLocalizations","boolean","default","validateYupSchema"],"mappings":";;AAEA,MAAMA,cAAAA,GAAiBC,GAAIC,CAAAA,MAAM,CAAC;AAChCC,IAAAA,eAAAA,EAAiBF,GAAIG,CAAAA,OAAO,EAAGC,CAAAA,OAAO,CAAC,KAAA;AACzC,CAAA,CAAA;AAEA,uBAAeC,kBAAkBN,cAAgB,CAAA;;;;"}