@strapi/i18n 0.0.0-next.82fd5bc51d11a2da848fc7fd1cc573f8ea0a6535 → 0.0.0-next.83367b80833204c0744701aef452a8d8d2ce25b6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/admin/components/CMHeaderActions.js +7 -1
  2. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  3. package/dist/admin/components/CMHeaderActions.mjs +7 -1
  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/LocalePicker.js +18 -11
  14. package/dist/admin/components/LocalePicker.js.map +1 -1
  15. package/dist/admin/components/LocalePicker.mjs +19 -12
  16. package/dist/admin/components/LocalePicker.mjs.map +1 -1
  17. package/dist/admin/contentManagerHooks/editView.js +6 -3
  18. package/dist/admin/contentManagerHooks/editView.js.map +1 -1
  19. package/dist/admin/contentManagerHooks/editView.mjs +7 -4
  20. package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
  21. package/dist/admin/index.js +0 -1
  22. package/dist/admin/index.js.map +1 -1
  23. package/dist/admin/index.mjs +0 -1
  24. package/dist/admin/index.mjs.map +1 -1
  25. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +34 -24
  26. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -1
  27. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs +34 -24
  28. package/dist/admin/middlewares/extendCTBAttributeInitialData.mjs.map +1 -1
  29. package/dist/admin/pages/SettingsPage.js +121 -46
  30. package/dist/admin/pages/SettingsPage.js.map +1 -1
  31. package/dist/admin/pages/SettingsPage.mjs +124 -30
  32. package/dist/admin/pages/SettingsPage.mjs.map +1 -1
  33. package/dist/admin/services/api.js +3 -1
  34. package/dist/admin/services/api.js.map +1 -1
  35. package/dist/admin/services/api.mjs +3 -1
  36. package/dist/admin/services/api.mjs.map +1 -1
  37. package/dist/admin/services/locales.js +4 -2
  38. package/dist/admin/services/locales.js.map +1 -1
  39. package/dist/admin/services/locales.mjs +4 -2
  40. package/dist/admin/services/locales.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/services/api.d.ts +1 -1
  46. package/dist/admin/src/services/locales.d.ts +1 -1
  47. package/dist/admin/src/services/relations.d.ts +1 -1
  48. package/dist/admin/src/services/settings.d.ts +5 -0
  49. package/dist/admin/src/utils/schemas.d.ts +642 -16
  50. package/dist/admin/translations/en.json.js +2 -0
  51. package/dist/admin/translations/en.json.js.map +1 -1
  52. package/dist/admin/translations/en.json.mjs +2 -0
  53. package/dist/admin/translations/en.json.mjs.map +1 -1
  54. package/dist/admin/utils/fields.js +6 -1
  55. package/dist/admin/utils/fields.js.map +1 -1
  56. package/dist/admin/utils/fields.mjs +6 -1
  57. package/dist/admin/utils/fields.mjs.map +1 -1
  58. package/dist/admin/utils/schemas.js +19 -13
  59. package/dist/admin/utils/schemas.js.map +1 -1
  60. package/dist/admin/utils/schemas.mjs +19 -13
  61. package/dist/admin/utils/schemas.mjs.map +1 -1
  62. package/dist/server/controllers/index.js +3 -1
  63. package/dist/server/controllers/index.js.map +1 -1
  64. package/dist/server/controllers/index.mjs +3 -1
  65. package/dist/server/controllers/index.mjs.map +1 -1
  66. package/dist/server/controllers/settings.js +24 -0
  67. package/dist/server/controllers/settings.js.map +1 -0
  68. package/dist/server/controllers/settings.mjs +22 -0
  69. package/dist/server/controllers/settings.mjs.map +1 -0
  70. package/dist/server/routes/admin.js +20 -0
  71. package/dist/server/routes/admin.js.map +1 -1
  72. package/dist/server/routes/admin.mjs +20 -0
  73. package/dist/server/routes/admin.mjs.map +1 -1
  74. package/dist/server/routes/content-api.js +11 -7
  75. package/dist/server/routes/content-api.js.map +1 -1
  76. package/dist/server/routes/content-api.mjs +11 -7
  77. package/dist/server/routes/content-api.mjs.map +1 -1
  78. package/dist/server/routes/index.mjs +2 -2
  79. package/dist/server/routes/validation/locale.js +57 -0
  80. package/dist/server/routes/validation/locale.js.map +1 -0
  81. package/dist/server/routes/validation/locale.mjs +36 -0
  82. package/dist/server/routes/validation/locale.mjs.map +1 -0
  83. package/dist/server/services/ai-localizations.js +28 -0
  84. package/dist/server/services/ai-localizations.js.map +1 -0
  85. package/dist/server/services/ai-localizations.mjs +26 -0
  86. package/dist/server/services/ai-localizations.mjs.map +1 -0
  87. package/dist/server/services/index.js +5 -1
  88. package/dist/server/services/index.js.map +1 -1
  89. package/dist/server/services/index.mjs +5 -1
  90. package/dist/server/services/index.mjs.map +1 -1
  91. package/dist/server/services/settings.js +25 -0
  92. package/dist/server/services/settings.js.map +1 -0
  93. package/dist/server/services/settings.mjs +23 -0
  94. package/dist/server/services/settings.mjs.map +1 -0
  95. package/dist/server/src/controllers/index.d.ts +4 -0
  96. package/dist/server/src/controllers/index.d.ts.map +1 -1
  97. package/dist/server/src/controllers/settings.d.ts +7 -0
  98. package/dist/server/src/controllers/settings.d.ts.map +1 -0
  99. package/dist/server/src/index.d.ts +22 -7
  100. package/dist/server/src/index.d.ts.map +1 -1
  101. package/dist/server/src/routes/admin.d.ts.map +1 -1
  102. package/dist/server/src/routes/content-api.d.ts +5 -8
  103. package/dist/server/src/routes/content-api.d.ts.map +1 -1
  104. package/dist/server/src/routes/index.d.ts +3 -7
  105. package/dist/server/src/routes/index.d.ts.map +1 -1
  106. package/dist/server/src/routes/validation/index.d.ts +2 -0
  107. package/dist/server/src/routes/validation/index.d.ts.map +1 -0
  108. package/dist/server/src/routes/validation/locale.d.ts +41 -0
  109. package/dist/server/src/routes/validation/locale.d.ts.map +1 -0
  110. package/dist/server/src/services/ai-localizations.d.ts +8 -0
  111. package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
  112. package/dist/server/src/services/index.d.ts +15 -0
  113. package/dist/server/src/services/index.d.ts.map +1 -1
  114. package/dist/server/src/services/settings.d.ts +13 -0
  115. package/dist/server/src/services/settings.d.ts.map +1 -0
  116. package/dist/server/src/utils/index.d.ts +3 -1
  117. package/dist/server/src/utils/index.d.ts.map +1 -1
  118. package/dist/server/src/validation/settings.d.ts +12 -0
  119. package/dist/server/src/validation/settings.d.ts.map +1 -0
  120. package/dist/server/utils/index.js.map +1 -1
  121. package/dist/server/utils/index.mjs.map +1 -1
  122. package/dist/server/validation/settings.js +11 -0
  123. package/dist/server/validation/settings.js.map +1 -0
  124. package/dist/server/validation/settings.mjs +9 -0
  125. package/dist/server/validation/settings.mjs.map +1 -0
  126. package/dist/shared/contracts/settings.d.ts +40 -0
  127. package/package.json +11 -9
@@ -36,6 +36,8 @@ var en = {
36
36
  "Settings.list.description": "Configure the settings for the Internationalization plugin",
37
37
  "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
38
  "Settings.list.empty.title": "There are no locales.",
39
+ "Settings.aiLocalizations.label": "AI Translations",
40
+ "Settings.aiLocalizations.description": "Everytime you save in the Content Manager, our AI will use your default locale to translate all other locales automatically.",
39
41
  "Settings.locales.default": "Default",
40
42
  "Settings.locales.list.sort.default": "Sort by the default locale",
41
43
  "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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -34,6 +34,8 @@ var en = {
34
34
  "Settings.list.description": "Configure the settings for the Internationalization plugin",
35
35
  "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
36
  "Settings.list.empty.title": "There are no locales.",
37
+ "Settings.aiLocalizations.label": "AI Translations",
38
+ "Settings.aiLocalizations.description": "Everytime you save in the Content Manager, our AI will use your default locale to translate all other locales automatically.",
37
39
  "Settings.locales.default": "Default",
38
40
  "Settings.locales.list.sort.default": "Sort by the default locale",
39
41
  "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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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;;;;"}
@@ -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","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AAQ,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,YAAAA;AAAW,SAAA;AACrC;;AAGA,IAAA,IAAI,CAACL,qBAAuB,EAAA;AAC1B,QAAA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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,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,gBAAiBC,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,11 +3,13 @@
3
3
  var locales = require('./locales.js');
4
4
  var contentTypes = require('./content-types.js');
5
5
  var isoLocales = require('./iso-locales.js');
6
+ var settings = require('./settings.js');
6
7
 
7
8
  var controllers = {
8
9
  locales,
9
10
  'iso-locales': isoLocales,
10
- 'content-types': contentTypes
11
+ 'content-types': contentTypes,
12
+ settings
11
13
  };
12
14
 
13
15
  module.exports = controllers;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import locales from './locales';\nimport contentTypes from './content-types';\nimport isoLocales from './iso-locales';\n\nexport default {\n locales,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n};\n"],"names":["locales","isoLocales","contentTypes"],"mappings":";;;;;;AAIA,kBAAe;AACbA,IAAAA,OAAAA;IACA,aAAeC,EAAAA,UAAAA;IACf,eAAiBC,EAAAA;AACnB,CAAE;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import locales from './locales';\nimport contentTypes from './content-types';\nimport isoLocales from './iso-locales';\nimport settings from './settings';\n\nexport default {\n locales,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n settings,\n};\n"],"names":["locales","isoLocales","contentTypes","settings"],"mappings":";;;;;;;AAKA,kBAAe;AACbA,IAAAA,OAAAA;IACA,aAAeC,EAAAA,UAAAA;IACf,eAAiBC,EAAAA,YAAAA;AACjBC,IAAAA;AACF,CAAE;;;;"}
@@ -1,11 +1,13 @@
1
1
  import controller from './locales.mjs';
2
2
  import controller$2 from './content-types.mjs';
3
3
  import controller$1 from './iso-locales.mjs';
4
+ import settings from './settings.mjs';
4
5
 
5
6
  var controllers = {
6
7
  locales: controller,
7
8
  'iso-locales': controller$1,
8
- 'content-types': controller$2
9
+ 'content-types': controller$2,
10
+ settings
9
11
  };
10
12
 
11
13
  export { controllers as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import locales from './locales';\nimport contentTypes from './content-types';\nimport isoLocales from './iso-locales';\n\nexport default {\n locales,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n};\n"],"names":["locales","isoLocales","contentTypes"],"mappings":";;;;AAIA,kBAAe;AACbA,aAAAA,UAAAA;IACA,aAAeC,EAAAA,YAAAA;IACf,eAAiBC,EAAAA;AACnB,CAAE;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../server/src/controllers/index.ts"],"sourcesContent":["import locales from './locales';\nimport contentTypes from './content-types';\nimport isoLocales from './iso-locales';\nimport settings from './settings';\n\nexport default {\n locales,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n settings,\n};\n"],"names":["locales","isoLocales","contentTypes","settings"],"mappings":";;;;;AAKA,kBAAe;AACbA,aAAAA,UAAAA;IACA,aAAeC,EAAAA,YAAAA;IACf,eAAiBC,EAAAA,YAAAA;AACjBC,IAAAA;AACF,CAAE;;;;"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var index = require('../utils/index.js');
4
+ var settings$1 = require('../validation/settings.js');
5
+
6
+ var settings = {
7
+ async updateSettings (ctx) {
8
+ const { request: { body } } = ctx;
9
+ const data = await settings$1(body);
10
+ await index.getService('settings').setSettings(data);
11
+ ctx.body = {
12
+ data
13
+ };
14
+ },
15
+ async getSettings (ctx) {
16
+ const data = await index.getService('settings').getSettings();
17
+ ctx.body = {
18
+ data
19
+ };
20
+ }
21
+ };
22
+
23
+ module.exports = settings;
24
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sources":["../../../server/src/controllers/settings.ts"],"sourcesContent":["import type { Context } from 'koa';\n\nimport { getService } from '../utils';\nimport validateSettings from '../validation/settings';\n\nexport default {\n async updateSettings(ctx: Context) {\n const {\n request: { body },\n } = ctx;\n\n const data = await validateSettings(body);\n\n await getService('settings').setSettings(data);\n\n ctx.body = { data };\n },\n\n async getSettings(ctx: Context) {\n const data = await getService('settings').getSettings();\n\n ctx.body = { data };\n },\n};\n"],"names":["updateSettings","ctx","request","body","data","validateSettings","getService","setSettings","getSettings"],"mappings":";;;;;AAKA,eAAe;AACb,IAAA,MAAMA,gBAAeC,GAAY,EAAA;AAC/B,QAAA,MAAM,EACJC,OAAS,EAAA,EAAEC,IAAI,EAAE,EAClB,GAAGF,GAAAA;QAEJ,MAAMG,IAAAA,GAAO,MAAMC,UAAiBF,CAAAA,IAAAA,CAAAA;QAEpC,MAAMG,gBAAAA,CAAW,UAAYC,CAAAA,CAAAA,WAAW,CAACH,IAAAA,CAAAA;AAEzCH,QAAAA,GAAAA,CAAIE,IAAI,GAAG;AAAEC,YAAAA;AAAK,SAAA;AACpB,KAAA;AAEA,IAAA,MAAMI,aAAYP,GAAY,EAAA;AAC5B,QAAA,MAAMG,IAAO,GAAA,MAAME,gBAAW,CAAA,UAAA,CAAA,CAAYE,WAAW,EAAA;AAErDP,QAAAA,GAAAA,CAAIE,IAAI,GAAG;AAAEC,YAAAA;AAAK,SAAA;AACpB;AACF,CAAE;;;;"}
@@ -0,0 +1,22 @@
1
+ import { getService } from '../utils/index.mjs';
2
+ import validateSettings from '../validation/settings.mjs';
3
+
4
+ var settings = {
5
+ async updateSettings (ctx) {
6
+ const { request: { body } } = ctx;
7
+ const data = await validateSettings(body);
8
+ await getService('settings').setSettings(data);
9
+ ctx.body = {
10
+ data
11
+ };
12
+ },
13
+ async getSettings (ctx) {
14
+ const data = await getService('settings').getSettings();
15
+ ctx.body = {
16
+ data
17
+ };
18
+ }
19
+ };
20
+
21
+ export { settings as default };
22
+ //# sourceMappingURL=settings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.mjs","sources":["../../../server/src/controllers/settings.ts"],"sourcesContent":["import type { Context } from 'koa';\n\nimport { getService } from '../utils';\nimport validateSettings from '../validation/settings';\n\nexport default {\n async updateSettings(ctx: Context) {\n const {\n request: { body },\n } = ctx;\n\n const data = await validateSettings(body);\n\n await getService('settings').setSettings(data);\n\n ctx.body = { data };\n },\n\n async getSettings(ctx: Context) {\n const data = await getService('settings').getSettings();\n\n ctx.body = { data };\n },\n};\n"],"names":["updateSettings","ctx","request","body","data","validateSettings","getService","setSettings","getSettings"],"mappings":";;;AAKA,eAAe;AACb,IAAA,MAAMA,gBAAeC,GAAY,EAAA;AAC/B,QAAA,MAAM,EACJC,OAAS,EAAA,EAAEC,IAAI,EAAE,EAClB,GAAGF,GAAAA;QAEJ,MAAMG,IAAAA,GAAO,MAAMC,gBAAiBF,CAAAA,IAAAA,CAAAA;QAEpC,MAAMG,UAAAA,CAAW,UAAYC,CAAAA,CAAAA,WAAW,CAACH,IAAAA,CAAAA;AAEzCH,QAAAA,GAAAA,CAAIE,IAAI,GAAG;AAAEC,YAAAA;AAAK,SAAA;AACpB,KAAA;AAEA,IAAA,MAAMI,aAAYP,GAAY,EAAA;AAC5B,QAAA,MAAMG,IAAO,GAAA,MAAME,UAAW,CAAA,UAAA,CAAA,CAAYE,WAAW,EAAA;AAErDP,QAAAA,GAAAA,CAAIE,IAAI,GAAG;AAAEC,YAAAA;AAAK,SAAA;AACpB;AACF,CAAE;;;;"}
@@ -94,6 +94,26 @@ var admin = {
94
94
  'admin::isAuthenticatedAdmin'
95
95
  ]
96
96
  }
97
+ },
98
+ {
99
+ method: 'GET',
100
+ path: '/settings',
101
+ handler: 'settings.getSettings',
102
+ config: {
103
+ policies: [
104
+ 'admin::isAuthenticatedAdmin'
105
+ ]
106
+ }
107
+ },
108
+ {
109
+ method: 'PUT',
110
+ path: '/settings',
111
+ handler: 'settings.updateSettings',
112
+ config: {
113
+ policies: [
114
+ 'admin::isAuthenticatedAdmin'
115
+ ]
116
+ }
97
117
  }
98
118
  ]
99
119
  };
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sources":["../../../server/src/routes/admin.ts"],"sourcesContent":["export default {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n path: '/iso-locales',\n handler: 'iso-locales.listIsoLocales',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.read'] },\n },\n ],\n },\n },\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'POST',\n path: '/locales',\n handler: 'locales.createLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.create'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/locales/:id',\n handler: 'locales.updateLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/locales/:id',\n handler: 'locales.deleteLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.delete'] },\n },\n ],\n },\n },\n {\n method: 'POST',\n path: '/content-manager/actions/get-non-localized-fields',\n handler: 'content-types.getNonLocalizedAttributes',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n"],"names":["type","routes","method","path","handler","config","policies","name","actions"],"mappings":";;AAAA,YAAe;IACbA,IAAM,EAAA,OAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,4BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA2B;AAAC;AAClD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,qBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF,SAAA;AACA,QAAA;YACEJ,MAAQ,EAAA,MAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA6B;AAAC;AACpD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA6B;AAAC;AACpD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,QAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA6B;AAAC;AACpD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,MAAA;YACRC,IAAM,EAAA,mDAAA;YACNC,OAAS,EAAA,yCAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH,CAAE;;;;"}
1
+ {"version":3,"file":"admin.js","sources":["../../../server/src/routes/admin.ts"],"sourcesContent":["export default {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n path: '/iso-locales',\n handler: 'iso-locales.listIsoLocales',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.read'] },\n },\n ],\n },\n },\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'POST',\n path: '/locales',\n handler: 'locales.createLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.create'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/locales/:id',\n handler: 'locales.updateLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/locales/:id',\n handler: 'locales.deleteLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.delete'] },\n },\n ],\n },\n },\n {\n method: 'POST',\n path: '/content-manager/actions/get-non-localized-fields',\n handler: 'content-types.getNonLocalizedAttributes',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'GET',\n path: '/settings',\n handler: 'settings.getSettings',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'PUT',\n path: '/settings',\n handler: 'settings.updateSettings',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n"],"names":["type","routes","method","path","handler","config","policies","name","actions"],"mappings":";;AAAA,YAAe;IACbA,IAAM,EAAA,OAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,4BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA2B;AAAC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AAA,WAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF,SAAA;AACA,QAAA;YACEJ,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,WAAA;YACNC,OAAS,EAAA,yBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH,CAAE;;;;"}
@@ -92,6 +92,26 @@ var admin = {
92
92
  'admin::isAuthenticatedAdmin'
93
93
  ]
94
94
  }
95
+ },
96
+ {
97
+ method: 'GET',
98
+ path: '/settings',
99
+ handler: 'settings.getSettings',
100
+ config: {
101
+ policies: [
102
+ 'admin::isAuthenticatedAdmin'
103
+ ]
104
+ }
105
+ },
106
+ {
107
+ method: 'PUT',
108
+ path: '/settings',
109
+ handler: 'settings.updateSettings',
110
+ config: {
111
+ policies: [
112
+ 'admin::isAuthenticatedAdmin'
113
+ ]
114
+ }
95
115
  }
96
116
  ]
97
117
  };
@@ -1 +1 @@
1
- {"version":3,"file":"admin.mjs","sources":["../../../server/src/routes/admin.ts"],"sourcesContent":["export default {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n path: '/iso-locales',\n handler: 'iso-locales.listIsoLocales',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.read'] },\n },\n ],\n },\n },\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'POST',\n path: '/locales',\n handler: 'locales.createLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.create'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/locales/:id',\n handler: 'locales.updateLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/locales/:id',\n handler: 'locales.deleteLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.delete'] },\n },\n ],\n },\n },\n {\n method: 'POST',\n path: '/content-manager/actions/get-non-localized-fields',\n handler: 'content-types.getNonLocalizedAttributes',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n"],"names":["type","routes","method","path","handler","config","policies","name","actions"],"mappings":"AAAA,YAAe;IACbA,IAAM,EAAA,OAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,4BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA2B;AAAC;AAClD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,qBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF,SAAA;AACA,QAAA;YACEJ,MAAQ,EAAA,MAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA6B;AAAC;AACpD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA6B;AAAC;AACpD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,QAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA6B;AAAC;AACpD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,MAAA;YACRC,IAAM,EAAA,mDAAA;YACNC,OAAS,EAAA,yCAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH,CAAE;;;;"}
1
+ {"version":3,"file":"admin.mjs","sources":["../../../server/src/routes/admin.ts"],"sourcesContent":["export default {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n path: '/iso-locales',\n handler: 'iso-locales.listIsoLocales',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.read'] },\n },\n ],\n },\n },\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'POST',\n path: '/locales',\n handler: 'locales.createLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.create'] },\n },\n ],\n },\n },\n {\n method: 'PUT',\n path: '/locales/:id',\n handler: 'locales.updateLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.update'] },\n },\n ],\n },\n },\n {\n method: 'DELETE',\n path: '/locales/:id',\n handler: 'locales.deleteLocale',\n config: {\n policies: [\n 'admin::isAuthenticatedAdmin',\n {\n name: 'plugin::content-manager.hasPermissions',\n config: { actions: ['plugin::i18n.locale.delete'] },\n },\n ],\n },\n },\n {\n method: 'POST',\n path: '/content-manager/actions/get-non-localized-fields',\n handler: 'content-types.getNonLocalizedAttributes',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'GET',\n path: '/settings',\n handler: 'settings.getSettings',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'PUT',\n path: '/settings',\n handler: 'settings.updateSettings',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n"],"names":["type","routes","method","path","handler","config","policies","name","actions"],"mappings":"AAAA,YAAe;IACbA,IAAM,EAAA,OAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,cAAA;YACNC,OAAS,EAAA,4BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AACR,oBAAA,6BAAA;AACA,oBAAA;wBACEC,IAAM,EAAA,wCAAA;wBACNF,MAAQ,EAAA;4BAAEG,OAAS,EAAA;AAAC,gCAAA;AAA2B;AAAC;AAClD;AACD;AACH;AACF,SAAA;AACA,QAAA;YACEN,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,qBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF,SAAA;AACA,QAAA;YACEJ,MAAQ,EAAA,MAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,sBAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,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@@
1
1
  'use strict';
2
2
 
3
- var contentApi = {
4
- type: 'content-api',
5
- routes: [
3
+ var utils = require('@strapi/utils');
4
+ var locale = require('./validation/locale.js');
5
+
6
+ const createContentApiRoutes = utils.createContentApiRoutesFactory(()=>{
7
+ const validator = new locale.I18nLocaleRouteValidator(strapi);
8
+ return [
6
9
  {
7
10
  method: 'GET',
8
11
  path: '/locales',
9
- handler: 'locales.listLocales'
12
+ handler: 'locales.listLocales',
13
+ response: validator.locales
10
14
  }
11
- ]
12
- };
15
+ ];
16
+ });
13
17
 
14
- module.exports = contentApi;
18
+ module.exports = createContentApiRoutes;
15
19
  //# sourceMappingURL=content-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"content-api.js","sources":["../../../server/src/routes/content-api.ts"],"sourcesContent":["export default {\n type: 'content-api',\n routes: [\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n },\n ],\n};\n"],"names":["type","routes","method","path","handler"],"mappings":";;AAAA,iBAAe;IACbA,IAAM,EAAA,aAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA;AACX;AACD;AACH,CAAE;;;;"}
1
+ {"version":3,"file":"content-api.js","sources":["../../../server/src/routes/content-api.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { createContentApiRoutesFactory } from '@strapi/utils';\nimport { I18nLocaleRouteValidator } from './validation';\n\nconst createContentApiRoutes = createContentApiRoutesFactory((): Core.RouterInput['routes'] => {\n const validator = new I18nLocaleRouteValidator(strapi);\n return [\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n response: validator.locales,\n },\n ];\n});\n\nexport default createContentApiRoutes;\n"],"names":["createContentApiRoutes","createContentApiRoutesFactory","validator","I18nLocaleRouteValidator","strapi","method","path","handler","response","locales"],"mappings":";;;;;AAIA,MAAMA,yBAAyBC,mCAA8B,CAAA,IAAA;IAC3D,MAAMC,SAAAA,GAAY,IAAIC,+BAAyBC,CAAAA,MAAAA,CAAAA;IAC/C,OAAO;AACL,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,qBAAA;AACTC,YAAAA,QAAAA,EAAUN,UAAUO;AACtB;AACD,KAAA;AACH,CAAA;;;;"}
@@ -1,13 +1,17 @@
1
- var contentApi = {
2
- type: 'content-api',
3
- routes: [
1
+ import { createContentApiRoutesFactory } from '@strapi/utils';
2
+ import { I18nLocaleRouteValidator } from './validation/locale.mjs';
3
+
4
+ const createContentApiRoutes = createContentApiRoutesFactory(()=>{
5
+ const validator = new I18nLocaleRouteValidator(strapi);
6
+ return [
4
7
  {
5
8
  method: 'GET',
6
9
  path: '/locales',
7
- handler: 'locales.listLocales'
10
+ handler: 'locales.listLocales',
11
+ response: validator.locales
8
12
  }
9
- ]
10
- };
13
+ ];
14
+ });
11
15
 
12
- export { contentApi as default };
16
+ export { createContentApiRoutes as default };
13
17
  //# sourceMappingURL=content-api.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"content-api.mjs","sources":["../../../server/src/routes/content-api.ts"],"sourcesContent":["export default {\n type: 'content-api',\n routes: [\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n },\n ],\n};\n"],"names":["type","routes","method","path","handler"],"mappings":"AAAA,iBAAe;IACbA,IAAM,EAAA,aAAA;IACNC,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA;AACX;AACD;AACH,CAAE;;;;"}
1
+ {"version":3,"file":"content-api.mjs","sources":["../../../server/src/routes/content-api.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport { createContentApiRoutesFactory } from '@strapi/utils';\nimport { I18nLocaleRouteValidator } from './validation';\n\nconst createContentApiRoutes = createContentApiRoutesFactory((): Core.RouterInput['routes'] => {\n const validator = new I18nLocaleRouteValidator(strapi);\n return [\n {\n method: 'GET',\n path: '/locales',\n handler: 'locales.listLocales',\n response: validator.locales,\n },\n ];\n});\n\nexport default createContentApiRoutes;\n"],"names":["createContentApiRoutes","createContentApiRoutesFactory","validator","I18nLocaleRouteValidator","strapi","method","path","handler","response","locales"],"mappings":";;;AAIA,MAAMA,yBAAyBC,6BAA8B,CAAA,IAAA;IAC3D,MAAMC,SAAAA,GAAY,IAAIC,wBAAyBC,CAAAA,MAAAA,CAAAA;IAC/C,OAAO;AACL,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,UAAA;YACNC,OAAS,EAAA,qBAAA;AACTC,YAAAA,QAAAA,EAAUN,UAAUO;AACtB;AACD,KAAA;AACH,CAAA;;;;"}
@@ -1,9 +1,9 @@
1
1
  import admin from './admin.mjs';
2
- import contentApi from './content-api.mjs';
2
+ import createContentApiRoutes from './content-api.mjs';
3
3
 
4
4
  var routes = {
5
5
  admin,
6
- 'content-api': contentApi
6
+ 'content-api': createContentApiRoutes
7
7
  };
8
8
 
9
9
  export { routes as default };