Skip to content

v3.0.0-rc.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@mifi mifi released this 20 Jan 12:03

v3 is a complete rewrite of node-sdk with many bugfixes and improvements, as well as a new promise based API. See #87 for all changes.

Breaking changes

I have made some changes to make the API more consistent and easy to understand. This is an almost complete rewrite so there may be some unforeseen changes. These are the known breaking changes:

  • All previous callback methods now return a promise and do not accept a callback
  • replayAssembly(opts) changed to replayAssembly(assemblyId, params) (previously assemblyId was a key inside opts, but it was not optional, it was required)
-replayAssembly(opts, callback)
+await replayAssembly(assemblyId, params)
  • replayAssemblyNotification(opts) changed to replayAssemblyNotification(assemblyId, params) (previously assemblyId was a key inside opts, but it was not optional, it was required)
-replayAssemblyNotification(opts, callback)
+await replayAssemblyNotification(assemblyId, params)
  • deleteAssembly renamed to cancelAssembly to reflect the official terminology
  • Removed undocumented fields option (directly under createAssembly(opts)). Please use the fields key inside params instead.
  • Changed createAssembly(options[, onProgress]) to: createAssembly({ onUploadProgress: Function({ uploadedBytes, totalBytes }), onAssemblyProgress: Function(assembly) }) (see readme)

Before:

createAssembly({
  params: { ... },
  fields: { field1: 'val' },
}, callback, progressCb)

Now:

await createAssembly({
  params: {
    fields: { field1: 'val' },
  },
  onUploadProgress,
  onAssemblyProgress,
})
  • Increase default request timeout from 5000 to 60000
  • Now returns from waitForCompletion with the assembly result instead of throwing unknown error if result.ok is ASSEMBLY_CANCELED or REQUEST_ABORTED

Declarative createAssembly

addFile and addStream have been removed and are instead part of createAssembly:

// Before:
transloadit.addFile('file1', '/path/to/file')
transloadit.createAssembly({ ... })

// Now:
transloadit.createAssembly({
  files: {
    file1: '/path/to/file'
  },
  ...
})
// Before:
transloadit.addStream('file2', process.stdin)
transloadit.createAssembly({ ... })

// Now:
transloadit.createAssembly({
  uploads: {
    file2: process.stdin
  },
  ...
})

Auto retry logic

  • Will now only auto retry 5 times on RATE_LIMIT_REACHED (previous retry logic was overly aggressive: Used to retry on almost all errors, even unrecoverable ones, e.g. INVALID_FILE_META_DATA). Relevant code: 1 2
  • Will no longer automatically retry if assembly_url == null or assembly_ssl_url == null. Will instead throw a TransloaditClient.InconsistentResponseError. (relevant code)

Errors

Thrown errors have changed:

When HTTP response code is not successful, the error will now be a TransloaditClient.HTTPError object with an additional transloaditErrorCode property (used to be a normal Error object)

  • Message has been improved
  • Error property error has been renamed to transloaditErrorCode
  • Error property assembly_id has been renamed to assemblyId
  • All other JSON response properties from the Transloadit JSON response are no longer added directly to the Error object, but can instead be found in HTTPError.response.body.
  • The rest of the response JSON properties can be found on under HTTPError.response?.body (e.g. catch (err) { err.response.assembly_id }) - Note that err.response will be undefined for non-server errors
  • Will now also await ASSEMBLY_REPLAYING when waitForCompletion
  • Assemblies that have an error status (assembly.error) (but HTTP 200) will now result in an error thrown also when calling replayAssembly, to make it consistent with createAssembly
  • No longer throwing "Unknown error" for createTemplate and editTemplate if result.ok happens to be not defined
  • 404 response from the server will now throw a TransloaditClient.HTTPError (previously 404 gave a successful result)

See also README

v2.0.10...v3.0.0-rc.1