@strapi-ai/translator 0.0.1
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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/admin/SettingsPage-C5nm32bD.mjs +466 -0
- package/dist/admin/SettingsPage-CD90jfwT.js +466 -0
- package/dist/admin/en-CU6ocWlA.mjs +97 -0
- package/dist/admin/en-I9cvzxfF.js +97 -0
- package/dist/admin/index-CS0LCA35.mjs +1694 -0
- package/dist/admin/index-DQ3-ym--.js +1693 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/components/DiffView.d.ts +31 -0
- package/dist/admin/src/components/Initializer.d.ts +3 -0
- package/dist/admin/src/components/PluginIcon.d.ts +4 -0
- package/dist/admin/src/components/ProgressBar.d.ts +7 -0
- package/dist/admin/src/components/TranslationModal.d.ts +23 -0
- package/dist/admin/src/components/TranslationPanel.d.ts +4 -0
- package/dist/admin/src/components/TranslationWorkflow.d.ts +2 -0
- package/dist/admin/src/components/settings/ProviderConnectionFields.d.ts +12 -0
- package/dist/admin/src/components/settings/TranslationSettingsFields.d.ts +7 -0
- package/dist/admin/src/hooks/useProviderModels.d.ts +13 -0
- package/dist/admin/src/hooks/useTranslationConfig.d.ts +8 -0
- package/dist/admin/src/index.d.ts +12 -0
- package/dist/admin/src/pages/SettingsPage.d.ts +2 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/utils/clampNumber.d.ts +1 -0
- package/dist/admin/src/utils/configPayload.d.ts +23 -0
- package/dist/admin/src/utils/contentManagerLocale.d.ts +1 -0
- package/dist/admin/src/utils/getTranslation.d.ts +1 -0
- package/dist/admin/src/utils/providerDefaults.d.ts +10 -0
- package/dist/admin/src/utils/sse.d.ts +2 -0
- package/dist/admin/src/utils/translatableFields.d.ts +3 -0
- package/dist/admin/src/utils/translationPatch.d.ts +13 -0
- package/dist/server/index.js +1217 -0
- package/dist/server/index.mjs +1217 -0
- package/dist/server/src/application/assemble-translation-patch.d.ts +3 -0
- package/dist/server/src/application/extract-translatable-units.d.ts +9 -0
- package/dist/server/src/application/translate-entry.d.ts +17 -0
- package/dist/server/src/application/translation-provider.d.ts +33 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +5 -0
- package/dist/server/src/controllers/index.d.ts +27 -0
- package/dist/server/src/controllers/translation.controller.d.ts +28 -0
- package/dist/server/src/domain/field-path.d.ts +6 -0
- package/dist/server/src/domain/translation-config.d.ts +27 -0
- package/dist/server/src/domain/translation-event.d.ts +59 -0
- package/dist/server/src/domain/translation-patch.d.ts +11 -0
- package/dist/server/src/domain/translation-unit.d.ts +28 -0
- package/dist/server/src/domain/value-codecs/index.d.ts +3 -0
- package/dist/server/src/domain/value-codecs/string-codec.d.ts +2 -0
- package/dist/server/src/domain/value-codecs/structured-value-codec.d.ts +3 -0
- package/dist/server/src/domain/value-codecs/types.d.ts +11 -0
- package/dist/server/src/index.d.ts +64 -0
- package/dist/server/src/infrastructure/llm/chat-completion-client.d.ts +18 -0
- package/dist/server/src/infrastructure/llm/llm-translation-provider.d.ts +15 -0
- package/dist/server/src/infrastructure/llm/model-list-client.d.ts +19 -0
- package/dist/server/src/infrastructure/llm/openai-chat-completion-client.d.ts +6 -0
- package/dist/server/src/infrastructure/strapi/reconcile-schema.d.ts +7 -0
- package/dist/server/src/infrastructure/strapi/secret-cipher.d.ts +8 -0
- package/dist/server/src/infrastructure/strapi/translation-config-repository.d.ts +16 -0
- package/dist/server/src/infrastructure/strapi/translation-session-service.d.ts +37 -0
- package/dist/server/src/routes/index.d.ts +19 -0
- package/dist/server/src/services/index.d.ts +7 -0
- package/package.json +87 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type UnitStatus = 'pending' | 'translating' | 'done' | 'failed';
|
|
2
|
+
export interface DiffEntry {
|
|
3
|
+
key: string;
|
|
4
|
+
original: string;
|
|
5
|
+
translated: string;
|
|
6
|
+
current?: string;
|
|
7
|
+
changed: boolean;
|
|
8
|
+
editable: boolean;
|
|
9
|
+
included: boolean;
|
|
10
|
+
status?: UnitStatus;
|
|
11
|
+
}
|
|
12
|
+
interface DiffViewProps {
|
|
13
|
+
entries: DiffEntry[];
|
|
14
|
+
isStreaming?: boolean;
|
|
15
|
+
viewMode: ViewMode;
|
|
16
|
+
sourceLocale?: string;
|
|
17
|
+
targetLocale?: string;
|
|
18
|
+
onToggleField?: (key: string, included: boolean) => void;
|
|
19
|
+
onToggleAll?: (included: boolean) => void;
|
|
20
|
+
onEditField?: (key: string, value: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export type ViewMode = 'split' | 'preview' | 'diff';
|
|
23
|
+
export declare const VIEW_MODES: Array<{
|
|
24
|
+
mode: ViewMode;
|
|
25
|
+
id: string;
|
|
26
|
+
defaultMessage: string;
|
|
27
|
+
hintId: string;
|
|
28
|
+
hint: string;
|
|
29
|
+
}>;
|
|
30
|
+
declare const DiffView: ({ entries, isStreaming, viewMode, sourceLocale, targetLocale, onToggleField, onToggleAll, onEditField, }: DiffViewProps) => import("react").JSX.Element;
|
|
31
|
+
export default DiffView;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DiffEntry } from './DiffView';
|
|
2
|
+
interface TranslationModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
isStreaming: boolean;
|
|
5
|
+
sourceLocale: string;
|
|
6
|
+
targetLocale: string;
|
|
7
|
+
diffEntries: DiffEntry[];
|
|
8
|
+
progress: {
|
|
9
|
+
current: number;
|
|
10
|
+
total: number;
|
|
11
|
+
} | null;
|
|
12
|
+
currentField: string;
|
|
13
|
+
failedFields: string[];
|
|
14
|
+
elapsedTime: number;
|
|
15
|
+
onAccept: () => void;
|
|
16
|
+
onCancel: () => void;
|
|
17
|
+
onRetryFailed: () => void;
|
|
18
|
+
onToggleField: (key: string, included: boolean) => void;
|
|
19
|
+
onToggleAll: (included: boolean) => void;
|
|
20
|
+
onEditField: (key: string, value: string) => void;
|
|
21
|
+
}
|
|
22
|
+
declare const TranslationModal: ({ isOpen, isStreaming, sourceLocale, targetLocale, diffEntries, progress, currentField, failedFields, elapsedTime, onAccept, onCancel, onRetryFailed, onToggleField, onToggleAll, onEditField, }: TranslationModalProps) => import("react").JSX.Element;
|
|
23
|
+
export default TranslationModal;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginConfig } from '../../../custom';
|
|
2
|
+
import { ProviderModelOption } from '../../hooks/useProviderModels';
|
|
3
|
+
interface ProviderConnectionFieldsProps {
|
|
4
|
+
config: PluginConfig;
|
|
5
|
+
updateField: (field: keyof PluginConfig, value: any) => void;
|
|
6
|
+
onClearApiKey: () => void;
|
|
7
|
+
providerModels: ProviderModelOption[];
|
|
8
|
+
providerModelsError: string | null;
|
|
9
|
+
onLoadModels: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const ProviderConnectionFields: ({ config, updateField, onClearApiKey, providerModels, providerModelsError, onLoadModels, }: ProviderConnectionFieldsProps) => import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PluginConfig } from '../../../custom';
|
|
2
|
+
interface TranslationSettingsFieldsProps {
|
|
3
|
+
config: PluginConfig;
|
|
4
|
+
updateField: (field: keyof PluginConfig, value: any) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const TranslationSettingsFields: ({ config, updateField, }: TranslationSettingsFieldsProps) => import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ProviderModelOption {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
export interface DraftCredentials {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const useProviderModels: () => {
|
|
10
|
+
models: ProviderModelOption[];
|
|
11
|
+
error: string | null;
|
|
12
|
+
load: (draft?: DraftCredentials) => Promise<void>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PluginConfig } from '../../custom';
|
|
2
|
+
export declare const useTranslationConfig: () => {
|
|
3
|
+
config: PluginConfig;
|
|
4
|
+
save: (next: PluginConfig) => Promise<void>;
|
|
5
|
+
restore: () => Promise<void>;
|
|
6
|
+
clearApiKey: () => Promise<void>;
|
|
7
|
+
updateField: (field: keyof PluginConfig, value: any) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrapiApp } from '@strapi/strapi/admin';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
register(app: StrapiApp): void;
|
|
4
|
+
bootstrap(app: StrapiApp): void;
|
|
5
|
+
registerTrads({ locales }: {
|
|
6
|
+
locales: string[];
|
|
7
|
+
}): Promise<{
|
|
8
|
+
data: any;
|
|
9
|
+
locale: string;
|
|
10
|
+
}[]>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_ID = "ai-translator";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clampNumber: (value: number | undefined, defaultVal: number, min: number, max?: number) => number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PluginConfig } from '../../custom';
|
|
2
|
+
export declare const toEditablePayload: (settings: PluginConfig) => {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
model: string;
|
|
5
|
+
fallbackModel: string;
|
|
6
|
+
systemPrompt: string;
|
|
7
|
+
temperature: number;
|
|
8
|
+
maxTokens: number;
|
|
9
|
+
maxRetries: number;
|
|
10
|
+
retryBaseDelayMs: number;
|
|
11
|
+
retryMaxDelayMs: number;
|
|
12
|
+
} | {
|
|
13
|
+
apiKey: string;
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
model: string;
|
|
16
|
+
fallbackModel: string;
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
temperature: number;
|
|
19
|
+
maxTokens: number;
|
|
20
|
+
maxRetries: number;
|
|
21
|
+
retryBaseDelayMs: number;
|
|
22
|
+
retryMaxDelayMs: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getContentManagerLocale: () => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTranslation(id: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const DEFAULT_SYSTEM_PROMPT = "You are a CMS content translator. Output only the translated text, with no explanations, no quotes, and no metadata. Preserve formatting and markup exactly: Markdown, HTML, custom tags, links, images. Leave code blocks, URLs, query parameters, variables, and placeholders unchanged. Keep brand names, product names, and currency values in their original form. Translate meaning by meaning, using natural, concise wording and the standard terminology of the target locale.";
|
|
2
|
+
export declare const DEFAULT_PROVIDER_BASE_URL = "";
|
|
3
|
+
export declare const DEFAULT_PROVIDER_MODEL = "";
|
|
4
|
+
export declare const DEFAULT_PROVIDER_TEMPERATURE = 0.3;
|
|
5
|
+
export declare const MAX_PROVIDER_TEMPERATURE = 2;
|
|
6
|
+
export declare const MIN_PROVIDER_TEMPERATURE = 0;
|
|
7
|
+
export declare const DEFAULT_MAX_TOKENS = 0;
|
|
8
|
+
export declare const DEFAULT_MAX_RETRIES = 3;
|
|
9
|
+
export declare const DEFAULT_RETRY_BASE_DELAY_MS = 1000;
|
|
10
|
+
export declare const DEFAULT_RETRY_MAX_DELAY_MS = 30000;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TranslationPatch } from '../../custom';
|
|
2
|
+
export type FieldPath = Array<string | number>;
|
|
3
|
+
export declare const pathToLabel: (path: FieldPath | undefined) => string;
|
|
4
|
+
export declare const getValueByPath: (source: Record<string, any>, path: FieldPath) => unknown;
|
|
5
|
+
export declare const setValueByPath: (source: Record<string, any>, path: FieldPath, value: unknown) => Record<string, any>;
|
|
6
|
+
export declare const applyTranslationPatch: (source: Record<string, any>, patch: TranslationPatch) => Record<string, any>;
|
|
7
|
+
export declare const applyTranslationPatchToFillData: (fillData: Record<string, any> | null | undefined, sourceData: Record<string, any>, patch: TranslationPatch) => Record<string, any>;
|
|
8
|
+
export declare const mergeTranslationResult: ({ formValues, fillData, patch, }: {
|
|
9
|
+
formValues: Record<string, any>;
|
|
10
|
+
fillData: Record<string, any> | null | undefined;
|
|
11
|
+
patch: TranslationPatch;
|
|
12
|
+
}) => Record<string, any>;
|
|
13
|
+
export declare const hasTextContent: (value: unknown) => boolean;
|