@strapi/i18n 5.48.1 → 5.49.0

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 (44) hide show
  1. package/dist/admin/components/CMHeaderActions.js +3 -2
  2. package/dist/admin/components/CMHeaderActions.js.map +1 -1
  3. package/dist/admin/components/CheckboxConfirmation.js +3 -2
  4. package/dist/admin/components/CheckboxConfirmation.js.map +1 -1
  5. package/dist/admin/components/CreateLocale.js +4 -3
  6. package/dist/admin/components/CreateLocale.js.map +1 -1
  7. package/dist/admin/components/DeleteLocale.js +3 -2
  8. package/dist/admin/components/DeleteLocale.js.map +1 -1
  9. package/dist/admin/components/EditLocale.js +3 -2
  10. package/dist/admin/components/EditLocale.js.map +1 -1
  11. package/dist/admin/components/LocalePicker.js +3 -2
  12. package/dist/admin/components/LocalePicker.js.map +1 -1
  13. package/dist/admin/components/LocaleTable.js +3 -2
  14. package/dist/admin/components/LocaleTable.js.map +1 -1
  15. package/dist/admin/hooks/useAILocalizationJobsPolling.js +3 -2
  16. package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -1
  17. package/dist/admin/hooks/useI18n.js +7 -3
  18. package/dist/admin/hooks/useI18n.js.map +1 -1
  19. package/dist/admin/index.js +7 -3
  20. package/dist/admin/index.js.map +1 -1
  21. package/dist/admin/middlewares/extendCTBAttributeInitialData.js +6 -2
  22. package/dist/admin/middlewares/extendCTBAttributeInitialData.js.map +1 -1
  23. package/dist/admin/middlewares/rbac-middleware.js +3 -2
  24. package/dist/admin/middlewares/rbac-middleware.js.map +1 -1
  25. package/dist/admin/utils/fields.js +5 -1
  26. package/dist/admin/utils/fields.js.map +1 -1
  27. package/dist/admin/utils/schemas.js +6 -2
  28. package/dist/admin/utils/schemas.js.map +1 -1
  29. package/dist/server/controllers/locales.js +3 -2
  30. package/dist/server/controllers/locales.js.map +1 -1
  31. package/dist/server/register.js +6 -2
  32. package/dist/server/register.js.map +1 -1
  33. package/dist/server/routes/validation/locale.js +3 -2
  34. package/dist/server/routes/validation/locale.js.map +1 -1
  35. package/dist/server/services/content-types.js +6 -2
  36. package/dist/server/services/content-types.js.map +1 -1
  37. package/dist/server/services/content-types.mjs.map +1 -1
  38. package/dist/server/services/localizations.js.map +1 -1
  39. package/dist/server/services/localizations.mjs.map +1 -1
  40. package/dist/server/src/index.d.ts +1 -1
  41. package/dist/server/src/services/content-types.d.ts +1 -1
  42. package/dist/server/src/services/content-types.d.ts.map +1 -1
  43. package/dist/server/src/services/index.d.ts +1 -1
  44. package/package.json +7 -7
@@ -3,6 +3,10 @@
3
3
  var omit = require('lodash/omit');
4
4
  var fields = require('./fields.js');
5
5
 
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var omit__default = /*#__PURE__*/_interopDefault(omit);
9
+
6
10
  /* -------------------------------------------------------------------------------------------------
7
11
  * mutateCTBContentTypeSchema
8
12
  * -----------------------------------------------------------------------------------------------*/ // TODO: refactor for CTB refactors
@@ -30,7 +34,7 @@ const mutateCTBContentTypeSchema = (nextSchema, prevSchema)=>{
30
34
  }
31
35
  // Remove the i18n object from the pluginOptions
32
36
  if (!isNextSchemaLocalized) {
33
- const pluginOptions = omit(nextSchema.pluginOptions, 'i18n');
37
+ const pluginOptions = omit__default.default(nextSchema.pluginOptions, 'i18n');
34
38
  const attributes = disableAttributesLocalisation(nextSchema.attributes);
35
39
  return {
36
40
  ...nextSchema,
@@ -66,7 +70,7 @@ const mutateCTBContentTypeSchema = (nextSchema, prevSchema)=>{
66
70
  * disableAttributesLocalisation
67
71
  * -----------------------------------------------------------------------------------------------*/ const disableAttributesLocalisation = (attributes)=>{
68
72
  return attributes.map((currentAttribute)=>{
69
- return omit(currentAttribute, 'pluginOptions.i18n');
73
+ return omit__default.default(currentAttribute, 'pluginOptions.i18n');
70
74
  });
71
75
  };
72
76
 
@@ -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\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;AAGlG,MAAMA,0BAAAA,GAA6B,CACjCC,UAAAA,EAKAC,UAAAA,GAAAA;AAMA,IAAA,IAAI,CAACA,UAAAA,EAAY;QACf,OAAOD,UAAAA;AACT,IAAA;;AAGA,IAAA,IAAI,CAACE,yCAAAA,CAAmCF,UAAAA,CAAWG,aAAa,CAAA,EAAG;QACjE,OAAOH,UAAAA;AACT,IAAA;AAEA,IAAA,MAAMI,wBAAwBJ,UAAAA,CAAWG,aAAa,CAACE,IAAI,CAACC,SAAS;AACrE,IAAA,MAAMC,wBAAwBL,yCAAAA,CAAmCD,UAAAA,EAAYE,iBACzEF,UAAAA,EAAYE,aAAAA,CAAcE,KAAKC,SAAAA,GAC/B,KAAA;;;AAIJ,IAAA,IAAIF,yBAAyBG,qBAAAA,EAAuB;QAClD,OAAOP,UAAAA;AACT,IAAA;AAEA,IAAA,IAAII,qBAAAA,EAAuB;QACzB,MAAMI,UAAAA,GAAaC,uBAAAA,CAAwBT,UAAAA,CAAWQ,UAAU,CAAA;QAEhE,OAAO;AACL,YAAA,GAAGR,UAAU;AACbQ,YAAAA;AACF,SAAA;AACF,IAAA;;AAGA,IAAA,IAAI,CAACJ,qBAAAA,EAAuB;AAC1B,QAAA,MAAMD,aAAAA,GAAgBO,IAAAA,CAAKV,UAAAA,CAAWG,aAAa,EAAE,MAAA,CAAA;QACrD,MAAMK,UAAAA,GAAaG,6BAAAA,CAA8BX,UAAAA,CAAWQ,UAAU,CAAA;QAEtE,OAAO;AACL,YAAA,GAAGR,UAAU;AACbG,YAAAA,aAAAA;AACAK,YAAAA;AACF,SAAA;AACF,IAAA;IAEA,OAAOR,UAAAA;AACT;AAEA;;qGAIA,MAAMS,0BAA0B,CAACD,UAAAA,GAAAA;IAC/B,OAAOA,UAAAA,CAAWI,GAAG,CAAC,CAACC,gBAAAA,GAAAA;AACrB,QAAA,IAAIC,uBAAAA,CAAiBC,QAAQ,CAACF,gBAAAA,CAAiBG,IAAI,CAAA,EAAG;AACpD,YAAA,MAAMX,IAAAA,GAAO;gBAAEC,SAAAA,EAAW;AAAK,aAAA;YAE/B,MAAMH,aAAAA,GAAgBU,gBAAAA,CAAiBV,aAAa,GAChD;AAAE,gBAAA,GAAGU,iBAAiBV,aAAa;AAAEE,gBAAAA;aAAK,GAC1C;AAAEA,gBAAAA;AAAK,aAAA;YAEX,OAAO;AAAE,gBAAA,GAAGQ,gBAAgB;AAAEV,gBAAAA;AAAc,aAAA;AAC9C,QAAA;QAEA,OAAOU,gBAAAA;AACT,IAAA,CAAA,CAAA;AACF,CAAA;AAEA;;qGAIA,MAAMF,gCAAgC,CAACH,UAAAA,GAAAA;IACrC,OAAOA,UAAAA,CAAWI,GAAG,CAAC,CAACC,gBAAAA,GAAAA;AACrB,QAAA,OAAOH,KAAKG,gBAAAA,EAAkB,oBAAA,CAAA;AAChC,IAAA,CAAA,CAAA;AACF,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;AAGlG,MAAMA,0BAAAA,GAA6B,CACjCC,UAAAA,EAKAC,UAAAA,GAAAA;AAMA,IAAA,IAAI,CAACA,UAAAA,EAAY;QACf,OAAOD,UAAAA;AACT,IAAA;;AAGA,IAAA,IAAI,CAACE,yCAAAA,CAAmCF,UAAAA,CAAWG,aAAa,CAAA,EAAG;QACjE,OAAOH,UAAAA;AACT,IAAA;AAEA,IAAA,MAAMI,wBAAwBJ,UAAAA,CAAWG,aAAa,CAACE,IAAI,CAACC,SAAS;AACrE,IAAA,MAAMC,wBAAwBL,yCAAAA,CAAmCD,UAAAA,EAAYE,iBACzEF,UAAAA,EAAYE,aAAAA,CAAcE,KAAKC,SAAAA,GAC/B,KAAA;;;AAIJ,IAAA,IAAIF,yBAAyBG,qBAAAA,EAAuB;QAClD,OAAOP,UAAAA;AACT,IAAA;AAEA,IAAA,IAAII,qBAAAA,EAAuB;QACzB,MAAMI,UAAAA,GAAaC,uBAAAA,CAAwBT,UAAAA,CAAWQ,UAAU,CAAA;QAEhE,OAAO;AACL,YAAA,GAAGR,UAAU;AACbQ,YAAAA;AACF,SAAA;AACF,IAAA;;AAGA,IAAA,IAAI,CAACJ,qBAAAA,EAAuB;AAC1B,QAAA,MAAMD,aAAAA,GAAgBO,qBAAAA,CAAKV,UAAAA,CAAWG,aAAa,EAAE,MAAA,CAAA;QACrD,MAAMK,UAAAA,GAAaG,6BAAAA,CAA8BX,UAAAA,CAAWQ,UAAU,CAAA;QAEtE,OAAO;AACL,YAAA,GAAGR,UAAU;AACbG,YAAAA,aAAAA;AACAK,YAAAA;AACF,SAAA;AACF,IAAA;IAEA,OAAOR,UAAAA;AACT;AAEA;;qGAIA,MAAMS,0BAA0B,CAACD,UAAAA,GAAAA;IAC/B,OAAOA,UAAAA,CAAWI,GAAG,CAAC,CAACC,gBAAAA,GAAAA;AACrB,QAAA,IAAIC,uBAAAA,CAAiBC,QAAQ,CAACF,gBAAAA,CAAiBG,IAAI,CAAA,EAAG;AACpD,YAAA,MAAMX,IAAAA,GAAO;gBAAEC,SAAAA,EAAW;AAAK,aAAA;YAE/B,MAAMH,aAAAA,GAAgBU,gBAAAA,CAAiBV,aAAa,GAChD;AAAE,gBAAA,GAAGU,iBAAiBV,aAAa;AAAEE,gBAAAA;aAAK,GAC1C;AAAEA,gBAAAA;AAAK,aAAA;YAEX,OAAO;AAAE,gBAAA,GAAGQ,gBAAgB;AAAEV,gBAAAA;AAAc,aAAA;AAC9C,QAAA;QAEA,OAAOU,gBAAAA;AACT,IAAA,CAAA,CAAA;AACF,CAAA;AAEA;;qGAIA,MAAMF,gCAAgC,CAACH,UAAAA,GAAAA;IACrC,OAAOA,UAAAA,CAAWI,GAAG,CAAC,CAACC,gBAAAA,GAAAA;AACrB,QAAA,OAAOH,sBAAKG,gBAAAA,EAAkB,oBAAA,CAAA;AAChC,IAAA,CAAA,CAAA;AACF,CAAA;;;;"}
@@ -6,7 +6,8 @@ var index = require('../utils/index.js');
6
6
  var locales = require('../validation/locales.js');
7
7
  var locale = require('../domain/locale.js');
8
8
 
9
- function _interopNamespaceDefault(e) {
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
10
11
  var n = Object.create(null);
11
12
  if (e) {
12
13
  Object.keys(e).forEach(function (k) {
@@ -23,7 +24,7 @@ function _interopNamespaceDefault(e) {
23
24
  return Object.freeze(n);
24
25
  }
25
26
 
26
- var utils__namespace = /*#__PURE__*/_interopNamespaceDefault(utils);
27
+ var utils__namespace = /*#__PURE__*/_interopNamespace(utils);
27
28
 
28
29
  const { setCreatorFields } = utils__namespace;
29
30
  const { ApplicationError } = utils__namespace.errors;
@@ -1 +1 @@
1
- {"version":3,"file":"locales.js","sources":["../../../server/src/controllers/locales.ts"],"sourcesContent":["import * as utils from '@strapi/utils';\nimport { pick } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { getService } from '../utils';\nimport { validateCreateLocaleInput, validateUpdateLocaleInput } from '../validation/locales';\nimport { formatLocale } from '../domain/locale';\n\nconst { setCreatorFields } = utils;\nconst { ApplicationError } = utils.errors;\n\nconst sanitizeLocale = (locale: any) => {\n const model = strapi.getModel('plugin::i18n.locale');\n\n return strapi.contentAPI.sanitize.output(locale, model);\n};\n\nconst controller: Core.Controller = {\n async listLocales(ctx) {\n const localesService = getService('locales');\n\n const locales = await localesService.find();\n const sanitizedLocales = await sanitizeLocale(locales);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocales);\n },\n\n async createLocale(ctx) {\n const { user } = ctx.state;\n const body = ctx.request.body as any;\n const { isDefault, ...localeToCreate } = body;\n\n await validateCreateLocaleInput(body);\n\n const localesService = getService('locales');\n\n const existingLocale = await localesService.findByCode(body.code);\n if (existingLocale) {\n throw new ApplicationError('This locale already exists');\n }\n\n const localeToPersist = setCreatorFields({ user })(formatLocale(localeToCreate));\n\n const locale = await localesService.create(localeToPersist);\n\n if (isDefault) {\n await localesService.setDefaultLocale(locale);\n }\n\n const sanitizedLocale = await sanitizeLocale(locale);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocale);\n },\n\n async updateLocale(ctx) {\n const { user } = ctx.state;\n const { id } = ctx.params;\n const body = ctx.request.body as any;\n const { isDefault, ...updates } = body;\n\n await validateUpdateLocaleInput(body);\n\n const localesService = getService('locales');\n\n const existingLocale = await localesService.findById(id);\n if (!existingLocale) {\n return ctx.notFound('locale.notFound');\n }\n\n const allowedParams = ['name'];\n const cleanUpdates = setCreatorFields({ user, isEdition: true })(pick(allowedParams, updates));\n\n const updatedLocale = await localesService.update({ id }, cleanUpdates);\n\n if (isDefault) {\n await localesService.setDefaultLocale(updatedLocale);\n }\n\n const sanitizedLocale = await sanitizeLocale(updatedLocale);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocale);\n },\n\n async deleteLocale(ctx) {\n const { id } = ctx.params;\n\n const localesService = getService('locales');\n\n const existingLocale = await localesService.findById(id);\n if (!existingLocale) {\n return ctx.notFound('locale.notFound');\n }\n\n const defaultLocaleCode = await localesService.getDefaultLocale();\n if (existingLocale.code === defaultLocaleCode) {\n throw new ApplicationError('Cannot delete the default locale');\n }\n\n await localesService.delete({ id });\n\n const sanitizedLocale = await sanitizeLocale(existingLocale);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocale);\n },\n};\n\nexport default controller;\n"],"names":["setCreatorFields","utils","ApplicationError","errors","sanitizeLocale","locale","model","strapi","getModel","contentAPI","sanitize","output","controller","listLocales","ctx","localesService","getService","locales","find","sanitizedLocales","body","setIsDefault","createLocale","user","state","request","isDefault","localeToCreate","validateCreateLocaleInput","existingLocale","findByCode","code","localeToPersist","formatLocale","create","setDefaultLocale","sanitizedLocale","updateLocale","id","params","updates","validateUpdateLocaleInput","findById","notFound","allowedParams","cleanUpdates","isEdition","pick","updatedLocale","update","deleteLocale","defaultLocaleCode","getDefaultLocale","delete"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,gBAAAA;AAC7B,MAAM,EAAEC,gBAAgB,EAAE,GAAGD,iBAAME,MAAM;AAEzC,MAAMC,iBAAiB,CAACC,MAAAA,GAAAA;IACtB,MAAMC,KAAAA,GAAQC,MAAAA,CAAOC,QAAQ,CAAC,qBAAA,CAAA;AAE9B,IAAA,OAAOD,OAAOE,UAAU,CAACC,QAAQ,CAACC,MAAM,CAACN,MAAAA,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Ae4C,aAAAA,CAAAA;AAE7ClC,QAAAA,GAAAA,CAAIM,IAAI,GAAG,MAAML,cAAAA,CAAeM,YAAY,CAACe,eAAAA,CAAAA;AAC/C,IAAA,CAAA;AAEA,IAAA,MAAMc,cAAapC,GAAG,EAAA;AACpB,QAAA,MAAM,EAAEwB,EAAE,EAAE,GAAGxB,IAAIyB,MAAM;AAEzB,QAAA,MAAMxB,iBAAiBC,gBAAAA,CAAW,SAAA,CAAA;AAElC,QAAA,MAAMa,cAAAA,GAAiB,MAAMd,cAAAA,CAAe2B,QAAQ,CAACJ,EAAAA,CAAAA;AACrD,QAAA,IAAI,CAACT,cAAAA,EAAgB;YACnB,OAAOf,GAAAA,CAAI6B,QAAQ,CAAC,iBAAA,CAAA;AACtB,QAAA;QAEA,MAAMQ,iBAAAA,GAAoB,MAAMpC,cAAAA,CAAeqC,gBAAgB,EAAA;QAC/D,IAAIvB,cAAAA,CAAeE,IAAI,KAAKoB,iBAAAA,EAAmB;AAC7C,YAAA,MAAM,IAAIjD,gBAAAA,CAAiB,kCAAA,CAAA;AAC7B,QAAA;QAEA,MAAMa,cAAAA,CAAesC,MAAM,CAAC;AAAEf,YAAAA;AAAG,SAAA,CAAA;QAEjC,MAAMF,eAAAA,GAAkB,MAAMhC,cAAAA,CAAeyB,cAAAA,CAAAA;AAE7Cf,QAAAA,GAAAA,CAAIM,IAAI,GAAG,MAAML,cAAAA,CAAeM,YAAY,CAACe,eAAAA,CAAAA;AAC/C,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"locales.js","sources":["../../../server/src/controllers/locales.ts"],"sourcesContent":["import * as utils from '@strapi/utils';\nimport { pick } from 'lodash/fp';\nimport type { Core } from '@strapi/types';\nimport { getService } from '../utils';\nimport { validateCreateLocaleInput, validateUpdateLocaleInput } from '../validation/locales';\nimport { formatLocale } from '../domain/locale';\n\nconst { setCreatorFields } = utils;\nconst { ApplicationError } = utils.errors;\n\nconst sanitizeLocale = (locale: any) => {\n const model = strapi.getModel('plugin::i18n.locale');\n\n return strapi.contentAPI.sanitize.output(locale, model);\n};\n\nconst controller: Core.Controller = {\n async listLocales(ctx) {\n const localesService = getService('locales');\n\n const locales = await localesService.find();\n const sanitizedLocales = await sanitizeLocale(locales);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocales);\n },\n\n async createLocale(ctx) {\n const { user } = ctx.state;\n const body = ctx.request.body as any;\n const { isDefault, ...localeToCreate } = body;\n\n await validateCreateLocaleInput(body);\n\n const localesService = getService('locales');\n\n const existingLocale = await localesService.findByCode(body.code);\n if (existingLocale) {\n throw new ApplicationError('This locale already exists');\n }\n\n const localeToPersist = setCreatorFields({ user })(formatLocale(localeToCreate));\n\n const locale = await localesService.create(localeToPersist);\n\n if (isDefault) {\n await localesService.setDefaultLocale(locale);\n }\n\n const sanitizedLocale = await sanitizeLocale(locale);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocale);\n },\n\n async updateLocale(ctx) {\n const { user } = ctx.state;\n const { id } = ctx.params;\n const body = ctx.request.body as any;\n const { isDefault, ...updates } = body;\n\n await validateUpdateLocaleInput(body);\n\n const localesService = getService('locales');\n\n const existingLocale = await localesService.findById(id);\n if (!existingLocale) {\n return ctx.notFound('locale.notFound');\n }\n\n const allowedParams = ['name'];\n const cleanUpdates = setCreatorFields({ user, isEdition: true })(pick(allowedParams, updates));\n\n const updatedLocale = await localesService.update({ id }, cleanUpdates);\n\n if (isDefault) {\n await localesService.setDefaultLocale(updatedLocale);\n }\n\n const sanitizedLocale = await sanitizeLocale(updatedLocale);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocale);\n },\n\n async deleteLocale(ctx) {\n const { id } = ctx.params;\n\n const localesService = getService('locales');\n\n const existingLocale = await localesService.findById(id);\n if (!existingLocale) {\n return ctx.notFound('locale.notFound');\n }\n\n const defaultLocaleCode = await localesService.getDefaultLocale();\n if (existingLocale.code === defaultLocaleCode) {\n throw new ApplicationError('Cannot delete the default locale');\n }\n\n await localesService.delete({ id });\n\n const sanitizedLocale = await sanitizeLocale(existingLocale);\n\n ctx.body = await localesService.setIsDefault(sanitizedLocale);\n },\n};\n\nexport default controller;\n"],"names":["setCreatorFields","utils","ApplicationError","errors","sanitizeLocale","locale","model","strapi","getModel","contentAPI","sanitize","output","controller","listLocales","ctx","localesService","getService","locales","find","sanitizedLocales","body","setIsDefault","createLocale","user","state","request","isDefault","localeToCreate","validateCreateLocaleInput","existingLocale","findByCode","code","localeToPersist","formatLocale","create","setDefaultLocale","sanitizedLocale","updateLocale","id","params","updates","validateUpdateLocaleInput","findById","notFound","allowedParams","cleanUpdates","isEdition","pick","updatedLocale","update","deleteLocale","defaultLocaleCode","getDefaultLocale","delete"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,gBAAAA;AAC7B,MAAM,EAAEC,gBAAgB,EAAE,GAAGD,iBAAME,MAAM;AAEzC,MAAMC,iBAAiB,CAACC,MAAAA,GAAAA;IACtB,MAAMC,KAAAA,GAAQC,MAAAA,CAAOC,QAAQ,CAAC,qBAAA,CAAA;AAE9B,IAAA,OAAOD,OAAOE,UAAU,CAACC,QAAQ,CAACC,MAAM,CAACN,MAAAA,EAAQC,KAAAA,CAAAA;AACnD,CAAA;AAEA,MAAMM,UAAAA,GAA8B;AAClC,IAAA,MAAMC,aAAYC,GAAG,EAAA;AACnB,QAAA,MAAMC,iBAAiBC,gBAAAA,CAAW,SAAA,CAAA;QAElC,MAAMC,OAAAA,GAAU,MAAMF,cAAAA,CAAeG,IAAI,EAAA;QACzC,MAAMC,gBAAAA,GAAmB,MAAMf,cAAAA,CAAea,OAAAA,CAAAA;AAE9CH,QAAAA,GAAAA,CAAIM,IAAI,GAAG,MAAML,cAAAA,CAAeM,YAAY,CAACF,gBAAAA,CAAAA;AAC/C,IAAA,CAAA;AAEA,IAAA,MAAMG,cAAaR,GAAG,EAAA;AACpB,QAAA,MAAM,EAAES,IAAI,EAAE,GAAGT,IAAIU,KAAK;A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MAAMQ,iBAAAA,GAAoB,MAAMpC,cAAAA,CAAeqC,gBAAgB,EAAA;QAC/D,IAAIvB,cAAAA,CAAeE,IAAI,KAAKoB,iBAAAA,EAAmB;AAC7C,YAAA,MAAM,IAAIjD,gBAAAA,CAAiB,kCAAA,CAAA;AAC7B,QAAA;QAEA,MAAMa,cAAAA,CAAesC,MAAM,CAAC;AAAEf,YAAAA;AAAG,SAAA,CAAA;QAEjC,MAAMF,eAAAA,GAAkB,MAAMhC,cAAAA,CAAeyB,cAAAA,CAAAA;AAE7Cf,QAAAA,GAAAA,CAAIM,IAAI,GAAG,MAAML,cAAAA,CAAeM,YAAY,CAACe,eAAAA,CAAAA;AAC/C,IAAA;AACF;;;;"}
@@ -6,6 +6,10 @@ var graphql = require('./graphql.js');
6
6
  var index = require('./utils/index.js');
7
7
  var aiLocalizationJob = require('./models/ai-localization-job.js');
8
8
 
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var ___default = /*#__PURE__*/_interopDefault(_);
12
+
9
13
  var register = (async ({ strapi })=>{
10
14
  strapi.get('models').add(aiLocalizationJob.aiLocalizationJob);
11
15
  extendContentTypes(strapi);
@@ -38,14 +42,14 @@ var register = (async ({ strapi })=>{
38
42
  Object.values(strapi.contentTypes).forEach((contentType)=>{
39
43
  const { attributes } = contentType;
40
44
  const isLocalized = isLocalizedContentType(contentType);
41
- _.set(attributes, 'locale', {
45
+ ___default.default.set(attributes, 'locale', {
42
46
  writable: true,
43
47
  private: !isLocalized,
44
48
  configurable: false,
45
49
  visible: false,
46
50
  type: 'string'
47
51
  });
48
- _.set(attributes, 'localizations', {
52
+ ___default.default.set(attributes, 'localizations', {
49
53
  type: 'relation',
50
54
  relation: 'oneToMany',
51
55
  target: contentType.uid,
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nimport validateLocaleCreation from './controllers/validate-locale-creation';\nimport graphqlProvider from './graphql';\nimport { getService } from './utils';\nimport { aiLocalizationJob } from './models/ai-localization-job';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.get('models').add(aiLocalizationJob);\n\n extendContentTypes(strapi);\n addContentManagerLocaleMiddleware(strapi);\n};\n\n// TODO: v5 if implemented in the CM => delete this middleware\n/**\n * Adds middleware on CM creation routes to use i18n locale passed in a specific param\n * @param {Strapi} strapi\n */\nconst addContentManagerLocaleMiddleware = (strapi: Core.Strapi) => {\n strapi.server.router.use('/content-manager/collection-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n\n strapi.server.router.use('/content-manager/single-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n};\n\n/**\n * Adds locale and localization fields to all content types\n * Even if content type is not localized, it will have these fields\n * @param {Strapi} strapi\n */\nconst extendContentTypes = (strapi: Core.Strapi) => {\n const { isLocalizedContentType } = getService('content-types');\n\n Object.values(strapi.contentTypes).forEach((contentType) => {\n const { attributes } = contentType;\n\n const isLocalized = isLocalizedContentType(contentType);\n\n _.set(attributes, 'locale', {\n writable: true,\n private: !isLocalized,\n configurable: false,\n visible: false,\n type: 'string',\n });\n\n _.set(attributes, 'localizations', {\n type: 'relation',\n relation: 'oneToMany',\n target: contentType.uid,\n writable: false,\n private: !isLocalized,\n configurable: false,\n visible: false,\n unstable_virtual: true,\n joinColumn: {\n name: 'document_id',\n referencedColumn: 'document_id',\n referencedTable: strapi.db.metadata.identifiers.getTableName(contentType.collectionName!),\n // ensure the population will not include the results we already loaded\n on({ results }: { results: any[] }) {\n return {\n id: {\n $notIn: results.map((r) => r.id),\n },\n };\n },\n },\n });\n });\n\n if (strapi.plugin('graphql')) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n graphqlProvider({ strapi }).register();\n }\n};\n"],"names":["strapi","get","add","aiLocalizationJob","extendContentTypes","addContentManagerLocaleMiddleware","server","router","use","ctx","next","method","validateLocaleCreation","isLocalizedContentType","getService","Object","values","contentTypes","forEach","contentType","attributes","isLocalized","_","set","writable","private","configurable","visible","type","relation","target","uid","unstable_virtual","joinColumn","name","referencedColumn","referencedTable","db","metadata","identifiers","getTableName","collectionName","on","results","id","$notIn","map","r","plugin","graphqlProvider","register"],"mappings":";;;;;;;;AAQA,eAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;AACvDA,IAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,mCAAAA,CAAAA;IAEzBC,kBAAAA,CAAmBJ,MAAAA,CAAAA;IACnBK,iCAAAA,CAAkCL,MAAAA,CAAAA;AACpC,CAAA;AAEA;AACA;;;IAIA,MAAMK,oCAAoC,CAACL,MAAAA,GAAAA;IACzCA,MAAAA,CAAOM,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,0CAAA,EAA4C,CAACC,GAAAA,EAAKC,IAAAA,GAAAA;AACzE,QAAA,IAAID,IAAIE,MAAM,KAAK,UAAUF,GAAAA,CAAIE,MAAM,KAAK,KAAA,EAAO;AACjD,YAAA,OAAOC,uBAAuBH,GAAAA,EAAKC,IAAAA,CAAAA;AACrC,QAAA;QAEA,OAAOA,IAAAA,EAAAA;AACT,IAAA,CAAA,CAAA;IAEAV,MAAAA,CAAOM,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,sCAAA,EAAwC,CAACC,GAAAA,EAAKC,IAAAA,GAAAA;AACrE,QAAA,IAAID,IAAIE,MAAM,KAAK,UAAUF,GAAAA,CAAIE,MAAM,KAAK,KAAA,EAAO;AACjD,YAAA,OAAOC,uBAAuBH,GAAAA,EAAKC,IAAAA,CAAAA;AACrC,QAAA;QAEA,OAAOA,IAAAA,EAAAA;AACT,IAAA,CAAA,CAAA;AACF,CAAA;AAEA;;;;IAKA,MAAMN,qBAAqB,CAACJ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A,CAAA;AACF,IAAA,CAAA,CAAA;IAEA,IAAI5C,MAAAA,CAAOgD,MAAM,CAAC,SAAA,CAAA,EAAY;;QAE5BC,OAAAA,CAAgB;AAAEjD,YAAAA;AAAO,SAAA,CAAA,CAAGkD,QAAQ,EAAA;AACtC,IAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"register.js","sources":["../../server/src/register.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Core } from '@strapi/types';\n\nimport validateLocaleCreation from './controllers/validate-locale-creation';\nimport graphqlProvider from './graphql';\nimport { getService } from './utils';\nimport { aiLocalizationJob } from './models/ai-localization-job';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.get('models').add(aiLocalizationJob);\n\n extendContentTypes(strapi);\n addContentManagerLocaleMiddleware(strapi);\n};\n\n// TODO: v5 if implemented in the CM => delete this middleware\n/**\n * Adds middleware on CM creation routes to use i18n locale passed in a specific param\n * @param {Strapi} strapi\n */\nconst addContentManagerLocaleMiddleware = (strapi: Core.Strapi) => {\n strapi.server.router.use('/content-manager/collection-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n\n strapi.server.router.use('/content-manager/single-types/:model', (ctx, next) => {\n if (ctx.method === 'POST' || ctx.method === 'PUT') {\n return validateLocaleCreation(ctx, next);\n }\n\n return next();\n });\n};\n\n/**\n * Adds locale and localization fields to all content types\n * Even if content type is not localized, it will have these fields\n * @param {Strapi} strapi\n */\nconst extendContentTypes = (strapi: Core.Strapi) => {\n const { isLocalizedContentType } = getService('content-types');\n\n Object.values(strapi.contentTypes).forEach((contentType) => {\n const { attributes } = contentType;\n\n const isLocalized = isLocalizedContentType(contentType);\n\n _.set(attributes, 'locale', {\n writable: true,\n private: !isLocalized,\n configurable: false,\n visible: false,\n type: 'string',\n });\n\n _.set(attributes, 'localizations', {\n type: 'relation',\n relation: 'oneToMany',\n target: contentType.uid,\n writable: false,\n private: !isLocalized,\n configurable: false,\n visible: false,\n unstable_virtual: true,\n joinColumn: {\n name: 'document_id',\n referencedColumn: 'document_id',\n referencedTable: strapi.db.metadata.identifiers.getTableName(contentType.collectionName!),\n // ensure the population will not include the results we already loaded\n on({ results }: { results: any[] }) {\n return {\n id: {\n $notIn: results.map((r) => r.id),\n },\n };\n },\n },\n });\n });\n\n if (strapi.plugin('graphql')) {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n graphqlProvider({ strapi }).register();\n }\n};\n"],"names":["strapi","get","add","aiLocalizationJob","extendContentTypes","addContentManagerLocaleMiddleware","server","router","use","ctx","next","method","validateLocaleCreation","isLocalizedContentType","getService","Object","values","contentTypes","forEach","contentType","attributes","isLocalized","_","set","writable","private","configurable","visible","type","relation","target","uid","unstable_virtual","joinColumn","name","referencedColumn","referencedTable","db","metadata","identifiers","getTableName","collectionName","on","results","id","$notIn","map","r","plugin","graphqlProvider","register"],"mappings":";;;;;;;;;;;;AAQA,eAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;AACvDA,IAAAA,MAAAA,CAAOC,GAAG,CAAC,QAAA,CAAA,CAAUC,GAAG,CAACC,mCAAAA,CAAAA;IAEzBC,kBAAAA,CAAmBJ,MAAAA,CAAAA;IACnBK,iCAAAA,CAAkCL,MAAAA,CAAAA;AACpC,CAAA;AAEA;AACA;;;IAIA,MAAMK,oCAAoC,CAACL,MAAAA,GAAAA;IACzCA,MAAAA,CAAOM,MAAM,CAACC,MAAM,CAACC,GAAG,CAAC,0CAAA,EAA4C,CAACC,GAAAA,EAAKC,IAAAA,GAAAA;AACzE,QAAA,IAAID,IAAIE,MAAM,KAAK,UAAUF,GAAAA,CAAIE,MAAM,KAAK,KAAA,EAAO;AACjD,YAAA,OAAOC,uBAAuBH,GAAAA,EAAKC,IAAAA,CAAAA;AACrC,QAAA;QAEA,OAAOA,IAAAA,EAAAA;AACT,IAAA,CAAA,CAAA;IAEAV,MAAAA,CAAOM,MAAM,CAACC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,eAAAA,EAAiBpC,MAAAA,CAAOqC,EAAE,CAACC,QAAQ,CAACC,WAAW,CAACC,YAAY,CAACrB,WAAAA,CAAYsB,cAAc,CAAA;;gBAEvFC,EAAAA,CAAAA,CAAG,EAAEC,OAAO,EAAsB,EAAA;oBAChC,OAAO;wBACLC,EAAAA,EAAI;AACFC,4BAAAA,MAAAA,EAAQF,QAAQG,GAAG,CAAC,CAACC,CAAAA,GAAMA,EAAEH,EAAE;AACjC;AACF,qBAAA;AACF,gBAAA;AACF;AACF,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;IAEA,IAAI5C,MAAAA,CAAOgD,MAAM,CAAC,SAAA,CAAA,EAAY;;QAE5BC,OAAAA,CAAgB;AAAEjD,YAAAA;AAAO,SAAA,CAAA,CAAGkD,QAAQ,EAAA;AACtC,IAAA;AACF,CAAA;;;;"}
@@ -2,7 +2,8 @@
2
2
 
3
3
  var z = require('zod/v4');
4
4
 
5
- function _interopNamespaceDefault(e) {
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
6
7
  var n = Object.create(null);
7
8
  if (e) {
8
9
  Object.keys(e).forEach(function (k) {
@@ -19,7 +20,7 @@ function _interopNamespaceDefault(e) {
19
20
  return Object.freeze(n);
20
21
  }
21
22
 
22
- var z__namespace = /*#__PURE__*/_interopNamespaceDefault(z);
23
+ var z__namespace = /*#__PURE__*/_interopNamespace(z);
23
24
 
24
25
  /**
25
26
  * A validator for i18n locale routes.
@@ -1 +1 @@
1
- {"version":3,"file":"locale.js","sources":["../../../../server/src/routes/validation/locale.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as z from 'zod/v4';\n\n/**\n * A validator for i18n locale routes.\n *\n */\nexport class I18nLocaleRouteValidator {\n protected readonly _strapi: Core.Strapi;\n\n public constructor(strapi: Core.Strapi) {\n this._strapi = strapi;\n }\n\n /**\n * Generates a validation schema for a single locale.\n *\n * @returns A schema for validating locale objects\n */\n get locale() {\n return z.object({\n id: z.number().int().positive(),\n documentId: z.string().uuid(),\n name: z.string(),\n code: z.string().length(2, 'Locale code must be exactly 2 characters'),\n createdAt: z.string(),\n updatedAt: z.string(),\n publishedAt: z.string().nullable(),\n isDefault: z.boolean(),\n });\n }\n\n /**\n * Generates a validation schema for an array of locales\n *\n * @returns A schema for validating arrays of locales\n */\n get locales() {\n return z.array(this.locale);\n }\n}\n"],"names":["I18nLocaleRouteValidator","locale","z","object","id","number","int","positive","documentId","string","uuid","name","code","length","createdAt","updatedAt","publishedAt","nullable","isDefault","boolean","locales","array","strapi","_strapi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;;AAGC,IACM,MAAMA,wBAAAA,CAAAA;AAOX;;;;AAIC,MACD,IAAIC,MAAAA,GAAS;QACX,OAAOC,YAAAA,CAAEC,MAAM,CAAC;AACdC,YAAAA,EAAAA,EAAIF,YAAAA,CAAEG,MAAM,EAAA,CAAGC,GAAG,GAAGC,QAAQ,EAAA;YAC7BC,UAAAA,EAAYN,YAAAA,CAAEO,MAAM,EAAA,CAAGC,IAAI,EAAA;AAC3BC,YAAAA,IAAAA,EAAMT,aAAEO,MAAM,EAAA;AACdG,YAAAA,IAAAA,EAAMV,YAAAA,CAAEO,MAAM,EAAA,CAAGI,MAAM,CAAC,CAAA,EAAG,0CAAA,CAAA;AAC3BC,YAAAA,SAAAA,EAAWZ,aAAEO,MAAM,EAAA;AACnBM,YAAAA,SAAAA,EAAWb,aAAEO,MAAM,EAAA;YACnBO,WAAAA,EAAad,YAAAA,CAAEO,MAAM,EAAA,CAAGQ,QAAQ,EAAA;AAChCC,YAAAA,SAAAA,EAAWhB,aAAEiB,OAAO;AACtB,SAAA,CAAA;AACF,IAAA;AAEA;;;;AAIC,MACD,IAAIC,OAAAA,GAAU;AACZ,QAAA,OAAOlB,YAAAA,CAAEmB,KAAK,CAAC,IAAI,CAACpB,MAAM,CAAA;AAC5B,IAAA;AA7BA,IAAA,WAAA,CAAmBqB,MAAmB,CAAE;QACtC,IAAI,CAACC,OAAO,GAAGD,MAAAA;AACjB,IAAA;AA4BF;;;;"}
1
+ {"version":3,"file":"locale.js","sources":["../../../../server/src/routes/validation/locale.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as z from 'zod/v4';\n\n/**\n * A validator for i18n locale routes.\n *\n */\nexport class I18nLocaleRouteValidator {\n protected readonly _strapi: Core.Strapi;\n\n public constructor(strapi: Core.Strapi) {\n this._strapi = strapi;\n }\n\n /**\n * Generates a validation schema for a single locale.\n *\n * @returns A schema for validating locale objects\n */\n get locale() {\n return z.object({\n id: z.number().int().positive(),\n documentId: z.string().uuid(),\n name: z.string(),\n code: z.string().length(2, 'Locale code must be exactly 2 characters'),\n createdAt: z.string(),\n updatedAt: z.string(),\n publishedAt: z.string().nullable(),\n isDefault: z.boolean(),\n });\n }\n\n /**\n * Generates a validation schema for an array of locales\n *\n * @returns A schema for validating arrays of locales\n */\n get locales() {\n return z.array(this.locale);\n }\n}\n"],"names":["I18nLocaleRouteValidator","locale","z","object","id","number","int","positive","documentId","string","uuid","name","code","length","createdAt","updatedAt","publishedAt","nullable","isDefault","boolean","locales","array","strapi","_strapi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;AAGC,IACM,MAAMA,wBAAAA,CAAAA;AAOX;;;;AAIC,MACD,IAAIC,MAAAA,GAAS;QACX,OAAOC,YAAAA,CAAEC,MAAM,CAAC;AACdC,YAAAA,EAAAA,EAAIF,YAAAA,CAAEG,MAAM,EAAA,CAAGC,GAAG,GAAGC,QAAQ,EAAA;YAC7BC,UAAAA,EAAYN,YAAAA,CAAEO,MAAM,EAAA,CAAGC,IAAI,EAAA;AAC3BC,YAAAA,IAAAA,EAAMT,aAAEO,MAAM,EAAA;AACdG,YAAAA,IAAAA,EAAMV,YAAAA,CAAEO,MAAM,EAAA,CAAGI,MAAM,CAAC,CAAA,EAAG,0CAAA,CAAA;AAC3BC,YAAAA,SAAAA,EAAWZ,aAAEO,MAAM,EAAA;AACnBM,YAAAA,SAAAA,EAAWb,aAAEO,MAAM,EAAA;YACnBO,WAAAA,EAAad,YAAAA,CAAEO,MAAM,EAAA,CAAGQ,QAAQ,EAAA;AAChCC,YAAAA,SAAAA,EAAWhB,aAAEiB,OAAO;AACtB,SAAA,CAAA;AACF,IAAA;AAEA;;;;AAIC,MACD,IAAIC,OAAAA,GAAU;AACZ,QAAA,OAAOlB,YAAAA,CAAEmB,KAAK,CAAC,IAAI,CAACpB,MAAM,CAAA;AAC5B,IAAA;AA7BA,IAAA,WAAA,CAAmBqB,MAAmB,CAAE;QACtC,IAAI,CAACC,OAAO,GAAGD,MAAAA;AACjB,IAAA;AA4BF;;;;"}
@@ -5,6 +5,10 @@ var fp = require('lodash/fp');
5
5
  var utils = require('@strapi/utils');
6
6
  var index = require('../utils/index.js');
7
7
 
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var ___default = /*#__PURE__*/_interopDefault(_);
11
+
8
12
  const { isRelationalAttribute, getVisibleAttributes, isTypedAttribute, getScalarAttributes, getRelationalAttributes } = utils.contentTypes;
9
13
  const { ApplicationError } = utils.errors;
10
14
  const hasLocalizedOption = (modelOrAttribute)=>{
@@ -53,7 +57,7 @@ const removeIdsMut = (model, entry)=>{
53
57
  return entry;
54
58
  }
55
59
  removeId(entry);
56
- _.forEach(model.attributes, (attr, attrName)=>{
60
+ ___default.default.forEach(model.attributes, (attr, attrName)=>{
57
61
  const value = entry[attrName];
58
62
  if (attr.type === 'dynamiczone' && fp.isArray(value)) {
59
63
  value.forEach((compo)=>{
@@ -101,7 +105,7 @@ const removeIdsMut = (model, entry)=>{
101
105
  }
102
106
  const modelDef = strapi.getModel(model);
103
107
  const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);
104
- _.forEach(relatedEntryCopy, (value, field)=>{
108
+ ___default.default.forEach(relatedEntryCopy, (value, field)=>{
105
109
  if (fp.isNil(entry[field])) {
106
110
  entry[field] = value;
107
111
  }
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: any) => (entry: any) => removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (model: any, entry: any) => {\n if (isNil(entry)) {\n return entry;\n }\n\n removeId(entry);\n\n _.forEach(model.attributes, (attr, attrName) => {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n });\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (model: any, entry: any) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n _.forEach(relatedEntryCopy, (value, field) => {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n });\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any) => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","_","forEach","attr","type","isArray","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,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H,YAAAA,oBAAAA,CAAqBN,IAAI,CAAA,GAAIO,cAAAA,CAAAA;AAC/B,QAAA,CAAA,MAAO,IAAIhC,IAAAA,CAAKC,IAAI,KAAK,aAAA,EAAe;AACtCD,YAAAA,IAAAA,CAAKK,UAAU,CAACN,OAAO,CAAC,CAACoC,aAAAA,GAAAA;gBACvB,MAAMH,cAAAA,GAAiBb,yCAAAA,CAA0CgB,aAAAA,CAAAA,CAAeF,GAAG,CACjF,CAACC,UAAAA,GAAe,CAAA,EAAG9C,QAAAA,CAAS,CAAC,EAAE8C,UAAAA,CAAAA,CAAY,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAA,GAAIO,cAAAA,CAAAA;AAC/B,YAAA,CAAA,CAAA;AACF,QAAA;AACF,IAAA;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: any) => (entry: any) => removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (model: any, entry: any): Record<string, any> => {\n if (isNil(entry)) {\n return entry as unknown as Record<string, any>;\n }\n\n removeId(entry);\n\n _.forEach(model.attributes, (attr, attrName) => {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n });\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (model: any, entry: any) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n _.forEach(relatedEntryCopy, (value, field) => {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n });\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any): string[] => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","_","forEach","attr","type","isArray","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;;;;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,kBAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,OAAAA,CAAK,gCAAgCD,gBAAAA,CAAAA,KAAsB,IAAA;AACpE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,gBAAAA,CAAW,SAAA,CAAA;AAElC,IAAA,IAAIC,SAAMH,MAAAA,CAAAA,EAAS;AACjB,QAAA,OAAOC,eAAeG,gBAAgB,EAAA;AACxC,IAAA;AAEA,IAAA,MAAMC,WAAAA,GAAc,MAAMJ,cAAAA,CAAeK,UA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A;AACF,IAAA;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.mjs","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: any) => (entry: any) => removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (model: any, entry: any) => {\n if (isNil(entry)) {\n return entry;\n }\n\n removeId(entry);\n\n _.forEach(model.attributes, (attr, attrName) => {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n });\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (model: any, entry: any) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n _.forEach(relatedEntryCopy, (value, field) => {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n });\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any) => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","_","forEach","attr","type","isArray","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,cAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,IAAAA,CAAK,gCAAgCD,gBAAAA,CAAAA,KAAsB,IAAA;AACpE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,UAAAA,CAAW,SAAA,CAAA;AAElC,IAAA,IAAIC,MAAMH,MAAAA,CAAAA,EAAS;AACjB,QAAA,OAAOC,eAAeG,gBAAgB,EAAA;AACxC,IAAA;AAEA,IAAA,MAAMC,WAAAA,GAAc,MAAMJ,cAAAA,CAAeK,UAAU,CAACN,MAAAA,CAAAA;AACpD,IAAA,IAAI,CAACK,WAAAA,EAAa;AAChB,QAAA,MAAM,IAAIX,gBAAAA,CAAiB,kBAAA,CAAA;AAC7B,IAAA;IAEA,OAAOM,MAAAA;AACT,CAAA;AAEA;;;;IAKA,MAAMO,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OACEZ,kBAAAA,CAAmBY,SAAAA,CAAAA,IACnBpB,qBAAAA,CAAsBoB,SAAAA,CAAAA,IACtBlB,iBAAiBkB,SAAAA,EAAW,KAAA,CAAA;AAEhC,CAAA;AAEA;;;;IAKA,MAAMC,yBAAyB,CAACC,KAAAA,GAAAA;AAC9B,IAAA,OAAOd,kBAAAA,CAAmBc,KAAAA,CAAAA;AAC5B,CAAA;AAEA;;;;IAKA,MAA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CAAS;QACxC,IAAIY,IAAAA,CAAKC,IAAI,KAAK,WAAA,EAAa;AAC7B,YAAA,MAAM+B,cAAAA,GAAiBb,yCAAAA,CAA0CnB,IAAAA,CAAKO,SAAS,CAAA,CAAE0B,GAAG,CAClF,CAACC,UAAAA,GAAe,CAAA,EAAG9C,QAAAA,CAAS,CAAC,EAAE8C,UAAAA,CAAAA,CAAY,CAAA;AAE7CH,YAAAA,oBAAAA,CAAqBN,IAAI,CAAA,GAAIO,cAAAA,CAAAA;AAC/B,QAAA,CAAA,MAAO,IAAIhC,IAAAA,CAAKC,IAAI,KAAK,aAAA,EAAe;AACtCD,YAAAA,IAAAA,CAAKK,UAAU,CAACN,OAAO,CAAC,CAACoC,aAAAA,GAAAA;gBACvB,MAAMH,cAAAA,GAAiBb,yCAAAA,CAA0CgB,aAAAA,CAAAA,CAAeF,GAAG,CACjF,CAACC,UAAAA,GAAe,CAAA,EAAG9C,QAAAA,CAAS,CAAC,EAAE8C,UAAAA,CAAAA,CAAY,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAA,GAAIO,cAAAA,CAAAA;AAC/B,YAAA,CAAA,CAAA;AACF,QAAA;AACF,IAAA;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"content-types.mjs","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport { pick, pipe, has, prop, isNil, cloneDeep, isArray } from 'lodash/fp';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst {\n isRelationalAttribute,\n getVisibleAttributes,\n isTypedAttribute,\n getScalarAttributes,\n getRelationalAttributes,\n} = contentTypeUtils;\nconst { ApplicationError } = errors;\n\nconst hasLocalizedOption = (modelOrAttribute: any) => {\n return prop('pluginOptions.i18n.localized', modelOrAttribute) === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (isNil(locale)) {\n return localesService.getDefaultLocale();\n }\n\n const foundLocale = await localesService.findByCode(locale);\n if (!foundLocale) {\n throw new ApplicationError('Locale not found');\n }\n\n return locale;\n};\n\n/**\n * Returns whether an attribute is localized or not\n * @param {*} attribute\n * @returns\n */\nconst isLocalizedAttribute = (attribute: any) => {\n return (\n hasLocalizedOption(attribute) ||\n isRelationalAttribute(attribute) ||\n isTypedAttribute(attribute, 'uid')\n );\n};\n\n/**\n * Returns whether a model is localized or not\n * @param {*} model\n * @returns\n */\nconst isLocalizedContentType = (model: any) => {\n return hasLocalizedOption(model);\n};\n\n/**\n * Returns the list of attribute names that are not localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getNonLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter(\n (attrName) => !isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\nconst removeId = (value: any) => {\n if (typeof value === 'object' && has('id', value)) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: any) => (entry: any) => removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (model: any, entry: any): Record<string, any> => {\n if (isNil(entry)) {\n return entry as unknown as Record<string, any>;\n }\n\n removeId(entry);\n\n _.forEach(model.attributes, (attr, attrName) => {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && isArray(value)) {\n value.forEach((compo) => {\n if (has('__component', compo)) {\n const model = strapi.components[compo.__component];\n removeIdsMut(model, compo);\n }\n });\n } else if (attr.type === 'component') {\n const model = strapi.components[attr.component];\n if (isArray(value)) {\n value.forEach((compo) => removeIdsMut(model, compo));\n } else {\n removeIdsMut(model, value);\n }\n }\n });\n\n return entry;\n};\n\n/**\n * Returns a copy of an entry picking only its non localized attributes\n * @param {object} model\n * @param {object} entry\n * @returns {object}\n */\nconst copyNonLocalizedAttributes = (model: any, entry: any) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return pipe(pick(nonLocalizedAttributes), removeIds(model))(entry);\n};\n\n/**\n * Returns the list of attribute names that are localized\n * @param {object} model\n * @returns {string[]}\n */\nconst getLocalizedAttributes = (model: any) => {\n return getVisibleAttributes(model).filter((attrName) =>\n isLocalizedAttribute(model.attributes[attrName])\n );\n};\n\n/**\n * Fill non localized fields of an entry if there are nil\n * @param {Object} entry entry to fill\n * @param {Object} relatedEntry values used to fill\n * @param {Object} options\n * @param {Object} options.model corresponding model\n */\nconst fillNonLocalizedAttributes = (entry: any, relatedEntry: any, { model }: any) => {\n if (isNil(relatedEntry)) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n _.forEach(relatedEntryCopy, (value, field) => {\n if (isNil(entry[field])) {\n entry[field] = value;\n }\n });\n};\n\n/**\n * build the populate param to\n * @param {String} modelUID uid of the model, could be of a content-type or a component\n */\nconst getNestedPopulateOfNonLocalizedAttributes = (modelUID: any): string[] => {\n const schema = strapi.getModel(modelUID);\n const scalarAttributes = getScalarAttributes(schema);\n const nonLocalizedAttributes = getNonLocalizedAttributes(schema);\n\n const allAttributes = [...scalarAttributes, ...nonLocalizedAttributes];\n if (schema.modelType === 'component') {\n // When called recursively on a non localized component we\n // need to explicitly populate that components relations\n allAttributes.push(...getRelationalAttributes(schema));\n }\n\n const currentAttributesToPopulate = allAttributes.filter((value, index, self) => {\n return self.indexOf(value) === index && self.lastIndexOf(value) === index;\n });\n\n const attributesToPopulate = [...currentAttributesToPopulate];\n for (const attrName of currentAttributesToPopulate) {\n const attr = schema.attributes[attrName];\n if (attr.type === 'component') {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(attr.component).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n } else if (attr.type === 'dynamiczone') {\n attr.components.forEach((componentName) => {\n const nestedPopulate = getNestedPopulateOfNonLocalizedAttributes(componentName).map(\n (nestedAttr) => `${attrName}.${nestedAttr}`\n );\n attributesToPopulate.push(...nestedPopulate);\n });\n }\n }\n\n return attributesToPopulate;\n};\n\nconst contentTypes = () => ({\n isLocalizedContentType,\n getValidLocale,\n getLocalizedAttributes,\n getNonLocalizedAttributes,\n copyNonLocalizedAttributes,\n fillNonLocalizedAttributes,\n getNestedPopulateOfNonLocalizedAttributes,\n});\n\ntype ContentTypesService = typeof contentTypes;\n\nexport default contentTypes;\nexport { ContentTypesService };\n"],"names":["isRelationalAttribute","getVisibleAttributes","isTypedAttribute","getScalarAttributes","getRelationalAttributes","contentTypeUtils","ApplicationError","errors","hasLocalizedOption","modelOrAttribute","prop","getValidLocale","locale","localesService","getService","isNil","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","_","forEach","attr","type","isArray","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pipe","pick","getLocalizedAttributes","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","getNestedPopulateOfNonLocalizedAttributes","modelUID","schema","scalarAttributes","allAttributes","modelType","push","currentAttributesToPopulate","index","self","indexOf","lastIndexOf","attributesToPopulate","nestedPopulate","map","nestedAttr","componentName","contentTypes"],"mappings":";;;;;AAKA,MAAM,EACJA,qBAAqB,EACrBC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,cAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,MAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,IAAAA,CAAK,gCAAgCD,gBAAAA,CAAAA,KAAsB,IAAA;AACpE,CAAA;AAEA,MA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Bb,yCAAAA,CAA0CgB,aAAAA,CAAAA,CAAeF,GAAG,CACjF,CAACC,UAAAA,GAAe,CAAA,EAAG9C,QAAAA,CAAS,CAAC,EAAE8C,UAAAA,CAAAA,CAAY,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAA,GAAIO,cAAAA,CAAAA;AAC/B,YAAA,CAAA,CAAA;AACF,QAAA;AACF,IAAA;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"localizations.js","sources":["../../../server/src/services/localizations.ts"],"sourcesContent":["import { cloneDeep, isEmpty } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { getService } from '../utils';\n\n/**\n * Mutates the provided data object in place and returns the same reference\n * with populated media values replaced by their upload file IDs.\n */\nconst normalizeMediaIds = (\n schema: Schema.ContentType | Schema.Component,\n data: Record<string, any>\n) => {\n if (!schema?.attributes || !data || typeof data !== 'object') {\n return data;\n }\n\n Object.entries(schema.attributes).forEach(([attributeName, attribute]) => {\n const value = data[attributeName];\n\n if (value == null) {\n return;\n }\n\n if (attribute.type === 'media') {\n if (attribute.multiple) {\n data[attributeName] = Array.isArray(value)\n ? value.map((file: unknown) =>\n file && typeof file === 'object' && 'id' in file ? file.id : file\n )\n : value;\n } else {\n data[attributeName] =\n value && typeof value === 'object' && 'id' in value ? value.id : value;\n }\n\n return;\n }\n\n if (attribute.type === 'component') {\n const componentSchema = strapi.getModel(attribute.component);\n\n if (attribute.repeatable && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) =>\n normalizeMediaIds(componentSchema, componentValue)\n );\n } else {\n normalizeMediaIds(componentSchema, value);\n }\n\n return;\n }\n\n if (attribute.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) => {\n if (componentValue?.__component) {\n normalizeMediaIds(strapi.getModel(componentValue.__component), componentValue);\n }\n });\n }\n });\n\n return data;\n};\n\n/**\n * Update non localized fields of all the related localizations of an entry with the entry values\n */\nconst syncNonLocalizedAttributes = async (sourceEntry: any, model: Schema.ContentType) => {\n const { copyNonLocalizedAttributes } = getService('content-types');\n\n const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);\n if (isEmpty(nonLocalizedAttributes)) {\n return;\n }\n\n const normalizedNonLocalizedAttributes = normalizeMediaIds(model, nonLocalizedAttributes);\n\n const uid = model.uid;\n const documentId = sourceEntry.documentId;\n const locale = sourceEntry.locale;\n const status = sourceEntry?.publishedAt ? 'published' : 'draft';\n\n // Find all the entries that need to be updated\n // this is every other entry of the document in the same status but a different locale\n const localeEntriesToUpdate = await strapi.db.query(uid).findMany({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $ne: locale },\n },\n select: ['locale', 'id'],\n });\n\n const entryData = await strapi.documents(uid).omitComponentData(normalizedNonLocalizedAttributes);\n\n await async.map(localeEntriesToUpdate, async (entry: any) => {\n const transformedData = await strapi.documents.utils.transformData(\n cloneDeep(normalizedNonLocalizedAttributes),\n {\n uid,\n status,\n locale: entry.locale,\n allowMissingId: true,\n }\n );\n\n // Update or create non localized components for the entry\n const componentData = await strapi\n .documents(uid)\n .updateComponents(entry, transformedData as any);\n\n // Update every other locale entry of this documentId in the same status\n await strapi.db.query(uid).update({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $eq: entry.locale },\n },\n // The data we send to the update function is the entry data merged with\n // the updated component data\n data: Object.assign(cloneDeep(entryData), componentData),\n });\n });\n};\n\nconst localizations = () => ({\n syncNonLocalizedAttributes,\n});\n\ntype LocalizationsService = typeof localizations;\n\nexport default localizations;\nexport type { LocalizationsService };\n"],"names":["normalizeMediaIds","schema","data","attributes","Object","entries","forEach","attributeName","attribute","value","type","multiple","Array","isArray","map","file","id","componentSchema","strapi","getModel","component","repeatable","componentValue","__component","syncNonLocalizedAttributes","sourceEntry","model","copyNonLocalizedAttributes","getService","nonLocalizedAttributes","isEmpty","normalizedNonLocalizedAttributes","uid","documentId","locale","status","publishedAt","localeEntriesToUpdate","db","query","findMany","where","$ne","select","entryData","documents","omitComponentData","async","entry","transformedData","utils","transformData","cloneDeep","allowMissingId","componentData","updateComponents","update","$eq","assign","localizations"],"mappings":";;;;;;AAMA;;;IAIA,MAAMA,iBAAAA,GAAoB,CACxBC,MAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,IAAI,CAACD,MAAAA,EAAQE,UAAAA,IAAc,CAACD,IAAAA,IAAQ,OAAOA,SAAS,QAAA,EAAU;QAC5D,OAAOA,IAAAA;AACT,IAAA;IAEAE,MAAAA,CAAOC,OAAO,CAACJ,MAAAA,CAAOE,UAAU,CAAA,CAAEG,OAAO,CAAC,CAAC,CAACC,aAAAA,EAAeC,SAAAA,CAAU,GAAA;QACnE,MAAMC,KAAAA,GAAQP,IAAI,CAACK,aAAAA,CAAc;AAEjC,QAAA,IAAIE,SAAS,IAAA,EAAM;AACjB,YAAA;AACF,QAAA;QAEA,IAAID,SAAAA,CAAUE,IAAI,KAAK,OAAA,EAAS;YAC9B,IAAIF,SAAAA,CAAUG,QAAQ,EAAE;gBACtBT,IAAI,CAACK,cAAc,GAAGK,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,GAChCA,MAAMK,GAAG,CAAC,CAACC,IAAAA,GACTA,IAAAA,IAAQ,OAAOA,IAAAA,KAAS,QAAA,IAAY,QAAQA,IAAAA,GAAOA,IAAAA,CAAKC,EAAE,GAAGD,IAAAA,CAAAA,GAE/DN,KAAAA;YACN,CAAA,MAAO;gBACLP,IAAI,CAACK,aAAAA,CAAc,GACjBE,KAAAA,IAAS,OAAOA,KA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B,CAACP,KAAAA,EAAOC,eAAAA,CAAAA;;AAG3B,QAAA,MAAM/B,OAAOoB,EAAE,CAACC,KAAK,CAACP,GAAAA,CAAAA,CAAKwB,MAAM,CAAC;YAChCf,KAAAA,EAAO;AACLR,gBAAAA,UAAAA;AACAG,gBAAAA,WAAAA,EAAaD,WAAW,WAAA,GAAc;oBAAEO,GAAAA,EAAK;iBAAK,GAAI,IAAA;gBACtDR,MAAAA,EAAQ;AAAEuB,oBAAAA,GAAAA,EAAKT,MAAMd;AAAO;AAC9B,aAAA;;;AAGAhC,YAAAA,IAAAA,EAAME,MAAAA,CAAOsD,MAAM,CAACN,YAAAA,CAAUR,SAAAA,CAAAA,EAAYU,aAAAA;AAC5C,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;AAEA,MAAMK,aAAAA,GAAgB,KAAO;AAC3BnC,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"localizations.js","sources":["../../../server/src/services/localizations.ts"],"sourcesContent":["import { cloneDeep, isEmpty } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { getService } from '../utils';\n\n/**\n * Mutates the provided data object in place and returns the same reference\n * with populated media values replaced by their upload file IDs.\n */\nconst normalizeMediaIds = (\n schema: Schema.ContentType | Schema.Component,\n data: Record<string, any>\n): Record<string, any> => {\n if (!schema?.attributes || !data || typeof data !== 'object') {\n return data;\n }\n\n Object.entries(schema.attributes).forEach(([attributeName, attribute]) => {\n const value = data[attributeName];\n\n if (value == null) {\n return;\n }\n\n if (attribute.type === 'media') {\n if (attribute.multiple) {\n data[attributeName] = Array.isArray(value)\n ? value.map((file: unknown) =>\n file && typeof file === 'object' && 'id' in file ? file.id : file\n )\n : value;\n } else {\n data[attributeName] =\n value && typeof value === 'object' && 'id' in value ? value.id : value;\n }\n\n return;\n }\n\n if (attribute.type === 'component') {\n const componentSchema = strapi.getModel(attribute.component);\n\n if (attribute.repeatable && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) =>\n normalizeMediaIds(componentSchema, componentValue)\n );\n } else {\n normalizeMediaIds(componentSchema, value);\n }\n\n return;\n }\n\n if (attribute.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) => {\n if (componentValue?.__component) {\n normalizeMediaIds(strapi.getModel(componentValue.__component), componentValue);\n }\n });\n }\n });\n\n return data;\n};\n\n/**\n * Update non localized fields of all the related localizations of an entry with the entry values\n */\nconst syncNonLocalizedAttributes = async (sourceEntry: any, model: Schema.ContentType) => {\n const { copyNonLocalizedAttributes } = getService('content-types');\n\n const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);\n if (isEmpty(nonLocalizedAttributes)) {\n return;\n }\n\n const normalizedNonLocalizedAttributes = normalizeMediaIds(model, nonLocalizedAttributes);\n\n const uid = model.uid;\n const documentId = sourceEntry.documentId;\n const locale = sourceEntry.locale;\n const status = sourceEntry?.publishedAt ? 'published' : 'draft';\n\n // Find all the entries that need to be updated\n // this is every other entry of the document in the same status but a different locale\n const localeEntriesToUpdate = await strapi.db.query(uid).findMany({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $ne: locale },\n },\n select: ['locale', 'id'],\n });\n\n const entryData = await strapi.documents(uid).omitComponentData(normalizedNonLocalizedAttributes);\n\n await async.map(localeEntriesToUpdate, async (entry: any) => {\n const transformedData = await strapi.documents.utils.transformData(\n cloneDeep(normalizedNonLocalizedAttributes),\n {\n uid,\n status,\n locale: entry.locale,\n allowMissingId: true,\n }\n );\n\n // Update or create non localized components for the entry\n const componentData = await strapi\n .documents(uid)\n .updateComponents(entry, transformedData as any);\n\n // Update every other locale entry of this documentId in the same status\n await strapi.db.query(uid).update({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $eq: entry.locale },\n },\n // The data we send to the update function is the entry data merged with\n // the updated component data\n data: Object.assign(cloneDeep(entryData), componentData),\n });\n });\n};\n\nconst localizations = () => ({\n syncNonLocalizedAttributes,\n});\n\ntype LocalizationsService = typeof localizations;\n\nexport default localizations;\nexport type { LocalizationsService };\n"],"names":["normalizeMediaIds","schema","data","attributes","Object","entries","forEach","attributeName","attribute","value","type","multiple","Array","isArray","map","file","id","componentSchema","strapi","getModel","component","repeatable","componentValue","__component","syncNonLocalizedAttributes","sourceEntry","model","copyNonLocalizedAttributes","getService","nonLocalizedAttributes","isEmpty","normalizedNonLocalizedAttributes","uid","documentId","locale","status","publishedAt","localeEntriesToUpdate","db","query","findMany","where","$ne","select","entryData","documents","omitComponentData","async","entry","transformedData","utils","transformData","cloneDeep","allowMissingId","componentData","updateComponents","update","$eq","assign","localizations"],"mappings":";;;;;;AAMA;;;IAIA,MAAMA,iBAAAA,GAAoB,CACxBC,MAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,IAAI,CAACD,MAAAA,EAAQE,UAAAA,IAAc,CAACD,IAAAA,IAAQ,OAAOA,SAAS,QAAA,EAAU;QAC5D,OAAOA,IAAAA;AACT,IAAA;IAEAE,MAAAA,CAAOC,OAAO,CAACJ,MAAAA,CAAOE,UAAU,CAAA,CAAEG,OAAO,CAAC,CAAC,CAACC,aAAAA,EAAeC,SAAAA,CAAU,GAAA;QACnE,MAAMC,KAAAA,GAAQP,IAAI,CAACK,aAAAA,CAAc;AAEjC,QAAA,IAAIE,SAAS,IAAA,EAAM;AACjB,YAAA;AACF,QAAA;QAEA,IAAID,SAAAA,CAAUE,IAAI,KAAK,OAAA,EAAS;YAC9B,IAAIF,SAAAA,CAAUG,QAAQ,EAAE;gBACtBT,IAAI,CAACK,cAAc,GAAGK,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,GAChCA,MAAMK,GAAG,CAAC,CAACC,IAAAA,GACTA,IAAAA,IAAQ,OAAOA,IAAAA,KAAS,QAAA,IAAY,QAAQA,IAAAA,GAAOA,IAAAA,CAAKC,EAAE,GAAGD,IAAAA,CAAAA,GAE/DN,KAAAA;YACN,CAAA,M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gB,MAAMpC,MAAAA,CACzB2B,SAAS,CAACb,GAAAA,CAAAA,CACVuB,gBAAgB,CAACP,KAAAA,EAAOC,eAAAA,CAAAA;;AAG3B,QAAA,MAAM/B,OAAOoB,EAAE,CAACC,KAAK,CAACP,GAAAA,CAAAA,CAAKwB,MAAM,CAAC;YAChCf,KAAAA,EAAO;AACLR,gBAAAA,UAAAA;AACAG,gBAAAA,WAAAA,EAAaD,WAAW,WAAA,GAAc;oBAAEO,GAAAA,EAAK;iBAAK,GAAI,IAAA;gBACtDR,MAAAA,EAAQ;AAAEuB,oBAAAA,GAAAA,EAAKT,MAAMd;AAAO;AAC9B,aAAA;;;AAGAhC,YAAAA,IAAAA,EAAME,MAAAA,CAAOsD,MAAM,CAACN,YAAAA,CAAUR,SAAAA,CAAAA,EAAYU,aAAAA;AAC5C,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;AAEA,MAAMK,aAAAA,GAAgB,KAAO;AAC3BnC,QAAAA;KACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"localizations.mjs","sources":["../../../server/src/services/localizations.ts"],"sourcesContent":["import { cloneDeep, isEmpty } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { getService } from '../utils';\n\n/**\n * Mutates the provided data object in place and returns the same reference\n * with populated media values replaced by their upload file IDs.\n */\nconst normalizeMediaIds = (\n schema: Schema.ContentType | Schema.Component,\n data: Record<string, any>\n) => {\n if (!schema?.attributes || !data || typeof data !== 'object') {\n return data;\n }\n\n Object.entries(schema.attributes).forEach(([attributeName, attribute]) => {\n const value = data[attributeName];\n\n if (value == null) {\n return;\n }\n\n if (attribute.type === 'media') {\n if (attribute.multiple) {\n data[attributeName] = Array.isArray(value)\n ? value.map((file: unknown) =>\n file && typeof file === 'object' && 'id' in file ? file.id : file\n )\n : value;\n } else {\n data[attributeName] =\n value && typeof value === 'object' && 'id' in value ? value.id : value;\n }\n\n return;\n }\n\n if (attribute.type === 'component') {\n const componentSchema = strapi.getModel(attribute.component);\n\n if (attribute.repeatable && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) =>\n normalizeMediaIds(componentSchema, componentValue)\n );\n } else {\n normalizeMediaIds(componentSchema, value);\n }\n\n return;\n }\n\n if (attribute.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) => {\n if (componentValue?.__component) {\n normalizeMediaIds(strapi.getModel(componentValue.__component), componentValue);\n }\n });\n }\n });\n\n return data;\n};\n\n/**\n * Update non localized fields of all the related localizations of an entry with the entry values\n */\nconst syncNonLocalizedAttributes = async (sourceEntry: any, model: Schema.ContentType) => {\n const { copyNonLocalizedAttributes } = getService('content-types');\n\n const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);\n if (isEmpty(nonLocalizedAttributes)) {\n return;\n }\n\n const normalizedNonLocalizedAttributes = normalizeMediaIds(model, nonLocalizedAttributes);\n\n const uid = model.uid;\n const documentId = sourceEntry.documentId;\n const locale = sourceEntry.locale;\n const status = sourceEntry?.publishedAt ? 'published' : 'draft';\n\n // Find all the entries that need to be updated\n // this is every other entry of the document in the same status but a different locale\n const localeEntriesToUpdate = await strapi.db.query(uid).findMany({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $ne: locale },\n },\n select: ['locale', 'id'],\n });\n\n const entryData = await strapi.documents(uid).omitComponentData(normalizedNonLocalizedAttributes);\n\n await async.map(localeEntriesToUpdate, async (entry: any) => {\n const transformedData = await strapi.documents.utils.transformData(\n cloneDeep(normalizedNonLocalizedAttributes),\n {\n uid,\n status,\n locale: entry.locale,\n allowMissingId: true,\n }\n );\n\n // Update or create non localized components for the entry\n const componentData = await strapi\n .documents(uid)\n .updateComponents(entry, transformedData as any);\n\n // Update every other locale entry of this documentId in the same status\n await strapi.db.query(uid).update({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $eq: entry.locale },\n },\n // The data we send to the update function is the entry data merged with\n // the updated component data\n data: Object.assign(cloneDeep(entryData), componentData),\n });\n });\n};\n\nconst localizations = () => ({\n syncNonLocalizedAttributes,\n});\n\ntype LocalizationsService = typeof localizations;\n\nexport default localizations;\nexport type { LocalizationsService };\n"],"names":["normalizeMediaIds","schema","data","attributes","Object","entries","forEach","attributeName","attribute","value","type","multiple","Array","isArray","map","file","id","componentSchema","strapi","getModel","component","repeatable","componentValue","__component","syncNonLocalizedAttributes","sourceEntry","model","copyNonLocalizedAttributes","getService","nonLocalizedAttributes","isEmpty","normalizedNonLocalizedAttributes","uid","documentId","locale","status","publishedAt","localeEntriesToUpdate","db","query","findMany","where","$ne","select","entryData","documents","omitComponentData","async","entry","transformedData","utils","transformData","cloneDeep","allowMissingId","componentData","updateComponents","update","$eq","assign","localizations"],"mappings":";;;;AAMA;;;IAIA,MAAMA,iBAAAA,GAAoB,CACxBC,MAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,IAAI,CAACD,MAAAA,EAAQE,UAAAA,IAAc,CAACD,IAAAA,IAAQ,OAAOA,SAAS,QAAA,EAAU;QAC5D,OAAOA,IAAAA;AACT,IAAA;IAEAE,MAAAA,CAAOC,OAAO,CAACJ,MAAAA,CAAOE,UAAU,CAAA,CAAEG,OAAO,CAAC,CAAC,CAACC,aAAAA,EAAeC,SAAAA,CAAU,GAAA;QACnE,MAAMC,KAAAA,GAAQP,IAAI,CAACK,aAAAA,CAAc;AAEjC,QAAA,IAAIE,SAAS,IAAA,EAAM;AACjB,YAAA;AACF,QAAA;QAEA,IAAID,SAAAA,CAAUE,IAAI,KAAK,OAAA,EAAS;YAC9B,IAAIF,SAAAA,CAAUG,QAAQ,EAAE;gBACtBT,IAAI,CAACK,cAAc,GAAGK,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,GAChCA,MAAMK,GAAG,CAAC,CAACC,IAAAA,GACTA,IAAAA,IAAQ,OAAOA,IAAAA,KAAS,QAAA,IAAY,QAAQA,IAAAA,GAAO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AAM;YACpBmB,cAAAA,EAAgB;AAClB,SAAA,CAAA;;QAIF,MAAMC,aAAAA,GAAgB,MAAMpC,MAAAA,CACzB2B,SAAS,CAACb,GAAAA,CAAAA,CACVuB,gBAAgB,CAACP,KAAAA,EAAOC,eAAAA,CAAAA;;AAG3B,QAAA,MAAM/B,OAAOoB,EAAE,CAACC,KAAK,CAACP,GAAAA,CAAAA,CAAKwB,MAAM,CAAC;YAChCf,KAAAA,EAAO;AACLR,gBAAAA,UAAAA;AACAG,gBAAAA,WAAAA,EAAaD,WAAW,WAAA,GAAc;oBAAEO,GAAAA,EAAK;iBAAK,GAAI,IAAA;gBACtDR,MAAAA,EAAQ;AAAEuB,oBAAAA,GAAAA,EAAKT,MAAMd;AAAO;AAC9B,aAAA;;;AAGAhC,YAAAA,IAAAA,EAAME,MAAAA,CAAOsD,MAAM,CAACN,SAAAA,CAAUR,SAAAA,CAAAA,EAAYU,aAAAA;AAC5C,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;AAEA,MAAMK,aAAAA,GAAgB,KAAO;AAC3BnC,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"localizations.mjs","sources":["../../../server/src/services/localizations.ts"],"sourcesContent":["import { cloneDeep, isEmpty } from 'lodash/fp';\n\nimport type { Schema } from '@strapi/types';\nimport { async } from '@strapi/utils';\nimport { getService } from '../utils';\n\n/**\n * Mutates the provided data object in place and returns the same reference\n * with populated media values replaced by their upload file IDs.\n */\nconst normalizeMediaIds = (\n schema: Schema.ContentType | Schema.Component,\n data: Record<string, any>\n): Record<string, any> => {\n if (!schema?.attributes || !data || typeof data !== 'object') {\n return data;\n }\n\n Object.entries(schema.attributes).forEach(([attributeName, attribute]) => {\n const value = data[attributeName];\n\n if (value == null) {\n return;\n }\n\n if (attribute.type === 'media') {\n if (attribute.multiple) {\n data[attributeName] = Array.isArray(value)\n ? value.map((file: unknown) =>\n file && typeof file === 'object' && 'id' in file ? file.id : file\n )\n : value;\n } else {\n data[attributeName] =\n value && typeof value === 'object' && 'id' in value ? value.id : value;\n }\n\n return;\n }\n\n if (attribute.type === 'component') {\n const componentSchema = strapi.getModel(attribute.component);\n\n if (attribute.repeatable && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) =>\n normalizeMediaIds(componentSchema, componentValue)\n );\n } else {\n normalizeMediaIds(componentSchema, value);\n }\n\n return;\n }\n\n if (attribute.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((componentValue: Record<string, any>) => {\n if (componentValue?.__component) {\n normalizeMediaIds(strapi.getModel(componentValue.__component), componentValue);\n }\n });\n }\n });\n\n return data;\n};\n\n/**\n * Update non localized fields of all the related localizations of an entry with the entry values\n */\nconst syncNonLocalizedAttributes = async (sourceEntry: any, model: Schema.ContentType) => {\n const { copyNonLocalizedAttributes } = getService('content-types');\n\n const nonLocalizedAttributes = copyNonLocalizedAttributes(model, sourceEntry);\n if (isEmpty(nonLocalizedAttributes)) {\n return;\n }\n\n const normalizedNonLocalizedAttributes = normalizeMediaIds(model, nonLocalizedAttributes);\n\n const uid = model.uid;\n const documentId = sourceEntry.documentId;\n const locale = sourceEntry.locale;\n const status = sourceEntry?.publishedAt ? 'published' : 'draft';\n\n // Find all the entries that need to be updated\n // this is every other entry of the document in the same status but a different locale\n const localeEntriesToUpdate = await strapi.db.query(uid).findMany({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $ne: locale },\n },\n select: ['locale', 'id'],\n });\n\n const entryData = await strapi.documents(uid).omitComponentData(normalizedNonLocalizedAttributes);\n\n await async.map(localeEntriesToUpdate, async (entry: any) => {\n const transformedData = await strapi.documents.utils.transformData(\n cloneDeep(normalizedNonLocalizedAttributes),\n {\n uid,\n status,\n locale: entry.locale,\n allowMissingId: true,\n }\n );\n\n // Update or create non localized components for the entry\n const componentData = await strapi\n .documents(uid)\n .updateComponents(entry, transformedData as any);\n\n // Update every other locale entry of this documentId in the same status\n await strapi.db.query(uid).update({\n where: {\n documentId,\n publishedAt: status === 'published' ? { $ne: null } : null,\n locale: { $eq: entry.locale },\n },\n // The data we send to the update function is the entry data merged with\n // the updated component data\n data: Object.assign(cloneDeep(entryData), componentData),\n });\n });\n};\n\nconst localizations = () => ({\n syncNonLocalizedAttributes,\n});\n\ntype LocalizationsService = typeof localizations;\n\nexport default localizations;\nexport type { LocalizationsService };\n"],"names":["normalizeMediaIds","schema","data","attributes","Object","entries","forEach","attributeName","attribute","value","type","multiple","Array","isArray","map","file","id","componentSchema","strapi","getModel","component","repeatable","componentValue","__component","syncNonLocalizedAttributes","sourceEntry","model","copyNonLocalizedAttributes","getService","nonLocalizedAttributes","isEmpty","normalizedNonLocalizedAttributes","uid","documentId","locale","status","publishedAt","localeEntriesToUpdate","db","query","findMany","where","$ne","select","entryData","documents","omitComponentData","async","entry","transformedData","utils","transformData","cloneDeep","allowMissingId","componentData","updateComponents","update","$eq","assign","localizations"],"mappings":";;;;AAMA;;;IAIA,MAAMA,iBAAAA,GAAoB,CACxBC,MAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,IAAI,CAACD,MAAAA,EAAQE,UAAAA,IAAc,CAACD,IAAAA,IAAQ,OAAOA,SAAS,QAAA,EAAU;QAC5D,OAAOA,IAAAA;AACT,IAAA;IAEAE,MAAAA,CAAOC,OAAO,CAACJ,MAAAA,CAAOE,UAAU,CAAA,CAAEG,OAAO,CAAC,CAAC,CAACC,aAAAA,EAAeC,SAAAA,CAAU,GAAA;QACnE,MAAMC,KAAAA,GAAQP,IAAI,CAACK,aAAAA,CAAc;AAEjC,QAAA,IAAIE,SAAS,IAAA,EAAM;AACjB,YAAA;AACF,QAAA;QAEA,IAAID,SAAAA,CAAUE,IAAI,KAAK,OAAA,EAAS;YAC9B,IAAIF,SAAAA,CAAUG,QAAQ,EAAE;gBACtBT,IAAI,CAACK,cAAc,GAAGK,KAAAA,CAAMC,OAAO,CAACJ,KAAAA,CAAAA,GAChCA,MAAMK,GAAG,CAAC,CAACC,IAAAA,GACTA,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A,GAAAA;AACAG,YAAAA,MAAAA;AACAD,YAAAA,MAAAA,EAAQc,MAAMd,MAAM;YACpBmB,cAAAA,EAAgB;AAClB,SAAA,CAAA;;QAIF,MAAMC,aAAAA,GAAgB,MAAMpC,MAAAA,CACzB2B,SAAS,CAACb,GAAAA,CAAAA,CACVuB,gBAAgB,CAACP,KAAAA,EAAOC,eAAAA,CAAAA;;AAG3B,QAAA,MAAM/B,OAAOoB,EAAE,CAACC,KAAK,CAACP,GAAAA,CAAAA,CAAKwB,MAAM,CAAC;YAChCf,KAAAA,EAAO;AACLR,gBAAAA,UAAAA;AACAG,gBAAAA,WAAAA,EAAaD,WAAW,WAAA,GAAc;oBAAEO,GAAAA,EAAK;iBAAK,GAAI,IAAA;gBACtDR,MAAAA,EAAQ;AAAEuB,oBAAAA,GAAAA,EAAKT,MAAMd;AAAO;AAC9B,aAAA;;;AAGAhC,YAAAA,IAAAA,EAAME,MAAAA,CAAOsD,MAAM,CAACN,SAAAA,CAAUR,SAAAA,CAAAA,EAAYU,aAAAA;AAC5C,SAAA,CAAA;AACF,IAAA,CAAA,CAAA;AACF,CAAA;AAEA,MAAMK,aAAAA,GAAgB,KAAO;AAC3BnC,QAAAA;KACF;;;;"}
@@ -153,7 +153,7 @@ declare const _default: () => {
153
153
  getValidLocale: (locale: any) => Promise<any>;
154
154
  getLocalizedAttributes: (model: any) => string[];
155
155
  getNonLocalizedAttributes: (model: any) => string[];
156
- copyNonLocalizedAttributes: (model: any, entry: any) => any;
156
+ copyNonLocalizedAttributes: (model: any, entry: any) => Record<string, any>;
157
157
  fillNonLocalizedAttributes: (entry: any, relatedEntry: any, { model }: any) => void;
158
158
  getNestedPopulateOfNonLocalizedAttributes: (modelUID: any) => string[];
159
159
  };
@@ -3,7 +3,7 @@ declare const contentTypes: () => {
3
3
  getValidLocale: (locale: any) => Promise<any>;
4
4
  getLocalizedAttributes: (model: any) => string[];
5
5
  getNonLocalizedAttributes: (model: any) => string[];
6
- copyNonLocalizedAttributes: (model: any, entry: any) => any;
6
+ copyNonLocalizedAttributes: (model: any, entry: any) => Record<string, any>;
7
7
  fillNonLocalizedAttributes: (entry: any, relatedEntry: any, { model }: any) => void;
8
8
  getNestedPopulateOfNonLocalizedAttributes: (modelUID: any) => string[];
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/services/content-types.ts"],"names":[],"mappings":"AA6LA,QAAA,MAAM,YAAY;oCA1IqB,GAAG;6BAjCJ,GAAG;oCAsGF,GAAG;uCA5DA,GAAG;wCAiDF,GAAG,SAAS,GAAG;wCAwBf,GAAG,gBAAgB,GAAG,aAAa,GAAG;0DAmBpB,GAAG;CA6C9D,CAAC;AAEH,KAAK,mBAAmB,GAAG,OAAO,YAAY,CAAC;AAE/C,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/services/content-types.ts"],"names":[],"mappings":"AA6LA,QAAA,MAAM,YAAY;oCA1IqB,GAAG;6BAjCJ,GAAG;oCAsGF,GAAG;uCA5DA,GAAG;wCAiDF,GAAG,SAAS,GAAG;wCAwBf,GAAG,gBAAgB,GAAG,aAAa,GAAG;0DAmBpB,GAAG,KAAG,MAAM,EAAE;CA6CzE,CAAC;AAEH,KAAK,mBAAmB,GAAG,OAAO,YAAY,CAAC;AAE/C,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -72,7 +72,7 @@ declare const _default: {
72
72
  getValidLocale: (locale: any) => Promise<any>;
73
73
  getLocalizedAttributes: (model: any) => string[];
74
74
  getNonLocalizedAttributes: (model: any) => string[];
75
- copyNonLocalizedAttributes: (model: any, entry: any) => any;
75
+ copyNonLocalizedAttributes: (model: any, entry: any) => Record<string, any>;
76
76
  fillNonLocalizedAttributes: (entry: any, relatedEntry: any, { model }: any) => void;
77
77
  getNestedPopulateOfNonLocalizedAttributes: (modelUID: any) => string[];
78
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/i18n",
3
- "version": "5.48.1",
3
+ "version": "5.49.0",
4
4
  "description": "Create read and update content in different languages, both from the Admin Panel and from the API",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -63,7 +63,7 @@
63
63
  "@reduxjs/toolkit": "1.9.7",
64
64
  "@strapi/design-system": "2.2.0",
65
65
  "@strapi/icons": "2.2.0",
66
- "@strapi/utils": "5.48.1",
66
+ "@strapi/utils": "5.49.0",
67
67
  "lodash": "4.18.1",
68
68
  "qs": "6.15.2",
69
69
  "react-intl": "6.6.2",
@@ -72,11 +72,11 @@
72
72
  "zod": "3.25.67"
73
73
  },
74
74
  "devDependencies": {
75
- "@strapi/admin": "5.48.1",
76
- "@strapi/admin-test-utils": "5.48.1",
77
- "@strapi/content-manager": "5.48.1",
78
- "@strapi/database": "5.48.1",
79
- "@strapi/types": "5.48.1",
75
+ "@strapi/admin": "5.49.0",
76
+ "@strapi/admin-test-utils": "5.49.0",
77
+ "@strapi/content-manager": "5.49.0",
78
+ "@strapi/database": "5.49.0",
79
+ "@strapi/types": "5.49.0",
80
80
  "@testing-library/react": "16.3.2",
81
81
  "@testing-library/user-event": "14.6.1",
82
82
  "koa": "2.16.4",