@strapi/i18n 5.61.1 → 5.62.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.
- package/dist/admin/components/CMHeaderActions.js +153 -0
- package/dist/admin/components/CMHeaderActions.js.map +1 -1
- package/dist/admin/components/CMHeaderActions.mjs +155 -3
- package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
- package/dist/admin/components/CreateLocale.js +1 -1
- package/dist/admin/components/CreateLocale.js.map +1 -1
- package/dist/admin/components/CreateLocale.mjs +2 -2
- package/dist/admin/components/CreateLocale.mjs.map +1 -1
- package/dist/admin/components/EditLocale.js +1 -1
- package/dist/admin/components/EditLocale.js.map +1 -1
- package/dist/admin/components/EditLocale.mjs +2 -2
- package/dist/admin/components/EditLocale.mjs.map +1 -1
- package/dist/admin/contentManagerHooks/editView.js +82 -16
- package/dist/admin/contentManagerHooks/editView.js.map +1 -1
- package/dist/admin/contentManagerHooks/editView.mjs +83 -18
- package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/src/components/CMHeaderActions.d.ts +20 -1
- package/dist/admin/src/components/tests/UnlockSharedFieldsAction.test.d.ts +1 -0
- package/dist/admin/src/contentManagerHooks/editView.d.ts +9 -2
- package/dist/admin/translations/en.json.js +9 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +9 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/bootstrap.js +16 -5
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +16 -5
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/services/ai-localizations.js +6 -1
- package/dist/server/services/ai-localizations.js.map +1 -1
- package/dist/server/services/ai-localizations.mjs +6 -1
- package/dist/server/services/ai-localizations.mjs.map +1 -1
- package/dist/server/services/content-types.js +21 -2
- package/dist/server/services/content-types.js.map +1 -1
- package/dist/server/services/content-types.mjs +21 -2
- package/dist/server/services/content-types.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +1 -1
- package/dist/server/src/services/ai-localizations.d.ts.map +1 -1
- package/dist/server/src/services/content-types.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -1
- package/dist/server/src/services/sanitize/index.d.ts +1 -1
- package/dist/server/src/utils/non-localized-original-data.d.ts +23 -0
- package/dist/server/src/utils/non-localized-original-data.d.ts.map +1 -0
- package/dist/server/utils/non-localized-original-data.js +29 -0
- package/dist/server/utils/non-localized-original-data.js.map +1 -0
- package/dist/server/utils/non-localized-original-data.mjs +27 -0
- package/dist/server/utils/non-localized-original-data.mjs.map +1 -0
- package/package.json +11 -11
|
@@ -86,6 +86,7 @@ const removeIdsMut = (model, entry)=>{
|
|
|
86
86
|
*/ const getLocalizedAttributes = (model)=>{
|
|
87
87
|
return getVisibleAttributes(model).filter((attrName)=>isLocalizedAttribute(model.attributes[attrName]));
|
|
88
88
|
};
|
|
89
|
+
const isPresentObject = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
89
90
|
/**
|
|
90
91
|
* Fill non localized fields of an entry if there are nil
|
|
91
92
|
* @param {Object} entry entry to fill
|
|
@@ -93,14 +94,32 @@ const removeIdsMut = (model, entry)=>{
|
|
|
93
94
|
* @param {Object} options
|
|
94
95
|
* @param {Object} options.model corresponding model
|
|
95
96
|
*/ const fillNonLocalizedAttributes = (entry, relatedEntry, { model })=>{
|
|
96
|
-
if (relatedEntry == null) {
|
|
97
|
+
if (relatedEntry == null || entry == null) {
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
100
|
const modelDef = strapi.getModel(model);
|
|
101
|
+
if (!modelDef) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
100
104
|
const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);
|
|
101
105
|
for (const [field, value] of Object.entries(relatedEntryCopy)){
|
|
102
|
-
|
|
106
|
+
const attr = modelDef.attributes?.[field];
|
|
107
|
+
// Empty arrays are the admin create-locale default for required repeatable
|
|
108
|
+
// components and dynamic zones. Other array-valued fields, such as JSON and
|
|
109
|
+
// multiple media, may be intentionally cleared and must remain untouched.
|
|
110
|
+
const isEmptyComponentValue = Array.isArray(entry[field]) && entry[field].length === 0 && (attr?.type === 'component' && attr.repeatable || attr?.type === 'dynamiczone');
|
|
111
|
+
const isUnset = entry[field] == null || isEmptyComponentValue;
|
|
112
|
+
if (isUnset) {
|
|
103
113
|
entry[field] = value;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// A present-but-shallow non-repeatable component (nested keys omitted or [])
|
|
117
|
+
// must still inherit those nested values. Otherwise saving a secondary locale
|
|
118
|
+
// syncs the shallow object to every locale and wipes nested data.
|
|
119
|
+
if (attr?.type === 'component' && !attr.repeatable && isPresentObject(entry[field]) && isPresentObject(value)) {
|
|
120
|
+
fillNonLocalizedAttributes(entry[field], value, {
|
|
121
|
+
model: attr.component
|
|
122
|
+
});
|
|
104
123
|
}
|
|
105
124
|
}
|
|
106
125
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.mjs","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import { get, has, cloneDeep, pick } from 'lodash';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\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 get(modelOrAttribute, 'pluginOptions.i18n.localized') === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (locale == null) {\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(value, 'id')) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: Struct.ComponentSchema | Struct.ContentTypeSchema) => (entry: any) =>\n removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n): Record<string, any> => {\n if (entry == null) {\n return entry as unknown as Record<string, any>;\n }\n\n removeId(entry);\n\n for (const [attrName, attr] of Object.entries(model.attributes)) {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((compo) => {\n if (has(compo, '__component')) {\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 (Array.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 = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return removeIds(model)(pick(entry, nonLocalizedAttributes));\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 (relatedEntry == null) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n for (const [field, value] of Object.entries(relatedEntryCopy)) {\n if (entry[field] == null) {\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","get","getValidLocale","locale","localesService","getService","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","attr","Object","entries","type","Array","isArray","forEach","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","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,GAAAA,CAAID,kBAAkB,8BAAA,CAAA,KAAoC,IAAA;AACnE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,UAAAA,CAAW,SAAA,CAAA;AAElC,IAA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A,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;AAC1BrD,QAAAA,sBAAAA;AACAT,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA3B,QAAAA,yBAAAA;AACAwB,QAAAA,0BAAAA;AACAI,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
|
|
1
|
+
{"version":3,"file":"content-types.mjs","sources":["../../../server/src/services/content-types.ts"],"sourcesContent":["import { get, has, cloneDeep, pick } from 'lodash';\nimport { errors, contentTypes as contentTypeUtils } from '@strapi/utils';\nimport type { Struct } from '@strapi/types';\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 get(modelOrAttribute, 'pluginOptions.i18n.localized') === true;\n};\n\nconst getValidLocale = async (locale: any) => {\n const localesService = getService('locales');\n\n if (locale == null) {\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(value, 'id')) {\n delete value.id;\n }\n};\n\nconst removeIds = (model: Struct.ComponentSchema | Struct.ContentTypeSchema) => (entry: any) =>\n removeIdsMut(model, cloneDeep(entry));\n\nconst removeIdsMut = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n): Record<string, any> => {\n if (entry == null) {\n return entry as unknown as Record<string, any>;\n }\n\n removeId(entry);\n\n for (const [attrName, attr] of Object.entries(model.attributes)) {\n const value = entry[attrName];\n if (attr.type === 'dynamiczone' && Array.isArray(value)) {\n value.forEach((compo) => {\n if (has(compo, '__component')) {\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 (Array.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 = (\n model: Struct.ComponentSchema | Struct.ContentTypeSchema,\n entry: any\n) => {\n const nonLocalizedAttributes = getNonLocalizedAttributes(model);\n\n return removeIds(model)(pick(entry, nonLocalizedAttributes));\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\nconst isPresentObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\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 (relatedEntry == null || entry == null) {\n return;\n }\n\n const modelDef = strapi.getModel(model);\n if (!modelDef) {\n return;\n }\n\n const relatedEntryCopy = copyNonLocalizedAttributes(modelDef, relatedEntry);\n\n for (const [field, value] of Object.entries(relatedEntryCopy)) {\n const attr = modelDef.attributes?.[field];\n // Empty arrays are the admin create-locale default for required repeatable\n // components and dynamic zones. Other array-valued fields, such as JSON and\n // multiple media, may be intentionally cleared and must remain untouched.\n const isEmptyComponentValue =\n Array.isArray(entry[field]) &&\n entry[field].length === 0 &&\n ((attr?.type === 'component' && attr.repeatable) || attr?.type === 'dynamiczone');\n const isUnset = entry[field] == null || isEmptyComponentValue;\n\n if (isUnset) {\n entry[field] = value;\n continue;\n }\n\n // A present-but-shallow non-repeatable component (nested keys omitted or [])\n // must still inherit those nested values. Otherwise saving a secondary locale\n // syncs the shallow object to every locale and wipes nested data.\n if (\n attr?.type === 'component' &&\n !attr.repeatable &&\n isPresentObject(entry[field]) &&\n isPresentObject(value)\n ) {\n fillNonLocalizedAttributes(entry[field], value, { model: attr.component });\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","get","getValidLocale","locale","localesService","getService","getDefaultLocale","foundLocale","findByCode","isLocalizedAttribute","attribute","isLocalizedContentType","model","getNonLocalizedAttributes","filter","attrName","attributes","removeId","value","has","id","removeIds","entry","removeIdsMut","cloneDeep","attr","Object","entries","type","Array","isArray","forEach","compo","strapi","components","__component","component","copyNonLocalizedAttributes","nonLocalizedAttributes","pick","getLocalizedAttributes","isPresentObject","fillNonLocalizedAttributes","relatedEntry","modelDef","getModel","relatedEntryCopy","field","isEmptyComponentValue","length","repeatable","isUnset","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,GAAAA,CAAID,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AA;AACF,QAAA;AACF,IAAA;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1B1D,QAAAA,sBAAAA;AACAT,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA3B,QAAAA,yBAAAA;AACAwB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAU,QAAAA;KACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":";AAkGA,wBAwCE"}
|
|
@@ -145,7 +145,7 @@ declare const _default: () => {
|
|
|
145
145
|
sanitize: ({ strapi }: {
|
|
146
146
|
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
147
147
|
}) => {
|
|
148
|
-
sanitizeLocalizationFields: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct/schema.js").ContentTypeSchema | import("@strapi/types/dist/struct/schema.js").ComponentSchema, import("@strapi/types/dist/data/entity.js").Entity<import("@strapi/types/dist/uid/index.js").Schema, string>, Promise<import("@strapi/utils/dist/types").
|
|
148
|
+
sanitizeLocalizationFields: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct/schema.js").ContentTypeSchema | import("@strapi/types/dist/struct/schema.js").ComponentSchema, import("@strapi/types/dist/data/entity.js").Entity<import("@strapi/types/dist/uid/index.js").Schema, string>, Promise<import("@strapi/utils/dist/types").Entry>>;
|
|
149
149
|
};
|
|
150
150
|
'iso-locales': () => {
|
|
151
151
|
getIsoLocales: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-localizations.d.ts","sourceRoot":"","sources":["../../../../server/src/services/ai-localizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE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IA;QACD,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC;QACvB,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC;KACzC;;CA0PJ,CAAC;AAEF,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/services/content-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/services/content-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAgO5C,QAAA,MAAM,YAAY;oCA/KqB,GAAG;6BAjCJ,GAAG;oCA6GF,GAAG;uCAnEA,GAAG;wCAsDpC,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,iBAAiB,SACjD,GAAG;wCA4B+B,GAAG,gBAAgB,GAAG,aAAa,GAAG;0DA8CpB,GAAG,KAAG,MAAM,EAAE;CA6CzE,CAAC;AAEH,KAAK,mBAAmB,GAAG,OAAO,YAAY,CAAC;AAE/C,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -65,7 +65,7 @@ declare const _default: {
|
|
|
65
65
|
sanitize: ({ strapi }: {
|
|
66
66
|
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
67
67
|
}) => {
|
|
68
|
-
sanitizeLocalizationFields: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct/schema.js").ContentTypeSchema | import("@strapi/types/dist/struct/schema.js").ComponentSchema, import("@strapi/types/dist/data/entity.js").Entity<import("@strapi/types/dist/uid/index.js").Schema, string>, Promise<import("@strapi/utils/dist/types").
|
|
68
|
+
sanitizeLocalizationFields: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct/schema.js").ContentTypeSchema | import("@strapi/types/dist/struct/schema.js").ComponentSchema, import("@strapi/types/dist/data/entity.js").Entity<import("@strapi/types/dist/uid/index.js").Schema, string>, Promise<import("@strapi/utils/dist/types").Entry>>;
|
|
69
69
|
};
|
|
70
70
|
'iso-locales': () => {
|
|
71
71
|
getIsoLocales: () => {
|
|
@@ -2,7 +2,7 @@ import type { Core, Data } from '@strapi/types';
|
|
|
2
2
|
declare const sanitize: ({ strapi }: {
|
|
3
3
|
strapi: Core.Strapi;
|
|
4
4
|
}) => {
|
|
5
|
-
sanitizeLocalizationFields: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct/schema.js").ContentTypeSchema | import("@strapi/types/dist/struct/schema.js").ComponentSchema, Data.Entity<import("@strapi/types/dist/uid/index.js").Schema, string>, Promise<import("@strapi/utils/dist/types").
|
|
5
|
+
sanitizeLocalizationFields: import("lodash").CurriedFunction2<import("@strapi/types/dist/struct/schema.js").ContentTypeSchema | import("@strapi/types/dist/struct/schema.js").ComponentSchema, Data.Entity<import("@strapi/types/dist/uid/index.js").Schema, string>, Promise<import("@strapi/utils/dist/types").Entry>>;
|
|
6
6
|
};
|
|
7
7
|
type SanitizeService = typeof sanitize;
|
|
8
8
|
export default sanitize;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type OriginalNonLocalizedLookupInput = {
|
|
2
|
+
documentId?: string;
|
|
3
|
+
locale?: unknown;
|
|
4
|
+
action: string;
|
|
5
|
+
hasDraftAndPublish: boolean;
|
|
6
|
+
defaultLocale?: unknown;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Lookup for the row we are about to write, so shared-field sync compares the
|
|
10
|
+
* same locale and publication status instead of an arbitrary document row.
|
|
11
|
+
*/
|
|
12
|
+
declare const getOriginalNonLocalizedLookup: ({ documentId, locale, action, hasDraftAndPublish, defaultLocale, }: OriginalNonLocalizedLookupInput) => {
|
|
13
|
+
documentId: string;
|
|
14
|
+
locale?: string;
|
|
15
|
+
publishedAt?: {
|
|
16
|
+
$ne: null;
|
|
17
|
+
} | {
|
|
18
|
+
$null: true;
|
|
19
|
+
};
|
|
20
|
+
} | null;
|
|
21
|
+
export { getOriginalNonLocalizedLookup };
|
|
22
|
+
export type { OriginalNonLocalizedLookupInput };
|
|
23
|
+
//# sourceMappingURL=non-localized-original-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-localized-original-data.d.ts","sourceRoot":"","sources":["../../../../server/src/utils/non-localized-original-data.ts"],"names":[],"mappings":"AAAA,KAAK,+BAA+B,GAAG;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAE5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAMF;;;GAGG;AACH,QAAA,MAAM,6BAA6B,GAAI,oEAMpC,+BAA+B;gBAQlB,MAAM;aACT,MAAM;kBACD;QAAE,GAAG,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE;QAYhD,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC;AACzC,YAAY,EAAE,+BAA+B,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** `'*'` means every locale, so it cannot scope the lookup to a single row. */ const asLocaleCode = (value)=>typeof value === 'string' && value !== '' && value !== '*' ? value : undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Lookup for the row we are about to write, so shared-field sync compares the
|
|
6
|
+
* same locale and publication status instead of an arbitrary document row.
|
|
7
|
+
*/ const getOriginalNonLocalizedLookup = ({ documentId, locale, action, hasDraftAndPublish, defaultLocale })=>{
|
|
8
|
+
if (!documentId) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const resolvedLocale = asLocaleCode(locale) ?? asLocaleCode(defaultLocale);
|
|
12
|
+
const where = {
|
|
13
|
+
documentId
|
|
14
|
+
};
|
|
15
|
+
if (resolvedLocale) {
|
|
16
|
+
where.locale = resolvedLocale;
|
|
17
|
+
}
|
|
18
|
+
if (hasDraftAndPublish) {
|
|
19
|
+
where.publishedAt = action === 'publish' ? {
|
|
20
|
+
$ne: null
|
|
21
|
+
} : {
|
|
22
|
+
$null: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return where;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.getOriginalNonLocalizedLookup = getOriginalNonLocalizedLookup;
|
|
29
|
+
//# sourceMappingURL=non-localized-original-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-localized-original-data.js","sources":["../../../server/src/utils/non-localized-original-data.ts"],"sourcesContent":["type OriginalNonLocalizedLookupInput = {\n documentId?: string;\n locale?: unknown;\n action: string;\n hasDraftAndPublish: boolean;\n // The locales service reads the default from the core store, which is untyped.\n defaultLocale?: unknown;\n};\n\n/** `'*'` means every locale, so it cannot scope the lookup to a single row. */\nconst asLocaleCode = (value: unknown): string | undefined =>\n typeof value === 'string' && value !== '' && value !== '*' ? value : undefined;\n\n/**\n * Lookup for the row we are about to write, so shared-field sync compares the\n * same locale and publication status instead of an arbitrary document row.\n */\nconst getOriginalNonLocalizedLookup = ({\n documentId,\n locale,\n action,\n hasDraftAndPublish,\n defaultLocale,\n}: OriginalNonLocalizedLookupInput) => {\n if (!documentId) {\n return null;\n }\n\n const resolvedLocale = asLocaleCode(locale) ?? asLocaleCode(defaultLocale);\n\n const where: {\n documentId: string;\n locale?: string;\n publishedAt?: { $ne: null } | { $null: true };\n } = { documentId };\n\n if (resolvedLocale) {\n where.locale = resolvedLocale;\n }\n\n if (hasDraftAndPublish) {\n where.publishedAt = action === 'publish' ? { $ne: null } : { $null: true };\n }\n\n return where;\n};\n\nexport { getOriginalNonLocalizedLookup };\nexport type { OriginalNonLocalizedLookupInput };\n"],"names":["asLocaleCode","value","undefined","getOriginalNonLocalizedLookup","documentId","locale","action","hasDraftAndPublish","defaultLocale","resolvedLocale","where","publishedAt","$ne","$null"],"mappings":";;AASA,gFACA,MAAMA,YAAAA,GAAe,CAACC,KAAAA,GACpB,OAAOA,KAAAA,KAAU,QAAA,IAAYA,KAAAA,KAAU,EAAA,IAAMA,KAAAA,KAAU,GAAA,GAAMA,KAAAA,GAAQC,SAAAA;AAEvE;;;AAGC,IACD,MAAMC,6BAAAA,GAAgC,CAAC,EACrCC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,kBAAkB,EAClBC,aAAa,EACmB,GAAA;AAChC,IAAA,IAAI,CAACJ,UAAAA,EAAY;QACf,OAAO,IAAA;AACT,IAAA;IAEA,MAAMK,cAAAA,GAAiBT,YAAAA,CAAaK,MAAAA,CAAAA,IAAWL,YAAAA,CAAaQ,aAAAA,CAAAA;AAE5D,IAAA,MAAME,KAAAA,GAIF;AAAEN,QAAAA;AAAW,KAAA;AAEjB,IAAA,IAAIK,cAAAA,EAAgB;AAClBC,QAAAA,KAAAA,CAAML,MAAM,GAAGI,cAAAA;AACjB,IAAA;AAEA,IAAA,IAAIF,kBAAAA,EAAoB;QACtBG,KAAAA,CAAMC,WAAW,GAAGL,MAAAA,KAAW,SAAA,GAAY;YAAEM,GAAAA,EAAK;SAAK,GAAI;YAAEC,KAAAA,EAAO;AAAK,SAAA;AAC3E,IAAA;IAEA,OAAOH,KAAAA;AACT;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** `'*'` means every locale, so it cannot scope the lookup to a single row. */ const asLocaleCode = (value)=>typeof value === 'string' && value !== '' && value !== '*' ? value : undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Lookup for the row we are about to write, so shared-field sync compares the
|
|
4
|
+
* same locale and publication status instead of an arbitrary document row.
|
|
5
|
+
*/ const getOriginalNonLocalizedLookup = ({ documentId, locale, action, hasDraftAndPublish, defaultLocale })=>{
|
|
6
|
+
if (!documentId) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const resolvedLocale = asLocaleCode(locale) ?? asLocaleCode(defaultLocale);
|
|
10
|
+
const where = {
|
|
11
|
+
documentId
|
|
12
|
+
};
|
|
13
|
+
if (resolvedLocale) {
|
|
14
|
+
where.locale = resolvedLocale;
|
|
15
|
+
}
|
|
16
|
+
if (hasDraftAndPublish) {
|
|
17
|
+
where.publishedAt = action === 'publish' ? {
|
|
18
|
+
$ne: null
|
|
19
|
+
} : {
|
|
20
|
+
$null: true
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return where;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { getOriginalNonLocalizedLookup };
|
|
27
|
+
//# sourceMappingURL=non-localized-original-data.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-localized-original-data.mjs","sources":["../../../server/src/utils/non-localized-original-data.ts"],"sourcesContent":["type OriginalNonLocalizedLookupInput = {\n documentId?: string;\n locale?: unknown;\n action: string;\n hasDraftAndPublish: boolean;\n // The locales service reads the default from the core store, which is untyped.\n defaultLocale?: unknown;\n};\n\n/** `'*'` means every locale, so it cannot scope the lookup to a single row. */\nconst asLocaleCode = (value: unknown): string | undefined =>\n typeof value === 'string' && value !== '' && value !== '*' ? value : undefined;\n\n/**\n * Lookup for the row we are about to write, so shared-field sync compares the\n * same locale and publication status instead of an arbitrary document row.\n */\nconst getOriginalNonLocalizedLookup = ({\n documentId,\n locale,\n action,\n hasDraftAndPublish,\n defaultLocale,\n}: OriginalNonLocalizedLookupInput) => {\n if (!documentId) {\n return null;\n }\n\n const resolvedLocale = asLocaleCode(locale) ?? asLocaleCode(defaultLocale);\n\n const where: {\n documentId: string;\n locale?: string;\n publishedAt?: { $ne: null } | { $null: true };\n } = { documentId };\n\n if (resolvedLocale) {\n where.locale = resolvedLocale;\n }\n\n if (hasDraftAndPublish) {\n where.publishedAt = action === 'publish' ? { $ne: null } : { $null: true };\n }\n\n return where;\n};\n\nexport { getOriginalNonLocalizedLookup };\nexport type { OriginalNonLocalizedLookupInput };\n"],"names":["asLocaleCode","value","undefined","getOriginalNonLocalizedLookup","documentId","locale","action","hasDraftAndPublish","defaultLocale","resolvedLocale","where","publishedAt","$ne","$null"],"mappings":"AASA,gFACA,MAAMA,YAAAA,GAAe,CAACC,KAAAA,GACpB,OAAOA,KAAAA,KAAU,QAAA,IAAYA,KAAAA,KAAU,EAAA,IAAMA,KAAAA,KAAU,GAAA,GAAMA,KAAAA,GAAQC,SAAAA;AAEvE;;;AAGC,IACD,MAAMC,6BAAAA,GAAgC,CAAC,EACrCC,UAAU,EACVC,MAAM,EACNC,MAAM,EACNC,kBAAkB,EAClBC,aAAa,EACmB,GAAA;AAChC,IAAA,IAAI,CAACJ,UAAAA,EAAY;QACf,OAAO,IAAA;AACT,IAAA;IAEA,MAAMK,cAAAA,GAAiBT,YAAAA,CAAaK,MAAAA,CAAAA,IAAWL,YAAAA,CAAaQ,aAAAA,CAAAA;AAE5D,IAAA,MAAME,KAAAA,GAIF;AAAEN,QAAAA;AAAW,KAAA;AAEjB,IAAA,IAAIK,cAAAA,EAAgB;AAClBC,QAAAA,KAAAA,CAAML,MAAM,GAAGI,cAAAA;AACjB,IAAA;AAEA,IAAA,IAAIF,kBAAAA,EAAoB;QACtBG,KAAAA,CAAMC,WAAW,GAAGL,MAAAA,KAAW,SAAA,GAAY;YAAEM,GAAAA,EAAK;SAAK,GAAI;YAAEC,KAAAA,EAAO;AAAK,SAAA;AAC3E,IAAA;IAEA,OAAOH,KAAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/i18n",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.62.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": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"build:types:admin": "run -T tsc -p admin/tsconfig.build.json --emitDeclarationOnly",
|
|
54
54
|
"clean": "run -T rimraf ./dist",
|
|
55
55
|
"lint": "run -T eslint . --max-warnings=0",
|
|
56
|
-
"test:front": "run -T
|
|
56
|
+
"test:front": "run -T jest --config ./jest.config.front.js",
|
|
57
57
|
"test:ts:back": "run -T tsc -p server/tsconfig.json",
|
|
58
58
|
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
|
59
59
|
"test:unit": "run -T jest",
|
|
@@ -62,22 +62,22 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@reduxjs/toolkit": "1.9.7",
|
|
65
|
-
"@strapi/design-system": "2.
|
|
66
|
-
"@strapi/icons": "2.
|
|
67
|
-
"@strapi/utils": "5.
|
|
65
|
+
"@strapi/design-system": "2.3.1",
|
|
66
|
+
"@strapi/icons": "2.3.1",
|
|
67
|
+
"@strapi/utils": "5.62.0",
|
|
68
68
|
"lodash": "4.18.1",
|
|
69
|
-
"qs": "6.16.
|
|
69
|
+
"qs": "6.16.2",
|
|
70
70
|
"react-intl": "6.6.2",
|
|
71
71
|
"react-redux": "8.1.3",
|
|
72
72
|
"yup": "0.32.9",
|
|
73
73
|
"zod": "4.4.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@strapi/admin": "5.
|
|
77
|
-
"@strapi/admin-test-utils": "5.
|
|
78
|
-
"@strapi/content-manager": "5.
|
|
79
|
-
"@strapi/database": "5.
|
|
80
|
-
"@strapi/types": "5.
|
|
76
|
+
"@strapi/admin": "5.62.0",
|
|
77
|
+
"@strapi/admin-test-utils": "5.62.0",
|
|
78
|
+
"@strapi/content-manager": "5.62.0",
|
|
79
|
+
"@strapi/database": "5.62.0",
|
|
80
|
+
"@strapi/types": "5.62.0",
|
|
81
81
|
"@testing-library/dom": "10.4.1",
|
|
82
82
|
"@testing-library/jest-dom": "6.9.1",
|
|
83
83
|
"@testing-library/react": "16.3.2",
|