@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,201 @@
1
+ import { I as I18nPruneConfig, L as LocalesFilesystemConfig, b as LocalesFilesystemConfig$1, c as LocaleLeafPathApi, d as ScannerConfigInput, e as ScannerConfigResolved, R as ResolveScannerConfigOptions, f as I18nPruneConfigParsed, g as ReferenceCommandOverrides } from './root-2-kCaBvQ.js';
2
+ export { C as CacheConfig, h as ConfigValidationError, E as EffectiveReferenceConfig, i as LocaleLeavesConfig, M as MissingCommandConfig, O as OutputConfig, j as OutputListConfig, P as ParityPolicy, k as PatchingConfig, l as Policies, a as PreservePolicy, m as ReferenceCommands, n as ReferenceConfig, o as ReferenceDefaults, S as StringPresencePolicy, p as TranslateConfig, q as TranslateMaxWorkersConfig, r as TranslatePolicyConfig, s as TranslateProviderRow, t as TranslateProviderRowDeepL, u as TranslateProviderRowGoogle, v as TranslateProviderRowLibre, w as TranslateProviderRowLlm, x as TranslateProviderRowMymemory, y as TranslateRateLimitConfig, U as UncertainKeyPolicy, z as configSchema, A as isConfigValidationError, B as localesFilesystemSchema, D as parseI18nPruneConfig } from './root-2-kCaBvQ.js';
3
+ import { R as RuntimeFsPort } from './fs-BUYD8ZhA.js';
4
+ import { C as CacheProfileId } from './profile-BwOP9WKh.js';
5
+ import { L as ListWindowResolved, R as ResolveListWindowOptions } from './listWindow-XEFxQZi1.js';
6
+ import { R as Result } from './index-X50E1FIX.js';
7
+ import { b as ConfigPathSystemRuntime } from './capabilities-x74cD2Hu.js';
8
+ import { T as TranslationProviderId } from './providers-0uMEfT6q.js';
9
+ import { T as TranslateConfigInput, R as ResolvedTranslateConfig, b as ResolveTranslateWarning } from './translate-CIHYp7wi.js';
10
+ export { c as ResolvedTranslateProviderRow, d as TranslatePolicyConfigInput, e as TranslateProviderRowInput, f as TranslateRateLimitConfigInput } from './translate-CIHYp7wi.js';
11
+ import 'zod';
12
+ import './path-Bfn3SAts.js';
13
+
14
+ /**
15
+ * Typed helper for **`i18nprune.config.{ts,mts,cts,js,mjs,cjs}`** files. Merges partial user input
16
+ * with **`DEFAULT_CONFIG`** and normalizes a few fields (notably **`translate.workers`** clamping)
17
+ * so the returned value matches what the CLI / SDK see at runtime.
18
+ *
19
+ * Returns the public friendly **`I18nPruneConfig`** directly — drop it straight into
20
+ * **`createCoreContext`**:
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // i18nprune.config.ts
25
+ * import { defineConfig } from '@i18nprune/core';
26
+ *
27
+ * export default defineConfig({
28
+ * locales: {
29
+ * source: 'en',
30
+ * directory: 'locales',
31
+ * },
32
+ * src: 'src',
33
+ * functions: ['t'],
34
+ * translate: {
35
+ * primary: 'google',
36
+ * providers: [{ id: 'google' }],
37
+ * },
38
+ * });
39
+ * ```
40
+ *
41
+ * @remarks
42
+ * - **`.json`** configs are intentionally not loaded by the CLI - see
43
+ * **`SUPPORTED_CONFIG_EXTENSIONS`** in **`packages/cli/src/shared/config/paths.ts`**.
44
+ * - **`locales.source`** and the zod schema are validated when the CLI loads the file via
45
+ * **`parseI18nPruneConfig`** (same path as a plain `export default { … }` config). Use
46
+ * **`parseI18nPruneConfig`** directly for REST / DB / generated sources.
47
+ * - Call this once per project; the file is loaded by the CLI host (or by an SDK consumer with
48
+ * **`loadCoreConfigFromPath`**).
49
+ */
50
+ declare function defineConfig(config: Partial<I18nPruneConfig>): I18nPruneConfig;
51
+
52
+ /** Clamp `translate.workers` / CLI `--workers` to `1…64`. */
53
+ declare function clampTranslateMaxWorkers(n: number): number;
54
+
55
+ /**
56
+ * Soft compatibility checks for `locales.mode` + `locales.structure` (warn only — does not block parse).
57
+ *
58
+ * @remarks Prefer this over zod `.superRefine` when the config should still load; hosts log warnings via
59
+ * `normalizeConfigRuntimeFields` (CLI) or equivalent.
60
+ */
61
+ declare function collectLocalesFilesystemConfigWarnings(locales: LocalesFilesystemConfig): string[];
62
+
63
+ type LocalesSourceInputKind = 'language_code' | 'path' | 'json_filename' | 'invalid_shape';
64
+ type LocalesSourceValidationResult = {
65
+ ok: true;
66
+ code: string;
67
+ } | {
68
+ ok: false;
69
+ issueCode: string;
70
+ message: string;
71
+ };
72
+
73
+ /** Classify raw `locales.source` before catalog / bundle checks. */
74
+ declare function classifyLocalesSourceInput(raw: string): LocalesSourceInputKind;
75
+ /**
76
+ * Validate `locales.source` is a supported language code (not a path or `*.json` basename).
77
+ * Used at config parse, CLI normalize, and readiness.
78
+ */
79
+ declare function validateLocalesSourceConfigValue(raw: string): LocalesSourceValidationResult;
80
+ /** Readiness: configured source code has no matching locale segments under `locales.directory`. */
81
+ declare function issueLocalesSourceNotInBundle(input: {
82
+ sourceCode: string;
83
+ directory: string;
84
+ presentCodes: readonly string[];
85
+ }): {
86
+ issueCode: string;
87
+ message: string;
88
+ };
89
+
90
+ /** Resolve the on-disk primary source locale JSON file from `locales.source` (language code). */
91
+ declare function resolveSourceLocaleAbsolutePath(input: {
92
+ locales: LocalesFilesystemConfig$1;
93
+ directoryAbsolute: string;
94
+ path: LocaleLeafPathApi;
95
+ fs?: RuntimeFsPort;
96
+ }): string;
97
+ /** Resolve source locale absolute path from project-relative archive paths (zip / upload prepare). */
98
+ declare function resolveSourceLocaleAbsoluteFromRelPaths(input: {
99
+ locales: LocalesFilesystemConfig$1;
100
+ directoryAbsolute: string;
101
+ projectRootAbsolute: string;
102
+ path: LocaleLeafPathApi;
103
+ relPaths: readonly string[];
104
+ }): string;
105
+
106
+ type OutputListConfigInput = {
107
+ top?: number;
108
+ full?: boolean;
109
+ /** Optional override for the hard safety cap (still validated/clamped in core). */
110
+ maxCap?: number;
111
+ };
112
+ type CoreConfigInput = {
113
+ output?: {
114
+ list?: OutputListConfigInput;
115
+ };
116
+ scanner?: ScannerConfigInput;
117
+ cache?: {
118
+ enabled?: boolean;
119
+ dir?: string;
120
+ profile?: CacheProfileId;
121
+ mode?: 'readWrite' | 'readOnly';
122
+ rebuild?: 'partial' | 'full';
123
+ fullRescanThresholdPercent?: number;
124
+ };
125
+ };
126
+ type CoreConfigResolved = {
127
+ output: {
128
+ list: ListWindowResolved;
129
+ };
130
+ scanner: ScannerConfigResolved;
131
+ cache: {
132
+ enabled: boolean;
133
+ profile: CacheProfileId;
134
+ dir?: string;
135
+ mode: 'readWrite' | 'readOnly';
136
+ rebuild: 'partial' | 'full';
137
+ fullRescanThresholdPercent: number;
138
+ };
139
+ };
140
+ type ResolveCoreConfigOptions = {
141
+ listWindow?: ResolveListWindowOptions;
142
+ scanner?: ResolveScannerConfigOptions;
143
+ };
144
+
145
+ type CoreConfigLayer = {
146
+ /** Optional label for debugging/traceability (host-defined). */
147
+ name?: string;
148
+ input: CoreConfigInput;
149
+ };
150
+ type ParseConfigText = (text: string, configPath: string) => unknown | Promise<unknown>;
151
+ type LoadCoreConfigFromPathInput = {
152
+ configPath: string;
153
+ readText: (configPath: string) => string | Promise<string>;
154
+ parseText?: ParseConfigText;
155
+ resolveOptions?: ResolveCoreConfigOptions;
156
+ runtime?: ConfigPathSystemRuntime;
157
+ };
158
+
159
+ /** Explicit base defaults for core-resolved config domains. */
160
+ declare const CORE_CONFIG_DEFAULT_INPUT: CoreConfigInput;
161
+
162
+ /** Baseline reference policy copied into defaults and per-command overrides. */
163
+ declare const REFERENCE_POLICY_SAFE_DEFAULTS: ReferenceCommandOverrides;
164
+ /** Canonical app config defaults (shared by all hosts). */
165
+ declare const DEFAULT_CONFIG: I18nPruneConfigParsed;
166
+
167
+ /** Load + parse + resolve core config from a given path using host-provided I/O. */
168
+ declare function loadCoreConfigFromPath(input: LoadCoreConfigFromPathInput): Promise<CoreConfigResolved>;
169
+ /**
170
+ * Non-throwing helper for clients that prefer Result envelopes over exceptions.
171
+ */
172
+ declare function tryLoadCoreConfigFromPath(input: LoadCoreConfigFromPathInput, cwd?: string): Promise<Result<'core.config', CoreConfigResolved>>;
173
+
174
+ declare function mergeCoreConfigInputs(a: CoreConfigInput | undefined, b: CoreConfigInput | undefined): CoreConfigInput;
175
+ /** Resolve portable core config (defaults + clamp rules), independent of any host parser. */
176
+ declare function resolveCoreConfig(input?: CoreConfigInput, options?: ResolveCoreConfigOptions): CoreConfigResolved;
177
+ /**
178
+ * Resolve core config from multiple layers. Merge semantics: later layers override earlier.
179
+ * Hosts can use this to combine defaults + file config + flags in a deterministic order.
180
+ */
181
+ declare function resolveCoreConfigLayers(layers: readonly CoreConfigLayer[], options?: ResolveCoreConfigOptions): CoreConfigResolved;
182
+
183
+ /**
184
+ * Deep-merge a partial config object onto a base (typically zip-resolved config).
185
+ * Nested plain objects merge recursively; arrays and primitives replace.
186
+ */
187
+ declare function mergePartialConfigIntoBase(base: Record<string, unknown> | null | undefined, partial: Record<string, unknown>): Record<string, unknown>;
188
+
189
+ declare function resolveTranslateConfig(input: {
190
+ config: TranslateConfigInput | undefined;
191
+ env?: Record<string, string | undefined>;
192
+ pin?: {
193
+ providerId?: TranslationProviderId;
194
+ workers?: number;
195
+ };
196
+ }): {
197
+ resolved: ResolvedTranslateConfig;
198
+ warnings: ResolveTranslateWarning[];
199
+ };
200
+
201
+ export { CORE_CONFIG_DEFAULT_INPUT, type CoreConfigInput, type CoreConfigLayer, type CoreConfigResolved, DEFAULT_CONFIG, I18nPruneConfig, type LoadCoreConfigFromPathInput, LocalesFilesystemConfig, type LocalesSourceInputKind, type LocalesSourceValidationResult, REFERENCE_POLICY_SAFE_DEFAULTS, ReferenceCommandOverrides, type ResolveCoreConfigOptions, ResolveTranslateWarning, ResolvedTranslateConfig, TranslateConfigInput, clampTranslateMaxWorkers, classifyLocalesSourceInput, collectLocalesFilesystemConfigWarnings, defineConfig, issueLocalesSourceNotInBundle, loadCoreConfigFromPath, mergeCoreConfigInputs, mergePartialConfigIntoBase, resolveCoreConfig, resolveCoreConfigLayers, resolveSourceLocaleAbsoluteFromRelPaths, resolveSourceLocaleAbsolutePath, resolveTranslateConfig, tryLoadCoreConfigFromPath, validateLocalesSourceConfigValue };