diff --git a/package.json b/package.json
index db96ae1ca5..ec899739fb 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"seedrandom": "^3.0.5"
},
"devDependencies": {
+ "@types/node": "18.11.18",
"@types/gulp": "4.0.10",
"@types/gulp-rename": "2.0.1",
"chalk": "4.1.2",
diff --git a/packages/backend/package.json b/packages/backend/package.json
index 6f63441023..2037490924 100644
--- a/packages/backend/package.json
+++ b/packages/backend/package.json
@@ -28,7 +28,7 @@
"@bull-board/api": "5.2.0",
"@bull-board/koa": "5.2.0",
"@bull-board/ui": "5.2.0",
- "@calckey/megalodon": "5.2.0",
+ "@calckey/megalodon": "workspace:*",
"@discordapp/twemoji": "14.1.2",
"@elastic/elasticsearch": "7.17.0",
"@koa/cors": "3.4.3",
diff --git a/packages/megalodon/.idea/.gitignore b/packages/megalodon/.idea/.gitignore
new file mode 100644
index 0000000000..b58b603fea
--- /dev/null
+++ b/packages/megalodon/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/packages/megalodon/.idea/compiler.xml b/packages/megalodon/.idea/compiler.xml
new file mode 100644
index 0000000000..1a2fb332ee
--- /dev/null
+++ b/packages/megalodon/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/megalodon/.idea/inspectionProfiles/Project_Default.xml b/packages/megalodon/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000000..03d9549ea8
--- /dev/null
+++ b/packages/megalodon/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/megalodon/.idea/jsLibraryMappings.xml b/packages/megalodon/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000000..d23208fbb7
--- /dev/null
+++ b/packages/megalodon/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/megalodon/.idea/megalodon.iml b/packages/megalodon/.idea/megalodon.iml
new file mode 100644
index 0000000000..24643cc374
--- /dev/null
+++ b/packages/megalodon/.idea/megalodon.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/megalodon/.idea/modules.xml b/packages/megalodon/.idea/modules.xml
new file mode 100644
index 0000000000..2ae34ba951
--- /dev/null
+++ b/packages/megalodon/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/megalodon/.idea/vcs.xml b/packages/megalodon/.idea/vcs.xml
new file mode 100644
index 0000000000..6c0b863585
--- /dev/null
+++ b/packages/megalodon/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/megalodon/.npmignore b/packages/megalodon/.npmignore
new file mode 100644
index 0000000000..fd54d1deb4
--- /dev/null
+++ b/packages/megalodon/.npmignore
@@ -0,0 +1,3 @@
+node_modules
+./src
+tsconfig.json
diff --git a/packages/megalodon/.vscode/settings.json b/packages/megalodon/.vscode/settings.json
new file mode 100644
index 0000000000..5af1e3ee1d
--- /dev/null
+++ b/packages/megalodon/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "editor.tabCompletion": "on",
+ "diffEditor.codeLens": true
+}
\ No newline at end of file
diff --git a/packages/megalodon/lib/src/cancel.d.ts b/packages/megalodon/lib/src/cancel.d.ts
new file mode 100644
index 0000000000..63cb98db12
--- /dev/null
+++ b/packages/megalodon/lib/src/cancel.d.ts
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 0000000000..98620146fb
--- /dev/null
+++ b/packages/megalodon/lib/src/cancel.js
@@ -0,0 +1,33 @@
+"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
new file mode 100644
index 0000000000..a708890bf0
--- /dev/null
+++ b/packages/megalodon/lib/src/converter.d.ts
@@ -0,0 +1,3 @@
+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
new file mode 100644
index 0000000000..3ee9984548
--- /dev/null
+++ b/packages/megalodon/lib/src/converter.js
@@ -0,0 +1,7 @@
+"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
new file mode 100644
index 0000000000..65c6afa45c
--- /dev/null
+++ b/packages/megalodon/lib/src/default.d.ts
@@ -0,0 +1,3 @@
+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
new file mode 100644
index 0000000000..926730ab44
--- /dev/null
+++ b/packages/megalodon/lib/src/default.js
@@ -0,0 +1,6 @@
+"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
new file mode 100644
index 0000000000..66a4d87d21
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/account.d.ts
@@ -0,0 +1,27 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/account.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/activity.d.ts b/packages/megalodon/lib/src/entities/activity.d.ts
new file mode 100644
index 0000000000..ccfa72e8c9
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/activity.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/activity.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/announcement.d.ts b/packages/megalodon/lib/src/entities/announcement.d.ts
new file mode 100644
index 0000000000..8438dd9aa5
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/announcement.d.ts
@@ -0,0 +1,31 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/announcement.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/application.d.ts b/packages/megalodon/lib/src/entities/application.d.ts
new file mode 100644
index 0000000000..910f867376
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/application.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/application.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/async_attachment.d.ts b/packages/megalodon/lib/src/entities/async_attachment.d.ts
new file mode 100644
index 0000000000..911083f964
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/async_attachment.d.ts
@@ -0,0 +1,14 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/async_attachment.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/attachment.d.ts b/packages/megalodon/lib/src/entities/attachment.d.ts
new file mode 100644
index 0000000000..bbb94f3cd9
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/attachment.d.ts
@@ -0,0 +1,41 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/attachment.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/card.d.ts b/packages/megalodon/lib/src/entities/card.d.ts
new file mode 100644
index 0000000000..6e319e7baa
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/card.d.ts
@@ -0,0 +1,16 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/card.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/context.d.ts b/packages/megalodon/lib/src/entities/context.d.ts
new file mode 100644
index 0000000000..4c3397654f
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/context.d.ts
@@ -0,0 +1,7 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/context.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/conversation.d.ts b/packages/megalodon/lib/src/entities/conversation.d.ts
new file mode 100644
index 0000000000..dd5a1b1439
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/conversation.d.ts
@@ -0,0 +1,10 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/conversation.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/emoji.d.ts b/packages/megalodon/lib/src/entities/emoji.d.ts
new file mode 100644
index 0000000000..ca3c195065
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/emoji.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/emoji.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/featured_tag.d.ts b/packages/megalodon/lib/src/entities/featured_tag.d.ts
new file mode 100644
index 0000000000..5a8b36ff63
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/featured_tag.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/featured_tag.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/field.d.ts b/packages/megalodon/lib/src/entities/field.d.ts
new file mode 100644
index 0000000000..efa9f0aec8
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/field.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/field.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/filter.d.ts b/packages/megalodon/lib/src/entities/filter.d.ts
new file mode 100644
index 0000000000..48d0477cb1
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/filter.d.ts
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/filter.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/history.d.ts b/packages/megalodon/lib/src/entities/history.d.ts
new file mode 100644
index 0000000000..6b238a1d96
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/history.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/history.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/identity_proof.d.ts b/packages/megalodon/lib/src/entities/identity_proof.d.ts
new file mode 100644
index 0000000000..7d4a4fbf00
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/identity_proof.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/identity_proof.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/instance.d.ts b/packages/megalodon/lib/src/entities/instance.d.ts
new file mode 100644
index 0000000000..a869f7e6da
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/instance.d.ts
@@ -0,0 +1,40 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/instance.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/list.d.ts b/packages/megalodon/lib/src/entities/list.d.ts
new file mode 100644
index 0000000000..ab7c6416d8
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/list.d.ts
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/list.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/marker.d.ts b/packages/megalodon/lib/src/entities/marker.d.ts
new file mode 100644
index 0000000000..d23e1b5ef7
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/marker.d.ts
@@ -0,0 +1,15 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/marker.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/mention.d.ts b/packages/megalodon/lib/src/entities/mention.d.ts
new file mode 100644
index 0000000000..986105454a
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/mention.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/mention.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/notification.d.ts b/packages/megalodon/lib/src/entities/notification.d.ts
new file mode 100644
index 0000000000..2aed757892
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/notification.d.ts
@@ -0,0 +1,13 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/notification.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/poll.d.ts b/packages/megalodon/lib/src/entities/poll.d.ts
new file mode 100644
index 0000000000..bd5fb5c48c
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/poll.d.ts
@@ -0,0 +1,12 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/poll.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/poll_option.d.ts b/packages/megalodon/lib/src/entities/poll_option.d.ts
new file mode 100644
index 0000000000..968aff9a42
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/poll_option.d.ts
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/poll_option.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/preferences.d.ts b/packages/megalodon/lib/src/entities/preferences.d.ts
new file mode 100644
index 0000000000..79e62955df
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/preferences.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/preferences.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/push_subscription.d.ts b/packages/megalodon/lib/src/entities/push_subscription.d.ts
new file mode 100644
index 0000000000..92fa7a39f1
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/push_subscription.d.ts
@@ -0,0 +1,15 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/push_subscription.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/reaction.d.ts b/packages/megalodon/lib/src/entities/reaction.d.ts
new file mode 100644
index 0000000000..eb4cfb7802
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/reaction.d.ts
@@ -0,0 +1,10 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/reaction.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/relationship.d.ts b/packages/megalodon/lib/src/entities/relationship.d.ts
new file mode 100644
index 0000000000..56c5201313
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/relationship.d.ts
@@ -0,0 +1,17 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/relationship.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/report.d.ts b/packages/megalodon/lib/src/entities/report.d.ts
new file mode 100644
index 0000000000..6d42cbf46b
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/report.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/report.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/results.d.ts b/packages/megalodon/lib/src/entities/results.d.ts
new file mode 100644
index 0000000000..639b2fc134
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/results.d.ts
@@ -0,0 +1,10 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/results.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/scheduled_status.d.ts b/packages/megalodon/lib/src/entities/scheduled_status.d.ts
new file mode 100644
index 0000000000..b6842dad39
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/scheduled_status.d.ts
@@ -0,0 +1,10 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/scheduled_status.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/source.d.ts b/packages/megalodon/lib/src/entities/source.d.ts
new file mode 100644
index 0000000000..13a0cf9b6c
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/source.d.ts
@@ -0,0 +1,10 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/source.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/stats.d.ts b/packages/megalodon/lib/src/entities/stats.d.ts
new file mode 100644
index 0000000000..d23ae51cb7
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/stats.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/stats.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/status.d.ts b/packages/megalodon/lib/src/entities/status.d.ts
new file mode 100644
index 0000000000..5fdab67e0b
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/status.d.ts
@@ -0,0 +1,44 @@
+///
+///
+///
+///
+///
+///
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/status.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/status_edit.d.ts b/packages/megalodon/lib/src/entities/status_edit.d.ts
new file mode 100644
index 0000000000..638d33b899
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/status_edit.d.ts
@@ -0,0 +1,22 @@
+///
+///
+///
+///
+///
+///
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/status_edit.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/status_params.d.ts b/packages/megalodon/lib/src/entities/status_params.d.ts
new file mode 100644
index 0000000000..872be786b3
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/status_params.d.ts
@@ -0,0 +1,12 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/status_params.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/tag.d.ts b/packages/megalodon/lib/src/entities/tag.d.ts
new file mode 100644
index 0000000000..29130004e3
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/tag.d.ts
@@ -0,0 +1,9 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/tag.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/token.d.ts b/packages/megalodon/lib/src/entities/token.d.ts
new file mode 100644
index 0000000000..feae2d08c8
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/token.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/token.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entities/urls.d.ts b/packages/megalodon/lib/src/entities/urls.d.ts
new file mode 100644
index 0000000000..3a60528519
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/urls.d.ts
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/entities/urls.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/entity.d.ts b/packages/megalodon/lib/src/entity.d.ts
new file mode 100644
index 0000000000..6d6d3261f4
--- /dev/null
+++ b/packages/megalodon/lib/src/entity.d.ts
@@ -0,0 +1,37 @@
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+export default Entity;
diff --git a/packages/megalodon/lib/src/entity.js b/packages/megalodon/lib/src/entity.js
new file mode 100644
index 0000000000..c8ad2e549b
--- /dev/null
+++ b/packages/megalodon/lib/src/entity.js
@@ -0,0 +1,2 @@
+"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
new file mode 100644
index 0000000000..f996a32278
--- /dev/null
+++ b/packages/megalodon/lib/src/filter_context.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..743568f6e1
--- /dev/null
+++ b/packages/megalodon/lib/src/filter_context.js
@@ -0,0 +1,11 @@
+"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
new file mode 100644
index 0000000000..5a7d8776e8
--- /dev/null
+++ b/packages/megalodon/lib/src/index.d.ts
@@ -0,0 +1,12 @@
+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
new file mode 100644
index 0000000000..6c0f108ce8
--- /dev/null
+++ b/packages/megalodon/lib/src/index.js
@@ -0,0 +1,45 @@
+"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
new file mode 100644
index 0000000000..9191f0add1
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon.d.ts
@@ -0,0 +1,374 @@
+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
new file mode 100644
index 0000000000..6ae7ed51c2
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon.js
@@ -0,0 +1,2367 @@
+"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
new file mode 100644
index 0000000000..b5169744d9
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/api_client.d.ts
@@ -0,0 +1,152 @@
+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
new file mode 100644
index 0000000000..8ff48c4048
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/api_client.js
@@ -0,0 +1,614 @@
+"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
new file mode 100644
index 0000000000..02b3d5b8c5
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/account.d.ts
@@ -0,0 +1,27 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/account.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/activity.d.ts b/packages/megalodon/lib/src/mastodon/entities/activity.d.ts
new file mode 100644
index 0000000000..26d3c4338e
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/activity.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/activity.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/announcement.d.ts b/packages/megalodon/lib/src/mastodon/entities/announcement.d.ts
new file mode 100644
index 0000000000..bd5acb7505
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/announcement.d.ts
@@ -0,0 +1,37 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/announcement.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/application.d.ts b/packages/megalodon/lib/src/mastodon/entities/application.d.ts
new file mode 100644
index 0000000000..88943865bb
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/application.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/application.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..59d8daff22
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/async_attachment.d.ts
@@ -0,0 +1,14 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/async_attachment.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/attachment.d.ts b/packages/megalodon/lib/src/mastodon/entities/attachment.d.ts
new file mode 100644
index 0000000000..bb0b8d6dc7
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/attachment.d.ts
@@ -0,0 +1,41 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/attachment.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/card.d.ts b/packages/megalodon/lib/src/mastodon/entities/card.d.ts
new file mode 100644
index 0000000000..927ed7d6cc
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/card.d.ts
@@ -0,0 +1,16 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/card.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/context.d.ts b/packages/megalodon/lib/src/mastodon/entities/context.d.ts
new file mode 100644
index 0000000000..91e15feb23
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/context.d.ts
@@ -0,0 +1,7 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/context.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/conversation.d.ts b/packages/megalodon/lib/src/mastodon/entities/conversation.d.ts
new file mode 100644
index 0000000000..ec32531799
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/conversation.d.ts
@@ -0,0 +1,10 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/conversation.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/emoji.d.ts b/packages/megalodon/lib/src/mastodon/entities/emoji.d.ts
new file mode 100644
index 0000000000..e5aedd56f7
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/emoji.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/emoji.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..1587354b93
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/featured_tag.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/featured_tag.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/field.d.ts b/packages/megalodon/lib/src/mastodon/entities/field.d.ts
new file mode 100644
index 0000000000..bff55954cf
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/field.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/field.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/filter.d.ts b/packages/megalodon/lib/src/mastodon/entities/filter.d.ts
new file mode 100644
index 0000000000..963c7c4aed
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/filter.d.ts
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/filter.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/history.d.ts b/packages/megalodon/lib/src/mastodon/entities/history.d.ts
new file mode 100644
index 0000000000..3303cdd6e3
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/history.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/history.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..c4c42548f6
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/identity_proof.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/identity_proof.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/instance.d.ts b/packages/megalodon/lib/src/mastodon/entities/instance.d.ts
new file mode 100644
index 0000000000..c8c0dc6087
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/instance.d.ts
@@ -0,0 +1,40 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/instance.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/list.d.ts b/packages/megalodon/lib/src/mastodon/entities/list.d.ts
new file mode 100644
index 0000000000..e72bc79935
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/list.d.ts
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/list.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/marker.d.ts b/packages/megalodon/lib/src/mastodon/entities/marker.d.ts
new file mode 100644
index 0000000000..c10a16586d
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/marker.d.ts
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/marker.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/mention.d.ts b/packages/megalodon/lib/src/mastodon/entities/mention.d.ts
new file mode 100644
index 0000000000..c850ddb811
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/mention.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/mention.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/notification.d.ts b/packages/megalodon/lib/src/mastodon/entities/notification.d.ts
new file mode 100644
index 0000000000..22b16434d8
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/notification.d.ts
@@ -0,0 +1,12 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/notification.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/poll.d.ts b/packages/megalodon/lib/src/mastodon/entities/poll.d.ts
new file mode 100644
index 0000000000..636b0ed933
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/poll.d.ts
@@ -0,0 +1,12 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/poll.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..7ed529faad
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/poll_option.d.ts
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/poll_option.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/preferences.d.ts b/packages/megalodon/lib/src/mastodon/entities/preferences.d.ts
new file mode 100644
index 0000000000..011dc27d1b
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/preferences.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/preferences.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..dbed36e34a
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/push_subscription.d.ts
@@ -0,0 +1,15 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/push_subscription.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/relationship.d.ts b/packages/megalodon/lib/src/mastodon/entities/relationship.d.ts
new file mode 100644
index 0000000000..33b9f8d858
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/relationship.d.ts
@@ -0,0 +1,18 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/relationship.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/report.d.ts b/packages/megalodon/lib/src/mastodon/entities/report.d.ts
new file mode 100644
index 0000000000..d2118f105b
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/report.d.ts
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/report.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/results.d.ts b/packages/megalodon/lib/src/mastodon/entities/results.d.ts
new file mode 100644
index 0000000000..2dbd766c2c
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/results.d.ts
@@ -0,0 +1,10 @@
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/results.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..9bed699544
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/scheduled_status.d.ts
@@ -0,0 +1,10 @@
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/scheduled_status.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/source.d.ts b/packages/megalodon/lib/src/mastodon/entities/source.d.ts
new file mode 100644
index 0000000000..fc7d06164c
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/source.d.ts
@@ -0,0 +1,10 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/source.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/stats.d.ts b/packages/megalodon/lib/src/mastodon/entities/stats.d.ts
new file mode 100644
index 0000000000..86648217a3
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/stats.d.ts
@@ -0,0 +1,7 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/stats.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/status.d.ts b/packages/megalodon/lib/src/mastodon/entities/status.d.ts
new file mode 100644
index 0000000000..7d0778fdeb
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/status.d.ts
@@ -0,0 +1,42 @@
+///
+///
+///
+///
+///
+///
+///
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/status.js
@@ -0,0 +1 @@
+"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
new file mode 100644
index 0000000000..cf4e9bf296
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/status_params.d.ts
@@ -0,0 +1,12 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/status_params.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/tag.d.ts b/packages/megalodon/lib/src/mastodon/entities/tag.d.ts
new file mode 100644
index 0000000000..418b527a97
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/tag.d.ts
@@ -0,0 +1,9 @@
+///
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/tag.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/token.d.ts b/packages/megalodon/lib/src/mastodon/entities/token.d.ts
new file mode 100644
index 0000000000..d7d2e192a8
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/token.d.ts
@@ -0,0 +1,8 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/token.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entities/urls.d.ts b/packages/megalodon/lib/src/mastodon/entities/urls.d.ts
new file mode 100644
index 0000000000..fd56c2b325
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/urls.d.ts
@@ -0,0 +1,5 @@
+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
new file mode 100644
index 0000000000..3918c74e44
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entities/urls.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/packages/megalodon/lib/src/mastodon/entity.d.ts b/packages/megalodon/lib/src/mastodon/entity.d.ts
new file mode 100644
index 0000000000..e93268d6f7
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entity.d.ts
@@ -0,0 +1,36 @@
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+export default MastodonEntity;
diff --git a/packages/megalodon/lib/src/mastodon/entity.js b/packages/megalodon/lib/src/mastodon/entity.js
new file mode 100644
index 0000000000..c8ad2e549b
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/entity.js
@@ -0,0 +1,2 @@
+"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
new file mode 100644
index 0000000000..d05e327906
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/notification.d.ts
@@ -0,0 +1,11 @@
+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
new file mode 100644
index 0000000000..790ca9d845
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/notification.js
@@ -0,0 +1,13 @@
+"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
new file mode 100644
index 0000000000..639afab43d
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/web_socket.d.ts
@@ -0,0 +1,39 @@
+///
+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
new file mode 100644
index 0000000000..f378767292
--- /dev/null
+++ b/packages/megalodon/lib/src/mastodon/web_socket.js
@@ -0,0 +1,260 @@
+"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
new file mode 100644
index 0000000000..1128dd0a5f
--- /dev/null
+++ b/packages/megalodon/lib/src/megalodon.d.ts
@@ -0,0 +1,386 @@
+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