v3.0.0-rc.1
Pre-release
Pre-release
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 toreplayAssembly(assemblyId, params)
(previouslyassemblyId
was a key inside opts, but it was not optional, it was required)
-replayAssembly(opts, callback)
+await replayAssembly(assemblyId, params)
replayAssemblyNotification(opts)
changed toreplayAssemblyNotification(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 tocancelAssembly
to reflect the official terminology- Removed undocumented
fields
option (directly undercreateAssembly(opts)
). Please use thefields
key insideparams
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 isASSEMBLY_CANCELED
orREQUEST_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
orassembly_ssl_url == null
. Will instead throw aTransloaditClient.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
propertyerror
has been renamed totransloaditErrorCode
Error
propertyassembly_id
has been renamed toassemblyId
- All other JSON response properties from the Transloadit JSON response are no longer added directly to the
Error
object, but can instead be found inHTTPError.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 thaterr.response
will be undefined for non-server errors - Will now also await
ASSEMBLY_REPLAYING
whenwaitForCompletion
- Assemblies that have an error status (
assembly.error
) (but HTTP 200) will now result in an error thrown also when callingreplayAssembly
, to make it consistent withcreateAssembly
- 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