diff --git a/example/typescript/src/mastodon/marker.ts b/example/typescript/src/mastodon/marker.ts new file mode 100644 index 0000000..bc56695 --- /dev/null +++ b/example/typescript/src/mastodon/marker.ts @@ -0,0 +1,23 @@ +import generator, { Entity, Response } from 'megalodon' + +declare var process: { + env: { + MASTODON_ACCESS_TOKEN: string + } +} + +const BASE_URL: string = 'https://fedibird.com' + +const access_token: string = process.env.MASTODON_ACCESS_TOKEN + +const client = generator('mastodon', BASE_URL, access_token) + +client.getMarkers(['home', 'notifications']).then((res: Response) => { + console.log(res.data) +}) + +client + .saveMarkers({ home: { last_read_id: '106347765980135935' }, notifications: { last_read_id: '105917259070666683' } }) + .then((res: Response) => { + console.log(res.data) + }) diff --git a/package.json b/package.json index 734f680..2095a01 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ }, "devDependencies": { "@types/core-js": "^2.5.0", + "@types/form-data": "^2.5.0", "@types/jest": "^26.0.20", "@types/object-assign-deep": "^0.4.0", "@types/uuid": "^8.0.0", diff --git a/src/mastodon.ts b/src/mastodon.ts index 39e63e8..97f5070 100644 --- a/src/mastodon.ts +++ b/src/mastodon.ts @@ -1784,13 +1784,13 @@ export default class Mastodon implements MegalodonInterface { // ====================================== // timelines/markers // ====================================== - public async getMarker(timeline: Array<'home' | 'notifications'>): Promise> { + public async getMarkers(timeline: Array): Promise> { return this.client.get('/api/v1/markers', { timeline: timeline }) } - public async saveMarker(options?: { + public async saveMarkers(options?: { home?: { last_read_id: string } notifications?: { last_read_id: string } }): Promise> { diff --git a/src/megalodon.ts b/src/megalodon.ts index 8a88faa..7c79910 100644 --- a/src/megalodon.ts +++ b/src/megalodon.ts @@ -1024,7 +1024,7 @@ export interface MegalodonInterface { * @param timelines Array of timeline names, String enum anyOf home, notifications. * @return Marker or empty object. */ - getMarker(timeline: Array<'home' | 'notifications'>): Promise> + getMarkers(timeline: Array): Promise> /** * POST /api/v1/markers * @@ -1032,7 +1032,7 @@ export interface MegalodonInterface { * @param options.notifications Marker position of the last read notification ID in notifications. * @return Marker. */ - saveMarker(options?: { home?: { last_read_id: string }; notifications?: { last_read_id: string } }): Promise> + saveMarkers(options?: { home?: { last_read_id: string }; notifications?: { last_read_id: string } }): Promise> // ====================================== // notifications // ====================================== diff --git a/src/misskey.ts b/src/misskey.ts index 83b5621..a9c1941 100644 --- a/src/misskey.ts +++ b/src/misskey.ts @@ -1713,14 +1713,14 @@ export default class Misskey implements MegalodonInterface { // ====================================== // timelines/markers // ====================================== - public async getMarker(_timeline: Array<'home' | 'notifications'>): Promise> { + public async getMarkers(_timeline: Array): Promise> { return new Promise((_, reject) => { const err = new NoImplementedError('misskey does not support') reject(err) }) } - public async saveMarker(_options?: { + public async saveMarkers(_options?: { home?: { last_read_id: string } notifications?: { last_read_id: string } }): Promise> { diff --git a/src/pleroma.ts b/src/pleroma.ts index 274eff4..947cf21 100644 --- a/src/pleroma.ts +++ b/src/pleroma.ts @@ -1791,13 +1791,13 @@ export default class Pleroma implements MegalodonInterface { // ====================================== // timelines/markers // ====================================== - public async getMarker(timeline: Array<'home' | 'notifications'>): Promise> { + public async getMarkers(timeline: Array): Promise> { return this.client.get('/api/v1/markers', { timeline: timeline }) } - public async saveMarker(options?: { + public async saveMarkers(options?: { home?: { last_read_id: string } notifications?: { last_read_id: string } }): Promise> { diff --git a/yarn.lock b/yarn.lock index 2d40a23..91fe5b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -642,6 +642,13 @@ resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== +"@types/form-data@^2.5.0": + version "2.5.0" + resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.5.0.tgz#5025f7433016f923348434c40006d9a797c1b0e8" + integrity sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg== + dependencies: + form-data "*" + "@types/graceful-fs@^4.1.2": version "4.1.3" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.3.tgz#039af35fe26bec35003e8d86d2ee9c586354348f" @@ -2031,7 +2038,7 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= -form-data@^4.0.0: +form-data@*, form-data@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==