@strapi/i18n 0.0.0-next.06f5279fc9311f59f0473629613fe9516b74ddca → 0.0.0-next.07574a2620494b9275cb638d597903ed2f92c360
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/BulkLocaleActionModal.js.map +1 -1
- package/dist/admin/components/BulkLocaleActionModal.mjs.map +1 -1
- package/dist/admin/components/CMHeaderActions.js +240 -5
- package/dist/admin/components/CMHeaderActions.js.map +1 -1
- package/dist/admin/components/CMHeaderActions.mjs +244 -10
- 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 +1 -1
- 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 +1 -1
- package/dist/admin/components/EditLocale.mjs.map +1 -1
- package/dist/admin/components/LocaleListCell.js +65 -45
- package/dist/admin/components/LocaleListCell.js.map +1 -1
- package/dist/admin/components/LocaleListCell.mjs +66 -46
- package/dist/admin/components/LocaleListCell.mjs.map +1 -1
- package/dist/admin/components/LocalePicker.js +18 -11
- package/dist/admin/components/LocalePicker.js.map +1 -1
- package/dist/admin/components/LocalePicker.mjs +19 -12
- package/dist/admin/components/LocalePicker.mjs.map +1 -1
- package/dist/admin/contentManagerHooks/editView.js +6 -3
- package/dist/admin/contentManagerHooks/editView.js.map +1 -1
- package/dist/admin/contentManagerHooks/editView.mjs +7 -4
- package/dist/admin/contentManagerHooks/editView.mjs.map +1 -1
- package/dist/admin/contentManagerHooks/listView.js +2 -1
- package/dist/admin/contentManagerHooks/listView.js.map +1 -1
- package/dist/admin/contentManagerHooks/listView.mjs +2 -1
- package/dist/admin/contentManagerHooks/listView.mjs.map +1 -1
- package/dist/admin/hooks/useAILocalizationJobsPolling.js +110 -0
- package/dist/admin/hooks/useAILocalizationJobsPolling.js.map +1 -0
- package/dist/admin/hooks/useAILocalizationJobsPolling.mjs +89 -0
- package/dist/admin/hooks/useAILocalizationJobsPolling.mjs.map +1 -0
- package/dist/admin/hooks/useI18n.js +4 -4
- package/dist/admin/hooks/useI18n.js.map +1 -1
- package/dist/admin/hooks/useI18n.mjs +4 -4
- package/dist/admin/hooks/useI18n.mjs.map +1 -1
- package/dist/admin/index.js +1 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +2 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/SettingsPage.js +121 -46
- package/dist/admin/pages/SettingsPage.js.map +1 -1
- package/dist/admin/pages/SettingsPage.mjs +124 -30
- package/dist/admin/pages/SettingsPage.mjs.map +1 -1
- package/dist/admin/services/aiLocalizationJobs.js +26 -0
- package/dist/admin/services/aiLocalizationJobs.js.map +1 -0
- package/dist/admin/services/aiLocalizationJobs.mjs +24 -0
- package/dist/admin/services/aiLocalizationJobs.mjs.map +1 -0
- package/dist/admin/services/api.js +3 -1
- package/dist/admin/services/api.js.map +1 -1
- package/dist/admin/services/api.mjs +3 -1
- package/dist/admin/services/api.mjs.map +1 -1
- package/dist/admin/services/locales.js.map +1 -1
- package/dist/admin/services/locales.mjs.map +1 -1
- package/dist/admin/services/settings.js +29 -0
- package/dist/admin/services/settings.js.map +1 -0
- package/dist/admin/services/settings.mjs +26 -0
- package/dist/admin/services/settings.mjs.map +1 -0
- package/dist/admin/src/components/CMHeaderActions.d.ts +17 -4
- package/dist/admin/src/components/LocaleListCell.d.ts +2 -1
- package/dist/admin/src/hooks/useAILocalizationJobsPolling.d.ts +9 -0
- package/dist/admin/src/services/aiLocalizationJobs.d.ts +6 -0
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/locales.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +1 -1
- package/dist/admin/src/services/settings.d.ts +5 -0
- package/dist/admin/translations/en.json.js +10 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +10 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/utils/clean.js +2 -2
- package/dist/admin/utils/clean.js.map +1 -1
- package/dist/admin/utils/clean.mjs +2 -2
- package/dist/admin/utils/clean.mjs.map +1 -1
- package/dist/admin/utils/getTranslation.js.map +1 -1
- package/dist/admin/utils/getTranslation.mjs.map +1 -1
- package/dist/admin/utils/prefixPluginTranslations.js.map +1 -1
- package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -1
- package/dist/server/bootstrap.js +2 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +2 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/constants/iso-locales.json.js +4 -0
- package/dist/server/constants/iso-locales.json.js.map +1 -1
- package/dist/server/constants/iso-locales.json.mjs +4 -0
- package/dist/server/constants/iso-locales.json.mjs.map +1 -1
- package/dist/server/controllers/ai-localization-jobs.js +47 -0
- package/dist/server/controllers/ai-localization-jobs.js.map +1 -0
- package/dist/server/controllers/ai-localization-jobs.mjs +45 -0
- package/dist/server/controllers/ai-localization-jobs.mjs.map +1 -0
- package/dist/server/controllers/index.js +5 -1
- package/dist/server/controllers/index.js.map +1 -1
- package/dist/server/controllers/index.mjs +5 -1
- package/dist/server/controllers/index.mjs.map +1 -1
- package/dist/server/controllers/settings.js +24 -0
- package/dist/server/controllers/settings.js.map +1 -0
- package/dist/server/controllers/settings.mjs +22 -0
- package/dist/server/controllers/settings.mjs.map +1 -0
- package/dist/server/models/ai-localization-job.js +60 -0
- package/dist/server/models/ai-localization-job.js.map +1 -0
- package/dist/server/models/ai-localization-job.mjs +57 -0
- package/dist/server/models/ai-localization-job.mjs.map +1 -0
- package/dist/server/register.js +3 -1
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +3 -1
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/routes/admin.js +40 -0
- package/dist/server/routes/admin.js.map +1 -1
- package/dist/server/routes/admin.mjs +40 -0
- package/dist/server/routes/admin.mjs.map +1 -1
- package/dist/server/routes/content-api.js +11 -13
- package/dist/server/routes/content-api.js.map +1 -1
- package/dist/server/routes/content-api.mjs +11 -13
- package/dist/server/routes/content-api.mjs.map +1 -1
- package/dist/server/routes/index.mjs +2 -2
- package/dist/server/services/ai-localization-jobs.js +64 -0
- package/dist/server/services/ai-localization-jobs.js.map +1 -0
- package/dist/server/services/ai-localization-jobs.mjs +62 -0
- package/dist/server/services/ai-localization-jobs.mjs.map +1 -0
- package/dist/server/services/ai-localizations.js +276 -0
- package/dist/server/services/ai-localizations.js.map +1 -0
- package/dist/server/services/ai-localizations.mjs +274 -0
- package/dist/server/services/ai-localizations.mjs.map +1 -0
- package/dist/server/services/content-types.js.map +1 -1
- package/dist/server/services/content-types.mjs.map +1 -1
- package/dist/server/services/index.js +7 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +7 -1
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/services/metrics.js +12 -1
- package/dist/server/services/metrics.js.map +1 -1
- package/dist/server/services/metrics.mjs +12 -1
- package/dist/server/services/metrics.mjs.map +1 -1
- package/dist/server/services/settings.js +25 -0
- package/dist/server/services/settings.js.map +1 -0
- package/dist/server/services/settings.mjs +23 -0
- package/dist/server/services/settings.mjs.map +1 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/ai-localization-jobs.d.ts +17 -0
- package/dist/server/src/controllers/ai-localization-jobs.d.ts.map +1 -0
- package/dist/server/src/controllers/index.d.ts +10 -0
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/settings.d.ts +7 -0
- package/dist/server/src/controllers/settings.d.ts.map +1 -0
- package/dist/server/src/index.d.ts +49 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/models/ai-localization-job.d.ts +5 -0
- package/dist/server/src/models/ai-localization-job.d.ts.map +1 -0
- package/dist/server/src/models/index.d.ts +5 -0
- package/dist/server/src/models/index.d.ts.map +1 -0
- package/dist/server/src/register.d.ts +1 -1
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/admin.d.ts.map +1 -1
- package/dist/server/src/routes/content-api.d.ts +5 -2
- package/dist/server/src/routes/content-api.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts +4 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/ai-localization-jobs.d.ts +26 -0
- package/dist/server/src/services/ai-localization-jobs.d.ts.map +1 -0
- package/dist/server/src/services/ai-localizations.d.ts +18 -0
- package/dist/server/src/services/ai-localizations.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +34 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/metrics.d.ts +1 -0
- package/dist/server/src/services/metrics.d.ts.map +1 -1
- package/dist/server/src/services/settings.d.ts +13 -0
- package/dist/server/src/services/settings.d.ts.map +1 -0
- package/dist/server/src/utils/index.d.ts +7 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/src/validation/settings.d.ts +12 -0
- package/dist/server/src/validation/settings.d.ts.map +1 -0
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/server/validation/settings.js +11 -0
- package/dist/server/validation/settings.js.map +1 -0
- package/dist/server/validation/settings.mjs +9 -0
- package/dist/server/validation/settings.mjs.map +1 -0
- package/dist/shared/contracts/ai-localization-jobs.d.ts +27 -0
- package/dist/shared/contracts/ai-localization-jobs.d.ts.map +1 -0
- package/dist/shared/contracts/settings.d.ts +40 -0
- package/dist/shared/contracts/shared.d.ts.map +1 -0
- package/package.json +10 -8
|
@@ -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,EAChBC,mBAAmB,EACnBC,uBAAuB,EACxB,GAAGC,kBAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,MAAMC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AAA,CAAAA,GAAG,CACjF,CAACC,UAAe,GAAA,CAAC,EAAE9C,QAAAA,CAAS,CAAC,EAAE8C,WAAW,CAAC,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,aAAA,CAAA;AACF;AACF;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEMK,MAAAA,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) => {\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,kBAAAA;AACJ,MAAM,EAAEC,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,MAAMC,qBAAqB,CAACC,gBAAAA,GAAAA;IAC1B,OAAOC,OAAAA,CAAK,gCAAgCD,gBAAsB,CAAA,KAAA,IAAA;AACpE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,gBAAW,CAAA,SAAA,CAAA;AAElC,IAAA,IAAIC,SAAMH,MAAS,CAAA,EAAA;AACjB,QAAA,OAAOC,eAAeG,gBAAgB,EAAA;AACxC;AAEA,IAAA,MAAMC,WAAc,GAAA,MAAMJ,cAAeK,CAAAA,UAAU,CAACN,MAAAA,CAAAA;AACpD,IAAA,IAAI,CAACK,WAAa,EAAA;AAChB,QAAA,MAAM,IAAIX,gBAAiB,CAAA,kBAAA,CAAA;AAC7B;IAEA,OAAOM,MAAAA;AACT,CAAA;AAEA;;;;IAKA,MAAMO,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OACEZ,kBAAmBY,CAAAA,SAAAA,CAAAA,IACnBpB,qBAAsBoB,CAAAA,SAAAA,CAAAA,IACtBlB,iBAAiBkB,SAAW,EAAA,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AOqB,GAAAA,MAAAA,CAAOhC,UAAU,CAACD,QAAS,CAAA;QACxC,IAAIY,IAAAA,CAAKC,IAAI,KAAK,WAAa,EAAA;AAC7B,YAAA,MAAM+B,cAAiBb,GAAAA,yCAAAA,CAA0CnB,IAAKO,CAAAA,SAAS,CAAE0B,CAAAA,GAAG,CAClF,CAACC,UAAe,GAAA,CAAA,EAAG9C,QAAS,CAAA,CAAC,EAAE8C,UAAY,CAAA,CAAA,CAAA;AAE7CH,YAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,SAAA,MAAO,IAAIhC,IAAAA,CAAKC,IAAI,KAAK,aAAe,EAAA;AACtCD,YAAAA,IAAAA,CAAKK,UAAU,CAACN,OAAO,CAAC,CAACoC,aAAAA,GAAAA;gBACvB,MAAMH,cAAAA,GAAiBb,yCAA0CgB,CAAAA,aAAAA,CAAAA,CAAeF,GAAG,CACjF,CAACC,UAAAA,GAAe,CAAG9C,EAAAA,QAAAA,CAAS,CAAC,EAAE8C,UAAY,CAAA,CAAA,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,aAAA,CAAA;AACF;AACF;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEMK,MAAAA,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,gBAAsB,CAAA,KAAA,IAAA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,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,aAAA,CAAA;AACF;AACF;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEMK,MAAAA,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) => {\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,gBAAsB,CAAA,KAAA,IAAA;AACpE,CAAA;AAEA,MAAME,iBAAiB,OAAOC,MAAAA,GAAAA;AAC5B,IAAA,MAAMC,iBAAiBC,UAAW,CAAA,SAAA,CAAA;AAElC,IAAA,IAAIC,MAAMH,MAAS,CAAA,EAAA;AACjB,QAAA,OAAOC,eAAeG,gBAAgB,EAAA;AACxC;AAEA,IAAA,MAAMC,WAAc,GAAA,MAAMJ,cAAeK,CAAAA,UAAU,CAACN,MAAAA,CAAAA;AACpD,IAAA,IAAI,CAACK,WAAa,EAAA;AAChB,QAAA,MAAM,IAAIX,gBAAiB,CAAA,kBAAA,CAAA;AAC7B;IAEA,OAAOM,MAAAA;AACT,CAAA;AAEA;;;;IAKA,MAAMO,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OACEZ,kBAAmBY,CAAAA,SAAAA,CAAAA,IACnBpB,qBAAsBoB,CAAAA,SAAAA,CAAAA,IACtBlB,iBAAiBkB,SAAW,EAAA,KAAA,CAAA;AAEhC,CAAA;AAEA;;;;IAKA,MAAMC,yBAAyB,CAACC,KAAAA,GAAAA;AAC9B,IAAA,OAAOd,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,EAAA;AAC7B,YAAA,MAAM+B,cAAiBb,GAAAA,yCAAAA,CAA0CnB,IAAKO,CAAAA,SAAS,CAAE0B,CAAAA,GAAG,CAClF,CAACC,UAAe,GAAA,CAAA,EAAG9C,QAAS,CAAA,CAAC,EAAE8C,UAAY,CAAA,CAAA,CAAA;AAE7CH,YAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,SAAA,MAAO,IAAIhC,IAAAA,CAAKC,IAAI,KAAK,aAAe,EAAA;AACtCD,YAAAA,IAAAA,CAAKK,UAAU,CAACN,OAAO,CAAC,CAACoC,aAAAA,GAAAA;gBACvB,MAAMH,cAAAA,GAAiBb,yCAA0CgB,CAAAA,aAAAA,CAAAA,CAAeF,GAAG,CACjF,CAACC,UAAAA,GAAe,CAAG9C,EAAAA,QAAAA,CAAS,CAAC,EAAE8C,UAAY,CAAA,CAAA,CAAA;AAE7CH,gBAAAA,oBAAAA,CAAqBN,IAAI,CAAIO,GAAAA,cAAAA,CAAAA;AAC/B,aAAA,CAAA;AACF;AACF;IAEA,OAAOD,oBAAAA;AACT,CAAA;AAEMK,MAAAA,YAAAA,GAAe,KAAO;AAC1BpD,QAAAA,sBAAAA;AACAV,QAAAA,cAAAA;AACAsC,QAAAA,sBAAAA;AACA1B,QAAAA,yBAAAA;AACAsB,QAAAA,0BAAAA;AACAK,QAAAA,0BAAAA;AACAM,QAAAA;KACF;;;;"}
|
|
@@ -7,6 +7,9 @@ var locales = require('./locales.js');
|
|
|
7
7
|
var isoLocales = require('./iso-locales.js');
|
|
8
8
|
var contentTypes = require('./content-types.js');
|
|
9
9
|
var index = require('./sanitize/index.js');
|
|
10
|
+
var settings = require('./settings.js');
|
|
11
|
+
var aiLocalizations = require('./ai-localizations.js');
|
|
12
|
+
var aiLocalizationJobs = require('./ai-localization-jobs.js');
|
|
10
13
|
|
|
11
14
|
var services = {
|
|
12
15
|
permissions,
|
|
@@ -15,7 +18,10 @@ var services = {
|
|
|
15
18
|
locales,
|
|
16
19
|
sanitize: index,
|
|
17
20
|
'iso-locales': isoLocales,
|
|
18
|
-
'content-types': contentTypes
|
|
21
|
+
'content-types': contentTypes,
|
|
22
|
+
'ai-localizations': aiLocalizations.createAILocalizationsService,
|
|
23
|
+
'ai-localization-jobs': aiLocalizationJobs.createAILocalizationJobsService,
|
|
24
|
+
settings: settings.createSettingsService
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
module.exports = services;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import permissions from './permissions';\nimport metrics from './metrics';\nimport localizations from './localizations';\nimport locales from './locales';\nimport isoLocales from './iso-locales';\nimport contentTypes from './content-types';\nimport sanitize from './sanitize';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import permissions from './permissions';\nimport metrics from './metrics';\nimport localizations from './localizations';\nimport locales from './locales';\nimport isoLocales from './iso-locales';\nimport contentTypes from './content-types';\nimport sanitize from './sanitize';\nimport { createSettingsService } from './settings';\nimport { createAILocalizationsService } from './ai-localizations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n 'ai-localizations': createAILocalizationsService,\n 'ai-localization-jobs': createAILocalizationJobsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAILocalizationJobsService","settings","createSettingsService"],"mappings":";;;;;;;;;;;;;AAWA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,cAAAA,KAAAA;IACA,aAAeC,EAAAA,UAAAA;IACf,eAAiBC,EAAAA,YAAAA;IACjB,kBAAoBC,EAAAA,4CAAAA;IACpB,sBAAwBC,EAAAA,kDAAAA;IACxBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
|
|
@@ -5,6 +5,9 @@ import locales from './locales.mjs';
|
|
|
5
5
|
import isoLocalesService from './iso-locales.mjs';
|
|
6
6
|
import contentTypes from './content-types.mjs';
|
|
7
7
|
import sanitize from './sanitize/index.mjs';
|
|
8
|
+
import { createSettingsService } from './settings.mjs';
|
|
9
|
+
import { createAILocalizationsService } from './ai-localizations.mjs';
|
|
10
|
+
import { createAILocalizationJobsService } from './ai-localization-jobs.mjs';
|
|
8
11
|
|
|
9
12
|
var services = {
|
|
10
13
|
permissions,
|
|
@@ -13,7 +16,10 @@ var services = {
|
|
|
13
16
|
locales,
|
|
14
17
|
sanitize,
|
|
15
18
|
'iso-locales': isoLocalesService,
|
|
16
|
-
'content-types': contentTypes
|
|
19
|
+
'content-types': contentTypes,
|
|
20
|
+
'ai-localizations': createAILocalizationsService,
|
|
21
|
+
'ai-localization-jobs': createAILocalizationJobsService,
|
|
22
|
+
settings: createSettingsService
|
|
17
23
|
};
|
|
18
24
|
|
|
19
25
|
export { services as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import permissions from './permissions';\nimport metrics from './metrics';\nimport localizations from './localizations';\nimport locales from './locales';\nimport isoLocales from './iso-locales';\nimport contentTypes from './content-types';\nimport sanitize from './sanitize';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../server/src/services/index.ts"],"sourcesContent":["import permissions from './permissions';\nimport metrics from './metrics';\nimport localizations from './localizations';\nimport locales from './locales';\nimport isoLocales from './iso-locales';\nimport contentTypes from './content-types';\nimport sanitize from './sanitize';\nimport { createSettingsService } from './settings';\nimport { createAILocalizationsService } from './ai-localizations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\n\nexport default {\n permissions,\n metrics,\n localizations,\n locales,\n sanitize,\n 'iso-locales': isoLocales,\n 'content-types': contentTypes,\n 'ai-localizations': createAILocalizationsService,\n 'ai-localization-jobs': createAILocalizationJobsService,\n settings: createSettingsService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAILocalizationJobsService","settings","createSettingsService"],"mappings":";;;;;;;;;;;AAWA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,QAAAA;IACA,aAAeC,EAAAA,iBAAAA;IACf,eAAiBC,EAAAA,YAAAA;IACjB,kBAAoBC,EAAAA,4BAAAA;IACpB,sBAAwBC,EAAAA,+BAAAA;IACxBC,QAAUC,EAAAA;AACZ,CAAE;;;;"}
|
|
@@ -21,9 +21,20 @@ const sendDidUpdateI18nLocalesEvent = async ()=>{
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
+
const sendWithAIEventProperty = async (event, payload = {})=>{
|
|
25
|
+
const settings = await index.getService('settings').getSettings();
|
|
26
|
+
strapi.telemetry.send(event, {
|
|
27
|
+
...payload,
|
|
28
|
+
eventProperties: {
|
|
29
|
+
...payload?.eventProperties,
|
|
30
|
+
isAIi18nConfigured: Boolean(settings?.aiLocalizations)
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
24
34
|
const metrics = ()=>({
|
|
25
35
|
sendDidInitializeEvent,
|
|
26
|
-
sendDidUpdateI18nLocalesEvent
|
|
36
|
+
sendDidUpdateI18nLocalesEvent,
|
|
37
|
+
sendWithAIEventProperty
|
|
27
38
|
});
|
|
28
39
|
|
|
29
40
|
module.exports = metrics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sources":["../../../server/src/services/metrics.ts"],"sourcesContent":["import { reduce } from 'lodash/fp';\nimport { getService } from '../utils';\n\nconst sendDidInitializeEvent = async () => {\n const { isLocalizedContentType } = getService('content-types');\n\n // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n const numberOfContentTypes = reduce(\n (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),\n 0\n )(strapi.contentTypes as any);\n\n await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });\n};\n\nconst sendDidUpdateI18nLocalesEvent = async () => {\n const numberOfLocales = await getService('locales').count();\n\n await strapi.telemetry.send('didUpdateI18nLocales', {\n groupProperties: { numberOfLocales },\n });\n};\n\nconst metrics = () => ({\n sendDidInitializeEvent,\n sendDidUpdateI18nLocalesEvent,\n});\n\ntype MetricsService = typeof metrics;\n\nexport default metrics;\nexport type { MetricsService };\n"],"names":["sendDidInitializeEvent","isLocalizedContentType","getService","numberOfContentTypes","reduce","sum","contentType","strapi","contentTypes","telemetry","send","groupProperties","sendDidUpdateI18nLocalesEvent","numberOfLocales","count","metrics"],"mappings":";;;;;AAGA,MAAMA,sBAAyB,GAAA,UAAA;AAC7B,IAAA,MAAM,EAAEC,sBAAsB,EAAE,GAAGC,gBAAW,CAAA,eAAA,CAAA;;AAG9C,IAAA,MAAMC,oBAAuBC,GAAAA,SAAAA,CAC3B,CAACC,GAAAA,EAAKC,WAAiBL,GAAAA,sBAAAA,CAAuBK,WAAeD,CAAAA,GAAAA,GAAAA,GAAM,CAAIA,GAAAA,GAAAA,EACvE,CACAE,CAAAA,CAAAA,MAAAA,CAAOC,YAAY,CAAA;AAErB,IAAA,MAAMD,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,mBAAqB,EAAA;QAAEC,eAAiB,EAAA;AAAER,YAAAA;AAAqB;AAAE,KAAA,CAAA;AAC/F,CAAA;AAEA,MAAMS,6BAAgC,GAAA,UAAA;AACpC,IAAA,MAAMC,eAAkB,GAAA,MAAMX,gBAAW,CAAA,SAAA,CAAA,CAAWY,KAAK,EAAA;AAEzD,IAAA,MAAMP,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,sBAAwB,EAAA;QAClDC,eAAiB,EAAA;AAAEE,YAAAA;AAAgB;AACrC,KAAA,CAAA;AACF,CAAA;
|
|
1
|
+
{"version":3,"file":"metrics.js","sources":["../../../server/src/services/metrics.ts"],"sourcesContent":["import { reduce } from 'lodash/fp';\nimport { getService } from '../utils';\n\nconst sendDidInitializeEvent = async () => {\n const { isLocalizedContentType } = getService('content-types');\n\n // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n const numberOfContentTypes = reduce(\n (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),\n 0\n )(strapi.contentTypes as any);\n\n await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });\n};\n\nconst sendDidUpdateI18nLocalesEvent = async () => {\n const numberOfLocales = await getService('locales').count();\n\n await strapi.telemetry.send('didUpdateI18nLocales', {\n groupProperties: { numberOfLocales },\n });\n};\n\nconst sendWithAIEventProperty = async (event: string, payload: Record<string, any> = {}) => {\n const settings = await getService('settings').getSettings();\n\n strapi.telemetry.send(event, {\n ...payload,\n eventProperties: {\n ...payload?.eventProperties,\n isAIi18nConfigured: Boolean(settings?.aiLocalizations),\n },\n });\n};\n\nconst metrics = () => ({\n sendDidInitializeEvent,\n sendDidUpdateI18nLocalesEvent,\n sendWithAIEventProperty,\n});\n\ntype MetricsService = typeof metrics;\n\nexport default metrics;\nexport type { MetricsService };\n"],"names":["sendDidInitializeEvent","isLocalizedContentType","getService","numberOfContentTypes","reduce","sum","contentType","strapi","contentTypes","telemetry","send","groupProperties","sendDidUpdateI18nLocalesEvent","numberOfLocales","count","sendWithAIEventProperty","event","payload","settings","getSettings","eventProperties","isAIi18nConfigured","Boolean","aiLocalizations","metrics"],"mappings":";;;;;AAGA,MAAMA,sBAAyB,GAAA,UAAA;AAC7B,IAAA,MAAM,EAAEC,sBAAsB,EAAE,GAAGC,gBAAW,CAAA,eAAA,CAAA;;AAG9C,IAAA,MAAMC,oBAAuBC,GAAAA,SAAAA,CAC3B,CAACC,GAAAA,EAAKC,WAAiBL,GAAAA,sBAAAA,CAAuBK,WAAeD,CAAAA,GAAAA,GAAAA,GAAM,CAAIA,GAAAA,GAAAA,EACvE,CACAE,CAAAA,CAAAA,MAAAA,CAAOC,YAAY,CAAA;AAErB,IAAA,MAAMD,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,mBAAqB,EAAA;QAAEC,eAAiB,EAAA;AAAER,YAAAA;AAAqB;AAAE,KAAA,CAAA;AAC/F,CAAA;AAEA,MAAMS,6BAAgC,GAAA,UAAA;AACpC,IAAA,MAAMC,eAAkB,GAAA,MAAMX,gBAAW,CAAA,SAAA,CAAA,CAAWY,KAAK,EAAA;AAEzD,IAAA,MAAMP,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,sBAAwB,EAAA;QAClDC,eAAiB,EAAA;AAAEE,YAAAA;AAAgB;AACrC,KAAA,CAAA;AACF,CAAA;AAEA,MAAME,uBAA0B,GAAA,OAAOC,KAAeC,EAAAA,OAAAA,GAA+B,EAAE,GAAA;AACrF,IAAA,MAAMC,QAAW,GAAA,MAAMhB,gBAAW,CAAA,UAAA,CAAA,CAAYiB,WAAW,EAAA;AAEzDZ,IAAAA,MAAAA,CAAOE,SAAS,CAACC,IAAI,CAACM,KAAO,EAAA;AAC3B,QAAA,GAAGC,OAAO;QACVG,eAAiB,EAAA;AACf,YAAA,GAAGH,SAASG,eAAe;AAC3BC,YAAAA,kBAAAA,EAAoBC,QAAQJ,QAAUK,EAAAA,eAAAA;AACxC;AACF,KAAA,CAAA;AACF,CAAA;AAEMC,MAAAA,OAAAA,GAAU,KAAO;AACrBxB,QAAAA,sBAAAA;AACAY,QAAAA,6BAAAA;AACAG,QAAAA;KACF;;;;"}
|
|
@@ -19,9 +19,20 @@ const sendDidUpdateI18nLocalesEvent = async ()=>{
|
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
+
const sendWithAIEventProperty = async (event, payload = {})=>{
|
|
23
|
+
const settings = await getService('settings').getSettings();
|
|
24
|
+
strapi.telemetry.send(event, {
|
|
25
|
+
...payload,
|
|
26
|
+
eventProperties: {
|
|
27
|
+
...payload?.eventProperties,
|
|
28
|
+
isAIi18nConfigured: Boolean(settings?.aiLocalizations)
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
22
32
|
const metrics = ()=>({
|
|
23
33
|
sendDidInitializeEvent,
|
|
24
|
-
sendDidUpdateI18nLocalesEvent
|
|
34
|
+
sendDidUpdateI18nLocalesEvent,
|
|
35
|
+
sendWithAIEventProperty
|
|
25
36
|
});
|
|
26
37
|
|
|
27
38
|
export { metrics as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.mjs","sources":["../../../server/src/services/metrics.ts"],"sourcesContent":["import { reduce } from 'lodash/fp';\nimport { getService } from '../utils';\n\nconst sendDidInitializeEvent = async () => {\n const { isLocalizedContentType } = getService('content-types');\n\n // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n const numberOfContentTypes = reduce(\n (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),\n 0\n )(strapi.contentTypes as any);\n\n await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });\n};\n\nconst sendDidUpdateI18nLocalesEvent = async () => {\n const numberOfLocales = await getService('locales').count();\n\n await strapi.telemetry.send('didUpdateI18nLocales', {\n groupProperties: { numberOfLocales },\n });\n};\n\nconst metrics = () => ({\n sendDidInitializeEvent,\n sendDidUpdateI18nLocalesEvent,\n});\n\ntype MetricsService = typeof metrics;\n\nexport default metrics;\nexport type { MetricsService };\n"],"names":["sendDidInitializeEvent","isLocalizedContentType","getService","numberOfContentTypes","reduce","sum","contentType","strapi","contentTypes","telemetry","send","groupProperties","sendDidUpdateI18nLocalesEvent","numberOfLocales","count","metrics"],"mappings":";;;AAGA,MAAMA,sBAAyB,GAAA,UAAA;AAC7B,IAAA,MAAM,EAAEC,sBAAsB,EAAE,GAAGC,UAAW,CAAA,eAAA,CAAA;;AAG9C,IAAA,MAAMC,oBAAuBC,GAAAA,MAAAA,CAC3B,CAACC,GAAAA,EAAKC,WAAiBL,GAAAA,sBAAAA,CAAuBK,WAAeD,CAAAA,GAAAA,GAAAA,GAAM,CAAIA,GAAAA,GAAAA,EACvE,CACAE,CAAAA,CAAAA,MAAAA,CAAOC,YAAY,CAAA;AAErB,IAAA,MAAMD,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,mBAAqB,EAAA;QAAEC,eAAiB,EAAA;AAAER,YAAAA;AAAqB;AAAE,KAAA,CAAA;AAC/F,CAAA;AAEA,MAAMS,6BAAgC,GAAA,UAAA;AACpC,IAAA,MAAMC,eAAkB,GAAA,MAAMX,UAAW,CAAA,SAAA,CAAA,CAAWY,KAAK,EAAA;AAEzD,IAAA,MAAMP,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,sBAAwB,EAAA;QAClDC,eAAiB,EAAA;AAAEE,YAAAA;AAAgB;AACrC,KAAA,CAAA;AACF,CAAA;
|
|
1
|
+
{"version":3,"file":"metrics.mjs","sources":["../../../server/src/services/metrics.ts"],"sourcesContent":["import { reduce } from 'lodash/fp';\nimport { getService } from '../utils';\n\nconst sendDidInitializeEvent = async () => {\n const { isLocalizedContentType } = getService('content-types');\n\n // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.\n const numberOfContentTypes = reduce(\n (sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),\n 0\n )(strapi.contentTypes as any);\n\n await strapi.telemetry.send('didInitializeI18n', { groupProperties: { numberOfContentTypes } });\n};\n\nconst sendDidUpdateI18nLocalesEvent = async () => {\n const numberOfLocales = await getService('locales').count();\n\n await strapi.telemetry.send('didUpdateI18nLocales', {\n groupProperties: { numberOfLocales },\n });\n};\n\nconst sendWithAIEventProperty = async (event: string, payload: Record<string, any> = {}) => {\n const settings = await getService('settings').getSettings();\n\n strapi.telemetry.send(event, {\n ...payload,\n eventProperties: {\n ...payload?.eventProperties,\n isAIi18nConfigured: Boolean(settings?.aiLocalizations),\n },\n });\n};\n\nconst metrics = () => ({\n sendDidInitializeEvent,\n sendDidUpdateI18nLocalesEvent,\n sendWithAIEventProperty,\n});\n\ntype MetricsService = typeof metrics;\n\nexport default metrics;\nexport type { MetricsService };\n"],"names":["sendDidInitializeEvent","isLocalizedContentType","getService","numberOfContentTypes","reduce","sum","contentType","strapi","contentTypes","telemetry","send","groupProperties","sendDidUpdateI18nLocalesEvent","numberOfLocales","count","sendWithAIEventProperty","event","payload","settings","getSettings","eventProperties","isAIi18nConfigured","Boolean","aiLocalizations","metrics"],"mappings":";;;AAGA,MAAMA,sBAAyB,GAAA,UAAA;AAC7B,IAAA,MAAM,EAAEC,sBAAsB,EAAE,GAAGC,UAAW,CAAA,eAAA,CAAA;;AAG9C,IAAA,MAAMC,oBAAuBC,GAAAA,MAAAA,CAC3B,CAACC,GAAAA,EAAKC,WAAiBL,GAAAA,sBAAAA,CAAuBK,WAAeD,CAAAA,GAAAA,GAAAA,GAAM,CAAIA,GAAAA,GAAAA,EACvE,CACAE,CAAAA,CAAAA,MAAAA,CAAOC,YAAY,CAAA;AAErB,IAAA,MAAMD,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,mBAAqB,EAAA;QAAEC,eAAiB,EAAA;AAAER,YAAAA;AAAqB;AAAE,KAAA,CAAA;AAC/F,CAAA;AAEA,MAAMS,6BAAgC,GAAA,UAAA;AACpC,IAAA,MAAMC,eAAkB,GAAA,MAAMX,UAAW,CAAA,SAAA,CAAA,CAAWY,KAAK,EAAA;AAEzD,IAAA,MAAMP,MAAOE,CAAAA,SAAS,CAACC,IAAI,CAAC,sBAAwB,EAAA;QAClDC,eAAiB,EAAA;AAAEE,YAAAA;AAAgB;AACrC,KAAA,CAAA;AACF,CAAA;AAEA,MAAME,uBAA0B,GAAA,OAAOC,KAAeC,EAAAA,OAAAA,GAA+B,EAAE,GAAA;AACrF,IAAA,MAAMC,QAAW,GAAA,MAAMhB,UAAW,CAAA,UAAA,CAAA,CAAYiB,WAAW,EAAA;AAEzDZ,IAAAA,MAAAA,CAAOE,SAAS,CAACC,IAAI,CAACM,KAAO,EAAA;AAC3B,QAAA,GAAGC,OAAO;QACVG,eAAiB,EAAA;AACf,YAAA,GAAGH,SAASG,eAAe;AAC3BC,YAAAA,kBAAAA,EAAoBC,QAAQJ,QAAUK,EAAAA,eAAAA;AACxC;AACF,KAAA,CAAA;AACF,CAAA;AAEMC,MAAAA,OAAAA,GAAU,KAAO;AACrBxB,QAAAA,sBAAAA;AACAY,QAAAA,6BAAAA;AACAG,QAAAA;KACF;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const createSettingsService = ({ strapi })=>{
|
|
4
|
+
const settings = strapi.store({
|
|
5
|
+
type: 'plugin',
|
|
6
|
+
name: 'i18n',
|
|
7
|
+
key: 'settings'
|
|
8
|
+
});
|
|
9
|
+
async function getSettings() {
|
|
10
|
+
const res = await settings.get({});
|
|
11
|
+
return res;
|
|
12
|
+
}
|
|
13
|
+
function setSettings(value) {
|
|
14
|
+
return settings.set({
|
|
15
|
+
value
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
getSettings,
|
|
20
|
+
setSettings
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.createSettingsService = createSettingsService;
|
|
25
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sources":["../../../server/src/services/settings.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { Settings } from '../validation/settings';\n\nconst createSettingsService = ({ strapi }: { strapi: Core.Strapi }) => {\n const settings = strapi.store!({ type: 'plugin', name: 'i18n', key: 'settings' });\n\n async function getSettings() {\n const res = (await settings.get({})) as Settings | null;\n\n return res;\n }\n\n function setSettings(value: Settings) {\n return settings.set({ value });\n }\n\n return {\n getSettings,\n setSettings,\n };\n};\n\nexport { createSettingsService };\nexport type SettingsService = ReturnType<typeof createSettingsService>;\n"],"names":["createSettingsService","strapi","settings","store","type","name","key","getSettings","res","get","setSettings","value","set"],"mappings":";;AAGA,MAAMA,qBAAwB,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;IAChE,MAAMC,QAAAA,GAAWD,MAAOE,CAAAA,KAAK,CAAE;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA,MAAA;QAAQC,GAAK,EAAA;AAAW,KAAA,CAAA;IAE/E,eAAeC,WAAAA,GAAAA;AACb,QAAA,MAAMC,GAAO,GAAA,MAAMN,QAASO,CAAAA,GAAG,CAAC,EAAC,CAAA;QAEjC,OAAOD,GAAAA;AACT;AAEA,IAAA,SAASE,YAAYC,KAAe,EAAA;QAClC,OAAOT,QAAAA,CAASU,GAAG,CAAC;AAAED,YAAAA;AAAM,SAAA,CAAA;AAC9B;IAEA,OAAO;AACLJ,QAAAA,WAAAA;AACAG,QAAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const createSettingsService = ({ strapi })=>{
|
|
2
|
+
const settings = strapi.store({
|
|
3
|
+
type: 'plugin',
|
|
4
|
+
name: 'i18n',
|
|
5
|
+
key: 'settings'
|
|
6
|
+
});
|
|
7
|
+
async function getSettings() {
|
|
8
|
+
const res = await settings.get({});
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
11
|
+
function setSettings(value) {
|
|
12
|
+
return settings.set({
|
|
13
|
+
value
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
getSettings,
|
|
18
|
+
setSettings
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { createSettingsService };
|
|
23
|
+
//# sourceMappingURL=settings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.mjs","sources":["../../../server/src/services/settings.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { Settings } from '../validation/settings';\n\nconst createSettingsService = ({ strapi }: { strapi: Core.Strapi }) => {\n const settings = strapi.store!({ type: 'plugin', name: 'i18n', key: 'settings' });\n\n async function getSettings() {\n const res = (await settings.get({})) as Settings | null;\n\n return res;\n }\n\n function setSettings(value: Settings) {\n return settings.set({ value });\n }\n\n return {\n getSettings,\n setSettings,\n };\n};\n\nexport { createSettingsService };\nexport type SettingsService = ReturnType<typeof createSettingsService>;\n"],"names":["createSettingsService","strapi","settings","store","type","name","key","getSettings","res","get","setSettings","value","set"],"mappings":"AAGA,MAAMA,qBAAwB,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;IAChE,MAAMC,QAAAA,GAAWD,MAAOE,CAAAA,KAAK,CAAE;QAAEC,IAAM,EAAA,QAAA;QAAUC,IAAM,EAAA,MAAA;QAAQC,GAAK,EAAA;AAAW,KAAA,CAAA;IAE/E,eAAeC,WAAAA,GAAAA;AACb,QAAA,MAAMC,GAAO,GAAA,MAAMN,QAASO,CAAAA,GAAG,CAAC,EAAC,CAAA;QAEjC,OAAOD,GAAAA;AACT;AAEA,IAAA,SAASE,YAAYC,KAAe,EAAA;QAClC,OAAOT,QAAAA,CAASU,GAAG,CAAC;AAAED,YAAAA;AAAM,SAAA,CAAA;AAC9B;IAEA,OAAO;AACLJ,QAAAA,WAAAA;AACAG,QAAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":";AA4DA,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":";AA4DA,wBA0BE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
declare const createAILocalizationJobsController: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
/**
|
|
6
|
+
* Get a job for a singleType using the contentType
|
|
7
|
+
* There is only 1 job per contentType
|
|
8
|
+
*/
|
|
9
|
+
getJobForSingleType(ctx: any): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Get a job for a collectionType using the documentId
|
|
12
|
+
* There is only 1 job per documentId
|
|
13
|
+
*/
|
|
14
|
+
getJobForCollectionType(ctx: any): Promise<any>;
|
|
15
|
+
};
|
|
16
|
+
export default createAILocalizationJobsController;
|
|
17
|
+
//# sourceMappingURL=ai-localization-jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-localization-jobs.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/ai-localization-jobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,QAAA,MAAM,kCAAkC,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;IAK3E;;;OAGG;6BAC4B,GAAG;IAkBlC;;;OAGG;iCACgC,GAAG;CAmBzC,CAAC;AAEF,eAAe,kCAAkC,CAAC"}
|
|
@@ -5,6 +5,16 @@ declare const _default: {
|
|
|
5
5
|
'content-types': {
|
|
6
6
|
getNonLocalizedAttributes(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
|
|
7
7
|
};
|
|
8
|
+
settings: {
|
|
9
|
+
updateSettings(ctx: import("koa").Context): Promise<void>;
|
|
10
|
+
getSettings(ctx: import("koa").Context): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
'ai-localization-jobs': ({ strapi }: {
|
|
13
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
14
|
+
}) => {
|
|
15
|
+
getJobForSingleType(ctx: any): Promise<any>;
|
|
16
|
+
getJobForCollectionType(ctx: any): Promise<any>;
|
|
17
|
+
};
|
|
8
18
|
};
|
|
9
19
|
export default _default;
|
|
10
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,wBAME"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;;wBAMP,OAAO;qBAYV,OAAO;;AAbhC,wBAkBE"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
declare const _default: () => {
|
|
4
4
|
register: ({ strapi }: {
|
|
5
5
|
strapi: import("@strapi/types/dist/core").Strapi;
|
|
6
|
-
}) => void
|
|
6
|
+
}) => Promise<void>;
|
|
7
7
|
bootstrap: () => Promise<void>;
|
|
8
8
|
routes: {
|
|
9
9
|
admin: {
|
|
@@ -22,7 +22,10 @@ declare const _default: () => {
|
|
|
22
22
|
};
|
|
23
23
|
}[];
|
|
24
24
|
};
|
|
25
|
-
'content-api': () =>
|
|
25
|
+
'content-api': () => {
|
|
26
|
+
type: "content-api";
|
|
27
|
+
routes: import("@strapi/types/dist/core").RouteInput[];
|
|
28
|
+
};
|
|
26
29
|
};
|
|
27
30
|
controllers: {
|
|
28
31
|
locales: import("@strapi/types/dist/core").Controller;
|
|
@@ -30,6 +33,16 @@ declare const _default: () => {
|
|
|
30
33
|
'content-types': {
|
|
31
34
|
getNonLocalizedAttributes(ctx: import("koa").Context): Promise<import("koa").Context | undefined>;
|
|
32
35
|
};
|
|
36
|
+
settings: {
|
|
37
|
+
updateSettings(ctx: import("koa").Context): Promise<void>;
|
|
38
|
+
getSettings(ctx: import("koa").Context): Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
'ai-localization-jobs': ({ strapi }: {
|
|
41
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
42
|
+
}) => {
|
|
43
|
+
getJobForSingleType(ctx: any): Promise<any>;
|
|
44
|
+
getJobForCollectionType(ctx: any): Promise<any>;
|
|
45
|
+
};
|
|
33
46
|
};
|
|
34
47
|
contentTypes: {
|
|
35
48
|
locale: {
|
|
@@ -106,6 +119,7 @@ declare const _default: () => {
|
|
|
106
119
|
metrics: () => {
|
|
107
120
|
sendDidInitializeEvent: () => Promise<void>;
|
|
108
121
|
sendDidUpdateI18nLocalesEvent: () => Promise<void>;
|
|
122
|
+
sendWithAIEventProperty: (event: string, payload?: Record<string, any>) => Promise<void>;
|
|
109
123
|
};
|
|
110
124
|
localizations: () => {
|
|
111
125
|
syncNonLocalizedAttributes: (sourceEntry: any, model: import("@strapi/types/dist/struct").ContentTypeSchema) => Promise<void>;
|
|
@@ -143,6 +157,39 @@ declare const _default: () => {
|
|
|
143
157
|
fillNonLocalizedAttributes: (entry: any, relatedEntry: any, { model }: any) => void;
|
|
144
158
|
getNestedPopulateOfNonLocalizedAttributes: (modelUID: any) => string[];
|
|
145
159
|
};
|
|
160
|
+
'ai-localizations': ({ strapi }: {
|
|
161
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
162
|
+
}) => {
|
|
163
|
+
isEnabled(): Promise<boolean>;
|
|
164
|
+
generateDocumentLocalizations({ model, document, }: {
|
|
165
|
+
model: import("@strapi/types/dist/uid").ContentType;
|
|
166
|
+
document: import("@strapi/types/dist/modules/documents").AnyDocument;
|
|
167
|
+
}): Promise<void>;
|
|
168
|
+
setupMiddleware(): void;
|
|
169
|
+
};
|
|
170
|
+
'ai-localization-jobs': ({ strapi }: {
|
|
171
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
172
|
+
}) => {
|
|
173
|
+
upsertJobForDocument({ documentId, contentType, sourceLocale, targetLocales, status, }: {
|
|
174
|
+
documentId: string;
|
|
175
|
+
contentType: string;
|
|
176
|
+
sourceLocale: string;
|
|
177
|
+
targetLocales: string[];
|
|
178
|
+
status?: "processing" | "completed" | "failed" | undefined;
|
|
179
|
+
}): Promise<any>;
|
|
180
|
+
getJobByDocument(contentType: string, documentId: string): Promise<any>;
|
|
181
|
+
getJobByContentType(contentType: string): Promise<any>;
|
|
182
|
+
};
|
|
183
|
+
settings: ({ strapi }: {
|
|
184
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
185
|
+
}) => {
|
|
186
|
+
getSettings: () => Promise<import("yup/lib/object").AssertsShape<{
|
|
187
|
+
aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
|
|
188
|
+
}> | null>;
|
|
189
|
+
setSettings: (value: import("yup/lib/object").AssertsShape<{
|
|
190
|
+
aiLocalizations: import("yup").BooleanSchema<boolean, Record<string, any>, boolean>;
|
|
191
|
+
}>) => Promise<void>;
|
|
192
|
+
};
|
|
146
193
|
};
|
|
147
194
|
};
|
|
148
195
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../server/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wBAOG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Model } from '@strapi/database';
|
|
2
|
+
declare const AI_LOCALIZATION_JOB_UID = "plugin::i18n.ai-localization-job";
|
|
3
|
+
declare const aiLocalizationJob: Model;
|
|
4
|
+
export { aiLocalizationJob, AI_LOCALIZATION_JOB_UID };
|
|
5
|
+
//# sourceMappingURL=ai-localization-job.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-localization-job.d.ts","sourceRoot":"","sources":["../../../../server/src/models/ai-localization-job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,QAAA,MAAM,uBAAuB,qCAAqC,CAAC;AAEnE,QAAA,MAAM,iBAAiB,EAAE,KAsCxB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/models/index.ts"],"names":[],"mappings":";;;AAEA,wBAEE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../server/src/register.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../server/src/register.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;qCAOR;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;AAAzD,wBAKE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/admin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/admin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wBA4GE"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { Core } from '@strapi/types';
|
|
2
|
-
declare const
|
|
3
|
-
|
|
2
|
+
declare const createContentApiRoutes: () => {
|
|
3
|
+
type: "content-api";
|
|
4
|
+
routes: Core.RouteInput[];
|
|
5
|
+
};
|
|
6
|
+
export default createContentApiRoutes;
|
|
4
7
|
//# sourceMappingURL=content-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-api.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/content-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"content-api.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/content-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAI1C,QAAA,MAAM,sBAAsB;;;CAU1B,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
|
|
@@ -15,7 +15,10 @@ declare const _default: {
|
|
|
15
15
|
};
|
|
16
16
|
}[];
|
|
17
17
|
};
|
|
18
|
-
'content-api': () =>
|
|
18
|
+
'content-api': () => {
|
|
19
|
+
type: "content-api";
|
|
20
|
+
routes: import("@strapi/types/dist/core").RouteInput[];
|
|
21
|
+
};
|
|
19
22
|
};
|
|
20
23
|
export default _default;
|
|
21
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,wBAGE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
import type { AILocalizationJobs } from '../../../shared/contracts/ai-localization-jobs';
|
|
3
|
+
export declare const createAILocalizationJobsService: ({ strapi }: {
|
|
4
|
+
strapi: Core.Strapi;
|
|
5
|
+
}) => {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new AI localizations job or update an existing one for a document
|
|
8
|
+
* Ensures only one job exists per document
|
|
9
|
+
*/
|
|
10
|
+
upsertJobForDocument({ documentId, contentType, sourceLocale, targetLocales, status, }: {
|
|
11
|
+
documentId: string;
|
|
12
|
+
contentType: string;
|
|
13
|
+
sourceLocale: string;
|
|
14
|
+
targetLocales: string[];
|
|
15
|
+
status?: AILocalizationJobs['status'];
|
|
16
|
+
}): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Get job by document ID
|
|
19
|
+
*/
|
|
20
|
+
getJobByDocument(contentType: string, documentId: string): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Get job by content type
|
|
23
|
+
*/
|
|
24
|
+
getJobByContentType(contentType: string): Promise<any>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=ai-localization-jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-localization-jobs.d.ts","sourceRoot":"","sources":["../../../../server/src/services/ai-localization-jobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AAEzF,eAAO,MAAM,+BAA+B,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;IACjF;;;OAGG;4FAOA;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC;KACvC;IAsCD;;OAEG;kCACiC,MAAM,cAAc,MAAM;IAS9D;;OAEG;qCACoC,MAAM;CAO7C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Core, Modules, UID } from '@strapi/types';
|
|
2
|
+
declare const createAILocalizationsService: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
isEnabled(): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if there are localizations that need to be generated for the given document,
|
|
8
|
+
* and if so, calls the AI service and saves the results to the database.
|
|
9
|
+
* Works for both single and collection types, on create and update.
|
|
10
|
+
*/
|
|
11
|
+
generateDocumentLocalizations({ model, document, }: {
|
|
12
|
+
model: UID.ContentType;
|
|
13
|
+
document: Modules.Documents.AnyDocument;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
setupMiddleware(): void;
|
|
16
|
+
};
|
|
17
|
+
export { createAILocalizationsService };
|
|
18
|
+
//# sourceMappingURL=ai-localizations.d.ts.map
|