v5.0.0
5.0.0 (2022-12-23)
Migration Guide
-
We have changed the HTTP library to
fetch
API (node-fetch
) fromaxios
. You may have to update your code if you're using some features that are specific to Axios. -
All methods now have an explicit version. Add
v1
orv2
─ the prefix depends on the endpoint─ before the name of a method. #722
// v4
masto.statuses.create({ status: "Hello" });
// v5
masto.v1.statuses.create({ status: "Hello" });
- All response types are now exported under a namespace
mastodon
and also have explicit version numbers. #722
// v4
import { Status } from "masto";
// v5
import { mastodon } from "masto";
mastodon.v1.Status;
fetchAll
,fetchMany
, anditerate
are now integrated into a methodlist
which you can bothawait
andfor-await-of
. #763
const favourites = await masto.v1.favourites.list();
for await (const statuses of masto.v1.favourites.list()) {
// ...
}
- If you're using Node.js 18, You'll need to use
Blob
interface for uploading a media attachment. Uploading an image with a Stream API is no longer supported since we moved to the web standard Fetch API.
// v4
masto.v2.mediaAttachments.create({ file: fs.createReadStream("./some_file.png") });
// v5
masto.v2.mediaAttachments.create({ file: new Blob([fs.readFileSync("./some_file.png")]) });
Bug Fixes
- Fix
instanceof
operator for error classes (7893b4d) - Fix broken test for paginator (584d1dc)
- Fix http-native-impl to use getContentType (875c371)
- Fix setupFilesAfterEnv to include isomorphic-fetch (2fd41e3)
- Fix tests (58ba2c7)
- Fix tsc errors in domain blocks (4f8700e)
- Fix v2 search path (b3d95f8)
- Remove "DOM" from TypeScript lib dependency (61a9467)
- Remove Array constraint from IRepository (ced6608)
- Remove MimeType and change it to string (129a17a)
- Rename methods that returns an array to start with
list
(68e8ff9) - Repository#delete -> Repository#remove (b4e06a5)
- Update resource name to comply with the current Mastodon document (6a20ad9)
- Use version check as error handling (d24ab9a)
Features
- Add explicit API versions to methods (d4dd3fa)
- Add logging interface (bedc623)
- Drop Axios support (903c09d)
- Move entities and repositories under the namespace (5da5773)
- Remove deprecated class aliases (17582c1)
- Remove next() argument (5370e0c)
BREAKING CHANGES
- Outdated resource names are updated with the current Mastodon document. Including
WebPushSubscription
,CustomEmoji
,AccountField
, etc - You have to import
mastodon
to use any entity instead of importing single entity directly - Paginator#next no longer accepts an argument. Please recreate Paginator if you want to reset the internal state
- fetchAll, fetchMany and other methods that returns an array is now prefixed with list*
- Alias for iteration methods and error classes are now removed
- All API calls now require masto.v1 or masto.v2 as a prefix.
- headers option for login() now should be a WHATWG object. Proxy support is also dropped.