{"_id":"@ecosplay/e-translate","_rev":"5-9b93c5a86a722e2d3e39c0d803d4c42e","name":"@ecosplay/e-translate","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.0":{"name":"@ecosplay/e-translate","version":"1.0.0","keywords":["translate","translation","libretranslate","e-translate","sdk","i18n"],"license":"MIT","_id":"@ecosplay/e-translate@1.0.0","maintainers":[{"name":"ecosplay","email":"contact@e-cosplay.fr"}],"dist":{"shasum":"90906695be4a90dc395636593a41d51b39997bc3","tarball":"https://registry.npmjs.org/@ecosplay/e-translate/-/e-translate-1.0.0.tgz","fileCount":9,"integrity":"sha512-vSk8fzen/cT/PebY/ot3lDGp18yJYjRRIQkUnPWDMQIydKwAmpIGvBlfLLUprtQVZgnawMiw42VDqcOeCxrJXw==","signatures":[{"sig":"MEUCIQDRZhmJKT9GB29nouCDih1k6ODyKUfabFpuwQpGRooaMgIgJDbdpmREqHP24obJsSGE4euyBOfp4ZSMynF/3wnuaNs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51669},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"ca383a60ce07dc24667f64a8f84bb39c72b23539","scripts":{"build":"tsup","prepare":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ecosplay","email":"contact@e-cosplay.fr"},"repository":{"url":"ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git","type":"git"},"_npmVersion":"10.8.2","description":"Client SDK (TypeScript) pour l'API e-translate (translation.e-cosplay.fr).","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/e-translate_1.0.0_1781338337843_0.9211818031060632","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@ecosplay/e-translate","version":"1.1.0","keywords":["translate","translation","e-translate","sdk","i18n"],"license":"MIT","_id":"@ecosplay/e-translate@1.1.0","maintainers":[{"name":"ecosplay","email":"contact@e-cosplay.fr"}],"dist":{"shasum":"e621e3fa3fc284acf675e0ecd0a96336e3aff4d7","tarball":"https://registry.npmjs.org/@ecosplay/e-translate/-/e-translate-1.1.0.tgz","fileCount":9,"integrity":"sha512-IqMYMq7VIPIi/xBDjmzJVYb+yNzZM/hMlEKLN11A8m/HKLLCawzq4jpeXSn3plqTrs6D0mPYp3/vXXbT3XsGJA==","signatures":[{"sig":"MEUCIQC5os9mQMvd5cmSepd/AjW+n6DaIsP4Kq3wGjM17liTEQIgIs8tZprrDRjEsh/nSqRJoNXO9HKlp9eXAp/IIhbmoSk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51882},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"0eae591ea74aa5d4dc1d213f2ea3ed5096e688df","scripts":{"test":"vitest run","build":"tsup","prepare":"tsup","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ecosplay","email":"contact@e-cosplay.fr"},"repository":{"url":"ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git","type":"git"},"_npmVersion":"10.8.2","description":"Client SDK (TypeScript) pour l'API e-translate (translation.e-cosplay.fr).","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.8","typescript":"^5.6.0","@vitest/coverage-v8":"^2.1.8"},"_npmOperationalInternal":{"tmp":"tmp/e-translate_1.1.0_1781339031014_0.6259119157840995","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@ecosplay/e-translate","version":"1.1.1","keywords":["translate","translation","e-translate","sdk","i18n"],"license":"MIT","_id":"@ecosplay/e-translate@1.1.1","maintainers":[{"name":"ecosplay","email":"contact@e-cosplay.fr"}],"dist":{"shasum":"17897b657eac93fbe7bea2cceb68278e419dce53","tarball":"https://registry.npmjs.org/@ecosplay/e-translate/-/e-translate-1.1.1.tgz","fileCount":9,"integrity":"sha512-P7smQZnBCWjaNtetQAR1kYQs/lt3Qo5QVPddW4cyJN/YJlDAzvapnnyspXfCHPz847Zy2cgOoezENWERAgU4hQ==","signatures":[{"sig":"MEUCIQDPz5b0xGK9hyWdVN00NmJaqG2PgpFa2DH1wD7aRMEbiwIgNX5d3toVk23srTklYiKAWk7dBYDQjnD7mrXBCv/paEo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51877},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"51f7c9553603d261714c05030a0cd333e240d9ee","scripts":{"test":"vitest run","build":"tsup","prepare":"tsup","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ecosplay","email":"contact@e-cosplay.fr"},"repository":{"url":"ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git","type":"git"},"_npmVersion":"10.8.2","description":"Client SDK (TypeScript) pour l'API e-translate (translation.e-cosplay.fr).","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.8","typescript":"^5.6.0","@vitest/coverage-v8":"^2.1.8"},"_npmOperationalInternal":{"tmp":"tmp/e-translate_1.1.1_1781339382782_0.8160696885319152","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@ecosplay/e-translate","version":"1.1.2","keywords":["translate","translation","e-translate","sdk","i18n"],"license":"MIT","_id":"@ecosplay/e-translate@1.1.2","maintainers":[{"name":"ecosplay","email":"contact@e-cosplay.fr"}],"dist":{"shasum":"837b93ed9c1362ae342ef55c8e4183755c68e16d","tarball":"https://registry.npmjs.org/@ecosplay/e-translate/-/e-translate-1.1.2.tgz","fileCount":10,"integrity":"sha512-mQq7bYEtied+GjncBL7H+do3vkwelOWJ62L2MYPluMBfl7eI2wCyTZAZDRFmuwI2jXprXLyV/5dZmFQj9H5hKg==","signatures":[{"sig":"MEUCIEDT99Lds4RFxMC2F+BHufCkbNhrcCHC+YBeipUv8pZ6AiEA6+EaC75/FutumtbsKCYEBnMUMnIw2guAbQhtLH615eE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52311},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"5750509779458b7ad5654e571295516e28a925d9","scripts":{"test":"vitest run","build":"tsup","prepare":"tsup","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"ecosplay","email":"contact@e-cosplay.fr"},"repository":{"url":"ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git","type":"git"},"_npmVersion":"10.8.2","description":"TypeScript/JavaScript client SDK for the e-translate API (translation.e-cosplay.fr).","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.8","typescript":"^5.6.0","@vitest/coverage-v8":"^2.1.8"},"_npmOperationalInternal":{"tmp":"tmp/e-translate_1.1.2_1781340739090_0.13384906294237342","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@ecosplay/e-translate","version":"1.1.3","description":"TypeScript/JavaScript client SDK for the e-translate API (translation.e-cosplay.fr).","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"engines":{"node":">=18"},"sideEffects":false,"scripts":{"build":"tsup","prepare":"tsup","typecheck":"tsc --noEmit","test":"vitest run","test:coverage":"vitest run --coverage","socket:issues":"node scripts/socket-issues.mjs"},"keywords":["translate","translation","e-translate","sdk","i18n"],"license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"repository":{"type":"git","url":"ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git"},"devDependencies":{"@vitest/coverage-v8":"^3.2.6","tsup":"^8.3.0","typescript":"^5.6.0","vitest":"^3.2.6"},"overrides":{"esbuild":"^0.28.1"},"_id":"@ecosplay/e-translate@1.1.3","gitHead":"645a8ce4b6300da0b8bd9c445354d571e19013d5","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-LkcwQxGJSKivwz9Pl/4MrLahI7AM06PUHROdF9OpfBx867a3zQiQEb2bVCK+UXVLvJlK0NwWkmKyEQtR7RGLlg==","shasum":"11974b2ceae0c6ab9ec80425950ff073e18b93bf","tarball":"https://registry.npmjs.org/@ecosplay/e-translate/-/e-translate-1.1.3.tgz","fileCount":10,"unpackedSize":52413,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHEaWOu1Oq3SeWhr2fkcvlatOOsa7M3D9qfOxfGF68jsAiEAtoKeESLwP8cQbrxJZPhkkkMG/guCzE/LWf/Q3fhf6l0="}]},"_npmUser":{"name":"ecosplay","email":"contact@e-cosplay.fr"},"directories":{},"maintainers":[{"name":"ecosplay","email":"contact@e-cosplay.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/e-translate_1.1.3_1781694070955_0.8826348813947682"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-13T08:12:17.635Z","modified":"2026-06-17T11:01:11.204Z","1.0.0":"2026-06-13T08:12:18.066Z","1.1.0":"2026-06-13T08:23:51.152Z","1.1.1":"2026-06-13T08:29:42.937Z","1.1.2":"2026-06-13T08:52:19.218Z","1.1.3":"2026-06-17T11:01:11.100Z"},"license":"MIT","keywords":["translate","translation","e-translate","sdk","i18n"],"repository":{"type":"git","url":"ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git"},"description":"TypeScript/JavaScript client SDK for the e-translate API (translation.e-cosplay.fr).","maintainers":[{"name":"ecosplay","email":"contact@e-cosplay.fr"}],"readme":"# @ecosplay/e-translate\n\n[![Quality Gate Status](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=alert_status&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Coverage](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=coverage&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Duplicated Lines (%)](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=duplicated_lines_density&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Lines of Code](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=ncloc&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Security Hotspots](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=security_hotspots&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Maintainability Rating](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=software_quality_maintainability_rating&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Reliability Rating](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=software_quality_reliability_rating&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n[![Security Rating](https://sn.e-cosplay.fr/api/project_badges/measure?project=e-translate-sdk-js&metric=software_quality_security_rating&token=sqb_af5f3b3f8adae526165e73f0ed40f1fc9525e9b1)](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\n\n**TypeScript / JavaScript** client for the [e-translate](https://translation.e-cosplay.fr) API\n(translation through a key-authenticated API, with built-in caching).\n\n- ✅ Works in **Node.js ≥ 18** (native fetch) and in the **browser**\n- ✅ **TypeScript** (types included) — **ESM + CJS** outputs\n- ✅ Zero runtime dependencies\n- ✅ Available on **npm** (`@ecosplay/e-translate`)\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @ecosplay/e-translate\n```\n\nWith pnpm or yarn:\n\n```bash\npnpm add @ecosplay/e-translate\nyarn add @ecosplay/e-translate\n```\n\n**Pin a version** (recommended in production):\n\n```bash\nnpm install @ecosplay/e-translate@1.1.2\n```\n\n> Published to npm automatically by CI on each `vX.Y.Z` tag (see\n> `.gitea/workflows/publish.yml`).\n\n---\n\n## 🚀 Usage\n\n### ESM / TypeScript\n\n```ts\nimport { ETranslateClient } from \"@ecosplay/e-translate\";\n\nconst client = new ETranslateClient({\n  baseUrl: \"https://translation.e-cosplay.fr\",\n  apiKey: \"etk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n});\n\nconst res = await client.translate({ message: \"Bonjour le monde\", from: \"fr\", to: \"en\" });\nconsole.log(res.translatedText); // \"Hello world\"\nconsole.log(res.cached);         // false, then true on an identical 2nd call\n```\n\n### CommonJS\n\n```js\nconst { ETranslateClient } = require(\"@ecosplay/e-translate\");\n\nconst client = new ETranslateClient({\n  baseUrl: \"https://translation.e-cosplay.fr\",\n  apiKey: process.env.ETRANSLATE_KEY,\n});\n\nclient.translate({ message: \"Hello\", from: \"en\", to: \"fr\" }).then((r) => console.log(r.translatedText));\n```\n\n### Auto-detection, arrays, HTML\n\n```ts\n// from: \"auto\" -> the source language is detected\nconst r1 = await client.translate({ message: \"Guten Tag\", from: \"auto\", to: \"fr\" });\nconsole.log(r1.detectedLanguage); // { confidence: 90, language: \"de\" }\n\n// Translate several texts at once\nconst r2 = await client.translate({ message: [\"Cat\", \"Dog\"], from: \"en\", to: \"fr\" });\nconsole.log(r2.translatedText); // [\"Chat\", \"Chien\"]\n\n// Preserve HTML markup\nawait client.translate({ message: \"<b>Bonjour</b>\", from: \"fr\", to: \"en\", format: \"html\" });\n```\n\n---\n\n## 📚 API\n\n### `new ETranslateClient(options)` / `createClient(options)`\n\n| Option      | Type                     | Default            | Description                              |\n| ----------- | ------------------------ | ------------------ | ---------------------------------------- |\n| `baseUrl`   | `string`                 | —                  | Server URL (required)                    |\n| `apiKey`    | `string`                 | —                  | `etk_…` key (required except `health()`) |\n| `timeoutMs` | `number`                 | `20000`            | Per-request timeout                      |\n| `fetch`     | `typeof fetch`           | `globalThis.fetch` | Custom fetch (Node < 18, tests)          |\n| `headers`   | `Record<string,string>`  | `{}`               | Extra headers                            |\n\n### Methods\n\n| Method                | Endpoint          | Returns                       |\n| --------------------- | ----------------- | ----------------------------- |\n| `translate(params)`   | `POST /translate` | `Promise<TranslateResult>`    |\n| `detect(text)`        | `POST /detect`    | `Promise<DetectedLanguage[]>` |\n| `languages()`         | `GET /languages`  | `Promise<Language[]>`         |\n| `health()`            | `GET /health`     | `Promise<HealthResult>`       |\n\n`translate(params)` — `params`: `{ message: string | string[]; from: string; to: string; format?: \"text\" | \"html\" }`.\n(`from` accepts `\"auto\"`. The server-side aliases `source`/`target`/`q` are also accepted.)\n\n### Error handling\n\nAny non-2xx response (or a network failure) throws an **`ETranslateError`**:\n\n```ts\nimport { ETranslateError } from \"@ecosplay/e-translate\";\n\ntry {\n  await client.translate({ message: \"x\", from: \"fr\", to: \"en\" });\n} catch (e) {\n  if (e instanceof ETranslateError) {\n    console.error(e.status); // 401 (invalid key), 429 (rate limit), 502 (upstream), 0 (network/timeout)\n    console.error(e.message);\n    console.error(e.body);   // JSON body returned by the server, if any\n  }\n}\n```\n\n---\n\n## 🧪 Tests & coverage\n\nTests run against an in-process **mock server** (`test/mock-server.ts`), so no real\nbackend is required.\n\n```bash\nnpm test              # run the test suite (vitest)\nnpm run test:coverage # run with V8 coverage -> coverage/lcov.info (used by SonarQube)\n```\n\nCoverage is reported to [SonarQube](https://sn.e-cosplay.fr/dashboard?id=e-translate-sdk-js)\nby CI (see the `Coverage` badge above).\n\n---\n\n## 🛠️ Build from source\n\n```bash\ngit clone ssh://git@code.e-cosplay.fr:222/shoko/e-translate-sdk-js.git\ncd e-translate-sdk-js\nnpm install        # also runs the build via \"prepare\"\nnpm run build      # -> dist/index.js (ESM), dist/index.cjs (CJS), dist/index.d.ts\nnpm run typecheck  # type-check without emitting\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}