@i18nprune/core 0.1.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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -0
  3. package/dist/adapters-gp1lXp0T.d.ts +12 -0
  4. package/dist/capabilities-x74cD2Hu.d.ts +48 -0
  5. package/dist/cleanup.d.ts +64 -0
  6. package/dist/cleanup.js +3999 -0
  7. package/dist/config.d.ts +201 -0
  8. package/dist/config.js +2865 -0
  9. package/dist/coreContext-DMaWLvmB.d.ts +388 -0
  10. package/dist/fs-BUYD8ZhA.d.ts +20 -0
  11. package/dist/generate.d.ts +487 -0
  12. package/dist/generate.js +9389 -0
  13. package/dist/humanEmit-ygNlYX-S.d.ts +79 -0
  14. package/dist/index-BQuLEQ9b.d.ts +7 -0
  15. package/dist/index-B_ow_Xvr.d.ts +97 -0
  16. package/dist/index-BgG01AKL.d.ts +287 -0
  17. package/dist/index-CIzZl4W8.d.ts +124 -0
  18. package/dist/index-Csm1w7XD.d.ts +58 -0
  19. package/dist/index-DLwTogCo.d.ts +43 -0
  20. package/dist/index-DVT26v11.d.ts +61 -0
  21. package/dist/index-DdjljwMj.d.ts +39 -0
  22. package/dist/index-DeIw-cZd.d.ts +52 -0
  23. package/dist/index-X50E1FIX.d.ts +50 -0
  24. package/dist/index.d.ts +9180 -0
  25. package/dist/index.js +21888 -0
  26. package/dist/init.d.ts +86 -0
  27. package/dist/init.js +848 -0
  28. package/dist/listWindow-XEFxQZi1.d.ts +30 -0
  29. package/dist/localeTargetCodes-BBIQjauw.d.ts +11 -0
  30. package/dist/locales.d.ts +39 -0
  31. package/dist/locales.js +2288 -0
  32. package/dist/missing-BVCvgUC8.d.ts +10 -0
  33. package/dist/missing.d.ts +85 -0
  34. package/dist/missing.js +5892 -0
  35. package/dist/modeResolve-cGVaY5Hh.d.ts +25 -0
  36. package/dist/path-Bfn3SAts.d.ts +11 -0
  37. package/dist/profile-BwOP9WKh.d.ts +9 -0
  38. package/dist/providers-0uMEfT6q.d.ts +82 -0
  39. package/dist/prune-c6hKZCv_.d.ts +33 -0
  40. package/dist/quality.d.ts +36 -0
  41. package/dist/quality.js +3868 -0
  42. package/dist/report-D5-6bVFj.d.ts +8 -0
  43. package/dist/report-schema.d.ts +102 -0
  44. package/dist/report-schema.js +42 -0
  45. package/dist/resumeCandidates-xR13eEwt.d.ts +200 -0
  46. package/dist/root-2-kCaBvQ.d.ts +1110 -0
  47. package/dist/runtime/edge.d.ts +21 -0
  48. package/dist/runtime/edge.js +87 -0
  49. package/dist/runtime/helpers/sync.d.ts +16 -0
  50. package/dist/runtime/helpers/sync.js +117 -0
  51. package/dist/runtime/node.d.ts +24 -0
  52. package/dist/runtime/node.js +204 -0
  53. package/dist/runtime/web.d.ts +21 -0
  54. package/dist/runtime/web.js +84 -0
  55. package/dist/shared.d.ts +1177 -0
  56. package/dist/shared.js +4897 -0
  57. package/dist/sourceContext-1LQg3HiQ.d.ts +36 -0
  58. package/dist/sourceSurface-mDtwGo1E.d.ts +122 -0
  59. package/dist/sync.d.ts +86 -0
  60. package/dist/sync.js +4971 -0
  61. package/dist/syncSegment-Bx6He2Mu.d.ts +149 -0
  62. package/dist/targets-EmtKyr6F.d.ts +23 -0
  63. package/dist/template-CGM-_WLT.d.ts +139 -0
  64. package/dist/translate-CIHYp7wi.d.ts +77 -0
  65. package/dist/types/shared.d.ts +21 -0
  66. package/dist/types/shared.js +1 -0
  67. package/dist/types.d.ts +1345 -0
  68. package/dist/types.js +1 -0
  69. package/dist/validate.d.ts +126 -0
  70. package/dist/validate.js +3717 -0
  71. package/package.json +128 -0
@@ -0,0 +1,25 @@
1
+ import { L as LocaleMetadataReport, a as LocaleLeafMode } from './index-DLwTogCo.js';
2
+ import { R as ResolveLocaleLeafModeInput } from './index-B_ow_Xvr.js';
3
+
4
+ declare function metadataModeEnabledFromConfig(mode: LocaleLeafMode | undefined): boolean;
5
+ /** Resolve final leaf mode with stable precedence: strip > metadata > config > legacy default. */
6
+ declare function resolveLocaleLeafMode(input: ResolveLocaleLeafModeInput): {
7
+ mode: LocaleLeafMode;
8
+ conflict: boolean;
9
+ reason: 'strip_precedence' | 'explicit_metadata' | 'config_structured' | 'default_legacy';
10
+ };
11
+ /**
12
+ * Resolve locale leaf mode ({@link resolveLocaleLeafMode}) then {@link applyLocaleLeafMode}.
13
+ * Shared by **generate** (including **`generate --resume`**) immediately after translation passes.
14
+ */
15
+ declare function applyLocaleLeafNormalization(input: {
16
+ localeJson: unknown;
17
+ sourceMap: Map<string, string>;
18
+ resolveInput: ResolveLocaleLeafModeInput;
19
+ }): {
20
+ next: unknown;
21
+ report: LocaleMetadataReport;
22
+ modeDecision: ReturnType<typeof resolveLocaleLeafMode>;
23
+ };
24
+
25
+ export { applyLocaleLeafNormalization as a, metadataModeEnabledFromConfig as m, resolveLocaleLeafMode as r };
@@ -0,0 +1,11 @@
1
+ type RuntimePathPort = {
2
+ join: (...parts: string[]) => string;
3
+ dirname: (value: string) => string;
4
+ basename: (value: string, ext?: string) => string;
5
+ normalize: (value: string) => string;
6
+ relative: (from: string, to: string) => string;
7
+ resolve: (...parts: string[]) => string;
8
+ isAbsolute: (value: string) => boolean;
9
+ };
10
+
11
+ export type { RuntimePathPort as R };
@@ -0,0 +1,9 @@
1
+ /** Named cache presets; resolved via {@link resolveCacheConfig}. */
2
+ type CacheProfileId = 'safe' | 'balanced' | 'fast';
3
+ type CacheProfileDefaults = {
4
+ rebuild: 'partial' | 'full';
5
+ fullRescanThresholdPercent: number;
6
+ mode: 'readWrite' | 'readOnly';
7
+ };
8
+
9
+ export type { CacheProfileId as C, CacheProfileDefaults as a };
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Translation provider registry — **ids**, **descriptors** for clients (CLI help, doctor), and
3
+ * **resolved options** passed into {@link resolveTranslator} (secrets supplied by the client, never logged by core).
4
+ *
5
+ * **LLM backends:** resolved options carry **OpenAI-compatible** fields (`baseUrl`, `apiKey`, `model`); implementations follow later.
6
+ */
7
+ /** Registered translation backends (`resolveTranslator` may not implement every id yet). */
8
+ type TranslationProviderId = 'google' | 'mymemory' | 'deepl' | 'libre' | 'llm';
9
+ type TranslationProviderKind = 'public_http' | 'api_key' | 'llm';
10
+ /** Declares an env var for docs / CLI validation (names only — never values). */
11
+ type TranslationProviderEnvVar = {
12
+ key: string;
13
+ description: string;
14
+ required: boolean;
15
+ };
16
+ /**
17
+ * Static metadata for **`--help`**, **`doctor`**, and programmatic discovery.
18
+ * Safe to serialize to JSON (no secrets).
19
+ */
20
+ type TranslationProviderDescriptor = {
21
+ id: TranslationProviderId;
22
+ label: string;
23
+ kind: TranslationProviderKind;
24
+ /** Env vars this provider may read (documented for tooling — values are merged by CLI, not core). */
25
+ envVars: readonly TranslationProviderEnvVar[];
26
+ /** Optional notes for authoring **`translate.providers`** `{ id, … }` rows in **`i18nprune.config.*`**. */
27
+ configKeys?: readonly {
28
+ key: string;
29
+ description: string;
30
+ optional: boolean;
31
+ }[];
32
+ };
33
+ /**
34
+ * Optional execution hints from the **client** (CLI / host). Core may apply these for retries,
35
+ * pacing, or future AI rate limits — **never** store API tokens here.
36
+ */
37
+ type TranslationClientHints = {
38
+ /** Override max attempts for transient failures (default from `translateLeaf` / provider). */
39
+ maxRetries?: number;
40
+ /** Minimum delay ms between outbound translation requests (future: AI rate limits). */
41
+ minDelayMs?: number;
42
+ };
43
+ type GoogleResolvedTranslationOptions = {
44
+ provider: 'google';
45
+ hints?: TranslationClientHints;
46
+ };
47
+ type MymemoryResolvedTranslationOptions = {
48
+ provider: 'mymemory';
49
+ /** Optional — raises MyMemory quota when set (per MyMemory docs). */
50
+ contactEmail?: string;
51
+ hints?: TranslationClientHints;
52
+ };
53
+ type LibreResolvedTranslationOptions = {
54
+ provider: 'libre';
55
+ /** LibreTranslate-compatible API origin (no trailing slash), e.g. `https://libretranslate.de`. */
56
+ baseUrl?: string;
57
+ hints?: TranslationClientHints;
58
+ };
59
+ type DeeplResolvedTranslationOptions = {
60
+ provider: 'deepl';
61
+ /** DeepL API token (provided by CLI from config/env — core must not log). */
62
+ apiKey?: string;
63
+ hints?: TranslationClientHints;
64
+ };
65
+ /**
66
+ * OpenAI-compatible HTTP API (`/v1/chat/completions`-style hosts).
67
+ * Resolved by CLI from the **`llm`** **`translate.providers`** row + `I18NPRUNE_TRANSLATE_LLM_*` env.
68
+ */
69
+ type LlmResolvedTranslationOptions = {
70
+ provider: 'llm';
71
+ apiKey?: string;
72
+ /** Base URL including protocol, e.g. `https://api.openai.com/v1` or a proxy. */
73
+ baseUrl?: string;
74
+ model?: string;
75
+ hints?: TranslationClientHints;
76
+ };
77
+ /**
78
+ * Discriminated union — clients construct this from argv + env + config file; core only consumes.
79
+ */
80
+ type ResolvedTranslationProviderOptions = GoogleResolvedTranslationOptions | MymemoryResolvedTranslationOptions | LibreResolvedTranslationOptions | DeeplResolvedTranslationOptions | LlmResolvedTranslationOptions;
81
+
82
+ export type { DeeplResolvedTranslationOptions as D, GoogleResolvedTranslationOptions as G, LibreResolvedTranslationOptions as L, MymemoryResolvedTranslationOptions as M, ResolvedTranslationProviderOptions as R, TranslationProviderId as T, LlmResolvedTranslationOptions as a, TranslationClientHints as b, TranslationProviderDescriptor as c, TranslationProviderEnvVar as d, TranslationProviderKind as e };
@@ -0,0 +1,33 @@
1
+ type MergeToTemplateOptions = {
2
+ /**
3
+ * Keep extra **object** keys present in `target` but not in `template` when their dotted path
4
+ * matches any prefix (uncertain / dynamic key protection). Array length extras are unchanged.
5
+ */
6
+ uncertainKeepPrefixes?: string[];
7
+ /** Source leaf paths that should keep target values but should not hydrate missing target paths. */
8
+ skipFillPaths?: readonly string[];
9
+ /** Target leaf paths that should be overwritten from the template source value. */
10
+ forceFillPaths?: readonly string[];
11
+ };
12
+ /**
13
+ * Merge `target` toward `template` shape: keep existing translations where paths match;
14
+ * fill missing from template (source strings); remove extras; preserve paths forced to source.
15
+ *
16
+ * Terminals follow the template type: plain string leaves preserve **whole** `{ value, … }` locale objects
17
+ * when the template leaf is a string (structured metadata is not flattened here — use strip flows when needed).
18
+ */
19
+ declare function mergeToTemplateShape(template: unknown, target: unknown, preserve: unknown | undefined, options?: MergeToTemplateOptions): unknown;
20
+ /** Apply preserve: set paths in `target` from `source` verbatim. */
21
+ declare function applyPreserveFromSource(target: unknown, source: unknown, paths: string[]): unknown;
22
+
23
+ type PruneToTemplateOptions = {
24
+ /** Keep extra object keys in `target` when their path matches (same semantics as merge). */
25
+ uncertainKeepPrefixes?: string[];
26
+ };
27
+ /**
28
+ * Remove keys from `target` that are not present in `template` (recursive object shape only).
29
+ * Optionally retains extra branches that match uncertain key prefixes (sync with dynamic keys).
30
+ */
31
+ declare function pruneToTemplateShape(template: unknown, target: unknown, options?: PruneToTemplateOptions): unknown;
32
+
33
+ export { type MergeToTemplateOptions as M, type PruneToTemplateOptions as P, applyPreserveFromSource as a, mergeToTemplateShape as m, pruneToTemplateShape as p };
@@ -0,0 +1,36 @@
1
+ import { Q as QualityFileLine, a as QualityJsonData, C as ComputeEnglishIdenticalCountsInput, b as QualityRunOptions, c as QualityHostHooks, d as QualityRunResult } from './index-DVT26v11.js';
2
+ import { C as CoreContext } from './coreContext-DMaWLvmB.js';
3
+ import './index-X50E1FIX.js';
4
+ import './index-BQuLEQ9b.js';
5
+ import './root-2-kCaBvQ.js';
6
+ import 'zod';
7
+ import './path-Bfn3SAts.js';
8
+ import './fs-BUYD8ZhA.js';
9
+ import './providers-0uMEfT6q.js';
10
+ import './index-BgG01AKL.js';
11
+ import './capabilities-x74cD2Hu.js';
12
+ import './adapters-gp1lXp0T.js';
13
+
14
+ declare function buildQualityJsonData(input: {
15
+ total: number;
16
+ perFile: Record<string, number>;
17
+ dynamicKeySites: number;
18
+ sourceLocale: string;
19
+ localesDir: string;
20
+ localeCount: number;
21
+ targetLocaleCount: number;
22
+ files: QualityFileLine[];
23
+ }): QualityJsonData;
24
+
25
+ /**
26
+ * Count target locale leaves whose string value equals the source locale at the same path,
27
+ * after applying parity exclusions (same rules as the quality operation).
28
+ */
29
+ declare function computeEnglishIdenticalCounts(input: ComputeEnglishIdenticalCountsInput): {
30
+ total: number;
31
+ perFile: Record<string, number>;
32
+ };
33
+
34
+ declare function runQuality(ctx: CoreContext, opts: QualityRunOptions, host: QualityHostHooks): QualityRunResult;
35
+
36
+ export { QualityFileLine, QualityHostHooks, QualityJsonData, QualityRunOptions, QualityRunResult, buildQualityJsonData, computeEnglishIdenticalCounts, runQuality };