@strapi/i18n 5.54.0 → 5.55.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 +5 -5
- package/dist/admin/components/CMHeaderActions.js.map +1 -1
- package/dist/admin/components/CMHeaderActions.mjs +5 -5
- package/dist/admin/components/CMHeaderActions.mjs.map +1 -1
- package/dist/admin/hooks/useAITranslations.js +11 -0
- package/dist/admin/hooks/useAITranslations.js.map +1 -0
- package/dist/admin/hooks/useAITranslations.mjs +9 -0
- package/dist/admin/hooks/useAITranslations.mjs.map +1 -0
- package/dist/admin/pages/SettingsPage.js +2 -2
- package/dist/admin/pages/SettingsPage.js.map +1 -1
- package/dist/admin/pages/SettingsPage.mjs +2 -2
- package/dist/admin/pages/SettingsPage.mjs.map +1 -1
- package/dist/admin/src/hooks/useAITranslations.d.ts +1 -0
- package/dist/admin/src/services/settings.d.ts +1 -1
- package/dist/server/bootstrap.js +5 -1
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +5 -1
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/settings.js +5 -2
- package/dist/server/controllers/settings.js.map +1 -1
- package/dist/server/controllers/settings.mjs +5 -2
- package/dist/server/controllers/settings.mjs.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/services/ai-localizations.js +8 -34
- package/dist/server/services/ai-localizations.js.map +1 -1
- package/dist/server/services/ai-localizations.mjs +8 -34
- package/dist/server/services/ai-localizations.mjs.map +1 -1
- package/dist/server/services/ai-translations-strapi-managed.js +44 -0
- package/dist/server/services/ai-translations-strapi-managed.js.map +1 -0
- package/dist/server/services/ai-translations-strapi-managed.mjs +42 -0
- package/dist/server/services/ai-translations-strapi-managed.mjs.map +1 -0
- package/dist/server/services/ai-translations.js +50 -0
- package/dist/server/services/ai-translations.js.map +1 -0
- package/dist/server/services/ai-translations.mjs +48 -0
- package/dist/server/services/ai-translations.mjs.map +1 -0
- package/dist/server/services/index.js +2 -0
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +2 -0
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/settings.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/ai-localizations.d.ts.map +1 -1
- package/dist/server/src/services/ai-translations-strapi-managed.d.ts +7 -0
- package/dist/server/src/services/ai-translations-strapi-managed.d.ts.map +1 -0
- package/dist/server/src/services/ai-translations.d.ts +29 -0
- package/dist/server/src/services/ai-translations.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +3 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/shared/contracts/settings.d.ts +6 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-localizations.mjs","sources":["../../../server/src/services/ai-localizations.ts"],"sourcesContent":["import type { Core, Modules, Schema, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { getService } from '../utils';\n\nconst isLocalizedAttribute = (attribute: Schema.Attribute.Attribute | undefined): boolean => {\n return (attribute?.pluginOptions as any)?.i18n?.localized === true;\n};\n\nconst UNSUPPORTED_ATTRIBUTE_TYPES: Schema.Attribute.Kind[] = [\n 'media',\n 'relation',\n 'boolean',\n 'enumeration',\n];\n\nconst IGNORED_FIELDS = [\n 'id',\n 'documentId',\n 'createdAt',\n 'updatedAt',\n 'publishedAt',\n 'locale',\n 'updatedBy',\n 'createdBy',\n 'localizations',\n];\n\n/**\n * Deep merge where target values take priority over source values.\n * Arrays are merged by index to align repeatable component / dynamic zone items.\n */\nconst deepMerge = (\n source: Record<string, any>,\n target: Record<string, any>\n): Record<string, any> => {\n const result = { ...source };\n\n for (const key of Object.keys(target)) {\n const sourceVal = source[key];\n const targetVal = target[key];\n\n if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {\n result[key] = targetVal.map((item, i) => {\n if (item && typeof item === 'object' && sourceVal[i] && typeof sourceVal[i] === 'object') {\n return deepMerge(sourceVal[i], item);\n }\n return item;\n });\n } else if (\n targetVal &&\n typeof targetVal === 'object' &&\n !Array.isArray(targetVal) &&\n sourceVal &&\n typeof sourceVal === 'object' &&\n !Array.isArray(sourceVal)\n ) {\n result[key] = deepMerge(sourceVal, targetVal);\n } else {\n result[key] = targetVal;\n }\n }\n\n return result;\n};\n\n/**\n * Merges unsupported field types (media, boolean, enumeration, relation)\n * from a source document into the target data object.\n *\n * Uses traverseEntity to walk the source document and extract only unsupported fields,\n * then deep-merges the AI-translated target data on top so translated values take priority.\n */\nconst mergeUnsupportedFields = async (\n targetData: Record<string, any>,\n sourceDoc: Record<string, any> | null,\n schema: Schema.Schema,\n getModel: (uid: UID.Schema) => Schema.Schema | undefined\n): Promise<Record<string, any>> => {\n if (!sourceDoc) {\n return targetData;\n }\n\n // Track paths of relation/media fields so traverseEntity's recursion\n // into those fields doesn't strip internal fields like `id` or `url`.\n const preservedPaths = new Set<string>();\n\n // Use traverseEntity to extract only unsupported fields from the source document.\n // traverseEntity handles component and dynamic zone recursion automatically.\n const unsupportedFieldsOnly = await traverseEntity(\n ({ key, attribute, path }, { remove }) => {\n // If we're inside a relation or media subtree, preserve everything.\n // Use path-based prefix check instead of parent-based check because\n // traverseEntity mutates `parent` across siblings at the same level,\n // which would incorrectly mark sibling fields as inside a preserved subtree.\n const isInsidePreservedSubtree =\n path.raw && Array.from(preservedPaths).some((pp) => path.raw!.startsWith(`${pp}.`));\n if (isInsidePreservedSubtree) {\n preservedPaths.add(path.raw!);\n return;\n }\n\n if (IGNORED_FIELDS.includes(key)) {\n remove(key);\n return;\n }\n\n // Keep fields with no schema attribute (e.g. __component in dynamic zones)\n if (!attribute) {\n return;\n }\n\n // Mark relation and media subtrees as preserved so their internal\n // fields (id, url, etc.) are not removed during recursion\n if (attribute.type === 'media' || attribute.type === 'relation') {\n preservedPaths.add(path.raw!);\n return;\n }\n\n // Keep other unsupported attribute types (boolean, enumeration)\n if (UNSUPPORTED_ATTRIBUTE_TYPES.includes(attribute.type)) {\n return;\n }\n\n // Keep components and dynamic zones — traverseEntity recurses into them\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n return;\n }\n\n // Remove supported (translatable) fields\n remove(key);\n },\n { schema, getModel: getModel as (uid: string) => Schema.Schema },\n sourceDoc\n );\n\n // Deep merge: AI-translated target takes priority over source unsupported fields\n return deepMerge(unsupportedFieldsOnly, targetData);\n};\n\nconst createAILocalizationsService = ({ strapi }: { strapi: Core.Strapi }) => {\n // TODO: add a helper function to get the AI server URL\n const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';\n const aiLocalizationJobsService = getService('ai-localization-jobs');\n\n return {\n // Async to avoid changing the signature later (there will be a db check in the future)\n async isEnabled() {\n if (strapi.ai.admin.isEnabled() === false) {\n return false;\n }\n const settings = getService('settings');\n const aiSettings = await settings.getSettings();\n return aiSettings?.aiLocalizations === true;\n },\n\n /**\n * Checks if there are localizations that need to be generated for the given document,\n * and if so, calls the AI service and saves the results to the database.\n * Works for both single and collection types, on create and update.\n */\n async generateDocumentLocalizations({\n model,\n document,\n }: {\n model: UID.ContentType;\n document: Modules.Documents.AnyDocument;\n }) {\n const isFeatureEnabled = await this.isEnabled();\n if (!isFeatureEnabled) {\n return;\n }\n\n const schema = strapi.getModel(model);\n const localeService = getService('locales');\n\n // No localizations needed for content types with i18n disabled\n const isLocalizedContentType = getService('content-types').isLocalizedContentType(schema);\n if (!isLocalizedContentType) {\n return;\n }\n\n // Don't trigger localizations if the update is on a derived locale, only do it on the default\n const defaultLocale = await localeService.getDefaultLocale();\n if (document?.locale !== defaultLocale) {\n return;\n }\n\n const documentId = document.documentId;\n\n if (!documentId) {\n strapi.log.warn(`AI Localizations: missing documentId for ${schema.uid}`);\n return;\n }\n\n const localizedRoots = new Set();\n\n const translateableContent = await traverseEntity(\n ({ key, attribute, parent, path }, { remove }) => {\n if (IGNORED_FIELDS.includes(key)) {\n remove(key);\n return;\n }\n const hasLocalizedOption = attribute && isLocalizedAttribute(attribute);\n if (attribute && UNSUPPORTED_ATTRIBUTE_TYPES.includes(attribute.type)) {\n remove(key);\n return;\n }\n\n // If this field is localized, keep it (and mark as localized root if component/dz)\n if (hasLocalizedOption) {\n // If it's a component/dynamiczone, add to the set\n if (['component', 'dynamiczone'].includes(attribute.type)) {\n localizedRoots.add(path.raw);\n }\n return; // keep\n }\n\n if (parent && localizedRoots.has(parent.path.raw)) {\n // If parent exists in the localized roots set, keep it\n // If this is also a component/dz, propagate the localized root flag\n if (['component', 'dynamiczone'].includes(attribute?.type ?? '')) {\n localizedRoots.add(path.raw);\n }\n return; // keep\n }\n\n // Otherwise, remove the field\n remove(key);\n },\n { schema, getModel: strapi.getModel.bind(strapi) },\n document\n );\n\n if (Object.keys(translateableContent).length === 0) {\n strapi.log.info(\n `AI Localizations: no translatable content for ${schema.uid} document ${documentId}`\n );\n return;\n }\n\n const localesList = await localeService.find();\n const targetLocales = localesList\n .filter((l) => l.code !== document.locale)\n .map((l) => l.code);\n\n if (targetLocales.length === 0) {\n strapi.log.info(\n `AI Localizations: no target locales for ${schema.uid} document ${documentId}`\n );\n return;\n }\n\n await aiLocalizationJobsService.upsertJobForDocument({\n contentType: model,\n documentId,\n sourceLocale: document.locale,\n targetLocales,\n status: 'processing',\n });\n\n let token: string;\n try {\n const tokenData = await strapi.ai.admin.getAiToken();\n token = tokenData.token;\n } catch (error) {\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'failed',\n });\n throw new Error('Failed to retrieve AI token', {\n cause: error instanceof Error ? error : undefined,\n });\n }\n\n /**\n * Provide a schema to the LLM so that we can give it instructions about how to handle each\n * type of attribute. Only keep essential schema data to avoid cluttering the context.\n * Ignore fields that don't need to be localized.\n * TODO: also provide a schema of all the referenced components\n */\n const minimalContentTypeSchema = Object.fromEntries(\n Object.entries(schema.attributes)\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n .filter(([_, attr]) => {\n const isLocalized = isLocalizedAttribute(attr);\n const isSupportedType = !UNSUPPORTED_ATTRIBUTE_TYPES.includes(attr.type);\n return isLocalized && isSupportedType;\n })\n .map(([key, attr]) => {\n const minimalAttribute: Record<string, unknown> = { type: attr.type };\n if (attr.type === 'component') {\n (\n minimalAttribute as Schema.Attribute.Component<`${string}.${string}`, boolean>\n ).repeatable = attr.repeatable ?? false;\n }\n\n const { maxLength, minLength } = attr as {\n maxLength?: number;\n minLength?: number;\n };\n if (typeof maxLength === 'number') {\n minimalAttribute.maxLength = maxLength;\n }\n if (typeof minLength === 'number') {\n minimalAttribute.minLength = minLength;\n }\n return [key, minimalAttribute];\n })\n );\n\n strapi.log.http('Contacting AI Server for localizations generation');\n const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n content: translateableContent,\n sourceLocale: document.locale,\n targetLocales,\n contentTypeSchema: minimalContentTypeSchema,\n }),\n });\n\n if (!response.ok) {\n strapi.log.error(\n `AI Localizations request failed: ${response.status} ${response.statusText}`\n );\n\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'failed',\n });\n\n throw new Error(`AI Localizations request failed: ${response.statusText}`);\n }\n\n const aiResult = (await response.json()) as {\n localizations: Array<{ content: Record<string, unknown>; locale: string }>;\n };\n\n // Use populate-builder service for deep populate to fetch all nested fields\n const populateBuilderService = strapi.plugin('content-manager').service('populate-builder');\n // @ts-expect-error - populate-builder service returns a callable function\n const deepPopulate = await populateBuilderService(model).populateDeep(Infinity).build();\n const getModelBound = strapi.getModel.bind(strapi);\n\n // Fetch the source document with all fields populated (for new locales that don't exist yet)\n const sourceDocWithAllFields = await strapi.documents(model).findOne({\n documentId,\n locale: document.locale,\n populate: deepPopulate,\n });\n\n const results = await Promise.allSettled(\n aiResult.localizations.map(async (localization) => {\n const { content, locale } = localization;\n\n const derivedDoc = await strapi.documents(model).findOne({\n documentId,\n locale,\n populate: deepPopulate,\n });\n\n let mergedData = structuredClone(content);\n\n const sourceForUnsupportedFields = derivedDoc || sourceDocWithAllFields;\n mergedData = await mergeUnsupportedFields(\n mergedData,\n sourceForUnsupportedFields,\n schema,\n getModelBound\n );\n\n await strapi.documents(model).update({\n documentId,\n locale,\n fields: [],\n data: mergedData,\n });\n })\n );\n\n const failedLocales: string[] = [];\n results.forEach((result, index) => {\n if (result.status === 'rejected') {\n const locale = aiResult.localizations[index]?.locale;\n failedLocales.push(locale);\n const reason =\n result.reason instanceof Error ? result.reason.message : String(result.reason);\n strapi.log.error(\n `AI Localizations: failed to save locale \"${locale}\" for ${model} document ${documentId}: ${reason}`\n );\n }\n });\n\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: failedLocales.length > 0 ? 'failed' : 'completed',\n });\n },\n setupMiddleware() {\n strapi.documents.use(async (context, next) => {\n const result = await next();\n\n // Only trigger for the allowed actions\n if (!['create', 'update'].includes(context.action)) {\n return result;\n }\n\n // Check if AI localizations are enabled before triggering\n const isEnabled = await this.isEnabled();\n if (!isEnabled) {\n return result;\n }\n\n // Don't await since localizations should be done in the background without blocking the request\n strapi\n .plugin('i18n')\n .service('ai-localizations')\n .generateDocumentLocalizations({\n model: context.contentType.uid,\n document: result,\n })\n .catch((error: any) => {\n strapi.log.error('AI Localizations generation failed', error);\n });\n\n return result;\n });\n },\n };\n};\n\nexport { createAILocalizationsService, mergeUnsupportedFields };\n"],"names":["isLocalizedAttribute","attribute","pluginOptions","i18n","localized","UNSUPPORTED_ATTRIBUTE_TYPES","IGNORED_FIELDS","deepMerge","source","target","result","key","Object","keys","sourceVal","targetVal","Array","isArray","map","item","i","mergeUnsupportedFields","targetData","sourceDoc","schema","getModel","preservedPaths","Set","unsupportedFieldsOnly","traverseEntity","path","remove","isInsidePreservedSubtree","raw","from","some","pp","startsWith","add","includes","type","createAILocalizationsService","strapi","aiServerUrl","process","env","STRAPI_AI_URL","aiLocalizationJobsService","getService","isEnabled","ai","admin","settings","aiSettings","getSettings","aiLocalizations","generateDocumentLocalizations","model","document","isFeatureEnabled","localeService","isLocalizedContentType","defaultLocale","getDefaultLocale","locale","documentId","log","warn","uid","localizedRoots","translateableContent","parent","hasLocalizedOption","has","bind","length","info","localesList","find","targetLocales","filter","l","code","upsertJobForDocument","contentType","sourceLocale","status","token","tokenData","getAiToken","error","Error","cause","undefined","minimalContentTypeSchema","fromEntries","entries","attributes","_","attr","isLocalized","isSupportedType","minimalAttribute","repeatable","maxLength","minLength","http","response","fetch","method","headers","Authorization","body","JSON","stringify","content","contentTypeSchema","ok","statusText","aiResult","json","populateBuilderService","plugin","service","deepPopulate","populateDeep","Infinity","build","getModelBound","sourceDocWithAllFields","documents","findOne","populate","results","Promise","allSettled","localizations","localization","derivedDoc","mergedData","structuredClone","sourceForUnsupportedFields","update","fields","data","failedLocales","forEach","index","push","reason","message","String","setupMiddleware","use","context","next","action","catch"],"mappings":";;;AAIA,MAAMA,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OAAO,SAACA,EAAWC,aAAAA,EAAuBC,IAAAA,EAAMC,SAAAA,KAAc,IAAA;AAChE,CAAA;AAEA,MAAMC,2BAAAA,GAAuD;AAC3D,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,cAAAA,GAAiB;AACrB,IAAA,IAAA;AACA,IAAA,YAAA;AACA,IAAA,WAAA;AACA,IAA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,KAAAA,CAAAA;AACzD,gBAAA,CAAA,CAAA;gBAEF,OAAOhF,MAAAA;AACT,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"ai-localizations.mjs","sources":["../../../server/src/services/ai-localizations.ts"],"sourcesContent":["import type { Core, Modules, Schema, UID } from '@strapi/types';\nimport { traverseEntity } from '@strapi/utils';\nimport { getService } from '../utils';\nimport type { GenerateTranslationsResult } from './ai-translations';\n\nconst isLocalizedAttribute = (attribute: Schema.Attribute.Attribute | undefined): boolean => {\n return (attribute?.pluginOptions as any)?.i18n?.localized === true;\n};\n\nconst UNSUPPORTED_ATTRIBUTE_TYPES: Schema.Attribute.Kind[] = [\n 'media',\n 'relation',\n 'boolean',\n 'enumeration',\n];\n\nconst IGNORED_FIELDS = [\n 'id',\n 'documentId',\n 'createdAt',\n 'updatedAt',\n 'publishedAt',\n 'locale',\n 'updatedBy',\n 'createdBy',\n 'localizations',\n];\n\n/**\n * Deep merge where target values take priority over source values.\n * Arrays are merged by index to align repeatable component / dynamic zone items.\n */\nconst deepMerge = (\n source: Record<string, any>,\n target: Record<string, any>\n): Record<string, any> => {\n const result = { ...source };\n\n for (const key of Object.keys(target)) {\n const sourceVal = source[key];\n const targetVal = target[key];\n\n if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {\n result[key] = targetVal.map((item, i) => {\n if (item && typeof item === 'object' && sourceVal[i] && typeof sourceVal[i] === 'object') {\n return deepMerge(sourceVal[i], item);\n }\n return item;\n });\n } else if (\n targetVal &&\n typeof targetVal === 'object' &&\n !Array.isArray(targetVal) &&\n sourceVal &&\n typeof sourceVal === 'object' &&\n !Array.isArray(sourceVal)\n ) {\n result[key] = deepMerge(sourceVal, targetVal);\n } else {\n result[key] = targetVal;\n }\n }\n\n return result;\n};\n\n/**\n * Merges unsupported field types (media, boolean, enumeration, relation)\n * from a source document into the target data object.\n *\n * Uses traverseEntity to walk the source document and extract only unsupported fields,\n * then deep-merges the AI-translated target data on top so translated values take priority.\n */\nconst mergeUnsupportedFields = async (\n targetData: Record<string, any>,\n sourceDoc: Record<string, any> | null,\n schema: Schema.Schema,\n getModel: (uid: UID.Schema) => Schema.Schema | undefined\n): Promise<Record<string, any>> => {\n if (!sourceDoc) {\n return targetData;\n }\n\n // Track paths of relation/media fields so traverseEntity's recursion\n // into those fields doesn't strip internal fields like `id` or `url`.\n const preservedPaths = new Set<string>();\n\n // Use traverseEntity to extract only unsupported fields from the source document.\n // traverseEntity handles component and dynamic zone recursion automatically.\n const unsupportedFieldsOnly = await traverseEntity(\n ({ key, attribute, path }, { remove }) => {\n // If we're inside a relation or media subtree, preserve everything.\n // Use path-based prefix check instead of parent-based check because\n // traverseEntity mutates `parent` across siblings at the same level,\n // which would incorrectly mark sibling fields as inside a preserved subtree.\n const isInsidePreservedSubtree =\n path.raw && Array.from(preservedPaths).some((pp) => path.raw!.startsWith(`${pp}.`));\n if (isInsidePreservedSubtree) {\n preservedPaths.add(path.raw!);\n return;\n }\n\n if (IGNORED_FIELDS.includes(key)) {\n remove(key);\n return;\n }\n\n // Keep fields with no schema attribute (e.g. __component in dynamic zones)\n if (!attribute) {\n return;\n }\n\n // Mark relation and media subtrees as preserved so their internal\n // fields (id, url, etc.) are not removed during recursion\n if (attribute.type === 'media' || attribute.type === 'relation') {\n preservedPaths.add(path.raw!);\n return;\n }\n\n // Keep other unsupported attribute types (boolean, enumeration)\n if (UNSUPPORTED_ATTRIBUTE_TYPES.includes(attribute.type)) {\n return;\n }\n\n // Keep components and dynamic zones — traverseEntity recurses into them\n if (attribute.type === 'component' || attribute.type === 'dynamiczone') {\n return;\n }\n\n // Remove supported (translatable) fields\n remove(key);\n },\n { schema, getModel: getModel as (uid: string) => Schema.Schema },\n sourceDoc\n );\n\n // Deep merge: AI-translated target takes priority over source unsupported fields\n return deepMerge(unsupportedFieldsOnly, targetData);\n};\n\nconst createAILocalizationsService = ({ strapi }: { strapi: Core.Strapi }) => {\n const aiLocalizationJobsService = getService('ai-localization-jobs');\n\n return {\n // Async to avoid changing the signature later (there will be a db check in the future)\n async isEnabled() {\n if (getService('ai-translations').hasProvider() === false) {\n return false;\n }\n const settings = getService('settings');\n const aiSettings = await settings.getSettings();\n return aiSettings?.aiLocalizations === true;\n },\n\n /**\n * Checks if there are localizations that need to be generated for the given document,\n * and if so, calls the AI service and saves the results to the database.\n * Works for both single and collection types, on create and update.\n */\n async generateDocumentLocalizations({\n model,\n document,\n }: {\n model: UID.ContentType;\n document: Modules.Documents.AnyDocument;\n }) {\n const isFeatureEnabled = await this.isEnabled();\n if (!isFeatureEnabled) {\n return;\n }\n\n const schema = strapi.getModel(model);\n const localeService = getService('locales');\n\n // No localizations needed for content types with i18n disabled\n const isLocalizedContentType = getService('content-types').isLocalizedContentType(schema);\n if (!isLocalizedContentType) {\n return;\n }\n\n // Don't trigger localizations if the update is on a derived locale, only do it on the default\n const defaultLocale = await localeService.getDefaultLocale();\n if (document?.locale !== defaultLocale) {\n return;\n }\n\n const documentId = document.documentId;\n\n if (!documentId) {\n strapi.log.warn(`AI Localizations: missing documentId for ${schema.uid}`);\n return;\n }\n\n const localizedRoots = new Set();\n\n const translateableContent = await traverseEntity(\n ({ key, attribute, parent, path }, { remove }) => {\n if (IGNORED_FIELDS.includes(key)) {\n remove(key);\n return;\n }\n const hasLocalizedOption = attribute && isLocalizedAttribute(attribute);\n if (attribute && UNSUPPORTED_ATTRIBUTE_TYPES.includes(attribute.type)) {\n remove(key);\n return;\n }\n\n // If this field is localized, keep it (and mark as localized root if component/dz)\n if (hasLocalizedOption) {\n // If it's a component/dynamiczone, add to the set\n if (['component', 'dynamiczone'].includes(attribute.type)) {\n localizedRoots.add(path.raw);\n }\n return; // keep\n }\n\n if (parent && localizedRoots.has(parent.path.raw)) {\n // If parent exists in the localized roots set, keep it\n // If this is also a component/dz, propagate the localized root flag\n if (['component', 'dynamiczone'].includes(attribute?.type ?? '')) {\n localizedRoots.add(path.raw);\n }\n return; // keep\n }\n\n // Otherwise, remove the field\n remove(key);\n },\n { schema, getModel: strapi.getModel.bind(strapi) },\n document\n );\n\n if (Object.keys(translateableContent).length === 0) {\n strapi.log.info(\n `AI Localizations: no translatable content for ${schema.uid} document ${documentId}`\n );\n return;\n }\n\n const localesList = await localeService.find();\n const targetLocales = localesList\n .filter((l) => l.code !== document.locale)\n .map((l) => l.code);\n\n if (targetLocales.length === 0) {\n strapi.log.info(\n `AI Localizations: no target locales for ${schema.uid} document ${documentId}`\n );\n return;\n }\n\n await aiLocalizationJobsService.upsertJobForDocument({\n contentType: model,\n documentId,\n sourceLocale: document.locale,\n targetLocales,\n status: 'processing',\n });\n\n /**\n * Provide a schema to the LLM so that we can give it instructions about how to handle each\n * type of attribute. Only keep essential schema data to avoid cluttering the context.\n * Ignore fields that don't need to be localized.\n * TODO: also provide a schema of all the referenced components\n */\n const minimalContentTypeSchema = Object.fromEntries(\n Object.entries(schema.attributes)\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n .filter(([_, attr]) => {\n const isLocalized = isLocalizedAttribute(attr);\n const isSupportedType = !UNSUPPORTED_ATTRIBUTE_TYPES.includes(attr.type);\n return isLocalized && isSupportedType;\n })\n .map(([key, attr]) => {\n const minimalAttribute: Record<string, unknown> = { type: attr.type };\n if (attr.type === 'component') {\n (\n minimalAttribute as Schema.Attribute.Component<`${string}.${string}`, boolean>\n ).repeatable = attr.repeatable ?? false;\n }\n\n const { maxLength, minLength } = attr as {\n maxLength?: number;\n minLength?: number;\n };\n if (typeof maxLength === 'number') {\n minimalAttribute.maxLength = maxLength;\n }\n if (typeof minLength === 'number') {\n minimalAttribute.minLength = minLength;\n }\n return [key, minimalAttribute];\n })\n );\n\n let aiResult: GenerateTranslationsResult;\n try {\n aiResult = await getService('ai-translations').generateTranslations({\n sourceLocale: document.locale,\n targetLocales,\n content: translateableContent,\n contentTypeSchema: minimalContentTypeSchema,\n });\n } catch (error) {\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: 'failed',\n });\n\n throw error;\n }\n\n // Use populate-builder service for deep populate to fetch all nested fields\n const populateBuilderService = strapi.plugin('content-manager').service('populate-builder');\n // @ts-expect-error - populate-builder service returns a callable function\n const deepPopulate = await populateBuilderService(model).populateDeep(Infinity).build();\n const getModelBound = strapi.getModel.bind(strapi);\n\n // Fetch the source document with all fields populated (for new locales that don't exist yet)\n const sourceDocWithAllFields = await strapi.documents(model).findOne({\n documentId,\n locale: document.locale,\n populate: deepPopulate,\n });\n\n const results = await Promise.allSettled(\n aiResult.localizations.map(async (localization) => {\n const { content, locale } = localization;\n\n const derivedDoc = await strapi.documents(model).findOne({\n documentId,\n locale,\n populate: deepPopulate,\n });\n\n let mergedData = structuredClone(content);\n\n const sourceForUnsupportedFields = derivedDoc || sourceDocWithAllFields;\n mergedData = await mergeUnsupportedFields(\n mergedData,\n sourceForUnsupportedFields,\n schema,\n getModelBound\n );\n\n await strapi.documents(model).update({\n documentId,\n locale,\n fields: [],\n data: mergedData,\n });\n })\n );\n\n const failedLocales: string[] = [];\n results.forEach((result, index) => {\n if (result.status === 'rejected') {\n const locale = aiResult.localizations[index]?.locale;\n failedLocales.push(locale);\n const reason =\n result.reason instanceof Error ? result.reason.message : String(result.reason);\n strapi.log.error(\n `AI Localizations: failed to save locale \"${locale}\" for ${model} document ${documentId}: ${reason}`\n );\n }\n });\n\n await aiLocalizationJobsService.upsertJobForDocument({\n documentId,\n contentType: model,\n sourceLocale: document.locale,\n targetLocales,\n status: failedLocales.length > 0 ? 'failed' : 'completed',\n });\n },\n setupMiddleware() {\n strapi.documents.use(async (context, next) => {\n const result = await next();\n\n // Only trigger for the allowed actions\n if (!['create', 'update'].includes(context.action)) {\n return result;\n }\n\n // Check if AI localizations are enabled before triggering\n const isEnabled = await this.isEnabled();\n if (!isEnabled) {\n return result;\n }\n\n // Don't await since localizations should be done in the background without blocking the request\n strapi\n .plugin('i18n')\n .service('ai-localizations')\n .generateDocumentLocalizations({\n model: context.contentType.uid,\n document: result,\n })\n .catch((error: any) => {\n strapi.log.error('AI Localizations generation failed', error);\n });\n\n return result;\n });\n },\n };\n};\n\nexport { createAILocalizationsService, mergeUnsupportedFields };\n"],"names":["isLocalizedAttribute","attribute","pluginOptions","i18n","localized","UNSUPPORTED_ATTRIBUTE_TYPES","IGNORED_FIELDS","deepMerge","source","target","result","key","Object","keys","sourceVal","targetVal","Array","isArray","map","item","i","mergeUnsupportedFields","targetData","sourceDoc","schema","getModel","preservedPaths","Set","unsupportedFieldsOnly","traverseEntity","path","remove","isInsidePreservedSubtree","raw","from","some","pp","startsWith","add","includes","type","createAILocalizationsService","strapi","aiLocalizationJobsService","getService","isEnabled","hasProvider","settings","aiSettings","getSettings","aiLocalizations","generateDocumentLocalizations","model","document","isFeatureEnabled","localeService","isLocalizedContentType","defaultLocale","getDefaultLocale","locale","documentId","log","warn","uid","localizedRoots","translateableContent","parent","hasLocalizedOption","has","bind","length","info","localesList","find","targetLocales","filter","l","code","upsertJobForDocument","contentType","sourceLocale","status","minimalContentTypeSchema","fromEntries","entries","attributes","_","attr","isLocalized","isSupportedType","minimalAttribute","repeatable","maxLength","minLength","aiResult","generateTranslations","content","contentTypeSchema","error","populateBuilderService","plugin","service","deepPopulate","populateDeep","Infinity","build","getModelBound","sourceDocWithAllFields","documents","findOne","populate","results","Promise","allSettled","localizations","localization","derivedDoc","mergedData","structuredClone","sourceForUnsupportedFields","update","fields","data","failedLocales","forEach","index","push","reason","Error","message","String","setupMiddleware","use","context","next","action","catch"],"mappings":";;;AAKA,MAAMA,uBAAuB,CAACC,SAAAA,GAAAA;AAC5B,IAAA,OAAO,SAACA,EAAWC,aAAAA,EAAuBC,IAAAA,EAAMC,SAAAA,KAAc,IAAA;AAChE,CAAA;AAEA,MAAMC,2BAAAA,GAAuD;AAC3D,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,SAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,cAAAA,GAAiB;A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iBACZ,CAAA,CACC8H,KAAK,CAAC,CAACtC,KAAAA,GAAAA;AACNxD,oBAAAA,MAAAA,CAAOmB,GAAG,CAACqC,KAAK,CAAC,oCAAA,EAAsCA,KAAAA,CAAAA;AACzD,gBAAA,CAAA,CAAA;gBAEF,OAAOxF,MAAAA;AACT,YAAA,CAAA,CAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const createStrapiManagedAiTranslationsProvider = ({ strapi })=>{
|
|
4
|
+
// TODO: add a helper function to get the AI server URL
|
|
5
|
+
const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';
|
|
6
|
+
const getAiToken = async ()=>{
|
|
7
|
+
try {
|
|
8
|
+
const { token } = await strapi.ai.admin.getAiToken();
|
|
9
|
+
return token;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
throw new Error('Failed to retrieve AI token', {
|
|
12
|
+
cause: error instanceof Error ? error : undefined
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
name: 'strapi-managed',
|
|
18
|
+
async generateTranslations ({ sourceLocale, targetLocales, content, contentTypeSchema }) {
|
|
19
|
+
const token = await getAiToken();
|
|
20
|
+
strapi.log.http('Contacting AI Server for localizations generation');
|
|
21
|
+
const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
Authorization: `Bearer ${token}`
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
content,
|
|
29
|
+
sourceLocale,
|
|
30
|
+
targetLocales,
|
|
31
|
+
contentTypeSchema
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
strapi.log.error(`AI Localizations request failed: ${response.status} ${response.statusText}`);
|
|
36
|
+
throw new Error(`AI Localizations request failed: ${response.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
return await response.json();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.createStrapiManagedAiTranslationsProvider = createStrapiManagedAiTranslationsProvider;
|
|
44
|
+
//# sourceMappingURL=ai-translations-strapi-managed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-translations-strapi-managed.js","sources":["../../../server/src/services/ai-translations-strapi-managed.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport type { AiTranslationsProvider } from './ai-translations';\n\nconst createStrapiManagedAiTranslationsProvider = ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): AiTranslationsProvider => {\n // TODO: add a helper function to get the AI server URL\n const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';\n\n const getAiToken = async () => {\n try {\n const { token } = await strapi.ai.admin.getAiToken();\n return token;\n } catch (error) {\n throw new Error('Failed to retrieve AI token', {\n cause: error instanceof Error ? error : undefined,\n });\n }\n };\n\n return {\n name: 'strapi-managed',\n\n async generateTranslations({ sourceLocale, targetLocales, content, contentTypeSchema }) {\n const token = await getAiToken();\n\n strapi.log.http('Contacting AI Server for localizations generation');\n const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n content,\n sourceLocale,\n targetLocales,\n contentTypeSchema,\n }),\n });\n\n if (!response.ok) {\n strapi.log.error(\n `AI Localizations request failed: ${response.status} ${response.statusText}`\n );\n\n throw new Error(`AI Localizations request failed: ${response.statusText}`);\n }\n\n return (await response.json()) as Awaited<\n ReturnType<AiTranslationsProvider['generateTranslations']>\n >;\n },\n };\n};\n\nexport { createStrapiManagedAiTranslationsProvider };\n"],"names":["createStrapiManagedAiTranslationsProvider","strapi","aiServerUrl","process","env","STRAPI_AI_URL","getAiToken","token","ai","admin","error","Error","cause","undefined","name","generateTranslations","sourceLocale","targetLocales","content","contentTypeSchema","log","http","response","fetch","method","headers","Authorization","body","JSON","stringify","ok","status","statusText","json"],"mappings":";;AAIA,MAAMA,yCAAAA,GAA4C,CAAC,EACjDC,MAAM,EAGP,GAAA;;AAEC,IAAA,MAAMC,WAAAA,GAAcC,OAAAA,CAAQC,GAAG,CAACC,aAAa,IAAI,kCAAA;AAEjD,IAAA,MAAMC,UAAAA,GAAa,UAAA;QACjB,IAAI;YACF,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMN,OAAOO,EAAE,CAACC,KAAK,CAACH,UAAU,EAAA;YAClD,OAAOC,KAAAA;AACT,QAAA,CAAA,CAAE,OAAOG,KAAAA,EAAO;YACd,MAAM,IAAIC,MAAM,6BAAA,EAA+B;gBAC7CC,KAAAA,EAAOF,KAAAA,YAAiBC,QAAQD,KAAAA,GAAQG;AAC1C,aAAA,CAAA;AACF,QAAA;AACF,IAAA,CAAA;IAEA,OAAO;QACLC,IAAAA,EAAM,gBAAA;QAEN,MAAMC,oBAAAA,CAAAA,CAAqB,EAAEC,YAAY,EAAEC,aAAa,EAAEC,OAAO,EAAEC,iBAAiB,EAAE,EAAA;AACpF,YAAA,MAAMZ,QAAQ,MAAMD,UAAAA,EAAAA;YAEpBL,MAAAA,CAAOmB,GAAG,CAACC,IAAI,CAAC,mDAAA,CAAA;AAChB,YAAA,MAAMC,WAAW,MAAMC,KAAAA,CAAM,GAAGrB,WAAAA,CAAY,4BAA4B,CAAC,EAAE;gBACzEsB,MAAAA,EAAQ,MAAA;gBACRC,OAAAA,EAAS;oBACP,cAAA,EAAgB,kBAAA;oBAChBC,aAAAA,EAAe,CAAC,OAAO,EAAEnB,KAAAA,CAAAA;AAC3B,iBAAA;gBACAoB,IAAAA,EAAMC,IAAAA,CAAKC,SAAS,CAAC;AACnBX,oBAAAA,OAAAA;AACAF,oBAAAA,YAAAA;AACAC,oBAAAA,aAAAA;AACAE,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;YAEA,IAAI,CAACG,QAAAA,CAASQ,EAAE,EAAE;AAChB7B,gBAAAA,MAAAA,CAAOmB,GAAG,CAACV,KAAK,CACd,CAAC,iCAAiC,EAAEY,QAAAA,CAASS,MAAM,CAAC,CAAC,EAAET,QAAAA,CAASU,UAAU,CAAA,CAAE,CAAA;AAG9E,gBAAA,MAAM,IAAIrB,KAAAA,CAAM,CAAC,iCAAiC,EAAEW,QAAAA,CAASU,UAAU,CAAA,CAAE,CAAA;AAC3E,YAAA;YAEA,OAAQ,MAAMV,SAASW,IAAI,EAAA;AAG7B,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const createStrapiManagedAiTranslationsProvider = ({ strapi })=>{
|
|
2
|
+
// TODO: add a helper function to get the AI server URL
|
|
3
|
+
const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';
|
|
4
|
+
const getAiToken = async ()=>{
|
|
5
|
+
try {
|
|
6
|
+
const { token } = await strapi.ai.admin.getAiToken();
|
|
7
|
+
return token;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
throw new Error('Failed to retrieve AI token', {
|
|
10
|
+
cause: error instanceof Error ? error : undefined
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
name: 'strapi-managed',
|
|
16
|
+
async generateTranslations ({ sourceLocale, targetLocales, content, contentTypeSchema }) {
|
|
17
|
+
const token = await getAiToken();
|
|
18
|
+
strapi.log.http('Contacting AI Server for localizations generation');
|
|
19
|
+
const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: {
|
|
22
|
+
'Content-Type': 'application/json',
|
|
23
|
+
Authorization: `Bearer ${token}`
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
content,
|
|
27
|
+
sourceLocale,
|
|
28
|
+
targetLocales,
|
|
29
|
+
contentTypeSchema
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
strapi.log.error(`AI Localizations request failed: ${response.status} ${response.statusText}`);
|
|
34
|
+
throw new Error(`AI Localizations request failed: ${response.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
return await response.json();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { createStrapiManagedAiTranslationsProvider };
|
|
42
|
+
//# sourceMappingURL=ai-translations-strapi-managed.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-translations-strapi-managed.mjs","sources":["../../../server/src/services/ai-translations-strapi-managed.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\n\nimport type { AiTranslationsProvider } from './ai-translations';\n\nconst createStrapiManagedAiTranslationsProvider = ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): AiTranslationsProvider => {\n // TODO: add a helper function to get the AI server URL\n const aiServerUrl = process.env.STRAPI_AI_URL || 'https://strapi-ai.apps.strapi.io';\n\n const getAiToken = async () => {\n try {\n const { token } = await strapi.ai.admin.getAiToken();\n return token;\n } catch (error) {\n throw new Error('Failed to retrieve AI token', {\n cause: error instanceof Error ? error : undefined,\n });\n }\n };\n\n return {\n name: 'strapi-managed',\n\n async generateTranslations({ sourceLocale, targetLocales, content, contentTypeSchema }) {\n const token = await getAiToken();\n\n strapi.log.http('Contacting AI Server for localizations generation');\n const response = await fetch(`${aiServerUrl}/i18n/generate-localizations`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify({\n content,\n sourceLocale,\n targetLocales,\n contentTypeSchema,\n }),\n });\n\n if (!response.ok) {\n strapi.log.error(\n `AI Localizations request failed: ${response.status} ${response.statusText}`\n );\n\n throw new Error(`AI Localizations request failed: ${response.statusText}`);\n }\n\n return (await response.json()) as Awaited<\n ReturnType<AiTranslationsProvider['generateTranslations']>\n >;\n },\n };\n};\n\nexport { createStrapiManagedAiTranslationsProvider };\n"],"names":["createStrapiManagedAiTranslationsProvider","strapi","aiServerUrl","process","env","STRAPI_AI_URL","getAiToken","token","ai","admin","error","Error","cause","undefined","name","generateTranslations","sourceLocale","targetLocales","content","contentTypeSchema","log","http","response","fetch","method","headers","Authorization","body","JSON","stringify","ok","status","statusText","json"],"mappings":"AAIA,MAAMA,yCAAAA,GAA4C,CAAC,EACjDC,MAAM,EAGP,GAAA;;AAEC,IAAA,MAAMC,WAAAA,GAAcC,OAAAA,CAAQC,GAAG,CAACC,aAAa,IAAI,kCAAA;AAEjD,IAAA,MAAMC,UAAAA,GAAa,UAAA;QACjB,IAAI;YACF,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMN,OAAOO,EAAE,CAACC,KAAK,CAACH,UAAU,EAAA;YAClD,OAAOC,KAAAA;AACT,QAAA,CAAA,CAAE,OAAOG,KAAAA,EAAO;YACd,MAAM,IAAIC,MAAM,6BAAA,EAA+B;gBAC7CC,KAAAA,EAAOF,KAAAA,YAAiBC,QAAQD,KAAAA,GAAQG;AAC1C,aAAA,CAAA;AACF,QAAA;AACF,IAAA,CAAA;IAEA,OAAO;QACLC,IAAAA,EAAM,gBAAA;QAEN,MAAMC,oBAAAA,CAAAA,CAAqB,EAAEC,YAAY,EAAEC,aAAa,EAAEC,OAAO,EAAEC,iBAAiB,EAAE,EAAA;AACpF,YAAA,MAAMZ,QAAQ,MAAMD,UAAAA,EAAAA;YAEpBL,MAAAA,CAAOmB,GAAG,CAACC,IAAI,CAAC,mDAAA,CAAA;AAChB,YAAA,MAAMC,WAAW,MAAMC,KAAAA,CAAM,GAAGrB,WAAAA,CAAY,4BAA4B,CAAC,EAAE;gBACzEsB,MAAAA,EAAQ,MAAA;gBACRC,OAAAA,EAAS;oBACP,cAAA,EAAgB,kBAAA;oBAChBC,aAAAA,EAAe,CAAC,OAAO,EAAEnB,KAAAA,CAAAA;AAC3B,iBAAA;gBACAoB,IAAAA,EAAMC,IAAAA,CAAKC,SAAS,CAAC;AACnBX,oBAAAA,OAAAA;AACAF,oBAAAA,YAAAA;AACAC,oBAAAA,aAAAA;AACAE,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;YAEA,IAAI,CAACG,QAAAA,CAASQ,EAAE,EAAE;AAChB7B,gBAAAA,MAAAA,CAAOmB,GAAG,CAACV,KAAK,CACd,CAAC,iCAAiC,EAAEY,QAAAA,CAASS,MAAM,CAAC,CAAC,EAAET,QAAAA,CAASU,UAAU,CAAA,CAAE,CAAA;AAG9E,gBAAA,MAAM,IAAIrB,KAAAA,CAAM,CAAC,iCAAiC,EAAEW,QAAAA,CAASU,UAAU,CAAA,CAAE,CAAA;AAC3E,YAAA;YAEA,OAAQ,MAAMV,SAASW,IAAI,EAAA;AAG7B,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var aiTranslationsStrapiManaged = require('./ai-translations-strapi-managed.js');
|
|
4
|
+
|
|
5
|
+
const createAITranslationsService = ({ strapi })=>{
|
|
6
|
+
let registeredProvider = null;
|
|
7
|
+
const resolveProvider = ()=>{
|
|
8
|
+
if (!strapi.ai.admin.isAvailable()) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return registeredProvider;
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
hasProvider () {
|
|
15
|
+
return resolveProvider() !== null;
|
|
16
|
+
},
|
|
17
|
+
registerProvider ({ provider }) {
|
|
18
|
+
if (!strapi.ai.admin.authorizeCustomProvider()) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (registeredProvider !== null) {
|
|
22
|
+
throw new Error(`The AI translations provider "${registeredProvider.name}" is already registered, "${provider.name}" cannot replace it.`);
|
|
23
|
+
}
|
|
24
|
+
registeredProvider = provider;
|
|
25
|
+
},
|
|
26
|
+
registerStrapiManagedProvider () {
|
|
27
|
+
if (!strapi.ai.admin.isStrapiManagedAiEnabled()) {
|
|
28
|
+
strapi.log.warn('The Strapi-managed AI translations provider was ignored: the Strapi license does not include the "cms-ai" feature.');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const provider = aiTranslationsStrapiManaged.createStrapiManagedAiTranslationsProvider({
|
|
32
|
+
strapi
|
|
33
|
+
});
|
|
34
|
+
if (registeredProvider !== null) {
|
|
35
|
+
throw new Error(`The AI translations provider "${registeredProvider.name}" is already registered, "${provider.name}" cannot replace it.`);
|
|
36
|
+
}
|
|
37
|
+
registeredProvider = provider;
|
|
38
|
+
},
|
|
39
|
+
async generateTranslations (params) {
|
|
40
|
+
const provider = resolveProvider();
|
|
41
|
+
if (provider === null) {
|
|
42
|
+
throw new Error('No AI translations provider is registered.');
|
|
43
|
+
}
|
|
44
|
+
return provider.generateTranslations(params);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.createAITranslationsService = createAITranslationsService;
|
|
50
|
+
//# sourceMappingURL=ai-translations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-translations.js","sources":["../../../server/src/services/ai-translations.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { createStrapiManagedAiTranslationsProvider } from './ai-translations-strapi-managed';\n\nexport type GenerateTranslationsParams = {\n sourceLocale: string;\n targetLocales: string[];\n content: Record<string, unknown>;\n contentTypeSchema: Record<string, Record<string, unknown>>;\n};\n\nexport type GenerateTranslationsResult = {\n localizations: Array<{ content: Record<string, unknown>; locale: string }>;\n};\n\nexport type AiTranslationsProvider = Modules.AI.AiProvider & {\n generateTranslations: (params: GenerateTranslationsParams) => Promise<GenerateTranslationsResult>;\n};\n\nexport interface AiTranslationsService {\n hasProvider(): boolean;\n registerProvider(params: { provider: AiTranslationsProvider }): void;\n registerStrapiManagedProvider(): void;\n generateTranslations(params: GenerateTranslationsParams): Promise<GenerateTranslationsResult>;\n}\n\nconst createAITranslationsService = ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): AiTranslationsService => {\n let registeredProvider: AiTranslationsProvider | null = null;\n\n const resolveProvider = (): AiTranslationsProvider | null => {\n if (!strapi.ai.admin.isAvailable()) {\n return null;\n }\n\n return registeredProvider;\n };\n\n return {\n hasProvider(): boolean {\n return resolveProvider() !== null;\n },\n\n registerProvider({ provider }: { provider: AiTranslationsProvider }) {\n if (!strapi.ai.admin.authorizeCustomProvider()) {\n return;\n }\n\n if (registeredProvider !== null) {\n throw new Error(\n `The AI translations provider \"${registeredProvider.name}\" is already registered, \"${provider.name}\" cannot replace it.`\n );\n }\n\n registeredProvider = provider;\n },\n\n registerStrapiManagedProvider() {\n if (!strapi.ai.admin.isStrapiManagedAiEnabled()) {\n strapi.log.warn(\n 'The Strapi-managed AI translations provider was ignored: the Strapi license does not include the \"cms-ai\" feature.'\n );\n return;\n }\n\n const provider = createStrapiManagedAiTranslationsProvider({ strapi });\n\n if (registeredProvider !== null) {\n throw new Error(\n `The AI translations provider \"${registeredProvider.name}\" is already registered, \"${provider.name}\" cannot replace it.`\n );\n }\n\n registeredProvider = provider;\n },\n\n async generateTranslations(\n params: GenerateTranslationsParams\n ): Promise<GenerateTranslationsResult> {\n const provider = resolveProvider();\n\n if (provider === null) {\n throw new Error('No AI translations provider is registered.');\n }\n\n return provider.generateTranslations(params);\n },\n };\n};\n\nexport { createAITranslationsService };\n"],"names":["createAITranslationsService","strapi","registeredProvider","resolveProvider","ai","admin","isAvailable","hasProvider","registerProvider","provider","authorizeCustomProvider","Error","name","registerStrapiManagedProvider","isStrapiManagedAiEnabled","log","warn","createStrapiManagedAiTranslationsProvider","generateTranslations","params"],"mappings":";;;;AAyBA,MAAMA,2BAAAA,GAA8B,CAAC,EACnCC,MAAM,EAGP,GAAA;AACC,IAAA,IAAIC,kBAAAA,GAAoD,IAAA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O,QAAAA;AACvB,QAAA,CAAA;AAEA,QAAA,MAAMS,sBACJC,MAAkC,EAAA;AAElC,YAAA,MAAMV,QAAAA,GAAWN,eAAAA,EAAAA;AAEjB,YAAA,IAAIM,aAAa,IAAA,EAAM;AACrB,gBAAA,MAAM,IAAIE,KAAAA,CAAM,4CAAA,CAAA;AAClB,YAAA;YAEA,OAAOF,QAAAA,CAASS,oBAAoB,CAACC,MAAAA,CAAAA;AACvC,QAAA;AACF,KAAA;AACF;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createStrapiManagedAiTranslationsProvider } from './ai-translations-strapi-managed.mjs';
|
|
2
|
+
|
|
3
|
+
const createAITranslationsService = ({ strapi })=>{
|
|
4
|
+
let registeredProvider = null;
|
|
5
|
+
const resolveProvider = ()=>{
|
|
6
|
+
if (!strapi.ai.admin.isAvailable()) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return registeredProvider;
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
hasProvider () {
|
|
13
|
+
return resolveProvider() !== null;
|
|
14
|
+
},
|
|
15
|
+
registerProvider ({ provider }) {
|
|
16
|
+
if (!strapi.ai.admin.authorizeCustomProvider()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (registeredProvider !== null) {
|
|
20
|
+
throw new Error(`The AI translations provider "${registeredProvider.name}" is already registered, "${provider.name}" cannot replace it.`);
|
|
21
|
+
}
|
|
22
|
+
registeredProvider = provider;
|
|
23
|
+
},
|
|
24
|
+
registerStrapiManagedProvider () {
|
|
25
|
+
if (!strapi.ai.admin.isStrapiManagedAiEnabled()) {
|
|
26
|
+
strapi.log.warn('The Strapi-managed AI translations provider was ignored: the Strapi license does not include the "cms-ai" feature.');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const provider = createStrapiManagedAiTranslationsProvider({
|
|
30
|
+
strapi
|
|
31
|
+
});
|
|
32
|
+
if (registeredProvider !== null) {
|
|
33
|
+
throw new Error(`The AI translations provider "${registeredProvider.name}" is already registered, "${provider.name}" cannot replace it.`);
|
|
34
|
+
}
|
|
35
|
+
registeredProvider = provider;
|
|
36
|
+
},
|
|
37
|
+
async generateTranslations (params) {
|
|
38
|
+
const provider = resolveProvider();
|
|
39
|
+
if (provider === null) {
|
|
40
|
+
throw new Error('No AI translations provider is registered.');
|
|
41
|
+
}
|
|
42
|
+
return provider.generateTranslations(params);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { createAITranslationsService };
|
|
48
|
+
//# sourceMappingURL=ai-translations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-translations.mjs","sources":["../../../server/src/services/ai-translations.ts"],"sourcesContent":["import type { Core, Modules } from '@strapi/types';\nimport { createStrapiManagedAiTranslationsProvider } from './ai-translations-strapi-managed';\n\nexport type GenerateTranslationsParams = {\n sourceLocale: string;\n targetLocales: string[];\n content: Record<string, unknown>;\n contentTypeSchema: Record<string, Record<string, unknown>>;\n};\n\nexport type GenerateTranslationsResult = {\n localizations: Array<{ content: Record<string, unknown>; locale: string }>;\n};\n\nexport type AiTranslationsProvider = Modules.AI.AiProvider & {\n generateTranslations: (params: GenerateTranslationsParams) => Promise<GenerateTranslationsResult>;\n};\n\nexport interface AiTranslationsService {\n hasProvider(): boolean;\n registerProvider(params: { provider: AiTranslationsProvider }): void;\n registerStrapiManagedProvider(): void;\n generateTranslations(params: GenerateTranslationsParams): Promise<GenerateTranslationsResult>;\n}\n\nconst createAITranslationsService = ({\n strapi,\n}: {\n strapi: Core.Strapi;\n}): AiTranslationsService => {\n let registeredProvider: AiTranslationsProvider | null = null;\n\n const resolveProvider = (): AiTranslationsProvider | null => {\n if (!strapi.ai.admin.isAvailable()) {\n return null;\n }\n\n return registeredProvider;\n };\n\n return {\n hasProvider(): boolean {\n return resolveProvider() !== null;\n },\n\n registerProvider({ provider }: { provider: AiTranslationsProvider }) {\n if (!strapi.ai.admin.authorizeCustomProvider()) {\n return;\n }\n\n if (registeredProvider !== null) {\n throw new Error(\n `The AI translations provider \"${registeredProvider.name}\" is already registered, \"${provider.name}\" cannot replace it.`\n );\n }\n\n registeredProvider = provider;\n },\n\n registerStrapiManagedProvider() {\n if (!strapi.ai.admin.isStrapiManagedAiEnabled()) {\n strapi.log.warn(\n 'The Strapi-managed AI translations provider was ignored: the Strapi license does not include the \"cms-ai\" feature.'\n );\n return;\n }\n\n const provider = createStrapiManagedAiTranslationsProvider({ strapi });\n\n if (registeredProvider !== null) {\n throw new Error(\n `The AI translations provider \"${registeredProvider.name}\" is already registered, \"${provider.name}\" cannot replace it.`\n );\n }\n\n registeredProvider = provider;\n },\n\n async generateTranslations(\n params: GenerateTranslationsParams\n ): Promise<GenerateTranslationsResult> {\n const provider = resolveProvider();\n\n if (provider === null) {\n throw new Error('No AI translations provider is registered.');\n }\n\n return provider.generateTranslations(params);\n },\n };\n};\n\nexport { createAITranslationsService };\n"],"names":["createAITranslationsService","strapi","registeredProvider","resolveProvider","ai","admin","isAvailable","hasProvider","registerProvider","provider","authorizeCustomProvider","Error","name","registerStrapiManagedProvider","isStrapiManagedAiEnabled","log","warn","createStrapiManagedAiTranslationsProvider","generateTranslations","params"],"mappings":";;AAyBA,MAAMA,2BAAAA,GAA8B,CAAC,EACnCC,MAAM,EAGP,GAAA;AACC,IAAA,IAAIC,kBAAAA,GAAoD,IAAA;AAExD,IAAA,MAAMC,eAAAA,GAAkB,IAAA;AACtB,QAAA,IAAI,CAACF,MAAAA,CAAOG,EAAE,CAACC,KAAK,CAACC,WAAW,EAAA,EAAI;YAClC,OAAO,IAAA;AACT,QAAA;QAEA,OAAOJ,kBAAAA;AACT,IAAA,CAAA;IAEA,OAAO;AACLK,QAAAA,WAAAA,CAAAA,GAAAA;AACE,YAAA,OAAOJ,eAAAA,EAAAA,KAAsB,IAAA;AAC/B,QAAA,CAAA;QAEAK,gBAAAA,CAAAA,CAAiB,EA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entTypes = require('./content-types.js');
|
|
|
9
9
|
var index = require('./sanitize/index.js');
|
|
10
10
|
var settings = require('./settings.js');
|
|
11
11
|
var aiLocalizations = require('./ai-localizations.js');
|
|
12
|
+
var aiTranslations = require('./ai-translations.js');
|
|
12
13
|
var aiLocalizationJobs = require('./ai-localization-jobs.js');
|
|
13
14
|
var fillFromLocale = require('./fill-from-locale.js');
|
|
14
15
|
|
|
@@ -21,6 +22,7 @@ var services = {
|
|
|
21
22
|
'iso-locales': isoLocales,
|
|
22
23
|
'content-types': contentTypes,
|
|
23
24
|
'ai-localizations': aiLocalizations.createAILocalizationsService,
|
|
25
|
+
'ai-translations': aiTranslations.createAITranslationsService,
|
|
24
26
|
'ai-localization-jobs': aiLocalizationJobs.createAILocalizationJobsService,
|
|
25
27
|
settings: settings.createSettingsService,
|
|
26
28
|
'fill-from-locale': fillFromLocale.createFillFromLocaleService
|
|
@@ -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';\nimport { createSettingsService } from './settings';\nimport { createAILocalizationsService } from './ai-localizations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\nimport { createFillFromLocaleService } from './fill-from-locale';\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 'fill-from-locale': createFillFromLocaleService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAILocalizationJobsService","settings","createSettingsService","createFillFromLocaleService"],"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 { createAITranslationsService } from './ai-translations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\nimport { createFillFromLocaleService } from './fill-from-locale';\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-translations': createAITranslationsService,\n 'ai-localization-jobs': createAILocalizationJobsService,\n settings: createSettingsService,\n 'fill-from-locale': createFillFromLocaleService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAITranslationsService","createAILocalizationJobsService","settings","createSettingsService","createFillFromLocaleService"],"mappings":";;;;;;;;;;;;;;;AAaA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,cAAAA,KAAAA;IACA,aAAA,EAAeC,UAAAA;IACf,eAAA,EAAiBC,YAAAA;IACjB,kBAAA,EAAoBC,4CAAAA;IACpB,iBAAA,EAAmBC,0CAAAA;IACnB,sBAAA,EAAwBC,kDAAAA;IACxBC,QAAAA,EAAUC,8BAAAA;IACV,kBAAA,EAAoBC;AACtB,CAAA;;;;"}
|
|
@@ -7,6 +7,7 @@ import contentTypes from './content-types.mjs';
|
|
|
7
7
|
import sanitize from './sanitize/index.mjs';
|
|
8
8
|
import { createSettingsService } from './settings.mjs';
|
|
9
9
|
import { createAILocalizationsService } from './ai-localizations.mjs';
|
|
10
|
+
import { createAITranslationsService } from './ai-translations.mjs';
|
|
10
11
|
import { createAILocalizationJobsService } from './ai-localization-jobs.mjs';
|
|
11
12
|
import { createFillFromLocaleService } from './fill-from-locale.mjs';
|
|
12
13
|
|
|
@@ -19,6 +20,7 @@ var services = {
|
|
|
19
20
|
'iso-locales': isoLocalesService,
|
|
20
21
|
'content-types': contentTypes,
|
|
21
22
|
'ai-localizations': createAILocalizationsService,
|
|
23
|
+
'ai-translations': createAITranslationsService,
|
|
22
24
|
'ai-localization-jobs': createAILocalizationJobsService,
|
|
23
25
|
settings: createSettingsService,
|
|
24
26
|
'fill-from-locale': createFillFromLocaleService
|
|
@@ -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';\nimport { createSettingsService } from './settings';\nimport { createAILocalizationsService } from './ai-localizations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\nimport { createFillFromLocaleService } from './fill-from-locale';\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 'fill-from-locale': createFillFromLocaleService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAILocalizationJobsService","settings","createSettingsService","createFillFromLocaleService"],"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 { createAITranslationsService } from './ai-translations';\nimport { createAILocalizationJobsService } from './ai-localization-jobs';\nimport { createFillFromLocaleService } from './fill-from-locale';\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-translations': createAITranslationsService,\n 'ai-localization-jobs': createAILocalizationJobsService,\n settings: createSettingsService,\n 'fill-from-locale': createFillFromLocaleService,\n};\n"],"names":["permissions","metrics","localizations","locales","sanitize","isoLocales","contentTypes","createAILocalizationsService","createAITranslationsService","createAILocalizationJobsService","settings","createSettingsService","createFillFromLocaleService"],"mappings":";;;;;;;;;;;;;AAaA,eAAe;AACbA,IAAAA,WAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,QAAAA;IACA,aAAA,EAAeC,iBAAAA;IACf,eAAA,EAAiBC,YAAAA;IACjB,kBAAA,EAAoBC,4BAAAA;IACpB,iBAAA,EAAmBC,2BAAAA;IACnB,sBAAA,EAAwBC,+BAAAA;IACxBC,QAAAA,EAAUC,qBAAAA;IACV,kBAAA,EAAoBC;AACtB,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":";AAkFA,
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../../server/src/bootstrap.ts"],"names":[],"mappings":";AAkFA,wBAwCE"}
|
|
@@ -1 +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,
|
|
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,wBAuBE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { AiTranslationsProvider, AiTranslationsService, GenerateTranslationsParams, GenerateTranslationsResult, } from './services/ai-translations';
|
|
1
2
|
declare const _default: () => {
|
|
2
3
|
register: ({ strapi }: {
|
|
3
4
|
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
@@ -172,6 +173,9 @@ declare const _default: () => {
|
|
|
172
173
|
}): Promise<void>;
|
|
173
174
|
setupMiddleware(): void;
|
|
174
175
|
};
|
|
176
|
+
'ai-translations': ({ strapi, }: {
|
|
177
|
+
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
178
|
+
}) => import(".").AiTranslationsService;
|
|
175
179
|
'ai-localization-jobs': ({ strapi }: {
|
|
176
180
|
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
177
181
|
}) => {
|
|
@@ -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,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAUmJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;AARjM,wBAOG"}
|
|
@@ -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,MAAM,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
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,MAAM,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAkEhE;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,GAC1B,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EACrC,QAAQ,MAAM,CAAC,MAAM,EACrB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,GAAG,SAAS,KACvD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA4D7B,CAAC;AAEF,QAAA,MAAM,4BAA4B,GAAI,YAAY;IAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE;;IAcrE;;;;OAIG;wDAIA;QACD,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC;QACvB,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC;KACzC;;CAoPJ,CAAC;AAEF,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
import type { AiTranslationsProvider } from './ai-translations';
|
|
3
|
+
declare const createStrapiManagedAiTranslationsProvider: ({ strapi, }: {
|
|
4
|
+
strapi: Core.Strapi;
|
|
5
|
+
}) => AiTranslationsProvider;
|
|
6
|
+
export { createStrapiManagedAiTranslationsProvider };
|
|
7
|
+
//# sourceMappingURL=ai-translations-strapi-managed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-translations-strapi-managed.d.ts","sourceRoot":"","sources":["../../../../server/src/services/ai-translations-strapi-managed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,QAAA,MAAM,yCAAyC,GAAI,aAEhD;IACD,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACrB,KAAG,sBAiDH,CAAC;AAEF,OAAO,EAAE,yCAAyC,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Core, Modules } from '@strapi/types';
|
|
2
|
+
export type GenerateTranslationsParams = {
|
|
3
|
+
sourceLocale: string;
|
|
4
|
+
targetLocales: string[];
|
|
5
|
+
content: Record<string, unknown>;
|
|
6
|
+
contentTypeSchema: Record<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
export type GenerateTranslationsResult = {
|
|
9
|
+
localizations: Array<{
|
|
10
|
+
content: Record<string, unknown>;
|
|
11
|
+
locale: string;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
export type AiTranslationsProvider = Modules.AI.AiProvider & {
|
|
15
|
+
generateTranslations: (params: GenerateTranslationsParams) => Promise<GenerateTranslationsResult>;
|
|
16
|
+
};
|
|
17
|
+
export interface AiTranslationsService {
|
|
18
|
+
hasProvider(): boolean;
|
|
19
|
+
registerProvider(params: {
|
|
20
|
+
provider: AiTranslationsProvider;
|
|
21
|
+
}): void;
|
|
22
|
+
registerStrapiManagedProvider(): void;
|
|
23
|
+
generateTranslations(params: GenerateTranslationsParams): Promise<GenerateTranslationsResult>;
|
|
24
|
+
}
|
|
25
|
+
declare const createAITranslationsService: ({ strapi, }: {
|
|
26
|
+
strapi: Core.Strapi;
|
|
27
|
+
}) => AiTranslationsService;
|
|
28
|
+
export { createAITranslationsService };
|
|
29
|
+
//# sourceMappingURL=ai-translations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-translations.d.ts","sourceRoot":"","sources":["../../../../server/src/services/ai-translations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGnD,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG;IAC3D,oBAAoB,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACnG,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,WAAW,IAAI,OAAO,CAAC;IACvB,gBAAgB,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,sBAAsB,CAAA;KAAE,GAAG,IAAI,CAAC;IACrE,6BAA6B,IAAI,IAAI,CAAC;IACtC,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;CAC/F;AAED,QAAA,MAAM,2BAA2B,GAAI,aAElC;IACD,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;CACrB,KAAG,qBA6DH,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -92,6 +92,9 @@ declare const _default: {
|
|
|
92
92
|
}): Promise<void>;
|
|
93
93
|
setupMiddleware(): void;
|
|
94
94
|
};
|
|
95
|
+
'ai-translations': ({ strapi, }: {
|
|
96
|
+
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
97
|
+
}) => import("./ai-translations").AiTranslationsService;
|
|
95
98
|
'ai-localization-jobs': ({ strapi }: {
|
|
96
99
|
strapi: import("@strapi/types/dist/core/strapi.js").Strapi;
|
|
97
100
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkBS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBACJ,CAAC;;;;;;;;;;;;;;;;;;;;AANP,wBAaE"}
|
|
@@ -8,6 +8,7 @@ import type { SanitizeService } from '../services/sanitize';
|
|
|
8
8
|
import type { SettingsService } from '../services/settings';
|
|
9
9
|
import type { createAILocalizationsService } from '../services/ai-localizations';
|
|
10
10
|
import type { createAILocalizationJobsService } from '../services/ai-localization-jobs';
|
|
11
|
+
import type { createAITranslationsService } from '../services/ai-translations';
|
|
11
12
|
import type { createFillFromLocaleService } from '../services/fill-from-locale';
|
|
12
13
|
type S = {
|
|
13
14
|
permissions: PermissionsService;
|
|
@@ -20,6 +21,7 @@ type S = {
|
|
|
20
21
|
sanitize: SanitizeService;
|
|
21
22
|
['ai-localizations']: ReturnType<typeof createAILocalizationsService>;
|
|
22
23
|
'ai-localization-jobs': ReturnType<typeof createAILocalizationJobsService>;
|
|
24
|
+
'ai-translations': ReturnType<typeof createAITranslationsService>;
|
|
23
25
|
'fill-from-locale': ReturnType<typeof createFillFromLocaleService>;
|
|
24
26
|
};
|
|
25
27
|
declare const getCoreStore: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACxF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAEhF,KAAK,CAAC,GAAG;IACP,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,eAAe,CAAC;IAC1B,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACnC,CAAC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACvC,QAAQ,EAAE,eAAe,CAAC;IAC1B,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC;IACtE,sBAAsB,EAAE,UAAU,CAA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C;AAEhF,KAAK,CAAC,GAAG;IACP,WAAW,EAAE,kBAAkB,CAAC;IAChC,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,oBAAoB,CAAC;IACpC,QAAQ,EAAE,eAAe,CAAC;IAC1B,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IACnC,CAAC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACvC,QAAQ,EAAE,eAAe,CAAC;IAC1B,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC;IACtE,sBAAsB,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC;IAC3E,iBAAiB,EAAE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;IAClE,kBAAkB,EAAE,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;CACpE,CAAC;AAEF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;CAEjB,CAAC;AAGF,QAAA,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,CAAC,EACnC,MAAM,CAAC,KACN,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAE7D,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\nimport type { SettingsService } from '../services/settings';\nimport type { createAILocalizationsService } from '../services/ai-localizations';\nimport type { createAILocalizationJobsService } from '../services/ai-localization-jobs';\nimport type { createFillFromLocaleService } from '../services/fill-from-locale';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n settings: SettingsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;\n 'ai-localization-jobs': ReturnType<typeof createAILocalizationJobsService>;\n 'fill-from-locale': ReturnType<typeof createFillFromLocaleService>;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(\n name: T\n): S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T] => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\nimport type { SettingsService } from '../services/settings';\nimport type { createAILocalizationsService } from '../services/ai-localizations';\nimport type { createAILocalizationJobsService } from '../services/ai-localization-jobs';\nimport type { createAITranslationsService } from '../services/ai-translations';\nimport type { createFillFromLocaleService } from '../services/fill-from-locale';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n settings: SettingsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;\n 'ai-localization-jobs': ReturnType<typeof createAILocalizationJobsService>;\n 'ai-translations': ReturnType<typeof createAITranslationsService>;\n 'fill-from-locale': ReturnType<typeof createFillFromLocaleService>;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(\n name: T\n): S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T] => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":";;AA4BA,MAAMA,YAAAA,GAAe,IAAA;IACnB,OAAOC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAAA,EAAM,QAAA;QAAUC,IAAAA,EAAM;AAAO,KAAA,CAAA;AACrD;AAEA;AACA,MAAMC,aAAa,CACjBD,IAAAA,GAAAA;AAEA,IAAA,OAAOH,MAAAA,CAAOK,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAACH,IAAAA,CAAAA;AACvC;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\nimport type { SettingsService } from '../services/settings';\nimport type { createAILocalizationsService } from '../services/ai-localizations';\nimport type { createAILocalizationJobsService } from '../services/ai-localization-jobs';\nimport type { createFillFromLocaleService } from '../services/fill-from-locale';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n settings: SettingsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;\n 'ai-localization-jobs': ReturnType<typeof createAILocalizationJobsService>;\n 'fill-from-locale': ReturnType<typeof createFillFromLocaleService>;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(\n name: T\n): S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T] => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../server/src/utils/index.ts"],"sourcesContent":["import type { LocaleService } from '../services/locales';\nimport type { PermissionsService } from '../services/permissions';\nimport type { ContentTypesService } from '../services/content-types';\nimport type { MetricsService } from '../services/metrics';\nimport type { ISOLocalesService } from '../services/iso-locales';\nimport type { LocalizationsService } from '../services/localizations';\nimport type { SanitizeService } from '../services/sanitize';\nimport type { SettingsService } from '../services/settings';\nimport type { createAILocalizationsService } from '../services/ai-localizations';\nimport type { createAILocalizationJobsService } from '../services/ai-localization-jobs';\nimport type { createAITranslationsService } from '../services/ai-translations';\nimport type { createFillFromLocaleService } from '../services/fill-from-locale';\n\ntype S = {\n permissions: PermissionsService;\n metrics: MetricsService;\n locales: LocaleService;\n localizations: LocalizationsService;\n settings: SettingsService;\n ['iso-locales']: ISOLocalesService;\n ['content-types']: ContentTypesService;\n sanitize: SanitizeService;\n ['ai-localizations']: ReturnType<typeof createAILocalizationsService>;\n 'ai-localization-jobs': ReturnType<typeof createAILocalizationJobsService>;\n 'ai-translations': ReturnType<typeof createAITranslationsService>;\n 'fill-from-locale': ReturnType<typeof createFillFromLocaleService>;\n};\n\nconst getCoreStore = () => {\n return strapi.store({ type: 'plugin', name: 'i18n' });\n};\n\n// retrieve a local service\nconst getService = <T extends keyof S>(\n name: T\n): S[T] extends (...args: any) => any ? ReturnType<S[T]> : S[T] => {\n return strapi.plugin('i18n').service(name);\n};\n\nexport { getService, getCoreStore };\n"],"names":["getCoreStore","strapi","store","type","name","getService","plugin","service"],"mappings":"AA4BA,MAAMA,YAAAA,GAAe,IAAA;IACnB,OAAOC,MAAAA,CAAOC,KAAK,CAAC;QAAEC,IAAAA,EAAM,QAAA;QAAUC,IAAAA,EAAM;AAAO,KAAA,CAAA;AACrD;AAEA;AACA,MAAMC,aAAa,CACjBD,IAAAA,GAAAA;AAEA,IAAA,OAAOH,MAAAA,CAAOK,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAACH,IAAAA,CAAAA;AACvC;;;;"}
|