Skip to content

v1.29.0

Latest

Choose a tag to compare

@github-actions github-actions released this 02 Nov 11:36

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

  • DocumentTranslationError copies httpStatusCode and shouldRetry from its
    cause when the cause is a DeepLError.
  • Added waitUntilTranslationMemoryJobDone(), which replaces
    isTranslationMemoryJobComplete(). It accepts the job as an ID or a
    TranslationMemoryJob, and WaitOptions or the timeout in milliseconds, and
    rejects with the job's error message if the job fails or expires.
    getTranslationMemoryJob() also accepts a TranslationMemoryJob.
  • Added result, status, done() and ok() to TranslationMemoryJob:
    the single entry of results, its status, whether the job completed, and
    whether it has not failed or expired. done() and ok() are optional members
    of the type, so objects built without them still compile; done() is also true
    for the deprecated 'downloaded' status.
  • Added the CreateTranslationMemoryImportOptions and
    ImportTranslationMemoryOptions types, with extraBodyParameters merged last
    into the import request body.
  • importTranslationMemoryFromFilepath() accepts a Buffer or ReadStream, with
    the new fileName option (or displayName) as the file name.
  • isTranslationMemoryJobComplete() also accepts WaitOptions.
  • The style rule methods getStyleRule(), updateStyleRuleName(),
    updateStyleRuleConfiguredRules(), deleteStyleRule() and the four custom
    instruction methods accept the style rule as an ID or a StyleRuleInfo
    object. getStyleRuleCustomInstruction(), updateStyleRuleCustomInstruction()
    and deleteStyleRuleCustomInstruction() accept the custom instruction as an
    ID or a CustomInstruction object.
  • Added an optional last options argument with extraBodyParameters to
    createStyleRule(), updateStyleRuleName(), updateStyleRuleConfiguredRules(),
    createStyleRuleCustomInstruction() and updateStyleRuleCustomInstruction()
    (types CreateStyleRuleOptions, UpdateStyleRuleNameOptions,
    UpdateStyleRuleConfiguredRulesOptions, CreateStyleRuleCustomInstructionOptions
    and UpdateStyleRuleCustomInstructionOptions).
  • Added translateDocumentUpload(), translateDocumentGetStatus() and
    translateDocumentDownload(), which replace uploadDocument(),
    getDocumentStatus() and downloadDocument() and behave the same.
  • Added documentId to DocumentStatus, parsed from document_id; undefined
    when the response does not contain it.
  • Added the timeoutMs option to DocumentTranslateOptions: the maximum time
    translateDocument() waits for the translation between upload and download.
    When it expires, translateDocument() rejects with a DocumentTranslationError.
  • Added the WaitOptions type with timeoutMs.
  • Added tagHandlingVersion to TextResult: the tag handling version used, parsed
    from the response; undefined when the API does not return it.
  • SentenceSplittingMode accepts '1' and '0', the API values, which are sent
    unchanged.
  • Added the extraBodyParameters option to BaseRequestOptions, and so to
    TranslateTextOptions, DocumentTranslateOptions, RephraseTextOptions and
    CorrectTextOptions.
    It replaces extraRequestParameters and behaves the same. Passing both
    throws ArgumentError.
  • Added NotFoundError, thrown when the API answers HTTP 404 on any endpoint.
    GlossaryNotFoundError now extends it.
  • Added httpStatusCode to DeepLError: the HTTP status code of the failed
    response, or undefined if there was no HTTP response.
  • Added shouldRetry to DeepLError (previously only on ConnectionError):
    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 styleProfile option to TranslateTextOptions and
    DocumentTranslateOptions to translate text and documents with a style
    profile, given as its ID or a StyleProfile object. It is sent as
    style_profile_id.
  • Added style profiles (/v3/style_profiles) to DeepLClient:
    listStyleProfiles(), createStyleProfile(), getStyleProfile(),
    updateStyleProfile() and deleteStyleProfile(). Added the StyleProfile,
    CreateStyleProfileOptions and UpdateStyleProfileOptions types. The
    options accept extraBodyParameters, 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) to DeepLClient:
    createSpokenTerms(), listSpokenTerms(), getSpokenTerms(),
    updateSpokenTerms(), getSpokenTermsEntries(), replaceSpokenTermsList(),
    deleteSpokenTerms() and deleteSpokenTermsList(). Added the SpokenTerms,
    SpokenTermsList and SpokenTermsEntries types, and the
    CreateSpokenTermsOptions, UpdateSpokenTermsOptions and
    ReplaceSpokenTermsListOptions types, which accept extraBodyParameters.
    The options of updateSpokenTerms() 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/usage to Usage: apiKeyCharacter,
    speechToTextMinutes and speechToSpeechMinutes (UsageDetail), products
    (array of the new UsageProduct type), and startTime and endTime
    (Date). They are undefined when the response does not contain them, as
    are the UsageProduct fields missing from a products entry.
    anyLimitReached() still checks only the character, document and team
    document usage.
  • Added the DeepLAdminClient class 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
    the HttpClientOptions, DeepLAdminClientOptions, DeveloperKey,
    DeveloperKeyUsageLimits, DeveloperKeyUsageLimitsUpdate, AdminUsageReport,
    AdminUsageBreakdown, KeyUsage, AdminUsageGroupBy, CustomTagUsageReport,
    CustomTagUsage, CustomTagUsageBreakdown and CustomTagUsageAggregateBy
    types; AdminUsageGroupBy and CustomTagUsageAggregateBy also accept any
    other string, which is sent unchanged. The developer key methods take a
    trailing options argument (CreateDeveloperKeyOptions with label,
    DeactivateDeveloperKeyOptions, RenameDeveloperKeyOptions,
    SetDeveloperKeyUsageLimitsOptions) that accepts extraBodyParameters.
    AdminUsageBreakdown includes speechToSpeechMinutes.
    DeveloperKey.label, DeveloperKey.usageLimits, KeyUsage.apiKeyLabel,
    AdminUsageBreakdown.speechToSpeechMinutes,
    CustomTagUsageBreakdown.speechToSpeechMinutes, AdminUsageReport.totalUsage
    and startDate and endDate of both reports are optional and undefined
    when the response does not contain them, never 0, an all-zero breakdown or
    an invalid Date. Report dates are Dates at UTC midnight.
  • Added getLanguageResources() to DeepLClient, which retrieves the resources
    supported by the DeepL API and, for each feature, whether the source and/or
    target language must support it. Added the LanguageResource and
    ResourceFeature types.
    ResourceFeature.needsSourceSupport and needsTargetSupport are boolean
    and [secure] when the API omits them.
  • Added getLanguagesForResource() to DeepLClient, 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 optional include
    option adds beta languages and features, or features relying on third-party
    providers. Added the LanguageSupport, LanguageFeature,
    LanguageResourceName, LanguageInclude and GetLanguagesForResourceOptions types.
    LanguageResourceName and LanguageInclude accept any string in addition to
    their listed values, which is sent unchanged.
  • Added correctText() to DeepLClient, which corrects grammar, spelling and punctuation
    of a string or an array of strings via POST /v2/write/correct. Takes an optional
    target language and an optional CorrectTextOptions object (BaseRequestOptions, so
    extraBodyParameters), and returns WriteResult objects, like rephraseText().
  • Added the outputFormat option to DocumentTranslateOptions, 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 enableWatermark option to DocumentTranslateOptions, which adds a
    "Translated by DeepL" watermark to the translated document. Only supported for
    docx and pdf output.
  • Added translateDocumentWaitUntilDone(), which polls a document translation
    until it is done and resolves with the final DocumentStatus, or rejects with
    a DeepLError if the translation fails. Its optional second argument
    (WaitOptions) takes timeoutMs, after which it rejects with a DeepLError.
  • Added the RephraseTextOptions type with writingStyle and tone. It
    extends BaseRequestOptions, so it also accepts extraBodyParameters,
    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: configuredRules as
    configured_rules (e.g. { dates_and_times: { calendar_era: 'use_bc_and_ad' } },
    like updateStyleRuleConfiguredRules()), and customInstructions as
    custom_instructions (CustomInstructionRequestBody objects with label,
    prompt and source_language).
  • createStyleRuleCustomInstruction() and updateStyleRuleCustomInstruction()
    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
    UpdateMultilingualGlossaryOptions holds name and dictionaries; 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
    options argument with extraBodyParameters (new types
    CreateMultilingualGlossaryOptions and
    ReplaceMultilingualGlossaryDictionaryOptions).
  • getMultilingualGlossary() accepts a MultilingualGlossaryInfo object as well
    as a glossary ID.

Changed

  • translateText() accepts the glossary and glossaryIds options 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
    and ModelType accept any string in addition to their listed values, so values
    the API adds later can be passed without a type cast. A switch over one of
    these types that ends in a never check no longer compiles; add a default
    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 plain DeepLError.
  • 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 by createDeveloperKey(), and the final ConnectionError
    has shouldRetry set to true. With the defaults an unreachable server now
    fails after about 16 seconds instead of at once; set maxRetries: 0 for the
    old behaviour.
  • maxRetries now 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-Encoding or Host header in the
    headers option is now ignored. Before, a Content-Type replaced the form
    content type and broke the request.
  • The proxy option now also accepts a proxy URL string, for example
    'http://user:pass@proxy.example.com:3128', and is typed
    ProxyConfig | string; code that reads options.proxy.host must first check
    that proxy is not a string.
  • TargetLanguageCode now includes de-CH, de-DE, es-ES, fr-CA, fr-FR,
    en and pt; a Record<TargetLanguageCode, …> object literal must list
    them.
  • translateDocument() and translateDocumentUpload() now send the filename
    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 a DeepLError with "Unexpected status code".
  • rephraseText() and correctText() now throw DeepLError when the response
    contains a different number of improvements than texts sent; previously a
    single text resolved to undefined and 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 raw SyntaxError or TypeError escape.
  • getSourceLanguages(), getTargetLanguages(), and getGlossaryLanguagePairs() now call the
    GET /v3/languages endpoint instead of the deprecated GET /v2/languages and
    GET /v2/glossary-language-pairs endpoints. The returned language lists may contain
    additional languages.
  • Target languages en and pt are no longer rejected client-side as deprecated;
    the DeepL API translates them as en-US and pt-PT.
  • The language parameters of translateText(), translateDocument(),
    uploadDocument(), createGlossary() and createGlossaryWithCsv() accept
    any language code string, so languages the API adds can be used without a new
    release of this package. They use the new SourceLanguageCodeInput,
    TargetLanguageCodeInput and LanguageCodeInput types, 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(): use waitUntilTranslationMemoryJobDone()
    instead.
  • The 'downloaded' member of TranslationMemoryJobStatus: the API does not
    report it for translation memory jobs.
  • uploadDocument(), getDocumentStatus() and downloadDocument() are
    deprecated; use translateDocumentUpload(), translateDocumentGetStatus()
    and translateDocumentDownload() instead. They will be removed in the next
    major version.
  • SentenceSplittingMode values 'on' and 'default' are deprecated. Use '1'
    instead.
  • extraRequestParameters is deprecated; use extraBodyParameters instead.
    It will be removed in the next major version.
  • Translator and TranslatorOptions are deprecated; use DeepLClient and
    DeepLClientOptions instead, which support every method of Translator.
    They will be removed in the next major version.
  • GlossaryNotFoundError is deprecated; catch NotFoundError instead. It will
    be removed in the next major version.
  • TranslateTextOptions.__path is 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 a RephraseTextOptions object as the third
    argument instead. The positional form will be removed in the next major
    version.
  • Passing a single CreateStyleRuleRequestBody object to createStyleRule()
    is deprecated, as is the CreateStyleRuleRequestBody type; pass separate
    arguments instead. Passing a CustomInstructionRequestBody object to
    createStyleRuleCustomInstruction() or updateStyleRuleCustomInstruction()
    is deprecated; pass the label, prompt and source language as separate
    arguments instead. These object forms and CreateStyleRuleRequestBody will be
    removed in the next major version.
  • Document minification is deprecated: the enableDocumentMinification option
    of DocumentTranslateOptions, the DocumentMinifier class, and the
    DocumentMinificationError and DocumentDeminificationError errors. 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 *ApiResponse types used to parse API
    responses (MultilingualGlossaryDictionaryEntriesApiResponse,
    MultilingualGlossaryDictionaryApiResponse,
    ListMultilingualGlossaryApiResponse, StyleRuleInfoApiResponse,
    ListStyleRuleApiResponse, TranslationMemoryInfoApiResponse,
    ListTranslationMemoryApiResponse, TranslationMemorySegmentsApiResponse,
    TranslationMemoryImportApiResponse, TranslationMemoryExportApiResponse,
    TranslationMemoryJobApiResponse and LanguageResourceApiResponse) 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 its shouldRetry is true
    for such a timeout.
  • A response with a 3xx status that is not followed as a redirect (for example
    300 or 304) throws a DeepLError with its httpStatusCode instead of being
    parsed as a successful response.
  • A negative or non-integer maxRetries option throws an ArgumentError when the
    client is constructed. Before, every request failed by throwing undefined.
  • deleteMultilingualGlossaryDictionary() and deleteSpokenTermsList() encode a
    space in query values as %20 instead of +.
  • translateDocument() checks before any request that the input file is
    readable; a missing input still rejects with DocumentTranslationError.
  • 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 uncaught EEXIST/ENOENT when the path exists or cannot be
    created: it creates the file before the request and rejects. A connection
    failure mid-download in translateDocumentDownload(), translateDocument() and
    downloadTranslationMemoryExport() rejects with a ConnectionError instead
    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 a DeepLError before any request.
  • getUsage() leaves character, document and teamDocument undefined
    when the response's count or limit for them is not a number, as it already did
    for the API Pro usage fields. Before, a null or 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 made translateDocument() 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 (and extraRequestParameters) of translateText() and
    uploadDocument()/translateDocument() now replace every parameter of the same
    name set by the library. Before, parameters appended after the languages and
    glossaries, such as text, split_sentences, style_id or output_format, were
    sent twice.
  • translateText() no longer writes the lower-cased splitSentences value 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 with EEXIST before downloading anything, on every Node
    version, and leaves the existing file unchanged.
  • createMultilingualGlossary(), createMultilingualGlossaryWithCsv() and
    listMultilingualGlossaries() now throw GlossaryNotFoundError on 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-redirects to 1.16.2 in the lockfile to resolve the
    high-severity advisory GHSA-mrwp-f3q8-3g9p.