Repository navigation
TL;DR: new APIs in this release: the Admin API, spoken terms, style profiles and text correction.
Translation memories, style rules and multilingual glossaries gained many options and fixes.
Read Changed and Deprecated before upgrading; no public API is removed in this release.
Added
DocumentTranslationErrorcopieshttpStatusCodeandshouldRetryfrom its
cause when the cause is aDeepLError.- Added
waitUntilTranslationMemoryJobDone(), which replaces
isTranslationMemoryJobComplete(). It accepts the job as an ID or a
TranslationMemoryJob, andWaitOptionsor the timeout in milliseconds, and
rejects with the job's error message if the job fails or expires.
getTranslationMemoryJob()also accepts aTranslationMemoryJob. - Added
result,status,done()andok()toTranslationMemoryJob:
the single entry ofresults, its status, whether the job completed, and
whether it has not failed or expired.done()andok()are optional members
of the type, so objects built without them still compile;done()is also true
for the deprecated'downloaded'status. - Added the
CreateTranslationMemoryImportOptionsand
ImportTranslationMemoryOptionstypes, withextraBodyParametersmerged last
into the import request body. importTranslationMemoryFromFilepath()accepts aBufferorReadStream, with
the newfileNameoption (ordisplayName) as the file name.isTranslationMemoryJobComplete()also acceptsWaitOptions.- The style rule methods
getStyleRule(),updateStyleRuleName(),
updateStyleRuleConfiguredRules(),deleteStyleRule()and the four custom
instruction methods accept the style rule as an ID or aStyleRuleInfo
object.getStyleRuleCustomInstruction(),updateStyleRuleCustomInstruction()
anddeleteStyleRuleCustomInstruction()accept the custom instruction as an
ID or aCustomInstructionobject. - Added an optional last
optionsargument withextraBodyParametersto
createStyleRule(),updateStyleRuleName(),updateStyleRuleConfiguredRules(),
createStyleRuleCustomInstruction()andupdateStyleRuleCustomInstruction()
(typesCreateStyleRuleOptions,UpdateStyleRuleNameOptions,
UpdateStyleRuleConfiguredRulesOptions,CreateStyleRuleCustomInstructionOptions
andUpdateStyleRuleCustomInstructionOptions). - Added
translateDocumentUpload(),translateDocumentGetStatus()and
translateDocumentDownload(), which replaceuploadDocument(),
getDocumentStatus()anddownloadDocument()and behave the same. - Added
documentIdtoDocumentStatus, parsed fromdocument_id;undefined
when the response does not contain it. - Added the
timeoutMsoption toDocumentTranslateOptions: the maximum time
translateDocument()waits for the translation between upload and download.
When it expires,translateDocument()rejects with aDocumentTranslationError. - Added the
WaitOptionstype withtimeoutMs. - Added
tagHandlingVersiontoTextResult: the tag handling version used, parsed
from the response;undefinedwhen the API does not return it. SentenceSplittingModeaccepts'1'and'0', the API values, which are sent
unchanged.- Added the
extraBodyParametersoption toBaseRequestOptions, and so to
TranslateTextOptions,DocumentTranslateOptions,RephraseTextOptionsand
CorrectTextOptions.
It replacesextraRequestParametersand behaves the same. Passing both
throwsArgumentError. - Added
NotFoundError, thrown when the API answers HTTP 404 on any endpoint.
GlossaryNotFoundErrornow extends it. - Added
httpStatusCodetoDeepLError: the HTTP status code of the failed
response, orundefinedif there was no HTTP response. - Added
shouldRetrytoDeepLError(previously only onConnectionError):
true for HTTP 429, 5xx and transient network failures. For
DeepLAdminClient.createDeveloperKey()it is true only when the request was
not processed (HTTP 429, DNS failures and refused connections). isFreeAccountAuthKey()is exported from the package root.- Added the
styleProfileoption toTranslateTextOptionsand
DocumentTranslateOptionsto translate text and documents with a style
profile, given as its ID or aStyleProfileobject. It is sent as
style_profile_id. - Added style profiles (
/v3/style_profiles) toDeepLClient:
listStyleProfiles(),createStyleProfile(),getStyleProfile(),
updateStyleProfile()anddeleteStyleProfile(). Added theStyleProfile,
CreateStyleProfileOptionsandUpdateStyleProfileOptionstypes. The
options acceptextraBodyParameters, and the linked glossaries, style rule
lists and translation memories as IDs or objects; the options of
updateStyleProfile()are optional. - Added spoken terms collections (
/v3/spoken-terms) toDeepLClient:
createSpokenTerms(),listSpokenTerms(),getSpokenTerms(),
updateSpokenTerms(),getSpokenTermsEntries(),replaceSpokenTermsList(),
deleteSpokenTerms()anddeleteSpokenTermsList(). Added theSpokenTerms,
SpokenTermsListandSpokenTermsEntriestypes, and the
CreateSpokenTermsOptions,UpdateSpokenTermsOptionsand
ReplaceSpokenTermsListOptionstypes, which acceptextraBodyParameters.
The options ofupdateSpokenTerms()are optional; without them an empty body
is sent. Terms are trimmed, then checked and sent trimmed. - Added the API Pro fields of
GET /v2/usagetoUsage:apiKeyCharacter,
speechToTextMinutesandspeechToSpeechMinutes(UsageDetail),products
(array of the newUsageProducttype), andstartTimeandendTime
(Date). They areundefinedwhen the response does not contain them, as
are theUsageProductfields missing from aproductsentry.
anyLimitReached()still checks only the character, document and team
document usage. - Added the
DeepLAdminClientclass for the Admin API. It must be created with
an admin API key and supports managing developer keys
(createDeveloperKey(),listDeveloperKeys(),deactivateDeveloperKey(),
renameDeveloperKey(),setDeveloperKeyUsageLimits()) and retrieving usage
analytics (getUsageAnalytics(startDate, endDate, groupBy?),
getCustomTagUsageAnalytics(startDate, endDate, aggregateBy?, page?)). Added
theHttpClientOptions,DeepLAdminClientOptions,DeveloperKey,
DeveloperKeyUsageLimits,DeveloperKeyUsageLimitsUpdate,AdminUsageReport,
AdminUsageBreakdown,KeyUsage,AdminUsageGroupBy,CustomTagUsageReport,
CustomTagUsage,CustomTagUsageBreakdownandCustomTagUsageAggregateBy
types;AdminUsageGroupByandCustomTagUsageAggregateByalso accept any
other string, which is sent unchanged. The developer key methods take a
trailing options argument (CreateDeveloperKeyOptionswithlabel,
DeactivateDeveloperKeyOptions,RenameDeveloperKeyOptions,
SetDeveloperKeyUsageLimitsOptions) that acceptsextraBodyParameters.
AdminUsageBreakdownincludesspeechToSpeechMinutes.
DeveloperKey.label,DeveloperKey.usageLimits,KeyUsage.apiKeyLabel,
AdminUsageBreakdown.speechToSpeechMinutes,
CustomTagUsageBreakdown.speechToSpeechMinutes,AdminUsageReport.totalUsage
andstartDateandendDateof both reports are optional andundefined
when the response does not contain them, never0, an all-zero breakdown or
an invalidDate. Report dates areDates at UTC midnight. - Added
getLanguageResources()toDeepLClient, which retrieves the resources
supported by the DeepL API and, for each feature, whether the source and/or
target language must support it. Added theLanguageResourceand
ResourceFeaturetypes.
ResourceFeature.needsSourceSupportandneedsTargetSupportareboolean
and[secure]when the API omits them. - Added
getLanguagesForResource()toDeepLClient, which retrieves the languages supported
by a DeepL API resource (GET /v3/languages), whether each is usable as source
and/or target language, and the features it supports. The optionalinclude
option adds beta languages and features, or features relying on third-party
providers. Added theLanguageSupport,LanguageFeature,
LanguageResourceName,LanguageIncludeandGetLanguagesForResourceOptionstypes.
LanguageResourceNameandLanguageIncludeaccept any string in addition to
their listed values, which is sent unchanged. - Added
correctText()toDeepLClient, which corrects grammar, spelling and punctuation
of a string or an array of strings viaPOST /v2/write/correct. Takes an optional
target language and an optionalCorrectTextOptionsobject (BaseRequestOptions, so
extraBodyParameters), and returnsWriteResultobjects, likerephraseText(). - Added the
outputFormatoption toDocumentTranslateOptions, which requests the file
format of the translated document, for example'docx'. By default the translated
document has the same format as the input document. - Added the
enableWatermarkoption toDocumentTranslateOptions, which adds a
"Translated by DeepL" watermark to the translated document. Only supported for
docxandpdfoutput. - Added
translateDocumentWaitUntilDone(), which polls a document translation
until it is done and resolves with the finalDocumentStatus, or rejects with
aDeepLErrorif the translation fails. Its optional second argument
(WaitOptions) takestimeoutMs, after which it rejects with aDeepLError. - Added the
RephraseTextOptionstype withwritingStyleandtone. It
extendsBaseRequestOptions, so it also acceptsextraBodyParameters,
which are added to the request body and override parameters of the same
name.rephraseText()accepts it as its third argument. createStyleRule()accepts the name, language, configured rules and custom
instructions as separate arguments:
createStyleRule(name, language, configuredRules?, customInstructions?).
They use the API's names and are sent as given:configuredRulesas
configured_rules(e.g.{ dates_and_times: { calendar_era: 'use_bc_and_ad' } },
likeupdateStyleRuleConfiguredRules()), andcustomInstructionsas
custom_instructions(CustomInstructionRequestBodyobjects withlabel,
promptandsource_language).createStyleRuleCustomInstruction()andupdateStyleRuleCustomInstruction()
accept the label, prompt and optional source language as separate arguments:
createStyleRuleCustomInstruction(styleId, label, prompt, sourceLanguage?)and
updateStyleRuleCustomInstruction(styleId, instructionId, label, prompt, sourceLanguage?).- Added
updateMultilingualGlossary(glossary, options?), which changes the
name and merges dictionaries of a multilingual glossary in one request. The new
UpdateMultilingualGlossaryOptionsholdsnameanddictionaries; only the
fields that are set are sent, as JSON. - Added
createMultilingualGlossaryFromCsv(),
updateMultilingualGlossaryDictionaryFromCsv()and
replaceMultilingualGlossaryDictionaryFromCsv(), which replace the*WithCsv()
methods of the same name and behave the same. createMultilingualGlossary(),createMultilingualGlossaryFromCsv(),
updateMultilingualGlossaryName(),updateMultilingualGlossaryDictionary(),
updateMultilingualGlossaryDictionaryFromCsv(),
replaceMultilingualGlossaryDictionary()and
replaceMultilingualGlossaryDictionaryFromCsv()take an optional last
optionsargument withextraBodyParameters(new types
CreateMultilingualGlossaryOptionsand
ReplaceMultilingualGlossaryDictionaryOptions).getMultilingualGlossary()accepts aMultilingualGlossaryInfoobject as well
as a glossary ID.
Changed
translateText()accepts theglossaryandglossaryIdsoptions without a
source language; the API detects the source language and uses the glossary's
dictionary for the detected language pair. Document translation with a
glossary still requires a source language.Formality,SentenceSplittingMode,TagHandlingMode,TagHandlingVersion
andModelTypeaccept any string in addition to their listed values, so values
the API adds later can be passed without a type cast. Aswitchover one of
these types that ends in anevercheck no longer compiles; add adefault
branch.- Every HTTP 404 response now throws
NotFoundError; before, only glossary
requests threw an error class of their own (GlossaryNotFoundError, which
is still thrown there) and other requests threw a plainDeepLError. - The default per-attempt timeout (
minTimeout) is now 10 seconds instead of
5 seconds. - Refused connections (
ECONNREFUSED), DNS failures (ENOTFOUND) and
unreachable hosts or networks (EHOSTUNREACH,ENETUNREACH,ENETDOWN) are
now retried, also bycreateDeveloperKey(), and the finalConnectionError
hasshouldRetryset to true. With the defaults an unreachable server now
fails after about 16 seconds instead of at once; setmaxRetries: 0for the
old behaviour. maxRetriesnow counts retries after the first attempt, so every setting
makes one more attempt than before (default: 6 attempts instead of 5).- A
Content-Type,Content-Length,Transfer-EncodingorHostheader in the
headersoption is now ignored. Before, aContent-Typereplaced the form
content type and broke the request. - The
proxyoption now also accepts a proxy URL string, for example
'http://user:pass@proxy.example.com:3128', and is typed
ProxyConfig | string; code that readsoptions.proxy.hostmust first check
thatproxyis not a string. TargetLanguageCodenow includesde-CH,de-DE,es-ES,fr-CA,fr-FR,
enandpt; aRecord<TargetLanguageCode, …>object literal must list
them.translateDocument()andtranslateDocumentUpload()now send thefilename
option as the file name when the input is a file path; previously they always
sent the path's base name. The base name remains the default.- HTTP 401 responses now throw
AuthorizationError, like 403; previously they
threw aDeepLErrorwith "Unexpected status code". rephraseText()andcorrectText()now throwDeepLErrorwhen the response
contains a different number of improvements than texts sent; previously a
single text resolved toundefinedand an array to a shorter array.- Malformed or non-object API responses now throw
DeepLError; previously some
methods (getSourceLanguages(),getTargetLanguages(), the multilingual
glossary, style rule, custom instruction, spoken terms and style profile
methods) let a rawSyntaxErrororTypeErrorescape. getSourceLanguages(),getTargetLanguages(), andgetGlossaryLanguagePairs()now call the
GET /v3/languagesendpoint instead of the deprecatedGET /v2/languagesand
GET /v2/glossary-language-pairsendpoints. The returned language lists may contain
additional languages.- Target languages
enandptare no longer rejected client-side as deprecated;
the DeepL API translates them asen-USandpt-PT. - The language parameters of
translateText(),translateDocument(),
uploadDocument(),createGlossary()andcreateGlossaryWithCsv()accept
any language code string, so languages the API adds can be used without a new
release of this package. They use the newSourceLanguageCodeInput,
TargetLanguageCodeInputandLanguageCodeInputtypes, which keep editor
autocompletion for the listed codes. Result types are unchanged. - README: the document minification section no longer states a 30 MB upload
limit and links to the DeepL API usage limits instead.
Deprecated
isTranslationMemoryJobComplete(): usewaitUntilTranslationMemoryJobDone()
instead.- The
'downloaded'member ofTranslationMemoryJobStatus: the API does not
report it for translation memory jobs. uploadDocument(),getDocumentStatus()anddownloadDocument()are
deprecated; usetranslateDocumentUpload(),translateDocumentGetStatus()
andtranslateDocumentDownload()instead. They will be removed in the next
major version.SentenceSplittingModevalues'on'and'default'are deprecated. Use'1'
instead.extraRequestParametersis deprecated; useextraBodyParametersinstead.
It will be removed in the next major version.TranslatorandTranslatorOptionsare deprecated; useDeepLClientand
DeepLClientOptionsinstead, which support every method ofTranslator.
They will be removed in the next major version.GlossaryNotFoundErroris deprecated; catchNotFoundErrorinstead. It will
be removed in the next major version.TranslateTextOptions.__pathis deprecated. It is for internal use only
and will be removed in the next major version.isDocumentTranslationComplete()is deprecated; use
translateDocumentWaitUntilDone()instead. It will be removed in the next
major version.- Passing the writing style and tone of
rephraseText()as positional
arguments is deprecated; pass aRephraseTextOptionsobject as the third
argument instead. The positional form will be removed in the next major
version. - Passing a single
CreateStyleRuleRequestBodyobject tocreateStyleRule()
is deprecated, as is theCreateStyleRuleRequestBodytype; pass separate
arguments instead. Passing aCustomInstructionRequestBodyobject to
createStyleRuleCustomInstruction()orupdateStyleRuleCustomInstruction()
is deprecated; pass the label, prompt and source language as separate
arguments instead. These object forms andCreateStyleRuleRequestBodywill be
removed in the next major version. - Document minification is deprecated: the
enableDocumentMinificationoption
ofDocumentTranslateOptions, theDocumentMinifierclass, and the
DocumentMinificationErrorandDocumentDeminificationErrorerrors. The
DeepL API accepts larger documents; see the
usage limits.
Minification keeps working and will be removed in the next major version. checkStatusCode()and the internal*ApiResponsetypes used to parse API
responses (MultilingualGlossaryDictionaryEntriesApiResponse,
MultilingualGlossaryDictionaryApiResponse,
ListMultilingualGlossaryApiResponse,StyleRuleInfoApiResponse,
ListStyleRuleApiResponse,TranslationMemoryInfoApiResponse,
ListTranslationMemoryApiResponse,TranslationMemorySegmentsApiResponse,
TranslationMemoryImportApiResponse,TranslationMemoryExportApiResponse,
TranslationMemoryJobApiResponseandLanguageResourceApiResponse) are
deprecated. They are internal and will no longer be exported in the next
major version.createMultilingualGlossaryWithCsv(),
updateMultilingualGlossaryDictionaryWithCsv()and
replaceMultilingualGlossaryDictionaryWithCsv()are deprecated; use the
*FromCsv()methods of the same name instead. They will be removed in the next
major version.
Fixed
DeepLAdminClient.createDeveloperKey()is also retried after a timeout that
occurred before the connection was established, and itsshouldRetryis true
for such a timeout.- A response with a 3xx status that is not followed as a redirect (for example
300 or 304) throws aDeepLErrorwith itshttpStatusCodeinstead of being
parsed as a successful response. - A negative or non-integer
maxRetriesoption throws anArgumentErrorwhen the
client is constructed. Before, every request failed by throwingundefined. deleteMultilingualGlossaryDictionary()anddeleteSpokenTermsList()encode a
space in query values as%20instead of+.translateDocument()checks before any request that the input file is
readable; a missing input still rejects withDocumentTranslationError.- A failed document minification in
translateDocument()now removes the
output file it created; previously the empty file was left behind. translateDocumentDownload()with an output file path no longer crashes the
process with an uncaughtEEXIST/ENOENTwhen the path exists or cannot be
created: it creates the file before the request and rejects. A connection
failure mid-download intranslateDocumentDownload(),translateDocument()and
downloadTranslationMemoryExport()rejects with aConnectionErrorinstead
of an uncaught or raw stream error.- Glossary terms are trimmed before they are validated and sent by
createGlossary(),createMultilingualGlossary(),
updateMultilingualGlossary(),updateMultilingualGlossaryDictionary()and
replaceMultilingualGlossaryDictionary(), so' foo 'is sent as'foo'and
a whitespace-only term throws aDeepLErrorbefore any request. getUsage()leavescharacter,documentandteamDocumentundefined
when the response's count or limit for them is not a number, as it already did
for the API Pro usage fields. Before, anullor string value was returned as
the count or limit.isTranslationMemoryJobComplete(),importTranslationMemoryFromFilepath()and
exportTranslationMemoryToFilepath()keep polling on an unknown status or a
job without results instead of rejecting; the timeout bounds the wait.- Translation memory and job IDs are URL-encoded in request paths.
exportTranslationMemoryToFilepath()checks for an existing output file and
an unwritable or missing output directory before it creates the export job,
and throws the same Node error (EEXIST,ENOENT,EACCES) as before;
before, it was thrown only after the export had been created and waited for.DocumentStatus.ok()is now true for every status except'error'. Before,
a status the library did not know madetranslateDocument()and
translateDocumentWaitUntilDone()stop polling and reject with
unknown error.- The document ID is now URL-encoded in the request paths of the document
status and download methods. extraBodyParameters(andextraRequestParameters) oftranslateText()and
uploadDocument()/translateDocument()now replace every parameter of the same
name set by the library. Before, parameters appended after the languages and
glossaries, such astext,split_sentences,style_idoroutput_format, were
sent twice.translateText()no longer writes the lower-casedsplitSentencesvalue back into
the caller's options object.- The authentication key is trimmed before it is checked, used for the free
account (:fx) detection and sent; a whitespace-only key is rejected. downloadTranslationMemoryExport()no longer hangs on Node 16 and 17 when the output file
already exists. It now rejects withEEXISTbefore downloading anything, on every Node
version, and leaves the existing file unchanged.createMultilingualGlossary(),createMultilingualGlossaryWithCsv()and
listMultilingualGlossaries()now throwGlossaryNotFoundErroron HTTP 404,
like the other multilingual glossary methods.- The glossary ID is now URL-encoded in the request paths of the multilingual
glossary methods, and the language codes of
deleteMultilingualGlossaryDictionary()in its query string. replaceMultilingualGlossaryDictionary()and
replaceMultilingualGlossaryDictionaryWithCsv()now send a JSON body, the only
format the API documents for this request; before they sent form-encoded data.
Security
- Updated
follow-redirectsto 1.16.2 in the lockfile to resolve the
high-severity advisory GHSA-mrwp-f3q8-3g9p.