auto-translate-json-library 2.3.1 → 2.4.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/CHANGELOG.md ADDED
@@ -0,0 +1,326 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.4.0] - 2026-11-29
9
+
10
+ > 2.3.2 was prepared but never published to npm; its changes are folded into this
11
+ > release together with the CLI/toolchain work.
12
+
13
+ ### ⚠️ Upgrade notes
14
+
15
+ - **Node.js 22 or newer is required** (`engines` is now declared and enforced by
16
+ npm). The floor was already implicit — `openai@7` requires Node 22 — but it is
17
+ now stated.
18
+ - **Importing the package no longer has side effects.** `import { translate } from
19
+ 'auto-translate-json-library'` used to load `.env`, parse the *host process's*
20
+ `process.argv`, and print the configuration to stdout. Pass configuration
21
+ explicitly to `translate(file, config)`; the CLI still reads `.env` and argv.
22
+ - **`atj --json` output is now a stable contract** (see below). Anything that
23
+ parsed stdout itself should now be able to just `JSON.parse` it.
24
+
25
+ ### 🧹 Library Entry & Packaging
26
+
27
+ #### Fixed
28
+ - **`--json` now emits a single machine-readable document on *every* exit path.** The envelope used to be produced only inside `main()` after console capture was installed, so every pre-flight failure — missing API key, invalid `--engine`/`--format`/`--mode`, missing or unusable input path, credential errors for all eight engines — printed coloured human text (or nothing at all on stdout) and exited 1. Automation doing `atj --json … | jq .status` got a parse error instead of `"error"`.
29
+ - **One failure path (`exitWithError`) replaced ~17 scattered `console.error(...) + process.exit(1)` sites**, so text mode and JSON mode cannot drift apart again. The success envelope is unchanged; failures now use the same shape: `{ command, version, timestamp, input, status: "error", error, hints?, performance?, logs }`.
30
+ - **`--json --list-formats` returns data instead of a help screen**: `{ command: "list-formats", version, formats: [{ format, extensions, description }] }`. `--help` stays human-readable text by design.
31
+ - **Piped output can no longer be truncated**: the JSON document is written with `writeSync(1, …)` before `process.exit()`, so a slow reader of `atj --json … | …` cannot lose the tail (verified byte-identical through a 1 s-delayed consumer).
32
+ - **Captured `logs` are ANSI-free**, so the whole document stays valid JSON even under `FORCE_COLOR=1`.
33
+ - **Stack traces are opt-in** via the new `--debug` / `-d` flag; JSON payloads sent to agents/CI no longer leak absolute filesystem paths by default.
34
+ - **DeepL `deepLPro` credential errors went to stdout** (`console.log`) instead of stderr; unified with every other error.
35
+ - **`index.ts` no longer has import-time side effects**: importing the package used to run `.env` loading, `minimist` parsing of the *consumer's* `process.argv`, and `console.log(config)` — so a plain `import { translate } from 'auto-translate-json-library'` printed configuration noise into the host app's stdout and, if the host process happened to receive `--pivotTranslation`, could kick off a translation run. The entry point now only exports `translate` and the `Configuration` type. All environment/CLI wiring stays in the CLI (`src/bin/cli.ts`), which is where `process.argv` and `.env` belong.
36
+
37
+ #### Changed
38
+ - **`atj --json` stdout is now valid JSON**: the dotenv v17 banner (`◇ injected env ...`) and the `🔨 Auto translate json cli v…` banner used to be printed to stdout before the JSON envelope, so piping `--json` output into `jq`/an LLM failed to parse. dotenv is now loaded with `quiet: true`, the version banner is suppressed in JSON mode, and every exit path (success or failure) goes through one emitter.
39
+ - **`engines.node` is now `>=22.0.0`** (was undeclared). `openai@7` requires Node 22 and `yargs@18` requires `^20.19 || ^22.12 || >=23`, so Node 22 is the real floor; declaring it stops EBADENGINE warnings at install time.
40
+ - **Publish workflow now runs on Node 22** and gates the release on `npm run lint` + `npm test` before building and publishing.
41
+ - **Removed `NODE_AUTH_TOKEN` from the publish workflow**: the package publishes via npm trusted publishing (OIDC); an empty/expired `NPM_TOKEN` secret would silently break provenance publishing.
42
+ - **Removed `npm pkg fix` from the workflow**: it rewrote `package.json` after the packed-artifact dry run, so the tarball that was verified was not the tarball that shipped.
43
+
44
+ #### Packaging
45
+ - **Added a `LICENSE` file** (MIT). `package.json` declared MIT but the repository shipped no license text.
46
+ - **Stopped shipping `build/package.json`**: it was an untracked, gitignored leftover that duplicated `name`/`main`/`files` with a stale version and does not exist in a clean CI checkout, so the tarball was not reproducible. The root `package.json` already provides `"type": "module"`.
47
+ - **`CHANGELOG.md` is now included** in the published package.
48
+ - **`@types/js-yaml` moved to `devDependencies`** (it was leaking a type-only package to every consumer).
49
+ - **Added `homepage` and `bugs` metadata** so the npm page links to the repo and issue tracker.
50
+ - **`tsconfig.json` now sets `noEmitOnError: true`**, so a type error can no longer produce a broken-but-publishable build.
51
+ - **`build/` is cleaned before every compile** (`npm run build` = `clean` + `tsc`), and `pretest` rebuilds first, so the CLI integration tests can never run against stale `build/src/bin/cli.js` output.
52
+ - **Dev scripts now point at the CLI entry point** (`src/bin/cli.ts` / `build/src/bin/cli.js`) instead of `src/index.ts`, which no longer has CLI side effects.
53
+
54
+ #### Known issues (not fixed in this release)
55
+ - ~~`--json` only emits JSON on the success path~~ — **fixed**, see above.
56
+ - **`--json` can report `"status": "success"` even when nothing was translated.** `translate()` resolves after its validation/error-recovery layer skips or falls back per locale, so the CLI cannot tell "all locales translated" from "every locale skipped" (e.g. an unreachable provider still yields `success` with the recovery messages in `logs`). A truthful status needs `translate()` to return a result/summary object — a library API change, not a CLI fix.
57
+ - ~~The `overrides` workaround does not protect consumers~~ — **resolved** by the `@google-cloud/translate` 10 upgrade, which removed `google-gax`'s `rimraf → glob@10` chain: a clean consumer install of the tarball now audits clean. The remaining `glob`/`minimatch` overrides only cover the dev tree (Jest).
58
+
59
+ ### ⬆️ Toolchain & Dependencies (TypeScript 7)
60
+
61
+ #### Toolchain
62
+ - **TypeScript `6.0.3` → `7.0.2`** (the native/Go compiler). `npm run build` is now `tsc` from TS 7; `noEmitOnError` keeps it a hard gate.
63
+ - **Removed `@topce/native-preview` and the `build:go` script** — the `tsgo` preview fork existed only because the native compiler was not yet released as `typescript`; TS 7 ships it directly, so the extra dependency is gone.
64
+ - **`ts-jest` → `@swc/jest`.** TypeScript 7's package root exports only `{ version, versionMajorMinor }` — it no longer exposes the JS compiler API (`ts.createProgram`, …) that ts-jest requires, and ts-jest's peer range is `>=4.3 <7`. Tests are now transpiled by SWC. Type checking is unchanged: `tsconfig.json` has no `include`/`exclude`, so `tsc` still type-checks `src/` **and** `tests/` on every build.
65
+ - **Removed `ts-node`** (same compiler-API dependency). `npm run debug` / `npm run start` / `npm run build:run` now run the compiled CLI (`node build/src/bin/cli.js`); `debug` rebuilds first.
66
+ - **`npm run test:watch` and `npm run test:coverage` were broken** (they invoked `jest` without `--experimental-vm-modules`, so every ESM suite failed to parse). All three jest scripts now use the same `node --experimental-vm-modules …` invocation.
67
+
68
+ #### Dependency majors
69
+ - **`@google-cloud/translate` `9.4.2` → `10.3.0`** (requires Node ≥22; the `v2` client API used here is unchanged)
70
+ - **`deepl-node` `1.28.1` → `2.0.0`** — `Translator` was renamed to `DeepLClient` (`src/deepl.ts`); `serverUrl`/`minTimeout`/`maxRetries` options and `translateText()` signature are unchanged
71
+ - **`js-yaml` `4.3.2` → `5.5.0`** — `DEFAULT_SCHEMA` no longer exists: loaders default to `CORE_SCHEMA`, and `DUMP_SCHEMA` is the safe dumping schema (`src/format/yaml-handler.ts`). Empty/whitespace/comment-only documents now throw instead of returning `undefined`, so that case is translated back into the existing "YAML file is empty" error.
72
+ - **`gettext-parser` `9.1.1` → `10.0.0`** (ESM-only; `po.parse` / `po.compile` unchanged)
73
+ - **`dotenv` `17.4.2` → `18.0.10`** (`config({ quiet: true })` still supported)
74
+ - **`@aws-sdk/client-translate` → `3.1179.0`**, **`openai` → `7.65.0`**, **`@huggingface/inference` → `^4.13.33`**, **`uuid` → `14.0.3`**, **`yargs` → `18.2.0`**
75
+ - **Dev**: `jest` → `30.5.2`, `@biomejs/biome` → `2.6.9`, `@types/node` → `26.6.11`
76
+ - **Removed `@types/js-yaml`** — js-yaml 5 ships its own type declarations, which would otherwise conflict
77
+
78
+ #### Overrides
79
+ - `glob` is now overridden for **all** versions (`^14.0.6`), not just `glob@^10`: Jest 30.5.2 pulls the vulnerable `glob@13` and `test-exclude` pulls `glob@10`, and both fall in the `9.0.0 - 14.0.1` advisory range.
80
+ - Added `minimatch: ^11.0.9`, which lifts the vulnerable `minimatch@10.x` under `test-exclude`.
81
+ - With these, a full `npm audit` (dev tree included, not just `--omit=dev`) reports **0 vulnerabilities**.
82
+
83
+ ### 🔒 Security & Dependency Updates
84
+
85
+ All open Dependabot alerts resolved (0 remaining). `npm audit` reports **0 vulnerabilities** both in this repository (dev tree included) and in a clean consumer install of the packed tarball — the `@google-cloud/translate` 10 upgrade dropped `google-gax`'s `rimraf → glob@10` chain, so the advisories that previously affected downstream installs are gone.
86
+
87
+ #### Updated Dependencies
88
+ - **axios**: `1.19.0` → `1.21.1` (with `follow-redirects` `1.16.0` → `1.16.3`)
89
+ - **fast-xml-parser**: `5.10.1` → `5.12.1`
90
+ - **sharp**: `0.35.3` → `0.35.6`
91
+ - **@huggingface/transformers**: `4.2.0` → `4.3.2` (removes the second, vulnerable `sharp@0.34.5` copy)
92
+ - **adm-zip**, **handlebars**, **brace-expansion**, **@grpc/grpc-js**: transitive updates from the Dependabot sweep
93
+ - Every package is now on its latest release; the majors are listed in the toolchain section above.
94
+
95
+ #### Verification
96
+ - `npm audit`: 0 vulnerabilities (repo, dev tree included) and 0 in a clean consumer install
97
+ - None of the 48 Dependabot alert ranges match an installed version
98
+ - `npm run build` (`tsc` 7.0.2, native compiler) succeeds
99
+ - All 486 tests pass (12 suites), also under `npm run test:coverage`
100
+ - `npm run release:check` (lint + build + tests + `npm pack --dry-run`) passes; tarball contains only `build/src`, `README.MD`, `CHANGELOG.md`, `LICENSE` and `package.json` (no sources, tests, coverage, demo or `.env` files)
101
+ - The packed `2.4.0` tarball was installed into an empty project and smoke-tested: `atj -v`, `atj --json -v`, `atj --list-formats`, `atj --json --list-formats`, and all failure paths (missing/invalid credentials, engine, format, mode, path) return `JSON.parse`-able documents with the right exit codes; `npm audit` in that consumer project reports 0 vulnerabilities.
102
+ - `import { translate } from 'auto-translate-json-library'` produces no stdout output; the installed `atj` / `auto-translate-json-library` binaries report `v2.3.2` and print valid help from a packed-and-installed tarball
103
+ - The packed tarball was installed into an empty project and smoke-tested (`--version`, `--help`, `--json`, library import)
104
+
105
+ ## [2.3.1] - 2026-07-31
106
+
107
+ ### 🐛 Dot-Key Collision Fix (JSON & YAML)
108
+
109
+ #### Fixed
110
+ - **Fixed crash on flat keys that collide under dot-nesting** (`src/format/json-handler.ts`, `src/format/yaml-handler.ts`): Serializing a translation set where one flat key is also a dot-boundary prefix of another (for example `admin.invite.circabc.admin` together with `admin.invite.circabc.admin.succeed`) threw `Failed to serialize JSON: Cannot create property 'succeed' on string '…'`. The same path cannot be both a string leaf and an object in a nested tree, and under ES module strict mode the assignment threw instead of failing silently.
111
+ - `reconstructFromFlatStructure` is now collision-aware: keys involved in a dot-boundary prefix collision are preserved as literal (flat) keys, so the output stays lossless and valid. Non-colliding keys continue to nest exactly as before (backward compatible).
112
+ - `setNestedValue` no longer throws on an incompatible shape; it reports the collision so the caller can keep the key literal, guarding against any residual mixed array/object cases.
113
+
114
+ #### Verification
115
+ - All 478 tests pass (12 suites), including new regression tests:
116
+ - `tests/json-handler.test.ts`: 4 collision tests (no-throw, lossless preservation, mixed nest/flat, round-trip)
117
+ - `tests/files-integration.test.ts`: end-to-end round-trip through `Files.load/saveJsonToLocale` (the real translate save path)
118
+ - `tests/yaml-handler.test.ts`: 3 collision tests on the flat reconstruction path
119
+ - `npm run build` (tsc) succeeds
120
+ - Biome lint passes on changed source files
121
+ - `npm pack --dry-run` succeeds (91 files, 104.4 kB packed)
122
+
123
+ ## [2.3.0] - 2026-07-31
124
+
125
+ ### 🧹 Library Entry Cleanup & Dependency Updates
126
+
127
+ #### Fixed
128
+ - **Removed debug logging from production code**: Dropped the `🔍 DEBUG` `console.log` statements from the OpenAI translator (`src/openai.ts`) that were logging prompts and translation input/output.
129
+
130
+ #### Updated Dependencies
131
+ - **@aws-sdk/client-translate**: `3.1032.0` → `3.1100.0`
132
+ - **@google-cloud/translate**: `9.3.0` → `9.4.2`
133
+ - **@huggingface/inference**: `4.13.15` → `4.13.24`
134
+ - **@huggingface/transformers**: `4.1.0` → `4.2.0`
135
+ - **axios**: `1.15.0` → `1.19.0`
136
+ - **csv-parser**: `3.2.0` → `3.2.1`
137
+ - **deepl-node**: `1.26.0` → `1.27.0`
138
+ - **fast-xml-parser**: `5.7.1` → `5.10.1`
139
+ - **form-data**: `4.0.5` → `4.0.6`
140
+ - **gettext-parser**: `9.0.2` → `9.1.1`
141
+ - **js-yaml**: `4.1.1` → `4.3.1`
142
+ - **openai**: `6.34.0` → `7.3.0` (major)
143
+ - **sharp**: `0.34.5` → `0.35.3`
144
+ - **uuid**: `13.0.0` → `14.0.1` (major)
145
+ - **yargs**: `18.0.0` → `18.1.0`
146
+
147
+ #### Updated Dev Dependencies
148
+ - **@biomejs/biome**: `2.4.12` → `2.5.6`
149
+ - **@topce/native-preview**: `7.0.0-dev.20260215` → `7.0.3`
150
+ - **@types/node**: `25.6.0` → `26.1.2`
151
+ - **jest**: `30.3.0` → `30.4.2`
152
+ - **ts-jest**: `29.4.9` → `29.4.12`
153
+
154
+ #### Verification
155
+ - All 470 tests pass (12 suites)
156
+ - `npm pack --dry-run` succeeds (91 files, 100.7 kB packed)
157
+
158
+ ## [2.2.0] - 2026-04-18
159
+
160
+ ### 🔧 Dependency Updates & Bug Fixes
161
+
162
+ #### Updated Dependencies
163
+ - **@biomejs/biome**: bumped to `2.4.12`
164
+ - **@types/node**: bumped to `25.6.0`
165
+ - **ts-jest**: bumped to `29.4.9`
166
+ - **typescript**: bumped to `6.0.3`
167
+ - **@aws-sdk/client-translate**: bumped to `3.1032.0`
168
+ - **@huggingface/transformers**: bumped to `^4.1.0`
169
+ - **axios**: bumped to `1.15.0`
170
+ - **deepl-node**: bumped to `1.26.0`
171
+ - **dotenv**: bumped to `17.4.2`
172
+ - **fast-xml-parser**: bumped to `5.7.1`
173
+ - **openai**: bumped to `6.34.0`
174
+
175
+ #### Fixed
176
+ - **TypeScript**: Added `"jest"` and `"node"` to `types` in `tsconfig.json` so Jest globals (`describe`, `it`, `expect`) are correctly recognized
177
+ - **Jest config**: Added `moduleResolution: 'bundler'`, `rootDir: '.'`, and `ignoreDeprecations: '6.0'` to ts-jest tsconfig override to fix TS5011 and TS5107 errors in test runs
178
+ - All 470 tests pass
179
+
180
+ ## [2.1.0] - 2026-03-22
181
+
182
+ ### ⚡ Performance & CLI Improvements Release
183
+
184
+ #### Added
185
+ - **Lazy Loading**: Translation engines now load on-demand instead of at startup
186
+ - **JSON Output Mode**: New `--json` flag for structured, LLM-friendly output
187
+ - **Enhanced CLI Help**: Comprehensive examples and engine documentation
188
+ - **Performance Metrics**: Execution timing in JSON output for monitoring
189
+
190
+ #### Enhanced
191
+ - **CLI User Experience**: Better error messages with helpful tips and links
192
+ - **Engine Documentation**: All engines (huggingface, huggingface-local) fully documented
193
+ - **Local Inference Support**: Improved documentation for huggingface-local and Ollama
194
+ - **Developer Experience**: 15+ comprehensive usage examples added
195
+
196
+ #### Performance Improvements
197
+ - **Startup Time**: Reduced from ~500ms to ~27ms (library import)
198
+ - **Memory Footprint**: Only selected engine's SDK loads into memory
199
+ - **CLI Response**: Help/version commands don't trigger SDK loading
200
+ - **Engine Loading**: Each provider SDK loads only when first used
201
+
202
+ #### Technical Improvements
203
+ - **Provider Factory**: New `provider-factory.ts` with dynamic imports
204
+ - **Console Capture**: JSON output captures all logs, errors, and warnings
205
+ - **Error Handling**: Enhanced error messages with configuration guidance
206
+ - **Type Safety**: Maintained full TypeScript compatibility
207
+
208
+ #### Backward Compatibility
209
+ - ✅ All existing functionality preserved
210
+ - ✅ All 470 tests pass
211
+ - ✅ No breaking API changes
212
+ - ✅ Existing environment variables unchanged
213
+ - ✅ Demo scripts continue to work
214
+
215
+ ### Migration Notes
216
+ - No migration required - fully backward compatible
217
+ - New `--json` flag available for automation workflows
218
+ - Performance benefits automatic (no configuration needed)
219
+ - Existing scripts continue to work unchanged
220
+
221
+ ## [2.0.0] - 2025-01-04
222
+
223
+ ### 🚀 Major Release - Complete Rewrite and Enhancement
224
+
225
+ #### Breaking Changes
226
+ - **ES Modules Migration**: Project now uses ES modules (`"type": "module"`) instead of CommonJS
227
+ - **Node.js Compatibility**: Requires Node.js with ES modules support
228
+ - **API Changes**: Some internal APIs may have changed due to the comprehensive refactoring
229
+
230
+ #### Added
231
+ - **Comprehensive Validation System**: New validation framework with enhanced error detection and recovery
232
+ - `ValidationService` for centralized validation logic
233
+ - `EnhancedValidationResult` with detailed error reporting
234
+ - `ErrorRecovery` system for automatic error correction
235
+ - Format-specific validation rules and error messages
236
+ - **Demo System**: Complete demo setup with example files and automation scripts
237
+ - Interactive demo with multiple format examples
238
+ - Reset and run scripts for easy testing
239
+ - Sample files in JSON, XML, YAML, ARB, PO, Properties, and CSV formats
240
+ - **Enhanced Format Support**: Expanded format handlers with improved validation
241
+ - Better ARB (Flutter) file handling with metadata preservation
242
+ - Enhanced CSV/TSV support with configurable column mapping
243
+ - Improved XLIFF 1.2 and 2.x support
244
+ - Advanced PO/POT file handling with plural forms
245
+ - Enhanced Properties file support with Unicode handling
246
+ - Robust XML handling for Android, iOS, and generic formats
247
+ - Comprehensive YAML support with nested structures
248
+ - **Advanced Testing Suite**: Extensive test coverage across all format handlers
249
+ - Integration tests for CLI functionality
250
+ - Error handling and edge case testing
251
+ - Format-specific validation testing
252
+ - Cross-format compatibility testing
253
+
254
+ #### Enhanced
255
+ - **Code Quality**: Complete codebase formatting and linting with Biome
256
+ - Consistent code style across all modules
257
+ - Enhanced TypeScript configurations
258
+ - Improved error handling and type safety
259
+ - **CLI Interface**: Enhanced command-line interface with better error reporting
260
+ - Improved argument parsing and validation
261
+ - Better progress reporting and user feedback
262
+ - Enhanced format detection and override capabilities
263
+ - **Performance**: Optimized file processing and translation workflows
264
+ - Improved memory usage for large files
265
+ - Better error recovery and continuation
266
+ - Enhanced parallel processing capabilities
267
+ - **Documentation**: Updated examples and usage patterns throughout codebase
268
+
269
+ #### Fixed
270
+ - **Dependency Security**: Updated all dependencies to latest secure versions
271
+ - Axios updated to 1.13.2 (from 1.12.1)
272
+ - JWS updated to 4.0.1 (security fix)
273
+ - All dev dependencies updated to latest versions
274
+ - **Format Handling**: Resolved various format-specific parsing and serialization issues
275
+ - **Error Handling**: Improved error messages and recovery mechanisms
276
+ - **Type Safety**: Enhanced TypeScript definitions and type checking
277
+
278
+ #### Technical Improvements
279
+ - **Module System**: Complete migration to ES modules with proper import/export syntax
280
+ - **Build System**: Updated build configuration for ES modules compatibility
281
+ - **Testing Framework**: Enhanced Jest configuration for ES modules support
282
+ - **Development Tools**: Improved development workflow with better tooling integration
283
+
284
+ ### Migration Guide for v2.0.0
285
+ - Update Node.js to a version that supports ES modules
286
+ - Update import statements from `require()` to `import` syntax
287
+ - Review any custom integrations for API compatibility
288
+ - Test thoroughly with your specific file formats and workflows
289
+
290
+ ## [1.5.5] - 2024-11-02
291
+
292
+ ### Enhanced - XML Handler Improvements
293
+
294
+ #### Added
295
+ - **Enhanced Format Detection**: XML format detection now properly handles XML with attributes and namespaces (e.g., `<resources xmlns:android="...">`)
296
+ - **Generic XML Support**: Added support for generic XML formats with automatic structure flattening
297
+ - Example: `<messages><greeting>Hello</greeting></messages>` becomes `messages.greeting: "Hello"`
298
+ - **Robust Validation**: Improved validation system that properly detects invalid Android/iOS XML structures
299
+ - **Malformed XML Detection**: Added validation for malformed XML with unclosed tags and proper error reporting
300
+
301
+ #### Fixed
302
+ - **XML Serialization**: Fixed iOS XML serialization to properly update translated values in plist structure
303
+ - **Validation Logic**: Fixed validation to correctly identify invalid XML structures instead of treating them as generic XML
304
+ - **Error Handling**: XML parser now properly throws errors for malformed XML content
305
+ - **Attribute Parsing**: Fixed parsing of XML elements with attributes like `translatable="false"`
306
+
307
+ #### Improved
308
+ - **Test Coverage**: All 40 XML handler tests now pass (100% success rate)
309
+ - **Android XML**: Enhanced support for resource groups and CDATA sections
310
+ - **iOS XML**: Improved plist format handling with proper key-value pair processing
311
+ - **Round-trip Translation**: Ensured translated content maintains XML structure integrity
312
+
313
+ ### Technical Details
314
+ - Enhanced `detectXmlFormat()` to check both content and parsed structure
315
+ - Improved `transformGenericXml()` to properly flatten nested XML structures
316
+ - Added `validateXmlStructure()` for malformed XML detection
317
+ - Enhanced validation with `looksLikeAndroidXml()` and `looksLikeIosXml()` helpers
318
+ - Fixed `updateTranslatedValues()` for proper iOS plist serialization
319
+
320
+ ## [Previous Versions]
321
+
322
+ ### [1.5.4] and earlier
323
+ - Comprehensive multi-format support (JSON, XML, XLIFF, ARB, PO/POT, YAML, Properties, CSV/TSV)
324
+ - Multiple translation engine support (Google, AWS, Azure, DeepL, OpenAI)
325
+ - CLI interface with format detection
326
+ - Format-specific validation and error handling
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2026 codegrue and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.MD CHANGED
@@ -72,6 +72,9 @@ This major release brings comprehensive improvements including:
72
72
  npm i auto-translate-json-library
73
73
  ```
74
74
 
75
+ Requires **Node.js 22 or newer** (enforced via `engines` in `package.json`).
76
+ The package is ESM-only (`"type": "module"`) and ships TypeScript declarations.
77
+
75
78
  ### Basic Usage
76
79
 
77
80
  ```typescript
@@ -276,10 +279,10 @@ After that, GitHub Actions can publish with OIDC and `--provenance`, with no npm
276
279
 
277
280
  ### Release flow
278
281
 
279
- 1. Bump `version` in `package.json`.
280
- 2. Run `npm run release:check` locally.
282
+ 1. Bump `version` in `package.json` and add a `CHANGELOG.md` entry.
283
+ 2. Run `npm run release:check` locally (lint + tests + `npm pack --dry-run`).
281
284
  3. Commit and push to `master`.
282
- 4. Create and push a version tag such as `v2.0.4`.
285
+ 4. Create and push a version tag that matches `package.json` exactly.
283
286
 
284
287
  ```shell
285
288
  git tag v2.0.4
@@ -288,12 +291,15 @@ git push origin v2.0.4
288
291
 
289
292
  The publish workflow will then:
290
293
 
291
- - install with `npm ci`
292
- - run tests
294
+ - install with `npm ci` on Node 22
295
+ - run `npm run lint`
296
+ - run the test suite
293
297
  - build the package
294
298
  - run `npm pack --dry-run`
295
299
  - publish to npm with provenance
296
300
 
301
+ `npm publish` is additionally guarded by a `prepublishOnly` hook that builds and tests, so a manual publish cannot ship an untested build.
302
+
297
303
  ### Local dry run
298
304
 
299
305
  If you want to inspect the package before tagging:
@@ -456,8 +462,47 @@ atj translations/en.json -e google --json --format json
456
462
 
457
463
  # Capture all logs and performance metrics
458
464
  atj translations/en.json -e openai --json | jq '.performance.totalMs'
465
+
466
+ # Inspect available formats as data
467
+ atj --list-formats --json | jq -r '.formats[].format'
468
+ ```
469
+
470
+ `--json` always writes exactly one parseable document to stdout and never anything
471
+ else, including on failure. Exit code `0` means success, `1` means failure.
472
+
473
+ ```jsonc
474
+ // success
475
+ {
476
+ "command": "translate",
477
+ "version": "2.3.2",
478
+ "timestamp": "2026-11-29T08:50:11.407Z",
479
+ "input": { "path": "/abs/en.json", "mode": "file", "engine": "openai", "sourceLocale": "en", "format": "auto", "keepTranslations": true, "keepExtraTranslations": false },
480
+ "performance": { "startTime": 1763970000000, "endTime": 1763970001234, "totalMs": 1234 },
481
+ "logs": [ { "type": "log", "message": "…", "timestamp": 1763970000100 } ],
482
+ "status": "success",
483
+ "message": "Translation completed successfully"
484
+ }
485
+
486
+ // failure (validation, credentials, or a thrown translation error)
487
+ {
488
+ "command": "translate",
489
+ "version": "2.3.2",
490
+ "timestamp": "2026-11-29T08:50:12.001Z",
491
+ "input": { "path": "/abs/en.json", "mode": "file", "engine": "openai", "sourceLocale": "en", "format": "auto", "keepTranslations": true, "keepExtraTranslations": false },
492
+ "status": "error",
493
+ "error": "OpenAI API key not found in environment variable ATJ_OPEN_AI_SECRET_KEY",
494
+ "hints": [ "For OpenAI: Set ATJ_OPEN_AI_SECRET_KEY to your OpenAI API key" ],
495
+ "logs": []
496
+ }
459
497
  ```
460
498
 
499
+ `--help` is always human-readable text. Add `--debug` (`-d`) to include a `stack`
500
+ field on errors.
501
+
502
+ > Note: the library recovers from per-locale provider failures internally, so a run
503
+ > where every locale was skipped can still report `"status": "success"` — the
504
+ > recovery details are in `logs`.
505
+
461
506
  #### Lazy Loading in Action
462
507
  ```shell
463
508
  # Only Hugging Face SDK loads (not Google, AWS, etc.)
@@ -574,13 +619,18 @@ Clone repo and use the following commands:
574
619
  ```shell
575
620
  npm i
576
621
  npm run build
577
- node ./build/src/index.js --pivotTranslation=./tests/translations/en.json
622
+ node ./build/src/bin/cli.js --pivotTranslation=./tests/translations/en.json
578
623
  ```
579
624
 
580
625
  After some time you should see es.json file with translation.
581
626
 
582
627
  ### Development Workflow
583
628
 
629
+ The build uses **TypeScript 7** (the native compiler) via `tsc`; tests are transpiled
630
+ with **SWC** (`@swc/jest`) because TS 7 no longer exposes the JS compiler API that
631
+ `ts-jest`/`ts-node` depend on. `tsc` still type-checks both `src/` and `tests/` on
632
+ every build, so `npm run build` is the type-check gate.
633
+
584
634
  ```shell
585
635
  # Install dependencies
586
636
  npm install