@strapi/i18n 0.0.0-next.929f36e7cd2888f97e66b5159baa15234a283fca → 0.0.0-next.92e60e369ae0e382a5d486de347f6d286ab22987

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 (203) hide show
  1. package/dist/admin/components/BulkLocaleActionModal.js +2 -2
  2. package/dist/admin/components/BulkLocaleActionModal.js.map +1 -1
  3. package/dist/admin/components/BulkLocaleActionModal.mjs +2 -2
  4. package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -1
  5. package/dist/admin/components/CMHeaderActions.js +294 -20
  6. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  7. package/dist/admin/components/CMHeaderActions.mjs +298 -25
  8. package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
  9. package/dist/admin/components/CreateLocale.js +8 -4
  10. package/dist/admin/components/CreateLocale.js.map +1 -1
  11. package/dist/admin/components/CreateLocale.mjs +9 -5
  12. package/dist/admin/components/CreateLocale.mjs.map +1 -1
  13. package/dist/admin/components/EditLocale.js +1 -1
  14. package/dist/admin/components/EditLocale.js.map +1 -1
  15. package/dist/admin/components/EditLocale.mjs +1 -1
  16. package/dist/admin/components/EditLocale.mjs.map +1 -1
  17. package/dist/admin/components/LocaleListCell.js +65 -45
  18. package/dist/admin/components/LocaleListCell.js.map +1 -1
  19. package/dist/admin/components/LocaleListCell.mjs +66 -46
  20. package/dist/admin/components/LocaleListCell.mjs.map +1 -1
  21. package/dist/admin/components/LocalePicker.js +18 -11
  22. package/dist/admin/components/LocalePicker.js.map +1 -1
  23. package/dist/admin/components/LocalePicker.mjs +19 -12
  24. package/dist/admin/components/LocalePicker.mjs.map +1 -1
  25. package/dist/admin/contentManagerHooks/editView.js +6 -3
  26. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  27. package/dist/admin/contentManagerHooks/editView.mjs +7 -4
  28. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  29. package/dist/admin/contentManagerHooks/listView.js +2 -1
  30. package/dist/admin/contentManagerHooks/listView.js.map +1 -1
  31. package/dist/admin/contentManagerHooks/listView.mjs +2 -1
  32. package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
  33. package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
  34. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
  35. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
  36. package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
  37. package/dist/admin/hooks/useI18n.js +4 -4
  38. package/dist/admin/hooks/useI18n.js.map +1 -1
  39. package/dist/admin/hooks/useI18n.mjs +4 -4
  40. package/dist/admin/hooks/useI18n.mjs.map +1 -1
  41. package/dist/admin/index.js +1 -1
  42. package/dist/admin/index.js.map +1 -1
  43. package/dist/admin/index.mjs +2 -2
  44. package/dist/admin/index.mjs.map +1 -1
  45. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +34 -24
  46. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -1
  47. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +34 -24
  48. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -1
  49. package/dist/admin/pages/SettingsPage.js +121 -46
  50. package/dist/admin/pages/SettingsPage.js.map +1 -1
  51. package/dist/admin/pages/SettingsPage.mjs +124 -30
  52. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  53. package/dist/admin/services/aiLocalizationJobs.js +26 -0
  54. package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
  55. package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
  56. package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
  57. package/dist/admin/services/api.js +4 -1
  58. package/dist/admin/services/api.js.map +1 -1
  59. package/dist/admin/services/api.mjs +4 -1
  60. package/dist/admin/services/api.mjs.map +1 -1
  61. package/dist/admin/services/locales.js +4 -2
  62. package/dist/admin/services/locales.js.map +1 -1
  63. package/dist/admin/services/locales.mjs +4 -2
  64. package/dist/admin/services/locales.mjs.map +1 -1
  65. package/dist/admin/services/settings.js +30 -0
  66. package/dist/admin/services/settings.js.map +1 -0
  67. package/dist/admin/services/settings.mjs +27 -0
  68. package/dist/admin/services/settings.mjs.map +1 -0
  69. package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
  70. package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
  71. package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
  72. package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
  73. package/dist/admin/src/services/api.d.ts +1 -1
  74. package/dist/admin/src/services/locales.d.ts +1 -1
  75. package/dist/admin/src/services/relations.d.ts +1 -1
  76. package/dist/admin/src/services/settings.d.ts +5 -0
  77. package/dist/admin/src/utils/schemas.d.ts +642 -16
  78. package/dist/admin/translations/en.json.js +10 -0
  79. package/dist/admin/translations/en.json.js.map +1 -1
  80. package/dist/admin/translations/en.json.mjs +10 -0
  81. package/dist/admin/translations/en.json.mjs.map +1 -1
  82. package/dist/admin/utils/clean.js +2 -2
  83. package/dist/admin/utils/clean.js.map +1 -1
  84. package/dist/admin/utils/clean.mjs +2 -2
  85. package/dist/admin/utils/clean.mjs.map +1 -1
  86. package/dist/admin/utils/fields.js +6 -1
  87. package/dist/admin/utils/fields.js.map +1 -1
  88. package/dist/admin/utils/fields.mjs +6 -1
  89. package/dist/admin/utils/fields.mjs.map +1 -1
  90. package/dist/admin/utils/getTranslation.js.map +1 -1
  91. package/dist/admin/utils/getTranslation.mjs.map +1 -1
  92. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
  93. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
  94. package/dist/admin/utils/schemas.js +19 -13
  95. package/dist/admin/utils/schemas.js.map +1 -1
  96. package/dist/admin/utils/schemas.mjs +19 -13
  97. package/dist/admin/utils/schemas.mjs.map +1 -1
  98. package/dist/server/bootstrap.js +24 -8
  99. package/dist/server/bootstrap.js.map +1 -1
  100. package/dist/server/bootstrap.mjs +24 -8
  101. package/dist/server/bootstrap.mjs.map +1 -1
  102. package/dist/server/constants/iso-locales.json.js +4 -0
  103. package/dist/server/constants/iso-locales.json.js.map +1 -1
  104. package/dist/server/constants/iso-locales.json.mjs +4 -0
  105. package/dist/server/constants/iso-locales.json.mjs.map +1 -1
  106. package/dist/server/controllers/ai-localization-jobs.js +47 -0
  107. package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
  108. package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
  109. package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
  110. package/dist/server/controllers/index.js +5 -1
  111. package/dist/server/controllers/index.js.map +1 -1
  112. package/dist/server/controllers/index.mjs +5 -1
  113. package/dist/server/controllers/index.mjs.map +1 -1
  114. package/dist/server/controllers/settings.js +24 -0
  115. package/dist/server/controllers/settings.js.map +1 -0
  116. package/dist/server/controllers/settings.mjs +22 -0
  117. package/dist/server/controllers/settings.mjs.map +1 -0
  118. package/dist/server/models/ai-localization-job.js +60 -0
  119. package/dist/server/models/ai-localization-job.js.map +1 -0
  120. package/dist/server/models/ai-localization-job.mjs +57 -0
  121. package/dist/server/models/ai-localization-job.mjs.map +1 -0
  122. package/dist/server/register.js +3 -1
  123. package/dist/server/register.js.map +1 -1
  124. package/dist/server/register.mjs +3 -1
  125. package/dist/server/register.mjs.map +1 -1
  126. package/dist/server/routes/admin.js +40 -0
  127. package/dist/server/routes/admin.js.map +1 -1
  128. package/dist/server/routes/admin.mjs +40 -0
  129. package/dist/server/routes/admin.mjs.map +1 -1
  130. package/dist/server/routes/content-api.js +11 -7
  131. package/dist/server/routes/content-api.js.map +1 -1
  132. package/dist/server/routes/content-api.mjs +11 -7
  133. package/dist/server/routes/content-api.mjs.map +1 -1
  134. package/dist/server/routes/index.mjs +2 -2
  135. package/dist/server/routes/validation/locale.js +57 -0
  136. package/dist/server/routes/validation/locale.js.map +1 -0
  137. package/dist/server/routes/validation/locale.mjs +36 -0
  138. package/dist/server/routes/validation/locale.mjs.map +1 -0
  139. package/dist/server/services/ai-localization-jobs.js +64 -0
  140. package/dist/server/services/ai-localization-jobs.js.map +1 -0
  141. package/dist/server/services/ai-localization-jobs.mjs +62 -0
  142. package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
  143. package/dist/server/services/ai-localizations.js +268 -0
  144. package/dist/server/services/ai-localizations.js.map +1 -0
  145. package/dist/server/services/ai-localizations.mjs +266 -0
  146. package/dist/server/services/ai-localizations.mjs.map +1 -0
  147. package/dist/server/services/content-types.js.map +1 -1
  148. package/dist/server/services/content-types.mjs.map +1 -1
  149. package/dist/server/services/index.js +7 -1
  150. package/dist/server/services/index.js.map +1 -1
  151. package/dist/server/services/index.mjs +7 -1
  152. package/dist/server/services/index.mjs.map +1 -1
  153. package/dist/server/services/settings.js +25 -0
  154. package/dist/server/services/settings.js.map +1 -0
  155. package/dist/server/services/settings.mjs +23 -0
  156. package/dist/server/services/settings.mjs.map +1 -0
  157. package/dist/server/src/bootstrap.d.ts.map +1 -1
  158. package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
  159. package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
  160. package/dist/server/src/controllers/index.d.ts +10 -0
  161. package/dist/server/src/controllers/index.d.ts.map +1 -1
  162. package/dist/server/src/controllers/settings.d.ts +7 -0
  163. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  164. package/dist/server/src/index.d.ts +47 -8
  165. package/dist/server/src/index.d.ts.map +1 -1
  166. package/dist/server/src/models/ai-localization-job.d.ts +5 -0
  167. package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
  168. package/dist/server/src/models/index.d.ts +5 -0
  169. package/dist/server/src/models/index.d.ts.map +1 -0
  170. package/dist/server/src/register.d.ts +1 -1
  171. package/dist/server/src/register.d.ts.map +1 -1
  172. package/dist/server/src/routes/admin.d.ts.map +1 -1
  173. package/dist/server/src/routes/content-api.d.ts +5 -8
  174. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  175. package/dist/server/src/routes/index.d.ts +3 -7
  176. package/dist/server/src/routes/index.d.ts.map +1 -1
  177. package/dist/server/src/routes/validation/index.d.ts +2 -0
  178. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  179. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  180. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  181. package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
  182. package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
  183. package/dist/server/src/services/ai-localizations.d.ts +18 -0
  184. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  185. package/dist/server/src/services/index.d.ts +33 -0
  186. package/dist/server/src/services/index.d.ts.map +1 -1
  187. package/dist/server/src/services/settings.d.ts +13 -0
  188. package/dist/server/src/services/settings.d.ts.map +1 -0
  189. package/dist/server/src/utils/index.d.ts +7 -1
  190. package/dist/server/src/utils/index.d.ts.map +1 -1
  191. package/dist/server/src/validation/settings.d.ts +12 -0
  192. package/dist/server/src/validation/settings.d.ts.map +1 -0
  193. package/dist/server/utils/index.js.map +1 -1
  194. package/dist/server/utils/index.mjs.map +1 -1
  195. package/dist/server/validation/settings.js +11 -0
  196. package/dist/server/validation/settings.js.map +1 -0
  197. package/dist/server/validation/settings.mjs +9 -0
  198. package/dist/server/validation/settings.mjs.map +1 -0
  199. package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
  200. package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
  201. package/dist/shared/contracts/settings.d.ts +40 -0
  202. package/dist/shared/contracts/shared.d.ts.map +1 -0
  203. package/package.json +13 -10
@@ -20,8 +20,16 @@ var en = {
20
20
  "CMEditViewBulkLocale.publication-status": "Publication Status",
21
21
  "CMEditViewBulkLocale.draft-relation-warning": "Some locales are related to draft entries. Publishing them could leave broken links in your app.",
22
22
  "CMEditViewBulkLocale.continue-confirmation": "Are you sure you want to continue?",
23
+ "CMEditViewAITranslation.status-aria-label": "AI Translation Status",
24
+ "CMEditViewAITranslation.status-title": "{enabled, select, true {AI translation enabled} false {AI translation disabled} other {AI translation disabled}}",
25
+ "CMEditViewAITranslation.status-description": "Our AI translates content in all locales each time you save a modification in the default locale.",
26
+ "CMEditViewAITranslation.settings-link": "{enabled, select, true {Disable it in settings} false {Enable it in settings} other {Enable it in settings}}",
27
+ "CMEditViewAITranslation.job-completed": "AI translation completed successfully!",
28
+ "CMEditViewAITranslation.job-failed": "AI translation failed. Please try again.",
23
29
  "CMEditViewLocalePicker.locale.create": "Create <bold>{locale}</bold> locale",
30
+ "CMEditViewLocalePicker.locale.ai-translations": "AI Translations:",
24
31
  "CMListView.popover.display-locales.label": "Display translated locales",
32
+ "CMListView.popover.display-locales.more": "{locales} + {count} more",
25
33
  "CheckboxConfirmation.Modal.body": "Do you want to disable it?",
26
34
  "CheckboxConfirmation.Modal.button-confirm": "Yes, disable",
27
35
  "CheckboxConfirmation.Modal.content": "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing).",
@@ -36,6 +44,8 @@ var en = {
36
44
  "Settings.list.description": "Configure the settings for the Internationalization plugin",
37
45
  "Settings.list.empty.description": "This is not a usual behavior, meaning that you have eventually modified the database manually. Make sure to have at least one locale saved in your database in order to be able to use Strapi correctly.",
38
46
  "Settings.list.empty.title": "There are no locales.",
47
+ "Settings.aiLocalizations.label": "AI Translations",
48
+ "Settings.aiLocalizations.description": "Everytime you save in the Content Manager, our AI will use your default locale to translate all other locales automatically.",
39
49
  "Settings.locales.default": "Default",
40
50
  "Settings.locales.list.sort.default": "Sort by the default locale",
41
51
  "Settings.locales.list.sort.displayName": "Sort by display name",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -18,8 +18,16 @@ var en = {
18
18
  "CMEditViewBulkLocale.publication-status": "Publication Status",
19
19
  "CMEditViewBulkLocale.draft-relation-warning": "Some locales are related to draft entries. Publishing them could leave broken links in your app.",
20
20
  "CMEditViewBulkLocale.continue-confirmation": "Are you sure you want to continue?",
21
+ "CMEditViewAITranslation.status-aria-label": "AI Translation Status",
22
+ "CMEditViewAITranslation.status-title": "{enabled, select, true {AI translation enabled} false {AI translation disabled} other {AI translation disabled}}",
23
+ "CMEditViewAITranslation.status-description": "Our AI translates content in all locales each time you save a modification in the default locale.",
24
+ "CMEditViewAITranslation.settings-link": "{enabled, select, true {Disable it in settings} false {Enable it in settings} other {Enable it in settings}}",
25
+ "CMEditViewAITranslation.job-completed": "AI translation completed successfully!",
26
+ "CMEditViewAITranslation.job-failed": "AI translation failed. Please try again.",
21
27
  "CMEditViewLocalePicker.locale.create": "Create <bold>{locale}</bold> locale",
28
+ "CMEditViewLocalePicker.locale.ai-translations": "AI Translations:",
22
29
  "CMListView.popover.display-locales.label": "Display translated locales",
30
+ "CMListView.popover.display-locales.more": "{locales} + {count} more",
23
31
  "CheckboxConfirmation.Modal.body": "Do you want to disable it?",
24
32
  "CheckboxConfirmation.Modal.button-confirm": "Yes, disable",
25
33
  "CheckboxConfirmation.Modal.content": "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing).",
@@ -34,6 +42,8 @@ var en = {
34
42
  "Settings.list.description": "Configure the settings for the Internationalization plugin",
35
43
  "Settings.list.empty.description": "This is not a usual behavior, meaning that you have eventually modified the database manually. Make sure to have at least one locale saved in your database in order to be able to use Strapi correctly.",
36
44
  "Settings.list.empty.title": "There are no locales.",
45
+ "Settings.aiLocalizations.label": "AI Translations",
46
+ "Settings.aiLocalizations.description": "Everytime you save in the Content Manager, our AI will use your default locale to translate all other locales automatically.",
37
47
  "Settings.locales.default": "Default",
38
48
  "Settings.locales.list.sort.default": "Sort by the default locale",
39
49
  "Settings.locales.list.sort.displayName": "Sort by display name",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -55,8 +55,8 @@ const recursiveRemoveFieldTypes = (data, schema, components, fields)=>{
55
55
  __temp_key__: index + 1
56
56
  };
57
57
  });
58
- } else {
59
- const { id: _, ...rest } = recursiveRemoveFieldTypes(data[current] ?? {}, components[component], components, fields);
58
+ } else if (data[current]) {
59
+ const { id: _, ...rest } = recursiveRemoveFieldTypes(data[current], components[component], components, fields);
60
60
  acc[current] = rest;
61
61
  }
62
62
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"clean.js","sources":["../../../admin/src/utils/clean.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\n\ntype Data = Record<keyof Schema.ContentType['attributes'], any>;\n\nconst cleanData = (\n data: Data,\n schema: Schema.ContentType,\n components: Record<string, Schema.Component>\n) => {\n const cleanedData = removeFields(data, [\n 'createdAt',\n 'createdBy',\n 'updatedAt',\n 'updatedBy',\n 'id',\n 'documentId',\n 'publishedAt',\n 'strapi_stage',\n 'strapi_assignee',\n 'locale',\n 'status',\n ]);\n\n const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(\n cleanedData,\n schema,\n components,\n ['relation', 'password']\n );\n\n return cleanedDataWithoutPasswordAndRelation;\n};\n\nconst removeFields = (data: Data, fields: Array<keyof Schema.ContentType['attributes']>) => {\n return Object.keys(data).reduce((acc, current) => {\n if (fields.includes(current)) {\n return acc;\n }\n acc[current] = data[current];\n return acc;\n }, {} as Data);\n};\n\nconst recursiveRemoveFieldTypes = (\n data: Data,\n schema: Schema.Schema,\n components: Record<string, Schema.Component>,\n fields: Array<keyof Schema.ContentType['attributes']>\n) => {\n return Object.keys(data).reduce((acc, current) => {\n const attribute = schema.attributes[current] ?? { type: undefined };\n\n if (fields.includes(attribute.type)) {\n return acc;\n }\n\n if (attribute.type === 'dynamiczone') {\n acc[current] = data[current].map((componentValue: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n componentValue,\n components[componentValue.__component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else if (attribute.type === 'component') {\n const { repeatable, component } = attribute;\n\n if (repeatable) {\n acc[current] = (data[current] ?? []).map((compoData: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n compoData,\n components[component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n data[current] ?? {},\n components[component],\n components,\n fields\n );\n\n acc[current] = rest;\n }\n } else {\n acc[current] = data[current];\n }\n\n return acc;\n }, {} as any);\n};\n\nexport { cleanData };\n"],"names":["cleanData","data","schema","components","cleanedData","removeFields","cleanedDataWithoutPasswordAndRelation","recursiveRemoveFieldTypes","fields","Object","keys","reduce","acc","current","includes","attribute","attributes","type","undefined","map","componentValue","index","id","_","rest","__component","__temp_key__","repeatable","component","compoData"],"mappings":";;AAIMA,MAAAA,SAAAA,GAAY,CAChBC,IAAAA,EACAC,MACAC,EAAAA,UAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,aAAaJ,IAAM,EAAA;AACrC,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,IAAA;AACA,QAAA,YAAA;AACA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T,KAAA,EAAG,EAAC,CAAA;AACN,CAAA;;;;"}
1
+ {"version":3,"file":"clean.js","sources":["../../../admin/src/utils/clean.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\n\ntype Data = Record<keyof Schema.ContentType['attributes'], any>;\n\nconst cleanData = (\n data: Data,\n schema: Schema.ContentType,\n components: Record<string, Schema.Component>\n) => {\n const cleanedData = removeFields(data, [\n 'createdAt',\n 'createdBy',\n 'updatedAt',\n 'updatedBy',\n 'id',\n 'documentId',\n 'publishedAt',\n 'strapi_stage',\n 'strapi_assignee',\n 'locale',\n 'status',\n ]);\n\n const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(\n cleanedData,\n schema,\n components,\n ['relation', 'password']\n );\n\n return cleanedDataWithoutPasswordAndRelation;\n};\n\nconst removeFields = (data: Data, fields: Array<keyof Schema.ContentType['attributes']>) => {\n return Object.keys(data).reduce((acc, current) => {\n if (fields.includes(current)) {\n return acc;\n }\n acc[current] = data[current];\n return acc;\n }, {} as Data);\n};\n\nconst recursiveRemoveFieldTypes = (\n data: Data,\n schema: Schema.Schema,\n components: Record<string, Schema.Component>,\n fields: Array<keyof Schema.ContentType['attributes']>\n) => {\n return Object.keys(data).reduce((acc, current) => {\n const attribute = schema.attributes[current] ?? { type: undefined };\n\n if (fields.includes(attribute.type)) {\n return acc;\n }\n\n if (attribute.type === 'dynamiczone') {\n acc[current] = data[current].map((componentValue: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n componentValue,\n components[componentValue.__component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else if (attribute.type === 'component') {\n const { repeatable, component } = attribute;\n\n if (repeatable) {\n acc[current] = (data[current] ?? []).map((compoData: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n compoData,\n components[component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else if (data[current]) {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n data[current],\n components[component],\n components,\n fields\n );\n\n acc[current] = rest;\n }\n } else {\n acc[current] = data[current];\n }\n\n return acc;\n }, {} as any);\n};\n\nexport { cleanData };\n"],"names":["cleanData","data","schema","components","cleanedData","removeFields","cleanedDataWithoutPasswordAndRelation","recursiveRemoveFieldTypes","fields","Object","keys","reduce","acc","current","includes","attribute","attributes","type","undefined","map","componentValue","index","id","_","rest","__component","__temp_key__","repeatable","component","compoData"],"mappings":";;AAIMA,MAAAA,SAAAA,GAAY,CAChBC,IAAAA,EACAC,MACAC,EAAAA,UAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,aAAaJ,IAAM,EAAA;AACrC,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,IAAA;AACA,QAAA,YAAA;AACA,QAAA,aAAA;AACA,QAAA,cAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA;AACD,KAAA,CAAA;AAED,IAAA,MAAMK,qCAAwCC,GAAAA,yBAAAA,CAC5CH,WACAF,EAAAA,MAAAA,EACAC,UACA,EAAA;AAAC,QAAA,UAAA;AAAY,QAAA;AAAW,KAAA,CAAA;IAG1B,OAAOG,qCAAAA;AACT;AAEA,MAAMD,YAAAA,GAAe,CAACJ,IAAYO,EAAAA,MAAAA,GAAAA;AAChC,IAAA,OAAOC,OAAOC,IAAI,CAACT,MAAMU,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;QACpC,IAAIL,MAAAA,CAAOM,QAAQ,CAACD,OAAU,CAAA,EAAA;YAC5B,OAAOD,GAAAA;AACT;AACAA,QAAAA,GAAG,CAACC,OAAAA,CAAQ,GAAGZ,IAAI,CAACY,OAAQ,CAAA;QAC5B,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN,CAAA;AAEA,MAAML,yBAA4B,GAAA,CAChCN,IACAC,EAAAA,MAAAA,EACAC,UACAK,EA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U,EACrBzB,UACAK,EAAAA,MAAAA,CAAAA;oBAGF,OAAO;AACL,wBAAA,GAAGgB,IAAI;AACPE,wBAAAA,YAAAA,EAAcL,KAAQ,GAAA;AACxB,qBAAA;AACF,iBAAA,CAAA;AACF,aAAA,MAAO,IAAIpB,IAAI,CAACY,OAAAA,CAAQ,EAAE;AACxB,gBAAA,MAAM,EAAES,EAAIC,EAAAA,CAAC,EAAE,GAAGC,MAAM,GAAGjB,yBAAAA,CACzBN,IAAI,CAACY,QAAQ,EACbV,UAAU,CAACyB,SAAAA,CAAU,EACrBzB,UACAK,EAAAA,MAAAA,CAAAA;gBAGFI,GAAG,CAACC,QAAQ,GAAGW,IAAAA;AACjB;SACK,MAAA;AACLZ,YAAAA,GAAG,CAACC,OAAAA,CAAQ,GAAGZ,IAAI,CAACY,OAAQ,CAAA;AAC9B;QAEA,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN,CAAA;;;;"}
@@ -53,8 +53,8 @@ const recursiveRemoveFieldTypes = (data, schema, components, fields)=>{
53
53
  __temp_key__: index + 1
54
54
  };
55
55
  });
56
- } else {
57
- const { id: _, ...rest } = recursiveRemoveFieldTypes(data[current] ?? {}, components[component], components, fields);
56
+ } else if (data[current]) {
57
+ const { id: _, ...rest } = recursiveRemoveFieldTypes(data[current], components[component], components, fields);
58
58
  acc[current] = rest;
59
59
  }
60
60
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"clean.mjs","sources":["../../../admin/src/utils/clean.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\n\ntype Data = Record<keyof Schema.ContentType['attributes'], any>;\n\nconst cleanData = (\n data: Data,\n schema: Schema.ContentType,\n components: Record<string, Schema.Component>\n) => {\n const cleanedData = removeFields(data, [\n 'createdAt',\n 'createdBy',\n 'updatedAt',\n 'updatedBy',\n 'id',\n 'documentId',\n 'publishedAt',\n 'strapi_stage',\n 'strapi_assignee',\n 'locale',\n 'status',\n ]);\n\n const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(\n cleanedData,\n schema,\n components,\n ['relation', 'password']\n );\n\n return cleanedDataWithoutPasswordAndRelation;\n};\n\nconst removeFields = (data: Data, fields: Array<keyof Schema.ContentType['attributes']>) => {\n return Object.keys(data).reduce((acc, current) => {\n if (fields.includes(current)) {\n return acc;\n }\n acc[current] = data[current];\n return acc;\n }, {} as Data);\n};\n\nconst recursiveRemoveFieldTypes = (\n data: Data,\n schema: Schema.Schema,\n components: Record<string, Schema.Component>,\n fields: Array<keyof Schema.ContentType['attributes']>\n) => {\n return Object.keys(data).reduce((acc, current) => {\n const attribute = schema.attributes[current] ?? { type: undefined };\n\n if (fields.includes(attribute.type)) {\n return acc;\n }\n\n if (attribute.type === 'dynamiczone') {\n acc[current] = data[current].map((componentValue: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n componentValue,\n components[componentValue.__component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else if (attribute.type === 'component') {\n const { repeatable, component } = attribute;\n\n if (repeatable) {\n acc[current] = (data[current] ?? []).map((compoData: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n compoData,\n components[component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n data[current] ?? {},\n components[component],\n components,\n fields\n );\n\n acc[current] = rest;\n }\n } else {\n acc[current] = data[current];\n }\n\n return acc;\n }, {} as any);\n};\n\nexport { cleanData };\n"],"names":["cleanData","data","schema","components","cleanedData","removeFields","cleanedDataWithoutPasswordAndRelation","recursiveRemoveFieldTypes","fields","Object","keys","reduce","acc","current","includes","attribute","attributes","type","undefined","map","componentValue","index","id","_","rest","__component","__temp_key__","repeatable","component","compoData"],"mappings":"AAIMA,MAAAA,SAAAA,GAAY,CAChBC,IAAAA,EACAC,MACAC,EAAAA,UAAAA,GAAAA;IAEA,MAAMC,WAAAA,G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GW,IAAAA;AACjB;SACK,MAAA;AACLZ,YAAAA,GAAG,CAACC,OAAAA,CAAQ,GAAGZ,IAAI,CAACY,OAAQ,CAAA;AAC9B;QAEA,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN,CAAA;;;;"}
1
+ {"version":3,"file":"clean.mjs","sources":["../../../admin/src/utils/clean.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\n\ntype Data = Record<keyof Schema.ContentType['attributes'], any>;\n\nconst cleanData = (\n data: Data,\n schema: Schema.ContentType,\n components: Record<string, Schema.Component>\n) => {\n const cleanedData = removeFields(data, [\n 'createdAt',\n 'createdBy',\n 'updatedAt',\n 'updatedBy',\n 'id',\n 'documentId',\n 'publishedAt',\n 'strapi_stage',\n 'strapi_assignee',\n 'locale',\n 'status',\n ]);\n\n const cleanedDataWithoutPasswordAndRelation = recursiveRemoveFieldTypes(\n cleanedData,\n schema,\n components,\n ['relation', 'password']\n );\n\n return cleanedDataWithoutPasswordAndRelation;\n};\n\nconst removeFields = (data: Data, fields: Array<keyof Schema.ContentType['attributes']>) => {\n return Object.keys(data).reduce((acc, current) => {\n if (fields.includes(current)) {\n return acc;\n }\n acc[current] = data[current];\n return acc;\n }, {} as Data);\n};\n\nconst recursiveRemoveFieldTypes = (\n data: Data,\n schema: Schema.Schema,\n components: Record<string, Schema.Component>,\n fields: Array<keyof Schema.ContentType['attributes']>\n) => {\n return Object.keys(data).reduce((acc, current) => {\n const attribute = schema.attributes[current] ?? { type: undefined };\n\n if (fields.includes(attribute.type)) {\n return acc;\n }\n\n if (attribute.type === 'dynamiczone') {\n acc[current] = data[current].map((componentValue: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n componentValue,\n components[componentValue.__component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else if (attribute.type === 'component') {\n const { repeatable, component } = attribute;\n\n if (repeatable) {\n acc[current] = (data[current] ?? []).map((compoData: any, index: number) => {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n compoData,\n components[component],\n components,\n fields\n );\n\n return {\n ...rest,\n __temp_key__: index + 1,\n };\n });\n } else if (data[current]) {\n const { id: _, ...rest } = recursiveRemoveFieldTypes(\n data[current],\n components[component],\n components,\n fields\n );\n\n acc[current] = rest;\n }\n } else {\n acc[current] = data[current];\n }\n\n return acc;\n }, {} as any);\n};\n\nexport { cleanData };\n"],"names":["cleanData","data","schema","components","cleanedData","removeFields","cleanedDataWithoutPasswordAndRelation","recursiveRemoveFieldTypes","fields","Object","keys","reduce","acc","current","includes","attribute","attributes","type","undefined","map","componentValue","index","id","_","rest","__component","__temp_key__","repeatable","component","compoData"],"mappings":"AAIMA,MAAAA,SAAAA,GAAY,CAChBC,IAAAA,EACAC,MACAC,EAAAA,UAAAA,GAAAA;IAEA,MAAMC,WAAAA,GAAcC,aAAaJ,IAAM,EAAA;AACrC,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,IAAA;AACA,QAAA,YAAA;AACA,QAAA,aAAA;AACA,QAAA,cAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA;AACD,KAAA,CAAA;AAED,IAAA,MAAMK,qCAAwCC,GAAAA,yBAAAA,CAC5CH,WACAF,EAAAA,MAAAA,EACAC,UACA,EAAA;AAAC,QAAA,UAAA;AAAY,QAAA;AAAW,KAAA,CAAA;IAG1B,OAAOG,qCAAAA;AACT;AAEA,MAAMD,YAAAA,GAAe,CAACJ,IAAYO,EAAAA,MAAAA,GAAAA;AAChC,IAAA,OAAOC,OAAOC,IAAI,CAACT,MAAMU,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;QACpC,IAAIL,MAAAA,CAAOM,QAAQ,CAACD,OAAU,CAAA,EAAA;YAC5B,OAAOD,GAAAA;AACT;AACAA,QAAAA,GAAG,CAACC,OAAAA,CAAQ,GAAGZ,IAAI,CAACY,OAAQ,CA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D,oBAAA,MAAM,EAAEC,EAAAA,EAAIC,CAAC,EAAE,GAAGC,IAAAA,EAAM,GAAGjB,yBAAAA,CACzBsB,SACA1B,EAAAA,UAAU,CAACyB,SAAAA,CAAU,EACrBzB,UACAK,EAAAA,MAAAA,CAAAA;oBAGF,OAAO;AACL,wBAAA,GAAGgB,IAAI;AACPE,wBAAAA,YAAAA,EAAcL,KAAQ,GAAA;AACxB,qBAAA;AACF,iBAAA,CAAA;AACF,aAAA,MAAO,IAAIpB,IAAI,CAACY,OAAAA,CAAQ,EAAE;AACxB,gBAAA,MAAM,EAAES,EAAIC,EAAAA,CAAC,EAAE,GAAGC,MAAM,GAAGjB,yBAAAA,CACzBN,IAAI,CAACY,QAAQ,EACbV,UAAU,CAACyB,SAAAA,CAAU,EACrBzB,UACAK,EAAAA,MAAAA,CAAAA;gBAGFI,GAAG,CAACC,QAAQ,GAAGW,IAAAA;AACjB;SACK,MAAA;AACLZ,YAAAA,GAAG,CAACC,OAAAA,CAAQ,GAAGZ,IAAI,CAACY,OAAQ,CAAA;AAC9B;QAEA,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN,CAAA;;;;"}
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var has = require('lodash/has');
4
+
3
5
  const LOCALIZED_FIELDS = [
4
6
  'biginteger',
5
7
  'boolean',
@@ -22,7 +24,10 @@ const LOCALIZED_FIELDS = [
22
24
  'text',
23
25
  'time'
24
26
  ];
25
- const doesPluginOptionsHaveI18nLocalized = (opts)=>typeof opts === 'object' && opts !== null && 'i18n' in opts && typeof opts.i18n === 'object' && opts.i18n !== null && 'localized' in opts.i18n && typeof opts.i18n.localized === 'boolean';
27
+ const doesPluginOptionsHaveI18nLocalized = (opts)=>has(opts, [
28
+ 'i18n',
29
+ 'localized'
30
+ ]);
26
31
 
27
32
  exports.LOCALIZED_FIELDS = LOCALIZED_FIELDS;
28
33
  exports.doesPluginOptionsHaveI18nLocalized = doesPluginOptionsHaveI18nLocalized;
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sources":["../../../admin/src/utils/fields.ts"],"sourcesContent":["const LOCALIZED_FIELDS = [\n 'biginteger',\n 'boolean',\n 'component',\n 'date',\n 'datetime',\n 'decimal',\n 'dynamiczone',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'media',\n 'number',\n 'password',\n 'richtext',\n 'blocks',\n 'string',\n 'text',\n 'time',\n];\n\nconst doesPluginOptionsHaveI18nLocalized = (\n opts?: object\n): opts is { i18n: { localized: boolean } } =>\n typeof opts === 'object' &&\n opts !== null &&\n 'i18n' in opts &&\n typeof opts.i18n === 'object' &&\n opts.i18n !== null &&\n 'localized' in opts.i18n &&\n typeof opts.i18n.localized === 'boolean';\n\nexport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized };\n"],"names":["LOCALIZED_FIELDS","doesPluginOptionsHaveI18nLocalized","opts","i18n","localized"],"mappings":";;AAAA,MAAMA,gBAAmB,GAAA;AACvB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD;AAED,MAAMC,kCAAqC,GAAA,CACzCC,IAEA,GAAA,OAAOA,IAAS,KAAA,QAAA,IAChBA,IAAS,KAAA,IAAA,IACT,MAAUA,IAAAA,IAAAA,IACV,OAAOA,IAAAA,CAAKC,IAAI,KAAK,QACrBD,IAAAA,IAAAA,CAAKC,IAAI,KAAK,IACd,IAAA,WAAA,IAAeD,IAAKC,CAAAA,IAAI,IACxB,OAAOD,IAAKC,CAAAA,IAAI,CAACC,SAAS,KAAK;;;;;"}
1
+ {"version":3,"file":"fields.js","sources":["../../../admin/src/utils/fields.ts"],"sourcesContent":["import has from 'lodash/has';\n\nconst LOCALIZED_FIELDS = [\n 'biginteger',\n 'boolean',\n 'component',\n 'date',\n 'datetime',\n 'decimal',\n 'dynamiczone',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'media',\n 'number',\n 'password',\n 'richtext',\n 'blocks',\n 'string',\n 'text',\n 'time',\n];\n\nconst doesPluginOptionsHaveI18nLocalized = (\n opts?: object\n): opts is { i18n: { localized: boolean } } => has(opts, ['i18n', 'localized']);\n\nexport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized };\n"],"names":["LOCALIZED_FIELDS","doesPluginOptionsHaveI18nLocalized","opts","has"],"mappings":";;;;AAEA,MAAMA,gBAAmB,GAAA;AACvB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD;AAED,MAAMC,kCAAqC,GAAA,CACzCC,IAC6CC,GAAAA,GAAAA,CAAID,IAAM,EAAA;AAAC,QAAA,MAAA;AAAQ,QAAA;AAAY,KAAA;;;;;"}
@@ -1,3 +1,5 @@
1
+ import has from 'lodash/has';
2
+
1
3
  const LOCALIZED_FIELDS = [
2
4
  'biginteger',
3
5
  'boolean',
@@ -20,7 +22,10 @@ const LOCALIZED_FIELDS = [
20
22
  'text',
21
23
  'time'
22
24
  ];
23
- const doesPluginOptionsHaveI18nLocalized = (opts)=>typeof opts === 'object' && opts !== null && 'i18n' in opts && typeof opts.i18n === 'object' && opts.i18n !== null && 'localized' in opts.i18n && typeof opts.i18n.localized === 'boolean';
25
+ const doesPluginOptionsHaveI18nLocalized = (opts)=>has(opts, [
26
+ 'i18n',
27
+ 'localized'
28
+ ]);
24
29
 
25
30
  export { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized };
26
31
  //# sourceMappingURL=fields.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.mjs","sources":["../../../admin/src/utils/fields.ts"],"sourcesContent":["const LOCALIZED_FIELDS = [\n 'biginteger',\n 'boolean',\n 'component',\n 'date',\n 'datetime',\n 'decimal',\n 'dynamiczone',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'media',\n 'number',\n 'password',\n 'richtext',\n 'blocks',\n 'string',\n 'text',\n 'time',\n];\n\nconst doesPluginOptionsHaveI18nLocalized = (\n opts?: object\n): opts is { i18n: { localized: boolean } } =>\n typeof opts === 'object' &&\n opts !== null &&\n 'i18n' in opts &&\n typeof opts.i18n === 'object' &&\n opts.i18n !== null &&\n 'localized' in opts.i18n &&\n typeof opts.i18n.localized === 'boolean';\n\nexport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized };\n"],"names":["LOCALIZED_FIELDS","doesPluginOptionsHaveI18nLocalized","opts","i18n","localized"],"mappings":"AAAA,MAAMA,gBAAmB,GAAA;AACvB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD;AAED,MAAMC,kCAAqC,GAAA,CACzCC,IAEA,GAAA,OAAOA,IAAS,KAAA,QAAA,IAChBA,IAAS,KAAA,IAAA,IACT,MAAUA,IAAAA,IAAAA,IACV,OAAOA,IAAAA,CAAKC,IAAI,KAAK,QACrBD,IAAAA,IAAAA,CAAKC,IAAI,KAAK,IACd,IAAA,WAAA,IAAeD,IAAKC,CAAAA,IAAI,IACxB,OAAOD,IAAKC,CAAAA,IAAI,CAACC,SAAS,KAAK;;;;"}
1
+ {"version":3,"file":"fields.mjs","sources":["../../../admin/src/utils/fields.ts"],"sourcesContent":["import has from 'lodash/has';\n\nconst LOCALIZED_FIELDS = [\n 'biginteger',\n 'boolean',\n 'component',\n 'date',\n 'datetime',\n 'decimal',\n 'dynamiczone',\n 'email',\n 'enumeration',\n 'float',\n 'integer',\n 'json',\n 'media',\n 'number',\n 'password',\n 'richtext',\n 'blocks',\n 'string',\n 'text',\n 'time',\n];\n\nconst doesPluginOptionsHaveI18nLocalized = (\n opts?: object\n): opts is { i18n: { localized: boolean } } => has(opts, ['i18n', 'localized']);\n\nexport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized };\n"],"names":["LOCALIZED_FIELDS","doesPluginOptionsHaveI18nLocalized","opts","has"],"mappings":";;AAEA,MAAMA,gBAAmB,GAAA;AACvB,IAAA,YAAA;AACA,IAAA,SAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,aAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,UAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD;AAED,MAAMC,kCAAqC,GAAA,CACzCC,IAC6CC,GAAAA,GAAAA,CAAID,IAAM,EAAA;AAAC,QAAA,MAAA;AAAQ,QAAA;AAAY,KAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslation.js","sources":["../../../admin/src/utils/getTranslation.ts"],"sourcesContent":["import { pluginId } from '../pluginId';\n\nconst getTranslation = (id: string) => `${pluginId}.${id}`;\n\nexport { getTranslation };\n"],"names":["getTranslation","id","pluginId"],"mappings":";;;;AAEMA,MAAAA,cAAAA,GAAiB,CAACC,EAAe,GAAA,CAAC,EAAEC,iBAAS,CAAA,CAAC,EAAED,EAAAA,CAAG;;;;"}
1
+ {"version":3,"file":"getTranslation.js","sources":["../../../admin/src/utils/getTranslation.ts"],"sourcesContent":["import { pluginId } from '../pluginId';\n\nconst getTranslation = (id: string) => `${pluginId}.${id}`;\n\nexport { getTranslation };\n"],"names":["getTranslation","id","pluginId"],"mappings":";;;;AAEA,MAAMA,iBAAiB,CAACC,EAAAA,GAAe,GAAGC,iBAAS,CAAA,CAAC,EAAED,EAAI,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslation.mjs","sources":["../../../admin/src/utils/getTranslation.ts"],"sourcesContent":["import { pluginId } from '../pluginId';\n\nconst getTranslation = (id: string) => `${pluginId}.${id}`;\n\nexport { getTranslation };\n"],"names":["getTranslation","id","pluginId"],"mappings":";;AAEMA,MAAAA,cAAAA,GAAiB,CAACC,EAAe,GAAA,CAAC,EAAEC,QAAS,CAAA,CAAC,EAAED,EAAAA,CAAG;;;;"}
1
+ {"version":3,"file":"getTranslation.mjs","sources":["../../../admin/src/utils/getTranslation.ts"],"sourcesContent":["import { pluginId } from '../pluginId';\n\nconst getTranslation = (id: string) => `${pluginId}.${id}`;\n\nexport { getTranslation };\n"],"names":["getTranslation","id","pluginId"],"mappings":";;AAEA,MAAMA,iBAAiB,CAACC,EAAAA,GAAe,GAAGC,QAAS,CAAA,CAAC,EAAED,EAAI,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"prefixPluginTranslations.js","sources":["../../../admin/src/utils/prefixPluginTranslations.ts"],"sourcesContent":["type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n"],"names":["prefixPluginTranslations","trad","pluginId","Object","keys","reduce","acc","current"],"mappings":";;AAEMA,MAAAA,wBAAAA,GAA2B,CAACC,IAAmBC,EAAAA,QAAAA,GAAAA;AAInD,IAAA,OAAOC,OAAOC,IAAI,CAACH,MAAMI,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;AACpCD,QAAAA,GAAG,CAAC,CAAC,EAAEJ,QAAAA,CAAS,CAAC,EAAEK,OAAQ,CAAA,CAAC,CAAC,GAAGN,IAAI,CAACM,OAAQ,CAAA;QAC7C,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN;;;;"}
1
+ {"version":3,"file":"prefixPluginTranslations.js","sources":["../../../admin/src/utils/prefixPluginTranslations.ts"],"sourcesContent":["type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n"],"names":["prefixPluginTranslations","trad","pluginId","Object","keys","reduce","acc","current"],"mappings":";;AAEMA,MAAAA,wBAAAA,GAA2B,CAACC,IAAmBC,EAAAA,QAAAA,GAAAA;AAInD,IAAA,OAAOC,OAAOC,IAAI,CAACH,MAAMI,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;QACpCD,GAAG,CAAC,CAAGJ,EAAAA,QAAAA,CAAS,CAAC,EAAEK,SAAS,CAAC,GAAGN,IAAI,CAACM,OAAQ,CAAA;QAC7C,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"prefixPluginTranslations.mjs","sources":["../../../admin/src/utils/prefixPluginTranslations.ts"],"sourcesContent":["type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n"],"names":["prefixPluginTranslations","trad","pluginId","Object","keys","reduce","acc","current"],"mappings":"AAEMA,MAAAA,wBAAAA,GAA2B,CAACC,IAAmBC,EAAAA,QAAAA,GAAAA;AAInD,IAAA,OAAOC,OAAOC,IAAI,CAACH,MAAMI,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;AACpCD,QAAAA,GAAG,CAAC,CAAC,EAAEJ,QAAAA,CAAS,CAAC,EAAEK,OAAQ,CAAA,CAAC,CAAC,GAAGN,IAAI,CAACM,OAAQ,CAAA;QAC7C,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN;;;;"}
1
+ {"version":3,"file":"prefixPluginTranslations.mjs","sources":["../../../admin/src/utils/prefixPluginTranslations.ts"],"sourcesContent":["type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n"],"names":["prefixPluginTranslations","trad","pluginId","Object","keys","reduce","acc","current"],"mappings":"AAEMA,MAAAA,wBAAAA,GAA2B,CAACC,IAAmBC,EAAAA,QAAAA,GAAAA;AAInD,IAAA,OAAOC,OAAOC,IAAI,CAACH,MAAMI,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;QACpCD,GAAG,CAAC,CAAGJ,EAAAA,QAAAA,CAAS,CAAC,EAAEK,SAAS,CAAC,GAAGN,IAAI,CAACM,OAAQ,CAAA;QAC7C,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN;;;;"}
@@ -5,13 +5,17 @@ var fields = require('./fields.js');
5
5
 
6
6
  /* -------------------------------------------------------------------------------------------------
7
7
  * mutateCTBContentTypeSchema
8
- * -----------------------------------------------------------------------------------------------*/ const mutateCTBContentTypeSchema = (nextSchema, prevSchema)=>{
8
+ * -----------------------------------------------------------------------------------------------*/ // TODO: refactor for CTB refactors
9
+ const mutateCTBContentTypeSchema = (nextSchema, prevSchema)=>{
10
+ if (!prevSchema) {
11
+ return nextSchema;
12
+ }
9
13
  // Don't perform mutations components
10
14
  if (!fields.doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {
11
15
  return nextSchema;
12
16
  }
13
17
  const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;
14
- const isPrevSchemaLocalized = fields.doesPluginOptionsHaveI18nLocalized(prevSchema?.schema?.pluginOptions) ? prevSchema?.schema?.pluginOptions.i18n.localized : false;
18
+ const isPrevSchemaLocalized = fields.doesPluginOptionsHaveI18nLocalized(prevSchema?.pluginOptions) ? prevSchema?.pluginOptions.i18n.localized : false;
15
19
  // No need to perform modification on the schema, if the i18n feature was not changed
16
20
  // at the ct level
17
21
  if (isNextSchemaLocalized && isPrevSchemaLocalized) {
@@ -38,8 +42,8 @@ var fields = require('./fields.js');
38
42
  };
39
43
  /* -------------------------------------------------------------------------------------------------
40
44
  * addLocalisationToFields
41
- * -----------------------------------------------------------------------------------------------*/ const addLocalisationToFields = (attributes)=>Object.keys(attributes).reduce((acc, current)=>{
42
- const currentAttribute = attributes[current];
45
+ * -----------------------------------------------------------------------------------------------*/ const addLocalisationToFields = (attributes)=>{
46
+ return attributes.map((currentAttribute)=>{
43
47
  if (fields.LOCALIZED_FIELDS.includes(currentAttribute.type)) {
44
48
  const i18n = {
45
49
  localized: true
@@ -50,19 +54,21 @@ var fields = require('./fields.js');
50
54
  } : {
51
55
  i18n
52
56
  };
53
- acc[current] = {
57
+ return {
54
58
  ...currentAttribute,
55
59
  pluginOptions
56
60
  };
57
- return acc;
58
61
  }
59
- acc[current] = currentAttribute;
60
- return acc;
61
- }, {});
62
- const disableAttributesLocalisation = (attributes)=>Object.keys(attributes).reduce((acc, current)=>{
63
- acc[current] = omit(attributes[current], 'pluginOptions.i18n');
64
- return acc;
65
- }, {});
62
+ return currentAttribute;
63
+ });
64
+ };
65
+ /* -------------------------------------------------------------------------------------------------
66
+ * disableAttributesLocalisation
67
+ * -----------------------------------------------------------------------------------------------*/ const disableAttributesLocalisation = (attributes)=>{
68
+ return attributes.map((currentAttribute)=>{
69
+ return omit(currentAttribute, 'pluginOptions.i18n');
70
+ });
71
+ };
66
72
 
67
73
  exports.mutateCTBContentTypeSchema = mutateCTBContentTypeSchema;
68
74
  //# sourceMappingURL=schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.js","sources":["../../../admin/src/utils/schemas.ts"],"sourcesContent":["import omit from 'lodash/omit';\n\nimport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized } from './fields';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * mutateCTBContentTypeSchema\n * -----------------------------------------------------------------------------------------------*/\n\nconst mutateCTBContentTypeSchema = (\n nextSchema: Schema.ContentType,\n prevSchema?: {\n apiID?: string;\n schema?: Schema.ContentType;\n uid?: string;\n }\n) => {\n // Don't perform mutations components\n if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {\n return nextSchema;\n }\n\n const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;\n const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(\n prevSchema?.schema?.pluginOptions\n )\n ? prevSchema?.schema?.pluginOptions.i18n.localized\n : false;\n\n // No need to perform modification on the schema, if the i18n feature was not changed\n // at the ct level\n if (isNextSchemaLocalized && isPrevSchemaLocalized) {\n return nextSchema;\n }\n\n if (isNextSchemaLocalized) {\n const attributes = addLocalisationToFields(nextSchema.attributes);\n\n return { ...nextSchema, attributes };\n }\n\n // Remove the i18n object from the pluginOptions\n if (!isNextSchemaLocalized) {\n const pluginOptions = omit(nextSchema.pluginOptions, 'i18n');\n const attributes = disableAttributesLocalisation(nextSchema.attributes);\n\n return { ...nextSchema, pluginOptions, attributes };\n }\n\n return nextSchema;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * addLocalisationToFields\n * -----------------------------------------------------------------------------------------------*/\n\nconst addLocalisationToFields = (attributes: Schema.ContentType['attributes']) =>\n Object.keys(attributes).reduce<Schema.ContentType['attributes']>((acc, current) => {\n const currentAttribute = attributes[current];\n\n if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {\n const i18n = { localized: true };\n\n const pluginOptions = currentAttribute.pluginOptions\n ? { ...currentAttribute.pluginOptions, i18n }\n : { i18n };\n\n acc[current] = { ...currentAttribute, pluginOptions };\n\n return acc;\n }\n\n acc[current] = currentAttribute;\n\n return acc;\n }, {});\n\n/* -------------------------------------------------------------------------------------------------\n * disableAttributesLocalisation\n * -----------------------------------------------------------------------------------------------*/\n\ntype OmitByPath<T extends object, K extends string[]> = Pick<T, Exclude<keyof T, K[number]>>;\n\nconst disableAttributesLocalisation = (attributes: Schema.ContentType['attributes']) =>\n Object.keys(attributes).reduce<\n Record<string, OmitByPath<Schema.ContentType['attributes'][string], ['pluginOptions', 'i18n']>>\n >((acc, current) => {\n acc[current] = omit(attributes[current], 'pluginOptions.i18n');\n\n return acc;\n }, {});\n\nexport { mutateCTBContentTypeSchema };\n"],"names":["mutateCTBContentTypeSchema","nextSchema","prevSchema","doesPluginOptionsHaveI18nLocalized","pluginOptions","isNextSchemaLocalized","i18n","localized","isPrevSchemaLocalized","schema","attributes","addLocalisationToFields","omit","disableAttributesLocalisation","Object","keys","reduce","acc","current","currentAttribute","LOCALIZED_FIELDS","includes","type"],"mappings":";;;;;AAMA;;qGAIA,MAAMA,0BAA6B,GAAA,CACjCC,UACAC,EAAAA,UAAAA,GAAAA;;AAOA,IAAA,IAAI,CAACC,yCAAAA,CAAmCF,UAAWG,CAAAA,aAAa,CAAG,EAAA;QACjE,OAAOH,UAAAA;AACT;AAEA,IAAA,MAAMI,wBAAwBJ,UAAWG,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;IACrE,MAAMC,qBAAAA,GAAwBL,0CAC5BD,UAAYO,EAAAA,MAAAA,EAAQL,iBAElBF,UAAYO,EAAAA,MAAAA,EAAQL,aAAcE,CAAAA,IAAAA,CAAKC,SACvC,GAAA,KAAA;;;AAIJ,IAAA,IAAIF,yBAAyBG,qBAAuB,EAAA;QAClD,OAAOP,UAAAA;AACT;AAEA,IAAA,IAAII,qBAAuB,EAAA;QACzB,MAAMK,UAAAA,GAAaC,uBAAwBV,CAAAA,UAAAA,CAAWS,UAAU,CAAA;QAEhE,OAAO;AAAE,YAAA,GAAGT,UAAU;AAAES,YAAAA;AAAW,SAAA;AACrC;;AAGA,IAAA,IAAI,CAACL,qBAAuB,EAAA;AAC1B,QAAA,MAAMD,aAAgBQ,GAAAA,IAAAA,CAAKX,UAAWG,CAAAA,aAAa,EAAE,MAAA,CAAA;QACrD,MAAMM,UAAAA,GAAaG,6BAA8BZ,CAAAA,UAAAA,CAAWS,UAAU,CAAA;QAEtE,OAAO;AAAE,YAAA,GAAGT,UAAU;AAAEG,YAAAA,aAAAA;AAAeM,YAAAA;AAAW,SAAA;AACpD;IAEA,OAAOT,UAAAA;AACT;AAEA;;qGAIA,MAAMU,uBAA0B,GAAA,CAACD,UAC/BI,GAAAA,MAAAA,CAAOC,IAAI,CAACL,UAAYM,CAAAA,CAAAA,MAAM,CAAmC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;QACrE,MAAMC,gBAAAA,GAAmBT,UAAU,CAACQ,OAAQ,CAAA;AAE5C,QAAA,IAAIE,uBAAiBC,CAAAA,QAAQ,CAACF,gBAAAA,CAAiBG,IAAI,CAAG,EAAA;AACpD,YAAA,MAAMhB,IAAO,GAAA;gBAAEC,SAAW,EAAA;AAAK,aAAA;YAE/B,MAAMH,aAAAA,GAAgBe,gBAAiBf,CAAAA,aAAa,GAChD;AAAE,gBAAA,GAAGe,iBAAiBf,aAAa;AAAEE,gBAAAA;aACrC,GAAA;AAAEA,gBAAAA;AAAK,aAAA;YAEXW,GAAG,CAACC,QAAQ,GAAG;AAAE,gBAAA,GAAGC,gBAAgB;AAAEf,gBAAAA;AAAc,aAAA;YAEpD,OAAOa,GAAAA;AACT;QAEAA,GAAG,CAACC,QAAQ,GAAGC,gBAAAA;QAEf,OAAOF,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AAQN,MAAMJ,6BAAAA,GAAgC,CAACH,UAAAA,GACrCI,MAAOC,CAAAA,IAAI,CAACL,UAAYM,CAAAA,CAAAA,MAAM,CAE5B,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;AACND,QAAAA,GAAG,CAACC,OAAQ,CAAA,GAAGN,KAAKF,UAAU,CAACQ,QAAQ,EAAE,oBAAA,CAAA;QAEzC,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;;;;"}
1
+ {"version":3,"file":"schemas.js","sources":["../../../admin/src/utils/schemas.ts"],"sourcesContent":["import omit from 'lodash/omit';\n\nimport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized } from './fields';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * mutateCTBContentTypeSchema\n * -----------------------------------------------------------------------------------------------*/\n\n// TODO: refactor for CTB refactors\nconst mutateCTBContentTypeSchema = (\n nextSchema: {\n pluginOptions: Schema.ContentType['pluginOptions'];\n attributes: Schema.Attribute.AnyAttribute[];\n uid?: string;\n },\n prevSchema?: {\n pluginOptions: Schema.ContentType['pluginOptions'];\n attributes: Schema.Attribute.AnyAttribute[];\n uid?: string;\n }\n) => {\n if (!prevSchema) {\n return nextSchema;\n }\n\n // Don't perform mutations components\n if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {\n return nextSchema;\n }\n\n const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;\n const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(prevSchema?.pluginOptions)\n ? prevSchema?.pluginOptions.i18n.localized\n : false;\n\n // No need to perform modification on the schema, if the i18n feature was not changed\n // at the ct level\n if (isNextSchemaLocalized && isPrevSchemaLocalized) {\n return nextSchema;\n }\n\n if (isNextSchemaLocalized) {\n const attributes = addLocalisationToFields(nextSchema.attributes);\n\n return {\n ...nextSchema,\n attributes,\n };\n }\n\n // Remove the i18n object from the pluginOptions\n if (!isNextSchemaLocalized) {\n const pluginOptions = omit(nextSchema.pluginOptions, 'i18n');\n const attributes = disableAttributesLocalisation(nextSchema.attributes);\n\n return {\n ...nextSchema,\n pluginOptions,\n attributes,\n };\n }\n\n return nextSchema;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * addLocalisationToFields\n * -----------------------------------------------------------------------------------------------*/\n\nconst addLocalisationToFields = (attributes: Schema.Attribute.AnyAttribute[]) => {\n return attributes.map((currentAttribute) => {\n if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {\n const i18n = { localized: true };\n\n const pluginOptions = currentAttribute.pluginOptions\n ? { ...currentAttribute.pluginOptions, i18n }\n : { i18n };\n\n return { ...currentAttribute, pluginOptions };\n }\n\n return currentAttribute;\n });\n};\n\n/* -------------------------------------------------------------------------------------------------\n * disableAttributesLocalisation\n * -----------------------------------------------------------------------------------------------*/\n\nconst disableAttributesLocalisation = (attributes: Schema.Attribute.AnyAttribute[]) => {\n return attributes.map((currentAttribute) => {\n return omit(currentAttribute, 'pluginOptions.i18n');\n });\n};\n\nexport { mutateCTBContentTypeSchema };\n"],"names":["mutateCTBContentTypeSchema","nextSchema","prevSchema","doesPluginOptionsHaveI18nLocalized","pluginOptions","isNextSchemaLocalized","i18n","localized","isPrevSchemaLocalized","attributes","addLocalisationToFields","omit","disableAttributesLocalisation","map","currentAttribute","LOCALIZED_FIELDS","includes","type"],"mappings":";;;;;AAMA;;AAEkG;AAG5FA,MAAAA,0BAAAA,GAA6B,CACjCC,UAKAC,EAAAA,UAAAA,GAAAA;AAMA,IAAA,IAAI,CAACA,UAAY,EAAA;QACf,OAAOD,UAAAA;AACT;;AAGA,IAAA,IAAI,CAACE,yCAAAA,CAAmCF,UAAWG,CAAAA,aAAa,CAAG,EAAA;QACjE,OAAOH,UAAAA;AACT;AAEA,IAAA,MAAMI,wBAAwBJ,UAAWG,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;AACrE,IAAA,MAAMC,wBAAwBL,yCAAmCD,CAAAA,UAAAA,EAAYE,iBACzEF,UAAYE,EAAAA,aAAAA,CAAcE,KAAKC,SAC/B,GAAA,KAAA;;;AAIJ,IAAA,IAAIF,yBAAyBG,qBAAuB,EAAA;QAClD,OAAOP,UAAAA;AACT;AAEA,IAAA,IAAII,qBAAuB,EAAA;QACzB,MAAMI,UAAAA,GAAaC,uBAAwBT,CAAAA,UAAAA,CAAWQ,UAAU,CAAA;QAEhE,OAAO;AACL,YAAA,GAAGR,UAAU;AACbQ,YAAAA;AACF,SAAA;AACF;;AAGA,IAAA,IAAI,CAACJ,qBAAuB,EAAA;AAC1B,QAAA,MAAMD,aAAgBO,GAAAA,IAAAA,CAAKV,UAAWG,CAAAA,aAAa,EAAE,MAAA,CAAA;QACrD,MAAMK,UAAAA,GAAaG,6BAA8BX,CAAAA,UAAAA,CAAWQ,UAAU,CAAA;QAEtE,OAAO;AACL,YAAA,GAAGR,UAAU;AACbG,YAAAA,aAAAA;AACAK,YAAAA;AACF,SAAA;AACF;IAEA,OAAOR,UAAAA;AACT;AAEA;;qGAIA,MAAMS,0BAA0B,CAACD,UAAAA,GAAAA;IAC/B,OAAOA,UAAAA,CAAWI,GAAG,CAAC,CAACC,gBAAAA,GAAAA;AACrB,QAAA,IAAIC,uBAAiBC,CAAAA,QAAQ,CAACF,gBAAAA,CAAiBG,IAAI,CAAG,EAAA;AACpD,YAAA,MAAMX,IAAO,GAAA;gBAAEC,SAAW,EAAA;AAAK,aAAA;YAE/B,MAAMH,aAAAA,GAAgBU,gBAAiBV,CAAAA,aAAa,GAChD;AAAE,gBAAA,GAAGU,iBAAiBV,aAAa;AAAEE,gBAAAA;aACrC,GAAA;AAAEA,gBAAAA;AAAK,aAAA;YAEX,OAAO;AAAE,gBAAA,GAAGQ,gBAAgB;AAAEV,gBAAAA;AAAc,aAAA;AAC9C;QAEA,OAAOU,gBAAAA;AACT,KAAA,CAAA;AACF,CAAA;AAEA;;qGAIA,MAAMF,gCAAgC,CAACH,UAAAA,GAAAA;IACrC,OAAOA,UAAAA,CAAWI,GAAG,CAAC,CAACC,gBAAAA,GAAAA;AACrB,QAAA,OAAOH,KAAKG,gBAAkB,EAAA,oBAAA,CAAA;AAChC,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -3,13 +3,17 @@ import { doesPluginOptionsHaveI18nLocalized, LOCALIZED_FIELDS } from './fields.m
3
3
 
4
4
  /* -------------------------------------------------------------------------------------------------
5
5
  * mutateCTBContentTypeSchema
6
- * -----------------------------------------------------------------------------------------------*/ const mutateCTBContentTypeSchema = (nextSchema, prevSchema)=>{
6
+ * -----------------------------------------------------------------------------------------------*/ // TODO: refactor for CTB refactors
7
+ const mutateCTBContentTypeSchema = (nextSchema, prevSchema)=>{
8
+ if (!prevSchema) {
9
+ return nextSchema;
10
+ }
7
11
  // Don't perform mutations components
8
12
  if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {
9
13
  return nextSchema;
10
14
  }
11
15
  const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;
12
- const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(prevSchema?.schema?.pluginOptions) ? prevSchema?.schema?.pluginOptions.i18n.localized : false;
16
+ const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(prevSchema?.pluginOptions) ? prevSchema?.pluginOptions.i18n.localized : false;
13
17
  // No need to perform modification on the schema, if the i18n feature was not changed
14
18
  // at the ct level
15
19
  if (isNextSchemaLocalized && isPrevSchemaLocalized) {
@@ -36,8 +40,8 @@ import { doesPluginOptionsHaveI18nLocalized, LOCALIZED_FIELDS } from './fields.m
36
40
  };
37
41
  /* -------------------------------------------------------------------------------------------------
38
42
  * addLocalisationToFields
39
- * -----------------------------------------------------------------------------------------------*/ const addLocalisationToFields = (attributes)=>Object.keys(attributes).reduce((acc, current)=>{
40
- const currentAttribute = attributes[current];
43
+ * -----------------------------------------------------------------------------------------------*/ const addLocalisationToFields = (attributes)=>{
44
+ return attributes.map((currentAttribute)=>{
41
45
  if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {
42
46
  const i18n = {
43
47
  localized: true
@@ -48,19 +52,21 @@ import { doesPluginOptionsHaveI18nLocalized, LOCALIZED_FIELDS } from './fields.m
48
52
  } : {
49
53
  i18n
50
54
  };
51
- acc[current] = {
55
+ return {
52
56
  ...currentAttribute,
53
57
  pluginOptions
54
58
  };
55
- return acc;
56
59
  }
57
- acc[current] = currentAttribute;
58
- return acc;
59
- }, {});
60
- const disableAttributesLocalisation = (attributes)=>Object.keys(attributes).reduce((acc, current)=>{
61
- acc[current] = omit(attributes[current], 'pluginOptions.i18n');
62
- return acc;
63
- }, {});
60
+ return currentAttribute;
61
+ });
62
+ };
63
+ /* -------------------------------------------------------------------------------------------------
64
+ * disableAttributesLocalisation
65
+ * -----------------------------------------------------------------------------------------------*/ const disableAttributesLocalisation = (attributes)=>{
66
+ return attributes.map((currentAttribute)=>{
67
+ return omit(currentAttribute, 'pluginOptions.i18n');
68
+ });
69
+ };
64
70
 
65
71
  export { mutateCTBContentTypeSchema };
66
72
  //# sourceMappingURL=schemas.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.mjs","sources":["../../../admin/src/utils/schemas.ts"],"sourcesContent":["import omit from 'lodash/omit';\n\nimport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized } from './fields';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * mutateCTBContentTypeSchema\n * -----------------------------------------------------------------------------------------------*/\n\nconst mutateCTBContentTypeSchema = (\n nextSchema: Schema.ContentType,\n prevSchema?: {\n apiID?: string;\n schema?: Schema.ContentType;\n uid?: string;\n }\n) => {\n // Don't perform mutations components\n if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {\n return nextSchema;\n }\n\n const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;\n const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(\n prevSchema?.schema?.pluginOptions\n )\n ? prevSchema?.schema?.pluginOptions.i18n.localized\n : false;\n\n // No need to perform modification on the schema, if the i18n feature was not changed\n // at the ct level\n if (isNextSchemaLocalized && isPrevSchemaLocalized) {\n return nextSchema;\n }\n\n if (isNextSchemaLocalized) {\n const attributes = addLocalisationToFields(nextSchema.attributes);\n\n return { ...nextSchema, attributes };\n }\n\n // Remove the i18n object from the pluginOptions\n if (!isNextSchemaLocalized) {\n const pluginOptions = omit(nextSchema.pluginOptions, 'i18n');\n const attributes = disableAttributesLocalisation(nextSchema.attributes);\n\n return { ...nextSchema, pluginOptions, attributes };\n }\n\n return nextSchema;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * addLocalisationToFields\n * -----------------------------------------------------------------------------------------------*/\n\nconst addLocalisationToFields = (attributes: Schema.ContentType['attributes']) =>\n Object.keys(attributes).reduce<Schema.ContentType['attributes']>((acc, current) => {\n const currentAttribute = attributes[current];\n\n if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {\n const i18n = { localized: true };\n\n const pluginOptions = currentAttribute.pluginOptions\n ? { ...currentAttribute.pluginOptions, i18n }\n : { i18n };\n\n acc[current] = { ...currentAttribute, pluginOptions };\n\n return acc;\n }\n\n acc[current] = currentAttribute;\n\n return acc;\n }, {});\n\n/* -------------------------------------------------------------------------------------------------\n * disableAttributesLocalisation\n * -----------------------------------------------------------------------------------------------*/\n\ntype OmitByPath<T extends object, K extends string[]> = Pick<T, Exclude<keyof T, K[number]>>;\n\nconst disableAttributesLocalisation = (attributes: Schema.ContentType['attributes']) =>\n Object.keys(attributes).reduce<\n Record<string, OmitByPath<Schema.ContentType['attributes'][string], ['pluginOptions', 'i18n']>>\n >((acc, current) => {\n acc[current] = omit(attributes[current], 'pluginOptions.i18n');\n\n return acc;\n }, {});\n\nexport { mutateCTBContentTypeSchema };\n"],"names":["mutateCTBContentTypeSchema","nextSchema","prevSchema","doesPluginOptionsHaveI18nLocalized","pluginOptions","isNextSchemaLocalized","i18n","localized","isPrevSchemaLocalized","schema","attributes","addLocalisationToFields","omit","disableAttributesLocalisation","Object","keys","reduce","acc","current","currentAttribute","LOCALIZED_FIELDS","includes","type"],"mappings":";;;AAMA;;qGAIA,MAAMA,0BAA6B,GAAA,CACjCC,UACAC,EAAAA,UAAAA,GAAAA;;AAOA,IAAA,IAAI,CAACC,kCAAAA,CAAmCF,UAAWG,CAAAA,aAAa,CAAG,EAAA;QACjE,OAAOH,UAAAA;AACT;AAEA,IAAA,MAAMI,wBAAwBJ,UAAWG,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;IACrE,MAAMC,qBAAAA,GAAwBL,mCAC5BD,UAAYO,EAAAA,MAAAA,EAAQL,iBAElBF,UAAYO,EAAAA,MAAAA,EAAQL,aAAcE,CAAAA,IAAAA,CAAKC,SACvC,GAAA,KAAA;;;AAIJ,IAAA,IAAIF,yBAAyBG,qBAAuB,EAAA;QAClD,OAAOP,UAAAA;AACT;AAEA,IAAA,IAAII,qBAAuB,EAAA;QACzB,MAAMK,UAAAA,GAAaC,uBAAwBV,CAAAA,UAAAA,CAAWS,UAAU,CAAA;QAEhE,OAAO;AAAE,YAAA,GAAGT,UAAU;AAAES,YAA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AAQ,CAAA,GAAGN,KAAKF,UAAU,CAACQ,QAAQ,EAAE,oBAAA,CAAA;QAEzC,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;;;;"}
1
+ {"version":3,"file":"schemas.mjs","sources":["../../../admin/src/utils/schemas.ts"],"sourcesContent":["import omit from 'lodash/omit';\n\nimport { LOCALIZED_FIELDS, doesPluginOptionsHaveI18nLocalized } from './fields';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * mutateCTBContentTypeSchema\n * -----------------------------------------------------------------------------------------------*/\n\n// TODO: refactor for CTB refactors\nconst mutateCTBContentTypeSchema = (\n nextSchema: {\n pluginOptions: Schema.ContentType['pluginOptions'];\n attributes: Schema.Attribute.AnyAttribute[];\n uid?: string;\n },\n prevSchema?: {\n pluginOptions: Schema.ContentType['pluginOptions'];\n attributes: Schema.Attribute.AnyAttribute[];\n uid?: string;\n }\n) => {\n if (!prevSchema) {\n return nextSchema;\n }\n\n // Don't perform mutations components\n if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {\n return nextSchema;\n }\n\n const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;\n const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(prevSchema?.pluginOptions)\n ? prevSchema?.pluginOptions.i18n.localized\n : false;\n\n // No need to perform modification on the schema, if the i18n feature was not changed\n // at the ct level\n if (isNextSchemaLocalized && isPrevSchemaLocalized) {\n return nextSchema;\n }\n\n if (isNextSchemaLocalized) {\n const attributes = addLocalisationToFields(nextSchema.attributes);\n\n return {\n ...nextSchema,\n attributes,\n };\n }\n\n // Remove the i18n object from the pluginOptions\n if (!isNextSchemaLocalized) {\n const pluginOptions = omit(nextSchema.pluginOptions, 'i18n');\n const attributes = disableAttributesLocalisation(nextSchema.attributes);\n\n return {\n ...nextSchema,\n pluginOptions,\n attributes,\n };\n }\n\n return nextSchema;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * addLocalisationToFields\n * -----------------------------------------------------------------------------------------------*/\n\nconst addLocalisationToFields = (attributes: Schema.Attribute.AnyAttribute[]) => {\n return attributes.map((currentAttribute) => {\n if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {\n const i18n = { localized: true };\n\n const pluginOptions = currentAttribute.pluginOptions\n ? { ...currentAttribute.pluginOptions, i18n }\n : { i18n };\n\n return { ...currentAttribute, pluginOptions };\n }\n\n return currentAttribute;\n });\n};\n\n/* -------------------------------------------------------------------------------------------------\n * disableAttributesLocalisation\n * -----------------------------------------------------------------------------------------------*/\n\nconst disableAttributesLocalisation = (attributes: Schema.Attribute.AnyAttribute[]) => {\n return attributes.map((currentAttribute) => {\n return omit(currentAttribute, 'pluginOptions.i18n');\n });\n};\n\nexport { mutateCTBContentTypeSchema };\n"],"names":["mutateCTBContentTypeSchema","nextSchema","prevSchema","doesPluginOptionsHaveI18nLocalized","pluginOptions","isNextSchemaLocalized","i18n","localized","isPrevSchemaLocalized","attributes","addLocalisationToFields","omit","disableAttributesLocalisation","map","currentAttribute","LOCALIZED_FIELDS","includes","type"],"mappings":";;;AAMA;;AAEkG;AAG5FA,MAAAA,0BAAAA,GAA6B,CACjCC,UAKAC,EAAAA,UAAAA,GAAAA;AAMA,IAAA,IAAI,CAACA,UAAY,EAAA;QACf,OAAOD,UAAAA;AACT;;AAGA,IAAA,IAAI,CAACE,kCAAAA,CAAmCF,UAAWG,CAAAA,aAAa,CAAG,EAAA;QACjE,OAAOH,UAAAA;AACT;AAEA,IAAA,MAAMI,wBAAwBJ,UAAWG,CAAAA,aAAa,CAACE,IAAI,CAACC,SAAS;AACrE,IAAA,MAAMC,wBAAwBL,kCAAmCD,CAAAA,UAAAA,EAAYE,iBACzEF,UAAYE,EAAAA,aAAAA,CAAcE,KAAKC,SAC/B,GAAA,KAAA;;;AAIJ,IAAA,IAAIF,yBAAyBG,qBAAuB,EAAA;QAClD,OAAOP,UAAAA;AACT;AAEA,IAAA,IAAII,qBAAuB,EAAA;QACzB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 var fp = require('lodash/fp');
3
4
  var index = require('./utils/index.js');
4
5
 
5
6
  const registerModelsHooks = ()=>{
@@ -28,8 +29,15 @@ const registerModelsHooks = ()=>{
28
29
  return next();
29
30
  }
30
31
  // Build a populate array for all non localized fields within the schema
31
- const { getNestedPopulateOfNonLocalizedAttributes } = index.getService('content-types');
32
+ const { getNestedPopulateOfNonLocalizedAttributes, copyNonLocalizedAttributes } = index.getService('content-types');
32
33
  const attributesToPopulate = getNestedPopulateOfNonLocalizedAttributes(schema.uid);
34
+ // Get original data before the update to compare what actually changed
35
+ const originalData = 'documentId' in context.params && context.params.documentId ? await strapi.db.query(schema.uid).findOne({
36
+ where: {
37
+ documentId: context.params.documentId
38
+ },
39
+ populate: attributesToPopulate
40
+ }) : null;
33
41
  // Get the result of the document service action
34
42
  const result = await next();
35
43
  // We may not have received a result with everything populated that we need
@@ -44,13 +52,19 @@ const registerModelsHooks = ()=>{
44
52
  } else {
45
53
  return result;
46
54
  }
47
- if (attributesToPopulate.length > 0) {
48
- const populatedResult = await strapi.db.query(schema.uid).findOne({
49
- where: {
50
- id: resultID
51
- },
52
- populate: attributesToPopulate
53
- });
55
+ const populatedResult = await strapi.db.query(schema.uid).findOne({
56
+ where: {
57
+ id: resultID
58
+ },
59
+ populate: attributesToPopulate
60
+ });
61
+ const originalFields = copyNonLocalizedAttributes(schema, originalData);
62
+ const currentFields = copyNonLocalizedAttributes(schema, populatedResult);
63
+ // Only sync if there are actual changes to non-localized fields
64
+ const shouldSync = !originalData || Object.keys(currentFields).some((key)=>{
65
+ return !fp.isEqual(currentFields[key], originalFields[key]);
66
+ });
67
+ if (shouldSync) {
54
68
  await index.getService('localizations').syncNonLocalizedAttributes(populatedResult, schema);
55
69
  }
56
70
  return result;
@@ -72,6 +86,8 @@ var bootstrap = (async ()=>{
72
86
  engine.registerI18nPermissionsHandlers();
73
87
  // Hooks & Models
74
88
  registerModelsHooks();
89
+ // AI Localizations
90
+ index.getService('ai-localizations').setupMiddleware();
75
91
  sendDidInitializeEvent();
76
92
  });
77
93
 
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\nimport { getService } from './utils';\n\nconst registerModelsHooks = () => {\n strapi.db.lifecycles.subscribe({\n models: ['plugin::i18n.locale'],\n\n async afterCreate() {\n await getService('permissions').actions.syncSuperAdminPermissionsWithLocales();\n },\n\n async afterDelete() {\n await getService('permissions').actions.syncSuperAdminPermissionsWithLocales();\n },\n });\n\n strapi.documents.use(async (context, next) => {\n const schema: Schema.ContentType = context.contentType;\n\n if (!['create', 'update', 'discardDraft', 'publish'].includes(context.action)) {\n return next();\n }\n\n if (!getService('content-types').isLocalizedContentType(schema)) {\n return next();\n }\n\n // Build a populate array for all non localized fields within the schema\n const { getNestedPopulateOfNonLocalizedAttributes } = getService('content-types');\n\n const attributesToPopulate = getNestedPopulateOfNonLocalizedAttributes(schema.uid);\n\n // Get the result of the document service action\n const result = (await next()) as any;\n\n // We may not have received a result with everything populated that we need\n // Use the id and populate built from non localized fields to get the full\n // result\n let resultID;\n // TODO: fix bug where an empty array can be returned\n if (Array.isArray(result?.entries) && result.entries[0]?.id) {\n resultID = result.entries[0].id;\n } else if (result?.id) {\n resultID = result.id;\n } else {\n return result;\n }\n\n if (attributesToPopulate.length > 0) {\n const populatedResult = await strapi.db\n .query(schema.uid)\n .findOne({ where: { id: resultID }, populate: attributesToPopulate });\n\n await getService('localizations').syncNonLocalizedAttributes(populatedResult, schema);\n }\n\n return result;\n });\n};\n\nexport default async () => {\n const { sendDidInitializeEvent } = getService('metrics');\n const { initDefaultLocale } = getService('locales');\n const { sectionsBuilder, actions, engine } = getService('permissions');\n\n // Data\n await initDefaultLocale();\n\n // Sections Builder\n sectionsBuilder.registerLocalesPropertyHandler();\n\n // Actions\n await actions.registerI18nActions();\n actions.registerI18nActionsHooks();\n actions.updateActionsProperties();\n\n // Engine/Permissions\n engine.registerI18nPermissionsHandlers();\n\n // Hooks & Models\n registerModelsHooks();\n\n sendDidInitializeEvent();\n};\n"],"names":["registerModelsHooks","strapi","db","lifecycles","subscribe","models","afterCreate","getService","actions","syncSuperAdminPermissionsWithLocales","afterDelete","documents","use","context","next","schema","contentType","includes","action","isLocalizedContentType","getNestedPopulateOfNonLocalizedAttributes","attributesToPopulate","uid","result","resultID","Array","isArray","entries","id","length","populatedResult","query","findOne","where","populate","syncNonLocalizedAttributes","sendDidInitializeEvent","initDefaultLocale","sectionsBuilder","engine","registerLocalesPropertyHandler","registerI18nActions","registerI18nActionsHooks","updateActionsProperties","registerI18nPermissionsHandlers"],"mappings":";;;;AAGA,MAAMA,mBAAsB,GAAA,IAAA;AAC1BC,IAAAA,MAAAA,CAAOC,EAAE,CAACC,UAAU,CAACC,SAAS,CAAC;QAC7BC,MAAQ,EAAA;AAAC,YAAA;AAAsB,SAAA;QAE/B,MAAMC,WAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMC,gBAAW,CAAA,aAAA,CAAA,CAAeC,OAAO,CAACC,oCAAoC,EAAA;AAC9E,SAAA;QAEA,MAAMC,WAAAA,CAAAA,GAAAA;AACJ,YAAA,MAAMH,gBAAW,CAAA,aAAA,CAAA,CAAeC,OAAO,CAACC,oCAAoC,EAAA;AAC9E;AACF,KAAA,CAAA;AAEAR,IAAAA,MAAAA,CAAOU,SAAS,CAACC,GAAG,CAAC,OAAOC,OAASC,EAAAA,IAAAA,GAAAA;QACnC,MAAMC,MAAAA,GAA6BF,QAAQG,WAAW;AAEtD,QAAA,IAAI,CAAC;AAAC,YAAA,QAAA;AAAU,YAAA,QAAA;AAAU,YAAA,cAAA;AAAgB,YAAA;AAAU,SAAA,CAACC,QAAQ,CAACJ,OAAQK,CAAAA,MAAM,CAAG,EAAA;YAC7E,OAAOJ,IAAAA,EAAAA;AACT;AAEA,QAAA,IAAI,CAACP,gBAAAA,CAAW,eAAiBY,CAAAA,CAAAA,sBAAsB,CAACJ,MAAS,CAAA,EAAA;YAC/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AE+B,MAAM,EAAE,GAAGhC,gBAAW,CAAA,aAAA,CAAA;;IAGxD,MAAM8B,iBAAAA,EAAAA;;AAGNC,IAAAA,eAAAA,CAAgBE,8BAA8B,EAAA;;AAG9C,IAAA,MAAMhC,QAAQiC,mBAAmB,EAAA;AACjCjC,IAAAA,OAAAA,CAAQkC,wBAAwB,EAAA;AAChClC,IAAAA,OAAAA,CAAQmC,uBAAuB,EAAA;;AAG/BJ,IAAAA,MAAAA,CAAOK,+BAA+B,EAAA;;AAGtC5C,IAAAA,mBAAAA,EAAAA;AAEAoC,IAAAA,sBAAAA,EAAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import type { Schema } from '@strapi/types';\nimport { isEqual } from 'lodash/fp';\nimport { getService } from './utils';\n\nconst registerModelsHooks = () => {\n strapi.db.lifecycles.subscribe({\n models: ['plugin::i18n.locale'],\n\n async afterCreate() {\n await getService('permissions').actions.syncSuperAdminPermissionsWithLocales();\n },\n\n async afterDelete() {\n await getService('permissions').actions.syncSuperAdminPermissionsWithLocales();\n },\n });\n\n strapi.documents.use(async (context, next) => {\n const schema: Schema.ContentType = context.contentType;\n\n if (!['create', 'update', 'discardDraft', 'publish'].includes(context.action)) {\n return next();\n }\n\n if (!getService('content-types').isLocalizedContentType(schema)) {\n return next();\n }\n\n // Build a populate array for all non localized fields within the schema\n const { getNestedPopulateOfNonLocalizedAttributes, copyNonLocalizedAttributes } =\n getService('content-types');\n const attributesToPopulate = getNestedPopulateOfNonLocalizedAttributes(schema.uid);\n\n // Get original data before the update to compare what actually changed\n const originalData =\n 'documentId' in context.params && context.params.documentId\n ? await strapi.db.query(schema.uid).findOne({\n where: { documentId: context.params.documentId },\n populate: attributesToPopulate,\n })\n : null;\n\n // Get the result of the document service action\n const result = (await next()) as any;\n\n // We may not have received a result with everything populated that we need\n // Use the id and populate built from non localized fields to get the full\n // result\n let resultID;\n // TODO: fix bug where an empty array can be returned\n if (Array.isArray(result?.entries) && result.entries[0]?.id) {\n resultID = result.entries[0].id;\n } else if (result?.id) {\n resultID = result.id;\n } else {\n return result;\n }\n\n const populatedResult = await strapi.db.query(schema.uid).findOne({\n where: { id: resultID },\n populate: attributesToPopulate,\n });\n\n const originalFields = copyNonLocalizedAttributes(schema, originalData);\n const currentFields = copyNonLocalizedAttributes(schema, populatedResult);\n\n // Only sync if there are actual changes to non-localized fields\n const shouldSync =\n !originalData ||\n Object.keys(currentFields).some((key) => {\n return !isEqual(currentFields[key], originalFields[key]);\n });\n\n if (shouldSync) {\n await getService('localizations').syncNonLocalizedAttributes(populatedResult, schema);\n }\n\n return result;\n });\n};\n\nexport default async () => {\n const { sendDidInitializeEvent } = getService('metrics');\n const { initDefaultLocale } = getService('locales');\n const { sectionsBuilder, actions, engine } = getService('permissions');\n\n // Data\n await initDefaultLocale();\n\n // Sections Builder\n sectionsBuilder.registerLocalesPropertyHandler();\n\n // Actions\n await actions.registerI18nActions();\n actions.registerI18nActionsHooks();\n actions.updateActionsProperties();\n\n // Engine/Permissions\n engine.registerI18nPermissionsHandlers();\n\n // Hooks & Models\n registerModelsHooks();\n\n // AI Localizations\n getService('ai-localizations').setupMiddleware();\n\n sendDidInitializeEvent();\n};\n"],"names":["registerModelsHooks","strapi","db","lifecycles","subscribe","models","afterCreate","getService","actions","syncSuperAdminPermissionsWithLocales","afterDelete","documents","use","context","next","schema","contentType","includes","action","isLocalizedContentType","getNestedPopulateOfNonLocalizedAttributes","copyNonLocalizedAttributes","attributesToPopulate","uid","originalData","params","documentId","query","findOne","where","populate","result","resultID","Array","isArray","entries","id","populatedResult","originalFields","currentFields","shouldSync","Object","keys","some","key","isEqual","syncNonLocalizedAttributes","sendDidInitializeEvent","initDefaultLocale","sectionsBuilder","engine","registerLocalesPropertyHandler","registerI18nActions","registerI18nActionsHooks","updateActionsProperties","registerI18nPermissionsHandlers","setupMiddleware"],"mappings":";;;;;AAIA,MAAMA,mBAAsB,GAAA,IAAA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OgB,MAAAA;AACT,KAAA,CAAA;AACF,CAAA;AAEA,gBAAe,CAAA,UAAA;AACb,IAAA,MAAM,EAAEgB,sBAAsB,EAAE,GAAGxC,gBAAW,CAAA,SAAA,CAAA;AAC9C,IAAA,MAAM,EAAEyC,iBAAiB,EAAE,GAAGzC,gBAAW,CAAA,SAAA,CAAA;IACzC,MAAM,EAAE0C,eAAe,EAAEzC,OAAO,EAAE0C,MAAM,EAAE,GAAG3C,gBAAW,CAAA,aAAA,CAAA;;IAGxD,MAAMyC,iBAAAA,EAAAA;;AAGNC,IAAAA,eAAAA,CAAgBE,8BAA8B,EAAA;;AAG9C,IAAA,MAAM3C,QAAQ4C,mBAAmB,EAAA;AACjC5C,IAAAA,OAAAA,CAAQ6C,wBAAwB,EAAA;AAChC7C,IAAAA,OAAAA,CAAQ8C,uBAAuB,EAAA;;AAG/BJ,IAAAA,MAAAA,CAAOK,+BAA+B,EAAA;;AAGtCvD,IAAAA,mBAAAA,EAAAA;;AAGAO,IAAAA,gBAAAA,CAAW,oBAAoBiD,eAAe,EAAA;AAE9CT,IAAAA,sBAAAA,EAAAA;AACF,CAAA;;;;"}
@@ -1,3 +1,4 @@
1
+ import { isEqual } from 'lodash/fp';
1
2
  import { getService } from './utils/index.mjs';
2
3
 
3
4
  const registerModelsHooks = ()=>{
@@ -26,8 +27,15 @@ const registerModelsHooks = ()=>{
26
27
  return next();
27
28
  }
28
29
  // Build a populate array for all non localized fields within the schema
29
- const { getNestedPopulateOfNonLocalizedAttributes } = getService('content-types');
30
+ const { getNestedPopulateOfNonLocalizedAttributes, copyNonLocalizedAttributes } = getService('content-types');
30
31
  const attributesToPopulate = getNestedPopulateOfNonLocalizedAttributes(schema.uid);
32
+ // Get original data before the update to compare what actually changed
33
+ const originalData = 'documentId' in context.params && context.params.documentId ? await strapi.db.query(schema.uid).findOne({
34
+ where: {
35
+ documentId: context.params.documentId
36
+ },
37
+ populate: attributesToPopulate
38
+ }) : null;
31
39
  // Get the result of the document service action
32
40
  const result = await next();
33
41
  // We may not have received a result with everything populated that we need
@@ -42,13 +50,19 @@ const registerModelsHooks = ()=>{
42
50
  } else {
43
51
  return result;
44
52
  }
45
- if (attributesToPopulate.length > 0) {
46
- const populatedResult = await strapi.db.query(schema.uid).findOne({
47
- where: {
48
- id: resultID
49
- },
50
- populate: attributesToPopulate
51
- });
53
+ const populatedResult = await strapi.db.query(schema.uid).findOne({
54
+ where: {
55
+ id: resultID
56
+ },
57
+ populate: attributesToPopulate
58
+ });
59
+ const originalFields = copyNonLocalizedAttributes(schema, originalData);
60
+ const currentFields = copyNonLocalizedAttributes(schema, populatedResult);
61
+ // Only sync if there are actual changes to non-localized fields
62
+ const shouldSync = !originalData || Object.keys(currentFields).some((key)=>{
63
+ return !isEqual(currentFields[key], originalFields[key]);
64
+ });
65
+ if (shouldSync) {
52
66
  await getService('localizations').syncNonLocalizedAttributes(populatedResult, schema);
53
67
  }
54
68
  return result;
@@ -70,6 +84,8 @@ var bootstrap = (async ()=>{
70
84
  engine.registerI18nPermissionsHandlers();
71
85
  // Hooks & Models
72
86
  registerModelsHooks();
87
+ // AI Localizations
88
+ getService('ai-localizations').setupMiddleware();
73
89
  sendDidInitializeEvent();
74
90
  });
75
91