diff --git a/.gitignore b/.gitignore index 3a667851c7..b65b06a8f5 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,8 @@ packages/backend/assets/sounds/None.mp3 !packages/backend/src/db +/packages/megalodon/lib + # blender backups *.blend1 *.blend2 diff --git a/packages/megalodon/lib/src/cancel.d.ts b/packages/megalodon/lib/src/cancel.d.ts deleted file mode 100644 index 63cb98db12..0000000000 --- a/packages/megalodon/lib/src/cancel.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare class RequestCanceledError extends Error { - isCancel: boolean; - constructor(msg: string); -} -export declare const isCancel: (value: any) => boolean; diff --git a/packages/megalodon/lib/src/cancel.js b/packages/megalodon/lib/src/cancel.js deleted file mode 100644 index 98620146fb..0000000000 --- a/packages/megalodon/lib/src/cancel.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.isCancel = exports.RequestCanceledError = void 0; -var RequestCanceledError = (function (_super) { - __extends(RequestCanceledError, _super); - function RequestCanceledError(msg) { - var _this = _super.call(this, msg) || this; - _this.isCancel = true; - Object.setPrototypeOf(_this, RequestCanceledError); - return _this; - } - return RequestCanceledError; -}(Error)); -exports.RequestCanceledError = RequestCanceledError; -var isCancel = function (value) { - return value && value.isCancel; -}; -exports.isCancel = isCancel; diff --git a/packages/megalodon/lib/src/converter.d.ts b/packages/megalodon/lib/src/converter.d.ts deleted file mode 100644 index a708890bf0..0000000000 --- a/packages/megalodon/lib/src/converter.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import MisskeyAPI from "./misskey/api_client"; -declare const _default: typeof MisskeyAPI.Converter; -export default _default; diff --git a/packages/megalodon/lib/src/converter.js b/packages/megalodon/lib/src/converter.js deleted file mode 100644 index 3ee9984548..0000000000 --- a/packages/megalodon/lib/src/converter.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var api_client_1 = __importDefault(require("./misskey/api_client")); -exports.default = api_client_1.default.Converter; diff --git a/packages/megalodon/lib/src/default.d.ts b/packages/megalodon/lib/src/default.d.ts deleted file mode 100644 index 65c6afa45c..0000000000 --- a/packages/megalodon/lib/src/default.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const NO_REDIRECT = "urn:ietf:wg:oauth:2.0:oob"; -export declare const DEFAULT_SCOPE: string[]; -export declare const DEFAULT_UA = "megalodon"; diff --git a/packages/megalodon/lib/src/default.js b/packages/megalodon/lib/src/default.js deleted file mode 100644 index 926730ab44..0000000000 --- a/packages/megalodon/lib/src/default.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DEFAULT_UA = exports.DEFAULT_SCOPE = exports.NO_REDIRECT = void 0; -exports.NO_REDIRECT = 'urn:ietf:wg:oauth:2.0:oob'; -exports.DEFAULT_SCOPE = ['read', 'write', 'follow']; -exports.DEFAULT_UA = 'megalodon'; diff --git a/packages/megalodon/lib/src/entities/account.d.ts b/packages/megalodon/lib/src/entities/account.d.ts deleted file mode 100644 index 66a4d87d21..0000000000 --- a/packages/megalodon/lib/src/entities/account.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// -/// -/// -declare namespace Entity { - type Account = { - id: string; - username: string; - acct: string; - display_name: string; - locked: boolean; - created_at: string; - followers_count: number; - following_count: number; - statuses_count: number; - note: string; - url: string; - avatar: string; - avatar_static: string; - header: string; - header_static: string; - emojis: Array; - moved: Account | null; - fields: Array; - bot: boolean | null; - source?: Source; - }; -} diff --git a/packages/megalodon/lib/src/entities/account.js b/packages/megalodon/lib/src/entities/account.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/account.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/activity.d.ts b/packages/megalodon/lib/src/entities/activity.d.ts deleted file mode 100644 index ccfa72e8c9..0000000000 --- a/packages/megalodon/lib/src/entities/activity.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace Entity { - type Activity = { - week: string; - statuses: string; - logins: string; - registrations: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/activity.js b/packages/megalodon/lib/src/entities/activity.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/activity.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/announcement.d.ts b/packages/megalodon/lib/src/entities/announcement.d.ts deleted file mode 100644 index 8438dd9aa5..0000000000 --- a/packages/megalodon/lib/src/entities/announcement.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// -/// -/// -declare namespace Entity { - type Announcement = { - id: string; - content: string; - starts_at: string | null; - ends_at: string | null; - published: boolean; - all_day: boolean; - published_at: string; - updated_at: string; - read?: boolean; - mentions: Array; - statuses: Array; - tags: Array; - emojis: Array; - reactions: Array; - }; - type AnnouncementAccount = { - id: string; - username: string; - url: string; - acct: string; - }; - type AnnouncementStatus = { - id: string; - url: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/announcement.js b/packages/megalodon/lib/src/entities/announcement.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/announcement.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/application.d.ts b/packages/megalodon/lib/src/entities/application.d.ts deleted file mode 100644 index 910f867376..0000000000 --- a/packages/megalodon/lib/src/entities/application.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace Entity { - type Application = { - name: string; - website?: string | null; - vapid_key?: string | null; - }; -} diff --git a/packages/megalodon/lib/src/entities/application.js b/packages/megalodon/lib/src/entities/application.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/application.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/async_attachment.d.ts b/packages/megalodon/lib/src/entities/async_attachment.d.ts deleted file mode 100644 index 911083f964..0000000000 --- a/packages/megalodon/lib/src/entities/async_attachment.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// -declare namespace Entity { - type AsyncAttachment = { - id: string; - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - url: string | null; - remote_url: string | null; - preview_url: string; - text_url: string | null; - meta: Meta | null; - description: string | null; - blurhash: string | null; - }; -} diff --git a/packages/megalodon/lib/src/entities/async_attachment.js b/packages/megalodon/lib/src/entities/async_attachment.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/async_attachment.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/attachment.d.ts b/packages/megalodon/lib/src/entities/attachment.d.ts deleted file mode 100644 index bbb94f3cd9..0000000000 --- a/packages/megalodon/lib/src/entities/attachment.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -declare namespace Entity { - type Sub = { - width?: number; - height?: number; - size?: string; - aspect?: number; - frame_rate?: string; - duration?: number; - bitrate?: number; - }; - type Focus = { - x: number; - y: number; - }; - type Meta = { - original?: Sub; - small?: Sub; - focus?: Focus; - length?: string; - duration?: number; - fps?: number; - size?: string; - width?: number; - height?: number; - aspect?: number; - audio_encode?: string; - audio_bitrate?: string; - audio_channel?: string; - }; - type Attachment = { - id: string; - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - url: string; - remote_url: string | null; - preview_url: string | null; - text_url: string | null; - meta: Meta | null; - description: string | null; - blurhash: string | null; - }; -} diff --git a/packages/megalodon/lib/src/entities/attachment.js b/packages/megalodon/lib/src/entities/attachment.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/attachment.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/card.d.ts b/packages/megalodon/lib/src/entities/card.d.ts deleted file mode 100644 index 6e319e7baa..0000000000 --- a/packages/megalodon/lib/src/entities/card.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -declare namespace Entity { - type Card = { - url: string; - title: string; - description: string; - type: 'link' | 'photo' | 'video' | 'rich'; - image?: string; - author_name?: string; - author_url?: string; - provider_name?: string; - provider_url?: string; - html?: string; - width?: number; - height?: number; - }; -} diff --git a/packages/megalodon/lib/src/entities/card.js b/packages/megalodon/lib/src/entities/card.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/card.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/context.d.ts b/packages/megalodon/lib/src/entities/context.d.ts deleted file mode 100644 index 4c3397654f..0000000000 --- a/packages/megalodon/lib/src/entities/context.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -declare namespace Entity { - type Context = { - ancestors: Array; - descendants: Array; - }; -} diff --git a/packages/megalodon/lib/src/entities/context.js b/packages/megalodon/lib/src/entities/context.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/context.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/conversation.d.ts b/packages/megalodon/lib/src/entities/conversation.d.ts deleted file mode 100644 index dd5a1b1439..0000000000 --- a/packages/megalodon/lib/src/entities/conversation.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -declare namespace Entity { - type Conversation = { - id: string; - accounts: Array; - last_status: Status | null; - unread: boolean; - }; -} diff --git a/packages/megalodon/lib/src/entities/conversation.js b/packages/megalodon/lib/src/entities/conversation.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/conversation.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/emoji.d.ts b/packages/megalodon/lib/src/entities/emoji.d.ts deleted file mode 100644 index ca3c195065..0000000000 --- a/packages/megalodon/lib/src/entities/emoji.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace Entity { - type Emoji = { - shortcode: string; - static_url: string; - url: string; - visible_in_picker: boolean; - category: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/emoji.js b/packages/megalodon/lib/src/entities/emoji.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/emoji.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/featured_tag.d.ts b/packages/megalodon/lib/src/entities/featured_tag.d.ts deleted file mode 100644 index 5a8b36ff63..0000000000 --- a/packages/megalodon/lib/src/entities/featured_tag.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace Entity { - type FeaturedTag = { - id: string; - name: string; - statuses_count: number; - last_status_at: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/featured_tag.js b/packages/megalodon/lib/src/entities/featured_tag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/featured_tag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/field.d.ts b/packages/megalodon/lib/src/entities/field.d.ts deleted file mode 100644 index efa9f0aec8..0000000000 --- a/packages/megalodon/lib/src/entities/field.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace Entity { - type Field = { - name: string; - value: string; - verified_at: string | null; - }; -} diff --git a/packages/megalodon/lib/src/entities/field.js b/packages/megalodon/lib/src/entities/field.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/field.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/filter.d.ts b/packages/megalodon/lib/src/entities/filter.d.ts deleted file mode 100644 index 48d0477cb1..0000000000 --- a/packages/megalodon/lib/src/entities/filter.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace Entity { - type Filter = { - id: string; - phrase: string; - context: Array; - expires_at: string | null; - irreversible: boolean; - whole_word: boolean; - }; - type FilterContext = string; -} diff --git a/packages/megalodon/lib/src/entities/filter.js b/packages/megalodon/lib/src/entities/filter.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/filter.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/history.d.ts b/packages/megalodon/lib/src/entities/history.d.ts deleted file mode 100644 index 6b238a1d96..0000000000 --- a/packages/megalodon/lib/src/entities/history.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace Entity { - type History = { - day: string; - uses: number; - accounts: number; - }; -} diff --git a/packages/megalodon/lib/src/entities/history.js b/packages/megalodon/lib/src/entities/history.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/history.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/identity_proof.d.ts b/packages/megalodon/lib/src/entities/identity_proof.d.ts deleted file mode 100644 index 7d4a4fbf00..0000000000 --- a/packages/megalodon/lib/src/entities/identity_proof.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace Entity { - type IdentityProof = { - provider: string; - provider_username: string; - updated_at: string; - proof_url: string; - profile_url: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/identity_proof.js b/packages/megalodon/lib/src/entities/identity_proof.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/identity_proof.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/instance.d.ts b/packages/megalodon/lib/src/entities/instance.d.ts deleted file mode 100644 index a869f7e6da..0000000000 --- a/packages/megalodon/lib/src/entities/instance.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// -/// -/// -declare namespace Entity { - type Instance = { - uri: string; - title: string; - description: string; - email: string; - version: string; - thumbnail: string | null; - urls: URLs; - stats: Stats; - languages: Array; - contact_account: Account | null; - max_toot_chars?: number; - registrations?: boolean; - configuration?: { - statuses: { - max_characters: number; - max_media_attachments: number; - characters_reserved_per_url: number; - }; - media_attachments: { - supported_mime_types: Array; - image_size_limit: number; - image_matrix_limit: number; - video_size_limit: number; - video_frame_limit: number; - video_matrix_limit: number; - }; - polls: { - max_options: number; - max_characters_per_option: number; - min_expiration: number; - max_expiration: number; - }; - }; - }; -} diff --git a/packages/megalodon/lib/src/entities/instance.js b/packages/megalodon/lib/src/entities/instance.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/instance.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/list.d.ts b/packages/megalodon/lib/src/entities/list.d.ts deleted file mode 100644 index ab7c6416d8..0000000000 --- a/packages/megalodon/lib/src/entities/list.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace Entity { - type List = { - id: string; - title: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/list.js b/packages/megalodon/lib/src/entities/list.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/list.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/marker.d.ts b/packages/megalodon/lib/src/entities/marker.d.ts deleted file mode 100644 index d23e1b5ef7..0000000000 --- a/packages/megalodon/lib/src/entities/marker.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare namespace Entity { - type Marker = { - home?: { - last_read_id: string; - version: number; - updated_at: string; - }; - notifications?: { - last_read_id: string; - version: number; - updated_at: string; - unread_count?: number; - }; - }; -} diff --git a/packages/megalodon/lib/src/entities/marker.js b/packages/megalodon/lib/src/entities/marker.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/marker.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/mention.d.ts b/packages/megalodon/lib/src/entities/mention.d.ts deleted file mode 100644 index 986105454a..0000000000 --- a/packages/megalodon/lib/src/entities/mention.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace Entity { - type Mention = { - id: string; - username: string; - url: string; - acct: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/mention.js b/packages/megalodon/lib/src/entities/mention.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/mention.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/notification.d.ts b/packages/megalodon/lib/src/entities/notification.d.ts deleted file mode 100644 index 2aed757892..0000000000 --- a/packages/megalodon/lib/src/entities/notification.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -/// -declare namespace Entity { - type Notification = { - account: Account; - created_at: string; - id: string; - status?: Status; - emoji?: string; - type: NotificationType; - }; - type NotificationType = string; -} diff --git a/packages/megalodon/lib/src/entities/notification.js b/packages/megalodon/lib/src/entities/notification.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/notification.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/poll.d.ts b/packages/megalodon/lib/src/entities/poll.d.ts deleted file mode 100644 index bd5fb5c48c..0000000000 --- a/packages/megalodon/lib/src/entities/poll.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// -declare namespace Entity { - type Poll = { - id: string; - expires_at: string | null; - expired: boolean; - multiple: boolean; - votes_count: number; - options: Array; - voted: boolean; - }; -} diff --git a/packages/megalodon/lib/src/entities/poll.js b/packages/megalodon/lib/src/entities/poll.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/poll.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/poll_option.d.ts b/packages/megalodon/lib/src/entities/poll_option.d.ts deleted file mode 100644 index 968aff9a42..0000000000 --- a/packages/megalodon/lib/src/entities/poll_option.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace Entity { - type PollOption = { - title: string; - votes_count: number | null; - }; -} diff --git a/packages/megalodon/lib/src/entities/poll_option.js b/packages/megalodon/lib/src/entities/poll_option.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/poll_option.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/preferences.d.ts b/packages/megalodon/lib/src/entities/preferences.d.ts deleted file mode 100644 index 79e62955df..0000000000 --- a/packages/megalodon/lib/src/entities/preferences.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace Entity { - type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct'; - 'posting:default:sensitive': boolean; - 'posting:default:language': string | null; - 'reading:expand:media': 'default' | 'show_all' | 'hide_all'; - 'reading:expand:spoilers': boolean; - }; -} diff --git a/packages/megalodon/lib/src/entities/preferences.js b/packages/megalodon/lib/src/entities/preferences.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/preferences.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/push_subscription.d.ts b/packages/megalodon/lib/src/entities/push_subscription.d.ts deleted file mode 100644 index 92fa7a39f1..0000000000 --- a/packages/megalodon/lib/src/entities/push_subscription.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare namespace Entity { - type Alerts = { - follow: boolean; - favourite: boolean; - mention: boolean; - reblog: boolean; - poll: boolean; - }; - type PushSubscription = { - id: string; - endpoint: string; - server_key: string; - alerts: Alerts; - }; -} diff --git a/packages/megalodon/lib/src/entities/push_subscription.js b/packages/megalodon/lib/src/entities/push_subscription.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/push_subscription.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/reaction.d.ts b/packages/megalodon/lib/src/entities/reaction.d.ts deleted file mode 100644 index eb4cfb7802..0000000000 --- a/packages/megalodon/lib/src/entities/reaction.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace Entity { - type Reaction = { - count: number; - me: boolean; - name: string; - url?: string; - accounts?: Array; - }; -} diff --git a/packages/megalodon/lib/src/entities/reaction.js b/packages/megalodon/lib/src/entities/reaction.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/reaction.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/relationship.d.ts b/packages/megalodon/lib/src/entities/relationship.d.ts deleted file mode 100644 index 56c5201313..0000000000 --- a/packages/megalodon/lib/src/entities/relationship.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare namespace Entity { - type Relationship = { - id: string; - following: boolean; - followed_by: boolean; - delivery_following?: boolean; - blocking: boolean; - blocked_by: boolean; - muting: boolean; - muting_notifications: boolean; - requested: boolean; - domain_blocking: boolean; - showing_reblogs: boolean; - endorsed: boolean; - notifying: boolean; - }; -} diff --git a/packages/megalodon/lib/src/entities/relationship.js b/packages/megalodon/lib/src/entities/relationship.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/relationship.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/report.d.ts b/packages/megalodon/lib/src/entities/report.d.ts deleted file mode 100644 index 6d42cbf46b..0000000000 --- a/packages/megalodon/lib/src/entities/report.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace Entity { - type Report = { - id: string; - action_taken: string; - comment: string; - account_id: string; - status_ids: Array; - }; -} diff --git a/packages/megalodon/lib/src/entities/report.js b/packages/megalodon/lib/src/entities/report.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/report.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/results.d.ts b/packages/megalodon/lib/src/entities/results.d.ts deleted file mode 100644 index 639b2fc134..0000000000 --- a/packages/megalodon/lib/src/entities/results.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -/// -declare namespace Entity { - type Results = { - accounts: Array; - statuses: Array; - hashtags: Array; - }; -} diff --git a/packages/megalodon/lib/src/entities/results.js b/packages/megalodon/lib/src/entities/results.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/results.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/scheduled_status.d.ts b/packages/megalodon/lib/src/entities/scheduled_status.d.ts deleted file mode 100644 index b6842dad39..0000000000 --- a/packages/megalodon/lib/src/entities/scheduled_status.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -declare namespace Entity { - type ScheduledStatus = { - id: string; - scheduled_at: string; - params: StatusParams; - media_attachments: Array; - }; -} diff --git a/packages/megalodon/lib/src/entities/scheduled_status.js b/packages/megalodon/lib/src/entities/scheduled_status.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/scheduled_status.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/source.d.ts b/packages/megalodon/lib/src/entities/source.d.ts deleted file mode 100644 index 13a0cf9b6c..0000000000 --- a/packages/megalodon/lib/src/entities/source.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace Entity { - type Source = { - privacy: string | null; - sensitive: boolean | null; - language: string | null; - note: string; - fields: Array; - }; -} diff --git a/packages/megalodon/lib/src/entities/source.js b/packages/megalodon/lib/src/entities/source.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/source.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/stats.d.ts b/packages/megalodon/lib/src/entities/stats.d.ts deleted file mode 100644 index d23ae51cb7..0000000000 --- a/packages/megalodon/lib/src/entities/stats.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace Entity { - type Stats = { - user_count: number; - status_count: number; - domain_count: number; - }; -} diff --git a/packages/megalodon/lib/src/entities/stats.js b/packages/megalodon/lib/src/entities/stats.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/stats.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/status.d.ts b/packages/megalodon/lib/src/entities/status.d.ts deleted file mode 100644 index 5fdab67e0b..0000000000 --- a/packages/megalodon/lib/src/entities/status.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -declare namespace Entity { - type Status = { - id: string; - uri: string; - url: string; - account: Account; - in_reply_to_id: string | null; - in_reply_to_account_id: string | null; - reblog: Status | null; - content: string; - plain_content: string | null; - created_at: string; - emojis: Emoji[]; - replies_count: number; - reblogs_count: number; - favourites_count: number; - reblogged: boolean | null; - favourited: boolean | null; - muted: boolean | null; - sensitive: boolean; - spoiler_text: string; - visibility: 'public' | 'unlisted' | 'private' | 'direct'; - media_attachments: Array; - mentions: Array; - tags: Array; - card: Card | null; - poll: Poll | null; - application: Application | null; - language: string | null; - pinned: boolean | null; - emoji_reactions: Array; - quote: Status | null; - bookmarked: boolean; - }; -} diff --git a/packages/megalodon/lib/src/entities/status.js b/packages/megalodon/lib/src/entities/status.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/status.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/status_edit.d.ts b/packages/megalodon/lib/src/entities/status_edit.d.ts deleted file mode 100644 index 638d33b899..0000000000 --- a/packages/megalodon/lib/src/entities/status_edit.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -declare namespace Entity { - type StatusEdit = { - account: Account; - content: string; - plain_content: string | null; - created_at: string; - emojis: Emoji[]; - sensitive: boolean; - spoiler_text: string; - media_attachments: Array; - poll: Poll | null; - }; -} diff --git a/packages/megalodon/lib/src/entities/status_edit.js b/packages/megalodon/lib/src/entities/status_edit.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/status_edit.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/status_params.d.ts b/packages/megalodon/lib/src/entities/status_params.d.ts deleted file mode 100644 index 872be786b3..0000000000 --- a/packages/megalodon/lib/src/entities/status_params.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace Entity { - type StatusParams = { - text: string; - in_reply_to_id: string | null; - media_ids: Array | null; - sensitive: boolean | null; - spoiler_text: string | null; - visibility: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at: string | null; - application_id: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/status_params.js b/packages/megalodon/lib/src/entities/status_params.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/status_params.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/tag.d.ts b/packages/megalodon/lib/src/entities/tag.d.ts deleted file mode 100644 index 29130004e3..0000000000 --- a/packages/megalodon/lib/src/entities/tag.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace Entity { - type Tag = { - name: string; - url: string; - history: Array | null; - following?: boolean; - }; -} diff --git a/packages/megalodon/lib/src/entities/tag.js b/packages/megalodon/lib/src/entities/tag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/tag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/token.d.ts b/packages/megalodon/lib/src/entities/token.d.ts deleted file mode 100644 index feae2d08c8..0000000000 --- a/packages/megalodon/lib/src/entities/token.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace Entity { - type Token = { - access_token: string; - token_type: string; - scope: string; - created_at: number; - }; -} diff --git a/packages/megalodon/lib/src/entities/token.js b/packages/megalodon/lib/src/entities/token.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/token.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entities/urls.d.ts b/packages/megalodon/lib/src/entities/urls.d.ts deleted file mode 100644 index 3a60528519..0000000000 --- a/packages/megalodon/lib/src/entities/urls.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace Entity { - type URLs = { - streaming_api: string; - }; -} diff --git a/packages/megalodon/lib/src/entities/urls.js b/packages/megalodon/lib/src/entities/urls.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/entities/urls.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/entity.d.ts b/packages/megalodon/lib/src/entity.d.ts deleted file mode 100644 index 6d6d3261f4..0000000000 --- a/packages/megalodon/lib/src/entity.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -export default Entity; diff --git a/packages/megalodon/lib/src/entity.js b/packages/megalodon/lib/src/entity.js deleted file mode 100644 index c8ad2e549b..0000000000 --- a/packages/megalodon/lib/src/entity.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/megalodon/lib/src/filter_context.d.ts b/packages/megalodon/lib/src/filter_context.d.ts deleted file mode 100644 index f996a32278..0000000000 --- a/packages/megalodon/lib/src/filter_context.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import Entity from './entity'; -declare namespace FilterContext { - const Home: Entity.FilterContext; - const Notifications: Entity.FilterContext; - const Public: Entity.FilterContext; - const Thread: Entity.FilterContext; - const Account: Entity.FilterContext; -} -export default FilterContext; diff --git a/packages/megalodon/lib/src/filter_context.js b/packages/megalodon/lib/src/filter_context.js deleted file mode 100644 index 743568f6e1..0000000000 --- a/packages/megalodon/lib/src/filter_context.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var FilterContext; -(function (FilterContext) { - FilterContext.Home = 'home'; - FilterContext.Notifications = 'notifications'; - FilterContext.Public = 'public'; - FilterContext.Thread = 'thread'; - FilterContext.Account = 'account'; -})(FilterContext || (FilterContext = {})); -exports.default = FilterContext; diff --git a/packages/megalodon/lib/src/index.d.ts b/packages/megalodon/lib/src/index.d.ts deleted file mode 100644 index 5a7d8776e8..0000000000 --- a/packages/megalodon/lib/src/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Response from './response'; -import OAuth from './oauth'; -import { isCancel, RequestCanceledError } from './cancel'; -import { ProxyConfig } from './proxy_config'; -import generator, { detector, MegalodonInterface, WebSocketInterface } from './megalodon'; -import Misskey from './misskey'; -import Entity from './entity'; -import NotificationType from './notification'; -import FilterContext from './filter_context'; -import Converter from './converter'; -export { Response, OAuth, RequestCanceledError, isCancel, ProxyConfig, detector, MegalodonInterface, WebSocketInterface, NotificationType, FilterContext, Misskey, Entity, Converter }; -export default generator; diff --git a/packages/megalodon/lib/src/index.js b/packages/megalodon/lib/src/index.js deleted file mode 100644 index 6c0f108ce8..0000000000 --- a/packages/megalodon/lib/src/index.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Converter = exports.Misskey = exports.FilterContext = exports.NotificationType = exports.detector = exports.isCancel = exports.RequestCanceledError = exports.OAuth = void 0; -var oauth_1 = __importDefault(require("./oauth")); -exports.OAuth = oauth_1.default; -var cancel_1 = require("./cancel"); -Object.defineProperty(exports, "isCancel", { enumerable: true, get: function () { return cancel_1.isCancel; } }); -Object.defineProperty(exports, "RequestCanceledError", { enumerable: true, get: function () { return cancel_1.RequestCanceledError; } }); -var megalodon_1 = __importStar(require("./megalodon")); -Object.defineProperty(exports, "detector", { enumerable: true, get: function () { return megalodon_1.detector; } }); -var misskey_1 = __importDefault(require("./misskey")); -exports.Misskey = misskey_1.default; -var notification_1 = __importDefault(require("./notification")); -exports.NotificationType = notification_1.default; -var filter_context_1 = __importDefault(require("./filter_context")); -exports.FilterContext = filter_context_1.default; -var converter_1 = __importDefault(require("./converter")); -exports.Converter = converter_1.default; -exports.default = megalodon_1.default; diff --git a/packages/megalodon/lib/src/mastodon.d.ts b/packages/megalodon/lib/src/mastodon.d.ts deleted file mode 100644 index 9191f0add1..0000000000 --- a/packages/megalodon/lib/src/mastodon.d.ts +++ /dev/null @@ -1,374 +0,0 @@ -import MastodonAPI from './mastodon/api_client'; -import WebSocket from './mastodon/web_socket'; -import { MegalodonInterface } from './megalodon'; -import Response from './response'; -import Entity from './entity'; -import { ProxyConfig } from './proxy_config'; -import OAuth from './oauth'; -export default class Mastodon implements MegalodonInterface { - client: MastodonAPI.Interface; - baseUrl: string; - constructor(baseUrl: string, accessToken?: string | null, userAgent?: string | null, proxyConfig?: ProxyConfig | false); - cancel(): void; - registerApp(client_name: string, options: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - createApp(client_name: string, options: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - generateAuthUrl(clientId: string, clientSecret: string, options: Partial<{ - scope: Array; - redirect_uri: string; - }>): Promise; - verifyAppCredentials(): Promise>; - fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string): Promise; - refreshToken(client_id: string, client_secret: string, refresh_token: string): Promise; - revokeToken(client_id: string, client_secret: string, token: string): Promise>; - registerAccount(username: string, email: string, password: string, agreement: boolean, locale: string, reason?: string | null): Promise>; - verifyAccountCredentials(): Promise>; - updateCredentials(options?: { - discoverable?: boolean; - bot?: boolean; - display_name?: string; - note?: string; - avatar?: string; - header?: string; - locked?: boolean; - source?: { - privacy?: string; - sensitive?: boolean; - language?: string; - }; - fields_attributes?: Array<{ - name: string; - value: string; - }>; - }): Promise>; - getAccount(id: string): Promise>; - getAccountStatuses(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - pinned?: boolean; - exclude_replies?: boolean; - exclude_reblogs?: boolean; - only_media: boolean; - }): Promise>>; - subscribeAccount(id: string): Promise>; - unsubscribeAccount(id: string): Promise>; - getAccountFavourites(_id: string, _options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getAccountFollowers(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - get_all?: boolean; - sleep_ms?: number; - }): Promise>>; - getAccountFollowing(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - get_all?: boolean; - sleep_ms?: number; - }): Promise>>; - private urlToAccounts; - getAccountLists(id: string): Promise>>; - getIdentityProof(id: string): Promise>>; - followAccount(id: string, options?: { - reblog?: boolean; - }): Promise>; - unfollowAccount(id: string): Promise>; - blockAccount(id: string): Promise>; - unblockAccount(id: string): Promise>; - muteAccount(id: string, notifications?: boolean): Promise>; - unmuteAccount(id: string): Promise>; - pinAccount(id: string): Promise>; - unpinAccount(id: string): Promise>; - getRelationship(id: string): Promise>; - getRelationships(ids: Array): Promise>>; - searchAccount(q: string, options?: { - following?: boolean; - resolve?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getBookmarks(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getFavourites(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getMutes(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getDomainBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - blockDomain(domain: string): Promise>; - unblockDomain(domain: string): Promise>; - getFilters(): Promise>>; - getFilter(id: string): Promise>; - createFilter(phrase: string, context: Array, options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - updateFilter(id: string, phrase: string, context: Array, options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - deleteFilter(id: string): Promise>; - report(account_id: string, comment: string, options?: { - status_ids?: Array; - forward?: boolean; - }): Promise>; - getFollowRequests(limit?: number): Promise>>; - acceptFollowRequest(id: string): Promise>; - rejectFollowRequest(id: string): Promise>; - getEndorsements(options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getFeaturedTags(): Promise>>; - getAccountFeaturedTags(id: string): Promise>>; - createFeaturedTag(name: string): Promise>; - deleteFeaturedTag(id: string): Promise>; - getSuggestedTags(): Promise>>; - getPreferences(): Promise>; - getSuggestions(limit?: number): Promise>>; - getTag(id: string): Promise>; - followTag(id: string): Promise>; - unfollowTag(id: string): Promise>; - postStatus(status: string, options: { - media_ids?: Array; - poll?: { - options: Array; - expires_in: number; - multiple?: boolean; - hide_totals?: boolean; - }; - in_reply_to_id?: string; - sensitive?: boolean; - spoiler_text?: string; - visibility?: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at?: string; - language?: string; - quote_id?: string; - }): Promise>; - getStatus(id: string): Promise>; - editStatus(id: string, options: { - status?: string; - spoiler_text?: string; - sensitive?: boolean; - media_ids?: Array; - poll?: { - options?: Array; - expires_in?: number; - multiple?: boolean; - hide_totals?: boolean; - }; - }): Promise>; - deleteStatus(id: string): Promise>; - getStatusContext(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>; - getStatusRebloggedBy(id: string): Promise>>; - getStatusFavouritedBy(id: string): Promise>>; - favouriteStatus(id: string): Promise>; - unfavouriteStatus(id: string): Promise>; - reblogStatus(id: string): Promise>; - unreblogStatus(id: string): Promise>; - bookmarkStatus(id: string): Promise>; - unbookmarkStatus(id: string): Promise>; - muteStatus(id: string): Promise>; - unmuteStatus(id: string): Promise>; - pinStatus(id: string): Promise>; - unpinStatus(id: string): Promise>; - uploadMedia(file: any, options?: { - description?: string; - focus?: string; - }): Promise>; - getMedia(id: string): Promise>; - updateMedia(id: string, options?: { - file?: any; - description?: string; - focus?: string; - }): Promise>; - getPoll(id: string): Promise>; - votePoll(id: string, choices: Array): Promise>; - getScheduledStatuses(options?: { - limit?: number | null; - max_id?: string | null; - since_id?: string | null; - min_id?: string | null; - }): Promise>>; - getScheduledStatus(id: string): Promise>; - scheduleStatus(id: string, scheduled_at?: string | null): Promise>; - cancelScheduledStatus(id: string): Promise>; - getPublicTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getLocalTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getTagTimeline(hashtag: string, options?: { - local?: boolean; - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getHomeTimeline(options?: { - local?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getListTimeline(list_id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getConversationTimeline(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - deleteConversation(id: string): Promise>; - readConversation(id: string): Promise>; - getLists(): Promise>>; - getList(id: string): Promise>; - createList(title: string): Promise>; - updateList(id: string, title: string): Promise>; - deleteList(id: string): Promise>; - getAccountsInList(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - addAccountsToList(id: string, account_ids: Array): Promise>; - deleteAccountsFromList(id: string, account_ids: Array): Promise>; - getMarkers(timeline: Array): Promise>; - saveMarkers(options?: { - home?: { - last_read_id: string; - }; - notifications?: { - last_read_id: string; - }; - }): Promise>; - getNotifications(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - exclude_types?: Array; - account_id?: string; - }): Promise>>; - getNotification(id: string): Promise>; - dismissNotifications(): Promise>; - dismissNotification(id: string): Promise>; - readNotifications(_options: { - id?: string; - max_id?: string; - }): Promise>>; - subscribePushNotification(subscription: { - endpoint: string; - keys: { - p256dh: string; - auth: string; - }; - }, data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - getPushSubscription(): Promise>; - updatePushSubscription(data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - deletePushSubscription(): Promise>; - search(q: string, type: 'accounts' | 'hashtags' | 'statuses', options?: { - limit?: number; - max_id?: string; - min_id?: string; - resolve?: boolean; - offset?: number; - following?: boolean; - account_id?: string; - exclude_unreviewed?: boolean; - }): Promise>; - getInstance(): Promise>; - getInstancePeers(): Promise>>; - getInstanceActivity(): Promise>>; - getInstanceTrends(limit?: number | null): Promise>>; - getInstanceDirectory(options?: { - limit?: number; - offset?: number; - order?: 'active' | 'new'; - local?: boolean; - }): Promise>>; - getInstanceCustomEmojis(): Promise>>; - getInstanceAnnouncements(with_dismissed?: boolean | null): Promise>>; - dismissInstanceAnnouncement(id: string): Promise>; - createEmojiReaction(_id: string, _emoji: string): Promise>; - deleteEmojiReaction(_id: string, _emoji: string): Promise>; - getEmojiReactions(_id: string): Promise>>; - getEmojiReaction(_id: string, _emoji: string): Promise>; - userSocket(): WebSocket; - publicSocket(): WebSocket; - localSocket(): WebSocket; - tagSocket(tag: string): WebSocket; - listSocket(list_id: string): WebSocket; - directSocket(): WebSocket; -} diff --git a/packages/megalodon/lib/src/mastodon.js b/packages/megalodon/lib/src/mastodon.js deleted file mode 100644 index 6ae7ed51c2..0000000000 --- a/packages/megalodon/lib/src/mastodon.js +++ /dev/null @@ -1,2367 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var oauth_1 = require("oauth"); -var form_data_1 = __importDefault(require("form-data")); -var parse_link_header_1 = __importDefault(require("parse-link-header")); -var api_client_1 = __importDefault(require("./mastodon/api_client")); -var megalodon_1 = require("./megalodon"); -var default_1 = require("./default"); -var oauth_2 = __importDefault(require("./oauth")); -var Mastodon = (function () { - function Mastodon(baseUrl, accessToken, userAgent, proxyConfig) { - if (accessToken === void 0) { accessToken = null; } - if (userAgent === void 0) { userAgent = default_1.DEFAULT_UA; } - if (proxyConfig === void 0) { proxyConfig = false; } - var token = ''; - if (accessToken) { - token = accessToken; - } - var agent = default_1.DEFAULT_UA; - if (userAgent) { - agent = userAgent; - } - this.client = new api_client_1.default.Client(baseUrl, token, agent, proxyConfig); - this.baseUrl = baseUrl; - } - Mastodon.prototype.cancel = function () { - return this.client.cancel(); - }; - Mastodon.prototype.registerApp = function (client_name, options) { - return __awaiter(this, void 0, void 0, function () { - var scopes; - var _this = this; - return __generator(this, function (_a) { - scopes = options.scopes || default_1.DEFAULT_SCOPE; - return [2, this.createApp(client_name, options).then(function (appData) { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.generateAuthUrl(appData.client_id, appData.client_secret, { - scope: scopes, - redirect_uri: appData.redirect_uri - }).then(function (url) { - appData.url = url; - return appData; - })]; - }); - }); })]; - }); - }); - }; - Mastodon.prototype.createApp = function (client_name, options) { - return __awaiter(this, void 0, void 0, function () { - var scopes, redirect_uris, params; - return __generator(this, function (_a) { - scopes = options.scopes || default_1.DEFAULT_SCOPE; - redirect_uris = options.redirect_uris || default_1.NO_REDIRECT; - params = { - client_name: client_name, - redirect_uris: redirect_uris, - scopes: scopes.join(' ') - }; - if (options.website) - params.website = options.website; - return [2, this.client - .post('/api/v1/apps', params) - .then(function (res) { return oauth_2.default.AppData.from(res.data); })]; - }); - }); - }; - Mastodon.prototype.generateAuthUrl = function (clientId, clientSecret, options) { - var _this = this; - var scope = options.scope || default_1.DEFAULT_SCOPE; - var redirect_uri = options.redirect_uri || default_1.NO_REDIRECT; - return new Promise(function (resolve) { - var oauth = new oauth_1.OAuth2(clientId, clientSecret, _this.baseUrl, undefined, '/oauth/token'); - var url = oauth.getAuthorizeUrl({ - redirect_uri: redirect_uri, - response_type: 'code', - client_id: clientId, - scope: scope.join(' ') - }); - resolve(url); - }); - }; - Mastodon.prototype.verifyAppCredentials = function () { - return this.client.get('/api/v1/apps/verify_credentials'); - }; - Mastodon.prototype.fetchAccessToken = function (client_id, client_secret, code, redirect_uri) { - if (redirect_uri === void 0) { redirect_uri = default_1.NO_REDIRECT; } - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (!client_id) { - throw new Error('client_id is required'); - } - return [2, this.client - .post('/oauth/token', { - client_id: client_id, - client_secret: client_secret, - code: code, - redirect_uri: redirect_uri, - grant_type: 'authorization_code' - }) - .then(function (res) { return oauth_2.default.TokenData.from(res.data); })]; - }); - }); - }; - Mastodon.prototype.refreshToken = function (client_id, client_secret, refresh_token) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/oauth/token', { - client_id: client_id, - client_secret: client_secret, - refresh_token: refresh_token, - grant_type: 'refresh_token' - }) - .then(function (res) { return oauth_2.default.TokenData.from(res.data); })]; - }); - }); - }; - Mastodon.prototype.revokeToken = function (client_id, client_secret, token) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/oauth/revoke', { - client_id: client_id, - client_secret: client_secret, - token: token - })]; - }); - }); - }; - Mastodon.prototype.registerAccount = function (username, email, password, agreement, locale, reason) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - username: username, - email: email, - password: password, - agreement: agreement, - locale: locale - }; - if (reason) { - params = Object.assign(params, { - reason: reason - }); - } - return [2, this.client.post('/api/v1/accounts', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.token(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.verifyAccountCredentials = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/accounts/verify_credentials').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.account(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.updateCredentials = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.discoverable !== undefined) { - params = Object.assign(params, { - discoverable: options.discoverable - }); - } - if (options.bot !== undefined) { - params = Object.assign(params, { - bot: options.bot - }); - } - if (options.display_name) { - params = Object.assign(params, { - display_name: options.display_name - }); - } - if (options.note) { - params = Object.assign(params, { - note: options.note - }); - } - if (options.avatar) { - params = Object.assign(params, { - avatar: options.avatar - }); - } - if (options.header) { - params = Object.assign(params, { - header: options.header - }); - } - if (options.locked !== undefined) { - params = Object.assign(params, { - locked: options.locked - }); - } - if (options.source) { - params = Object.assign(params, { - source: options.source - }); - } - if (options.fields_attributes) { - params = Object.assign(params, { - fields_attributes: options.fields_attributes - }); - } - } - return [2, this.client.patch('/api/v1/accounts/update_credentials', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.account(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.account(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getAccountStatuses = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.pinned) { - params = Object.assign(params, { - pinned: options.pinned - }); - } - if (options.exclude_replies) { - params = Object.assign(params, { - exclude_replies: options.exclude_replies - }); - } - if (options.exclude_reblogs) { - params = Object.assign(params, { - exclude_reblogs: options.exclude_reblogs - }); - } - if (options.only_media) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - } - return [2, this.client.get("/api/v1/accounts/".concat(id, "/statuses"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.subscribeAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - notify: true - }; - return [2, this.client.post("/api/v1/accounts/".concat(id, "/follow"), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unsubscribeAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - notify: false - }; - return [2, this.client.post("/api/v1/accounts/".concat(id, "/follow"), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getAccountFavourites = function (_id, _options) { - return new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('mastodon does not support'); - reject(err); - }); - }; - Mastodon.prototype.getAccountFollowers = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.urlToAccounts("/api/v1/accounts/".concat(id, "/followers"), params, (options === null || options === void 0 ? void 0 : options.get_all) || false, (options === null || options === void 0 ? void 0 : options.sleep_ms) || 0)]; - }); - }); - }; - Mastodon.prototype.getAccountFollowing = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.urlToAccounts("/api/v1/accounts/".concat(id, "/following"), params, (options === null || options === void 0 ? void 0 : options.get_all) || false, (options === null || options === void 0 ? void 0 : options.sleep_ms) || 0)]; - }); - }); - }; - Mastodon.prototype.urlToAccounts = function (url, params, get_all, sleep_ms) { - return __awaiter(this, void 0, void 0, function () { - var res, parsed, nextRes; - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: return [4, this.client.get(url, params)]; - case 1: - res = _b.sent(); - res.data = res.data.map(function (a) { return api_client_1.default.Converter.account(a); }); - if (!(get_all && res.headers.link)) return [3, 6]; - parsed = (0, parse_link_header_1.default)(res.headers.link); - _b.label = 2; - case 2: - if (!(parsed === null || parsed === void 0 ? void 0 : parsed.next)) return [3, 6]; - return [4, this.client.get(parsed === null || parsed === void 0 ? void 0 : parsed.next.url, undefined, undefined, true)]; - case 3: - nextRes = _b.sent(); - (_a = res.data).push.apply(_a, __spreadArray([], __read(nextRes.data.map(function (a) { return api_client_1.default.Converter.account(a); })), false)); - parsed = (0, parse_link_header_1.default)(nextRes.headers.link); - if (!sleep_ms) return [3, 5]; - return [4, new Promise(function (res) { return setTimeout(res, sleep_ms); })]; - case 4: - _b.sent(); - _b.label = 5; - case 5: return [3, 2]; - case 6: return [2, res]; - } - }); - }); - }; - Mastodon.prototype.getAccountLists = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id, "/lists")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (l) { return api_client_1.default.Converter.list(l); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getIdentityProof = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id, "/identity_proofs")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (i) { return api_client_1.default.Converter.identity_proof(i); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.followAccount = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.reblog !== undefined) { - params = Object.assign(params, { - reblog: options.reblog - }); - } - } - return [2, this.client.post("/api/v1/accounts/".concat(id, "/follow"), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unfollowAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unfollow")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.blockAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/block")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unblockAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unblock")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.muteAccount = function (id, notifications) { - if (notifications === void 0) { notifications = true; } - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post("/api/v1/accounts/".concat(id, "/mute"), { - notifications: notifications - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unmuteAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unmute")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.pinAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/pin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unpinAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unpin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getRelationship = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .get('/api/v1/accounts/relationships', { - id: [id] - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data[0]) - }); - })]; - }); - }); - }; - Mastodon.prototype.getRelationships = function (ids) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .get('/api/v1/accounts/relationships', { - id: ids - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (r) { return api_client_1.default.Converter.relationship(r); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.searchAccount = function (q, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { q: q }; - if (options) { - if (options.following !== undefined && options.following !== null) { - params = Object.assign(params, { - following: options.following - }); - } - if (options.resolve !== undefined && options.resolve !== null) { - params = Object.assign(params, { - resolve: options.resolve - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/accounts/search', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getBookmarks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - } - return [2, this.client.get('/api/v1/bookmarks', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getFavourites = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/favourites', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getMutes = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/mutes', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getBlocks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/blocks', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getDomainBlocks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/domain_blocks', params)]; - }); - }); - }; - Mastodon.prototype.blockDomain = function (domain) { - return this.client.post('/api/v1/domain_blocks', { - domain: domain - }); - }; - Mastodon.prototype.unblockDomain = function (domain) { - return this.client.del('/api/v1/domain_blocks', { - domain: domain - }); - }; - Mastodon.prototype.getFilters = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/filters').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return api_client_1.default.Converter.filter(f); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getFilter = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/filters/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.createFilter = function (phrase, context, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - phrase: phrase, - context: context - }; - if (options) { - if (options.irreversible !== undefined) { - params = Object.assign(params, { - irreversible: options.irreversible - }); - } - if (options.whole_word !== undefined) { - params = Object.assign(params, { - whole_word: options.whole_word - }); - } - if (options.expires_in) { - params = Object.assign(params, { - expires_in: options.expires_in - }); - } - } - return [2, this.client.post('/api/v1/filters', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.updateFilter = function (id, phrase, context, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - phrase: phrase, - context: context - }; - if (options) { - if (options.irreversible !== undefined) { - params = Object.assign(params, { - irreversible: options.irreversible - }); - } - if (options.whole_word !== undefined) { - params = Object.assign(params, { - whole_word: options.whole_word - }); - } - if (options.expires_in) { - params = Object.assign(params, { - expires_in: options.expires_in - }); - } - } - return [2, this.client.put("/api/v1/filters/".concat(id), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.deleteFilter = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.del("/api/v1/filters/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.report = function (account_id, comment, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - account_id: account_id, - comment: comment - }; - if (options) { - if (options.status_ids) { - params = Object.assign(params, { - status_ids: options.status_ids - }); - } - if (options.forward !== undefined) { - params = Object.assign(params, { - forward: options.forward - }); - } - } - return [2, this.client.post('/api/v1/reports', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.report(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getFollowRequests = function (limit) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (limit) { - return [2, this.client - .get('/api/v1/follow_requests', { - limit: limit - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - else { - return [2, this.client.get('/api/v1/follow_requests').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - return [2]; - }); - }); - }; - Mastodon.prototype.acceptFollowRequest = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/follow_requests/".concat(id, "/authorize")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.rejectFollowRequest = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/follow_requests/".concat(id, "/reject")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getEndorsements = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get('/api/v1/endorsements', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getFeaturedTags = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/featured_tags').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return api_client_1.default.Converter.featured_tag(f); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getAccountFeaturedTags = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id, "/featured_tags")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return api_client_1.default.Converter.featured_tag(f); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.createFeaturedTag = function (name) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/v1/featured_tags', { - name: name - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.featured_tag(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.deleteFeaturedTag = function (id) { - return this.client.del("/api/v1/featured_tags/".concat(id)); - }; - Mastodon.prototype.getSuggestedTags = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/featured_tags/suggestions').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (t) { return api_client_1.default.Converter.tag(t); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getPreferences = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/preferences').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.preferences(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getSuggestions = function (limit) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (limit) { - return [2, this.client - .get('/api/v1/suggestions', { - limit: limit - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - else { - return [2, this.client.get('/api/v1/suggestions').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - return [2]; - }); - }); - }; - Mastodon.prototype.getTag = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/tags/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.tag(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.followTag = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/tags/".concat(id, "/follow")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.tag(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unfollowTag = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/tags/".concat(id, "/unfollow")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.tag(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.postStatus = function (status, options) { - return __awaiter(this, void 0, void 0, function () { - var params, pollParam; - return __generator(this, function (_a) { - params = { - status: status - }; - if (options) { - if (options.media_ids) { - params = Object.assign(params, { - media_ids: options.media_ids - }); - } - if (options.poll) { - pollParam = { - options: options.poll.options, - expires_in: options.poll.expires_in - }; - if (options.poll.multiple !== undefined) { - pollParam = Object.assign(pollParam, { - multiple: options.poll.multiple - }); - } - if (options.poll.hide_totals !== undefined) { - pollParam = Object.assign(pollParam, { - hide_totals: options.poll.hide_totals - }); - } - params = Object.assign(params, { - poll: pollParam - }); - } - if (options.in_reply_to_id) { - params = Object.assign(params, { - in_reply_to_id: options.in_reply_to_id - }); - } - if (options.sensitive !== undefined) { - params = Object.assign(params, { - sensitive: options.sensitive - }); - } - if (options.spoiler_text) { - params = Object.assign(params, { - spoiler_text: options.spoiler_text - }); - } - if (options.visibility) { - params = Object.assign(params, { - visibility: options.visibility - }); - } - if (options.scheduled_at) { - params = Object.assign(params, { - scheduled_at: options.scheduled_at - }); - } - if (options.language) { - params = Object.assign(params, { - language: options.language - }); - } - if (options.quote_id) { - params = Object.assign(params, { - quote_id: options.quote_id - }); - } - } - return [2, this.client.post('/api/v1/statuses', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/statuses/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.editStatus = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params, pollParam; - return __generator(this, function (_a) { - params = {}; - if (options.status) { - params = Object.assign(params, { - status: options.status - }); - } - if (options.spoiler_text) { - params = Object.assign(params, { - spoiler_text: options.spoiler_text - }); - } - if (options.sensitive) { - params = Object.assign(params, { - sensitive: options.sensitive - }); - } - if (options.media_ids) { - params = Object.assign(params, { - media_ids: options.media_ids - }); - } - if (options.poll) { - pollParam = {}; - if (options.poll.options !== undefined) { - pollParam = Object.assign(pollParam, { - options: options.poll.options - }); - } - if (options.poll.expires_in !== undefined) { - pollParam = Object.assign(pollParam, { - expires_in: options.poll.expires_in - }); - } - if (options.poll.multiple !== undefined) { - pollParam = Object.assign(pollParam, { - multiple: options.poll.multiple - }); - } - if (options.poll.hide_totals !== undefined) { - pollParam = Object.assign(pollParam, { - hide_totals: options.poll.hide_totals - }); - } - params = Object.assign(params, { - poll: pollParam - }); - } - return [2, this.client.put("/api/v1/statuses/".concat(id), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.deleteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.del("/api/v1/statuses/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getStatusContext = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get("/api/v1/statuses/".concat(id, "/context"), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.context(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getStatusRebloggedBy = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/statuses/".concat(id, "/reblogged_by")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getStatusFavouritedBy = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/statuses/".concat(id, "/favourited_by")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.favouriteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/favourite")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unfavouriteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unfavourite")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.reblogStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/reblog")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unreblogStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unreblog")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.bookmarkStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/bookmark")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unbookmarkStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unbookmark")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.muteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/mute")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unmuteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unmute")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.pinStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/pin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.unpinStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unpin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.uploadMedia = function (file, options) { - return __awaiter(this, void 0, void 0, function () { - var formData; - return __generator(this, function (_a) { - formData = new form_data_1.default(); - formData.append('file', file); - if (options) { - if (options.description) { - formData.append('description', options.description); - } - if (options.focus) { - formData.append('focus', options.focus); - } - } - return [2, this.client.postForm('/api/v2/media', formData).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.async_attachment(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getMedia = function (id) { - return __awaiter(this, void 0, void 0, function () { - var res; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.get("/api/v1/media/".concat(id))]; - case 1: - res = _a.sent(); - return [2, Object.assign(res, { - data: api_client_1.default.Converter.attachment(res.data) - })]; - } - }); - }); - }; - Mastodon.prototype.updateMedia = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var formData; - return __generator(this, function (_a) { - formData = new form_data_1.default(); - if (options) { - if (options.file) { - formData.append('file', options.file); - } - if (options.description) { - formData.append('description', options.description); - } - if (options.focus) { - formData.append('focus', options.focus); - } - } - return [2, this.client.putForm("/api/v1/media/".concat(id), formData).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.attachment(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getPoll = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/polls/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.poll(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.votePoll = function (id, choices) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post("/api/v1/polls/".concat(id, "/votes"), { - choices: choices - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.poll(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getScheduledStatuses = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - } - return [2, this.client.get('/api/v1/scheduled_statuses', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.scheduled_status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getScheduledStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/scheduled_statuses/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.scheduled_status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.scheduleStatus = function (id, scheduled_at) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (scheduled_at) { - params = Object.assign(params, { - scheduled_at: scheduled_at - }); - } - return [2, this.client.put("/api/v1/scheduled_statuses/".concat(id), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.scheduled_status(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.cancelScheduledStatus = function (id) { - return this.client.del("/api/v1/scheduled_statuses/".concat(id)); - }; - Mastodon.prototype.getPublicTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - local: false - }; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/timelines/public', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getLocalTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - local: true - }; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/timelines/public', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getTagTimeline = function (hashtag, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.local !== undefined) { - params = Object.assign(params, { - local: options.local - }); - } - if (options.only_media !== undefined) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get("/api/v1/timelines/tag/".concat(hashtag), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getHomeTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.local !== undefined) { - params = Object.assign(params, { - local: options.local - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/timelines/home', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getListTimeline = function (list_id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get("/api/v1/timelines/list/".concat(list_id), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getConversationTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/conversations', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (c) { return api_client_1.default.Converter.conversation(c); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.deleteConversation = function (id) { - return this.client.del("/api/v1/conversations/".concat(id)); - }; - Mastodon.prototype.readConversation = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/conversations/".concat(id, "/read")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.conversation(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getLists = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/lists').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (l) { return api_client_1.default.Converter.list(l); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getList = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/lists/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.list(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.createList = function (title) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/v1/lists', { - title: title - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.list(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.updateList = function (id, title) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .put("/api/v1/lists/".concat(id), { - title: title - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.list(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.deleteList = function (id) { - return this.client.del("/api/v1/lists/".concat(id)); - }; - Mastodon.prototype.getAccountsInList = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get("/api/v1/lists/".concat(id, "/accounts"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.addAccountsToList = function (id, account_ids) { - return this.client.post("/api/v1/lists/".concat(id, "/accounts"), { - account_ids: account_ids - }); - }; - Mastodon.prototype.deleteAccountsFromList = function (id, account_ids) { - return this.client.del("/api/v1/lists/".concat(id, "/accounts"), { - account_ids: account_ids - }); - }; - Mastodon.prototype.getMarkers = function (timeline) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/markers', { - timeline: timeline - })]; - }); - }); - }; - Mastodon.prototype.saveMarkers = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.home) { - params = Object.assign(params, { - home: options.home - }); - } - if (options.notifications) { - params = Object.assign(params, { - notifications: options.notifications - }); - } - } - return [2, this.client.post('/api/v1/markers', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.marker(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getNotifications = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.exclude_types) { - params = Object.assign(params, { - exclude_types: options.exclude_types.map(function (e) { return api_client_1.default.Converter.encodeNotificationType(e); }) - }); - } - if (options.account_id) { - params = Object.assign(params, { - account_id: options.account_id - }); - } - } - return [2, this.client.get('/api/v1/notifications', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (n) { return api_client_1.default.Converter.notification(n); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getNotification = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/notifications/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.notification(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.dismissNotifications = function () { - return this.client.post('/api/v1/notifications/clear'); - }; - Mastodon.prototype.dismissNotification = function (id) { - return this.client.post("/api/v1/notifications/".concat(id, "/dismiss")); - }; - Mastodon.prototype.readNotifications = function (_options) { - return new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('mastodon does not support'); - reject(err); - }); - }; - Mastodon.prototype.subscribePushNotification = function (subscription, data) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - subscription: subscription - }; - if (data) { - params = Object.assign(params, { - data: data - }); - } - return [2, this.client.post('/api/v1/push/subscription', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.push_subscription(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getPushSubscription = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/push/subscription').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.push_subscription(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.updatePushSubscription = function (data) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (data) { - params = Object.assign(params, { - data: data - }); - } - return [2, this.client.put('/api/v1/push/subscription', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.push_subscription(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.deletePushSubscription = function () { - return this.client.del('/api/v1/push/subscription'); - }; - Mastodon.prototype.search = function (q, type, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - q: q, - type: type - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.resolve !== undefined) { - params = Object.assign(params, { - resolve: options.resolve - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - if (options.following !== undefined) { - params = Object.assign(params, { - following: options.following - }); - } - if (options.account_id) { - params = Object.assign(params, { - account_id: options.account_id - }); - } - if (options.exclude_unreviewed) { - params = Object.assign(params, { - exclude_unreviewed: options.exclude_unreviewed - }); - } - } - return [2, this.client.get('/api/v2/search', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.results(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getInstance = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/instance').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.instance(res.data) - }); - })]; - }); - }); - }; - Mastodon.prototype.getInstancePeers = function () { - return this.client.get('/api/v1/instance/peers'); - }; - Mastodon.prototype.getInstanceActivity = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/instance/activity').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.activity(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getInstanceTrends = function (limit) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (limit) { - params = Object.assign(params, { - limit: limit - }); - } - return [2, this.client.get('/api/v1/trends', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (t) { return api_client_1.default.Converter.tag(t); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getInstanceDirectory = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - if (options.order) { - params = Object.assign(params, { - order: options.order - }); - } - if (options.local !== undefined) { - params = Object.assign(params, { - local: options.local - }); - } - } - return [2, this.client.get('/api/v1/directory', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getInstanceCustomEmojis = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/custom_emojis').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (e) { return api_client_1.default.Converter.emoji(e); }) - }); - })]; - }); - }); - }; - Mastodon.prototype.getInstanceAnnouncements = function (with_dismissed) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (with_dismissed) { - params = Object.assign(params, { - with_dismissed: with_dismissed - }); - } - return [2, this.client.get('/api/v1/announcements', params).then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (t) { return api_client_1.default.Converter.announcement(t); }) })); })]; - }); - }); - }; - Mastodon.prototype.dismissInstanceAnnouncement = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/announcements/".concat(id, "/dismiss"))]; - }); - }); - }; - Mastodon.prototype.createEmojiReaction = function (_id, _emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Mastodon.prototype.deleteEmojiReaction = function (_id, _emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Mastodon.prototype.getEmojiReactions = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Mastodon.prototype.getEmojiReaction = function (_id, _emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Mastodon.prototype.userSocket = function () { - return this.client.socket('/api/v1/streaming', 'user'); - }; - Mastodon.prototype.publicSocket = function () { - return this.client.socket('/api/v1/streaming', 'public'); - }; - Mastodon.prototype.localSocket = function () { - return this.client.socket('/api/v1/streaming', 'public:local'); - }; - Mastodon.prototype.tagSocket = function (tag) { - return this.client.socket('/api/v1/streaming', 'hashtag', "tag=".concat(tag)); - }; - Mastodon.prototype.listSocket = function (list_id) { - return this.client.socket('/api/v1/streaming', 'list', "list=".concat(list_id)); - }; - Mastodon.prototype.directSocket = function () { - return this.client.socket('/api/v1/streaming', 'direct'); - }; - return Mastodon; -}()); -exports.default = Mastodon; diff --git a/packages/megalodon/lib/src/mastodon/api_client.d.ts b/packages/megalodon/lib/src/mastodon/api_client.d.ts deleted file mode 100644 index b5169744d9..0000000000 --- a/packages/megalodon/lib/src/mastodon/api_client.d.ts +++ /dev/null @@ -1,152 +0,0 @@ -import WebSocket from './web_socket'; -import Response from '../response'; -import { ProxyConfig } from '../proxy_config'; -import MastodonEntity from './entity'; -import MegalodonEntity from '../entity'; -import NotificationType from '../notification'; -declare namespace MastodonAPI { - interface Interface { - get(path: string, params?: any, headers?: { - [key: string]: string; - }, pathIsFullyQualified?: boolean): Promise>; - put(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - putForm(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - patch(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - patchForm(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - post(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - postForm(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - del(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - cancel(): void; - socket(path: string, stream: string, params?: string): WebSocket; - } - class Client implements Interface { - static DEFAULT_SCOPE: string[]; - static DEFAULT_URL: string; - static NO_REDIRECT: string; - private accessToken; - private baseUrl; - private userAgent; - private abortController; - private proxyConfig; - constructor(baseUrl: string, accessToken?: string | null, userAgent?: string, proxyConfig?: ProxyConfig | false); - get(path: string, params?: {}, headers?: { - [key: string]: string; - }, pathIsFullyQualified?: boolean): Promise>; - put(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - putForm(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - patch(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - patchForm(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - post(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - postForm(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - del(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - cancel(): void; - socket(path: string, stream: string, params?: string): WebSocket; - } - namespace Entity { - type Account = MastodonEntity.Account; - type Activity = MastodonEntity.Activity; - type Announcement = MastodonEntity.Announcement; - type Application = MastodonEntity.Application; - type AsyncAttachment = MegalodonEntity.AsyncAttachment; - type Attachment = MastodonEntity.Attachment; - type Card = MastodonEntity.Card; - type Context = MastodonEntity.Context; - type Conversation = MastodonEntity.Conversation; - type Emoji = MastodonEntity.Emoji; - type FeaturedTag = MastodonEntity.FeaturedTag; - type Field = MastodonEntity.Field; - type Filter = MastodonEntity.Filter; - type History = MastodonEntity.History; - type IdentityProof = MastodonEntity.IdentityProof; - type Instance = MastodonEntity.Instance; - type List = MastodonEntity.List; - type Marker = MastodonEntity.Marker; - type Mention = MastodonEntity.Mention; - type Notification = MastodonEntity.Notification; - type Poll = MastodonEntity.Poll; - type PollOption = MastodonEntity.PollOption; - type Preferences = MastodonEntity.Preferences; - type PushSubscription = MastodonEntity.PushSubscription; - type Relationship = MastodonEntity.Relationship; - type Reaction = MastodonEntity.Reaction; - type Report = MastodonEntity.Report; - type Results = MastodonEntity.Results; - type ScheduledStatus = MastodonEntity.ScheduledStatus; - type Source = MastodonEntity.Source; - type Stats = MastodonEntity.Stats; - type Status = MastodonEntity.Status; - type StatusParams = MastodonEntity.StatusParams; - type Tag = MastodonEntity.Tag; - type Token = MastodonEntity.Token; - type URLs = MastodonEntity.URLs; - } - namespace Converter { - const encodeNotificationType: (t: MegalodonEntity.NotificationType) => MastodonEntity.NotificationType; - const decodeNotificationType: (t: MastodonEntity.NotificationType) => MegalodonEntity.NotificationType; - const account: (a: Entity.Account) => MegalodonEntity.Account; - const activity: (a: Entity.Activity) => MegalodonEntity.Activity; - const announcement: (a: Entity.Announcement) => MegalodonEntity.Announcement; - const application: (a: Entity.Application) => MegalodonEntity.Application; - const attachment: (a: Entity.Attachment) => MegalodonEntity.Attachment; - const async_attachment: (a: Entity.AsyncAttachment) => MegalodonEntity.Attachment | MegalodonEntity.AsyncAttachment; - const card: (c: Entity.Card) => MegalodonEntity.Card; - const context: (c: Entity.Context) => MegalodonEntity.Context; - const conversation: (c: Entity.Conversation) => MegalodonEntity.Conversation; - const emoji: (e: Entity.Emoji) => MegalodonEntity.Emoji; - const featured_tag: (e: Entity.FeaturedTag) => MegalodonEntity.FeaturedTag; - const field: (f: Entity.Field) => MegalodonEntity.Field; - const filter: (f: Entity.Filter) => MegalodonEntity.Filter; - const history: (h: Entity.History) => MegalodonEntity.History; - const identity_proof: (i: Entity.IdentityProof) => MegalodonEntity.IdentityProof; - const instance: (i: Entity.Instance) => MegalodonEntity.Instance; - const list: (l: Entity.List) => MegalodonEntity.List; - const marker: (m: Entity.Marker) => MegalodonEntity.Marker; - const mention: (m: Entity.Mention) => MegalodonEntity.Mention; - const notification: (n: Entity.Notification) => MegalodonEntity.Notification; - const poll: (p: Entity.Poll) => MegalodonEntity.Poll; - const poll_option: (p: Entity.PollOption) => MegalodonEntity.PollOption; - const preferences: (p: Entity.Preferences) => MegalodonEntity.Preferences; - const push_subscription: (p: Entity.PushSubscription) => MegalodonEntity.PushSubscription; - const relationship: (r: Entity.Relationship) => MegalodonEntity.Relationship; - const reaction: (r: Entity.Reaction) => MegalodonEntity.Reaction; - const report: (r: Entity.Report) => MegalodonEntity.Report; - const results: (r: Entity.Results) => MegalodonEntity.Results; - const scheduled_status: (s: Entity.ScheduledStatus) => MegalodonEntity.ScheduledStatus; - const source: (s: Entity.Source) => MegalodonEntity.Source; - const stats: (s: Entity.Stats) => MegalodonEntity.Stats; - const status: (s: Entity.Status) => MegalodonEntity.Status; - const status_params: (s: Entity.StatusParams) => MegalodonEntity.StatusParams; - const tag: (t: Entity.Tag) => MegalodonEntity.Tag; - const token: (t: Entity.Token) => MegalodonEntity.Token; - const urls: (u: Entity.URLs) => MegalodonEntity.URLs; - } -} -export default MastodonAPI; diff --git a/packages/megalodon/lib/src/mastodon/api_client.js b/packages/megalodon/lib/src/mastodon/api_client.js deleted file mode 100644 index 8ff48c4048..0000000000 --- a/packages/megalodon/lib/src/mastodon/api_client.js +++ /dev/null @@ -1,614 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var axios_1 = __importDefault(require("axios")); -var object_assign_deep_1 = __importDefault(require("object-assign-deep")); -var web_socket_1 = __importDefault(require("./web_socket")); -var cancel_1 = require("../cancel"); -var proxy_config_1 = __importDefault(require("../proxy_config")); -var default_1 = require("../default"); -var notification_1 = __importDefault(require("../notification")); -var notification_2 = __importDefault(require("./notification")); -var MastodonAPI; -(function (MastodonAPI) { - var Client = (function () { - function Client(baseUrl, accessToken, userAgent, proxyConfig) { - if (accessToken === void 0) { accessToken = null; } - if (userAgent === void 0) { userAgent = default_1.DEFAULT_UA; } - if (proxyConfig === void 0) { proxyConfig = false; } - this.proxyConfig = false; - this.accessToken = accessToken; - this.baseUrl = baseUrl; - this.userAgent = userAgent; - this.proxyConfig = proxyConfig; - this.abortController = new AbortController(); - axios_1.default.defaults.signal = this.abortController.signal; - } - Client.prototype.get = function (path, params, headers, pathIsFullyQualified) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - if (pathIsFullyQualified === void 0) { pathIsFullyQualified = false; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - params: params, - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .get((pathIsFullyQualified ? '' : this.baseUrl) + path, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.put = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .put(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.putForm = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .putForm(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.patch = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .patch(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.patchForm = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .patchForm(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.post = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default.post(this.baseUrl + path, params, options).then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.postForm = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default.postForm(this.baseUrl + path, params, options).then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.del = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - data: params, - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .delete(this.baseUrl + path, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.cancel = function () { - return this.abortController.abort(); - }; - Client.prototype.socket = function (path, stream, params) { - if (!this.accessToken) { - throw new Error('accessToken is required'); - } - var url = this.baseUrl + path; - var streaming = new web_socket_1.default(url, stream, params, this.accessToken, this.userAgent, this.proxyConfig); - process.nextTick(function () { - streaming.start(); - }); - return streaming; - }; - Client.DEFAULT_SCOPE = default_1.DEFAULT_SCOPE; - Client.DEFAULT_URL = 'https://mastodon.social'; - Client.NO_REDIRECT = default_1.NO_REDIRECT; - return Client; - }()); - MastodonAPI.Client = Client; - var Converter; - (function (Converter) { - Converter.encodeNotificationType = function (t) { - switch (t) { - case notification_1.default.Follow: - return notification_2.default.Follow; - case notification_1.default.Favourite: - return notification_2.default.Favourite; - case notification_1.default.Reblog: - return notification_2.default.Reblog; - case notification_1.default.Mention: - return notification_2.default.Mention; - case notification_1.default.FollowRequest: - return notification_2.default.FollowRequest; - case notification_1.default.Status: - return notification_2.default.Status; - case notification_1.default.PollExpired: - return notification_2.default.Poll; - default: - return t; - } - }; - Converter.decodeNotificationType = function (t) { - switch (t) { - case notification_2.default.Follow: - return notification_1.default.Follow; - case notification_2.default.Favourite: - return notification_1.default.Favourite; - case notification_2.default.Mention: - return notification_1.default.Mention; - case notification_2.default.Reblog: - return notification_1.default.Reblog; - case notification_2.default.FollowRequest: - return notification_1.default.FollowRequest; - case notification_2.default.Status: - return notification_1.default.Status; - case notification_2.default.Poll: - return notification_1.default.PollExpired; - default: - return t; - } - }; - Converter.account = function (a) { return a; }; - Converter.activity = function (a) { return a; }; - Converter.announcement = function (a) { return (__assign(__assign({}, a), { reactions: a.reactions.map(function (r) { return Converter.reaction(r); }) })); }; - Converter.application = function (a) { return a; }; - Converter.attachment = function (a) { return a; }; - Converter.async_attachment = function (a) { - if (a.url) { - return { - id: a.id, - type: a.type, - url: a.url, - remote_url: a.remote_url, - preview_url: a.preview_url, - text_url: a.text_url, - meta: a.meta, - description: a.description, - blurhash: a.blurhash - }; - } - else { - return a; - } - }; - Converter.card = function (c) { return c; }; - Converter.context = function (c) { return ({ - ancestors: c.ancestors.map(function (a) { return Converter.status(a); }), - descendants: c.descendants.map(function (d) { return Converter.status(d); }) - }); }; - Converter.conversation = function (c) { return ({ - id: c.id, - accounts: c.accounts.map(function (a) { return Converter.account(a); }), - last_status: c.last_status ? Converter.status(c.last_status) : null, - unread: c.unread - }); }; - Converter.emoji = function (e) { return e; }; - Converter.featured_tag = function (e) { return e; }; - Converter.field = function (f) { return f; }; - Converter.filter = function (f) { return f; }; - Converter.history = function (h) { return h; }; - Converter.identity_proof = function (i) { return i; }; - Converter.instance = function (i) { return i; }; - Converter.list = function (l) { return l; }; - Converter.marker = function (m) { return m; }; - Converter.mention = function (m) { return m; }; - Converter.notification = function (n) { - if (n.status) { - return { - account: Converter.account(n.account), - created_at: n.created_at, - id: n.id, - status: Converter.status(n.status), - type: Converter.decodeNotificationType(n.type) - }; - } - else { - return { - account: Converter.account(n.account), - created_at: n.created_at, - id: n.id, - type: Converter.decodeNotificationType(n.type) - }; - } - }; - Converter.poll = function (p) { return p; }; - Converter.poll_option = function (p) { return p; }; - Converter.preferences = function (p) { return p; }; - Converter.push_subscription = function (p) { return p; }; - Converter.relationship = function (r) { return r; }; - Converter.reaction = function (r) { - var _a; - return ({ - count: r.count, - me: (_a = r.me) !== null && _a !== void 0 ? _a : false, - name: r.name, - url: r.url, - }); - }; - Converter.report = function (r) { return r; }; - Converter.results = function (r) { return ({ - accounts: r.accounts.map(function (a) { return Converter.account(a); }), - statuses: r.statuses.map(function (s) { return Converter.status(s); }), - hashtags: r.hashtags.map(function (h) { return Converter.tag(h); }) - }); }; - Converter.scheduled_status = function (s) { return s; }; - Converter.source = function (s) { return s; }; - Converter.stats = function (s) { return s; }; - Converter.status = function (s) { return ({ - id: s.id, - uri: s.uri, - url: s.url, - account: Converter.account(s.account), - in_reply_to_id: s.in_reply_to_id, - in_reply_to_account_id: s.in_reply_to_account_id, - reblog: s.reblog ? Converter.status(s.reblog) : s.quote ? Converter.status(s.quote) : null, - content: s.content, - plain_content: null, - created_at: s.created_at, - emojis: s.emojis.map(function (e) { return Converter.emoji(e); }), - replies_count: s.replies_count, - reblogs_count: s.reblogs_count, - favourites_count: s.favourites_count, - reblogged: s.reblogged, - favourited: s.favourited, - muted: s.muted, - sensitive: s.sensitive, - spoiler_text: s.spoiler_text, - visibility: s.visibility, - media_attachments: s.media_attachments.map(function (m) { return Converter.attachment(m); }), - mentions: s.mentions.map(function (m) { return Converter.mention(m); }), - tags: s.tags.map(function (t) { return Converter.tag(t); }), - card: s.card ? Converter.card(s.card) : null, - poll: s.poll ? Converter.poll(s.poll) : null, - application: s.application ? Converter.application(s.application) : null, - language: s.language, - pinned: s.pinned, - emoji_reactions: [], - bookmarked: s.bookmarked ? s.bookmarked : false, - quote: s.quote ? Converter.status(s.quote) : null - }); }; - Converter.status_params = function (s) { return s; }; - Converter.tag = function (t) { return t; }; - Converter.token = function (t) { return t; }; - Converter.urls = function (u) { return u; }; - })(Converter = MastodonAPI.Converter || (MastodonAPI.Converter = {})); -})(MastodonAPI || (MastodonAPI = {})); -exports.default = MastodonAPI; diff --git a/packages/megalodon/lib/src/mastodon/entities/account.d.ts b/packages/megalodon/lib/src/mastodon/entities/account.d.ts deleted file mode 100644 index 02b3d5b8c5..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/account.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// -/// -/// -declare namespace MastodonEntity { - type Account = { - id: string; - username: string; - acct: string; - display_name: string; - locked: boolean; - created_at: string; - followers_count: number; - following_count: number; - statuses_count: number; - note: string; - url: string; - avatar: string; - avatar_static: string; - header: string; - header_static: string; - emojis: Array; - moved: Account | null; - fields: Array; - bot: boolean | null; - source?: Source; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/account.js b/packages/megalodon/lib/src/mastodon/entities/account.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/account.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/activity.d.ts b/packages/megalodon/lib/src/mastodon/entities/activity.d.ts deleted file mode 100644 index 26d3c4338e..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/activity.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace MastodonEntity { - type Activity = { - week: string; - statuses: string; - logins: string; - registrations: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/activity.js b/packages/megalodon/lib/src/mastodon/entities/activity.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/activity.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/announcement.d.ts b/packages/megalodon/lib/src/mastodon/entities/announcement.d.ts deleted file mode 100644 index bd5acb7505..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/announcement.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -/// -declare namespace MastodonEntity { - type Announcement = { - id: string; - content: string; - starts_at: string | null; - ends_at: string | null; - published: boolean; - all_day: boolean; - published_at: string; - updated_at: string; - read?: boolean; - mentions: Array; - statuses: Array; - tags: Array; - emojis: Array; - reactions: Array; - }; - type AnnouncementAccount = { - id: string; - username: string; - url: string; - acct: string; - }; - type AnnouncementStatus = { - id: string; - url: string; - }; - type Reaction = { - name: string; - count: number; - me?: boolean; - url?: string; - static_url?: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/announcement.js b/packages/megalodon/lib/src/mastodon/entities/announcement.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/announcement.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/application.d.ts b/packages/megalodon/lib/src/mastodon/entities/application.d.ts deleted file mode 100644 index 88943865bb..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/application.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace MastodonEntity { - type Application = { - name: string; - website?: string | null; - vapid_key?: string | null; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/application.js b/packages/megalodon/lib/src/mastodon/entities/application.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/application.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/async_attachment.d.ts b/packages/megalodon/lib/src/mastodon/entities/async_attachment.d.ts deleted file mode 100644 index 59d8daff22..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/async_attachment.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// -declare namespace MastodonEntity { - type AsyncAttachment = { - id: string; - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - url: string | null; - remote_url: string | null; - preview_url: string; - text_url: string | null; - meta: Meta | null; - description: string | null; - blurhash: string | null; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/async_attachment.js b/packages/megalodon/lib/src/mastodon/entities/async_attachment.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/async_attachment.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/attachment.d.ts b/packages/megalodon/lib/src/mastodon/entities/attachment.d.ts deleted file mode 100644 index bb0b8d6dc7..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/attachment.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -declare namespace MastodonEntity { - type Sub = { - width?: number; - height?: number; - size?: string; - aspect?: number; - frame_rate?: string; - duration?: number; - bitrate?: number; - }; - type Focus = { - x: number; - y: number; - }; - type Meta = { - original?: Sub; - small?: Sub; - focus?: Focus; - length?: string; - duration?: number; - fps?: number; - size?: string; - width?: number; - height?: number; - aspect?: number; - audio_encode?: string; - audio_bitrate?: string; - audio_channel?: string; - }; - type Attachment = { - id: string; - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - url: string; - remote_url: string | null; - preview_url: string | null; - text_url: string | null; - meta: Meta | null; - description: string | null; - blurhash: string | null; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/attachment.js b/packages/megalodon/lib/src/mastodon/entities/attachment.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/attachment.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/card.d.ts b/packages/megalodon/lib/src/mastodon/entities/card.d.ts deleted file mode 100644 index 927ed7d6cc..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/card.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -declare namespace MastodonEntity { - type Card = { - url: string; - title: string; - description: string; - type: 'link' | 'photo' | 'video' | 'rich'; - image?: string; - author_name?: string; - author_url?: string; - provider_name?: string; - provider_url?: string; - html?: string; - width?: number; - height?: number; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/card.js b/packages/megalodon/lib/src/mastodon/entities/card.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/card.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/context.d.ts b/packages/megalodon/lib/src/mastodon/entities/context.d.ts deleted file mode 100644 index 91e15feb23..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/context.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -declare namespace MastodonEntity { - type Context = { - ancestors: Array; - descendants: Array; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/context.js b/packages/megalodon/lib/src/mastodon/entities/context.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/context.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/conversation.d.ts b/packages/megalodon/lib/src/mastodon/entities/conversation.d.ts deleted file mode 100644 index ec32531799..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/conversation.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -declare namespace MastodonEntity { - type Conversation = { - id: string; - accounts: Array; - last_status: Status | null; - unread: boolean; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/conversation.js b/packages/megalodon/lib/src/mastodon/entities/conversation.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/conversation.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/emoji.d.ts b/packages/megalodon/lib/src/mastodon/entities/emoji.d.ts deleted file mode 100644 index e5aedd56f7..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/emoji.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MastodonEntity { - type Emoji = { - shortcode: string; - static_url: string; - url: string; - visible_in_picker: boolean; - category: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/emoji.js b/packages/megalodon/lib/src/mastodon/entities/emoji.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/emoji.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/featured_tag.d.ts b/packages/megalodon/lib/src/mastodon/entities/featured_tag.d.ts deleted file mode 100644 index 1587354b93..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/featured_tag.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace MastodonEntity { - type FeaturedTag = { - id: string; - name: string; - statuses_count: number; - last_status_at: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/featured_tag.js b/packages/megalodon/lib/src/mastodon/entities/featured_tag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/featured_tag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/field.d.ts b/packages/megalodon/lib/src/mastodon/entities/field.d.ts deleted file mode 100644 index bff55954cf..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/field.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace MastodonEntity { - type Field = { - name: string; - value: string; - verified_at: string | null; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/field.js b/packages/megalodon/lib/src/mastodon/entities/field.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/field.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/filter.d.ts b/packages/megalodon/lib/src/mastodon/entities/filter.d.ts deleted file mode 100644 index 963c7c4aed..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/filter.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace MastodonEntity { - type Filter = { - id: string; - phrase: string; - context: Array; - expires_at: string | null; - irreversible: boolean; - whole_word: boolean; - }; - type FilterContext = string; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/filter.js b/packages/megalodon/lib/src/mastodon/entities/filter.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/filter.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/history.d.ts b/packages/megalodon/lib/src/mastodon/entities/history.d.ts deleted file mode 100644 index 3303cdd6e3..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/history.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace MastodonEntity { - type History = { - day: string; - uses: number; - accounts: number; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/history.js b/packages/megalodon/lib/src/mastodon/entities/history.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/history.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/identity_proof.d.ts b/packages/megalodon/lib/src/mastodon/entities/identity_proof.d.ts deleted file mode 100644 index c4c42548f6..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/identity_proof.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MastodonEntity { - type IdentityProof = { - provider: string; - provider_username: string; - updated_at: string; - proof_url: string; - profile_url: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/identity_proof.js b/packages/megalodon/lib/src/mastodon/entities/identity_proof.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/identity_proof.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/instance.d.ts b/packages/megalodon/lib/src/mastodon/entities/instance.d.ts deleted file mode 100644 index c8c0dc6087..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/instance.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// -/// -/// -declare namespace MastodonEntity { - type Instance = { - uri: string; - title: string; - description: string; - email: string; - version: string; - thumbnail: string | null; - urls: URLs; - stats: Stats; - languages: Array; - contact_account: Account | null; - max_toot_chars?: number; - registrations?: boolean; - configuration?: { - statuses: { - max_characters: number; - max_media_attachments: number; - characters_reserved_per_url: number; - }; - media_attachments: { - supported_mime_types: Array; - image_size_limit: number; - image_matrix_limit: number; - video_size_limit: number; - video_frame_limit: number; - video_matrix_limit: number; - }; - polls: { - max_options: number; - max_characters_per_option: number; - min_expiration: number; - max_expiration: number; - }; - }; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/instance.js b/packages/megalodon/lib/src/mastodon/entities/instance.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/instance.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/list.d.ts b/packages/megalodon/lib/src/mastodon/entities/list.d.ts deleted file mode 100644 index e72bc79935..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/list.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace MastodonEntity { - type List = { - id: string; - title: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/list.js b/packages/megalodon/lib/src/mastodon/entities/list.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/list.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/marker.d.ts b/packages/megalodon/lib/src/mastodon/entities/marker.d.ts deleted file mode 100644 index c10a16586d..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/marker.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -declare namespace MastodonEntity { - type Marker = { - home: { - last_read_id: string; - version: number; - updated_at: string; - }; - notifications: { - last_read_id: string; - version: number; - updated_at: string; - }; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/marker.js b/packages/megalodon/lib/src/mastodon/entities/marker.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/marker.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/mention.d.ts b/packages/megalodon/lib/src/mastodon/entities/mention.d.ts deleted file mode 100644 index c850ddb811..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/mention.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace MastodonEntity { - type Mention = { - id: string; - username: string; - url: string; - acct: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/mention.js b/packages/megalodon/lib/src/mastodon/entities/mention.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/mention.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/notification.d.ts b/packages/megalodon/lib/src/mastodon/entities/notification.d.ts deleted file mode 100644 index 22b16434d8..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/notification.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// -/// -declare namespace MastodonEntity { - type Notification = { - account: Account; - created_at: string; - id: string; - status?: Status; - type: NotificationType; - }; - type NotificationType = string; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/notification.js b/packages/megalodon/lib/src/mastodon/entities/notification.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/notification.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/poll.d.ts b/packages/megalodon/lib/src/mastodon/entities/poll.d.ts deleted file mode 100644 index 636b0ed933..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/poll.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// -declare namespace MastodonEntity { - type Poll = { - id: string; - expires_at: string | null; - expired: boolean; - multiple: boolean; - votes_count: number; - options: Array; - voted: boolean; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/poll.js b/packages/megalodon/lib/src/mastodon/entities/poll.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/poll.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/poll_option.d.ts b/packages/megalodon/lib/src/mastodon/entities/poll_option.d.ts deleted file mode 100644 index 7ed529faad..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/poll_option.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace MastodonEntity { - type PollOption = { - title: string; - votes_count: number | null; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/poll_option.js b/packages/megalodon/lib/src/mastodon/entities/poll_option.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/poll_option.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/preferences.d.ts b/packages/megalodon/lib/src/mastodon/entities/preferences.d.ts deleted file mode 100644 index 011dc27d1b..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/preferences.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MastodonEntity { - type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct'; - 'posting:default:sensitive': boolean; - 'posting:default:language': string | null; - 'reading:expand:media': 'default' | 'show_all' | 'hide_all'; - 'reading:expand:spoilers': boolean; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/preferences.js b/packages/megalodon/lib/src/mastodon/entities/preferences.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/preferences.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/push_subscription.d.ts b/packages/megalodon/lib/src/mastodon/entities/push_subscription.d.ts deleted file mode 100644 index dbed36e34a..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/push_subscription.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare namespace MastodonEntity { - type Alerts = { - follow: boolean; - favourite: boolean; - mention: boolean; - reblog: boolean; - poll: boolean; - }; - type PushSubscription = { - id: string; - endpoint: string; - server_key: string; - alerts: Alerts; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/push_subscription.js b/packages/megalodon/lib/src/mastodon/entities/push_subscription.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/push_subscription.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/relationship.d.ts b/packages/megalodon/lib/src/mastodon/entities/relationship.d.ts deleted file mode 100644 index 33b9f8d858..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/relationship.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -declare namespace MastodonEntity { - type Relationship = { - id: string; - following: boolean; - followed_by: boolean; - delivery_following: boolean; - blocking: boolean; - blocked_by: boolean; - muting: boolean; - muting_notifications: boolean; - requested: boolean; - domain_blocking: boolean; - showing_reblogs: boolean; - endorsed: boolean; - notifying: boolean; - note: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/relationship.js b/packages/megalodon/lib/src/mastodon/entities/relationship.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/relationship.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/report.d.ts b/packages/megalodon/lib/src/mastodon/entities/report.d.ts deleted file mode 100644 index d2118f105b..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/report.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MastodonEntity { - type Report = { - id: string; - action_taken: string; - comment: string; - account_id: string; - status_ids: Array; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/report.js b/packages/megalodon/lib/src/mastodon/entities/report.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/report.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/results.d.ts b/packages/megalodon/lib/src/mastodon/entities/results.d.ts deleted file mode 100644 index 2dbd766c2c..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/results.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -/// -declare namespace MastodonEntity { - type Results = { - accounts: Array; - statuses: Array; - hashtags: Array; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/results.js b/packages/megalodon/lib/src/mastodon/entities/results.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/results.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/scheduled_status.d.ts b/packages/megalodon/lib/src/mastodon/entities/scheduled_status.d.ts deleted file mode 100644 index 9bed699544..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/scheduled_status.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -declare namespace MastodonEntity { - type ScheduledStatus = { - id: string; - scheduled_at: string; - params: StatusParams; - media_attachments: Array; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/scheduled_status.js b/packages/megalodon/lib/src/mastodon/entities/scheduled_status.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/scheduled_status.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/source.d.ts b/packages/megalodon/lib/src/mastodon/entities/source.d.ts deleted file mode 100644 index fc7d06164c..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/source.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace MastodonEntity { - type Source = { - privacy: string | null; - sensitive: boolean | null; - language: string | null; - note: string; - fields: Array; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/source.js b/packages/megalodon/lib/src/mastodon/entities/source.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/source.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/stats.d.ts b/packages/megalodon/lib/src/mastodon/entities/stats.d.ts deleted file mode 100644 index 86648217a3..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/stats.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace MastodonEntity { - type Stats = { - user_count: number; - status_count: number; - domain_count: number; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/stats.js b/packages/megalodon/lib/src/mastodon/entities/stats.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/stats.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/status.d.ts b/packages/megalodon/lib/src/mastodon/entities/status.d.ts deleted file mode 100644 index 7d0778fdeb..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/status.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -declare namespace MastodonEntity { - type Status = { - id: string; - uri: string; - url: string; - account: Account; - in_reply_to_id: string | null; - in_reply_to_account_id: string | null; - reblog: Status | null; - content: string; - created_at: string; - emojis: Emoji[]; - replies_count: number; - reblogs_count: number; - favourites_count: number; - reblogged: boolean | null; - favourited: boolean | null; - muted: boolean | null; - sensitive: boolean; - spoiler_text: string; - visibility: 'public' | 'unlisted' | 'private' | 'direct'; - media_attachments: Array; - mentions: Array; - tags: Array; - card: Card | null; - poll: Poll | null; - application: Application | null; - language: string | null; - pinned: boolean | null; - bookmarked?: boolean; - quote_id?: string; - quote?: Status | null; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/status.js b/packages/megalodon/lib/src/mastodon/entities/status.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/status.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/status_params.d.ts b/packages/megalodon/lib/src/mastodon/entities/status_params.d.ts deleted file mode 100644 index cf4e9bf296..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/status_params.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace MastodonEntity { - type StatusParams = { - text: string; - in_reply_to_id: string | null; - media_ids: Array | null; - sensitive: boolean | null; - spoiler_text: string | null; - visibility: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at: string | null; - application_id: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/status_params.js b/packages/megalodon/lib/src/mastodon/entities/status_params.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/status_params.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/tag.d.ts b/packages/megalodon/lib/src/mastodon/entities/tag.d.ts deleted file mode 100644 index 418b527a97..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/tag.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace MastodonEntity { - type Tag = { - name: string; - url: string; - history: Array | null; - following?: boolean; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/tag.js b/packages/megalodon/lib/src/mastodon/entities/tag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/tag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/token.d.ts b/packages/megalodon/lib/src/mastodon/entities/token.d.ts deleted file mode 100644 index d7d2e192a8..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/token.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace MastodonEntity { - type Token = { - access_token: string; - token_type: string; - scope: string; - created_at: number; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/token.js b/packages/megalodon/lib/src/mastodon/entities/token.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/token.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entities/urls.d.ts b/packages/megalodon/lib/src/mastodon/entities/urls.d.ts deleted file mode 100644 index fd56c2b325..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/urls.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace MastodonEntity { - type URLs = { - streaming_api: string; - }; -} diff --git a/packages/megalodon/lib/src/mastodon/entities/urls.js b/packages/megalodon/lib/src/mastodon/entities/urls.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/mastodon/entities/urls.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/mastodon/entity.d.ts b/packages/megalodon/lib/src/mastodon/entity.d.ts deleted file mode 100644 index e93268d6f7..0000000000 --- a/packages/megalodon/lib/src/mastodon/entity.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -export default MastodonEntity; diff --git a/packages/megalodon/lib/src/mastodon/entity.js b/packages/megalodon/lib/src/mastodon/entity.js deleted file mode 100644 index c8ad2e549b..0000000000 --- a/packages/megalodon/lib/src/mastodon/entity.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/megalodon/lib/src/mastodon/notification.d.ts b/packages/megalodon/lib/src/mastodon/notification.d.ts deleted file mode 100644 index d05e327906..0000000000 --- a/packages/megalodon/lib/src/mastodon/notification.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import MastodonEntity from './entity'; -declare namespace MastodonNotificationType { - const Mention: MastodonEntity.NotificationType; - const Reblog: MastodonEntity.NotificationType; - const Favourite: MastodonEntity.NotificationType; - const Follow: MastodonEntity.NotificationType; - const Poll: MastodonEntity.NotificationType; - const FollowRequest: MastodonEntity.NotificationType; - const Status: MastodonEntity.NotificationType; -} -export default MastodonNotificationType; diff --git a/packages/megalodon/lib/src/mastodon/notification.js b/packages/megalodon/lib/src/mastodon/notification.js deleted file mode 100644 index 790ca9d845..0000000000 --- a/packages/megalodon/lib/src/mastodon/notification.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var MastodonNotificationType; -(function (MastodonNotificationType) { - MastodonNotificationType.Mention = 'mention'; - MastodonNotificationType.Reblog = 'reblog'; - MastodonNotificationType.Favourite = 'favourite'; - MastodonNotificationType.Follow = 'follow'; - MastodonNotificationType.Poll = 'poll'; - MastodonNotificationType.FollowRequest = 'follow_request'; - MastodonNotificationType.Status = 'status'; -})(MastodonNotificationType || (MastodonNotificationType = {})); -exports.default = MastodonNotificationType; diff --git a/packages/megalodon/lib/src/mastodon/web_socket.d.ts b/packages/megalodon/lib/src/mastodon/web_socket.d.ts deleted file mode 100644 index 639afab43d..0000000000 --- a/packages/megalodon/lib/src/mastodon/web_socket.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// -import WS from 'ws'; -import { EventEmitter } from 'events'; -import { ProxyConfig } from '../proxy_config'; -import { WebSocketInterface } from '../megalodon'; -export default class WebSocket extends EventEmitter implements WebSocketInterface { - url: string; - stream: string; - params: string | null; - parser: Parser; - headers: { - [key: string]: string; - }; - proxyConfig: ProxyConfig | false; - private _accessToken; - private _reconnectInterval; - private _reconnectMaxAttempts; - private _reconnectCurrentAttempts; - private _connectionClosed; - private _client; - private _pongReceivedTimestamp; - private _heartbeatInterval; - private _pongWaiting; - constructor(url: string, stream: string, params: string | undefined, accessToken: string, userAgent: string, proxyConfig?: ProxyConfig | false); - start(): void; - private _startWebSocketConnection; - stop(): void; - private _resetConnection; - private _resetRetryParams; - private _reconnect; - private _connect; - private _clearBinding; - private _bindSocket; - private _setupParser; - private _checkAlive; -} -export declare class Parser extends EventEmitter { - parse(data: WS.Data, isBinary: boolean): void; -} diff --git a/packages/megalodon/lib/src/mastodon/web_socket.js b/packages/megalodon/lib/src/mastodon/web_socket.js deleted file mode 100644 index f378767292..0000000000 --- a/packages/megalodon/lib/src/mastodon/web_socket.js +++ /dev/null @@ -1,260 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Parser = void 0; -var ws_1 = __importDefault(require("ws")); -var dayjs_1 = __importDefault(require("dayjs")); -var events_1 = require("events"); -var proxy_config_1 = __importDefault(require("../proxy_config")); -var api_client_1 = __importDefault(require("./api_client")); -var WebSocket = (function (_super) { - __extends(WebSocket, _super); - function WebSocket(url, stream, params, accessToken, userAgent, proxyConfig) { - if (proxyConfig === void 0) { proxyConfig = false; } - var _this = _super.call(this) || this; - _this.proxyConfig = false; - _this._heartbeatInterval = 60000; - _this._pongWaiting = false; - _this.url = url; - _this.stream = stream; - if (params === undefined) { - _this.params = null; - } - else { - _this.params = params; - } - _this.parser = new Parser(); - _this.headers = { - 'User-Agent': userAgent - }; - _this.proxyConfig = proxyConfig; - _this._accessToken = accessToken; - _this._reconnectInterval = 10000; - _this._reconnectMaxAttempts = Infinity; - _this._reconnectCurrentAttempts = 0; - _this._connectionClosed = false; - _this._client = null; - _this._pongReceivedTimestamp = (0, dayjs_1.default)(); - return _this; - } - WebSocket.prototype.start = function () { - this._connectionClosed = false; - this._resetRetryParams(); - this._startWebSocketConnection(); - }; - WebSocket.prototype._startWebSocketConnection = function () { - this._resetConnection(); - this._setupParser(); - this._client = this._connect(this.url, this.stream, this.params, this._accessToken, this.headers, this.proxyConfig); - this._bindSocket(this._client); - }; - WebSocket.prototype.stop = function () { - this._connectionClosed = true; - this._resetConnection(); - this._resetRetryParams(); - }; - WebSocket.prototype._resetConnection = function () { - if (this._client) { - this._client.close(1000); - this._client.removeAllListeners(); - this._client = null; - } - if (this.parser) { - this.parser.removeAllListeners(); - } - }; - WebSocket.prototype._resetRetryParams = function () { - this._reconnectCurrentAttempts = 0; - }; - WebSocket.prototype._reconnect = function () { - var _this = this; - setTimeout(function () { - if (_this._client && _this._client.readyState === ws_1.default.CONNECTING) { - return; - } - if (_this._reconnectCurrentAttempts < _this._reconnectMaxAttempts) { - _this._reconnectCurrentAttempts++; - _this._clearBinding(); - if (_this._client) { - _this._client.terminate(); - } - console.log('Reconnecting'); - _this._client = _this._connect(_this.url, _this.stream, _this.params, _this._accessToken, _this.headers, _this.proxyConfig); - _this._bindSocket(_this._client); - } - }, this._reconnectInterval); - }; - WebSocket.prototype._connect = function (url, stream, params, accessToken, headers, proxyConfig) { - var parameter = ["stream=".concat(stream)]; - if (params) { - parameter.push(params); - } - if (accessToken !== null) { - parameter.push("access_token=".concat(accessToken)); - } - var requestURL = "".concat(url, "/?").concat(parameter.join('&')); - var options = { - headers: headers - }; - if (proxyConfig) { - options = Object.assign(options, { - agent: (0, proxy_config_1.default)(proxyConfig) - }); - } - var cli = new ws_1.default(requestURL, options); - return cli; - }; - WebSocket.prototype._clearBinding = function () { - if (this._client) { - this._client.removeAllListeners('close'); - this._client.removeAllListeners('pong'); - this._client.removeAllListeners('open'); - this._client.removeAllListeners('message'); - this._client.removeAllListeners('error'); - } - }; - WebSocket.prototype._bindSocket = function (client) { - var _this = this; - client.on('close', function (code, _reason) { - if (code === 1000) { - _this.emit('close', {}); - } - else { - console.log("Closed connection with ".concat(code)); - if (!_this._connectionClosed) { - _this._reconnect(); - } - } - }); - client.on('pong', function () { - _this._pongWaiting = false; - _this.emit('pong', {}); - _this._pongReceivedTimestamp = (0, dayjs_1.default)(); - setTimeout(function () { return _this._checkAlive(_this._pongReceivedTimestamp); }, _this._heartbeatInterval); - }); - client.on('open', function () { - _this.emit('connect', {}); - setTimeout(function () { - client.ping(''); - }, 10000); - }); - client.on('message', function (data, isBinary) { - _this.parser.parse(data, isBinary); - }); - client.on('error', function (err) { - _this.emit('error', err); - }); - }; - WebSocket.prototype._setupParser = function () { - var _this = this; - this.parser.on('update', function (status) { - _this.emit('update', api_client_1.default.Converter.status(status)); - }); - this.parser.on('notification', function (notification) { - _this.emit('notification', api_client_1.default.Converter.notification(notification)); - }); - this.parser.on('delete', function (id) { - _this.emit('delete', id); - }); - this.parser.on('conversation', function (conversation) { - _this.emit('conversation', api_client_1.default.Converter.conversation(conversation)); - }); - this.parser.on('status_update', function (status) { - _this.emit('status_update', api_client_1.default.Converter.status(status)); - }); - this.parser.on('error', function (err) { - _this.emit('parser-error', err); - }); - this.parser.on('heartbeat', function (_) { - _this.emit('heartbeat', 'heartbeat'); - }); - }; - WebSocket.prototype._checkAlive = function (timestamp) { - var _this = this; - var now = (0, dayjs_1.default)(); - if (now.diff(timestamp) > this._heartbeatInterval - 1000 && !this._connectionClosed) { - if (this._client && this._client.readyState !== ws_1.default.CONNECTING) { - this._pongWaiting = true; - this._client.ping(''); - setTimeout(function () { - if (_this._pongWaiting) { - _this._pongWaiting = false; - _this._reconnect(); - } - }, 10000); - } - } - }; - return WebSocket; -}(events_1.EventEmitter)); -exports.default = WebSocket; -var Parser = (function (_super) { - __extends(Parser, _super); - function Parser() { - return _super !== null && _super.apply(this, arguments) || this; - } - Parser.prototype.parse = function (data, isBinary) { - var message = isBinary ? data : data.toString(); - if (typeof message !== 'string') { - this.emit('heartbeat', {}); - return; - } - if (message === '') { - this.emit('heartbeat', {}); - return; - } - var event = ''; - var payload = ''; - var mes = {}; - try { - var obj = JSON.parse(message); - event = obj.event; - payload = obj.payload; - mes = JSON.parse(payload); - } - catch (err) { - if (event !== 'delete') { - this.emit('error', new Error("Error parsing websocket reply: ".concat(message, ", error message: ").concat(err))); - return; - } - } - switch (event) { - case 'update': - this.emit('update', mes); - break; - case 'notification': - this.emit('notification', mes); - break; - case 'conversation': - this.emit('conversation', mes); - break; - case 'delete': - this.emit('delete', payload); - break; - case 'status.update': - this.emit('status_update', mes); - break; - default: - this.emit('error', new Error("Unknown event has received: ".concat(message))); - } - }; - return Parser; -}(events_1.EventEmitter)); -exports.Parser = Parser; diff --git a/packages/megalodon/lib/src/megalodon.d.ts b/packages/megalodon/lib/src/megalodon.d.ts deleted file mode 100644 index 1128dd0a5f..0000000000 --- a/packages/megalodon/lib/src/megalodon.d.ts +++ /dev/null @@ -1,386 +0,0 @@ -import Response from './response'; -import OAuth from './oauth'; -import { ProxyConfig } from './proxy_config'; -import Entity from './entity'; -export interface WebSocketInterface { - start(): void; - stop(): void; - on(event: string | symbol, listener: (...args: any[]) => void): this; - once(event: string | symbol, listener: (...args: any[]) => void): this; - removeListener(event: string | symbol, listener: (...args: any[]) => void): this; - removeAllListeners(event?: string | symbol): this; -} -export interface MegalodonInterface { - cancel(): void; - registerApp(client_name: string, options: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - createApp(client_name: string, options: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - verifyAppCredentials(): Promise>; - fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string): Promise; - refreshToken(client_id: string, client_secret: string, refresh_token: string): Promise; - revokeToken(client_id: string, client_secret: string, token: string): Promise>; - registerAccount(username: string, email: string, password: string, agreement: boolean, locale: string, reason?: string | null): Promise>; - verifyAccountCredentials(): Promise>; - updateCredentials(options?: { - discoverable?: boolean; - bot?: boolean; - display_name?: string; - note?: string; - avatar?: string; - header?: string; - locked?: boolean; - source?: { - privacy?: string; - sensitive?: boolean; - language?: string; - }; - fields_attributes?: Array<{ - name: string; - value: string; - }>; - }): Promise>; - getAccount(id: string): Promise>; - getAccountStatuses(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - pinned?: boolean; - exclude_replies?: boolean; - exclude_reblogs?: boolean; - only_media?: boolean; - }): Promise>>; - getAccountFavourites(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - subscribeAccount(id: string): Promise>; - unsubscribeAccount(id: string): Promise>; - getAccountFollowers(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - get_all?: boolean; - sleep_ms?: number; - }): Promise>>; - getAccountFeaturedTags(id: string): Promise>>; - getAccountFollowing(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - get_all?: boolean; - sleep_ms?: number; - }): Promise>>; - getAccountLists(id: string): Promise>>; - getIdentityProof(id: string): Promise>>; - followAccount(id: string, options?: { - reblog?: boolean; - }): Promise>; - unfollowAccount(id: string): Promise>; - blockAccount(id: string): Promise>; - unblockAccount(id: string): Promise>; - muteAccount(id: string, notifications: boolean): Promise>; - unmuteAccount(id: string): Promise>; - pinAccount(id: string): Promise>; - unpinAccount(id: string): Promise>; - getRelationship(id: string): Promise>; - getRelationships(ids: Array): Promise>>; - searchAccount(q: string, options?: { - following?: boolean; - resolve?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getBookmarks(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getFavourites(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getMutes(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getDomainBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - blockDomain(domain: string): Promise>; - unblockDomain(domain: string): Promise>; - getFilters(): Promise>>; - getFilter(id: string): Promise>; - createFilter(phrase: string, context: Array, options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - updateFilter(id: string, phrase: string, context: Array, options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - deleteFilter(id: string): Promise>; - report(account_id: string, comment: string, options?: { - status_ids?: Array; - forward?: boolean; - }): Promise>; - getFollowRequests(limit?: number): Promise>>; - acceptFollowRequest(id: string): Promise>; - rejectFollowRequest(id: string): Promise>; - getEndorsements(options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getFeaturedTags(): Promise>>; - createFeaturedTag(name: string): Promise>; - deleteFeaturedTag(id: string): Promise>; - getSuggestedTags(): Promise>>; - getPreferences(): Promise>; - getSuggestions(limit?: number): Promise>>; - getFollowedTags(): Promise>>; - getTag(id: string): Promise>; - followTag(id: string): Promise>; - unfollowTag(id: string): Promise>; - postStatus(status: string, options?: { - media_ids?: Array; - poll?: { - options: Array; - expires_in: number; - multiple?: boolean; - hide_totals?: boolean; - }; - in_reply_to_id?: string; - sensitive?: boolean; - spoiler_text?: string; - visibility?: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at?: string; - language?: string; - quote_id?: string; - }): Promise>; - getStatus(id: string): Promise>; - editStatus(id: string, options: { - status?: string; - spoiler_text?: string; - sensitive?: boolean; - media_ids?: Array; - poll?: { - options?: Array; - expires_in?: number; - multiple?: boolean; - hide_totals?: boolean; - }; - }): Promise>; - deleteStatus(id: string): Promise>; - getStatusContext(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>; - getStatusHistory(id: string): Promise>>; - getStatusRebloggedBy(id: string): Promise>>; - getStatusFavouritedBy(id: string): Promise>>; - favouriteStatus(id: string): Promise>; - unfavouriteStatus(id: string): Promise>; - reblogStatus(id: string): Promise>; - unreblogStatus(id: string): Promise>; - bookmarkStatus(id: string): Promise>; - unbookmarkStatus(id: string): Promise>; - muteStatus(id: string): Promise>; - unmuteStatus(id: string): Promise>; - pinStatus(id: string): Promise>; - unpinStatus(id: string): Promise>; - uploadMedia(file: any, options?: { - description?: string; - focus?: string; - }): Promise>; - getMedia(id: string): Promise>; - updateMedia(id: string, options?: { - file?: any; - description?: string; - focus?: string; - is_sensitive?: boolean; - }): Promise>; - getPoll(id: string): Promise>; - votePoll(id: string, choices: Array, status_id?: string | null): Promise>; - getScheduledStatuses(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getScheduledStatus(id: string): Promise>; - scheduleStatus(id: string, scheduled_at?: string | null): Promise>; - cancelScheduledStatus(id: string): Promise>; - getPublicTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getLocalTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getTagTimeline(hashtag: string, options?: { - local?: boolean; - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getHomeTimeline(options?: { - local?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getListTimeline(list_id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getConversationTimeline(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - deleteConversation(id: string): Promise>; - readConversation(id: string): Promise>; - getLists(): Promise>>; - getList(id: string): Promise>; - createList(title: string): Promise>; - updateList(id: string, title: string): Promise>; - deleteList(id: string): Promise>; - getAccountsInList(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - addAccountsToList(id: string, account_ids: Array): Promise>; - deleteAccountsFromList(id: string, account_ids: Array): Promise>; - getMarkers(timeline: Array): Promise>; - saveMarkers(options?: { - home?: { - last_read_id: string; - }; - notifications?: { - last_read_id: string; - }; - }): Promise>; - getNotifications(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - exclude_types?: Array; - account_id?: string; - }): Promise>>; - getNotification(id: string): Promise>; - dismissNotifications(): Promise>; - dismissNotification(id: string): Promise>; - readNotifications(options: { - id?: string; - max_id?: string; - }): Promise>>; - subscribePushNotification(subscription: { - endpoint: string; - keys: { - p256dh: string; - auth: string; - }; - }, data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - getPushSubscription(): Promise>; - updatePushSubscription(data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - deletePushSubscription(): Promise>; - search(q: string, type: 'accounts' | 'hashtags' | 'statuses', options?: { - limit?: number; - max_id?: string; - min_id?: string; - resolve?: boolean; - offset?: number; - following?: boolean; - account_id?: string; - exclude_unreviewed?: boolean; - }): Promise>; - getInstance(): Promise>; - getInstancePeers(): Promise>>; - getInstanceActivity(): Promise>>; - getInstanceTrends(limit?: number | null): Promise>>; - getInstanceDirectory(options?: { - limit?: number; - offset?: number; - order?: 'active' | 'new'; - local?: boolean; - }): Promise>>; - getInstanceCustomEmojis(): Promise>>; - getInstanceAnnouncements(with_dismissed?: boolean | null): Promise>>; - dismissInstanceAnnouncement(id: string): Promise>; - createEmojiReaction(id: string, emoji: string): Promise>; - deleteEmojiReaction(id: string, emoji: string): Promise>; - getEmojiReactions(id: string): Promise>>; - getEmojiReaction(id: string, emoji: string): Promise>; - userSocket(): WebSocketInterface; - publicSocket(): WebSocketInterface; - localSocket(): WebSocketInterface; - tagSocket(tag: string): WebSocketInterface; - listSocket(list_id: string): WebSocketInterface; - directSocket(): WebSocketInterface; -} -export declare class NoImplementedError extends Error { - constructor(err?: string); -} -export declare class ArgumentError extends Error { - constructor(err?: string); -} -export declare class UnexpectedError extends Error { - constructor(err?: string); -} -export declare const detector: (url: string, proxyConfig?: ProxyConfig | false) => Promise<'mastodon' | 'pleroma' | 'misskey'>; -declare const generator: (baseUrl: string, accessToken?: string | null, userAgent?: string | null, proxyConfig?: ProxyConfig | false) => MegalodonInterface; -export default generator; diff --git a/packages/megalodon/lib/src/megalodon.js b/packages/megalodon/lib/src/megalodon.js deleted file mode 100644 index 8071e7f820..0000000000 --- a/packages/megalodon/lib/src/megalodon.js +++ /dev/null @@ -1,146 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.detector = exports.UnexpectedError = exports.ArgumentError = exports.NoImplementedError = void 0; -var proxy_config_1 = __importDefault(require("./proxy_config")); -var axios_1 = __importDefault(require("axios")); -var misskey_1 = __importDefault(require("./misskey")); -var default_1 = require("./default"); -var NoImplementedError = (function (_super) { - __extends(NoImplementedError, _super); - function NoImplementedError(err) { - var _newTarget = this.constructor; - var _this = _super.call(this, err) || this; - _this.name = _newTarget.name; - Object.setPrototypeOf(_this, _newTarget.prototype); - return _this; - } - return NoImplementedError; -}(Error)); -exports.NoImplementedError = NoImplementedError; -var ArgumentError = (function (_super) { - __extends(ArgumentError, _super); - function ArgumentError(err) { - var _newTarget = this.constructor; - var _this = _super.call(this, err) || this; - _this.name = _newTarget.name; - Object.setPrototypeOf(_this, _newTarget.prototype); - return _this; - } - return ArgumentError; -}(Error)); -exports.ArgumentError = ArgumentError; -var UnexpectedError = (function (_super) { - __extends(UnexpectedError, _super); - function UnexpectedError(err) { - var _newTarget = this.constructor; - var _this = _super.call(this, err) || this; - _this.name = _newTarget.name; - Object.setPrototypeOf(_this, _newTarget.prototype); - return _this; - } - return UnexpectedError; -}(Error)); -exports.UnexpectedError = UnexpectedError; -var detector = function (url, proxyConfig) { - if (proxyConfig === void 0) { proxyConfig = false; } - return __awaiter(void 0, void 0, void 0, function () { - var options, res, err_1; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - options = { - headers: { - 'User-Agent': default_1.DEFAULT_UA - } - }; - if (proxyConfig) { - options = Object.assign(options, { - httpsAgent: (0, proxy_config_1.default)(proxyConfig) - }); - } - _a.label = 1; - case 1: - _a.trys.push([1, 3, , 5]); - return [4, axios_1.default.get(url + '/api/v1/instance', options)]; - case 2: - res = _a.sent(); - if (res.data.version.includes('Pleroma')) { - return [2, 'pleroma']; - } - else { - return [2, 'mastodon']; - } - return [3, 5]; - case 3: - err_1 = _a.sent(); - return [4, axios_1.default.post(url + '/api/meta', {}, options)]; - case 4: - _a.sent(); - return [2, 'misskey']; - case 5: return [2]; - } - }); - }); -}; -exports.detector = detector; -var generator = function (baseUrl, accessToken, userAgent, proxyConfig) { - if (accessToken === void 0) { accessToken = null; } - if (userAgent === void 0) { userAgent = null; } - if (proxyConfig === void 0) { proxyConfig = false; } - return new misskey_1.default(baseUrl, accessToken, userAgent, proxyConfig); -}; -exports.default = generator; diff --git a/packages/megalodon/lib/src/misskey.d.ts b/packages/megalodon/lib/src/misskey.d.ts deleted file mode 100644 index f315442186..0000000000 --- a/packages/megalodon/lib/src/misskey.d.ts +++ /dev/null @@ -1,385 +0,0 @@ -import AsyncLock from 'async-lock'; -import MisskeyAPI from './misskey/api_client'; -import { ProxyConfig } from './proxy_config'; -import OAuth from './oauth'; -import Response from './response'; -import Entity from './entity'; -import { MegalodonInterface, WebSocketInterface } from './megalodon'; -import MegalodonEntity from "@/entity"; -type AccountCache = { - locks: AsyncLock; - accounts: Entity.Account[]; -}; -export default class Misskey implements MegalodonInterface { - client: MisskeyAPI.Interface; - converter: MisskeyAPI.Converter; - baseUrl: string; - proxyConfig: ProxyConfig | false; - constructor(baseUrl: string, accessToken?: string | null, userAgent?: string | null, proxyConfig?: ProxyConfig | false); - private baseUrlToHost; - cancel(): void; - registerApp(client_name: string, options?: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - createApp(client_name: string, options?: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - generateAuthUrlAndToken(clientSecret: string): Promise; - verifyAppCredentials(): Promise>; - fetchAccessToken(_client_id: string | null, client_secret: string, session_token: string, _redirect_uri?: string): Promise; - refreshToken(_client_id: string, _client_secret: string, _refresh_token: string): Promise; - revokeToken(_client_id: string, _client_secret: string, _token: string): Promise>; - registerAccount(_username: string, _email: string, _password: string, _agreement: boolean, _locale: string, _reason?: string | null): Promise>; - verifyAccountCredentials(): Promise>; - updateCredentials(options?: { - discoverable?: boolean; - bot?: boolean; - display_name?: string; - note?: string; - avatar?: string; - header?: string; - locked?: boolean; - source?: { - privacy?: string; - sensitive?: boolean; - language?: string; - } | null; - fields_attributes?: Array<{ - name: string; - value: string; - }>; - }): Promise>; - getAccount(id: string): Promise>; - getAccountByName(user: string, host: string | null): Promise>; - getAccountStatuses(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - pinned?: boolean; - exclude_replies: boolean; - exclude_reblogs: boolean; - only_media?: boolean; - }): Promise>>; - getAccountFavourites(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - subscribeAccount(_id: string): Promise>; - unsubscribeAccount(_id: string): Promise>; - getAccountFollowers(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getAccountFollowing(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getAccountLists(_id: string): Promise>>; - getIdentityProof(_id: string): Promise>>; - followAccount(id: string, _options?: { - reblog?: boolean; - }): Promise>; - unfollowAccount(id: string): Promise>; - blockAccount(id: string): Promise>; - unblockAccount(id: string): Promise>; - muteAccount(id: string, _notifications: boolean): Promise>; - unmuteAccount(id: string): Promise>; - pinAccount(_id: string): Promise>; - unpinAccount(_id: string): Promise>; - getRelationship(id: string): Promise>; - getRelationships(ids: Array): Promise>>; - searchAccount(q: string, options?: { - following?: boolean; - resolve?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getBookmarks(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getFavourites(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getMutes(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getDomainBlocks(_options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - blockDomain(_domain: string): Promise>; - unblockDomain(_domain: string): Promise>; - getFilters(): Promise>>; - getFilter(_id: string): Promise>; - createFilter(_phrase: string, _context: Array, _options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - updateFilter(_id: string, _phrase: string, _context: Array, _options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - deleteFilter(_id: string): Promise>; - report(account_id: string, comment: string, _options?: { - status_ids?: Array; - forward?: boolean; - }): Promise>; - getFollowRequests(_limit?: number): Promise>>; - acceptFollowRequest(id: string): Promise>; - rejectFollowRequest(id: string): Promise>; - getEndorsements(_options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getFeaturedTags(): Promise>>; - getAccountFeaturedTags(): Promise>>; - createFeaturedTag(_name: string): Promise>; - deleteFeaturedTag(_id: string): Promise>; - getSuggestedTags(): Promise>>; - getPreferences(): Promise>; - getSuggestions(limit?: number): Promise>>; - getFollowedTags(): Promise>>; - getTag(_id: string): Promise>; - followTag(_id: string): Promise>; - unfollowTag(_id: string): Promise>; - postStatus(status: string, options?: { - media_ids?: Array; - poll?: { - options: Array; - expires_in: number; - multiple?: boolean; - hide_totals?: boolean; - }; - in_reply_to_id?: string; - sensitive?: boolean; - spoiler_text?: string; - visibility?: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at?: string; - language?: string; - quote_id?: string; - }): Promise>; - getStatus(id: string): Promise>; - private getFreshAccountCache; - noteWithMentions(n: MisskeyAPI.Entity.Note, host: string, cache: AccountCache): Promise; - addMentionsToStatus(status: Entity.Status, cache: AccountCache): Promise; - getMentions(text: string, cache: AccountCache): Promise; - getAccountByNameCached(user: string, host: string | null, cache: AccountCache): Promise; - editStatus(_id: string, _options: { - status?: string; - spoiler_text?: string; - sensitive?: boolean; - media_ids?: Array; - poll?: { - options?: Array; - expires_in?: number; - multiple?: boolean; - hide_totals?: boolean; - }; - }): Promise>; - deleteStatus(id: string): Promise>; - getStatusContext(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>; - private dfs; - getStatusHistory(): Promise>>; - getStatusRebloggedBy(id: string): Promise>>; - getStatusFavouritedBy(_id: string): Promise>>; - favouriteStatus(id: string): Promise>; - private getDefaultFavoriteEmoji; - unfavouriteStatus(id: string): Promise>; - reblogStatus(id: string): Promise>; - unreblogStatus(id: string): Promise>; - bookmarkStatus(id: string): Promise>; - unbookmarkStatus(id: string): Promise>; - muteStatus(_id: string): Promise>; - unmuteStatus(_id: string): Promise>; - pinStatus(id: string): Promise>; - unpinStatus(id: string): Promise>; - uploadMedia(file: any, _options?: { - description?: string; - focus?: string; - }): Promise>; - getMedia(id: string): Promise>; - updateMedia(id: string, options?: { - file?: any; - description?: string; - focus?: string; - is_sensitive?: boolean; - }): Promise>; - getPoll(_id: string): Promise>; - votePoll(_id: string, choices: Array, status_id?: string | null): Promise>; - getScheduledStatuses(_options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getScheduledStatus(_id: string): Promise>; - scheduleStatus(_id: string, _scheduled_at?: string | null): Promise>; - cancelScheduledStatus(_id: string): Promise>; - getPublicTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getLocalTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getTagTimeline(hashtag: string, options?: { - local?: boolean; - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getHomeTimeline(options?: { - local?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getListTimeline(list_id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getConversationTimeline(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - deleteConversation(_id: string): Promise>; - readConversation(_id: string): Promise>; - getLists(): Promise>>; - getList(id: string): Promise>; - createList(title: string): Promise>; - updateList(id: string, title: string): Promise>; - deleteList(id: string): Promise>; - getAccountsInList(id: string, _options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - addAccountsToList(id: string, account_ids: Array): Promise>; - deleteAccountsFromList(id: string, account_ids: Array): Promise>; - getMarkers(_timeline: Array): Promise>; - saveMarkers(_options?: { - home?: { - last_read_id: string; - }; - notifications?: { - last_read_id: string; - }; - }): Promise>; - getNotifications(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - exclude_type?: Array; - account_id?: string; - }): Promise>>; - getNotification(_id: string): Promise>; - dismissNotifications(): Promise>; - dismissNotification(_id: string): Promise>; - readNotifications(_options: { - id?: string; - max_id?: string; - }): Promise>>; - subscribePushNotification(_subscription: { - endpoint: string; - keys: { - p256dh: string; - auth: string; - }; - }, _data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - getPushSubscription(): Promise>; - updatePushSubscription(_data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - deletePushSubscription(): Promise>; - search(q: string, type: 'accounts' | 'hashtags' | 'statuses', options?: { - limit?: number; - max_id?: string; - min_id?: string; - resolve?: boolean; - offset?: number; - following?: boolean; - account_id?: string; - exclude_unreviewed?: boolean; - }): Promise>; - getInstance(): Promise>; - getInstancePeers(): Promise>>; - getInstanceActivity(): Promise>>; - getInstanceTrends(_limit?: number | null): Promise>>; - getInstanceDirectory(_options?: { - limit?: number; - offset?: number; - order?: 'active' | 'new'; - local?: boolean; - }): Promise>>; - getInstanceCustomEmojis(): Promise>>; - getInstanceAnnouncements(with_dismissed?: boolean | null): Promise>>; - dismissInstanceAnnouncement(id: string): Promise>; - createEmojiReaction(id: string, emoji: string): Promise>; - deleteEmojiReaction(id: string, _emoji: string): Promise>; - getEmojiReactions(id: string): Promise>>; - getEmojiReaction(_id: string, _emoji: string): Promise>; - userSocket(): WebSocketInterface; - publicSocket(): WebSocketInterface; - localSocket(): WebSocketInterface; - tagSocket(_tag: string): WebSocketInterface; - listSocket(list_id: string): WebSocketInterface; - directSocket(): WebSocketInterface; -} -export {}; diff --git a/packages/megalodon/lib/src/misskey.js b/packages/megalodon/lib/src/misskey.js deleted file mode 100644 index 1730283e58..0000000000 --- a/packages/megalodon/lib/src/misskey.js +++ /dev/null @@ -1,2965 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var form_data_1 = __importDefault(require("form-data")); -var async_lock_1 = __importDefault(require("async-lock")); -var api_client_1 = __importDefault(require("./misskey/api_client")); -var default_1 = require("./default"); -var oauth_1 = __importDefault(require("./oauth")); -var megalodon_1 = require("./megalodon"); -var node_fs_1 = __importDefault(require("node:fs")); -var Misskey = (function () { - function Misskey(baseUrl, accessToken, userAgent, proxyConfig) { - if (accessToken === void 0) { accessToken = null; } - if (userAgent === void 0) { userAgent = default_1.DEFAULT_UA; } - if (proxyConfig === void 0) { proxyConfig = false; } - var token = ''; - if (accessToken) { - token = accessToken; - } - var agent = default_1.DEFAULT_UA; - if (userAgent) { - agent = userAgent; - } - this.converter = new api_client_1.default.Converter(baseUrl); - this.client = new api_client_1.default.Client(baseUrl, token, agent, proxyConfig, this.converter); - this.baseUrl = baseUrl; - this.proxyConfig = proxyConfig; - } - Misskey.prototype.baseUrlToHost = function (baseUrl) { - return baseUrl.replace('https://', ''); - }; - Misskey.prototype.cancel = function () { - return this.client.cancel(); - }; - Misskey.prototype.registerApp = function (client_name, options) { - if (options === void 0) { options = { - scopes: api_client_1.default.DEFAULT_SCOPE, - redirect_uris: this.baseUrl - }; } - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.createApp(client_name, options).then(function (appData) { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.generateAuthUrlAndToken(appData.client_secret).then(function (session) { - appData.url = session.url; - appData.session_token = session.token; - return appData; - })]; - }); - }); })]; - }); - }); - }; - Misskey.prototype.createApp = function (client_name, options) { - if (options === void 0) { options = { - scopes: api_client_1.default.DEFAULT_SCOPE, - redirect_uris: this.baseUrl - }; } - return __awaiter(this, void 0, void 0, function () { - var redirect_uris, scopes, params; - return __generator(this, function (_a) { - redirect_uris = options.redirect_uris || this.baseUrl; - scopes = options.scopes || api_client_1.default.DEFAULT_SCOPE; - params = { - name: client_name, - description: '', - permission: scopes, - callbackUrl: redirect_uris - }; - return [2, this.client.post('/api/app/create', params).then(function (res) { - var appData = { - id: res.data.id, - name: res.data.name, - website: null, - redirect_uri: res.data.callbackUrl, - client_id: '', - client_secret: res.data.secret - }; - return oauth_1.default.AppData.from(appData); - })]; - }); - }); - }; - Misskey.prototype.generateAuthUrlAndToken = function (clientSecret) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/auth/session/generate', { - appSecret: clientSecret - }) - .then(function (res) { return res.data; })]; - }); - }); - }; - Misskey.prototype.verifyAppCredentials = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.fetchAccessToken = function (_client_id, client_secret, session_token, _redirect_uri) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/auth/session/userkey', { - appSecret: client_secret, - token: session_token - }) - .then(function (res) { - var token = new oauth_1.default.TokenData(res.data.accessToken, 'misskey', '', 0, null, null); - return token; - })]; - }); - }); - }; - Misskey.prototype.refreshToken = function (_client_id, _client_secret, _refresh_token) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.revokeToken = function (_client_id, _client_secret, _token) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.registerAccount = function (_username, _email, _password, _agreement, _locale, _reason) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.verifyAccountCredentials = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client.post('/api/i').then(function (res) { - return Object.assign(res, { - data: _this.converter.userDetail(res.data, _this.baseUrlToHost(_this.baseUrl)) - }); - })]; - }); - }); - }; - Misskey.prototype.updateCredentials = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.bot !== undefined) { - params = Object.assign(params, { - isBot: options.bot - }); - } - if (options.display_name) { - params = Object.assign(params, { - name: options.display_name - }); - } - if (options.note) { - params = Object.assign(params, { - description: options.note - }); - } - if (options.locked !== undefined) { - params = Object.assign(params, { - isLocked: options.locked - }); - } - if (options.source) { - if (options.source.language) { - params = Object.assign(params, { - lang: options.source.language - }); - } - if (options.source.sensitive) { - params = Object.assign(params, { - alwaysMarkNsfw: options.source.sensitive - }); - } - } - } - return [2, this.client.post('/api/i', params).then(function (res) { - return Object.assign(res, { - data: _this.converter.userDetail(res.data, _this.baseUrlToHost(_this.baseUrl)) - }); - })]; - }); - }); - }; - Misskey.prototype.getAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/show', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.userDetail(res.data, _this.baseUrlToHost(_this.baseUrl)) - }); - })]; - }); - }); - }; - Misskey.prototype.getAccountByName = function (user, host) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/show', { - username: user, - host: host !== null && host !== void 0 ? host : null - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.userDetail(res.data, _this.baseUrlToHost(_this.baseUrl)) - }); - })]; - }); - }); - }; - Misskey.prototype.getAccountStatuses = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - if (options === null || options === void 0 ? void 0 : options.pinned) { - return [2, this.client - .post('/api/users/show', { - userId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - if (!res.data.pinnedNotes) return [3, 2]; - _a = [__assign({}, res)]; - _b = {}; - return [4, Promise.all(res.data.pinnedNotes.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, __assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)]))]; - case 2: return [2, __assign(__assign({}, res), { data: [] })]; - } - }); - }); })]; - } - params = { - userId: id - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.exclude_replies) { - params = Object.assign(params, { - includeReplies: false - }); - } - if (options.exclude_reblogs) { - params = Object.assign(params, { - includeMyRenotes: false - }); - } - if (options.only_media) { - params = Object.assign(params, { - withFiles: options.only_media - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client.post('/api/users/notes', params).then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var statuses; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, Promise.all(res.data.map(function (note) { return _this.noteWithMentions(note, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: - statuses = _a.sent(); - return [2, Object.assign(res, { - data: statuses - })]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getAccountFavourites = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = { - userId: id - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - } - return [2, this.client.post('/api/users/reactions', params).then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a, _b, _c; - var _d; - var _this = this; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - _b = (_a = Object).assign; - _c = [res]; - _d = {}; - return [4, Promise.all(res.data.map(function (fav) { return _this.noteWithMentions(fav.note, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, _b.apply(_a, _c.concat([(_d.data = _e.sent(), - _d)]))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.subscribeAccount = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.unsubscribeAccount = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getAccountFollowers = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = { - userId: id - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - return [2, this.client.post('/api/users/followers', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return _this.converter.follower(f); }) - }); - })]; - }); - }); - }; - Misskey.prototype.getAccountFollowing = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = { - userId: id - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.post('/api/users/following', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return _this.converter.following(f); }) - }); - })]; - }); - }); - }; - Misskey.prototype.getAccountLists = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getIdentityProof = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.followAccount = function (id, _options) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/following/create', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.unfollowAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/following/delete', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.blockAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/blocking/create', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.unblockAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/blocking/delete', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.muteAccount = function (id, _notifications) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/mute/create', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.unmuteAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/mute/delete', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.pinAccount = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.unpinAccount = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getRelationship = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - }); - }); - }; - Misskey.prototype.getRelationships = function (ids) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, Promise.all(ids.map(function (id) { return _this.getRelationship(id); })).then(function (results) { return (__assign(__assign({}, results[0]), { data: results.map(function (r) { return r.data; }) })); })]; - }); - }); - }; - Misskey.prototype.searchAccount = function (q, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = { - query: q, - detail: true - }; - if (options) { - if (options.resolve !== undefined) { - params = Object.assign(params, { - localOnly: options.resolve - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - return [2, this.client.post('/api/users/search', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (u) { return _this.converter.userDetail(u, _this.baseUrlToHost(_this.baseUrl)); }) - }); - })]; - }); - }); - }; - Misskey.prototype.getBookmarks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - return [2, this.client.post('/api/i/favorites', params).then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a, _b, _c; - var _d; - var _this = this; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - _b = (_a = Object).assign; - _c = [res]; - _d = {}; - return [4, Promise.all(res.data.map(function (s) { return _this.noteWithMentions(s.note, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, _b.apply(_a, _c.concat([(_d.data = _e.sent(), - _d)]))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getFavourites = function (options) { - return __awaiter(this, void 0, void 0, function () { - var userId; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/i').then(function (res) { return res.data.id; })]; - case 1: - userId = _a.sent(); - return [2, this.getAccountFavourites(userId, options)]; - } - }); - }); - }; - Misskey.prototype.getMutes = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - return [2, this.client.post('/api/mute/list', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (mute) { return _this.converter.userDetail(mute.mutee, _this.baseUrlToHost(_this.baseUrl)); }) - }); - })]; - }); - }); - }; - Misskey.prototype.getBlocks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 40 - }); - } - return [2, this.client.post('/api/blocking/list', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (blocking) { return _this.converter.userDetail(blocking.blockee, _this.baseUrlToHost(_this.baseUrl)); }) - }); - })]; - }); - }); - }; - Misskey.prototype.getDomainBlocks = function (_options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.blockDomain = function (_domain) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.unblockDomain = function (_domain) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getFilters = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getFilter = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.createFilter = function (_phrase, _context, _options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.updateFilter = function (_id, _phrase, _context, _options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.deleteFilter = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.report = function (account_id, comment, _options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/report-abuse', { - userId: account_id, - comment: comment - }) - .then(function (res) { - return Object.assign(res, { - data: { - id: '', - action_taken: '', - comment: comment, - account_id: account_id, - status_ids: [] - } - }); - })]; - }); - }); - }; - Misskey.prototype.getFollowRequests = function (_limit) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client.post('/api/following/requests/list').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (r) { return _this.converter.user(r.follower); }) - }); - })]; - }); - }); - }; - Misskey.prototype.acceptFollowRequest = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/following/requests/accept', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.rejectFollowRequest = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/following/requests/reject', { - userId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/users/relation', { - userId: id - }) - .then(function (res) { - return Object.assign(res, { - data: _this.converter.relation(res.data) - }); - })]; - } - }); - }); - }; - Misskey.prototype.getEndorsements = function (_options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getFeaturedTags = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.getAccountFeaturedTags()]; - }); - }); - }; - Misskey.prototype.getAccountFeaturedTags = function () { - return __awaiter(this, void 0, void 0, function () { - var tags, res; - return __generator(this, function (_a) { - tags = []; - res = { - headers: undefined, - statusText: "", - status: 200, - data: tags - }; - return [2, new Promise(function (resolve) { return resolve(res); })]; - }); - }); - }; - Misskey.prototype.createFeaturedTag = function (_name) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.deleteFeaturedTag = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getSuggestedTags = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getPreferences = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client.post('/api/i').then(function (res) { - return Object.assign(res, { - data: _this.converter.userPreferences(res.data, { defaultNoteVisibility: "followers", tutorial: -1 }) - }); - })]; - }); - }); - }; - Misskey.prototype.getSuggestions = function (limit) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = {}; - if (limit) { - params = Object.assign(params, { - limit: limit - }); - } - return [2, this.client - .post('/api/users/recommendation', params) - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (u) { return _this.converter.userDetail(u, _this.baseUrlToHost(_this.baseUrl)); }) })); })]; - }); - }); - }; - Misskey.prototype.getFollowedTags = function () { - return __awaiter(this, void 0, void 0, function () { - var tags, res; - return __generator(this, function (_a) { - tags = []; - res = { - headers: undefined, - statusText: "", - status: 200, - data: tags - }; - return [2, new Promise(function (resolve) { return resolve(res); })]; - }); - }); - }; - Misskey.prototype.getTag = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.followTag = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.unfollowTag = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.postStatus = function (status, options) { - return __awaiter(this, void 0, void 0, function () { - var params, pollParam; - var _this = this; - return __generator(this, function (_a) { - params = { - text: status - }; - if (options) { - if (options.media_ids) { - params = Object.assign(params, { - fileIds: options.media_ids - }); - } - if (options.poll) { - pollParam = { - choices: options.poll.options, - expiresAt: null, - expiredAfter: options.poll.expires_in - }; - if (options.poll.multiple !== undefined) { - pollParam = Object.assign(pollParam, { - multiple: options.poll.multiple - }); - } - params = Object.assign(params, { - poll: pollParam - }); - } - if (options.in_reply_to_id) { - params = Object.assign(params, { - replyId: options.in_reply_to_id - }); - } - if (options.sensitive) { - params = Object.assign(params, { - cw: '' - }); - } - if (options.spoiler_text) { - params = Object.assign(params, { - cw: options.spoiler_text - }); - } - if (options.visibility) { - params = Object.assign(params, { - visibility: this.converter.encodeVisibility(options.visibility) - }); - } - if (options.quote_id) { - params = Object.assign(params, { - renoteId: options.quote_id - }); - } - } - return [2, this.client - .post('/api/notes/create', params) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data.createdNote, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getFreshAccountCache = function () { - return { - locks: new async_lock_1.default(), - accounts: [] - }; - }; - Misskey.prototype.noteWithMentions = function (n, host, cache) { - return __awaiter(this, void 0, void 0, function () { - var status; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.converter.note(n, host)]; - case 1: - status = _a.sent(); - return [2, status.mentions.length === 0 ? this.addMentionsToStatus(status, cache) : status]; - } - }); - }); - }; - Misskey.prototype.addMentionsToStatus = function (status, cache) { - return __awaiter(this, void 0, void 0, function () { - var _a, _b, _c, m; - var e_1, _d; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - _a = status; - return [4, this.getMentions(status.plain_content, cache)]; - case 1: - _a.mentions = (_e.sent()).filter(function (p) { return p != null; }); - try { - for (_b = __values(status.mentions.filter(function (value, index, array) { return array.indexOf(value) === index; })), _c = _b.next(); !_c.done; _c = _b.next()) { - m = _c.value; - status.content = status.content.replace("@".concat(m.acct), "@").concat(m.acct, "")); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_d = _b.return)) _d.call(_b); - } - finally { if (e_1) throw e_1.error; } - } - return [2, status]; - } - }); - }); - }; - Misskey.prototype.getMentions = function (text, cache) { - return __awaiter(this, void 0, void 0, function () { - var mentions, mentionMatch, mentionMatch_1, mentionMatch_1_1, m, account, e_2_1; - var e_2, _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - mentions = []; - mentionMatch = text.matchAll(/(?<=^|\s)@(?.*?)(?:@(?.*?)|)(?=\s|$)/g); - _b.label = 1; - case 1: - _b.trys.push([1, 6, 7, 8]); - mentionMatch_1 = __values(mentionMatch), mentionMatch_1_1 = mentionMatch_1.next(); - _b.label = 2; - case 2: - if (!!mentionMatch_1_1.done) return [3, 5]; - m = mentionMatch_1_1.value; - if (m.groups == null) - return [3, 4]; - return [4, this.getAccountByNameCached(m.groups.user, m.groups.host, cache)]; - case 3: - account = _b.sent(); - if (account == null) - return [3, 4]; - mentions.push({ - id: account.id, - url: account.url, - username: account.username, - acct: account.acct - }); - _b.label = 4; - case 4: - mentionMatch_1_1 = mentionMatch_1.next(); - return [3, 2]; - case 5: return [3, 8]; - case 6: - e_2_1 = _b.sent(); - e_2 = { error: e_2_1 }; - return [3, 8]; - case 7: - try { - if (mentionMatch_1_1 && !mentionMatch_1_1.done && (_a = mentionMatch_1.return)) _a.call(mentionMatch_1); - } - finally { if (e_2) throw e_2.error; } - return [7]; - case 8: return [2, mentions]; - } - }); - }); - }; - Misskey.prototype.getAccountByNameCached = function (user, host, cache) { - return __awaiter(this, void 0, void 0, function () { - var acctToFind; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - acctToFind = host == null ? user : "".concat(user, "@").concat(host); - return [4, cache.locks.acquire(acctToFind, function () { return __awaiter(_this, void 0, void 0, function () { - var cacheHit, account, _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - cacheHit = cache.accounts.find(function (p) { return p.acct === acctToFind; }); - if (!(cacheHit !== null && cacheHit !== void 0)) return [3, 1]; - _a = cacheHit; - return [3, 3]; - case 1: return [4, this.getAccountByName(user, host !== null && host !== void 0 ? host : null)]; - case 2: - _a = (_b.sent()).data; - _b.label = 3; - case 3: - account = _a; - if (!account) { - return [2, null]; - } - if (cacheHit == null) { - cache.accounts.push(account); - } - return [2, account]; - } - }); - }); })]; - case 1: return [2, _a.sent()]; - } - }); - }); - }; - Misskey.prototype.editStatus = function (_id, _options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.deleteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/api/notes/delete', { - noteId: id - })]; - }); - }); - }; - Misskey.prototype.getStatusContext = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = { - noteId: id - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit, - depth: 12 - }); - } - else { - params = Object.assign(params, { - limit: 30, - depth: 12 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - } - else { - params = Object.assign(params, { - limit: 30, - depth: 12 - }); - } - return [2, this.client.post('/api/notes/children', params).then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var accountCache, conversation, parents, context, _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - accountCache = this.getFreshAccountCache(); - return [4, this.client.post('/api/notes/conversation', params)]; - case 1: - conversation = _c.sent(); - return [4, Promise.all(conversation.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 2: - parents = _c.sent(); - _b = { - ancestors: parents.reverse() - }; - _a = this.dfs; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 3: - context = (_b.descendants = _a.apply(this, [_c.sent()]), - _b); - return [2, __assign(__assign({}, res), { data: context })]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.dfs = function (graph) { - if (graph.length <= 1) { - return graph; - } - graph = graph.sort(function (a, b) { - if (a.id < b.id) - return -1; - if (a.id > b.id) - return 1; - return 0; - }); - var initialPostId = graph[0].in_reply_to_id; - var stack = graph.filter(function (reply) { return reply.in_reply_to_id === initialPostId; }).reverse(); - var visited = new Set(); - var result = []; - var _loop_1 = function () { - var e_3, _a; - var currentPost = stack.pop(); - if (currentPost === undefined) - return { value: result }; - if (!visited.has(currentPost)) { - visited.add(currentPost); - result.push(currentPost); - try { - for (var _b = (e_3 = void 0, __values(graph.filter(function (reply) { return reply.in_reply_to_id === currentPost.id; }).reverse())), _c = _b.next(); !_c.done; _c = _b.next()) { - var reply = _c.value; - stack.push(reply); - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_3) throw e_3.error; } - } - } - }; - while (stack.length) { - var state_1 = _loop_1(); - if (typeof state_1 === "object") - return state_1.value; - } - return result; - }; - Misskey.prototype.getStatusHistory = function () { - return __awaiter(this, void 0, void 0, function () { - var history, res; - return __generator(this, function (_a) { - history = []; - res = { - headers: undefined, - statusText: "", - status: 200, - data: history - }; - return [2, new Promise(function (resolve) { return resolve(res); })]; - }); - }); - }; - Misskey.prototype.getStatusRebloggedBy = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/notes/renotes', { - noteId: id - }) - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (n) { return _this.converter.user(n.user); }) })); })]; - }); - }); - }; - Misskey.prototype.getStatusFavouritedBy = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.favouriteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = this.createEmojiReaction; - _b = [id]; - return [4, this.getDefaultFavoriteEmoji()]; - case 1: return [2, _a.apply(this, _b.concat([_c.sent()]))]; - } - }); - }); - }; - Misskey.prototype.getDefaultFavoriteEmoji = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client - .post('/api/i/registry/get-unsecure', { - key: 'reactions', - scope: ['client', 'base'], - }) - .then(function (res) { var _a; return (_a = res.data[0]) !== null && _a !== void 0 ? _a : '⭐'; })]; - case 1: return [2, _a.sent()]; - } - }); - }); - }; - Misskey.prototype.unfavouriteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.deleteEmojiReaction(id, '')]; - }); - }); - }; - Misskey.prototype.reblogStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/notes/create', { - renoteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data.createdNote, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.unreblogStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/notes/unrenote', { - noteId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.bookmarkStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/notes/favorites/create', { - noteId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.unbookmarkStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/notes/favorites/delete', { - noteId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.muteStatus = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.unmuteStatus = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.pinStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/i/pin', { - noteId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.unpinStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/i/unpin', { - noteId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.uploadMedia = function (file, _options) { - return __awaiter(this, void 0, void 0, function () { - var formData, headers; - var _this = this; - return __generator(this, function (_a) { - formData = new form_data_1.default(); - formData.append('file', node_fs_1.default.createReadStream(file.path), { - contentType: file.mimetype, - filename: file.originalname, - }); - headers = {}; - if (typeof formData.getHeaders === 'function') { - headers = formData.getHeaders(); - } - return [2, this.client - .post('/api/drive/files/create', formData, headers) - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.file(res.data) })); })]; - }); - }); - }; - Misskey.prototype.getMedia = function (id) { - return __awaiter(this, void 0, void 0, function () { - var res; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/drive/files/show', { fileId: id })]; - case 1: - res = _a.sent(); - return [2, __assign(__assign({}, res), { data: this.converter.file(res.data) })]; - } - }); - }); - }; - Misskey.prototype.updateMedia = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = { - fileId: id - }; - if (options) { - if (options.is_sensitive !== undefined) { - params = Object.assign(params, { - isSensitive: options.is_sensitive - }); - } - } - return [2, this.client - .post('/api/drive/files/update', params) - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.file(res.data) })); })]; - }); - }); - }; - Misskey.prototype.getPoll = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.votePoll = function (_id, choices, status_id) { - return __awaiter(this, void 0, void 0, function () { - var params, res; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!status_id) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.ArgumentError('status_id is required'); - reject(err); - })]; - } - params = { - noteId: status_id, - choice: choices[0] - }; - return [4, this.client.post('/api/notes/polls/vote', params)]; - case 1: - _a.sent(); - return [4, this.client - .post('/api/notes/show', { - noteId: status_id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var note; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: - note = _a.sent(); - return [2, __assign(__assign({}, res), { data: note.poll })]; - } - }); - }); })]; - case 2: - res = _a.sent(); - if (!res.data) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.UnexpectedError('poll does not exist'); - reject(err); - })]; - } - return [2, __assign(__assign({}, res), { data: res.data })]; - } - }); - }); - }; - Misskey.prototype.getScheduledStatuses = function (_options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getScheduledStatus = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.scheduleStatus = function (_id, _scheduled_at) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.cancelScheduledStatus = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getPublicTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = {}; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - withFiles: options.only_media - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/notes/global-timeline', params) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getLocalTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = {}; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - withFiles: options.only_media - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/notes/local-timeline', params) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getTagTimeline = function (hashtag, options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = { - tag: hashtag - }; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - withFiles: options.only_media - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/notes/search-by-tag', params) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getHomeTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = { - withFiles: false - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/notes/timeline', params) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getListTimeline = function (list_id, options) { - return __awaiter(this, void 0, void 0, function () { - var accountCache, params; - var _this = this; - return __generator(this, function (_a) { - accountCache = this.getFreshAccountCache(); - params = { - listId: list_id, - withFiles: false - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/notes/user-list-timeline', params) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - var _this = this; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - }); - }); - }; - Misskey.prototype.getConversationTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = { - visibility: 'specified' - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/notes/mentions', params) - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (n) { return _this.converter.noteToConversation(n, _this.baseUrlToHost(_this.baseUrl)); }) })); })]; - }); - }); - }; - Misskey.prototype.deleteConversation = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.readConversation = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getLists = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/lists/list') - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (l) { return _this.converter.list(l); }) })); })]; - }); - }); - }; - Misskey.prototype.getList = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/lists/show', { - listId: id - }) - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.list(res.data) })); })]; - }); - }); - }; - Misskey.prototype.createList = function (title) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/lists/create', { - name: title - }) - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.list(res.data) })); })]; - }); - }); - }; - Misskey.prototype.updateList = function (id, title) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/users/lists/update', { - listId: id, - name: title - }) - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.list(res.data) })); })]; - }); - }); - }; - Misskey.prototype.deleteList = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/api/users/lists/delete', { - listId: id - })]; - }); - }); - }; - Misskey.prototype.getAccountsInList = function (id, _options) { - return __awaiter(this, void 0, void 0, function () { - var res, promise, accounts; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/users/lists/show', { - listId: id - })]; - case 1: - res = _a.sent(); - promise = res.data.userIds.map(function (userId) { return _this.getAccount(userId); }); - return [4, Promise.all(promise)]; - case 2: - accounts = _a.sent(); - return [2, __assign(__assign({}, res), { data: accounts.map(function (r) { return r.data; }) })]; - } - }); - }); - }; - Misskey.prototype.addAccountsToList = function (id, account_ids) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/api/users/lists/push', { - listId: id, - userId: account_ids[0] - })]; - }); - }); - }; - Misskey.prototype.deleteAccountsFromList = function (id, account_ids) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/api/users/lists/pull', { - listId: id, - userId: account_ids[0] - })]; - }); - }); - }; - Misskey.prototype.getMarkers = function (_timeline) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.saveMarkers = function (_options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getNotifications = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - sinceId: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - if (options.exclude_type) { - params = Object.assign(params, { - excludeType: options.exclude_type.map(function (e) { return _this.converter.encodeNotificationType(e); }) - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - return [2, this.client - .post('/api/i/notifications', params) - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (n) { return _this.converter.notification(n, _this.baseUrlToHost(_this.baseUrl)); }) })); })]; - }); - }); - }; - Misskey.prototype.getNotification = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.dismissNotifications = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/api/notifications/mark-all-as-read')]; - }); - }); - }; - Misskey.prototype.dismissNotification = function (_id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.readNotifications = function (_options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('mastodon does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.subscribePushNotification = function (_subscription, _data) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getPushSubscription = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.updatePushSubscription = function (_data) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.deletePushSubscription = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.search = function (q, type, options) { - var _a, _b; - return __awaiter(this, void 0, void 0, function () { - var accountCache, _c, params, match, lookupQuery, result, _d, params, params; - var _this = this; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - accountCache = this.getFreshAccountCache(); - _c = type; - switch (_c) { - case 'accounts': return [3, 1]; - case 'statuses': return [3, 7]; - case 'hashtags': return [3, 8]; - } - return [3, 9]; - case 1: - params = { - query: q - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - if (options.resolve) { - params = Object.assign(params, { - localOnly: options.resolve - }); - } - } - else { - params = Object.assign(params, { - limit: 20 - }); - } - _e.label = 2; - case 2: - _e.trys.push([2, 5, , 6]); - match = q.match(/^@(?.*?)(?:@(?.*?)|)$/); - if (!match) return [3, 4]; - lookupQuery = { - username: (_a = match.groups) === null || _a === void 0 ? void 0 : _a.user, - host: (_b = match.groups) === null || _b === void 0 ? void 0 : _b.host - }; - return [4, this.client.post('/api/users/show', lookupQuery).then(function (res) { return (__assign(__assign({}, res), { data: { - accounts: [_this.converter.userDetail(res.data, _this.baseUrlToHost(_this.baseUrl))], - statuses: [], - hashtags: [] - } })); })]; - case 3: - result = _e.sent(); - if (result.status !== 200) { - result.status = 200; - result.statusText = "OK"; - result.data = { - accounts: [], - statuses: [], - hashtags: [] - }; - } - return [2, result]; - case 4: return [3, 6]; - case 5: - _d = _e.sent(); - return [3, 6]; - case 6: return [2, this.client.post('/api/users/search', params).then(function (res) { return (__assign(__assign({}, res), { data: { - accounts: res.data.map(function (u) { return _this.converter.userDetail(u, _this.baseUrlToHost(_this.baseUrl)); }), - statuses: [], - hashtags: [] - } })); })]; - case 7: - { - params = { - query: q - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - if (options.max_id) { - params = Object.assign(params, { - untilId: options.max_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - sinceId: options.min_id - }); - } - if (options.account_id) { - params = Object.assign(params, { - userId: options.account_id - }); - } - } - return [2, this.client.post('/api/notes/search', params).then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b, _c; - var _this = this; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - _c = { - accounts: [] - }; - return [4, Promise.all(res.data.map(function (n) { return _this.noteWithMentions(n, _this.baseUrlToHost(_this.baseUrl), accountCache); }))]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = (_c.statuses = _d.sent(), - _c.hashtags = [], - _c), _b)])))]; - } - }); - }); })]; - } - _e.label = 8; - case 8: - { - params = { - query: q - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - } - return [2, this.client.post('/api/hashtags/search', params).then(function (res) { return (__assign(__assign({}, res), { data: { - accounts: [], - statuses: [], - hashtags: res.data.map(function (h) { return ({ name: h, url: h, history: null, following: false }); }) - } })); })]; - } - _e.label = 9; - case 9: return [2]; - } - }); - }); - }; - Misskey.prototype.getInstance = function () { - return __awaiter(this, void 0, void 0, function () { - var meta; - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/meta').then(function (res) { return res.data; })]; - case 1: - meta = _a.sent(); - return [2, this.client - .post('/api/stats') - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.meta(meta, res.data) })); })]; - } - }); - }); - }; - Misskey.prototype.getInstancePeers = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getInstanceActivity = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getInstanceTrends = function (_limit) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/hashtags/trend') - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (h) { return _this.converter.hashtag(h); }) })); })]; - }); - }); - }; - Misskey.prototype.getInstanceDirectory = function (_options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.getInstanceCustomEmojis = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/meta') - .then(function (res) { return (__assign(__assign({}, res), { data: res.data.emojis.map(function (e) { return _this.converter.emoji(e); }) })); })]; - }); - }); - }; - Misskey.prototype.getInstanceAnnouncements = function (with_dismissed) { - return __awaiter(this, void 0, void 0, function () { - var params; - var _this = this; - return __generator(this, function (_a) { - params = {}; - if (with_dismissed) { - params = Object.assign(params, { - withUnreads: with_dismissed - }); - } - return [2, this.client.post('/api/announcements', params).then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (t) { return _this.converter.announcement(t); }) })); })]; - }); - }); - }; - Misskey.prototype.dismissInstanceAnnouncement = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/api/i/read-announcement', { announcementId: id })]; - }); - }); - }; - Misskey.prototype.createEmojiReaction = function (id, emoji) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/notes/reactions/create', { - noteId: id, - reaction: emoji - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.deleteEmojiReaction = function (id, _emoji) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.post('/api/notes/reactions/delete', { - noteId: id - })]; - case 1: - _a.sent(); - return [2, this.client - .post('/api/notes/show', { - noteId: id - }) - .then(function (res) { return __awaiter(_this, void 0, void 0, function () { - var _a; - var _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _a = [__assign({}, res)]; - _b = {}; - return [4, this.noteWithMentions(res.data, this.baseUrlToHost(this.baseUrl), this.getFreshAccountCache())]; - case 1: return [2, (__assign.apply(void 0, _a.concat([(_b.data = _c.sent(), _b)])))]; - } - }); - }); })]; - } - }); - }); - }; - Misskey.prototype.getEmojiReactions = function (id) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, this.client - .post('/api/notes/reactions', { - noteId: id - }) - .then(function (res) { return (__assign(__assign({}, res), { data: _this.converter.reactions(res.data) })); })]; - }); - }); - }; - Misskey.prototype.getEmojiReaction = function (_id, _emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.NoImplementedError('misskey does not support'); - reject(err); - })]; - }); - }); - }; - Misskey.prototype.userSocket = function () { - return this.client.socket('user'); - }; - Misskey.prototype.publicSocket = function () { - return this.client.socket('globalTimeline'); - }; - Misskey.prototype.localSocket = function () { - return this.client.socket('localTimeline'); - }; - Misskey.prototype.tagSocket = function (_tag) { - throw new megalodon_1.NoImplementedError('TODO: implement'); - }; - Misskey.prototype.listSocket = function (list_id) { - return this.client.socket('list', list_id); - }; - Misskey.prototype.directSocket = function () { - return this.client.socket('conversation'); - }; - return Misskey; -}()); -exports.default = Misskey; diff --git a/packages/megalodon/lib/src/misskey/api_client.d.ts b/packages/megalodon/lib/src/misskey/api_client.d.ts deleted file mode 100644 index 71d17e23cb..0000000000 --- a/packages/megalodon/lib/src/misskey/api_client.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { ProxyConfig } from '../proxy_config'; -import Response from '../response'; -import MisskeyEntity from './entity'; -import MegalodonEntity from '../entity'; -import WebSocket from './web_socket'; -import NotificationType from '../notification'; -declare namespace MisskeyAPI { - namespace Entity { - type App = MisskeyEntity.App; - type Announcement = MisskeyEntity.Announcement; - type Blocking = MisskeyEntity.Blocking; - type Choice = MisskeyEntity.Choice; - type CreatedNote = MisskeyEntity.CreatedNote; - type Emoji = MisskeyEntity.Emoji; - type Favorite = MisskeyEntity.Favorite; - type Field = MisskeyEntity.Field; - type File = MisskeyEntity.File; - type Follower = MisskeyEntity.Follower; - type Following = MisskeyEntity.Following; - type FollowRequest = MisskeyEntity.FollowRequest; - type Hashtag = MisskeyEntity.Hashtag; - type List = MisskeyEntity.List; - type Meta = MisskeyEntity.Meta; - type Mute = MisskeyEntity.Mute; - type Note = MisskeyEntity.Note; - type Notification = MisskeyEntity.Notification; - type Poll = MisskeyEntity.Poll; - type Reaction = MisskeyEntity.Reaction; - type Relation = MisskeyEntity.Relation; - type User = MisskeyEntity.User; - type UserDetail = MisskeyEntity.UserDetail; - type UserDetailMe = MisskeyEntity.UserDetailMe; - type GetAll = MisskeyEntity.GetAll; - type UserKey = MisskeyEntity.UserKey; - type Session = MisskeyEntity.Session; - type Stats = MisskeyEntity.Stats; - type APIEmoji = { - emojis: Emoji[]; - }; - } - class Converter { - private baseUrl; - private instanceHost; - private plcUrl; - private modelOfAcct; - constructor(baseUrl: string); - escapeMFM: (text: string) => string; - emoji: (e: Entity.Emoji) => MegalodonEntity.Emoji; - field: (f: Entity.Field) => MegalodonEntity.Field; - user: (u: Entity.User) => MegalodonEntity.Account; - userDetail: (u: Entity.UserDetail, host: string) => MegalodonEntity.Account; - userPreferences: (u: MisskeyAPI.Entity.UserDetailMe, g: MisskeyAPI.Entity.GetAll) => MegalodonEntity.Preferences; - visibility: (v: 'public' | 'home' | 'followers' | 'specified') => 'public' | 'unlisted' | 'private' | 'direct'; - encodeVisibility: (v: 'public' | 'unlisted' | 'private' | 'direct') => 'public' | 'home' | 'followers' | 'specified'; - fileType: (s: string) => 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - file: (f: Entity.File) => MegalodonEntity.Attachment; - follower: (f: Entity.Follower) => MegalodonEntity.Account; - following: (f: Entity.Following) => MegalodonEntity.Account; - relation: (r: Entity.Relation) => MegalodonEntity.Relationship; - choice: (c: Entity.Choice) => MegalodonEntity.PollOption; - poll: (p: Entity.Poll) => MegalodonEntity.Poll; - note: (n: Entity.Note, host: string) => MegalodonEntity.Status; - mapReactions: (r: { - [key: string]: number; - }, myReaction?: string) => Array; - getTotalReactions: (r: { - [key: string]: number; - }) => number; - reactions: (r: Array) => Array; - noteToConversation: (n: Entity.Note, host: string) => MegalodonEntity.Conversation; - list: (l: Entity.List) => MegalodonEntity.List; - encodeNotificationType: (e: MegalodonEntity.NotificationType) => MisskeyEntity.NotificationType; - decodeNotificationType: (e: MisskeyEntity.NotificationType) => MegalodonEntity.NotificationType; - announcement: (a: Entity.Announcement) => MegalodonEntity.Announcement; - notification: (n: Entity.Notification, host: string) => MegalodonEntity.Notification; - stats: (s: Entity.Stats) => MegalodonEntity.Stats; - meta: (m: Entity.Meta, s: Entity.Stats) => MegalodonEntity.Instance; - hashtag: (h: Entity.Hashtag) => MegalodonEntity.Tag; - } - const DEFAULT_SCOPE: string[]; - interface Interface { - post(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - cancel(): void; - socket(channel: 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list', listId?: string): WebSocket; - } - class Client implements Interface { - private accessToken; - private baseUrl; - private userAgent; - private abortController; - private proxyConfig; - private converter; - constructor(baseUrl: string, accessToken: string | null, userAgent: string | undefined, proxyConfig: false | ProxyConfig | undefined, converter: Converter); - post(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - cancel(): void; - socket(channel: 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list', listId?: string): WebSocket; - } -} -export default MisskeyAPI; diff --git a/packages/megalodon/lib/src/misskey/api_client.js b/packages/megalodon/lib/src/misskey/api_client.js deleted file mode 100644 index 9ce065189c..0000000000 --- a/packages/megalodon/lib/src/misskey/api_client.js +++ /dev/null @@ -1,597 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var axios_1 = __importDefault(require("axios")); -var dayjs_1 = __importDefault(require("dayjs")); -var form_data_1 = __importDefault(require("form-data")); -var default_1 = require("@/default"); -var proxy_config_1 = __importDefault(require("../proxy_config")); -var web_socket_1 = __importDefault(require("./web_socket")); -var notification_1 = __importDefault(require("./notification")); -var notification_2 = __importDefault(require("../notification")); -var MisskeyAPI; -(function (MisskeyAPI) { - var Converter = (function () { - function Converter(baseUrl) { - var _this = this; - this.modelOfAcct = { - id: "1", - username: 'none', - acct: 'none', - display_name: 'none', - locked: true, - bot: true, - discoverable: false, - group: false, - created_at: '1971-01-01T00:00:00.000Z', - note: '', - url: 'plc', - avatar: 'plc', - avatar_static: 'plc', - header: 'plc', - header_static: 'plc', - followers_count: -1, - following_count: 0, - statuses_count: 0, - last_status_at: '1971-01-01T00:00:00.000Z', - noindex: true, - emojis: [], - fields: [], - moved: null - }; - this.escapeMFM = function (text) { return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(/`/g, '`') - .replace(/\r?\n/g, '
'); }; - this.emoji = function (e) { - return { - shortcode: e.name, - static_url: e.url, - url: e.url, - visible_in_picker: true, - category: e.category - }; - }; - this.field = function (f) { return ({ - name: f.name, - value: _this.escapeMFM(f.value), - verified_at: null - }); }; - this.user = function (u) { - var acct = u.username; - var acctUrl = "https://".concat(u.host || _this.instanceHost, "/@").concat(u.username); - if (u.host) { - acct = "".concat(u.username, "@").concat(u.host); - acctUrl = "https://".concat(u.host, "/@").concat(u.username); - } - return { - id: u.id, - username: u.username, - acct: acct, - display_name: u.name || u.username, - locked: false, - created_at: new Date().toISOString(), - followers_count: 0, - following_count: 0, - statuses_count: 0, - note: '', - url: acctUrl, - avatar: u.avatarUrl, - avatar_static: u.avatarUrl, - header: _this.plcUrl, - header_static: _this.plcUrl, - emojis: u.emojis.map(function (e) { return _this.emoji(e); }), - moved: null, - fields: [], - bot: false - }; - }; - this.userDetail = function (u, host) { - var _a, _b; - var acct = u.username; - host = host.replace('https://', ''); - var acctUrl = "https://".concat(host || u.host || _this.instanceHost, "/@").concat(u.username); - if (u.host) { - acct = "".concat(u.username, "@").concat(u.host); - acctUrl = "https://".concat(u.host, "/@").concat(u.username); - } - return { - id: u.id, - username: u.username, - acct: acct, - display_name: u.name, - locked: u.isLocked, - created_at: u.createdAt, - followers_count: u.followersCount, - following_count: u.followingCount, - statuses_count: u.notesCount, - note: u.description, - url: acctUrl, - avatar: u.avatarUrl, - avatar_static: u.avatarUrl, - header: (_a = u.bannerUrl) !== null && _a !== void 0 ? _a : _this.plcUrl, - header_static: (_b = u.bannerUrl) !== null && _b !== void 0 ? _b : _this.plcUrl, - emojis: u.emojis.map(function (e) { return _this.emoji(e); }), - moved: null, - fields: u.fields.map(function (f) { return _this.field(f); }), - bot: u.isBot, - }; - }; - this.userPreferences = function (u, g) { - return { - "reading:expand:media": "default", - "reading:expand:spoilers": false, - "posting:default:language": u.lang, - "posting:default:sensitive": u.alwaysMarkNsfw, - "posting:default:visibility": _this.visibility(g.defaultNoteVisibility) - }; - }; - this.visibility = function (v) { - switch (v) { - case 'public': - return v; - case 'home': - return 'unlisted'; - case 'followers': - return 'private'; - case 'specified': - return 'direct'; - } - }; - this.encodeVisibility = function (v) { - switch (v) { - case 'public': - return v; - case 'unlisted': - return 'home'; - case 'private': - return 'followers'; - case 'direct': - return 'specified'; - } - }; - this.fileType = function (s) { - if (s === 'image/gif') { - return 'gifv'; - } - if (s.includes('image')) { - return 'image'; - } - if (s.includes('video')) { - return 'video'; - } - if (s.includes('audio')) { - return 'audio'; - } - return 'unknown'; - }; - this.file = function (f) { - return { - id: f.id, - type: _this.fileType(f.type), - url: f.url, - remote_url: f.url, - preview_url: f.thumbnailUrl, - text_url: f.url, - meta: { - width: f.properties.width, - height: f.properties.height - }, - description: f.comment, - blurhash: f.blurhash - }; - }; - this.follower = function (f) { - return _this.user(f.follower); - }; - this.following = function (f) { - return _this.user(f.followee); - }; - this.relation = function (r) { - return { - id: r.id, - following: r.isFollowing, - followed_by: r.isFollowed, - blocking: r.isBlocking, - blocked_by: r.isBlocked, - muting: r.isMuted, - muting_notifications: false, - requested: r.hasPendingFollowRequestFromYou, - domain_blocking: false, - showing_reblogs: true, - endorsed: false, - notifying: false - }; - }; - this.choice = function (c) { - return { - title: c.text, - votes_count: c.votes - }; - }; - this.poll = function (p) { - var now = (0, dayjs_1.default)(); - var expire = (0, dayjs_1.default)(p.expiresAt); - var count = p.choices.reduce(function (sum, choice) { return sum + choice.votes; }, 0); - return { - id: '', - expires_at: p.expiresAt, - expired: now.isAfter(expire), - multiple: p.multiple, - votes_count: count, - options: p.choices.map(function (c) { return _this.choice(c); }), - voted: p.choices.some(function (c) { return c.isVoted; }) - }; - }; - this.note = function (n, host) { - var _a, _b; - host = host.replace('https://', ''); - return { - id: n.id, - uri: n.uri ? n.uri : "https://".concat(host, "/notes/").concat(n.id), - url: n.uri ? n.uri : "https://".concat(host, "/notes/").concat(n.id), - account: _this.user(n.user), - in_reply_to_id: n.replyId, - in_reply_to_account_id: (_b = (_a = n.reply) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : null, - reblog: n.renote ? _this.note(n.renote, host) : null, - content: n.text ? _this.escapeMFM(n.text) : '', - plain_content: n.text ? n.text : null, - created_at: n.createdAt, - emojis: n.emojis.map(function (e) { return _this.emoji(e); }), - replies_count: n.repliesCount, - reblogs_count: n.renoteCount, - favourites_count: _this.getTotalReactions(n.reactions), - reblogged: false, - favourited: !!n.myReaction, - muted: false, - sensitive: n.files ? n.files.some(function (f) { return f.isSensitive; }) : false, - spoiler_text: n.cw ? n.cw : '', - visibility: _this.visibility(n.visibility), - media_attachments: n.files ? n.files.map(function (f) { return _this.file(f); }) : [], - mentions: [], - tags: [], - card: null, - poll: n.poll ? _this.poll(n.poll) : null, - application: null, - language: null, - pinned: null, - emoji_reactions: _this.mapReactions(n.reactions, n.myReaction), - bookmarked: false, - quote: n.renote && n.text ? _this.note(n.renote, host) : null - }; - }; - this.mapReactions = function (r, myReaction) { - return Object.keys(r).map(function (key) { - if (myReaction && key === myReaction) { - return { - count: r[key], - me: true, - name: key - }; - } - return { - count: r[key], - me: false, - name: key - }; - }); - }; - this.getTotalReactions = function (r) { - return Object.values(r).length > 0 ? Object.values(r).reduce(function (previousValue, currentValue) { return previousValue + currentValue; }) : 0; - }; - this.reactions = function (r) { - var e_1, _a; - var result = []; - var _loop_1 = function (e) { - var i = result.findIndex(function (res) { return res.name === e.type; }); - if (i >= 0) { - result[i].count++; - } - else { - result.push({ - count: 1, - me: false, - name: e.type - }); - } - }; - try { - for (var r_1 = __values(r), r_1_1 = r_1.next(); !r_1_1.done; r_1_1 = r_1.next()) { - var e = r_1_1.value; - _loop_1(e); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (r_1_1 && !r_1_1.done && (_a = r_1.return)) _a.call(r_1); - } - finally { if (e_1) throw e_1.error; } - } - return result; - }; - this.noteToConversation = function (n, host) { - var accounts = [_this.user(n.user)]; - if (n.reply) { - accounts.push(_this.user(n.reply.user)); - } - return { - id: n.id, - accounts: accounts, - last_status: _this.note(n, host), - unread: false - }; - }; - this.list = function (l) { return ({ - id: l.id, - title: l.name - }); }; - this.encodeNotificationType = function (e) { - switch (e) { - case notification_2.default.Follow: - return notification_1.default.Follow; - case notification_2.default.Mention: - return notification_1.default.Reply; - case notification_2.default.Favourite: - case notification_2.default.EmojiReaction: - return notification_1.default.Reaction; - case notification_2.default.Reblog: - return notification_1.default.Renote; - case notification_2.default.PollVote: - return notification_1.default.PollVote; - case notification_2.default.FollowRequest: - return notification_1.default.ReceiveFollowRequest; - default: - return e; - } - }; - this.decodeNotificationType = function (e) { - switch (e) { - case notification_1.default.Follow: - return notification_2.default.Follow; - case notification_1.default.Mention: - case notification_1.default.Reply: - return notification_2.default.Mention; - case notification_1.default.Renote: - case notification_1.default.Quote: - return notification_2.default.Reblog; - case notification_1.default.Reaction: - return notification_2.default.EmojiReaction; - case notification_1.default.PollVote: - return notification_2.default.PollVote; - case notification_1.default.ReceiveFollowRequest: - return notification_2.default.FollowRequest; - case notification_1.default.FollowRequestAccepted: - return notification_2.default.Follow; - default: - return e; - } - }; - this.announcement = function (a) { return ({ - id: a.id, - content: "

".concat(_this.escapeMFM(a.title), "

").concat(_this.escapeMFM(a.text)), - starts_at: null, - ends_at: null, - published: true, - all_day: false, - published_at: a.createdAt, - updated_at: a.updatedAt, - read: a.isRead, - mentions: [], - statuses: [], - tags: [], - emojis: [], - reactions: [], - }); }; - this.notification = function (n, host) { - var notification = { - id: n.id, - account: n.user ? _this.user(n.user) : _this.modelOfAcct, - created_at: n.createdAt, - type: _this.decodeNotificationType(n.type) - }; - if (n.note) { - notification = Object.assign(notification, { - status: _this.note(n.note, host) - }); - } - if (n.reaction) { - notification = Object.assign(notification, { - emoji: n.reaction - }); - } - return notification; - }; - this.stats = function (s) { - return { - user_count: s.usersCount, - status_count: s.notesCount, - domain_count: s.instances - }; - }; - this.meta = function (m, s) { - var wss = m.uri.replace(/^https:\/\//, 'wss://'); - return { - uri: m.uri, - title: m.name, - description: m.description, - email: m.maintainerEmail, - version: m.version, - thumbnail: m.bannerUrl, - urls: { - streaming_api: "".concat(wss, "/streaming") - }, - stats: _this.stats(s), - languages: m.langs, - contact_account: null, - max_toot_chars: m.maxNoteTextLength, - registrations: !m.disableRegistration - }; - }; - this.hashtag = function (h) { - return { - name: h.tag, - url: h.tag, - history: null, - following: false - }; - }; - this.baseUrl = baseUrl; - this.instanceHost = baseUrl.substring(baseUrl.indexOf('//') + 2); - this.plcUrl = "".concat(baseUrl, "/static-assets/transparent.png"); - this.modelOfAcct.url = this.plcUrl; - this.modelOfAcct.avatar = this.plcUrl; - this.modelOfAcct.avatar_static = this.plcUrl; - this.modelOfAcct.header = this.plcUrl; - this.modelOfAcct.header_static = this.plcUrl; - } - return Converter; - }()); - MisskeyAPI.Converter = Converter; - MisskeyAPI.DEFAULT_SCOPE = [ - 'read:account', - 'write:account', - 'read:blocks', - 'write:blocks', - 'read:drive', - 'write:drive', - 'read:favorites', - 'write:favorites', - 'read:following', - 'write:following', - 'read:mutes', - 'write:mutes', - 'write:notes', - 'read:notifications', - 'write:notifications', - 'read:reactions', - 'write:reactions', - 'write:votes' - ]; - var Client = (function () { - function Client(baseUrl, accessToken, userAgent, proxyConfig, converter) { - if (userAgent === void 0) { userAgent = default_1.DEFAULT_UA; } - if (proxyConfig === void 0) { proxyConfig = false; } - this.proxyConfig = false; - this.accessToken = accessToken; - this.baseUrl = baseUrl; - this.userAgent = userAgent; - this.proxyConfig = proxyConfig; - this.abortController = new AbortController(); - this.converter = converter; - axios_1.default.defaults.signal = this.abortController.signal; - } - Client.prototype.post = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options, bodyParams; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - bodyParams = params; - if (this.accessToken) { - if (params instanceof form_data_1.default) { - bodyParams.append('i', this.accessToken); - } - else { - bodyParams = Object.assign(params, { - i: this.accessToken - }); - } - } - console.log("sending request to ".concat(this.baseUrl).concat(path, " with params:")); - console.log(JSON.stringify(bodyParams, null, 2)); - return [2, axios_1.default.post(this.baseUrl + path, bodyParams, options).then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.cancel = function () { - return this.abortController.abort(); - }; - Client.prototype.socket = function (channel, listId) { - if (!this.accessToken) { - throw new Error('accessToken is required'); - } - var url = "".concat(this.baseUrl, "/streaming"); - var streaming = new web_socket_1.default(url, channel, this.accessToken, listId, this.userAgent, this.proxyConfig, this.converter); - process.nextTick(function () { - streaming.start(); - }); - return streaming; - }; - return Client; - }()); - MisskeyAPI.Client = Client; -})(MisskeyAPI || (MisskeyAPI = {})); -exports.default = MisskeyAPI; diff --git a/packages/megalodon/lib/src/misskey/entities/GetAll.d.ts b/packages/megalodon/lib/src/misskey/entities/GetAll.d.ts deleted file mode 100644 index ee06de068e..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/GetAll.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace MisskeyEntity { - type GetAll = { - tutorial: number; - defaultNoteVisibility: 'public' | 'home' | 'followers' | 'specified'; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/GetAll.js b/packages/megalodon/lib/src/misskey/entities/GetAll.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/GetAll.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/accountCache.d.ts b/packages/megalodon/lib/src/misskey/entities/accountCache.d.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/megalodon/lib/src/misskey/entities/accountCache.js b/packages/megalodon/lib/src/misskey/entities/accountCache.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/accountCache.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/announcement.d.ts b/packages/megalodon/lib/src/misskey/entities/announcement.d.ts deleted file mode 100644 index 1d922c2f0a..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/announcement.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -declare namespace MisskeyEntity { - type Announcement = { - id: string; - createdAt: string; - updatedAt: string; - text: string; - title: string; - isRead?: boolean; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/announcement.js b/packages/megalodon/lib/src/misskey/entities/announcement.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/announcement.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/app.d.ts b/packages/megalodon/lib/src/misskey/entities/app.d.ts deleted file mode 100644 index 244e2f8004..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/app.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MisskeyEntity { - type App = { - id: string; - name: string; - callbackUrl: string; - permission: Array; - secret: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/app.js b/packages/megalodon/lib/src/misskey/entities/app.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/app.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/blocking.d.ts b/packages/megalodon/lib/src/misskey/entities/blocking.d.ts deleted file mode 100644 index c4ac3ca101..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/blocking.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Blocking = { - id: string; - createdAt: string; - blockeeId: string; - blockee: UserDetail; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/blocking.js b/packages/megalodon/lib/src/misskey/entities/blocking.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/blocking.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/createdNote.d.ts b/packages/megalodon/lib/src/misskey/entities/createdNote.d.ts deleted file mode 100644 index 42f4d26dfd..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/createdNote.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// -declare namespace MisskeyEntity { - type CreatedNote = { - createdNote: Note; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/createdNote.js b/packages/megalodon/lib/src/misskey/entities/createdNote.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/createdNote.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/emoji.d.ts b/packages/megalodon/lib/src/misskey/entities/emoji.d.ts deleted file mode 100644 index fd87ce5bfd..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/emoji.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MisskeyEntity { - type Emoji = { - name: string; - host: string | null; - url: string; - aliases: Array; - category: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/emoji.js b/packages/megalodon/lib/src/misskey/entities/emoji.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/emoji.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/favorite.d.ts b/packages/megalodon/lib/src/misskey/entities/favorite.d.ts deleted file mode 100644 index be76f6fcef..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/favorite.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Favorite = { - id: string; - createdAt: string; - noteId: string; - note: Note; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/favorite.js b/packages/megalodon/lib/src/misskey/entities/favorite.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/favorite.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/field.d.ts b/packages/megalodon/lib/src/misskey/entities/field.d.ts deleted file mode 100644 index c022c1c01d..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/field.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace MisskeyEntity { - type Field = { - name: string; - value: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/field.js b/packages/megalodon/lib/src/misskey/entities/field.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/field.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/file.d.ts b/packages/megalodon/lib/src/misskey/entities/file.d.ts deleted file mode 100644 index f0281daaf4..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/file.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -declare namespace MisskeyEntity { - type File = { - id: string; - createdAt: string; - name: string; - type: string; - md5: string; - size: number; - isSensitive: boolean; - properties: { - width: number; - height: number; - avgColor: string; - }; - url: string; - thumbnailUrl: string; - comment: string; - blurhash: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/file.js b/packages/megalodon/lib/src/misskey/entities/file.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/file.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/followRequest.d.ts b/packages/megalodon/lib/src/misskey/entities/followRequest.d.ts deleted file mode 100644 index f22595c928..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/followRequest.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// -declare namespace MisskeyEntity { - type FollowRequest = { - id: string; - follower: User; - followee: User; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/followRequest.js b/packages/megalodon/lib/src/misskey/entities/followRequest.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/followRequest.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/follower.d.ts b/packages/megalodon/lib/src/misskey/entities/follower.d.ts deleted file mode 100644 index 50e11286a4..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/follower.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Follower = { - id: string; - createdAt: string; - followeeId: string; - followerId: string; - follower: UserDetail; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/follower.js b/packages/megalodon/lib/src/misskey/entities/follower.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/follower.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/following.d.ts b/packages/megalodon/lib/src/misskey/entities/following.d.ts deleted file mode 100644 index 1538a5e2a6..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/following.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Following = { - id: string; - createdAt: string; - followeeId: string; - followerId: string; - followee: UserDetail; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/following.js b/packages/megalodon/lib/src/misskey/entities/following.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/following.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/hashtag.d.ts b/packages/megalodon/lib/src/misskey/entities/hashtag.d.ts deleted file mode 100644 index 341f7fcb31..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/hashtag.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace MisskeyEntity { - type Hashtag = { - tag: string; - chart: Array; - usersCount: number; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/hashtag.js b/packages/megalodon/lib/src/misskey/entities/hashtag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/hashtag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/list.d.ts b/packages/megalodon/lib/src/misskey/entities/list.d.ts deleted file mode 100644 index 076ebf9f8b..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/list.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace MisskeyEntity { - type List = { - id: string; - createdAt: string; - name: string; - userIds: Array; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/list.js b/packages/megalodon/lib/src/misskey/entities/list.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/list.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/meta.d.ts b/packages/megalodon/lib/src/misskey/entities/meta.d.ts deleted file mode 100644 index ac1fd6fb9a..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/meta.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Meta = { - maintainerName: string; - maintainerEmail: string; - name: string; - version: string; - uri: string; - description: string; - langs: Array; - disableRegistration: boolean; - disableLocalTimeline: boolean; - bannerUrl: string; - maxNoteTextLength: 300; - emojis: Array; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/meta.js b/packages/megalodon/lib/src/misskey/entities/meta.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/meta.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/mute.d.ts b/packages/megalodon/lib/src/misskey/entities/mute.d.ts deleted file mode 100644 index 7028a03b5e..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/mute.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Mute = { - id: string; - createdAt: string; - muteeId: string; - mutee: UserDetail; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/mute.js b/packages/megalodon/lib/src/misskey/entities/mute.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/mute.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/note.d.ts b/packages/megalodon/lib/src/misskey/entities/note.d.ts deleted file mode 100644 index fe3df8c934..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/note.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// -/// -/// -/// -declare namespace MisskeyEntity { - type Note = { - id: string; - createdAt: string; - userId: string; - user: User; - text: string | null; - cw: string | null; - visibility: 'public' | 'home' | 'followers' | 'specified'; - renoteCount: number; - repliesCount: number; - reactions: { - [key: string]: number; - }; - emojis: Array; - fileIds: Array; - files: Array; - replyId: string | null; - renoteId: string | null; - uri?: string; - reply?: Note; - renote?: Note; - viaMobile?: boolean; - tags?: Array; - poll?: Poll; - mentions?: Array; - myReaction?: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/note.js b/packages/megalodon/lib/src/misskey/entities/note.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/note.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/notification.d.ts b/packages/megalodon/lib/src/misskey/entities/notification.d.ts deleted file mode 100644 index dbb86bff64..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/notification.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// -/// -declare namespace MisskeyEntity { - type Notification = { - id: string; - createdAt: string; - type: NotificationType; - userId: string; - user: User; - note?: Note; - reaction?: string; - }; - type NotificationType = string; -} diff --git a/packages/megalodon/lib/src/misskey/entities/notification.js b/packages/megalodon/lib/src/misskey/entities/notification.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/notification.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/poll.d.ts b/packages/megalodon/lib/src/misskey/entities/poll.d.ts deleted file mode 100644 index 22236d5325..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/poll.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace MisskeyEntity { - type Choice = { - text: string; - votes: number; - isVoted: boolean; - }; - type Poll = { - multiple: boolean; - expiresAt: string; - choices: Array; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/poll.js b/packages/megalodon/lib/src/misskey/entities/poll.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/poll.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/reaction.d.ts b/packages/megalodon/lib/src/misskey/entities/reaction.d.ts deleted file mode 100644 index df0a106737..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/reaction.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace MisskeyEntity { - type Reaction = { - id: string; - createdAt: string; - user: User; - url?: string; - type: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/reaction.js b/packages/megalodon/lib/src/misskey/entities/reaction.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/reaction.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/relation.d.ts b/packages/megalodon/lib/src/misskey/entities/relation.d.ts deleted file mode 100644 index fce7a86f00..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/relation.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace MisskeyEntity { - type Relation = { - id: string; - isFollowing: boolean; - hasPendingFollowRequestFromYou: boolean; - hasPendingFollowRequestToYou: boolean; - isFollowed: boolean; - isBlocking: boolean; - isBlocked: boolean; - isMuted: boolean; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/relation.js b/packages/megalodon/lib/src/misskey/entities/relation.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/relation.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/session.d.ts b/packages/megalodon/lib/src/misskey/entities/session.d.ts deleted file mode 100644 index 7aef59d25b..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/session.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace MisskeyEntity { - type Session = { - token: string; - url: string; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/session.js b/packages/megalodon/lib/src/misskey/entities/session.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/session.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/stats.d.ts b/packages/megalodon/lib/src/misskey/entities/stats.d.ts deleted file mode 100644 index 43ca653533..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/stats.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace MisskeyEntity { - type Stats = { - notesCount: number; - originalNotesCount: number; - usersCount: number; - originalUsersCount: number; - instances: number; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/stats.js b/packages/megalodon/lib/src/misskey/entities/stats.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/stats.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/user.d.ts b/packages/megalodon/lib/src/misskey/entities/user.d.ts deleted file mode 100644 index 3f51d64e31..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/user.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// -declare namespace MisskeyEntity { - type User = { - id: string; - name: string; - username: string; - host: string | null; - avatarUrl: string; - avatarColor: string; - emojis: Array; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/user.js b/packages/megalodon/lib/src/misskey/entities/user.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/user.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/userDetail.d.ts b/packages/megalodon/lib/src/misskey/entities/userDetail.d.ts deleted file mode 100644 index eae2b9a3c5..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/userDetail.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// -/// -/// -declare namespace MisskeyEntity { - type UserDetail = { - id: string; - name: string; - username: string; - host: string | null; - avatarUrl: string; - avatarColor: string; - isAdmin: boolean; - isModerator: boolean; - isBot: boolean; - isCat: boolean; - emojis: Array; - createdAt: string; - bannerUrl: string; - bannerColor: string; - isLocked: boolean; - isSilenced: boolean; - isSuspended: boolean; - description: string; - followersCount: number; - followingCount: number; - notesCount: number; - avatarId: string; - bannerId: string; - pinnedNoteIds?: Array; - pinnedNotes?: Array; - fields: Array; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/userDetail.js b/packages/megalodon/lib/src/misskey/entities/userDetail.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/userDetail.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/userDetailMe.d.ts b/packages/megalodon/lib/src/misskey/entities/userDetailMe.d.ts deleted file mode 100644 index 72e9ac604b..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/userDetailMe.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// -/// -/// -declare namespace MisskeyEntity { - type UserDetailMe = { - id: string; - name: string; - username: string; - host: string | null; - avatarUrl: string; - avatarColor: string; - isAdmin: boolean; - isModerator: boolean; - isBot: boolean; - isCat: boolean; - emojis: Array; - createdAt: string; - bannerUrl: string; - bannerColor: string; - isLocked: boolean; - isSilenced: boolean; - isSuspended: boolean; - description: string; - followersCount: number; - followingCount: number; - notesCount: number; - avatarId: string; - bannerId: string; - pinnedNoteIds?: Array; - pinnedNotes?: Array; - fields: Array; - alwaysMarkNsfw: boolean; - lang: string | null; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/userDetailMe.js b/packages/megalodon/lib/src/misskey/entities/userDetailMe.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/userDetailMe.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entities/userkey.d.ts b/packages/megalodon/lib/src/misskey/entities/userkey.d.ts deleted file mode 100644 index a7dfe75c7a..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/userkey.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -declare namespace MisskeyEntity { - type UserKey = { - accessToken: string; - user: User; - }; -} diff --git a/packages/megalodon/lib/src/misskey/entities/userkey.js b/packages/megalodon/lib/src/misskey/entities/userkey.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/misskey/entities/userkey.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/misskey/entity.d.ts b/packages/megalodon/lib/src/misskey/entity.d.ts deleted file mode 100644 index 562970387f..0000000000 --- a/packages/megalodon/lib/src/misskey/entity.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -export default MisskeyEntity; diff --git a/packages/megalodon/lib/src/misskey/entity.js b/packages/megalodon/lib/src/misskey/entity.js deleted file mode 100644 index c8ad2e549b..0000000000 --- a/packages/megalodon/lib/src/misskey/entity.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/megalodon/lib/src/misskey/helpers/accountCache.d.ts b/packages/megalodon/lib/src/misskey/helpers/accountCache.d.ts deleted file mode 100644 index 9d35ad9fa3..0000000000 --- a/packages/megalodon/lib/src/misskey/helpers/accountCache.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -export {}; diff --git a/packages/megalodon/lib/src/misskey/helpers/accountCache.js b/packages/megalodon/lib/src/misskey/helpers/accountCache.js deleted file mode 100644 index c8ad2e549b..0000000000 --- a/packages/megalodon/lib/src/misskey/helpers/accountCache.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/megalodon/lib/src/misskey/notification.d.ts b/packages/megalodon/lib/src/misskey/notification.d.ts deleted file mode 100644 index fe63a8bd6c..0000000000 --- a/packages/megalodon/lib/src/misskey/notification.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import MisskeyEntity from './entity'; -declare namespace MisskeyNotificationType { - const Follow: MisskeyEntity.NotificationType; - const Mention: MisskeyEntity.NotificationType; - const Reply: MisskeyEntity.NotificationType; - const Renote: MisskeyEntity.NotificationType; - const Quote: MisskeyEntity.NotificationType; - const Reaction: MisskeyEntity.NotificationType; - const PollVote: MisskeyEntity.NotificationType; - const ReceiveFollowRequest: MisskeyEntity.NotificationType; - const FollowRequestAccepted: MisskeyEntity.NotificationType; - const GroupInvited: MisskeyEntity.NotificationType; -} -export default MisskeyNotificationType; diff --git a/packages/megalodon/lib/src/misskey/notification.js b/packages/megalodon/lib/src/misskey/notification.js deleted file mode 100644 index 24c36ed695..0000000000 --- a/packages/megalodon/lib/src/misskey/notification.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var MisskeyNotificationType; -(function (MisskeyNotificationType) { - MisskeyNotificationType.Follow = 'follow'; - MisskeyNotificationType.Mention = 'mention'; - MisskeyNotificationType.Reply = 'reply'; - MisskeyNotificationType.Renote = 'renote'; - MisskeyNotificationType.Quote = 'quote'; - MisskeyNotificationType.Reaction = 'favourite'; - MisskeyNotificationType.PollVote = 'pollVote'; - MisskeyNotificationType.ReceiveFollowRequest = 'receiveFollowRequest'; - MisskeyNotificationType.FollowRequestAccepted = 'followRequestAccepted'; - MisskeyNotificationType.GroupInvited = 'groupInvited'; -})(MisskeyNotificationType || (MisskeyNotificationType = {})); -exports.default = MisskeyNotificationType; diff --git a/packages/megalodon/lib/src/misskey/web_socket.d.ts b/packages/megalodon/lib/src/misskey/web_socket.d.ts deleted file mode 100644 index d513d0898c..0000000000 --- a/packages/megalodon/lib/src/misskey/web_socket.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// -import WS from 'ws'; -import { EventEmitter } from 'events'; -import { WebSocketInterface } from '../megalodon'; -import { ProxyConfig } from '../proxy_config'; -import MisskeyAPI from './api_client'; -export default class WebSocket extends EventEmitter implements WebSocketInterface { - url: string; - channel: 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list'; - parser: any; - headers: { - [key: string]: string; - }; - proxyConfig: ProxyConfig | false; - listId: string | null; - private _converter; - private _accessToken; - private _reconnectInterval; - private _reconnectMaxAttempts; - private _reconnectCurrentAttempts; - private _connectionClosed; - private _client; - private _channelID; - private _pongReceivedTimestamp; - private _heartbeatInterval; - private _pongWaiting; - constructor(url: string, channel: 'user' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline' | 'conversation' | 'list', accessToken: string, listId: string | undefined, userAgent: string, proxyConfig: false | ProxyConfig | undefined, converter: MisskeyAPI.Converter); - start(): void; - private baseUrlToHost; - private _startWebSocketConnection; - stop(): void; - private _resetConnection; - private _resetRetryParams; - private _connect; - private _channel; - private _reconnect; - private _clearBinding; - private _bindSocket; - private _setupParser; - private _checkAlive; -} -export declare class Parser extends EventEmitter { - parse(data: WS.Data, isBinary: boolean, channelID: string): void; -} diff --git a/packages/megalodon/lib/src/misskey/web_socket.js b/packages/megalodon/lib/src/misskey/web_socket.js deleted file mode 100644 index e1ad33af6c..0000000000 --- a/packages/megalodon/lib/src/misskey/web_socket.js +++ /dev/null @@ -1,318 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Parser = void 0; -var ws_1 = __importDefault(require("ws")); -var dayjs_1 = __importDefault(require("dayjs")); -var uuid_1 = require("uuid"); -var events_1 = require("events"); -var proxy_config_1 = __importDefault(require("../proxy_config")); -var WebSocket = (function (_super) { - __extends(WebSocket, _super); - function WebSocket(url, channel, accessToken, listId, userAgent, proxyConfig, converter) { - if (proxyConfig === void 0) { proxyConfig = false; } - var _this = _super.call(this) || this; - _this.proxyConfig = false; - _this.listId = null; - _this._client = null; - _this._heartbeatInterval = 60000; - _this._pongWaiting = false; - _this.url = url; - _this.parser = new Parser(); - _this.channel = channel; - _this.headers = { - 'User-Agent': userAgent - }; - if (listId === undefined) { - _this.listId = null; - } - else { - _this.listId = listId; - } - _this.proxyConfig = proxyConfig; - _this._accessToken = accessToken; - _this._reconnectInterval = 10000; - _this._reconnectMaxAttempts = Infinity; - _this._reconnectCurrentAttempts = 0; - _this._connectionClosed = false; - _this._channelID = (0, uuid_1.v4)(); - _this._pongReceivedTimestamp = (0, dayjs_1.default)(); - _this._converter = converter; - return _this; - } - WebSocket.prototype.start = function () { - this._connectionClosed = false; - this._resetRetryParams(); - this._startWebSocketConnection(); - }; - WebSocket.prototype.baseUrlToHost = function (baseUrl) { - return baseUrl.replace('https://', ''); - }; - WebSocket.prototype._startWebSocketConnection = function () { - this._resetConnection(); - this._setupParser(); - this._client = this._connect(); - this._bindSocket(this._client); - }; - WebSocket.prototype.stop = function () { - this._connectionClosed = true; - this._resetConnection(); - this._resetRetryParams(); - }; - WebSocket.prototype._resetConnection = function () { - if (this._client) { - this._client.close(1000); - this._client.removeAllListeners(); - this._client = null; - } - if (this.parser) { - this.parser.removeAllListeners(); - } - }; - WebSocket.prototype._resetRetryParams = function () { - this._reconnectCurrentAttempts = 0; - }; - WebSocket.prototype._connect = function () { - var options = { - headers: this.headers - }; - if (this.proxyConfig) { - options = Object.assign(options, { - agent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - var cli = new ws_1.default("".concat(this.url, "?i=").concat(this._accessToken), options); - return cli; - }; - WebSocket.prototype._channel = function () { - if (!this._client) { - return; - } - switch (this.channel) { - case 'conversation': - this._client.send(JSON.stringify({ - type: 'connect', - body: { - channel: 'main', - id: this._channelID - } - })); - break; - case 'user': - this._client.send(JSON.stringify({ - type: 'connect', - body: { - channel: 'main', - id: this._channelID - } - })); - this._client.send(JSON.stringify({ - type: 'connect', - body: { - channel: 'homeTimeline', - id: this._channelID - } - })); - break; - case 'list': - this._client.send(JSON.stringify({ - type: 'connect', - body: { - channel: 'userList', - id: this._channelID, - params: { - listId: this.listId - } - } - })); - break; - default: - this._client.send(JSON.stringify({ - type: 'connect', - body: { - channel: this.channel, - id: this._channelID - } - })); - break; - } - }; - WebSocket.prototype._reconnect = function () { - var _this = this; - setTimeout(function () { - if (_this._client && _this._client.readyState === ws_1.default.CONNECTING) { - return; - } - if (_this._reconnectCurrentAttempts < _this._reconnectMaxAttempts) { - _this._reconnectCurrentAttempts++; - _this._clearBinding(); - if (_this._client) { - _this._client.terminate(); - } - console.log('Reconnecting'); - _this._client = _this._connect(); - _this._bindSocket(_this._client); - } - }, this._reconnectInterval); - }; - WebSocket.prototype._clearBinding = function () { - if (this._client) { - this._client.removeAllListeners('close'); - this._client.removeAllListeners('pong'); - this._client.removeAllListeners('open'); - this._client.removeAllListeners('message'); - this._client.removeAllListeners('error'); - } - }; - WebSocket.prototype._bindSocket = function (client) { - var _this = this; - client.on('close', function (code, _reason) { - if (code === 1000) { - _this.emit('close', {}); - } - else { - console.log("Closed connection with ".concat(code)); - if (!_this._connectionClosed) { - _this._reconnect(); - } - } - }); - client.on('pong', function () { - _this._pongWaiting = false; - _this.emit('pong', {}); - _this._pongReceivedTimestamp = (0, dayjs_1.default)(); - setTimeout(function () { return _this._checkAlive(_this._pongReceivedTimestamp); }, _this._heartbeatInterval); - }); - client.on('open', function () { - _this.emit('connect', {}); - _this._channel(); - setTimeout(function () { - client.ping(''); - }, 10000); - }); - client.on('message', function (data, isBinary) { - _this.parser.parse(data, isBinary, _this._channelID); - }); - client.on('error', function (err) { - _this.emit('error', err); - }); - }; - WebSocket.prototype._setupParser = function () { - var _this = this; - this.parser.on('update', function (note) { - _this.emit('update', _this._converter.note(note, _this.baseUrlToHost(_this.url))); - }); - this.parser.on('notification', function (notification) { - _this.emit('notification', _this._converter.notification(notification, _this.baseUrlToHost(_this.url))); - }); - this.parser.on('conversation', function (note) { - _this.emit('conversation', _this._converter.noteToConversation(note, _this.baseUrlToHost(_this.url))); - }); - this.parser.on('error', function (err) { - _this.emit('parser-error', err); - }); - }; - WebSocket.prototype._checkAlive = function (timestamp) { - var _this = this; - var now = (0, dayjs_1.default)(); - if (now.diff(timestamp) > this._heartbeatInterval - 1000 && !this._connectionClosed) { - if (this._client && this._client.readyState !== ws_1.default.CONNECTING) { - this._pongWaiting = true; - this._client.ping(''); - setTimeout(function () { - if (_this._pongWaiting) { - _this._pongWaiting = false; - _this._reconnect(); - } - }, 10000); - } - } - }; - return WebSocket; -}(events_1.EventEmitter)); -exports.default = WebSocket; -var Parser = (function (_super) { - __extends(Parser, _super); - function Parser() { - return _super !== null && _super.apply(this, arguments) || this; - } - Parser.prototype.parse = function (data, isBinary, channelID) { - var message = isBinary ? data : data.toString(); - if (typeof message !== 'string') { - this.emit('heartbeat', {}); - return; - } - if (message === '') { - this.emit('heartbeat', {}); - return; - } - var obj; - var body; - try { - obj = JSON.parse(message); - if (obj.type !== 'channel') { - return; - } - if (!obj.body) { - return; - } - body = obj.body; - if (body.id !== channelID) { - return; - } - } - catch (err) { - this.emit('error', new Error("Error parsing websocket reply: ".concat(message, ", error message: ").concat(err))); - return; - } - switch (body.type) { - case 'note': - this.emit('update', body.body); - break; - case 'notification': - this.emit('notification', body.body); - break; - case 'mention': { - var note = body.body; - if (note.visibility === 'specified') { - this.emit('conversation', note); - } - break; - } - case 'renote': - case 'followed': - case 'follow': - case 'unfollow': - case 'receiveFollowRequest': - case 'meUpdated': - case 'readAllNotifications': - case 'readAllUnreadSpecifiedNotes': - case 'readAllAntennas': - case 'readAllUnreadMentions': - case 'unreadNotification': - break; - default: - this.emit('error', new Error("Unknown event has received: ".concat(JSON.stringify(body)))); - break; - } - }; - return Parser; -}(events_1.EventEmitter)); -exports.Parser = Parser; diff --git a/packages/megalodon/lib/src/notification.d.ts b/packages/megalodon/lib/src/notification.d.ts deleted file mode 100644 index ad90622b7c..0000000000 --- a/packages/megalodon/lib/src/notification.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Entity from './entity'; -declare namespace NotificationType { - const Follow: Entity.NotificationType; - const Favourite: Entity.NotificationType; - const Reblog: Entity.NotificationType; - const Mention: Entity.NotificationType; - const EmojiReaction: Entity.NotificationType; - const FollowRequest: Entity.NotificationType; - const Status: Entity.NotificationType; - const PollVote: Entity.NotificationType; - const PollExpired: Entity.NotificationType; -} -export default NotificationType; diff --git a/packages/megalodon/lib/src/notification.js b/packages/megalodon/lib/src/notification.js deleted file mode 100644 index 048a66e129..0000000000 --- a/packages/megalodon/lib/src/notification.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var NotificationType; -(function (NotificationType) { - NotificationType.Follow = 'follow'; - NotificationType.Favourite = 'favourite'; - NotificationType.Reblog = 'reblog'; - NotificationType.Mention = 'mention'; - NotificationType.EmojiReaction = 'emoji_reaction'; - NotificationType.FollowRequest = 'follow_request'; - NotificationType.Status = 'status'; - NotificationType.PollVote = 'poll_vote'; - NotificationType.PollExpired = 'poll_expired'; -})(NotificationType || (NotificationType = {})); -exports.default = NotificationType; diff --git a/packages/megalodon/lib/src/oauth.d.ts b/packages/megalodon/lib/src/oauth.d.ts deleted file mode 100644 index 0637fd5d83..0000000000 --- a/packages/megalodon/lib/src/oauth.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -declare namespace OAuth { - type AppDataFromServer = { - id: string; - name: string; - website: string | null; - redirect_uri: string; - client_id: string; - client_secret: string; - }; - type TokenDataFromServer = { - access_token: string; - token_type: string; - scope: string; - created_at: number; - expires_in: number | null; - refresh_token: string | null; - }; - class AppData { - id: string; - name: string; - website: string | null; - redirect_uri: string; - client_id: string; - client_secret: string; - url: string | null; - session_token: string | null; - constructor(id: string, name: string, website: string | null, redirect_uri: string, client_id: string, client_secret: string); - static from(raw: AppDataFromServer): AppData; - get redirectUri(): string; - get clientId(): string; - get clientSecret(): string; - } - class TokenData { - access_token: string; - token_type: string; - created_at: number; - expires_in: number | null; - refresh_token: string | null; - _scope: string; - constructor(access_token: string, token_type: string, scope: string, created_at: number, expires_in?: number | null, refresh_token?: string | null); - static from(raw: TokenDataFromServer): TokenData; - get accessToken(): string; - get tokenType(): string; - get scope(): string; - get createdAt(): number; - get expiresIn(): number | null; - get refreshToken(): string | null; - } -} -export default OAuth; diff --git a/packages/megalodon/lib/src/oauth.js b/packages/megalodon/lib/src/oauth.js deleted file mode 100644 index 80b5821595..0000000000 --- a/packages/megalodon/lib/src/oauth.js +++ /dev/null @@ -1,103 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var OAuth; -(function (OAuth) { - var AppData = (function () { - function AppData(id, name, website, redirect_uri, client_id, client_secret) { - this.id = id; - this.name = name; - this.website = website; - this.redirect_uri = redirect_uri; - this.client_id = client_id; - this.client_secret = client_secret; - this.url = null; - this.session_token = null; - } - AppData.from = function (raw) { - return new this(raw.id, raw.name, raw.website, raw.redirect_uri, raw.client_id, raw.client_secret); - }; - Object.defineProperty(AppData.prototype, "redirectUri", { - get: function () { - return this.redirect_uri; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(AppData.prototype, "clientId", { - get: function () { - return this.client_id; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(AppData.prototype, "clientSecret", { - get: function () { - return this.client_secret; - }, - enumerable: false, - configurable: true - }); - return AppData; - }()); - OAuth.AppData = AppData; - var TokenData = (function () { - function TokenData(access_token, token_type, scope, created_at, expires_in, refresh_token) { - if (expires_in === void 0) { expires_in = null; } - if (refresh_token === void 0) { refresh_token = null; } - this.access_token = access_token; - this.token_type = token_type; - this.created_at = created_at; - this.expires_in = expires_in; - this.refresh_token = refresh_token; - this._scope = scope; - } - TokenData.from = function (raw) { - return new this(raw.access_token, raw.token_type, raw.scope, raw.created_at, raw.expires_in, raw.refresh_token); - }; - Object.defineProperty(TokenData.prototype, "accessToken", { - get: function () { - return this.access_token; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TokenData.prototype, "tokenType", { - get: function () { - return this.token_type; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TokenData.prototype, "scope", { - get: function () { - return this._scope; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TokenData.prototype, "createdAt", { - get: function () { - return this.created_at; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TokenData.prototype, "expiresIn", { - get: function () { - return this.expires_in; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(TokenData.prototype, "refreshToken", { - get: function () { - return this.refresh_token; - }, - enumerable: false, - configurable: true - }); - return TokenData; - }()); - OAuth.TokenData = TokenData; -})(OAuth || (OAuth = {})); -exports.default = OAuth; diff --git a/packages/megalodon/lib/src/parser.d.ts b/packages/megalodon/lib/src/parser.d.ts deleted file mode 100644 index b07425a370..0000000000 --- a/packages/megalodon/lib/src/parser.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -import { EventEmitter } from 'events'; -export declare class Parser extends EventEmitter { - private message; - constructor(); - parse(chunk: string): void; -} diff --git a/packages/megalodon/lib/src/parser.js b/packages/megalodon/lib/src/parser.js deleted file mode 100644 index e3eba4964f..0000000000 --- a/packages/megalodon/lib/src/parser.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Parser = void 0; -var events_1 = require("events"); -var Parser = (function (_super) { - __extends(Parser, _super); - function Parser() { - var _this = _super.call(this) || this; - _this.message = ''; - return _this; - } - Parser.prototype.parse = function (chunk) { - if (chunk === ':thump\n') { - this.emit('heartbeat', {}); - return; - } - this.message += chunk; - chunk = this.message; - var size = chunk.length; - var start = 0; - var offset = 0; - var curr; - var next; - while (offset < size) { - curr = chunk[offset]; - next = chunk[offset + 1]; - if (curr === '\n' && next === '\n') { - var piece = chunk.slice(start, offset); - offset += 2; - start = offset; - if (!piece.length) - continue; - var root = piece.split('\n'); - if (root.length !== 2) - continue; - var event_1 = root[0].substr(7); - var data = root[1].substr(6); - var jsonObj = {}; - try { - jsonObj = JSON.parse(data); - } - catch (err) { - if (event_1 !== 'delete') { - this.emit('error', new Error("Error parsing API reply: '".concat(piece, "', error message: '").concat(err, "'"))); - continue; - } - } - switch (event_1) { - case 'update': - this.emit('update', jsonObj); - break; - case 'notification': - this.emit('notification', jsonObj); - break; - case 'conversation': - this.emit('conversation', jsonObj); - break; - case 'delete': - this.emit('delete', data); - break; - default: - this.emit('error', new Error("Unknown event has received: ".concat(event_1))); - continue; - } - } - offset++; - } - this.message = chunk.slice(start, size); - }; - return Parser; -}(events_1.EventEmitter)); -exports.Parser = Parser; diff --git a/packages/megalodon/lib/src/pleroma.d.ts b/packages/megalodon/lib/src/pleroma.d.ts deleted file mode 100644 index cff9fc8f3f..0000000000 --- a/packages/megalodon/lib/src/pleroma.d.ts +++ /dev/null @@ -1,367 +0,0 @@ -import PleromaAPI from './pleroma/api_client'; -import WebSocket from './pleroma/web_socket'; -import { MegalodonInterface } from './megalodon'; -import Response from './response'; -import Entity from './entity'; -import { ProxyConfig } from './proxy_config'; -import OAuth from './oauth'; -export default class Pleroma implements MegalodonInterface { - client: PleromaAPI.Interface; - baseUrl: string; - constructor(baseUrl: string, accessToken?: string | null, userAgent?: string | null, proxyConfig?: ProxyConfig | false); - cancel(): void; - registerApp(client_name: string, options: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - createApp(client_name: string, options: Partial<{ - scopes: Array; - redirect_uris: string; - website: string; - }>): Promise; - generateAuthUrl(clientId: string, clientSecret: string, options: Partial<{ - scope: Array; - redirect_uri: string; - }>): Promise; - verifyAppCredentials(): Promise>; - fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string): Promise; - refreshToken(client_id: string, client_secret: string, refresh_token: string): Promise; - revokeToken(client_id: string, client_secret: string, token: string): Promise>; - registerAccount(username: string, email: string, password: string, agreement: boolean, locale: string, reason?: string | null): Promise>; - verifyAccountCredentials(): Promise>; - updateCredentials(options?: { - discoverable?: boolean; - bot?: boolean; - display_name?: string; - note?: string; - avatar?: string; - header?: string; - locked?: boolean; - source?: { - privacy?: string; - sensitive?: boolean; - language?: string; - }; - fields_attributes?: Array<{ - name: string; - value: string; - }>; - }): Promise>; - getAccount(id: string): Promise>; - getAccountStatuses(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - pinned?: boolean; - exclude_replies?: boolean; - exclude_reblogs?: boolean; - only_media?: boolean; - }): Promise>>; - subscribeAccount(id: string): Promise>; - unsubscribeAccount(id: string): Promise>; - getAccountFavourites(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getAccountFollowers(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getAccountFollowing(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getAccountLists(id: string): Promise>>; - getIdentityProof(id: string): Promise>>; - followAccount(id: string, options?: { - reblog?: boolean; - }): Promise>; - unfollowAccount(id: string): Promise>; - blockAccount(id: string): Promise>; - unblockAccount(id: string): Promise>; - muteAccount(id: string, notifications?: boolean): Promise>; - unmuteAccount(id: string): Promise>; - pinAccount(id: string): Promise>; - unpinAccount(id: string): Promise>; - getRelationship(id: string): Promise>; - getRelationships(ids: Array): Promise>>; - searchAccount(q: string, options?: { - following?: boolean; - resolve?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getBookmarks(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getFavourites(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getMutes(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - getDomainBlocks(options?: { - limit?: number; - max_id?: string; - min_id?: string; - }): Promise>>; - blockDomain(domain: string): Promise>; - unblockDomain(domain: string): Promise>; - getFilters(): Promise>>; - getFilter(id: string): Promise>; - createFilter(phrase: string, context: Array, options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - updateFilter(id: string, phrase: string, context: Array, options?: { - irreversible?: boolean; - whole_word?: boolean; - expires_in?: string; - }): Promise>; - deleteFilter(id: string): Promise>; - report(account_id: string, comment: string, options?: { - status_ids?: Array; - forward?: boolean; - }): Promise>; - getFollowRequests(limit?: number): Promise>>; - acceptFollowRequest(id: string): Promise>; - rejectFollowRequest(id: string): Promise>; - getEndorsements(options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - getFeaturedTags(): Promise>>; - getAccountFeaturedTags(id: string): Promise>>; - createFeaturedTag(name: string): Promise>; - deleteFeaturedTag(id: string): Promise>; - getSuggestedTags(): Promise>>; - getPreferences(): Promise>; - getSuggestions(limit?: number): Promise>>; - getTag(id: string): Promise>; - followTag(id: string): Promise>; - unfollowTag(id: string): Promise>; - postStatus(status: string, options: { - media_ids?: Array; - poll?: { - options: Array; - expires_in: number; - multiple?: boolean; - hide_totals?: boolean; - }; - in_reply_to_id?: string; - sensitive?: boolean; - spoiler_text?: string; - visibility?: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at?: string; - language?: string; - }): Promise>; - getStatus(id: string): Promise>; - editStatus(id: string, options: { - status?: string; - spoiler_text?: string; - sensitive?: boolean; - media_ids?: Array; - poll?: { - options?: Array; - expires_in?: number; - multiple?: boolean; - hide_totals?: boolean; - }; - }): Promise>; - deleteStatus(id: string): Promise>; - getStatusContext(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>; - getStatusRebloggedBy(id: string): Promise>>; - getStatusFavouritedBy(id: string): Promise>>; - favouriteStatus(id: string): Promise>; - unfavouriteStatus(id: string): Promise>; - reblogStatus(id: string): Promise>; - unreblogStatus(id: string): Promise>; - bookmarkStatus(id: string): Promise>; - unbookmarkStatus(id: string): Promise>; - muteStatus(id: string): Promise>; - unmuteStatus(id: string): Promise>; - pinStatus(id: string): Promise>; - unpinStatus(id: string): Promise>; - uploadMedia(file: any, options?: { - description?: string; - focus?: string; - }): Promise>; - getMedia(id: string): Promise>; - updateMedia(id: string, options?: { - file?: any; - description?: string; - focus?: string; - }): Promise>; - getPoll(id: string): Promise>; - votePoll(id: string, choices: Array): Promise>; - getScheduledStatuses(options?: { - limit?: number | null; - max_id?: string | null; - since_id?: string | null; - min_id?: string | null; - }): Promise>>; - getScheduledStatus(id: string): Promise>; - scheduleStatus(id: string, scheduled_at?: string | null): Promise>; - cancelScheduledStatus(id: string): Promise>; - getPublicTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getLocalTimeline(options?: { - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getTagTimeline(hashtag: string, options?: { - local?: boolean; - only_media?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getHomeTimeline(options?: { - local?: boolean; - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getListTimeline(list_id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - getConversationTimeline(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - }): Promise>>; - deleteConversation(id: string): Promise>; - readConversation(id: string): Promise>; - getLists(): Promise>>; - getList(id: string): Promise>; - createList(title: string): Promise>; - updateList(id: string, title: string): Promise>; - deleteList(id: string): Promise>; - getAccountsInList(id: string, options?: { - limit?: number; - max_id?: string; - since_id?: string; - }): Promise>>; - addAccountsToList(id: string, account_ids: Array): Promise>; - deleteAccountsFromList(id: string, account_ids: Array): Promise>; - getMarkers(timeline: Array): Promise>; - saveMarkers(options?: { - home?: { - last_read_id: string; - }; - notifications?: { - last_read_id: string; - }; - }): Promise>; - getNotifications(options?: { - limit?: number; - max_id?: string; - since_id?: string; - min_id?: string; - exclude_types?: Array; - account_id?: string; - }): Promise>>; - getNotification(id: string): Promise>; - dismissNotifications(): Promise>; - dismissNotification(id: string): Promise>; - readNotifications(options: { - id?: string; - max_id?: string; - }): Promise>>; - subscribePushNotification(subscription: { - endpoint: string; - keys: { - p256dh: string; - auth: string; - }; - }, data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - getPushSubscription(): Promise>; - updatePushSubscription(data?: { - alerts: { - follow?: boolean; - favourite?: boolean; - reblog?: boolean; - mention?: boolean; - poll?: boolean; - }; - } | null): Promise>; - deletePushSubscription(): Promise>; - search(q: string, type: 'accounts' | 'hashtags' | 'statuses', options?: { - limit?: number; - max_id?: string; - min_id?: string; - resolve?: boolean; - offset?: number; - following?: boolean; - account_id?: string; - exclude_unreviewed?: boolean; - }): Promise>; - getInstance(): Promise>; - getInstancePeers(): Promise>>; - getInstanceActivity(): Promise>>; - getInstanceTrends(limit?: number | null): Promise>>; - getInstanceDirectory(options?: { - limit?: number; - offset?: number; - order?: 'active' | 'new'; - local?: boolean; - }): Promise>>; - getInstanceCustomEmojis(): Promise>>; - getInstanceAnnouncements(with_dismissed?: boolean | null): Promise>>; - dismissInstanceAnnouncement(id: string): Promise>; - createEmojiReaction(id: string, emoji: string): Promise>; - deleteEmojiReaction(id: string, emoji: string): Promise>; - getEmojiReactions(id: string): Promise>>; - getEmojiReaction(id: string, emoji: string): Promise>; - userSocket(): WebSocket; - publicSocket(): WebSocket; - localSocket(): WebSocket; - tagSocket(tag: string): WebSocket; - listSocket(list_id: string): WebSocket; - directSocket(): WebSocket; -} diff --git a/packages/megalodon/lib/src/pleroma.js b/packages/megalodon/lib/src/pleroma.js deleted file mode 100644 index 2521800ee4..0000000000 --- a/packages/megalodon/lib/src/pleroma.js +++ /dev/null @@ -1,2357 +0,0 @@ -"use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var oauth_1 = require("oauth"); -var form_data_1 = __importDefault(require("form-data")); -var api_client_1 = __importDefault(require("./pleroma/api_client")); -var megalodon_1 = require("./megalodon"); -var default_1 = require("./default"); -var oauth_2 = __importDefault(require("./oauth")); -var Pleroma = (function () { - function Pleroma(baseUrl, accessToken, userAgent, proxyConfig) { - if (accessToken === void 0) { accessToken = null; } - if (userAgent === void 0) { userAgent = default_1.DEFAULT_UA; } - if (proxyConfig === void 0) { proxyConfig = false; } - var token = ''; - if (accessToken) { - token = accessToken; - } - var agent = default_1.DEFAULT_UA; - if (userAgent) { - agent = userAgent; - } - this.client = new api_client_1.default.Client(baseUrl, token, agent, proxyConfig); - this.baseUrl = baseUrl; - } - Pleroma.prototype.cancel = function () { - return this.client.cancel(); - }; - Pleroma.prototype.registerApp = function (client_name, options) { - return __awaiter(this, void 0, void 0, function () { - var scopes; - var _this = this; - return __generator(this, function (_a) { - scopes = options.scopes || default_1.DEFAULT_SCOPE; - return [2, this.createApp(client_name, options).then(function (appData) { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.generateAuthUrl(appData.client_id, appData.client_secret, { - scope: scopes, - redirect_uri: appData.redirect_uri - }).then(function (url) { - appData.url = url; - return appData; - })]; - }); - }); })]; - }); - }); - }; - Pleroma.prototype.createApp = function (client_name, options) { - return __awaiter(this, void 0, void 0, function () { - var scopes, redirect_uris, params; - return __generator(this, function (_a) { - scopes = options.scopes || default_1.DEFAULT_SCOPE; - redirect_uris = options.redirect_uris || default_1.NO_REDIRECT; - params = { - client_name: client_name, - redirect_uris: redirect_uris, - scopes: scopes.join(' ') - }; - if (options.website) - params.website = options.website; - return [2, this.client - .post('/api/v1/apps', params) - .then(function (res) { return oauth_2.default.AppData.from(res.data); })]; - }); - }); - }; - Pleroma.prototype.generateAuthUrl = function (clientId, clientSecret, options) { - var _this = this; - var scope = options.scope || default_1.DEFAULT_SCOPE; - var redirect_uri = options.redirect_uri || default_1.NO_REDIRECT; - return new Promise(function (resolve) { - var oauth = new oauth_1.OAuth2(clientId, clientSecret, _this.baseUrl, undefined, '/oauth/token'); - var url = oauth.getAuthorizeUrl({ - redirect_uri: redirect_uri, - response_type: 'code', - client_id: clientId, - scope: scope.join(' ') - }); - resolve(url); - }); - }; - Pleroma.prototype.verifyAppCredentials = function () { - return this.client.get('/api/v1/apps/verify_credentials'); - }; - Pleroma.prototype.fetchAccessToken = function (client_id, client_secret, code, redirect_uri) { - if (redirect_uri === void 0) { redirect_uri = default_1.NO_REDIRECT; } - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (!client_id) { - throw new Error('client_id is required'); - } - return [2, this.client - .post('/oauth/token', { - client_id: client_id, - client_secret: client_secret, - code: code, - redirect_uri: redirect_uri, - grant_type: 'authorization_code' - }) - .then(function (res) { return oauth_2.default.TokenData.from(res.data); })]; - }); - }); - }; - Pleroma.prototype.refreshToken = function (client_id, client_secret, refresh_token) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/oauth/token', { - client_id: client_id, - client_secret: client_secret, - refresh_token: refresh_token, - grant_type: 'refresh_token' - }) - .then(function (res) { return oauth_2.default.TokenData.from(res.data); })]; - }); - }); - }; - Pleroma.prototype.revokeToken = function (client_id, client_secret, token) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post('/oauth/revoke', { - client_id: client_id, - client_secret: client_secret, - token: token - })]; - }); - }); - }; - Pleroma.prototype.registerAccount = function (username, email, password, agreement, locale, reason) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - username: username, - email: email, - password: password, - agreement: agreement, - locale: locale - }; - if (reason) { - params = Object.assign(params, { - reason: reason - }); - } - return [2, this.client.post('/api/v1/accounts', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.token(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.verifyAccountCredentials = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/accounts/verify_credentials').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.account(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.updateCredentials = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.discoverable !== undefined) { - params = Object.assign(params, { - discoverable: options.discoverable - }); - } - if (options.bot !== undefined) { - params = Object.assign(params, { - bot: options.bot - }); - } - if (options.display_name) { - params = Object.assign(params, { - display_name: options.display_name - }); - } - if (options.note) { - params = Object.assign(params, { - note: options.note - }); - } - if (options.avatar) { - params = Object.assign(params, { - avatar: options.avatar - }); - } - if (options.header) { - params = Object.assign(params, { - header: options.header - }); - } - if (options.locked !== undefined) { - params = Object.assign(params, { - locked: options.locked - }); - } - if (options.source) { - params = Object.assign(params, { - source: options.source - }); - } - if (options.fields_attributes) { - params = Object.assign(params, { - fields_attributes: options.fields_attributes - }); - } - } - return [2, this.client.patch('/api/v1/accounts/update_credentials', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.account(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.account(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccountStatuses = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.pinned) { - params = Object.assign(params, { - pinned: options.pinned - }); - } - if (options.exclude_replies) { - params = Object.assign(params, { - exclude_replies: options.exclude_replies - }); - } - if (options.exclude_reblogs) { - params = Object.assign(params, { - exclude_reblogs: options.exclude_reblogs - }); - } - if (options.only_media) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - } - return [2, this.client.get("/api/v1/accounts/".concat(id, "/statuses"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.subscribeAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/pleroma/accounts/".concat(id, "/subscribe")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unsubscribeAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/pleroma/accounts/".concat(id, "/unsubscribe")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccountFavourites = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get("/api/v1/pleroma/accounts/".concat(id, "/favourites"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccountFollowers = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get("/api/v1/accounts/".concat(id, "/followers"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccountFollowing = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get("/api/v1/accounts/".concat(id, "/following"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccountLists = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id, "/lists")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (l) { return api_client_1.default.Converter.list(l); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getIdentityProof = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id, "/identity_proofs")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (i) { return api_client_1.default.Converter.identity_proof(i); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.followAccount = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.reblog !== undefined) { - params = Object.assign(params, { - reblog: options.reblog - }); - } - } - return [2, this.client.post("/api/v1/accounts/".concat(id, "/follow"), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unfollowAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unfollow")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.blockAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/block")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unblockAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unblock")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.muteAccount = function (id, notifications) { - if (notifications === void 0) { notifications = true; } - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post("/api/v1/accounts/".concat(id, "/mute"), { - notifications: notifications - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unmuteAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unmute")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.pinAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/pin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unpinAccount = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/accounts/".concat(id, "/unpin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getRelationship = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .get('/api/v1/accounts/relationships', { - id: [id] - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data[0]) - }); - })]; - }); - }); - }; - Pleroma.prototype.getRelationships = function (ids) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .get('/api/v1/accounts/relationships', { - id: ids - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (r) { return api_client_1.default.Converter.relationship(r); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.searchAccount = function (q, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { q: q }; - if (options) { - if (options.following !== undefined && options.following !== null) { - params = Object.assign(params, { - following: options.following - }); - } - if (options.resolve !== undefined && options.resolve !== null) { - params = Object.assign(params, { - resolve: options.resolve - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/accounts/search', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getBookmarks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - } - return [2, this.client.get('/api/v1/bookmarks', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getFavourites = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/favourites', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getMutes = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/mutes', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getBlocks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/blocks', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getDomainBlocks = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/domain_blocks', params)]; - }); - }); - }; - Pleroma.prototype.blockDomain = function (domain) { - return this.client.post('/api/v1/domain_blocks', { - domain: domain - }); - }; - Pleroma.prototype.unblockDomain = function (domain) { - return this.client.del('/api/v1/domain_blocks', { - domain: domain - }); - }; - Pleroma.prototype.getFilters = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/filters').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return api_client_1.default.Converter.filter(f); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getFilter = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/filters/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.createFilter = function (phrase, context, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - phrase: phrase, - context: context - }; - if (options) { - if (options.irreversible !== undefined) { - params = Object.assign(params, { - irreversible: options.irreversible - }); - } - if (options.whole_word !== undefined) { - params = Object.assign(params, { - whole_word: options.whole_word - }); - } - if (options.expires_in) { - params = Object.assign(params, { - expires_in: options.expires_in - }); - } - } - return [2, this.client.post('/api/v1/filters', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.updateFilter = function (id, phrase, context, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - phrase: phrase, - context: context - }; - if (options) { - if (options.irreversible !== undefined) { - params = Object.assign(params, { - irreversible: options.irreversible - }); - } - if (options.whole_word !== undefined) { - params = Object.assign(params, { - whole_word: options.whole_word - }); - } - if (options.expires_in) { - params = Object.assign(params, { - expires_in: options.expires_in - }); - } - } - return [2, this.client.put("/api/v1/filters/".concat(id), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.deleteFilter = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.del("/api/v1/filters/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.filter(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.report = function (account_id, comment, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - account_id: account_id, - comment: comment - }; - if (options) { - if (options.status_ids) { - params = Object.assign(params, { - status_ids: options.status_ids - }); - } - if (options.forward !== undefined) { - params = Object.assign(params, { - forward: options.forward - }); - } - } - return [2, this.client.post('/api/v1/reports', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.report(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getFollowRequests = function (limit) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (limit) { - return [2, this.client - .get('/api/v1/follow_requests', { - limit: limit - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - else { - return [2, this.client.get('/api/v1/follow_requests').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - return [2]; - }); - }); - }; - Pleroma.prototype.acceptFollowRequest = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/follow_requests/".concat(id, "/authorize")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.rejectFollowRequest = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/follow_requests/".concat(id, "/reject")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.relationship(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getEndorsements = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get('/api/v1/endorsements', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getFeaturedTags = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/featured_tags').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return api_client_1.default.Converter.featured_tag(f); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getAccountFeaturedTags = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/accounts/".concat(id, "/featured_tags")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (f) { return api_client_1.default.Converter.featured_tag(f); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.createFeaturedTag = function (name) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/v1/featured_tags', { - name: name - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.featured_tag(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.deleteFeaturedTag = function (id) { - return this.client.del("/api/v1/featured_tags/".concat(id)); - }; - Pleroma.prototype.getSuggestedTags = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/featured_tags/suggestions').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (t) { return api_client_1.default.Converter.tag(t); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getPreferences = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/preferences').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.preferences(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getSuggestions = function (limit) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (limit) { - return [2, this.client - .get('/api/v1/suggestions', { - limit: limit - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - else { - return [2, this.client.get('/api/v1/suggestions').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - } - return [2]; - }); - }); - }; - Pleroma.prototype.getTag = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/tags/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.tag(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.followTag = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/tags/".concat(id, "/follow")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.tag(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unfollowTag = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/tags/".concat(id, "/unfollow")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.tag(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.postStatus = function (status, options) { - return __awaiter(this, void 0, void 0, function () { - var params, pollParam; - return __generator(this, function (_a) { - params = { - status: status - }; - if (options) { - if (options.media_ids) { - params = Object.assign(params, { - media_ids: options.media_ids - }); - } - if (options.poll) { - pollParam = { - options: options.poll.options, - expires_in: options.poll.expires_in - }; - if (options.poll.multiple !== undefined) { - pollParam = Object.assign(pollParam, { - multiple: options.poll.multiple - }); - } - if (options.poll.hide_totals !== undefined) { - pollParam = Object.assign(pollParam, { - hide_totals: options.poll.hide_totals - }); - } - params = Object.assign(params, { - poll: pollParam - }); - } - if (options.in_reply_to_id) { - params = Object.assign(params, { - in_reply_to_id: options.in_reply_to_id - }); - } - if (options.sensitive !== undefined) { - params = Object.assign(params, { - sensitive: options.sensitive - }); - } - if (options.spoiler_text) { - params = Object.assign(params, { - spoiler_text: options.spoiler_text - }); - } - if (options.visibility) { - params = Object.assign(params, { - visibility: options.visibility - }); - } - if (options.scheduled_at) { - params = Object.assign(params, { - scheduled_at: options.scheduled_at - }); - } - if (options.language) { - params = Object.assign(params, { - language: options.language - }); - } - } - return [2, this.client.post('/api/v1/statuses', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/statuses/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.editStatus = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params, pollParam; - return __generator(this, function (_a) { - params = {}; - if (options.status) { - params = Object.assign(params, { - status: options.status - }); - } - if (options.spoiler_text) { - params = Object.assign(params, { - spoiler_text: options.spoiler_text - }); - } - if (options.sensitive) { - params = Object.assign(params, { - sensitive: options.sensitive - }); - } - if (options.media_ids) { - params = Object.assign(params, { - media_ids: options.media_ids - }); - } - if (options.poll) { - pollParam = {}; - if (options.poll.options !== undefined) { - pollParam = Object.assign(pollParam, { - options: options.poll.options - }); - } - if (options.poll.expires_in !== undefined) { - pollParam = Object.assign(pollParam, { - expires_in: options.poll.expires_in - }); - } - if (options.poll.multiple !== undefined) { - pollParam = Object.assign(pollParam, { - multiple: options.poll.multiple - }); - } - if (options.poll.hide_totals !== undefined) { - pollParam = Object.assign(pollParam, { - hide_totals: options.poll.hide_totals - }); - } - params = Object.assign(params, { - poll: pollParam - }); - } - return [2, this.client.put("/api/v1/statuses/".concat(id), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.deleteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.del("/api/v1/statuses/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getStatusContext = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get("/api/v1/statuses/".concat(id, "/context"), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.context(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getStatusRebloggedBy = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/statuses/".concat(id, "/reblogged_by")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getStatusFavouritedBy = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/statuses/".concat(id, "/favourited_by")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.favouriteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/favourite")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unfavouriteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unfavourite")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.reblogStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/reblog")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unreblogStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unreblog")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.bookmarkStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/bookmark")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unbookmarkStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unbookmark")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.muteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/mute")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unmuteStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unmute")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.pinStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/pin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.unpinStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/statuses/".concat(id, "/unpin")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.uploadMedia = function (file, options) { - return __awaiter(this, void 0, void 0, function () { - var formData; - return __generator(this, function (_a) { - formData = new form_data_1.default(); - formData.append('file', file); - if (options) { - if (options.description) { - formData.append('description', options.description); - } - if (options.focus) { - formData.append('focus', options.focus); - } - } - return [2, this.client.postForm('/api/v2/media', formData).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.async_attachment(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getMedia = function (id) { - return __awaiter(this, void 0, void 0, function () { - var res; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.client.get("/api/v1/media/".concat(id))]; - case 1: - res = _a.sent(); - return [2, Object.assign(res, { - data: api_client_1.default.Converter.attachment(res.data) - })]; - } - }); - }); - }; - Pleroma.prototype.updateMedia = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var formData; - return __generator(this, function (_a) { - formData = new form_data_1.default(); - if (options) { - if (options.file) { - formData.append('file', options.file); - } - if (options.description) { - formData.append('description', options.description); - } - if (options.focus) { - formData.append('focus', options.focus); - } - } - return [2, this.client.putForm("/api/v1/media/".concat(id), formData).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.attachment(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getPoll = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/polls/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.poll(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.votePoll = function (id, choices) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post("/api/v1/polls/".concat(id, "/votes"), { - choices: choices - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.poll(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getScheduledStatuses = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - } - return [2, this.client.get('/api/v1/scheduled_statuses', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.scheduled_status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getScheduledStatus = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/scheduled_statuses/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.scheduled_status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.scheduleStatus = function (id, scheduled_at) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (scheduled_at) { - params = Object.assign(params, { - scheduled_at: scheduled_at - }); - } - return [2, this.client.put("/api/v1/scheduled_statuses/".concat(id), params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.scheduled_status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.cancelScheduledStatus = function (id) { - return this.client.del("/api/v1/scheduled_statuses/".concat(id)); - }; - Pleroma.prototype.getPublicTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - local: false - }; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/timelines/public', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getLocalTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - local: true - }; - if (options) { - if (options.only_media !== undefined) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/timelines/public', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getTagTimeline = function (hashtag, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.local !== undefined) { - params = Object.assign(params, { - local: options.local - }); - } - if (options.only_media !== undefined) { - params = Object.assign(params, { - only_media: options.only_media - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get("/api/v1/timelines/tag/".concat(hashtag), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getHomeTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.local !== undefined) { - params = Object.assign(params, { - local: options.local - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/timelines/home', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getListTimeline = function (list_id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get("/api/v1/timelines/list/".concat(list_id), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (s) { return api_client_1.default.Converter.status(s); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getConversationTimeline = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - } - return [2, this.client.get('/api/v1/conversations', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (c) { return api_client_1.default.Converter.conversation(c); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.deleteConversation = function (id) { - return this.client.del("/api/v1/conversations/".concat(id)); - }; - Pleroma.prototype.readConversation = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/conversations/".concat(id, "/read")).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.conversation(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getLists = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/lists').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (l) { return api_client_1.default.Converter.list(l); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getList = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/lists/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.list(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.createList = function (title) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .post('/api/v1/lists', { - title: title - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.list(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.updateList = function (id, title) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client - .put("/api/v1/lists/".concat(id), { - title: title - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.list(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.deleteList = function (id) { - return this.client.del("/api/v1/lists/".concat(id)); - }; - Pleroma.prototype.getAccountsInList = function (id, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - } - return [2, this.client.get("/api/v1/lists/".concat(id, "/accounts"), params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.addAccountsToList = function (id, account_ids) { - return this.client.post("/api/v1/lists/".concat(id, "/accounts"), { - account_ids: account_ids - }); - }; - Pleroma.prototype.deleteAccountsFromList = function (id, account_ids) { - return this.client.del("/api/v1/lists/".concat(id, "/accounts"), { - account_ids: account_ids - }); - }; - Pleroma.prototype.getMarkers = function (timeline) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/markers', { - timeline: timeline - })]; - }); - }); - }; - Pleroma.prototype.saveMarkers = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.home) { - params = Object.assign(params, { - home: options.home - }); - } - if (options.notifications) { - params = Object.assign(params, { - notifications: options.notifications - }); - } - } - return [2, this.client.post('/api/v1/markers', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.marker(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getNotifications = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.since_id) { - params = Object.assign(params, { - since_id: options.since_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.exclude_types) { - params = Object.assign(params, { - exclude_types: options.exclude_types.map(function (e) { return api_client_1.default.Converter.encodeNotificationType(e); }) - }); - } - if (options.account_id) { - params = Object.assign(params, { - account_id: options.account_id - }); - } - } - return [2, this.client.get('/api/v1/notifications', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (n) { return api_client_1.default.Converter.notification(n); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getNotification = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/notifications/".concat(id)).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.notification(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.dismissNotifications = function () { - return this.client.post('/api/v1/notifications/clear'); - }; - Pleroma.prototype.dismissNotification = function (id) { - return this.client.post("/api/v1/notifications/".concat(id, "/dismiss")); - }; - Pleroma.prototype.readNotifications = function (options) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - if (options.id) { - return [2, this.client - .post('/api/v1/pleroma/notifications/read', { - id: options.id - }) - .then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.notification(res.data) - }); - })]; - } - else if (options.max_id) { - return [2, this.client - .post('/api/v1/pleroma/notifications/read', { - max_id: options.max_id - }) - .then(function (res) { - return Object.assign(res, { - data: res.data.map(function (n) { return api_client_1.default.Converter.notification(n); }) - }); - })]; - } - else { - return [2, new Promise(function (_, reject) { - var err = new megalodon_1.ArgumentError('id or max_id is required'); - reject(err); - })]; - } - return [2]; - }); - }); - }; - Pleroma.prototype.subscribePushNotification = function (subscription, data) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - subscription: subscription - }; - if (data) { - params = Object.assign(params, { - data: data - }); - } - return [2, this.client.post('/api/v1/push/subscription', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.push_subscription(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getPushSubscription = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/push/subscription').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.push_subscription(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.updatePushSubscription = function (data) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (data) { - params = Object.assign(params, { - data: data - }); - } - return [2, this.client.put('/api/v1/push/subscription', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.push_subscription(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.deletePushSubscription = function () { - return this.client.del('/api/v1/push/subscription'); - }; - Pleroma.prototype.search = function (q, type, options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = { - q: q, - type: type - }; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.max_id) { - params = Object.assign(params, { - max_id: options.max_id - }); - } - if (options.min_id) { - params = Object.assign(params, { - min_id: options.min_id - }); - } - if (options.resolve !== undefined) { - params = Object.assign(params, { - resolve: options.resolve - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - if (options.following !== undefined) { - params = Object.assign(params, { - following: options.following - }); - } - if (options.account_id) { - params = Object.assign(params, { - account_id: options.account_id - }); - } - if (options.exclude_unreviewed) { - params = Object.assign(params, { - exclude_unreviewed: options.exclude_unreviewed - }); - } - } - return [2, this.client.get('/api/v2/search', params).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.results(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getInstance = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/instance').then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.instance(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getInstancePeers = function () { - return this.client.get('/api/v1/instance/peers'); - }; - Pleroma.prototype.getInstanceActivity = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/instance/activity').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.activity(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getInstanceTrends = function (limit) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (limit) { - params = Object.assign(params, { - limit: limit - }); - } - return [2, this.client.get('/api/v1/trends', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (t) { return api_client_1.default.Converter.tag(t); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getInstanceDirectory = function (options) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (options) { - if (options.limit) { - params = Object.assign(params, { - limit: options.limit - }); - } - if (options.offset) { - params = Object.assign(params, { - offset: options.offset - }); - } - if (options.order) { - params = Object.assign(params, { - order: options.order - }); - } - if (options.local !== undefined) { - params = Object.assign(params, { - local: options.local - }); - } - } - return [2, this.client.get('/api/v1/directory', params).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (a) { return api_client_1.default.Converter.account(a); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getInstanceCustomEmojis = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get('/api/v1/custom_emojis').then(function (res) { - return Object.assign(res, { - data: res.data.map(function (e) { return api_client_1.default.Converter.emoji(e); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getInstanceAnnouncements = function (with_dismissed) { - return __awaiter(this, void 0, void 0, function () { - var params; - return __generator(this, function (_a) { - params = {}; - if (with_dismissed) { - params = Object.assign(params, { - with_dismissed: with_dismissed - }); - } - return [2, this.client.get('/api/v1/announcements', params).then(function (res) { return (__assign(__assign({}, res), { data: res.data.map(function (t) { return api_client_1.default.Converter.announcement(t); }) })); })]; - }); - }); - }; - Pleroma.prototype.dismissInstanceAnnouncement = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.post("/api/v1/announcements/".concat(id, "/dismiss"))]; - }); - }); - }; - Pleroma.prototype.createEmojiReaction = function (id, emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.put("/api/v1/pleroma/statuses/".concat(id, "/reactions/").concat(encodeURI(emoji))).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.deleteEmojiReaction = function (id, emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.del("/api/v1/pleroma/statuses/".concat(id, "/reactions/").concat(encodeURI(emoji))).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.status(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.getEmojiReactions = function (id) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/pleroma/statuses/".concat(id, "/reactions")).then(function (res) { - return Object.assign(res, { - data: res.data.map(function (r) { return api_client_1.default.Converter.reaction(r); }) - }); - })]; - }); - }); - }; - Pleroma.prototype.getEmojiReaction = function (id, emoji) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2, this.client.get("/api/v1/pleroma/statuses/".concat(id, "/reactions/").concat(encodeURI(emoji))).then(function (res) { - return Object.assign(res, { - data: api_client_1.default.Converter.reaction(res.data) - }); - })]; - }); - }); - }; - Pleroma.prototype.userSocket = function () { - return this.client.socket('/api/v1/streaming', 'user'); - }; - Pleroma.prototype.publicSocket = function () { - return this.client.socket('/api/v1/streaming', 'public'); - }; - Pleroma.prototype.localSocket = function () { - return this.client.socket('/api/v1/streaming', 'public:local'); - }; - Pleroma.prototype.tagSocket = function (tag) { - return this.client.socket('/api/v1/streaming', 'hashtag', "tag=".concat(tag)); - }; - Pleroma.prototype.listSocket = function (list_id) { - return this.client.socket('/api/v1/streaming', 'list', "list=".concat(list_id)); - }; - Pleroma.prototype.directSocket = function () { - return this.client.socket('/api/v1/streaming', 'direct'); - }; - return Pleroma; -}()); -exports.default = Pleroma; diff --git a/packages/megalodon/lib/src/pleroma/api_client.d.ts b/packages/megalodon/lib/src/pleroma/api_client.d.ts deleted file mode 100644 index 7814930d7f..0000000000 --- a/packages/megalodon/lib/src/pleroma/api_client.d.ts +++ /dev/null @@ -1,152 +0,0 @@ -import MegalodonEntity from '../entity'; -import PleromaEntity from './entity'; -import Response from '../response'; -import { ProxyConfig } from '../proxy_config'; -import WebSocket from './web_socket'; -import NotificationType from '../notification'; -declare namespace PleromaAPI { - namespace Entity { - type Account = PleromaEntity.Account; - type Activity = PleromaEntity.Activity; - type Announcement = PleromaEntity.Announcement; - type Application = PleromaEntity.Application; - type AsyncAttachment = PleromaEntity.AsyncAttachment; - type Attachment = PleromaEntity.Attachment; - type Card = PleromaEntity.Card; - type Context = PleromaEntity.Context; - type Conversation = PleromaEntity.Conversation; - type Emoji = PleromaEntity.Emoji; - type FeaturedTag = PleromaEntity.FeaturedTag; - type Field = PleromaEntity.Field; - type Filter = PleromaEntity.Filter; - type History = PleromaEntity.History; - type IdentityProof = PleromaEntity.IdentityProof; - type Instance = PleromaEntity.Instance; - type List = PleromaEntity.List; - type Marker = PleromaEntity.Marker; - type Mention = PleromaEntity.Mention; - type Notification = PleromaEntity.Notification; - type Poll = PleromaEntity.Poll; - type PollOption = PleromaEntity.PollOption; - type Preferences = PleromaEntity.Preferences; - type PushSubscription = PleromaEntity.PushSubscription; - type Reaction = PleromaEntity.Reaction; - type Relationship = PleromaEntity.Relationship; - type Report = PleromaEntity.Report; - type Results = PleromaEntity.Results; - type ScheduledStatus = PleromaEntity.ScheduledStatus; - type Source = PleromaEntity.Source; - type Stats = PleromaEntity.Stats; - type Status = PleromaEntity.Status; - type StatusParams = PleromaEntity.StatusParams; - type Tag = PleromaEntity.Tag; - type Token = PleromaEntity.Token; - type URLs = PleromaEntity.URLs; - } - namespace Converter { - const decodeNotificationType: (t: PleromaEntity.NotificationType) => MegalodonEntity.NotificationType; - const encodeNotificationType: (t: MegalodonEntity.NotificationType) => PleromaEntity.NotificationType; - const account: (a: Entity.Account) => MegalodonEntity.Account; - const activity: (a: Entity.Activity) => MegalodonEntity.Activity; - const announcement: (a: Entity.Announcement) => MegalodonEntity.Announcement; - const application: (a: Entity.Application) => MegalodonEntity.Application; - const attachment: (a: Entity.Attachment) => MegalodonEntity.Attachment; - const async_attachment: (a: Entity.AsyncAttachment) => MegalodonEntity.Attachment | MegalodonEntity.AsyncAttachment; - const card: (c: Entity.Card) => MegalodonEntity.Card; - const context: (c: Entity.Context) => MegalodonEntity.Context; - const conversation: (c: Entity.Conversation) => MegalodonEntity.Conversation; - const emoji: (e: Entity.Emoji) => MegalodonEntity.Emoji; - const featured_tag: (f: Entity.FeaturedTag) => MegalodonEntity.FeaturedTag; - const field: (f: Entity.Field) => MegalodonEntity.Field; - const filter: (f: Entity.Filter) => MegalodonEntity.Filter; - const history: (h: Entity.History) => MegalodonEntity.History; - const identity_proof: (i: Entity.IdentityProof) => MegalodonEntity.IdentityProof; - const instance: (i: Entity.Instance) => MegalodonEntity.Instance; - const list: (l: Entity.List) => MegalodonEntity.List; - const marker: (m: Entity.Marker) => MegalodonEntity.Marker; - const mention: (m: Entity.Mention) => MegalodonEntity.Mention; - const notification: (n: Entity.Notification) => MegalodonEntity.Notification; - const poll: (p: Entity.Poll) => MegalodonEntity.Poll; - const pollOption: (p: Entity.PollOption) => MegalodonEntity.PollOption; - const preferences: (p: Entity.Preferences) => MegalodonEntity.Preferences; - const push_subscription: (p: Entity.PushSubscription) => MegalodonEntity.PushSubscription; - const reaction: (r: Entity.Reaction) => MegalodonEntity.Reaction; - const relationship: (r: Entity.Relationship) => MegalodonEntity.Relationship; - const report: (r: Entity.Report) => MegalodonEntity.Report; - const results: (r: Entity.Results) => MegalodonEntity.Results; - const scheduled_status: (s: Entity.ScheduledStatus) => MegalodonEntity.ScheduledStatus; - const source: (s: Entity.Source) => MegalodonEntity.Source; - const stats: (s: Entity.Stats) => MegalodonEntity.Stats; - const status: (s: Entity.Status) => MegalodonEntity.Status; - const status_params: (s: Entity.StatusParams) => MegalodonEntity.StatusParams; - const tag: (t: Entity.Tag) => MegalodonEntity.Tag; - const token: (t: Entity.Token) => MegalodonEntity.Token; - const urls: (u: Entity.URLs) => MegalodonEntity.URLs; - } - interface Interface { - get(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - put(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - putForm(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - patch(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - patchForm(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - post(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - postForm(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - del(path: string, params?: any, headers?: { - [key: string]: string; - }): Promise>; - cancel(): void; - socket(path: string, stream: string, params?: string): WebSocket; - } - class Client implements Interface { - static DEFAULT_SCOPE: string[]; - static DEFAULT_URL: string; - static NO_REDIRECT: string; - private accessToken; - private baseUrl; - private userAgent; - private abortController; - private proxyConfig; - constructor(baseUrl: string, accessToken?: string | null, userAgent?: string, proxyConfig?: ProxyConfig | false); - get(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - put(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - putForm(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - patch(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - patchForm(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - post(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - postForm(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - del(path: string, params?: {}, headers?: { - [key: string]: string; - }): Promise>; - cancel(): void; - socket(path: string, stream: string, params?: string): WebSocket; - } -} -export default PleromaAPI; diff --git a/packages/megalodon/lib/src/pleroma/api_client.js b/packages/megalodon/lib/src/pleroma/api_client.js deleted file mode 100644 index 2878735f8c..0000000000 --- a/packages/megalodon/lib/src/pleroma/api_client.js +++ /dev/null @@ -1,632 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var axios_1 = __importDefault(require("axios")); -var object_assign_deep_1 = __importDefault(require("object-assign-deep")); -var cancel_1 = require("../cancel"); -var proxy_config_1 = __importDefault(require("../proxy_config")); -var default_1 = require("../default"); -var web_socket_1 = __importDefault(require("./web_socket")); -var notification_1 = __importDefault(require("../notification")); -var notification_2 = __importDefault(require("./notification")); -var PleromaAPI; -(function (PleromaAPI) { - var Converter; - (function (Converter) { - Converter.decodeNotificationType = function (t) { - switch (t) { - case notification_2.default.Mention: - return notification_1.default.Mention; - case notification_2.default.Reblog: - return notification_1.default.Reblog; - case notification_2.default.Favourite: - return notification_1.default.Favourite; - case notification_2.default.Follow: - return notification_1.default.Follow; - case notification_2.default.Poll: - return notification_1.default.PollExpired; - case notification_2.default.PleromaEmojiReaction: - return notification_1.default.EmojiReaction; - case notification_2.default.FollowRequest: - return notification_1.default.FollowRequest; - default: - return t; - } - }; - Converter.encodeNotificationType = function (t) { - switch (t) { - case notification_1.default.Follow: - return notification_2.default.Follow; - case notification_1.default.Favourite: - return notification_2.default.Favourite; - case notification_1.default.Reblog: - return notification_2.default.Reblog; - case notification_1.default.Mention: - return notification_2.default.Mention; - case notification_1.default.PollExpired: - return notification_2.default.Poll; - case notification_1.default.EmojiReaction: - return notification_2.default.PleromaEmojiReaction; - case notification_1.default.FollowRequest: - return notification_2.default.FollowRequest; - default: - return t; - } - }; - Converter.account = function (a) { return a; }; - Converter.activity = function (a) { return a; }; - Converter.announcement = function (a) { return a; }; - Converter.application = function (a) { return a; }; - Converter.attachment = function (a) { return a; }; - Converter.async_attachment = function (a) { - if (a.url) { - return { - id: a.id, - type: a.type, - url: a.url, - remote_url: a.remote_url, - preview_url: a.preview_url, - text_url: a.text_url, - meta: a.meta, - description: a.description, - blurhash: a.blurhash - }; - } - else { - return a; - } - }; - Converter.card = function (c) { return c; }; - Converter.context = function (c) { return ({ - ancestors: c.ancestors.map(function (a) { return Converter.status(a); }), - descendants: c.descendants.map(function (d) { return Converter.status(d); }) - }); }; - Converter.conversation = function (c) { return ({ - id: c.id, - accounts: c.accounts.map(function (a) { return Converter.account(a); }), - last_status: c.last_status ? Converter.status(c.last_status) : null, - unread: c.unread - }); }; - Converter.emoji = function (e) { return e; }; - Converter.featured_tag = function (f) { return f; }; - Converter.field = function (f) { return f; }; - Converter.filter = function (f) { return f; }; - Converter.history = function (h) { return h; }; - Converter.identity_proof = function (i) { return i; }; - Converter.instance = function (i) { return i; }; - Converter.list = function (l) { return l; }; - Converter.marker = function (m) { - return { - notifications: { - last_read_id: m.notifications.last_read_id, - version: m.notifications.version, - updated_at: m.notifications.updated_at, - unread_count: m.notifications.pleroma.unread_count - } - }; - }; - Converter.mention = function (m) { return m; }; - Converter.notification = function (n) { - if (n.status && n.emoji) { - return { - id: n.id, - account: n.account, - created_at: n.created_at, - status: Converter.status(n.status), - emoji: n.emoji, - type: Converter.decodeNotificationType(n.type) - }; - } - else if (n.status) { - return { - id: n.id, - account: n.account, - created_at: n.created_at, - status: Converter.status(n.status), - type: Converter.decodeNotificationType(n.type) - }; - } - else { - return { - id: n.id, - account: n.account, - created_at: n.created_at, - type: Converter.decodeNotificationType(n.type) - }; - } - }; - Converter.poll = function (p) { return p; }; - Converter.pollOption = function (p) { return p; }; - Converter.preferences = function (p) { return p; }; - Converter.push_subscription = function (p) { return p; }; - Converter.reaction = function (r) { return r; }; - Converter.relationship = function (r) { return ({ - id: r.id, - following: r.following, - followed_by: r.followed_by, - blocking: r.blocking, - blocked_by: r.blocked_by, - muting: r.muting, - muting_notifications: r.muting_notifications, - requested: r.requested, - domain_blocking: r.domain_blocking, - showing_reblogs: r.showing_reblogs, - endorsed: r.endorsed, - notifying: r.subscribing - }); }; - Converter.report = function (r) { return r; }; - Converter.results = function (r) { return ({ - accounts: r.accounts.map(function (a) { return Converter.account(a); }), - statuses: r.statuses.map(function (s) { return Converter.status(s); }), - hashtags: r.hashtags.map(function (h) { return Converter.tag(h); }) - }); }; - Converter.scheduled_status = function (s) { return ({ - id: s.id, - scheduled_at: s.scheduled_at, - params: s.params, - media_attachments: s.media_attachments.map(function (m) { return Converter.attachment(m); }) - }); }; - Converter.source = function (s) { return s; }; - Converter.stats = function (s) { return s; }; - Converter.status = function (s) { - var _a; - return ({ - id: s.id, - uri: s.uri, - url: s.url, - account: Converter.account(s.account), - in_reply_to_id: s.in_reply_to_id, - in_reply_to_account_id: s.in_reply_to_account_id, - reblog: s.reblog ? Converter.status(s.reblog) : null, - content: s.content, - plain_content: ((_a = s.pleroma.content) === null || _a === void 0 ? void 0 : _a['text/plain']) ? s.pleroma.content['text/plain'] : null, - created_at: s.created_at, - emojis: s.emojis.map(function (e) { return Converter.emoji(e); }), - replies_count: s.replies_count, - reblogs_count: s.reblogs_count, - favourites_count: s.favourites_count, - reblogged: s.reblogged, - favourited: s.favourited, - muted: s.muted, - sensitive: s.sensitive, - spoiler_text: s.spoiler_text, - visibility: s.visibility, - media_attachments: s.media_attachments.map(function (m) { return Converter.attachment(m); }), - mentions: s.mentions.map(function (m) { return Converter.mention(m); }), - tags: s.tags.map(function (t) { return Converter.tag(t); }), - card: s.card ? Converter.card(s.card) : null, - poll: s.poll ? Converter.poll(s.poll) : null, - application: s.application ? Converter.application(s.application) : null, - language: s.language, - pinned: s.pinned, - emoji_reactions: s.pleroma.emoji_reactions ? s.pleroma.emoji_reactions.map(function (r) { return Converter.reaction(r); }) : [], - bookmarked: s.bookmarked ? s.bookmarked : false, - quote: null - }); - }; - Converter.status_params = function (s) { return s; }; - Converter.tag = function (t) { return t; }; - Converter.token = function (t) { return t; }; - Converter.urls = function (u) { return u; }; - })(Converter = PleromaAPI.Converter || (PleromaAPI.Converter = {})); - var Client = (function () { - function Client(baseUrl, accessToken, userAgent, proxyConfig) { - if (accessToken === void 0) { accessToken = null; } - if (userAgent === void 0) { userAgent = default_1.DEFAULT_UA; } - if (proxyConfig === void 0) { proxyConfig = false; } - this.proxyConfig = false; - this.accessToken = accessToken; - this.baseUrl = baseUrl; - this.userAgent = userAgent; - this.proxyConfig = proxyConfig; - this.abortController = new AbortController(); - axios_1.default.defaults.signal = this.abortController.signal; - } - Client.prototype.get = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - params: params, - headers: headers - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .get(this.baseUrl + path, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.put = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .put(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.putForm = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .putForm(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.patch = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .patch(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.patchForm = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .patchForm(this.baseUrl + path, params, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.post = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default.post(this.baseUrl + path, params, options).then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.postForm = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default.postForm(this.baseUrl + path, params, options).then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.del = function (path, params, headers) { - if (params === void 0) { params = {}; } - if (headers === void 0) { headers = {}; } - return __awaiter(this, void 0, void 0, function () { - var options; - return __generator(this, function (_a) { - options = { - data: params, - headers: headers, - maxContentLength: Infinity, - maxBodyLength: Infinity - }; - if (this.accessToken) { - options = (0, object_assign_deep_1.default)({}, options, { - headers: { - Authorization: "Bearer ".concat(this.accessToken) - } - }); - } - if (this.proxyConfig) { - options = Object.assign(options, { - httpAgent: (0, proxy_config_1.default)(this.proxyConfig), - httpsAgent: (0, proxy_config_1.default)(this.proxyConfig) - }); - } - return [2, axios_1.default - .delete(this.baseUrl + path, options) - .catch(function (err) { - if (axios_1.default.isCancel(err)) { - throw new cancel_1.RequestCanceledError(err.message); - } - else { - throw err; - } - }) - .then(function (resp) { - var res = { - data: resp.data, - status: resp.status, - statusText: resp.statusText, - headers: resp.headers - }; - return res; - })]; - }); - }); - }; - Client.prototype.cancel = function () { - return this.abortController.abort(); - }; - Client.prototype.socket = function (path, stream, params) { - if (!this.accessToken) { - throw new Error('accessToken is required'); - } - var url = this.baseUrl + path; - var streaming = new web_socket_1.default(url, stream, params, this.accessToken, this.userAgent, this.proxyConfig); - process.nextTick(function () { - streaming.start(); - }); - return streaming; - }; - Client.DEFAULT_SCOPE = default_1.DEFAULT_SCOPE; - Client.DEFAULT_URL = 'https://pleroma.io'; - Client.NO_REDIRECT = default_1.NO_REDIRECT; - return Client; - }()); - PleromaAPI.Client = Client; -})(PleromaAPI || (PleromaAPI = {})); -exports.default = PleromaAPI; diff --git a/packages/megalodon/lib/src/pleroma/entities/account.d.ts b/packages/megalodon/lib/src/pleroma/entities/account.d.ts deleted file mode 100644 index 96f4f43b61..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/account.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// -/// -/// -declare namespace PleromaEntity { - type Account = { - id: string; - username: string; - acct: string; - display_name: string; - locked: boolean; - created_at: string; - followers_count: number; - following_count: number; - statuses_count: number; - note: string; - url: string; - avatar: string; - avatar_static: string; - header: string; - header_static: string; - emojis: Array; - moved: Account | null; - fields: Array; - bot: boolean | null; - source?: Source; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/account.js b/packages/megalodon/lib/src/pleroma/entities/account.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/account.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/activity.d.ts b/packages/megalodon/lib/src/pleroma/entities/activity.d.ts deleted file mode 100644 index 34c5ecfb0e..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/activity.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace PleromaEntity { - type Activity = { - week: string; - statuses: string; - logins: string; - registrations: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/activity.js b/packages/megalodon/lib/src/pleroma/entities/activity.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/activity.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/announcement.d.ts b/packages/megalodon/lib/src/pleroma/entities/announcement.d.ts deleted file mode 100644 index 624cac36a6..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/announcement.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// -/// -/// -declare namespace PleromaEntity { - type Announcement = { - id: string; - content: string; - starts_at: string | null; - ends_at: string | null; - published: boolean; - all_day: boolean; - published_at: string; - updated_at: string; - read?: boolean; - mentions: Array; - statuses: Array; - tags: Array; - emojis: Array; - reactions: Array; - }; - type AnnouncementAccount = { - id: string; - username: string; - url: string; - acct: string; - }; - type AnnouncementStatus = { - id: string; - url: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/announcement.js b/packages/megalodon/lib/src/pleroma/entities/announcement.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/announcement.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/application.d.ts b/packages/megalodon/lib/src/pleroma/entities/application.d.ts deleted file mode 100644 index d6c91c6950..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/application.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace PleromaEntity { - type Application = { - name: string; - website?: string | null; - vapid_key?: string | null; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/application.js b/packages/megalodon/lib/src/pleroma/entities/application.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/application.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/async_attachment.d.ts b/packages/megalodon/lib/src/pleroma/entities/async_attachment.d.ts deleted file mode 100644 index 65ea109bd2..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/async_attachment.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// -declare namespace PleromaEntity { - type AsyncAttachment = { - id: string; - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - url: string | null; - remote_url: string | null; - preview_url: string; - text_url: string | null; - meta: Meta | null; - description: string | null; - blurhash: string | null; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/async_attachment.js b/packages/megalodon/lib/src/pleroma/entities/async_attachment.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/async_attachment.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/attachment.d.ts b/packages/megalodon/lib/src/pleroma/entities/attachment.d.ts deleted file mode 100644 index 5ed99d3435..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/attachment.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -declare namespace PleromaEntity { - type Sub = { - width?: number; - height?: number; - size?: string; - aspect?: number; - frame_rate?: string; - duration?: number; - bitrate?: number; - }; - type Focus = { - x: number; - y: number; - }; - type Meta = { - original?: Sub; - small?: Sub; - focus?: Focus; - length?: string; - duration?: number; - fps?: number; - size?: string; - width?: number; - height?: number; - aspect?: number; - audio_encode?: string; - audio_bitrate?: string; - audio_channel?: string; - }; - type Attachment = { - id: string; - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio'; - url: string; - remote_url: string | null; - preview_url: string | null; - text_url: string | null; - meta: Meta | null; - description: string | null; - blurhash: string | null; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/attachment.js b/packages/megalodon/lib/src/pleroma/entities/attachment.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/attachment.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/card.d.ts b/packages/megalodon/lib/src/pleroma/entities/card.d.ts deleted file mode 100644 index eb24153033..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/card.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare namespace PleromaEntity { - type Card = { - url: string; - title: string; - description: string; - type: 'link' | 'photo' | 'video' | 'rich'; - image?: string; - author_name?: string; - author_url?: string; - provider_name?: string; - provider_url?: string; - html?: string; - width?: number; - height?: number; - pleroma?: Object; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/card.js b/packages/megalodon/lib/src/pleroma/entities/card.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/card.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/context.d.ts b/packages/megalodon/lib/src/pleroma/entities/context.d.ts deleted file mode 100644 index 888d2ce778..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/context.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -declare namespace PleromaEntity { - type Context = { - ancestors: Array; - descendants: Array; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/context.js b/packages/megalodon/lib/src/pleroma/entities/context.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/context.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/conversation.d.ts b/packages/megalodon/lib/src/pleroma/entities/conversation.d.ts deleted file mode 100644 index f65b579742..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/conversation.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -declare namespace PleromaEntity { - type Conversation = { - id: string; - accounts: Array; - last_status: Status | null; - unread: boolean; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/conversation.js b/packages/megalodon/lib/src/pleroma/entities/conversation.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/conversation.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/emoji.d.ts b/packages/megalodon/lib/src/pleroma/entities/emoji.d.ts deleted file mode 100644 index a97d5c9ddf..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/emoji.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace PleromaEntity { - type Emoji = { - shortcode: string; - static_url: string; - url: string; - visible_in_picker: boolean; - category: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/emoji.js b/packages/megalodon/lib/src/pleroma/entities/emoji.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/emoji.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/featured_tag.d.ts b/packages/megalodon/lib/src/pleroma/entities/featured_tag.d.ts deleted file mode 100644 index a783d0da38..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/featured_tag.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace PleromaEntity { - type FeaturedTag = { - id: string; - name: string; - statuses_count: number; - last_status_at: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/featured_tag.js b/packages/megalodon/lib/src/pleroma/entities/featured_tag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/featured_tag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/field.d.ts b/packages/megalodon/lib/src/pleroma/entities/field.d.ts deleted file mode 100644 index a66dbf6450..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/field.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace PleromaEntity { - type Field = { - name: string; - value: string; - verified_at: string | null; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/field.js b/packages/megalodon/lib/src/pleroma/entities/field.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/field.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/filter.d.ts b/packages/megalodon/lib/src/pleroma/entities/filter.d.ts deleted file mode 100644 index d59cb56ccb..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/filter.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace PleromaEntity { - type Filter = { - id: string; - phrase: string; - context: Array; - expires_at: string | null; - irreversible: boolean; - whole_word: boolean; - }; - type FilterContext = string; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/filter.js b/packages/megalodon/lib/src/pleroma/entities/filter.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/filter.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/history.d.ts b/packages/megalodon/lib/src/pleroma/entities/history.d.ts deleted file mode 100644 index 12ee93cbf5..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/history.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace PleromaEntity { - type History = { - day: string; - uses: number; - accounts: number; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/history.js b/packages/megalodon/lib/src/pleroma/entities/history.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/history.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/identity_proof.d.ts b/packages/megalodon/lib/src/pleroma/entities/identity_proof.d.ts deleted file mode 100644 index 5195215135..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/identity_proof.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace PleromaEntity { - type IdentityProof = { - provider: string; - provider_username: string; - updated_at: string; - proof_url: string; - profile_url: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/identity_proof.js b/packages/megalodon/lib/src/pleroma/entities/identity_proof.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/identity_proof.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/instance.d.ts b/packages/megalodon/lib/src/pleroma/entities/instance.d.ts deleted file mode 100644 index 24c6d489b0..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/instance.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// -/// -/// -declare namespace PleromaEntity { - type Instance = { - uri: string; - title: string; - description: string; - email: string; - version: string; - thumbnail: string | null; - urls: URLs; - stats: Stats; - languages: Array; - contact_account: Account | null; - max_toot_chars?: number; - registrations?: boolean; - configuration?: { - statuses: { - max_characters: number; - max_media_attachments: number; - characters_reserved_per_url: number; - }; - media_attachments: { - supported_mime_types: Array; - image_size_limit: number; - image_matrix_limit: number; - video_size_limit: number; - video_frame_limit: number; - video_matrix_limit: number; - }; - polls: { - max_options: number; - max_characters_per_option: number; - min_expiration: number; - max_expiration: number; - }; - }; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/instance.js b/packages/megalodon/lib/src/pleroma/entities/instance.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/instance.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/list.d.ts b/packages/megalodon/lib/src/pleroma/entities/list.d.ts deleted file mode 100644 index aa8429d8ff..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/list.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace PleromaEntity { - type List = { - id: string; - title: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/list.js b/packages/megalodon/lib/src/pleroma/entities/list.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/list.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/marker.d.ts b/packages/megalodon/lib/src/pleroma/entities/marker.d.ts deleted file mode 100644 index 7a79f392fc..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/marker.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace PleromaEntity { - type Marker = { - notifications: { - last_read_id: string; - version: number; - updated_at: string; - pleroma: { - unread_count: number; - }; - }; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/marker.js b/packages/megalodon/lib/src/pleroma/entities/marker.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/marker.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/mention.d.ts b/packages/megalodon/lib/src/pleroma/entities/mention.d.ts deleted file mode 100644 index 3fde306c6e..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/mention.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace PleromaEntity { - type Mention = { - id: string; - username: string; - url: string; - acct: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/mention.js b/packages/megalodon/lib/src/pleroma/entities/mention.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/mention.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/notification.d.ts b/packages/megalodon/lib/src/pleroma/entities/notification.d.ts deleted file mode 100644 index 02ddf08660..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/notification.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// -/// -declare namespace PleromaEntity { - type Notification = { - account: Account; - created_at: string; - id: string; - status?: Status; - emoji?: string; - type: NotificationType; - }; - type NotificationType = string; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/notification.js b/packages/megalodon/lib/src/pleroma/entities/notification.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/notification.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/poll.d.ts b/packages/megalodon/lib/src/pleroma/entities/poll.d.ts deleted file mode 100644 index 0ec2095106..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/poll.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// -declare namespace PleromaEntity { - type Poll = { - id: string; - expires_at: string | null; - expired: boolean; - multiple: boolean; - votes_count: number; - options: Array; - voted: boolean; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/poll.js b/packages/megalodon/lib/src/pleroma/entities/poll.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/poll.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/poll_option.d.ts b/packages/megalodon/lib/src/pleroma/entities/poll_option.d.ts deleted file mode 100644 index 6714d51bdc..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/poll_option.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare namespace PleromaEntity { - type PollOption = { - title: string; - votes_count: number | null; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/poll_option.js b/packages/megalodon/lib/src/pleroma/entities/poll_option.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/poll_option.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/preferences.d.ts b/packages/megalodon/lib/src/pleroma/entities/preferences.d.ts deleted file mode 100644 index d8cf7d2a20..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/preferences.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace PleromaEntity { - type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct'; - 'posting:default:sensitive': boolean; - 'posting:default:language': string | null; - 'reading:expand:media': 'default' | 'show_all' | 'hide_all'; - 'reading:expand:spoilers': boolean; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/preferences.js b/packages/megalodon/lib/src/pleroma/entities/preferences.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/preferences.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/push_subscription.d.ts b/packages/megalodon/lib/src/pleroma/entities/push_subscription.d.ts deleted file mode 100644 index 221f49820e..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/push_subscription.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare namespace PleromaEntity { - type Alerts = { - follow: boolean; - favourite: boolean; - mention: boolean; - reblog: boolean; - poll: boolean; - }; - type PushSubscription = { - id: string; - endpoint: string; - server_key: string; - alerts: Alerts; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/push_subscription.js b/packages/megalodon/lib/src/pleroma/entities/push_subscription.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/push_subscription.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/reaction.d.ts b/packages/megalodon/lib/src/pleroma/entities/reaction.d.ts deleted file mode 100644 index 6c7315d0e7..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/reaction.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace PleromaEntity { - type Reaction = { - count: number; - me: boolean; - name: string; - accounts?: Array; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/reaction.js b/packages/megalodon/lib/src/pleroma/entities/reaction.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/reaction.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/relationship.d.ts b/packages/megalodon/lib/src/pleroma/entities/relationship.d.ts deleted file mode 100644 index 4a830e7f16..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/relationship.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -declare namespace PleromaEntity { - type Relationship = { - id: string; - following: boolean; - followed_by: boolean; - blocking: boolean; - blocked_by: boolean; - muting: boolean; - muting_notifications: boolean; - requested: boolean; - domain_blocking: boolean; - showing_reblogs: boolean; - endorsed: boolean; - subscribing: boolean; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/relationship.js b/packages/megalodon/lib/src/pleroma/entities/relationship.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/relationship.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/report.d.ts b/packages/megalodon/lib/src/pleroma/entities/report.d.ts deleted file mode 100644 index 1d8b383efc..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/report.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace PleromaEntity { - type Report = { - id: string; - action_taken: string; - comment: string; - account_id: string; - status_ids: Array; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/report.js b/packages/megalodon/lib/src/pleroma/entities/report.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/report.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/results.d.ts b/packages/megalodon/lib/src/pleroma/entities/results.d.ts deleted file mode 100644 index 44fac696db..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/results.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -/// -declare namespace PleromaEntity { - type Results = { - accounts: Array; - statuses: Array; - hashtags: Array; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/results.js b/packages/megalodon/lib/src/pleroma/entities/results.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/results.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/scheduled_status.d.ts b/packages/megalodon/lib/src/pleroma/entities/scheduled_status.d.ts deleted file mode 100644 index 12b15029dc..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/scheduled_status.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -/// -declare namespace PleromaEntity { - type ScheduledStatus = { - id: string; - scheduled_at: string; - params: StatusParams; - media_attachments: Array; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/scheduled_status.js b/packages/megalodon/lib/src/pleroma/entities/scheduled_status.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/scheduled_status.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/source.d.ts b/packages/megalodon/lib/src/pleroma/entities/source.d.ts deleted file mode 100644 index aa05282e1f..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/source.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// -declare namespace PleromaEntity { - type Source = { - privacy: string | null; - sensitive: boolean | null; - language: string | null; - note: string; - fields: Array; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/source.js b/packages/megalodon/lib/src/pleroma/entities/source.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/source.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/stats.d.ts b/packages/megalodon/lib/src/pleroma/entities/stats.d.ts deleted file mode 100644 index ddceb54964..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/stats.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare namespace PleromaEntity { - type Stats = { - user_count: number; - status_count: number; - domain_count: number; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/stats.js b/packages/megalodon/lib/src/pleroma/entities/stats.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/stats.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/status.d.ts b/packages/megalodon/lib/src/pleroma/entities/status.d.ts deleted file mode 100644 index e49bfaa0a3..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/status.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -declare namespace PleromaEntity { - type Status = { - id: string; - uri: string; - url: string; - account: Account; - in_reply_to_id: string | null; - in_reply_to_account_id: string | null; - reblog: Status | null; - content: string; - created_at: string; - emojis: Emoji[]; - replies_count: number; - reblogs_count: number; - favourites_count: number; - reblogged: boolean | null; - favourited: boolean | null; - muted: boolean | null; - sensitive: boolean; - spoiler_text: string; - visibility: 'public' | 'unlisted' | 'private' | 'direct'; - media_attachments: Array; - mentions: Array; - tags: Array; - card: Card | null; - poll: Poll | null; - application: Application | null; - language: string | null; - pinned: boolean | null; - bookmarked?: boolean; - pleroma: { - content?: { - 'text/plain': string; - }; - spoiler_text?: { - 'text/plain': string; - }; - conversation_id?: number; - direct_conversation_id?: number | null; - emoji_reactions?: Array; - expires_at?: string; - in_reply_to_account_acct?: string; - local: boolean; - parent_visible?: boolean; - pinned_at?: string; - thread_muted?: boolean; - }; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/status.js b/packages/megalodon/lib/src/pleroma/entities/status.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/status.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/status_params.d.ts b/packages/megalodon/lib/src/pleroma/entities/status_params.d.ts deleted file mode 100644 index 56252e5e6c..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/status_params.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace PleromaEntity { - type StatusParams = { - text: string; - in_reply_to_id: string | null; - media_ids: Array | null; - sensitive: boolean | null; - spoiler_text: string | null; - visibility: 'public' | 'unlisted' | 'private' | 'direct'; - scheduled_at: string | null; - application_id: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/status_params.js b/packages/megalodon/lib/src/pleroma/entities/status_params.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/status_params.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/tag.d.ts b/packages/megalodon/lib/src/pleroma/entities/tag.d.ts deleted file mode 100644 index aa7ba94773..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/tag.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -declare namespace PleromaEntity { - type Tag = { - name: string; - url: string; - history: Array | null; - following?: boolean; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/tag.js b/packages/megalodon/lib/src/pleroma/entities/tag.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/tag.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/token.d.ts b/packages/megalodon/lib/src/pleroma/entities/token.d.ts deleted file mode 100644 index f341f9f69f..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/token.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare namespace PleromaEntity { - type Token = { - access_token: string; - token_type: string; - scope: string; - created_at: number; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/token.js b/packages/megalodon/lib/src/pleroma/entities/token.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/token.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entities/urls.d.ts b/packages/megalodon/lib/src/pleroma/entities/urls.d.ts deleted file mode 100644 index 53960cbdd9..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/urls.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace PleromaEntity { - type URLs = { - streaming_api: string; - }; -} diff --git a/packages/megalodon/lib/src/pleroma/entities/urls.js b/packages/megalodon/lib/src/pleroma/entities/urls.js deleted file mode 100644 index 3918c74e44..0000000000 --- a/packages/megalodon/lib/src/pleroma/entities/urls.js +++ /dev/null @@ -1 +0,0 @@ -"use strict"; diff --git a/packages/megalodon/lib/src/pleroma/entity.d.ts b/packages/megalodon/lib/src/pleroma/entity.d.ts deleted file mode 100644 index 08a7f15d16..0000000000 --- a/packages/megalodon/lib/src/pleroma/entity.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -export default PleromaEntity; diff --git a/packages/megalodon/lib/src/pleroma/entity.js b/packages/megalodon/lib/src/pleroma/entity.js deleted file mode 100644 index c8ad2e549b..0000000000 --- a/packages/megalodon/lib/src/pleroma/entity.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/megalodon/lib/src/pleroma/notification.d.ts b/packages/megalodon/lib/src/pleroma/notification.d.ts deleted file mode 100644 index 7645aea65e..0000000000 --- a/packages/megalodon/lib/src/pleroma/notification.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import PleromaEntity from './entity'; -declare namespace PleromaNotificationType { - const Mention: PleromaEntity.NotificationType; - const Reblog: PleromaEntity.NotificationType; - const Favourite: PleromaEntity.NotificationType; - const Follow: PleromaEntity.NotificationType; - const Poll: PleromaEntity.NotificationType; - const PleromaEmojiReaction: PleromaEntity.NotificationType; - const FollowRequest: PleromaEntity.NotificationType; -} -export default PleromaNotificationType; diff --git a/packages/megalodon/lib/src/pleroma/notification.js b/packages/megalodon/lib/src/pleroma/notification.js deleted file mode 100644 index fa9499ca37..0000000000 --- a/packages/megalodon/lib/src/pleroma/notification.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var PleromaNotificationType; -(function (PleromaNotificationType) { - PleromaNotificationType.Mention = 'mention'; - PleromaNotificationType.Reblog = 'reblog'; - PleromaNotificationType.Favourite = 'favourite'; - PleromaNotificationType.Follow = 'follow'; - PleromaNotificationType.Poll = 'poll'; - PleromaNotificationType.PleromaEmojiReaction = 'pleroma:emoji_reaction'; - PleromaNotificationType.FollowRequest = 'follow_request'; -})(PleromaNotificationType || (PleromaNotificationType = {})); -exports.default = PleromaNotificationType; diff --git a/packages/megalodon/lib/src/pleroma/web_socket.d.ts b/packages/megalodon/lib/src/pleroma/web_socket.d.ts deleted file mode 100644 index 639afab43d..0000000000 --- a/packages/megalodon/lib/src/pleroma/web_socket.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// -import WS from 'ws'; -import { EventEmitter } from 'events'; -import { ProxyConfig } from '../proxy_config'; -import { WebSocketInterface } from '../megalodon'; -export default class WebSocket extends EventEmitter implements WebSocketInterface { - url: string; - stream: string; - params: string | null; - parser: Parser; - headers: { - [key: string]: string; - }; - proxyConfig: ProxyConfig | false; - private _accessToken; - private _reconnectInterval; - private _reconnectMaxAttempts; - private _reconnectCurrentAttempts; - private _connectionClosed; - private _client; - private _pongReceivedTimestamp; - private _heartbeatInterval; - private _pongWaiting; - constructor(url: string, stream: string, params: string | undefined, accessToken: string, userAgent: string, proxyConfig?: ProxyConfig | false); - start(): void; - private _startWebSocketConnection; - stop(): void; - private _resetConnection; - private _resetRetryParams; - private _reconnect; - private _connect; - private _clearBinding; - private _bindSocket; - private _setupParser; - private _checkAlive; -} -export declare class Parser extends EventEmitter { - parse(data: WS.Data, isBinary: boolean): void; -} diff --git a/packages/megalodon/lib/src/pleroma/web_socket.js b/packages/megalodon/lib/src/pleroma/web_socket.js deleted file mode 100644 index f378767292..0000000000 --- a/packages/megalodon/lib/src/pleroma/web_socket.js +++ /dev/null @@ -1,260 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Parser = void 0; -var ws_1 = __importDefault(require("ws")); -var dayjs_1 = __importDefault(require("dayjs")); -var events_1 = require("events"); -var proxy_config_1 = __importDefault(require("../proxy_config")); -var api_client_1 = __importDefault(require("./api_client")); -var WebSocket = (function (_super) { - __extends(WebSocket, _super); - function WebSocket(url, stream, params, accessToken, userAgent, proxyConfig) { - if (proxyConfig === void 0) { proxyConfig = false; } - var _this = _super.call(this) || this; - _this.proxyConfig = false; - _this._heartbeatInterval = 60000; - _this._pongWaiting = false; - _this.url = url; - _this.stream = stream; - if (params === undefined) { - _this.params = null; - } - else { - _this.params = params; - } - _this.parser = new Parser(); - _this.headers = { - 'User-Agent': userAgent - }; - _this.proxyConfig = proxyConfig; - _this._accessToken = accessToken; - _this._reconnectInterval = 10000; - _this._reconnectMaxAttempts = Infinity; - _this._reconnectCurrentAttempts = 0; - _this._connectionClosed = false; - _this._client = null; - _this._pongReceivedTimestamp = (0, dayjs_1.default)(); - return _this; - } - WebSocket.prototype.start = function () { - this._connectionClosed = false; - this._resetRetryParams(); - this._startWebSocketConnection(); - }; - WebSocket.prototype._startWebSocketConnection = function () { - this._resetConnection(); - this._setupParser(); - this._client = this._connect(this.url, this.stream, this.params, this._accessToken, this.headers, this.proxyConfig); - this._bindSocket(this._client); - }; - WebSocket.prototype.stop = function () { - this._connectionClosed = true; - this._resetConnection(); - this._resetRetryParams(); - }; - WebSocket.prototype._resetConnection = function () { - if (this._client) { - this._client.close(1000); - this._client.removeAllListeners(); - this._client = null; - } - if (this.parser) { - this.parser.removeAllListeners(); - } - }; - WebSocket.prototype._resetRetryParams = function () { - this._reconnectCurrentAttempts = 0; - }; - WebSocket.prototype._reconnect = function () { - var _this = this; - setTimeout(function () { - if (_this._client && _this._client.readyState === ws_1.default.CONNECTING) { - return; - } - if (_this._reconnectCurrentAttempts < _this._reconnectMaxAttempts) { - _this._reconnectCurrentAttempts++; - _this._clearBinding(); - if (_this._client) { - _this._client.terminate(); - } - console.log('Reconnecting'); - _this._client = _this._connect(_this.url, _this.stream, _this.params, _this._accessToken, _this.headers, _this.proxyConfig); - _this._bindSocket(_this._client); - } - }, this._reconnectInterval); - }; - WebSocket.prototype._connect = function (url, stream, params, accessToken, headers, proxyConfig) { - var parameter = ["stream=".concat(stream)]; - if (params) { - parameter.push(params); - } - if (accessToken !== null) { - parameter.push("access_token=".concat(accessToken)); - } - var requestURL = "".concat(url, "/?").concat(parameter.join('&')); - var options = { - headers: headers - }; - if (proxyConfig) { - options = Object.assign(options, { - agent: (0, proxy_config_1.default)(proxyConfig) - }); - } - var cli = new ws_1.default(requestURL, options); - return cli; - }; - WebSocket.prototype._clearBinding = function () { - if (this._client) { - this._client.removeAllListeners('close'); - this._client.removeAllListeners('pong'); - this._client.removeAllListeners('open'); - this._client.removeAllListeners('message'); - this._client.removeAllListeners('error'); - } - }; - WebSocket.prototype._bindSocket = function (client) { - var _this = this; - client.on('close', function (code, _reason) { - if (code === 1000) { - _this.emit('close', {}); - } - else { - console.log("Closed connection with ".concat(code)); - if (!_this._connectionClosed) { - _this._reconnect(); - } - } - }); - client.on('pong', function () { - _this._pongWaiting = false; - _this.emit('pong', {}); - _this._pongReceivedTimestamp = (0, dayjs_1.default)(); - setTimeout(function () { return _this._checkAlive(_this._pongReceivedTimestamp); }, _this._heartbeatInterval); - }); - client.on('open', function () { - _this.emit('connect', {}); - setTimeout(function () { - client.ping(''); - }, 10000); - }); - client.on('message', function (data, isBinary) { - _this.parser.parse(data, isBinary); - }); - client.on('error', function (err) { - _this.emit('error', err); - }); - }; - WebSocket.prototype._setupParser = function () { - var _this = this; - this.parser.on('update', function (status) { - _this.emit('update', api_client_1.default.Converter.status(status)); - }); - this.parser.on('notification', function (notification) { - _this.emit('notification', api_client_1.default.Converter.notification(notification)); - }); - this.parser.on('delete', function (id) { - _this.emit('delete', id); - }); - this.parser.on('conversation', function (conversation) { - _this.emit('conversation', api_client_1.default.Converter.conversation(conversation)); - }); - this.parser.on('status_update', function (status) { - _this.emit('status_update', api_client_1.default.Converter.status(status)); - }); - this.parser.on('error', function (err) { - _this.emit('parser-error', err); - }); - this.parser.on('heartbeat', function (_) { - _this.emit('heartbeat', 'heartbeat'); - }); - }; - WebSocket.prototype._checkAlive = function (timestamp) { - var _this = this; - var now = (0, dayjs_1.default)(); - if (now.diff(timestamp) > this._heartbeatInterval - 1000 && !this._connectionClosed) { - if (this._client && this._client.readyState !== ws_1.default.CONNECTING) { - this._pongWaiting = true; - this._client.ping(''); - setTimeout(function () { - if (_this._pongWaiting) { - _this._pongWaiting = false; - _this._reconnect(); - } - }, 10000); - } - } - }; - return WebSocket; -}(events_1.EventEmitter)); -exports.default = WebSocket; -var Parser = (function (_super) { - __extends(Parser, _super); - function Parser() { - return _super !== null && _super.apply(this, arguments) || this; - } - Parser.prototype.parse = function (data, isBinary) { - var message = isBinary ? data : data.toString(); - if (typeof message !== 'string') { - this.emit('heartbeat', {}); - return; - } - if (message === '') { - this.emit('heartbeat', {}); - return; - } - var event = ''; - var payload = ''; - var mes = {}; - try { - var obj = JSON.parse(message); - event = obj.event; - payload = obj.payload; - mes = JSON.parse(payload); - } - catch (err) { - if (event !== 'delete') { - this.emit('error', new Error("Error parsing websocket reply: ".concat(message, ", error message: ").concat(err))); - return; - } - } - switch (event) { - case 'update': - this.emit('update', mes); - break; - case 'notification': - this.emit('notification', mes); - break; - case 'conversation': - this.emit('conversation', mes); - break; - case 'delete': - this.emit('delete', payload); - break; - case 'status.update': - this.emit('status_update', mes); - break; - default: - this.emit('error', new Error("Unknown event has received: ".concat(message))); - } - }; - return Parser; -}(events_1.EventEmitter)); -exports.Parser = Parser; diff --git a/packages/megalodon/lib/src/proxy_config.d.ts b/packages/megalodon/lib/src/proxy_config.d.ts deleted file mode 100644 index a2ba7ded7b..0000000000 --- a/packages/megalodon/lib/src/proxy_config.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { HttpsProxyAgent } from 'https-proxy-agent'; -import { SocksProxyAgent } from 'socks-proxy-agent'; -export type ProxyConfig = { - host: string; - port: number; - auth?: { - username: string; - password: string; - }; - protocol: 'http' | 'https' | 'socks4' | 'socks4a' | 'socks5' | 'socks5h' | 'socks'; -}; -declare const proxyAgent: (proxyConfig: ProxyConfig) => HttpsProxyAgent | SocksProxyAgent; -export default proxyAgent; diff --git a/packages/megalodon/lib/src/proxy_config.js b/packages/megalodon/lib/src/proxy_config.js deleted file mode 100644 index d087c0f73f..0000000000 --- a/packages/megalodon/lib/src/proxy_config.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var https_proxy_agent_1 = require("https-proxy-agent"); -var socks_proxy_agent_1 = require("socks-proxy-agent"); -var ProxyProtocolError = (function (_super) { - __extends(ProxyProtocolError, _super); - function ProxyProtocolError() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ProxyProtocolError; -}(Error)); -var proxyAgent = function (proxyConfig) { - switch (proxyConfig.protocol) { - case 'http': { - var options = { - host: proxyConfig.host, - port: proxyConfig.port, - secureProxy: false - }; - if (proxyConfig.auth) { - options = Object.assign(options, { - auth: "".concat(proxyConfig.auth.username, ":").concat(proxyConfig.auth.password) - }); - } - var httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(options); - return httpsAgent; - } - case 'https': { - var options = { - host: proxyConfig.host, - port: proxyConfig.port, - secureProxy: true - }; - if (proxyConfig.auth) { - options = Object.assign(options, { - auth: "".concat(proxyConfig.auth.username, ":").concat(proxyConfig.auth.password) - }); - } - var httpsAgent = new https_proxy_agent_1.HttpsProxyAgent(options); - return httpsAgent; - } - case 'socks4': - case 'socks4a': { - var options = { - type: 4, - hostname: proxyConfig.host, - port: proxyConfig.port - }; - if (proxyConfig.auth) { - options = Object.assign(options, { - userId: proxyConfig.auth.username, - password: proxyConfig.auth.password - }); - } - var socksAgent = new socks_proxy_agent_1.SocksProxyAgent(options); - return socksAgent; - } - case 'socks5': - case 'socks5h': - case 'socks': { - var options = { - type: 5, - hostname: proxyConfig.host, - port: proxyConfig.port - }; - if (proxyConfig.auth) { - options = Object.assign(options, { - userId: proxyConfig.auth.username, - password: proxyConfig.auth.password - }); - } - var socksAgent = new socks_proxy_agent_1.SocksProxyAgent(options); - return socksAgent; - } - default: - throw new ProxyProtocolError('protocol is not accepted'); - } -}; -exports.default = proxyAgent; diff --git a/packages/megalodon/lib/src/response.d.ts b/packages/megalodon/lib/src/response.d.ts deleted file mode 100644 index ad96223f72..0000000000 --- a/packages/megalodon/lib/src/response.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -type Response = { - data: T; - status: number; - statusText: string; - headers: any; -}; -export default Response; diff --git a/packages/megalodon/lib/src/response.js b/packages/megalodon/lib/src/response.js deleted file mode 100644 index c8ad2e549b..0000000000 --- a/packages/megalodon/lib/src/response.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/packages/megalodon/lib/test/integration/cancel.spec.d.ts b/packages/megalodon/lib/test/integration/cancel.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/integration/cancel.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/integration/cancel.spec.js b/packages/megalodon/lib/test/integration/cancel.spec.js deleted file mode 100644 index cc61e44296..0000000000 --- a/packages/megalodon/lib/test/integration/cancel.spec.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var api_client_1 = __importDefault(require("@/mastodon/api_client")); -var jest_worker_1 = require("jest-worker"); -jest.mock('axios', function () { - var mockAxios = jest.requireActual('axios'); - mockAxios.get = function (_path) { - return new Promise(function (resolve) { - setTimeout(function () { - console.log('hoge'); - resolve({ - data: 'hoge', - status: 200, - statusText: '200OK', - headers: [], - config: {} - }); - }, 5000); - }); - }; - return mockAxios; -}); -var worker = function (client) { return __awaiter(void 0, void 0, void 0, function () { - var w; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - w = new jest_worker_1.Worker(require.resolve('./cancelWorker.ts')); - return [4, w.cancel(client)]; - case 1: - _a.sent(); - return [2]; - } - }); -}); }; -describe.skip('cancel', function () { - var client = new api_client_1.default.Client('testToken', 'https://pleroma.io/api/v1'); - it('should be raised', function () { return __awaiter(void 0, void 0, void 0, function () { - var getPromise; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - getPromise = client.get('/timelines/home'); - worker(client); - return [4, expect(getPromise).rejects.toThrow()]; - case 1: - _a.sent(); - return [2]; - } - }); - }); }); -}); diff --git a/packages/megalodon/lib/test/integration/cancelWorker.d.ts b/packages/megalodon/lib/test/integration/cancelWorker.d.ts deleted file mode 100644 index ff4f6d1d4c..0000000000 --- a/packages/megalodon/lib/test/integration/cancelWorker.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import MastodonAPI from '@/mastodon/api_client'; -export declare function cancel(client: MastodonAPI.Client): any; diff --git a/packages/megalodon/lib/test/integration/cancelWorker.js b/packages/megalodon/lib/test/integration/cancelWorker.js deleted file mode 100644 index a2bbcce8bb..0000000000 --- a/packages/megalodon/lib/test/integration/cancelWorker.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.cancel = void 0; -function cancel(client) { - return client.cancel(); -} -exports.cancel = cancel; diff --git a/packages/megalodon/lib/test/integration/mastodon.spec.d.ts b/packages/megalodon/lib/test/integration/mastodon.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/integration/mastodon.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/integration/mastodon.spec.js b/packages/megalodon/lib/test/integration/mastodon.spec.js deleted file mode 100644 index 5a94cd3c4a..0000000000 --- a/packages/megalodon/lib/test/integration/mastodon.spec.js +++ /dev/null @@ -1,219 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var notification_1 = __importDefault(require("@/mastodon/notification")); -var mastodon_1 = __importDefault(require("@/mastodon")); -var notification_2 = __importDefault(require("@/notification")); -var axios_1 = __importDefault(require("axios")); -jest.mock('axios'); -var account = { - id: '1', - username: 'h3poteto', - acct: 'h3poteto@pleroma.io', - display_name: 'h3poteto', - locked: false, - created_at: '2019-03-26T21:30:32', - followers_count: 10, - following_count: 10, - statuses_count: 100, - note: 'engineer', - url: 'https://pleroma.io', - avatar: '', - avatar_static: '', - header: '', - header_static: '', - emojis: [], - moved: null, - fields: [], - bot: false -}; -var status = { - id: '1', - uri: 'http://example.com', - url: 'http://example.com', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: 'hoge', - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - bookmarked: false -}; -var follow = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '1', - type: notification_1.default.Follow -}; -var favourite = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '2', - status: status, - type: notification_1.default.Favourite -}; -var mention = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '3', - status: status, - type: notification_1.default.Mention -}; -var reblog = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '4', - status: status, - type: notification_1.default.Reblog -}; -var poll = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '5', - type: notification_1.default.Poll -}; -var followRequest = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '6', - type: notification_1.default.FollowRequest -}; -var toot = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '7', - status: status, - type: notification_1.default.Status -}; -axios_1.default.CancelToken.source.mockImplementation(function () { - return { - token: { - throwIfRequested: function () { }, - promise: { - then: function () { }, - catch: function () { } - } - } - }; -}); -describe('getNotifications', function () { - var client = new mastodon_1.default('http://localhost', 'sample token'); - var cases = [ - { - event: follow, - expected: notification_2.default.Follow, - title: 'follow' - }, - { - event: favourite, - expected: notification_2.default.Favourite, - title: 'favourite' - }, - { - event: mention, - expected: notification_2.default.Mention, - title: 'mention' - }, - { - event: reblog, - expected: notification_2.default.Reblog, - title: 'reblog' - }, - { - event: poll, - expected: notification_2.default.PollExpired, - title: 'poll' - }, - { - event: followRequest, - expected: notification_2.default.FollowRequest, - title: 'followRequest' - }, - { - event: toot, - expected: notification_2.default.Status, - title: 'status' - } - ]; - cases.forEach(function (c) { - it("should be ".concat(c.title, " event"), function () { return __awaiter(void 0, void 0, void 0, function () { - var mockResponse, res; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - mockResponse = { - data: [c.event], - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - axios_1.default.get.mockResolvedValue(mockResponse); - return [4, client.getNotifications()]; - case 1: - res = _a.sent(); - expect(res.data[0].type).toEqual(c.expected); - return [2]; - } - }); - }); }); - }); -}); diff --git a/packages/megalodon/lib/test/integration/mastodon/api_client.spec.d.ts b/packages/megalodon/lib/test/integration/mastodon/api_client.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/integration/mastodon/api_client.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/integration/mastodon/api_client.spec.js b/packages/megalodon/lib/test/integration/mastodon/api_client.spec.js deleted file mode 100644 index 90ded51ccf..0000000000 --- a/packages/megalodon/lib/test/integration/mastodon/api_client.spec.js +++ /dev/null @@ -1,242 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var api_client_1 = __importDefault(require("@/mastodon/api_client")); -var axios_1 = __importDefault(require("axios")); -jest.mock('axios'); -var account = { - id: '1', - username: 'h3poteto', - acct: 'h3poteto@pleroma.io', - display_name: 'h3poteto', - locked: false, - created_at: '2019-03-26T21:30:32', - followers_count: 10, - following_count: 10, - statuses_count: 100, - note: 'engineer', - url: 'https://pleroma.io', - avatar: '', - avatar_static: '', - header: '', - header_static: '', - emojis: [], - moved: null, - fields: [], - bot: false -}; -var status = { - id: '1', - uri: 'http://example.com', - url: 'http://example.com', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: 'hoge', - plain_content: null, - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - emoji_reactions: [], - bookmarked: false, - quote: null -}; -axios_1.default.CancelToken.source.mockImplementation(function () { - return { - token: { - throwIfRequested: function () { }, - promise: { - then: function () { }, - catch: function () { } - } - } - }; -}); -describe('get', function () { - var client = new api_client_1.default.Client('testToken', 'https://pleroma.io/api/v1'); - var mockResponse = { - data: [status], - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - it('should be responsed', function () { return __awaiter(void 0, void 0, void 0, function () { - var response; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - ; - axios_1.default.get.mockResolvedValue(mockResponse); - return [4, client.get('/timelines/home')]; - case 1: - response = _a.sent(); - expect(response.data).toEqual([status]); - return [2]; - } - }); - }); }); -}); -describe('put', function () { - var client = new api_client_1.default.Client('testToken', 'https://pleroma.io/api/v1'); - var mockResponse = { - data: account, - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - it('should be responsed', function () { return __awaiter(void 0, void 0, void 0, function () { - var response; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - ; - axios_1.default.put.mockResolvedValue(mockResponse); - return [4, client.put('/accounts/update_credentials', { - display_name: 'hoge' - })]; - case 1: - response = _a.sent(); - expect(response.data).toEqual(account); - return [2]; - } - }); - }); }); -}); -describe('patch', function () { - var client = new api_client_1.default.Client('testToken', 'https://pleroma.io/api/v1'); - var mockResponse = { - data: account, - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - it('should be responsed', function () { return __awaiter(void 0, void 0, void 0, function () { - var response; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - ; - axios_1.default.patch.mockResolvedValue(mockResponse); - return [4, client.patch('/accounts/update_credentials', { - display_name: 'hoge' - })]; - case 1: - response = _a.sent(); - expect(response.data).toEqual(account); - return [2]; - } - }); - }); }); -}); -describe('post', function () { - var client = new api_client_1.default.Client('testToken', 'https://pleroma.io/api/v1'); - var mockResponse = { - data: status, - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - it('should be responsed', function () { return __awaiter(void 0, void 0, void 0, function () { - var response; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - ; - axios_1.default.post.mockResolvedValue(mockResponse); - return [4, client.post('/statuses', { - status: 'hoge' - })]; - case 1: - response = _a.sent(); - expect(response.data).toEqual(status); - return [2]; - } - }); - }); }); -}); -describe('del', function () { - var client = new api_client_1.default.Client('testToken', 'https://pleroma.io/api/v1'); - var mockResponse = { - data: {}, - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - it('should be responsed', function () { return __awaiter(void 0, void 0, void 0, function () { - var response; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - ; - axios_1.default.delete.mockResolvedValue(mockResponse); - return [4, client.del('/statuses/12asdf34')]; - case 1: - response = _a.sent(); - expect(response.data).toEqual({}); - return [2]; - } - }); - }); }); -}); diff --git a/packages/megalodon/lib/test/integration/megalodon.spec.d.ts b/packages/megalodon/lib/test/integration/megalodon.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/integration/megalodon.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/integration/megalodon.spec.js b/packages/megalodon/lib/test/integration/megalodon.spec.js deleted file mode 100644 index 7a822a019a..0000000000 --- a/packages/megalodon/lib/test/integration/megalodon.spec.js +++ /dev/null @@ -1,86 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var index_1 = require("../../src/index"); -describe('detector', function () { - describe('mastodon', function () { - var url = 'https://fedibird.com'; - it('should be mastodon', function () { return __awaiter(void 0, void 0, void 0, function () { - var mastodon; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, (0, index_1.detector)(url)]; - case 1: - mastodon = _a.sent(); - expect(mastodon).toEqual('mastodon'); - return [2]; - } - }); - }); }); - }); - describe('pleroma', function () { - var url = 'https://pleroma.soykaf.com'; - it('should be pleroma', function () { return __awaiter(void 0, void 0, void 0, function () { - var pleroma; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, (0, index_1.detector)(url)]; - case 1: - pleroma = _a.sent(); - expect(pleroma).toEqual('pleroma'); - return [2]; - } - }); - }); }); - }); - describe('misskey', function () { - var url = 'https://misskey.io'; - it('should be misskey', function () { return __awaiter(void 0, void 0, void 0, function () { - var misskey; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, (0, index_1.detector)(url)]; - case 1: - misskey = _a.sent(); - expect(misskey).toEqual('misskey'); - return [2]; - } - }); - }); }); - }); -}); diff --git a/packages/megalodon/lib/test/integration/misskey.spec.d.ts b/packages/megalodon/lib/test/integration/misskey.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/integration/misskey.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/integration/misskey.spec.js b/packages/megalodon/lib/test/integration/misskey.spec.js deleted file mode 100644 index cbf48dd7fb..0000000000 --- a/packages/megalodon/lib/test/integration/misskey.spec.js +++ /dev/null @@ -1,238 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var notification_1 = __importDefault(require("@/misskey/notification")); -var misskey_1 = __importDefault(require("@/misskey")); -var notification_2 = __importDefault(require("@/notification")); -var axios_1 = __importDefault(require("axios")); -jest.mock('axios'); -var user = { - id: '1', - name: 'test_user', - username: 'TestUser', - host: 'misskey.io', - avatarUrl: 'https://example.com/icon.png', - avatarColor: '#000000', - emojis: [] -}; -var note = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: '1', - user: user, - text: 'hogehoge', - cw: null, - visibility: 'public', - renoteCount: 0, - repliesCount: 0, - reactions: {}, - emojis: [], - fileIds: [], - files: [], - replyId: null, - renoteId: null -}; -var follow = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.Follow -}; -var mention = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.Mention, - note: note -}; -var reply = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.Reply, - note: note -}; -var renote = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.Renote, - note: note -}; -var quote = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.Quote, - note: note -}; -var reaction = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.Reaction, - note: note, - reaction: '♥' -}; -var pollVote = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.PollVote, - note: note -}; -var receiveFollowRequest = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.ReceiveFollowRequest -}; -var followRequestAccepted = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.FollowRequestAccepted -}; -var groupInvited = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: user.id, - user: user, - type: notification_1.default.GroupInvited -}; -axios_1.default.CancelToken.source.mockImplementation(function () { - return { - token: { - throwIfRequested: function () { }, - promise: { - then: function () { }, - catch: function () { } - } - } - }; -}); -describe('getNotifications', function () { - var client = new misskey_1.default('http://localhost', 'sample token'); - var cases = [ - { - event: follow, - expected: notification_2.default.Follow, - title: 'follow' - }, - { - event: mention, - expected: notification_2.default.Mention, - title: 'mention' - }, - { - event: reply, - expected: notification_2.default.Mention, - title: 'reply' - }, - { - event: renote, - expected: notification_2.default.Reblog, - title: 'renote' - }, - { - event: quote, - expected: notification_2.default.Reblog, - title: 'quote' - }, - { - event: reaction, - expected: notification_2.default.EmojiReaction, - title: 'reaction' - }, - { - event: pollVote, - expected: notification_2.default.PollVote, - title: 'pollVote' - }, - { - event: receiveFollowRequest, - expected: notification_2.default.FollowRequest, - title: 'receiveFollowRequest' - }, - { - event: followRequestAccepted, - expected: notification_2.default.Follow, - title: 'followRequestAccepted' - }, - { - event: groupInvited, - expected: notification_1.default.GroupInvited, - title: 'groupInvited' - } - ]; - cases.forEach(function (c) { - it("should be ".concat(c.title, " event"), function () { return __awaiter(void 0, void 0, void 0, function () { - var mockResponse, res; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - mockResponse = { - data: [c.event], - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - axios_1.default.post.mockResolvedValue(mockResponse); - return [4, client.getNotifications()]; - case 1: - res = _a.sent(); - expect(res.data[0].type).toEqual(c.expected); - return [2]; - } - }); - }); }); - }); -}); diff --git a/packages/megalodon/lib/test/integration/pleroma.spec.d.ts b/packages/megalodon/lib/test/integration/pleroma.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/integration/pleroma.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/integration/pleroma.spec.js b/packages/megalodon/lib/test/integration/pleroma.spec.js deleted file mode 100644 index 655f16e4ef..0000000000 --- a/packages/megalodon/lib/test/integration/pleroma.spec.js +++ /dev/null @@ -1,224 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var pleroma_1 = __importDefault(require("@/pleroma")); -var notification_1 = __importDefault(require("@/notification")); -var notification_2 = __importDefault(require("@/pleroma/notification")); -var axios_1 = __importDefault(require("axios")); -jest.mock('axios'); -var account = { - id: '1', - username: 'h3poteto', - acct: 'h3poteto@pleroma.io', - display_name: 'h3poteto', - locked: false, - created_at: '2019-03-26T21:30:32', - followers_count: 10, - following_count: 10, - statuses_count: 100, - note: 'engineer', - url: 'https://pleroma.io', - avatar: '', - avatar_static: '', - header: '', - header_static: '', - emojis: [], - moved: null, - fields: [], - bot: false -}; -var status = { - id: '1', - uri: 'http://example.com', - url: 'http://example.com', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: 'hoge', - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - bookmarked: false, - pleroma: { - local: false - } -}; -var follow = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '1', - type: notification_2.default.Follow -}; -var favourite = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '2', - type: notification_2.default.Favourite, - status: status -}; -var mention = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '3', - type: notification_2.default.Mention, - status: status -}; -var reblog = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '4', - type: notification_2.default.Reblog, - status: status -}; -var poll = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '5', - type: notification_2.default.Poll, - status: status -}; -var emojiReaction = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '6', - type: notification_2.default.PleromaEmojiReaction, - status: status, - emoji: '♥' -}; -var followRequest = { - account: account, - created_at: '2021-01-31T23:33:26', - id: '7', - type: notification_2.default.FollowRequest -}; -axios_1.default.CancelToken.source.mockImplementation(function () { - return { - token: { - throwIfRequested: function () { }, - promise: { - then: function () { }, - catch: function () { } - } - } - }; -}); -describe('getNotifications', function () { - var client = new pleroma_1.default('http://localhost', 'sample token'); - var cases = [ - { - event: follow, - expected: notification_1.default.Follow, - title: 'follow' - }, - { - event: favourite, - expected: notification_1.default.Favourite, - title: 'favourite' - }, - { - event: mention, - expected: notification_1.default.Mention, - title: 'mention' - }, - { - event: reblog, - expected: notification_1.default.Reblog, - title: 'reblog' - }, - { - event: poll, - expected: notification_1.default.PollExpired, - title: 'poll' - }, - { - event: emojiReaction, - expected: notification_1.default.EmojiReaction, - title: 'emojiReaction' - }, - { - event: followRequest, - expected: notification_1.default.FollowRequest, - title: 'followRequest' - } - ]; - cases.forEach(function (c) { - it("should be ".concat(c.title, " event"), function () { return __awaiter(void 0, void 0, void 0, function () { - var mockResponse, res; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - mockResponse = { - data: [c.event], - status: 200, - statusText: '200OK', - headers: {}, - config: {} - }; - axios_1.default.get.mockResolvedValue(mockResponse); - return [4, client.getNotifications()]; - case 1: - res = _a.sent(); - expect(res.data[0].type).toEqual(c.expected); - return [2]; - } - }); - }); }); - }); -}); diff --git a/packages/megalodon/lib/test/unit/mastodon.spec.d.ts b/packages/megalodon/lib/test/unit/mastodon.spec.d.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/megalodon/lib/test/unit/mastodon.spec.js b/packages/megalodon/lib/test/unit/mastodon.spec.js deleted file mode 100644 index 6c5e8b997b..0000000000 --- a/packages/megalodon/lib/test/unit/mastodon.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -describe('test', function () { - it('should be true', function () { - var res = true; - expect(res).toEqual(true); - }); -}); diff --git a/packages/megalodon/lib/test/unit/mastodon/api_client.spec.d.ts b/packages/megalodon/lib/test/unit/mastodon/api_client.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/unit/mastodon/api_client.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/unit/mastodon/api_client.spec.js b/packages/megalodon/lib/test/unit/mastodon/api_client.spec.js deleted file mode 100644 index bf8bc751fc..0000000000 --- a/packages/megalodon/lib/test/unit/mastodon/api_client.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var api_client_1 = __importDefault(require("@/mastodon/api_client")); -var notification_1 = __importDefault(require("@/notification")); -var notification_2 = __importDefault(require("@/mastodon/notification")); -describe('api_client', function () { - describe('notification', function () { - describe('encode', function () { - it('megalodon notification type should be encoded to mastodon notification type', function () { - var cases = [ - { - src: notification_1.default.Follow, - dist: notification_2.default.Follow - }, - { - src: notification_1.default.Favourite, - dist: notification_2.default.Favourite - }, - { - src: notification_1.default.Reblog, - dist: notification_2.default.Reblog - }, - { - src: notification_1.default.Mention, - dist: notification_2.default.Mention - }, - { - src: notification_1.default.PollExpired, - dist: notification_2.default.Poll - }, - { - src: notification_1.default.FollowRequest, - dist: notification_2.default.FollowRequest - }, - { - src: notification_1.default.Status, - dist: notification_2.default.Status - } - ]; - cases.forEach(function (c) { - expect(api_client_1.default.Converter.encodeNotificationType(c.src)).toEqual(c.dist); - }); - }); - }); - describe('decode', function () { - it('mastodon notification type should be decoded to megalodon notification type', function () { - var cases = [ - { - src: notification_2.default.Follow, - dist: notification_1.default.Follow - }, - { - src: notification_2.default.Favourite, - dist: notification_1.default.Favourite - }, - { - src: notification_2.default.Mention, - dist: notification_1.default.Mention - }, - { - src: notification_2.default.Reblog, - dist: notification_1.default.Reblog - }, - { - src: notification_2.default.Poll, - dist: notification_1.default.PollExpired - }, - { - src: notification_2.default.FollowRequest, - dist: notification_1.default.FollowRequest - } - ]; - cases.forEach(function (c) { - expect(api_client_1.default.Converter.decodeNotificationType(c.src)).toEqual(c.dist); - }); - }); - }); - }); -}); diff --git a/packages/megalodon/lib/test/unit/misskey/api_client.spec.d.ts b/packages/megalodon/lib/test/unit/misskey/api_client.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/unit/misskey/api_client.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/unit/misskey/api_client.spec.js b/packages/megalodon/lib/test/unit/misskey/api_client.spec.js deleted file mode 100644 index 5c7635567c..0000000000 --- a/packages/megalodon/lib/test/unit/misskey/api_client.spec.js +++ /dev/null @@ -1,231 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var api_client_1 = __importDefault(require("@/misskey/api_client")); -var notification_1 = __importDefault(require("@/notification")); -var notification_2 = __importDefault(require("@/misskey/notification")); -var user = { - id: '1', - name: 'test_user', - username: 'TestUser', - host: 'misskey.io', - avatarUrl: 'https://example.com/icon.png', - avatarColor: '#000000', - emojis: [] -}; -var converter = new api_client_1.default.Converter("https://example.com"); -describe('api_client', function () { - describe('notification', function () { - describe('encode', function () { - it('megalodon notification type should be encoded to misskey notification type', function () { - var cases = [ - { - src: notification_1.default.Follow, - dist: notification_2.default.Follow - }, - { - src: notification_1.default.Mention, - dist: notification_2.default.Reply - }, - { - src: notification_1.default.Favourite, - dist: notification_2.default.Reaction - }, - { - src: notification_1.default.EmojiReaction, - dist: notification_2.default.Reaction - }, - { - src: notification_1.default.Reblog, - dist: notification_2.default.Renote - }, - { - src: notification_1.default.PollVote, - dist: notification_2.default.PollVote - }, - { - src: notification_1.default.FollowRequest, - dist: notification_2.default.ReceiveFollowRequest - } - ]; - cases.forEach(function (c) { - expect(converter.encodeNotificationType(c.src)).toEqual(c.dist); - }); - }); - }); - describe('decode', function () { - it('misskey notification type should be decoded to megalodon notification type', function () { - var cases = [ - { - src: notification_2.default.Follow, - dist: notification_1.default.Follow - }, - { - src: notification_2.default.Mention, - dist: notification_1.default.Mention - }, - { - src: notification_2.default.Reply, - dist: notification_1.default.Mention - }, - { - src: notification_2.default.Renote, - dist: notification_1.default.Reblog - }, - { - src: notification_2.default.Quote, - dist: notification_1.default.Reblog - }, - { - src: notification_2.default.Reaction, - dist: notification_1.default.EmojiReaction - }, - { - src: notification_2.default.PollVote, - dist: notification_1.default.PollVote - }, - { - src: notification_2.default.ReceiveFollowRequest, - dist: notification_1.default.FollowRequest - }, - { - src: notification_2.default.FollowRequestAccepted, - dist: notification_1.default.Follow - } - ]; - cases.forEach(function (c) { - expect(converter.decodeNotificationType(c.src)).toEqual(c.dist); - }); - }); - }); - }); - describe('reactions', function () { - it('should be mapped', function () { - var misskeyReactions = [ - { - id: '1', - createdAt: '2020-04-21T13:04:13.968Z', - user: { - id: '81u70uwsja', - name: 'h3poteto', - username: 'h3poteto', - host: null, - avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png', - avatarColor: 'rgb(146,189,195)', - emojis: [] - }, - type: '❤' - }, - { - id: '2', - createdAt: '2020-04-21T13:04:13.968Z', - user: { - id: '81u70uwsja', - name: 'h3poteto', - username: 'h3poteto', - host: null, - avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png', - avatarColor: 'rgb(146,189,195)', - emojis: [] - }, - type: '❤' - }, - { - id: '3', - createdAt: '2020-04-21T13:04:13.968Z', - user: { - id: '81u70uwsja', - name: 'h3poteto', - username: 'h3poteto', - host: null, - avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png', - avatarColor: 'rgb(146,189,195)', - emojis: [] - }, - type: '☺' - }, - { - id: '4', - createdAt: '2020-04-21T13:04:13.968Z', - user: { - id: '81u70uwsja', - name: 'h3poteto', - username: 'h3poteto', - host: null, - avatarUrl: 'https://s3.arkjp.net/misskey/thumbnail-63807d97-20ca-40ba-9493-179aa48065c1.png', - avatarColor: 'rgb(146,189,195)', - emojis: [] - }, - type: '❤' - } - ]; - var reactions = converter.reactions(misskeyReactions); - expect(reactions).toEqual([ - { - count: 3, - me: false, - name: '❤' - }, - { - count: 1, - me: false, - name: '☺' - } - ]); - }); - }); - describe('status', function () { - describe('plain content', function () { - it('should be exported plain content and html content', function () { - var plainContent = 'hoge\nfuga\nfuga'; - var content = 'hoge
fuga
fuga'; - var note = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: '1', - user: user, - text: plainContent, - cw: null, - visibility: 'public', - renoteCount: 0, - repliesCount: 0, - reactions: {}, - emojis: [], - fileIds: [], - files: [], - replyId: null, - renoteId: null - }; - var megalodonStatus = converter.note(note, user.host || 'misskey.io'); - expect(megalodonStatus.plain_content).toEqual(plainContent); - expect(megalodonStatus.content).toEqual(content); - }); - it('html tags should be escaped', function () { - var plainContent = '

hoge\nfuga\nfuga

'; - var content = '<p>hoge
fuga
fuga<p>'; - var note = { - id: '1', - createdAt: '2021-02-01T01:49:29', - userId: '1', - user: user, - text: plainContent, - cw: null, - visibility: 'public', - renoteCount: 0, - repliesCount: 0, - reactions: {}, - emojis: [], - fileIds: [], - files: [], - replyId: null, - renoteId: null - }; - var megalodonStatus = converter.note(note, user.host || 'misskey.io'); - expect(megalodonStatus.plain_content).toEqual(plainContent); - expect(megalodonStatus.content).toEqual(content); - }); - }); - }); -}); diff --git a/packages/megalodon/lib/test/unit/parser.spec.d.ts b/packages/megalodon/lib/test/unit/parser.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/unit/parser.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/unit/parser.spec.js b/packages/megalodon/lib/test/unit/parser.spec.js deleted file mode 100644 index acb3f79fe7..0000000000 --- a/packages/megalodon/lib/test/unit/parser.spec.js +++ /dev/null @@ -1,141 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var parser_1 = require("@/parser"); -var account = { - id: '1', - username: 'h3poteto', - acct: 'h3poteto@pleroma.io', - display_name: 'h3poteto', - locked: false, - created_at: '2019-03-26T21:30:32', - followers_count: 10, - following_count: 10, - statuses_count: 100, - note: 'engineer', - url: 'https://pleroma.io', - avatar: '', - avatar_static: '', - header: '', - header_static: '', - emojis: [], - moved: null, - fields: [], - bot: false -}; -var status = { - id: '1', - uri: 'http://example.com', - url: 'http://example.com', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: 'hoge', - plain_content: 'hoge', - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - emoji_reactions: [], - bookmarked: false, - quote: null -}; -var notification = { - id: '1', - account: account, - status: status, - type: 'favourite', - created_at: '2019-04-01T17:01:32' -}; -var conversation = { - id: '1', - accounts: [account], - last_status: status, - unread: true -}; -describe('Parser', function () { - var parser; - beforeEach(function () { - parser = new parser_1.Parser(); - }); - describe('parse', function () { - describe('message is heartbeat', function () { - var message = ':thump\n'; - it('should be called', function () { - var spy = jest.fn(); - parser.on('heartbeat', spy); - parser.parse(message); - expect(spy).toHaveBeenLastCalledWith({}); - }); - }); - describe('message is not json', function () { - describe('event is delete', function () { - var message = "event: delete\ndata: 12asdf34\n\n"; - it('should be called', function () { - var spy = jest.fn(); - parser.once('delete', spy); - parser.parse(message); - expect(spy).toHaveBeenCalledWith('12asdf34'); - }); - }); - describe('event is not delete', function () { - var message = "event: event\ndata: 12asdf34\n\n"; - it('should be error', function () { - var error = jest.fn(); - var deleted = jest.fn(); - parser.once('error', error); - parser.once('delete', deleted); - parser.parse(message); - expect(error).toHaveBeenCalled(); - expect(deleted).not.toHaveBeenCalled(); - }); - }); - }); - describe('message is json', function () { - describe('event is update', function () { - var message = "event: update\ndata: ".concat(JSON.stringify(status), "\n\n"); - it('should be called', function () { - var spy = jest.fn(); - parser.once('update', spy); - parser.parse(message); - expect(spy).toHaveBeenCalledWith(status); - }); - }); - describe('event is notification', function () { - var message = "event: notification\ndata: ".concat(JSON.stringify(notification), "\n\n"); - it('should be called', function () { - var spy = jest.fn(); - parser.once('notification', spy); - parser.parse(message); - expect(spy).toHaveBeenCalledWith(notification); - }); - }); - describe('event is conversation', function () { - var message = "event: conversation\ndata: ".concat(JSON.stringify(conversation), "\n\n"); - it('should be called', function () { - var spy = jest.fn(); - parser.once('conversation', spy); - parser.parse(message); - expect(spy).toHaveBeenCalledWith(conversation); - }); - }); - }); - }); -}); diff --git a/packages/megalodon/lib/test/unit/pleroma/api_client.spec.d.ts b/packages/megalodon/lib/test/unit/pleroma/api_client.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/unit/pleroma/api_client.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/unit/pleroma/api_client.spec.js b/packages/megalodon/lib/test/unit/pleroma/api_client.spec.js deleted file mode 100644 index 4233db0381..0000000000 --- a/packages/megalodon/lib/test/unit/pleroma/api_client.spec.js +++ /dev/null @@ -1,199 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var api_client_1 = __importDefault(require("@/pleroma/api_client")); -var notification_1 = __importDefault(require("@/notification")); -var notification_2 = __importDefault(require("@/pleroma/notification")); -var account = { - id: '1', - username: 'h3poteto', - acct: 'h3poteto@pleroma.io', - display_name: 'h3poteto', - locked: false, - created_at: '2019-03-26T21:30:32', - followers_count: 10, - following_count: 10, - statuses_count: 100, - note: 'engineer', - url: 'https://pleroma.io', - avatar: '', - avatar_static: '', - header: '', - header_static: '', - emojis: [], - moved: null, - fields: [], - bot: false -}; -describe('api_client', function () { - describe('notification', function () { - describe('encode', function () { - it('megalodon notification type should be encoded to pleroma notification type', function () { - var cases = [ - { - src: notification_1.default.Follow, - dist: notification_2.default.Follow - }, - { - src: notification_1.default.Favourite, - dist: notification_2.default.Favourite - }, - { - src: notification_1.default.Reblog, - dist: notification_2.default.Reblog - }, - { - src: notification_1.default.Mention, - dist: notification_2.default.Mention - }, - { - src: notification_1.default.PollExpired, - dist: notification_2.default.Poll - }, - { - src: notification_1.default.EmojiReaction, - dist: notification_2.default.PleromaEmojiReaction - }, - { - src: notification_1.default.FollowRequest, - dist: notification_2.default.FollowRequest - } - ]; - cases.forEach(function (c) { - expect(api_client_1.default.Converter.encodeNotificationType(c.src)).toEqual(c.dist); - }); - }); - }); - describe('decode', function () { - it('pleroma notification type should be decoded to megalodon notification type', function () { - var cases = [ - { - src: notification_2.default.Follow, - dist: notification_1.default.Follow - }, - { - src: notification_2.default.Favourite, - dist: notification_1.default.Favourite - }, - { - src: notification_2.default.Mention, - dist: notification_1.default.Mention - }, - { - src: notification_2.default.Reblog, - dist: notification_1.default.Reblog - }, - { - src: notification_2.default.Poll, - dist: notification_1.default.PollExpired - }, - { - src: notification_2.default.PleromaEmojiReaction, - dist: notification_1.default.EmojiReaction - }, - { - src: notification_2.default.FollowRequest, - dist: notification_1.default.FollowRequest - } - ]; - cases.forEach(function (c) { - expect(api_client_1.default.Converter.decodeNotificationType(c.src)).toEqual(c.dist); - }); - }); - }); - }); - describe('status', function () { - describe('plain content is included', function () { - it('plain content in pleroma entity should be exported in plain_content column', function () { - var plainContent = 'hoge\nfuga\nfuga'; - var content = '

hoge
fuga
fuga

'; - var pleromaStatus = { - id: '1', - uri: 'https://pleroma.io/notice/1', - url: 'https://pleroma.io/notice/1', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: content, - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - bookmarked: false, - pleroma: { - content: { - 'text/plain': plainContent - }, - local: false - } - }; - var megalodonStatus = api_client_1.default.Converter.status(pleromaStatus); - expect(megalodonStatus.plain_content).toEqual(plainContent); - expect(megalodonStatus.content).toEqual(content); - }); - }); - describe('plain content is not included', function () { - it('plain_content should be null', function () { - var content = '

hoge
fuga
fuga

'; - var pleromaStatus = { - id: '1', - uri: 'https://pleroma.io/notice/1', - url: 'https://pleroma.io/notice/1', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: content, - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - bookmarked: false, - pleroma: { - local: false - } - }; - var megalodonStatus = api_client_1.default.Converter.status(pleromaStatus); - expect(megalodonStatus.plain_content).toBeNull(); - expect(megalodonStatus.content).toEqual(content); - }); - }); - }); -}); diff --git a/packages/megalodon/lib/test/unit/webo_socket.spec.d.ts b/packages/megalodon/lib/test/unit/webo_socket.spec.d.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/megalodon/lib/test/unit/webo_socket.spec.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/megalodon/lib/test/unit/webo_socket.spec.js b/packages/megalodon/lib/test/unit/webo_socket.spec.js deleted file mode 100644 index bb18640af9..0000000000 --- a/packages/megalodon/lib/test/unit/webo_socket.spec.js +++ /dev/null @@ -1,167 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var web_socket_1 = require("@/mastodon/web_socket"); -var account = { - id: '1', - username: 'h3poteto', - acct: 'h3poteto@pleroma.io', - display_name: 'h3poteto', - locked: false, - created_at: '2019-03-26T21:30:32', - followers_count: 10, - following_count: 10, - statuses_count: 100, - note: 'engineer', - url: 'https://pleroma.io', - avatar: '', - avatar_static: '', - header: '', - header_static: '', - emojis: [], - moved: null, - fields: [], - bot: false -}; -var status = { - id: '1', - uri: 'http://example.com', - url: 'http://example.com', - account: account, - in_reply_to_id: null, - in_reply_to_account_id: null, - reblog: null, - content: 'hoge', - plain_content: 'hoge', - created_at: '2019-03-26T21:40:32', - emojis: [], - replies_count: 0, - reblogs_count: 0, - favourites_count: 0, - reblogged: null, - favourited: null, - muted: null, - sensitive: false, - spoiler_text: '', - visibility: 'public', - media_attachments: [], - mentions: [], - tags: [], - card: null, - poll: null, - application: { - name: 'Web' - }, - language: null, - pinned: null, - emoji_reactions: [], - bookmarked: false, - quote: null -}; -var notification = { - id: '1', - account: account, - status: status, - type: 'favourite', - created_at: '2019-04-01T17:01:32' -}; -var conversation = { - id: '1', - accounts: [account], - last_status: status, - unread: true -}; -describe('Parser', function () { - var parser; - beforeEach(function () { - parser = new web_socket_1.Parser(); - }); - describe('parse', function () { - describe('message is heartbeat', function () { - describe('message is an object', function () { - var message = Buffer.alloc(0); - it('should be called', function () { - var spy = jest.fn(); - parser.once('heartbeat', spy); - parser.parse(message, true); - expect(spy).toHaveBeenCalledWith({}); - }); - }); - describe('message is empty string', function () { - var message = ''; - it('should be called', function () { - var spy = jest.fn(); - parser.once('heartbeat', spy); - parser.parse(Buffer.from(message), false); - expect(spy).toHaveBeenCalledWith({}); - }); - }); - }); - describe('message is not json', function () { - describe('event is delete', function () { - var message = JSON.stringify({ - event: 'delete', - payload: '12asdf34' - }); - it('should be called', function () { - var spy = jest.fn(); - parser.once('delete', spy); - parser.parse(Buffer.from(message), false); - expect(spy).toHaveBeenCalledWith('12asdf34'); - }); - }); - describe('event is not delete', function () { - var message = JSON.stringify({ - event: 'event', - payload: '12asdf34' - }); - it('should be called', function () { - var error = jest.fn(); - var deleted = jest.fn(); - parser.once('error', error); - parser.once('delete', deleted); - parser.parse(Buffer.from(message), false); - expect(error).toHaveBeenCalled(); - expect(deleted).not.toHaveBeenCalled(); - }); - }); - }); - describe('message is json', function () { - describe('event is update', function () { - var message = JSON.stringify({ - event: 'update', - payload: JSON.stringify(status) - }); - it('should be called', function () { - var spy = jest.fn(); - parser.once('update', spy); - parser.parse(Buffer.from(message), false); - expect(spy).toHaveBeenCalledWith(status); - }); - }); - describe('event is notification', function () { - var message = JSON.stringify({ - event: 'notification', - payload: JSON.stringify(notification) - }); - it('should be called', function () { - var spy = jest.fn(); - parser.once('notification', spy); - parser.parse(Buffer.from(message), false); - expect(spy).toHaveBeenCalledWith(notification); - }); - }); - describe('event is conversation', function () { - var message = JSON.stringify({ - event: 'conversation', - payload: JSON.stringify(conversation) - }); - it('should be called', function () { - var spy = jest.fn(); - parser.once('conversation', spy); - parser.parse(Buffer.from(message), false); - expect(spy).toHaveBeenCalledWith(conversation); - }); - }); - }); - }); -});