You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[x]**Breaking:** Package is now pure ESM, requires Node.js 20+, and exports `{ Transloadit }` instead of a default client.
20
-
-[x]**Breaking:**Assembly inputs are validated against rich schemas; migrate to the new `AssemblyInstructionsInput` types and expect `listAssemblies()` to return `{ items, count }`.
21
-
-[x] Added end-to-end TypeScript typings for robots, assemblies, templates, and responses, so assembly instructions now autocomplete every robot and its supported parameters.
22
-
-[x]Introduced structured error classes (`ApiError`, `InconsistentResponseError`, `PollingTimeoutError`) that preserve assembly IDs and server metadata.
20
+
-[x]**Breaking**`TransloaditError` removed in favor of a new, slightly different `ApiError`.
21
+
-[x] Added end-to-end TypeScript typings for robots, assemblies, templates, and responses, so assembly instructions now autocomplete every robot and its supported parameters. Notably, Assembly instructions and statuses are validates against rich TypeScript types; migrate to the new `AssemblyInstructionsInput` types and `AssemblyStatus` in responses.
22
+
-[x]New rich error stacktraces that aid in debugging issues.
23
23
-[x] Added opt-in `validateResponses` safeguard and a `getSignedSmartCDNUrl` helper for generating signed Smart CDN URLs.
24
+
-[x] Fix broken rate limiting #217
24
25
-[x] Modernized tooling, tests, and examples (Vitest, Biome, TypeScript examples). See [MIGRATION.md](./MIGRATION.md) for a guided upgrade path.
Copy file name to clipboardExpand all lines: MIGRATION.md
+53-36Lines changed: 53 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Version 4 focuses on type-safety, clearer errors, and modern Node support. Most
7
7
-[ ] Ensure your runtime is Node.js **20 or newer**.
8
8
-[ ] Switch from the v3 default export to the named `{ Transloadit }` ESM export.
9
9
-[ ] Adopt the new typed assembly instructions (`AssemblyInstructionsInput`) and update code that reads `listAssemblies()` results.
10
-
-[ ]Adjust error handling to account for the new `ApiError`, `InconsistentResponseError`, and `PollingTimeoutError` classes.
10
+
-[ ]Migrate from `TransloaditError` to `ApiError` signature.
11
11
-[ ] (Optional) Opt into `validateResponses` or use `getSignedSmartCDNUrl` if you need the new safeguards and helpers.
12
12
13
13
## Before you begin
@@ -17,13 +17,13 @@ Version 4 focuses on type-safety, clearer errors, and modern Node support. Most
17
17
- The SDK ships with `"type": "module"` and `.d.ts` typings. Pure CommonJS projects will need to either migrate to ESM or load the client via `import()` inside async code.
`AssemblyStatus` objects are now fully typed. Update any custom helpers to use the exported types instead of hand-rolled interfaces.
73
66
74
-
- `AssemblyStatus` objects are now fully typed. Update any custom helpers to use the exported types instead of hand-rolled interfaces.
75
-
- The pagination helpers (`PaginationStream`) are written in TypeScript and ship `.d.ts` files; imports work the same, but you can lean on the IDE for guidance now.
- `ApiError` wraps responses that contain an `error` payload even when the HTTP status code is 2xx. It carries `assemblyId`, `transloaditErrorCode`, and the raw `body`.
80
-
- `InconsistentResponseError` is thrown if the Transloadit API omits critical fields (for example, missing assembly URLs).
81
-
- `PollingTimeoutError` is thrown when waiting for an assembly to finish via `waitForCompletion` exceeds the timeout.
74
+
`TransloaditError` has been renamed to `ApiError`. Key differences between `TransloaditError` and `ApiError`:
75
+
76
+
- This error is also thrown when `body.error` is set, even if status from server is 2xx.
77
+
- `TransloaditError.response.body` can now be found in `ApiError.response`.
78
+
- `TransloaditError.assemblyId` can now be found in `ApiError.response.assembly_id`.
79
+
- `TransloaditError.transloaditErrorCode` can now be found in `ApiError.response.error`.
80
+
- `ApiError` does not inherit from `got.HTTPError`, but `ApiError.cause` will be the `got.HTTPError` instance that caused this error, except for when Tranloadit API responds with HTTP 200 and `error` prop set in JSON response (in which case `cause` will be `undefined`).
81
+
- Note that (just like before) when the Transloadit API responds with an error we will always throw an `ApiError` - In all other cases (like request timeout, connection error, TypeError etc.), we don't wrap the error in `ApiError`.
82
82
83
83
```ts
84
84
try {
85
-
awaittransloadit.createAssembly({ params })
85
+
awaittransloadit.createAssembly({ params });
86
86
} catch (error) {
87
-
if (error instanceof ApiError &&error.assemblyId) {
87
+
if (error instanceof ApiError &&error.response.assembly_id) {
88
88
console.error(
89
-
'Troubleshoot at https://transloadit.com/c/assemblies/'+error.assemblyId
90
-
)
89
+
"Troubleshoot at https://transloadit.com/c/assemblies/"+
90
+
error.response.assembly_id
91
+
);
91
92
}
92
-
throw error
93
+
throw error;
93
94
}
94
95
```
95
96
96
97
## 5. Optional enhancements
97
98
98
-
- `validateResponses` (client option) replays schema validation against responses you receive. Enable it when integrating with new workflows to surface unexpected fields early:
99
+
- `validateResponses` (client option) runs schema validation against responses you receive from Transloadit's servers. It will then throw additional `InconsistentResponseError` errors if responses are inconsistent with the schema. This will normally not happen, but enabling this will catch any bugs in Transloadit's API code where the response does not (yet) adhere with the schemas, instead of silently accepting the types as something else than what you expect (which is the case when the value is `false` - the default). We are of course working on making sure all our responses adhere to the schemas. In the future we want to make this option default to `true`.
99
100
100
101
```ts
101
102
consttransloadit=newTransloadit({
102
103
authKey,
103
104
authSecret,
104
105
validateResponses:true,
105
-
})
106
+
});
106
107
```
107
108
108
109
- `getSignedSmartCDNUrl` generates Smart CDN URLs with signatures that match the server-side implementation:
109
110
110
111
```ts
111
112
constsignedUrl=transloadit.getSignedSmartCDNUrl({
112
-
workspace:'my-team',
113
-
template:'hero-image',
114
-
input:'landing.jpg',
115
-
urlParams: { format:'webp' },
116
-
})
113
+
workspace:"my-team",
114
+
template:"hero-image",
115
+
input:"landing.jpg",
116
+
urlParams: { format:"webp" },
117
+
});
117
118
```
118
119
120
+
## 6. Removed `createAssembly` callback support
121
+
122
+
Use the returned promise instead.
123
+
124
+
## 7. Removed `isResumable` option
125
+
126
+
Only Tus uploads (which we call resumable uploads) are now supported using the SDK, and this option has therefore been removed.
127
+
128
+
## 8. `form-data` testing
129
+
130
+
`form-data` upgraded from 3 to 4 - this might cause some subtle differences in behavior related to file uploads. Be sure to test file uploads.
131
+
132
+
## 9. `got` upgraded
133
+
134
+
As a consequence of upgrading `got` to v14, the `gotRetry` option no longer accepts `number`. Instead use `{ limit:0 }`. See [`got``retry` object documentation](https://github.com/sindresorhus/got/blob/v14.4.9/documentation/7-retry.md).
135
+
119
136
## Testing & troubleshooting
120
137
121
138
- Run your existing integration tests on Node 20+. If you relied on CommonJS `require`, convert those modules or wrap calls in `import()` shims as shown above.
0 commit comments