locai 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -897
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/commands/review.d.ts +109 -0
  5. package/dist/commands/translator.d.ts +23 -0
  6. package/dist/config/index.d.ts +145 -0
  7. package/dist/core/adapters/base-adapter.d.ts +20 -0
  8. package/dist/core/adapters/factory.d.ts +16 -0
  9. package/dist/core/adapters/json-adapter.d.ts +9 -0
  10. package/dist/core/adapters/po-adapter.d.ts +9 -0
  11. package/dist/core/adapters/properties-adapter.d.ts +9 -0
  12. package/dist/core/adapters/yaml-adapter.d.ts +9 -0
  13. package/dist/core/context-processor.d.ts +81 -0
  14. package/dist/core/detection/framework-detector.d.ts +9 -0
  15. package/dist/core/detection/structure-detector.d.ts +9 -0
  16. package/dist/core/fallback-provider.d.ts +54 -0
  17. package/dist/core/orchestrator.d.ts +101 -0
  18. package/dist/core/orchestrator.js +0 -1
  19. package/dist/core/pipeline/Pipeline.d.ts +23 -0
  20. package/dist/core/pipeline/PipelineStep.d.ts +18 -0
  21. package/dist/core/pipeline/context.d.ts +29 -0
  22. package/dist/core/pipeline/steps/CacheReadStep.d.ts +25 -0
  23. package/dist/core/pipeline/steps/CacheWriteStep.d.ts +11 -0
  24. package/dist/core/pipeline/steps/ConfidenceCheckStep.d.ts +10 -0
  25. package/dist/core/pipeline/steps/GlossaryPostStep.d.ts +9 -0
  26. package/dist/core/pipeline/steps/GlossaryPreStep.d.ts +9 -0
  27. package/dist/core/pipeline/steps/InputValidationStep.d.ts +8 -0
  28. package/dist/core/pipeline/steps/QualityCheckStep.d.ts +10 -0
  29. package/dist/core/pipeline/steps/ToneCheckStep.d.ts +13 -0
  30. package/dist/core/pipeline/steps/TranslationStep.d.ts +22 -0
  31. package/dist/core/pipeline/steps/VectorCacheReadStep.d.ts +17 -0
  32. package/dist/core/pipeline/steps/VectorCacheWriteStep.d.ts +11 -0
  33. package/dist/core/pipeline/steps/__tests__/ToneCheckStep.test.d.ts +1 -0
  34. package/dist/core/provider-factory.d.ts +41 -0
  35. package/dist/providers/base-provider.d.ts +66 -0
  36. package/dist/providers/dashscope.d.ts +24 -0
  37. package/dist/providers/deepseek.d.ts +22 -0
  38. package/dist/providers/gemini.d.ts +22 -0
  39. package/dist/providers/openai.d.ts +28 -0
  40. package/dist/providers/xai.d.ts +22 -0
  41. package/dist/services/embedding-provider.d.ts +26 -0
  42. package/dist/services/translation-service.d.ts +138 -0
  43. package/dist/services/translation-service.js +1 -1
  44. package/dist/services/vector-store.d.ts +26 -0
  45. package/dist/utils/ai-context-analyzer.d.ts +73 -0
  46. package/dist/utils/confidence-scorer.d.ts +77 -0
  47. package/dist/utils/error-helper.d.ts +87 -0
  48. package/dist/utils/file-manager.d.ts +129 -0
  49. package/dist/utils/glossary-manager.d.ts +69 -0
  50. package/dist/utils/graceful-shutdown.d.ts +22 -0
  51. package/dist/utils/input-validator.d.ts +227 -0
  52. package/dist/utils/logger.d.ts +134 -0
  53. package/dist/utils/object-transformer.d.ts +38 -0
  54. package/dist/utils/progress-tracker.d.ts +63 -0
  55. package/dist/utils/prompt-templates.d.ts +37 -0
  56. package/dist/utils/quality/__tests__/tone-verifier.test.d.ts +1 -0
  57. package/dist/utils/quality/base-checker.d.ts +79 -0
  58. package/dist/utils/quality/code-block-checker.d.ts +64 -0
  59. package/dist/utils/quality/html-tag-checker.d.ts +33 -0
  60. package/dist/utils/quality/index.d.ts +39 -0
  61. package/dist/utils/quality/length-checker.d.ts +70 -0
  62. package/dist/utils/quality/markdown-checker.d.ts +63 -0
  63. package/dist/utils/quality/placeholder-checker.d.ts +42 -0
  64. package/dist/utils/quality/punctuation-checker.d.ts +31 -0
  65. package/dist/utils/quality/quote-balance-checker.d.ts +37 -0
  66. package/dist/utils/quality/special-characters-checker.d.ts +66 -0
  67. package/dist/utils/quality/style-guide-checker.d.ts +71 -0
  68. package/dist/utils/quality/text-sanitizer.d.ts +51 -0
  69. package/dist/utils/quality/tone-verifier.d.ts +14 -0
  70. package/dist/utils/rate-limiter.d.ts +73 -0
  71. package/dist/utils/retry-helper.d.ts +49 -0
  72. package/dist/utils/state-manager.d.ts +62 -0
  73. package/dist/utils/statistics-manager.d.ts +47 -0
  74. package/dist/utils/ui-manager.d.ts +21 -0
  75. package/package.json +19 -4
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Interactive Review Command.
3
+ * Allows manual review of low-confidence translations.
4
+ */
5
+ interface ReviewItem {
6
+ key: string;
7
+ language: string;
8
+ source: string;
9
+ translation: string;
10
+ confidence: {
11
+ score: number;
12
+ level: string;
13
+ issues: Array<{
14
+ severity: string;
15
+ message: string;
16
+ }>;
17
+ };
18
+ category?: string;
19
+ sourceLang?: string;
20
+ edited?: boolean;
21
+ editedAt?: string;
22
+ }
23
+ interface ReviewCommandConfig {
24
+ localesDir: string;
25
+ source: string;
26
+ [key: string]: any;
27
+ }
28
+ declare class ReviewCommand {
29
+ private config;
30
+ private reviewQueue;
31
+ private currentIndex;
32
+ private decisions;
33
+ /**
34
+ * Initialize ReviewCommand.
35
+ * @param {ReviewCommandConfig} config - Configuration object.
36
+ */
37
+ constructor(config: ReviewCommandConfig);
38
+ /**
39
+ * Load review queue from cache file.
40
+ * @returns {boolean} - True if loaded successfully, else false.
41
+ */
42
+ loadReviewQueue(): boolean;
43
+ /**
44
+ * Start interactive review session.
45
+ */
46
+ startReview(): Promise<void>;
47
+ /**
48
+ * Review a single translation item.
49
+ * @param {ReviewItem} item - Translation item to review.
50
+ * @param {number} current - Current item index (1-based).
51
+ * @param {number} total - Total items.
52
+ * @returns {Promise<string>} - Decision result.
53
+ */
54
+ reviewItem(item: ReviewItem, current: number, total: number): Promise<string>;
55
+ /**
56
+ * Handle user action input.
57
+ * @param {string} action - User action code.
58
+ * @param {ReviewItem} item - Current item.
59
+ * @returns {Promise<string>} - Result status.
60
+ */
61
+ handleAction(action: string, item: ReviewItem): Promise<string>;
62
+ /**
63
+ * Edit translation interactively.
64
+ * @param {ReviewItem} item - Item to edit.
65
+ * @returns {Promise<ReviewItem>} - Edited item.
66
+ */
67
+ editTranslation(item: ReviewItem): Promise<ReviewItem>;
68
+ /**
69
+ * Show help information to the user.
70
+ */
71
+ showHelp(): void;
72
+ /**
73
+ * Show summary of review session.
74
+ */
75
+ showSummary(): void;
76
+ /**
77
+ * Save review decisions to disk and apply them.
78
+ */
79
+ saveDecisions(): void;
80
+ /**
81
+ * Apply accepted and edited translations to locale files.
82
+ */
83
+ applyDecisions(): void;
84
+ /**
85
+ * Set nested value in object using dot notation.
86
+ * @param {any} obj - Object to modify.
87
+ * @param {string} path - Dot notation path.
88
+ * @param {any} value - Value to set.
89
+ */
90
+ setNestedValue(obj: any, path: string, value: any): void;
91
+ /**
92
+ * Get user input from terminal.
93
+ * @param {string} prompt - Prompt to display.
94
+ * @returns {Promise<string>} - User input.
95
+ */
96
+ getUserInput(prompt: string): Promise<string>;
97
+ /**
98
+ * Export review queue to JSON.
99
+ * @param {string} format - Export format (json or csv).
100
+ */
101
+ exportReviewQueue(format?: string): void;
102
+ /**
103
+ * Convert review queue to CSV format.
104
+ * @param {ReviewItem[]} items - Items to convert.
105
+ * @returns {string} - CSV content.
106
+ */
107
+ convertToCSV(items: ReviewItem[]): string;
108
+ }
109
+ export default ReviewCommand;
@@ -0,0 +1,23 @@
1
+ import { TranslationOptions, GlobalStats } from "../services/translation-service.js";
2
+ /**
3
+ * Main translator function to process source file and create translations.
4
+ * @param {string} file - Source file path.
5
+ * @param {TranslationOptions} options - Translation options.
6
+ * @returns {Promise<GlobalStats>} - Translation result.
7
+ */
8
+ declare function translateFile(file: string, options: TranslationOptions): Promise<GlobalStats>;
9
+ /**
10
+ * Find locale files based on source language.
11
+ * @param {string} localesDir - Locales directory.
12
+ * @param {string} sourceLang - Source language code.
13
+ * @returns {Promise<Array<string>>} - Array of locale file paths.
14
+ */
15
+ declare function findLocaleFiles(localesDir: string, sourceLang: string): Promise<string[]>;
16
+ /**
17
+ * Validate and fix existing translations that have length issues.
18
+ * @param {string} file - File path to validate.
19
+ * @param {TranslationOptions} options - Validation options.
20
+ * @returns {Promise<void>}
21
+ */
22
+ declare function validateAndFixExistingTranslations(file: string, options: TranslationOptions): Promise<void>;
23
+ export { translateFile, findLocaleFiles, validateAndFixExistingTranslations };
@@ -0,0 +1,145 @@
1
+ import { ConfigLayer } from "c12";
2
+ import { OrchestratorOptions } from "../core/orchestrator.js";
3
+ export interface LocalizeConfig extends Omit<Partial<OrchestratorOptions>, "context"> {
4
+ /**
5
+ * Source language code (e.g. 'en')
6
+ */
7
+ source?: string;
8
+ /**
9
+ * Target language codes (e.g. ['tr', 'es'])
10
+ */
11
+ targets?: string[];
12
+ /**
13
+ * Filter by file extensions (e.g. ['.json', '.arb'])
14
+ */
15
+ fileExtensions?: string[];
16
+ /**
17
+ * Directory where localization files are stored
18
+ * @default "./locales"
19
+ */
20
+ localesDir?: string;
21
+ /**
22
+ * API Provider to use for translations
23
+ * @default "openai"
24
+ */
25
+ apiProvider?: string;
26
+ /**
27
+ * Enable debug mode with verbose logging
28
+ * @default false
29
+ */
30
+ debug?: boolean;
31
+ /**
32
+ * Force update of existing translations
33
+ * @default false
34
+ */
35
+ forceUpdate?: boolean;
36
+ /**
37
+ * Synchronization options
38
+ */
39
+ syncOptions?: {
40
+ enabled?: boolean;
41
+ removeDeletedKeys?: boolean;
42
+ retranslateModified?: boolean;
43
+ stateTracking?: {
44
+ enabled?: boolean;
45
+ stateFileName?: string;
46
+ stateDir?: string;
47
+ };
48
+ };
49
+ /**
50
+ * Concurrency limit for parallel translations
51
+ * @default 5
52
+ */
53
+ concurrencyLimit?: number;
54
+ /**
55
+ * Save low-confidence items for manual review
56
+ * @default false
57
+ */
58
+ saveReviewQueue?: boolean;
59
+ /**
60
+ * Minimum confidence threshold (0-1)
61
+ */
62
+ minConfidence?: number;
63
+ fileOperations?: {
64
+ /**
65
+ * File format to use (json, yaml, po, properties, etc.)
66
+ * @default "json"
67
+ */
68
+ format?: "json" | "yaml" | "po" | "properties" | "arb" | "auto";
69
+ /**
70
+ * File structure (flat, nested, namespaced)
71
+ * @default "flat"
72
+ */
73
+ fileStructure?: "flat" | "nested" | "namespaced" | "auto";
74
+ backupFiles?: boolean;
75
+ backupDir?: string;
76
+ atomic?: boolean;
77
+ createMissingDirs?: boolean;
78
+ };
79
+ useAi?: boolean;
80
+ contextProvider?: string;
81
+ contextThreshold?: number;
82
+ contextConfidence?: number;
83
+ length?: string;
84
+ autoOptimize?: boolean;
85
+ stats?: boolean;
86
+ maxRetries?: number;
87
+ initialDelay?: number;
88
+ maxDelay?: number;
89
+ contextDebug?: boolean;
90
+ minTextLength?: number;
91
+ allowNewCategories?: boolean;
92
+ provider?: string;
93
+ concurrency?: number | string;
94
+ noCache?: boolean;
95
+ force?: boolean;
96
+ verbose?: boolean;
97
+ version?: string;
98
+ rateLimiter?: {
99
+ enabled?: boolean;
100
+ queueStrategy?: string;
101
+ queueTimeout?: number;
102
+ adaptiveThrottling?: boolean;
103
+ providerLimits?: any;
104
+ };
105
+ context?: {
106
+ enabled?: boolean;
107
+ useAI?: boolean;
108
+ aiProvider?: string;
109
+ minTextLength?: number;
110
+ allowNewCategories?: boolean;
111
+ debug?: boolean;
112
+ analysisOptions?: {
113
+ model?: string;
114
+ temperature?: number;
115
+ maxTokens?: number;
116
+ cacheAnalysis?: boolean;
117
+ };
118
+ detection?: {
119
+ threshold?: number;
120
+ minConfidence?: number;
121
+ };
122
+ categories?: any;
123
+ fallback?: any;
124
+ };
125
+ qualityChecks?: {
126
+ enabled?: boolean;
127
+ rules?: any;
128
+ autoFix?: boolean;
129
+ };
130
+ command?: string;
131
+ fixLength?: boolean;
132
+ showDetailedStats?: boolean;
133
+ }
134
+ /**
135
+ * Type-safe configuration helper
136
+ */
137
+ export declare function defineConfig(config: LocalizeConfig): LocalizeConfig;
138
+ /**
139
+ * Load configuration using c12
140
+ */
141
+ export declare function loadConfig(cwd?: string): Promise<{
142
+ config: LocalizeConfig;
143
+ configFile: string | undefined;
144
+ layers: ConfigLayer<LocalizeConfig, import("c12").ConfigLayerMeta>[] | undefined;
145
+ }>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Interface for file format adapters
3
+ */
4
+ export interface FileFormatAdapter {
5
+ /**
6
+ * File extensions supported by this adapter (including dot, e.g. ".json")
7
+ */
8
+ extensions: string[];
9
+ /**
10
+ * Parse file content into a key-value object
11
+ * @param content - Raw string content
12
+ */
13
+ parse(content: string): Promise<Record<string, any>>;
14
+ /**
15
+ * Serialize data object into string format
16
+ * @param data - Key-value object
17
+ * @param options - Serialization options
18
+ */
19
+ serialize(data: Record<string, any>, options?: any): Promise<string>;
20
+ }
@@ -0,0 +1,16 @@
1
+ import { FileFormatAdapter } from "./base-adapter.js";
2
+ /**
3
+ * Factory class to manage file format adapters
4
+ */
5
+ export declare class FormatFactory {
6
+ private static adapters;
7
+ /**
8
+ * Get adapter for a specific file path
9
+ * @param filePath - Path to file
10
+ */
11
+ static getAdapter(filePath: string): FileFormatAdapter;
12
+ /**
13
+ * Get adapter by format name (json, yaml, etc.)
14
+ */
15
+ static getAdapterByFormat(format: string): FileFormatAdapter;
16
+ }
@@ -0,0 +1,9 @@
1
+ import { FileFormatAdapter } from "./base-adapter.js";
2
+ /**
3
+ * Adapter for JSON files
4
+ */
5
+ export declare class JsonAdapter implements FileFormatAdapter {
6
+ extensions: string[];
7
+ parse(content: string): Promise<Record<string, any>>;
8
+ serialize(data: Record<string, any>, options?: any): Promise<string>;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { FileFormatAdapter } from "./base-adapter.js";
2
+ /**
3
+ * Adapter for Gettext PO files
4
+ */
5
+ export declare class PoAdapter implements FileFormatAdapter {
6
+ extensions: string[];
7
+ parse(content: string): Promise<Record<string, any>>;
8
+ serialize(data: Record<string, any>, options?: any): Promise<string>;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { FileFormatAdapter } from "./base-adapter.js";
2
+ /**
3
+ * Adapter for Java .properties files
4
+ */
5
+ export declare class PropertiesAdapter implements FileFormatAdapter {
6
+ extensions: string[];
7
+ parse(content: string): Promise<Record<string, any>>;
8
+ serialize(data: Record<string, any>, options?: any): Promise<string>;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { FileFormatAdapter } from "./base-adapter.js";
2
+ /**
3
+ * Adapter for YAML files
4
+ */
5
+ export declare class YamlAdapter implements FileFormatAdapter {
6
+ extensions: string[];
7
+ parse(content: string): Promise<Record<string, any>>;
8
+ serialize(data: Record<string, any>, options?: any): Promise<string>;
9
+ }
@@ -0,0 +1,81 @@
1
+ interface CategoryConfig {
2
+ keywords: string[];
3
+ weight?: number;
4
+ prompt?: string;
5
+ }
6
+ export interface ContextConfig {
7
+ enabled?: boolean;
8
+ useAI?: boolean;
9
+ aiProvider?: string;
10
+ minTextLength?: number;
11
+ analysisOptions?: {
12
+ cacheAnalysis?: boolean;
13
+ };
14
+ categories: Record<string, CategoryConfig>;
15
+ detection: {
16
+ threshold: number;
17
+ minConfidence: number;
18
+ };
19
+ fallback: {
20
+ category: string;
21
+ prompt: string;
22
+ };
23
+ }
24
+ interface AnalysisResult {
25
+ category: string;
26
+ confidence: number;
27
+ prompt?: string;
28
+ matches: number;
29
+ aiAnalyzed?: boolean;
30
+ keywords?: string[];
31
+ }
32
+ /**
33
+ * Handles context analysis for translation keys.
34
+ * Uses keyword matching and optional AI analysis to determine the best context category.
35
+ */
36
+ declare class ContextProcessor {
37
+ private config;
38
+ private keywordCache;
39
+ private aiAnalyzer;
40
+ private resultCache;
41
+ /**
42
+ * Create a new ContextProcessor instance.
43
+ * @param config - Configuration object.
44
+ */
45
+ constructor(config: any);
46
+ /**
47
+ * Initialize keyword matching patterns from configuration.
48
+ */
49
+ initializeKeywords(): void;
50
+ /**
51
+ * Perform context analysis on a batch of texts.
52
+ * @param texts - Array of texts to analyze.
53
+ * @returns - Array of context analysis results.
54
+ */
55
+ analyzeBatch(texts: string[]): Promise<AnalysisResult[]>;
56
+ /**
57
+ * Perform context analysis on a single text.
58
+ * @param text - Text to analyze.
59
+ * @returns - Context analysis result.
60
+ */
61
+ analyze(text: string): Promise<AnalysisResult>;
62
+ /**
63
+ * Perform keyword-based analysis on text.
64
+ * @param text - Text to analyze.
65
+ * @returns - Keyword analysis result.
66
+ */
67
+ private _performKeywordAnalysis;
68
+ /**
69
+ * Determine the best category match from analysis results.
70
+ */
71
+ private getBestMatch;
72
+ /**
73
+ * Get fallback analysis result.
74
+ */
75
+ private getFallback;
76
+ /**
77
+ * Generate a collision-resistant cache key for text and context.
78
+ */
79
+ private getCacheKey;
80
+ }
81
+ export default ContextProcessor;
@@ -0,0 +1,9 @@
1
+ export interface DetectedConfig {
2
+ framework: "next" | "vue" | "react" | "flutter" | "unknown";
3
+ localesDir?: string;
4
+ fileFormat?: "json" | "yaml" | "po" | "arb" | "properties";
5
+ source?: string;
6
+ }
7
+ export declare class FrameworkDetector {
8
+ static detect(projectRoot: string): Promise<DetectedConfig | null>;
9
+ }
@@ -0,0 +1,9 @@
1
+ export declare enum LocaleStructure {
2
+ FLAT = "flat",// en.json, tr.json
3
+ NESTED = "nested",// en/common.json, tr/common.json
4
+ NAMESPACED = "namespaced",// common.en.json (less common)
5
+ UNKNOWN = "unknown"
6
+ }
7
+ export declare class StructureDetector {
8
+ static detect(localesDir: string): Promise<LocaleStructure>;
9
+ }
@@ -0,0 +1,54 @@
1
+ import { TranslateOptions, ProviderConfig } from "../providers/base-provider.js";
2
+ export interface ProviderModule {
3
+ translate(text: string, sourceLang: string, targetLang: string, options?: TranslateOptions): Promise<string>;
4
+ analyze?(prompt: string, options?: ProviderConfig): Promise<string>;
5
+ chat?(messages: any[], options?: ProviderConfig): Promise<string>;
6
+ [key: string]: any;
7
+ }
8
+ export interface ProviderWrapper {
9
+ name: string;
10
+ implementation: ProviderModule;
11
+ }
12
+ interface ProviderStats {
13
+ success: number;
14
+ failure: number;
15
+ avgResponseTime: number;
16
+ totalTime: number;
17
+ lastSuccess: Date | null;
18
+ consecutiveFailures: number;
19
+ lastError: {
20
+ time: Date;
21
+ message: string;
22
+ } | null;
23
+ disabled: boolean;
24
+ disabledUntil: number | null;
25
+ successRate?: number;
26
+ totalCalls?: number;
27
+ avgResponseTimeMs?: number;
28
+ isDisabled?: boolean;
29
+ enablesInMs?: number;
30
+ }
31
+ declare class FallbackProvider {
32
+ private providers;
33
+ private currentIndex;
34
+ private providerStats;
35
+ private maxRetries;
36
+ private reRankInterval;
37
+ private operationCount;
38
+ private lastErrorTime;
39
+ private consecutiveErrors;
40
+ constructor(providers: ProviderWrapper[]);
41
+ _calculatePriority(text: string): number;
42
+ translate(text: string, sourceLang: string, targetLang: string, options?: TranslateOptions): Promise<string>;
43
+ analyze(prompt: string, options?: ProviderConfig): Promise<string>;
44
+ chat(messages: any[], options?: ProviderConfig): Promise<string>;
45
+ getStats(): Record<string, ProviderStats>;
46
+ reset(): void;
47
+ resetStats(): void;
48
+ _checkAndReRankProviders(): void;
49
+ _disableProvider(provider: ProviderWrapper, timeoutMs?: number): void;
50
+ _isProviderDisabled(provider?: ProviderWrapper): boolean;
51
+ _resetDisabledProviders(): void;
52
+ _getProviderName(provider: ProviderWrapper): string;
53
+ }
54
+ export default FallbackProvider;
@@ -0,0 +1,101 @@
1
+ import ProgressTracker from "../utils/progress-tracker.js";
2
+ import QualityChecker from "../utils/quality/index.js";
3
+ import { ContextConfig } from "./context-processor.js";
4
+ import { LRUCache } from "lru-cache";
5
+ import GlossaryManager from "../utils/glossary-manager.js";
6
+ import { TranslationResult } from "./pipeline/context.js";
7
+ import { CacheStats } from "./pipeline/steps/CacheReadStep.js";
8
+ import { ConfidenceSettings } from "./pipeline/steps/TranslationStep.js";
9
+ export interface OrchestratorOptions {
10
+ context: ContextConfig;
11
+ progressOptions?: any;
12
+ styleGuide?: any;
13
+ lengthControl?: any;
14
+ qualityChecks?: {
15
+ enabled?: boolean;
16
+ rules?: any;
17
+ };
18
+ advanced?: {
19
+ timeoutMs?: number;
20
+ maxKeyLength?: number;
21
+ maxBatchSize?: number;
22
+ autoOptimize?: boolean;
23
+ debug?: boolean;
24
+ };
25
+ glossary?: any;
26
+ rateLimiter?: {
27
+ queueStrategy?: string;
28
+ queueTimeout?: number;
29
+ adaptiveThrottling?: boolean;
30
+ providerLimits?: any;
31
+ };
32
+ cacheSize?: number;
33
+ cacheTTL?: number;
34
+ updateAgeOnGet?: boolean;
35
+ allowStaleCache?: boolean;
36
+ staleWhileRevalidate?: boolean;
37
+ minConfidence?: number;
38
+ saveReviewQueue?: boolean;
39
+ confidenceScoring?: {
40
+ enabled?: boolean;
41
+ minConfidence?: number;
42
+ saveReviewQueue?: boolean;
43
+ autoApproveThreshold?: number;
44
+ reviewThreshold?: number;
45
+ rejectThreshold?: number;
46
+ };
47
+ concurrencyLimit?: number;
48
+ cacheEnabled?: boolean;
49
+ source: string;
50
+ [key: string]: any;
51
+ }
52
+ import { VectorStore } from "../services/vector-store.js";
53
+ import { EmbeddingProvider } from "../services/embedding-provider.js";
54
+ import { VectorMemoryStats } from "./pipeline/steps/VectorCacheReadStep.js";
55
+ interface AdvancedSettings {
56
+ timeoutMs: number;
57
+ maxKeyLength: number;
58
+ maxBatchSize: number;
59
+ autoOptimize: boolean;
60
+ debug: boolean;
61
+ }
62
+ interface TranslationItem {
63
+ key: string;
64
+ text: string;
65
+ targetLang: string;
66
+ existingTranslation?: any;
67
+ [key: string]: any;
68
+ }
69
+ declare class Orchestrator {
70
+ private options;
71
+ private contextProcessor;
72
+ progress: ProgressTracker;
73
+ qualityChecker: QualityChecker | any;
74
+ advanced: AdvancedSettings;
75
+ glossaryManager: GlossaryManager;
76
+ translationCache: LRUCache<string, any> | null;
77
+ cacheStats: CacheStats;
78
+ vectorStore: VectorStore;
79
+ embeddingProvider: EmbeddingProvider;
80
+ vectorStats: VectorMemoryStats;
81
+ confidenceSettings: ConfidenceSettings;
82
+ private concurrencyLimit;
83
+ private pipeline;
84
+ private _shutdownCallback;
85
+ constructor(options: OrchestratorOptions);
86
+ private _buildPipeline;
87
+ processTranslation(key: string, text: string, targetLang: string, contextData: any, existingTranslation: any): Promise<TranslationResult>;
88
+ processTranslations(items: TranslationItem[]): Promise<TranslationResult[]>;
89
+ private _chunkArray;
90
+ private _applyAutoOptimizations;
91
+ clearCache(): void;
92
+ resetCacheStats(): void;
93
+ getCacheStats(): any;
94
+ _refreshCacheEntry(key: string, context: any): Promise<void>;
95
+ getStatus(): any;
96
+ saveReviewQueue(): void;
97
+ private _groupByLanguage;
98
+ private _groupByConfidenceLevel;
99
+ destroy(): void;
100
+ }
101
+ export default Orchestrator;
@@ -222,7 +222,6 @@ class Orchestrator {
222
222
  if (this.advanced.debug) {
223
223
  log(`Processing ${items.length} items with concurrency limit ${this.concurrencyLimit}`, true);
224
224
  }
225
- console.log(""); // Empty line for progress bar
226
225
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
227
226
  const allPromises = [];
228
227
  for (const chunk of chunks) {
@@ -0,0 +1,23 @@
1
+ import PipelineStep from "./PipelineStep.js";
2
+ import { TranslationContext } from "./context.js";
3
+ /**
4
+ * Generic Pipeline class implementing the middleware pattern.
5
+ * Allows composing a sequence of steps that can process a context object.
6
+ */
7
+ declare class Pipeline {
8
+ steps: any[];
9
+ constructor();
10
+ /**
11
+ * Add a step to the pipeline.
12
+ * @param step - A step instance with an execute(context, next) method.
13
+ * @returns - Returns self for chaining.
14
+ */
15
+ use(step: PipelineStep | any): Pipeline;
16
+ /**
17
+ * Execute the pipeline with the given context.
18
+ * @param context - The context object to be processed.
19
+ * @returns - The processed context.
20
+ */
21
+ execute(context: TranslationContext): Promise<TranslationContext>;
22
+ }
23
+ export default Pipeline;
@@ -0,0 +1,18 @@
1
+ import { TranslationContext } from "./context.js";
2
+ /**
3
+ * Base class for pipeline steps.
4
+ * All steps should extend this or implement the execute method.
5
+ */
6
+ declare abstract class PipelineStep {
7
+ /**
8
+ * Name of the step for debugging/logging purposes.
9
+ */
10
+ get name(): string;
11
+ /**
12
+ * Execute the step logic.
13
+ * @param context - Translation context.
14
+ * @param next - Next step callback.
15
+ */
16
+ abstract execute(context: TranslationContext, next: () => Promise<void>): Promise<void>;
17
+ }
18
+ export default PipelineStep;