{"_id":"@azure/ai-translation-document","name":"@azure/ai-translation-document","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@azure/ai-translation-document","version":"1.0.0","description":"SDK for Microsoft Translation Document service","engines":{"node":">=22.0.0"},"sideEffects":false,"autoPublish":false,"type":"module","main":"./dist/commonjs/index.js","module":"./dist/esm/index.js","types":"./dist/commonjs/index.d.ts","browser":"./dist/browser/index.js","react-native":"./dist/react-native/index.js","imports":{"#platform/*":{"react-native":"./src/*-react-native.mts","browser":"./src/*-browser.mts","default":"./src/*.ts"}},"exports":{"./package.json":"./package.json",".":{"browser":{"types":"./dist/browser/index.d.ts","default":"./dist/browser/index.js"},"react-native":{"types":"./dist/react-native/index.d.ts","default":"./dist/react-native/index.js"},"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./documentTranslation":{"browser":{"types":"./dist/browser/documentTranslation/index.d.ts","default":"./dist/browser/documentTranslation/index.js"},"react-native":{"types":"./dist/react-native/documentTranslation/index.d.ts","default":"./dist/react-native/documentTranslation/index.js"},"import":{"types":"./dist/esm/documentTranslation/index.d.ts","default":"./dist/esm/documentTranslation/index.js"},"require":{"types":"./dist/commonjs/documentTranslation/index.d.ts","default":"./dist/commonjs/documentTranslation/index.js"}},"./documentTranslation/api":{"browser":{"types":"./dist/browser/documentTranslation/api/index.d.ts","default":"./dist/browser/documentTranslation/api/index.js"},"react-native":{"types":"./dist/react-native/documentTranslation/api/index.d.ts","default":"./dist/react-native/documentTranslation/api/index.js"},"import":{"types":"./dist/esm/documentTranslation/api/index.d.ts","default":"./dist/esm/documentTranslation/api/index.js"},"require":{"types":"./dist/commonjs/documentTranslation/api/index.d.ts","default":"./dist/commonjs/documentTranslation/api/index.js"}},"./singleDocumentTranslation":{"browser":{"types":"./dist/browser/singleDocumentTranslation/index.d.ts","default":"./dist/browser/singleDocumentTranslation/index.js"},"react-native":{"types":"./dist/react-native/singleDocumentTranslation/index.d.ts","default":"./dist/react-native/singleDocumentTranslation/index.js"},"import":{"types":"./dist/esm/singleDocumentTranslation/index.d.ts","default":"./dist/esm/singleDocumentTranslation/index.js"},"require":{"types":"./dist/commonjs/singleDocumentTranslation/index.d.ts","default":"./dist/commonjs/singleDocumentTranslation/index.js"}},"./singleDocumentTranslation/api":{"browser":{"types":"./dist/browser/singleDocumentTranslation/api/index.d.ts","default":"./dist/browser/singleDocumentTranslation/api/index.js"},"react-native":{"types":"./dist/react-native/singleDocumentTranslation/api/index.d.ts","default":"./dist/react-native/singleDocumentTranslation/api/index.js"},"import":{"types":"./dist/esm/singleDocumentTranslation/api/index.d.ts","default":"./dist/esm/singleDocumentTranslation/api/index.js"},"require":{"types":"./dist/commonjs/singleDocumentTranslation/api/index.d.ts","default":"./dist/commonjs/singleDocumentTranslation/api/index.js"}},"./models":{"browser":{"types":"./dist/browser/models/index.d.ts","default":"./dist/browser/models/index.js"},"react-native":{"types":"./dist/react-native/models/index.d.ts","default":"./dist/react-native/models/index.js"},"import":{"types":"./dist/esm/models/index.d.ts","default":"./dist/esm/models/index.js"},"require":{"types":"./dist/commonjs/models/index.d.ts","default":"./dist/commonjs/models/index.js"}}},"keywords":["node","azure","cloud","typescript","browser","isomorphic"],"author":{"name":"Microsoft Corporation"},"license":"MIT","sdk-type":"client","repository":{"type":"git","url":"git+https://github.com/Azure/azure-sdk-for-js.git","directory":"sdk/translation/ai-translation-document"},"bugs":{"url":"https://github.com/Azure/azure-sdk-for-js/issues"},"homepage":"https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-document/README.md","prettier":"@azure/eslint-plugin-azure-sdk/prettier.json","//metadata":{"constantPaths":[{"path":"src/documentTranslation/api/documentTranslationContext.ts","prefix":"userAgentInfo"},{"path":"src/singleDocumentTranslation/api/singleDocumentTranslationContext.ts","prefix":"userAgentInfo"}]},"//sampleConfiguration":{"productName":"Azure Document Translation Service","productSlugs":["azure","azure-cognitive-services","azure-translator"],"requiredResources":{"Azure Cognitive Services instance":"https://learn.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account"},"apiRefLink":"https://learn.microsoft.com/javascript/api/@azure/ai-translation-document"},"dependencies":{"@azure-rest/core-client":"^2.3.1","@azure/abort-controller":"^2.1.2","@azure/core-auth":"^1.9.0","@azure/core-lro":"^3.1.0","@azure/core-rest-pipeline":"^1.20.0","@azure/logger":"^1.2.0","tslib":"^2.8.1"},"devDependencies":{"@azure/arm-cognitiveservices":"8.1.0","@azure/identity":"4.13.0","@azure/storage-blob":"^12.26.0","@types/node":"^22.0.0","cross-env":"^10.1.0","eslint":"^10.8.0","prettier":"^3.9.1","rimraf":"^6.1.0","@vitest/browser-playwright":"^4.1.2","@vitest/coverage-istanbul":"^4.1.2","dotenv":"^16.6.1","playwright":"^1.60.0","typescript":"~6.0.2","vitest":"^4.1.2","@azure-tools/test-credential":"^2.1.2","@azure-tools/test-recorder":"^4.1.1","@azure-tools/test-utils-vitest":"^2.0.1","@azure/eslint-plugin-azure-sdk":"^3.0.0","@azure/dev-tool":"^1.0.0"},"scripts":{"clean":"rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log","extract-api":"rimraf review && dev-tool run extract-api","pack":"pnpm pack 2>&1","lint":"eslint package.json src test","lint:fix":"eslint package.json src test --fix --fix-type [problem,suggestion]","build:samples":"echo skipped","check-format":"prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ","execute:samples":"echo skipped","format":"prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ","generate:client":"echo skipped","test:browser":"dev-tool run test:vitest --browser","build":"npm run clean && dev-tool run build-package && dev-tool run extract-api","test:node":"dev-tool run test:vitest","test":"tsc -b --noEmit && npm run test:node && npm run test:browser","update-snippets":"dev-tool run update-snippets"},"_id":"@azure/ai-translation-document@1.0.0","_integrity":"sha512-iV9DD6BK7CmOH04xBVJS6n2URmFwMIwHmX8UYJJxDRvH+JBwdtDG6L8sUc+KPzXTmTdjQM8e9MNJkdWL35M2Pg==","_resolved":"M:\\SvcFab\\_App\\MS.Ess.PackageManager.Publisher_App1\\temp\\affac8bf-645a-47a8-b141-004af80d2d0e\\azure-ai-translation-document-1.0.0.tgz","_from":"file:M:\\SvcFab\\_App\\MS.Ess.PackageManager.Publisher_App1\\temp\\affac8bf-645a-47a8-b141-004af80d2d0e\\azure-ai-translation-document-1.0.0.tgz","tag":"latest","_nodeVersion":"18.5.0","dist":{"integrity":"sha512-iV9DD6BK7CmOH04xBVJS6n2URmFwMIwHmX8UYJJxDRvH+JBwdtDG6L8sUc+KPzXTmTdjQM8e9MNJkdWL35M2Pg==","shasum":"16a0ed85a358ef71d0385651ef471d5e3bb72752","tarball":"https://registry.npmjs.org/@azure/ai-translation-document/-/ai-translation-document-1.0.0.tgz","fileCount":303,"unpackedSize":1094841,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFKC8dtG9mS0fl+ozl67yENpx/L+ZrfomLVO69zXA/e3AiEAi3YyxSP+DyZF8A/SotXK/NlBzfA+hA7UEh945kminio="}]},"_npmUser":{"name":"microsoft1es","email":"npmjs@microsoft.com"},"directories":{},"maintainers":[{"name":"azure-sdk","email":"azure-sdk-npmjs@microsoft.com"},{"name":"microsoft1es","email":"npmjs@microsoft.com"},{"name":"microsoft-oss-releases","email":"microsoft-oss-publishing@microsoft.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-translation-document_1.0.0_1785967245152_0.6462296357359589"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-05T22:00:44.970Z","1.0.0":"2026-08-05T22:00:45.314Z","modified":"2026-08-05T22:00:45.608Z"},"maintainers":[{"name":"azure-sdk","email":"azure-sdk-npmjs@microsoft.com"},{"name":"microsoft1es","email":"npmjs@microsoft.com"},{"name":"microsoft-oss-releases","email":"microsoft-oss-publishing@microsoft.com"}],"description":"SDK for Microsoft Translation Document service","homepage":"https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-document/README.md","keywords":["node","azure","cloud","typescript","browser","isomorphic"],"repository":{"type":"git","url":"git+https://github.com/Azure/azure-sdk-for-js.git","directory":"sdk/translation/ai-translation-document"},"author":{"name":"Microsoft Corporation"},"bugs":{"url":"https://github.com/Azure/azure-sdk-for-js/issues"},"license":"MIT","readme":"# Azure Document Translation client library for JavaScript\n\nDocument Translation is a cloud-based machine translation feature of the Azure AI Translator service. You can translate multiple and complex documents across all supported languages and dialects while preserving original document structure and data format. The Document Translation API supports two translation processes:\n\nAsynchronous batch translation supports the processing of multiple documents and large files. The batch translation process requires an Azure Blob storage account with storage containers for your source and translated documents.\n\nSynchronous single file translation supports the processing of single file translations. The file translation process doesn't require an Azure Blob storage account. The final response contains the translated document and is returned directly to the calling client.\n\nThe following operations are supported by the Document Translation feature:\n\n- **Synchronous document translation**: Used to synchronously translate a single document. The method doesn't require an Azure Blob storage account.\n- **Start batch translation**: Used to execute an asynchronous batch translation request. The method requires an Azure Blob storage account with storage containers for your source and translated documents.\n- **Get status for all translation jobs**: Used to request a list and the status of all translation jobs submitted by the user (associated with the resource).\n- **Get status for a specific translation job**: Used to request the status of a specific translation job. The response includes the overall job status and the status for documents that are being translated as part of that job.\n- **Get status for all documents**: Used to request the status for all documents in a translation job.\n- **Get status for a specific document**: Returns the status for a specific document in a job as indicated in the request by the id and documentId query parameters.\n- **Cancel translation**: Cancels a translation job that is currently processing or queued (pending). An operation isn't canceled if already completed, failed, or still canceling.\n- **Get supported formats**: Returns a list of document or glossary formats supported by the Document Translation feature.\n\nKey links:\n\n- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-document)\n- [Package (NPM)](https://www.npmjs.com/package/@azure/ai-translation-document)\n- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/ai-translation-document)\n- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-document/samples)\n\n## Getting started\n\n### Currently supported environments\n\n- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)\n- Latest versions of Safari, Chrome, Edge and Firefox.\n\nSee our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.\n\n### Prerequisites\n\n- An [Azure subscription][azure_sub].\n- An existing Translator service or Azure AI services resource. See [Create a Translator resource][translator_resource_create].\n\n### Install the `@azure/ai-translation-document` package\n\nInstall the Azure Document Translation client library for JavaScript with `npm`:\n\n```bash\nnpm install @azure/ai-translation-document\n```\n\n#### Set up Azure Blob Storage account\n\nBatch translation requires an Azure Blob Storage account. For more information about creating an Azure Blob Storage account see [here][azure_blob_storage_account]. For creating containers for your source and target files see [here][container]. Make sure to authorize your Translation resource storage access, more info [here][storage_container_authorization].\n\nWhen \"Allow Storage Account Key Access\" is disabled on the storage account, Managed Identity is enabled on the Translator resource, and it is assigned the role \"Storage Blob Data Contributor\" on the storage account, then you can use the container URLs directly and no SAS URIs will need to be generated.\n\n### Authenticate the client\n\nThis library exposes two clients:\n\n- `DocumentTranslationClient` for batch translation and translation status operations.\n- `SingleDocumentTranslationClient` for synchronous single-document translation.\n\nBoth clients can authenticate with a Microsoft Entra credential or an API key.\n\n#### Using a Microsoft Entra credential\n\nYou can authenticate with Microsoft Entra ID using a credential from the [@azure/identity][azure_identity] library. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:\n\n```bash\nnpm install @azure/identity\n```\n\nYou will also need to **register a new Microsoft Entra application and grant access** to the Translator resource by assigning a suitable role to your service principal.\n\nUsing Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client:\n\n```ts snippet:ReadmeSampleCreateClient_Node\nimport { DocumentTranslationClient } from \"@azure/ai-translation-document\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n\nconst endpoint = \"https://<translator-instance>.cognitiveservices.azure.com\";\nconst client = new DocumentTranslationClient(endpoint, new DefaultAzureCredential());\n```\n\nFor browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate:\n\n```ts snippet:ReadmeSampleCreateClient_Browser\nimport { InteractiveBrowserCredential } from \"@azure/identity\";\nimport { DocumentTranslationClient } from \"@azure/ai-translation-document\";\n\nconst credential = new InteractiveBrowserCredential({\n  tenantId: \"<YOUR_TENANT_ID>\",\n  clientId: \"<YOUR_CLIENT_ID>\",\n});\nconst client = new DocumentTranslationClient(\"<endpoint>\", credential);\n```\n\n#### Using an API key\n\nYou can also authenticate with the resource's API key using a `KeyCredential`:\n\n```ts snippet:ReadmeSampleCreateClient_KeyCredential\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { DocumentTranslationClient } from \"@azure/ai-translation-document\";\n\nconst endpoint = \"https://<translator-instance>.cognitiveservices.azure.com\";\nconst credential: KeyCredential = { key: \"YOUR_SUBSCRIPTION_KEY\" };\nconst client = new DocumentTranslationClient(endpoint, credential);\n```\n\n### JavaScript Bundle\n\nTo use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).\n\n## Key concepts\n\n### DocumentTranslationClient\n\n`DocumentTranslationClient` is the interface for asynchronous batch translation and for querying translation and document status. Batch translation requires an Azure Blob Storage account with containers for your source and translated documents.\n\n### SingleDocumentTranslationClient\n\n`SingleDocumentTranslationClient` is the interface for synchronous single-document translation. It doesn't require an Azure Blob Storage account; the translated document is returned directly in the response.\n\n## Examples\n\nThe following section provides several code snippets covering the main features of this client library.\n\n### Synchronous document translation\n\nUsed to synchronously translate a single document. The method doesn't require an Azure Blob storage account.\n\n```ts snippet:ReadmeSampleSynchronousDocumentTranslation\nimport { SingleDocumentTranslationClient } from \"@azure/ai-translation-document\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\nimport { writeFile } from \"node:fs/promises\";\n\nconst endpoint = \"https://<translator-instance>.cognitiveservices.azure.com\";\nconst client = new SingleDocumentTranslationClient(endpoint, new DefaultAzureCredential());\nconst response = await client.translate(\"hi\", {\n  document: {\n    contents: \"This is a test.\",\n    contentType: \"text/html\",\n    filename: \"test-input.txt\",\n  },\n});\nif (response.readableStreamBody) {\n  await writeFile(\"test-output.txt\", response.readableStreamBody);\n}\n```\n\n### Batch document translation\n\nUsed to execute an asynchronous batch translation request. The method requires an Azure Blob storage account with storage containers for your source and translated documents. Provide the source and target container URLs (with SAS tokens if required) and poll until the operation completes.\n\n```ts snippet:ReadmeSampleBatchDocumentTranslation\nimport { DocumentTranslationClient } from \"@azure/ai-translation-document\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n\nconst endpoint = \"https://<translator-instance>.cognitiveservices.azure.com\";\nconst client = new DocumentTranslationClient(endpoint, new DefaultAzureCredential());\nconst poller = client.startTranslation({\n  inputs: [\n    {\n      source: { sourceUrl: \"<source container SAS URL>\" },\n      targets: [{ targetUrl: \"<target container SAS URL>\", language: \"fr\" }],\n    },\n  ],\n});\nconst result = await poller.pollUntilDone();\nconsole.log(`Translation status: ${result.status}`);\n```\n\n### Get supported formats\n\nReturns a list of document formats supported by the Document Translation feature.\n\n```ts snippet:ReadmeSampleGetSupportedFormats\nimport { DocumentTranslationClient } from \"@azure/ai-translation-document\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n\nconst endpoint = \"https://<translator-instance>.cognitiveservices.azure.com\";\nconst client = new DocumentTranslationClient(endpoint, new DefaultAzureCredential());\nconst formats = await client.getSupportedFormats(\"Document\");\nfor (const format of formats.value) {\n  console.log(format.format);\n}\n```\n\n## Troubleshooting\n\n### Logging\n\nEnabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:\n\n```ts snippet:SetLogLevel\nimport { setLogLevel } from \"@azure/logger\";\n\nsetLogLevel(\"info\");\n```\n\nFor more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).\n\n## Contributing\n\nIf you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.\n\n## Related projects\n\n- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)\n\n[azure_sub]: https://azure.microsoft.com/free/\n[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity\n[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential\n[translator_resource_create]: https://learn.microsoft.com/azure/ai-services/translator/create-translator-resource\n[azure_blob_storage_account]: https://learn.microsoft.com/azure/storage/common/storage-account-create\n[container]: https://learn.microsoft.com/azure/storage/blobs/storage-quickstart-blobs-portal#create-a-container\n[storage_container_authorization]: https://learn.microsoft.com/azure/ai-services/translator/document-translation/how-to-guides/create-sas-tokens\n","readmeFilename":"README.md","_rev":"1-22931e02ec85006c7d309514d115c86d"}