[mastodon-client] Move megalodon to main repo

This commit is contained in:
Laura Hausmann 2023-07-06 00:36:26 +02:00 committed by Laura Hausmann
parent 9fd44339e8
commit ab18c22fa9
455 changed files with 26157 additions and 39 deletions

View file

@ -44,6 +44,7 @@
"seedrandom": "^3.0.5" "seedrandom": "^3.0.5"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "18.11.18",
"@types/gulp": "4.0.10", "@types/gulp": "4.0.10",
"@types/gulp-rename": "2.0.1", "@types/gulp-rename": "2.0.1",
"chalk": "4.1.2", "chalk": "4.1.2",

View file

@ -28,7 +28,7 @@
"@bull-board/api": "5.2.0", "@bull-board/api": "5.2.0",
"@bull-board/koa": "5.2.0", "@bull-board/koa": "5.2.0",
"@bull-board/ui": "5.2.0", "@bull-board/ui": "5.2.0",
"@calckey/megalodon": "5.2.0", "@calckey/megalodon": "workspace:*",
"@discordapp/twemoji": "14.1.2", "@discordapp/twemoji": "14.1.2",
"@elastic/elasticsearch": "7.17.0", "@elastic/elasticsearch": "7.17.0",
"@koa/cors": "3.4.3", "@koa/cors": "3.4.3",

5
packages/megalodon/.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="TypeScriptCompiler">
<option name="recompileOnChanges" value="true" />
</component>
</project>

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="Node.js Core" />
</component>
</project>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/megalodon.iml" filepath="$PROJECT_DIR$/.idea/megalodon.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View file

@ -0,0 +1,3 @@
node_modules
./src
tsconfig.json

View file

@ -0,0 +1,4 @@
{
"editor.tabCompletion": "on",
"diffEditor.codeLens": true
}

View file

@ -0,0 +1,5 @@
export declare class RequestCanceledError extends Error {
isCancel: boolean;
constructor(msg: string);
}
export declare const isCancel: (value: any) => boolean;

View file

@ -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;

View file

@ -0,0 +1,3 @@
import MisskeyAPI from "./misskey/api_client";
declare const _default: typeof MisskeyAPI.Converter;
export default _default;

View file

@ -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;

View file

@ -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";

View file

@ -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';

View file

@ -0,0 +1,27 @@
/// <reference path="emoji.d.ts" />
/// <reference path="source.d.ts" />
/// <reference path="field.d.ts" />
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<Emoji>;
moved: Account | null;
fields: Array<Field>;
bot: boolean | null;
source?: Source;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,8 @@
declare namespace Entity {
type Activity = {
week: string;
statuses: string;
logins: string;
registrations: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,31 @@
/// <reference path="tag.d.ts" />
/// <reference path="emoji.d.ts" />
/// <reference path="reaction.d.ts" />
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<AnnouncementAccount>;
statuses: Array<AnnouncementStatus>;
tags: Array<Tag>;
emojis: Array<Emoji>;
reactions: Array<Reaction>;
};
type AnnouncementAccount = {
id: string;
username: string;
url: string;
acct: string;
};
type AnnouncementStatus = {
id: string;
url: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,7 @@
declare namespace Entity {
type Application = {
name: string;
website?: string | null;
vapid_key?: string | null;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,14 @@
/// <reference path="attachment.d.ts" />
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;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -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;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -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;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,7 @@
/// <reference path="status.d.ts" />
declare namespace Entity {
type Context = {
ancestors: Array<Status>;
descendants: Array<Status>;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,10 @@
/// <reference path="account.d.ts" />
/// <reference path="status.d.ts" />
declare namespace Entity {
type Conversation = {
id: string;
accounts: Array<Account>;
last_status: Status | null;
unread: boolean;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,9 @@
declare namespace Entity {
type Emoji = {
shortcode: string;
static_url: string;
url: string;
visible_in_picker: boolean;
category: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,8 @@
declare namespace Entity {
type FeaturedTag = {
id: string;
name: string;
statuses_count: number;
last_status_at: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,7 @@
declare namespace Entity {
type Field = {
name: string;
value: string;
verified_at: string | null;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,11 @@
declare namespace Entity {
type Filter = {
id: string;
phrase: string;
context: Array<FilterContext>;
expires_at: string | null;
irreversible: boolean;
whole_word: boolean;
};
type FilterContext = string;
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,7 @@
declare namespace Entity {
type History = {
day: string;
uses: number;
accounts: number;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,9 @@
declare namespace Entity {
type IdentityProof = {
provider: string;
provider_username: string;
updated_at: string;
proof_url: string;
profile_url: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,40 @@
/// <reference path="account.d.ts" />
/// <reference path="urls.d.ts" />
/// <reference path="stats.d.ts" />
declare namespace Entity {
type Instance = {
uri: string;
title: string;
description: string;
email: string;
version: string;
thumbnail: string | null;
urls: URLs;
stats: Stats;
languages: Array<string>;
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<string>;
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;
};
};
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,6 @@
declare namespace Entity {
type List = {
id: string;
title: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -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;
};
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,8 @@
declare namespace Entity {
type Mention = {
id: string;
username: string;
url: string;
acct: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,13 @@
/// <reference path="account.d.ts" />
/// <reference path="status.d.ts" />
declare namespace Entity {
type Notification = {
account: Account;
created_at: string;
id: string;
status?: Status;
emoji?: string;
type: NotificationType;
};
type NotificationType = string;
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,12 @@
/// <reference path="poll_option.d.ts" />
declare namespace Entity {
type Poll = {
id: string;
expires_at: string | null;
expired: boolean;
multiple: boolean;
votes_count: number;
options: Array<PollOption>;
voted: boolean;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,6 @@
declare namespace Entity {
type PollOption = {
title: string;
votes_count: number | null;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -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;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -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;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,10 @@
/// <reference path="account.d.ts" />
declare namespace Entity {
type Reaction = {
count: number;
me: boolean;
name: string;
url?: string;
accounts?: Array<Account>;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -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;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,9 @@
declare namespace Entity {
type Report = {
id: string;
action_taken: string;
comment: string;
account_id: string;
status_ids: Array<string>;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,10 @@
/// <reference path="account.d.ts" />
/// <reference path="status.d.ts" />
/// <reference path="tag.d.ts" />
declare namespace Entity {
type Results = {
accounts: Array<Account>;
statuses: Array<Status>;
hashtags: Array<Tag>;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,10 @@
/// <reference path="attachment.d.ts" />
/// <reference path="status_params.d.ts" />
declare namespace Entity {
type ScheduledStatus = {
id: string;
scheduled_at: string;
params: StatusParams;
media_attachments: Array<Attachment>;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,10 @@
/// <reference path="field.d.ts" />
declare namespace Entity {
type Source = {
privacy: string | null;
sensitive: boolean | null;
language: string | null;
note: string;
fields: Array<Field>;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,7 @@
declare namespace Entity {
type Stats = {
user_count: number;
status_count: number;
domain_count: number;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,44 @@
/// <reference path="account.d.ts" />
/// <reference path="application.d.ts" />
/// <reference path="mention.d.ts" />
/// <reference path="tag.d.ts" />
/// <reference path="attachment.d.ts" />
/// <reference path="emoji.d.ts" />
/// <reference path="card.d.ts" />
/// <reference path="poll.d.ts" />
/// <reference path="reaction.d.ts" />
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<Attachment>;
mentions: Array<Mention>;
tags: Array<Tag>;
card: Card | null;
poll: Poll | null;
application: Application | null;
language: string | null;
pinned: boolean | null;
emoji_reactions: Array<Reaction>;
quote: Status | null;
bookmarked: boolean;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,22 @@
/// <reference path="account.d.ts" />
/// <reference path="application.d.ts" />
/// <reference path="mention.d.ts" />
/// <reference path="tag.d.ts" />
/// <reference path="attachment.d.ts" />
/// <reference path="emoji.d.ts" />
/// <reference path="card.d.ts" />
/// <reference path="poll.d.ts" />
/// <reference path="reaction.d.ts" />
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<Attachment>;
poll: Poll | null;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,12 @@
declare namespace Entity {
type StatusParams = {
text: string;
in_reply_to_id: string | null;
media_ids: Array<string> | null;
sensitive: boolean | null;
spoiler_text: string | null;
visibility: 'public' | 'unlisted' | 'private' | 'direct';
scheduled_at: string | null;
application_id: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,9 @@
/// <reference path="history.d.ts" />
declare namespace Entity {
type Tag = {
name: string;
url: string;
history: Array<History> | null;
following?: boolean;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,8 @@
declare namespace Entity {
type Token = {
access_token: string;
token_type: string;
scope: string;
created_at: number;
};
}

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,5 @@
declare namespace Entity {
type URLs = {
streaming_api: string;
};
}

View file

@ -0,0 +1 @@
"use strict";

37
packages/megalodon/lib/src/entity.d.ts vendored Normal file
View file

@ -0,0 +1,37 @@
/// <reference path="entities/account.d.ts" />
/// <reference path="entities/activity.d.ts" />
/// <reference path="entities/announcement.d.ts" />
/// <reference path="entities/application.d.ts" />
/// <reference path="entities/async_attachment.d.ts" />
/// <reference path="entities/attachment.d.ts" />
/// <reference path="entities/card.d.ts" />
/// <reference path="entities/context.d.ts" />
/// <reference path="entities/conversation.d.ts" />
/// <reference path="entities/emoji.d.ts" />
/// <reference path="entities/featured_tag.d.ts" />
/// <reference path="entities/field.d.ts" />
/// <reference path="entities/filter.d.ts" />
/// <reference path="entities/history.d.ts" />
/// <reference path="entities/identity_proof.d.ts" />
/// <reference path="entities/instance.d.ts" />
/// <reference path="entities/list.d.ts" />
/// <reference path="entities/marker.d.ts" />
/// <reference path="entities/mention.d.ts" />
/// <reference path="entities/notification.d.ts" />
/// <reference path="entities/poll.d.ts" />
/// <reference path="entities/poll_option.d.ts" />
/// <reference path="entities/preferences.d.ts" />
/// <reference path="entities/push_subscription.d.ts" />
/// <reference path="entities/reaction.d.ts" />
/// <reference path="entities/relationship.d.ts" />
/// <reference path="entities/report.d.ts" />
/// <reference path="entities/results.d.ts" />
/// <reference path="entities/scheduled_status.d.ts" />
/// <reference path="entities/source.d.ts" />
/// <reference path="entities/stats.d.ts" />
/// <reference path="entities/status.d.ts" />
/// <reference path="entities/status_params.d.ts" />
/// <reference path="entities/tag.d.ts" />
/// <reference path="entities/token.d.ts" />
/// <reference path="entities/urls.d.ts" />
export default Entity;

View file

@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View file

@ -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;

View file

@ -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;

12
packages/megalodon/lib/src/index.d.ts vendored Normal file
View file

@ -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;

View file

@ -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;

374
packages/megalodon/lib/src/mastodon.d.ts vendored Normal file
View file

@ -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<string>;
redirect_uris: string;
website: string;
}>): Promise<OAuth.AppData>;
createApp(client_name: string, options: Partial<{
scopes: Array<string>;
redirect_uris: string;
website: string;
}>): Promise<OAuth.AppData>;
generateAuthUrl(clientId: string, clientSecret: string, options: Partial<{
scope: Array<string>;
redirect_uri: string;
}>): Promise<string>;
verifyAppCredentials(): Promise<Response<Entity.Application>>;
fetchAccessToken(client_id: string | null, client_secret: string, code: string, redirect_uri?: string): Promise<OAuth.TokenData>;
refreshToken(client_id: string, client_secret: string, refresh_token: string): Promise<OAuth.TokenData>;
revokeToken(client_id: string, client_secret: string, token: string): Promise<Response<{}>>;
registerAccount(username: string, email: string, password: string, agreement: boolean, locale: string, reason?: string | null): Promise<Response<Entity.Token>>;
verifyAccountCredentials(): Promise<Response<Entity.Account>>;
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<Response<Entity.Account>>;
getAccount(id: string): Promise<Response<Entity.Account>>;
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<Response<Array<Entity.Status>>>;
subscribeAccount(id: string): Promise<Response<Entity.Relationship>>;
unsubscribeAccount(id: string): Promise<Response<Entity.Relationship>>;
getAccountFavourites(_id: string, _options?: {
limit?: number;
max_id?: string;
since_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getAccountFollowers(id: string, options?: {
limit?: number;
max_id?: string;
since_id?: string;
get_all?: boolean;
sleep_ms?: number;
}): Promise<Response<Array<Entity.Account>>>;
getAccountFollowing(id: string, options?: {
limit?: number;
max_id?: string;
since_id?: string;
get_all?: boolean;
sleep_ms?: number;
}): Promise<Response<Array<Entity.Account>>>;
private urlToAccounts;
getAccountLists(id: string): Promise<Response<Array<Entity.List>>>;
getIdentityProof(id: string): Promise<Response<Array<Entity.IdentityProof>>>;
followAccount(id: string, options?: {
reblog?: boolean;
}): Promise<Response<Entity.Relationship>>;
unfollowAccount(id: string): Promise<Response<Entity.Relationship>>;
blockAccount(id: string): Promise<Response<Entity.Relationship>>;
unblockAccount(id: string): Promise<Response<Entity.Relationship>>;
muteAccount(id: string, notifications?: boolean): Promise<Response<Entity.Relationship>>;
unmuteAccount(id: string): Promise<Response<Entity.Relationship>>;
pinAccount(id: string): Promise<Response<Entity.Relationship>>;
unpinAccount(id: string): Promise<Response<Entity.Relationship>>;
getRelationship(id: string): Promise<Response<Entity.Relationship>>;
getRelationships(ids: Array<string>): Promise<Response<Array<Entity.Relationship>>>;
searchAccount(q: string, options?: {
following?: boolean;
resolve?: boolean;
limit?: number;
max_id?: string;
since_id?: string;
}): Promise<Response<Array<Entity.Account>>>;
getBookmarks(options?: {
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getFavourites(options?: {
limit?: number;
max_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getMutes(options?: {
limit?: number;
max_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Account>>>;
getBlocks(options?: {
limit?: number;
max_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Account>>>;
getDomainBlocks(options?: {
limit?: number;
max_id?: string;
min_id?: string;
}): Promise<Response<Array<string>>>;
blockDomain(domain: string): Promise<Response<{}>>;
unblockDomain(domain: string): Promise<Response<{}>>;
getFilters(): Promise<Response<Array<Entity.Filter>>>;
getFilter(id: string): Promise<Response<Entity.Filter>>;
createFilter(phrase: string, context: Array<Entity.FilterContext>, options?: {
irreversible?: boolean;
whole_word?: boolean;
expires_in?: string;
}): Promise<Response<Entity.Filter>>;
updateFilter(id: string, phrase: string, context: Array<Entity.FilterContext>, options?: {
irreversible?: boolean;
whole_word?: boolean;
expires_in?: string;
}): Promise<Response<Entity.Filter>>;
deleteFilter(id: string): Promise<Response<Entity.Filter>>;
report(account_id: string, comment: string, options?: {
status_ids?: Array<string>;
forward?: boolean;
}): Promise<Response<Entity.Report>>;
getFollowRequests(limit?: number): Promise<Response<Array<Entity.Account>>>;
acceptFollowRequest(id: string): Promise<Response<Entity.Relationship>>;
rejectFollowRequest(id: string): Promise<Response<Entity.Relationship>>;
getEndorsements(options?: {
limit?: number;
max_id?: string;
since_id?: string;
}): Promise<Response<Array<Entity.Account>>>;
getFeaturedTags(): Promise<Response<Array<Entity.FeaturedTag>>>;
getAccountFeaturedTags(id: string): Promise<Response<Array<Entity.FeaturedTag>>>;
createFeaturedTag(name: string): Promise<Response<Entity.FeaturedTag>>;
deleteFeaturedTag(id: string): Promise<Response<{}>>;
getSuggestedTags(): Promise<Response<Array<Entity.Tag>>>;
getPreferences(): Promise<Response<Entity.Preferences>>;
getSuggestions(limit?: number): Promise<Response<Array<Entity.Account>>>;
getTag(id: string): Promise<Response<Entity.Tag>>;
followTag(id: string): Promise<Response<Entity.Tag>>;
unfollowTag(id: string): Promise<Response<Entity.Tag>>;
postStatus(status: string, options: {
media_ids?: Array<string>;
poll?: {
options: Array<string>;
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<Response<Entity.Status>>;
getStatus(id: string): Promise<Response<Entity.Status>>;
editStatus(id: string, options: {
status?: string;
spoiler_text?: string;
sensitive?: boolean;
media_ids?: Array<string>;
poll?: {
options?: Array<string>;
expires_in?: number;
multiple?: boolean;
hide_totals?: boolean;
};
}): Promise<Response<Entity.Status>>;
deleteStatus(id: string): Promise<Response<Entity.Status>>;
getStatusContext(id: string, options?: {
limit?: number;
max_id?: string;
since_id?: string;
}): Promise<Response<Entity.Context>>;
getStatusRebloggedBy(id: string): Promise<Response<Array<Entity.Account>>>;
getStatusFavouritedBy(id: string): Promise<Response<Array<Entity.Account>>>;
favouriteStatus(id: string): Promise<Response<Entity.Status>>;
unfavouriteStatus(id: string): Promise<Response<Entity.Status>>;
reblogStatus(id: string): Promise<Response<Entity.Status>>;
unreblogStatus(id: string): Promise<Response<Entity.Status>>;
bookmarkStatus(id: string): Promise<Response<Entity.Status>>;
unbookmarkStatus(id: string): Promise<Response<Entity.Status>>;
muteStatus(id: string): Promise<Response<Entity.Status>>;
unmuteStatus(id: string): Promise<Response<Entity.Status>>;
pinStatus(id: string): Promise<Response<Entity.Status>>;
unpinStatus(id: string): Promise<Response<Entity.Status>>;
uploadMedia(file: any, options?: {
description?: string;
focus?: string;
}): Promise<Response<Entity.Attachment | Entity.AsyncAttachment>>;
getMedia(id: string): Promise<Response<Entity.Attachment>>;
updateMedia(id: string, options?: {
file?: any;
description?: string;
focus?: string;
}): Promise<Response<Entity.Attachment>>;
getPoll(id: string): Promise<Response<Entity.Poll>>;
votePoll(id: string, choices: Array<number>): Promise<Response<Entity.Poll>>;
getScheduledStatuses(options?: {
limit?: number | null;
max_id?: string | null;
since_id?: string | null;
min_id?: string | null;
}): Promise<Response<Array<Entity.ScheduledStatus>>>;
getScheduledStatus(id: string): Promise<Response<Entity.ScheduledStatus>>;
scheduleStatus(id: string, scheduled_at?: string | null): Promise<Response<Entity.ScheduledStatus>>;
cancelScheduledStatus(id: string): Promise<Response<{}>>;
getPublicTimeline(options?: {
only_media?: boolean;
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getLocalTimeline(options?: {
only_media?: boolean;
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getTagTimeline(hashtag: string, options?: {
local?: boolean;
only_media?: boolean;
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getHomeTimeline(options?: {
local?: boolean;
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getListTimeline(list_id: string, options?: {
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Status>>>;
getConversationTimeline(options?: {
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
}): Promise<Response<Array<Entity.Conversation>>>;
deleteConversation(id: string): Promise<Response<{}>>;
readConversation(id: string): Promise<Response<Entity.Conversation>>;
getLists(): Promise<Response<Array<Entity.List>>>;
getList(id: string): Promise<Response<Entity.List>>;
createList(title: string): Promise<Response<Entity.List>>;
updateList(id: string, title: string): Promise<Response<Entity.List>>;
deleteList(id: string): Promise<Response<{}>>;
getAccountsInList(id: string, options?: {
limit?: number;
max_id?: string;
since_id?: string;
}): Promise<Response<Array<Entity.Account>>>;
addAccountsToList(id: string, account_ids: Array<string>): Promise<Response<{}>>;
deleteAccountsFromList(id: string, account_ids: Array<string>): Promise<Response<{}>>;
getMarkers(timeline: Array<string>): Promise<Response<Entity.Marker | {}>>;
saveMarkers(options?: {
home?: {
last_read_id: string;
};
notifications?: {
last_read_id: string;
};
}): Promise<Response<Entity.Marker>>;
getNotifications(options?: {
limit?: number;
max_id?: string;
since_id?: string;
min_id?: string;
exclude_types?: Array<Entity.NotificationType>;
account_id?: string;
}): Promise<Response<Array<Entity.Notification>>>;
getNotification(id: string): Promise<Response<Entity.Notification>>;
dismissNotifications(): Promise<Response<{}>>;
dismissNotification(id: string): Promise<Response<{}>>;
readNotifications(_options: {
id?: string;
max_id?: string;
}): Promise<Response<Entity.Notification | Array<Entity.Notification>>>;
subscribePushNotification(subscription: {
endpoint: string;
keys: {
p256dh: string;
auth: string;
};
}, data?: {
alerts: {
follow?: boolean;
favourite?: boolean;
reblog?: boolean;
mention?: boolean;
poll?: boolean;
};
} | null): Promise<Response<Entity.PushSubscription>>;
getPushSubscription(): Promise<Response<Entity.PushSubscription>>;
updatePushSubscription(data?: {
alerts: {
follow?: boolean;
favourite?: boolean;
reblog?: boolean;
mention?: boolean;
poll?: boolean;
};
} | null): Promise<Response<Entity.PushSubscription>>;
deletePushSubscription(): Promise<Response<{}>>;
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<Response<Entity.Results>>;
getInstance(): Promise<Response<Entity.Instance>>;
getInstancePeers(): Promise<Response<Array<string>>>;
getInstanceActivity(): Promise<Response<Array<Entity.Activity>>>;
getInstanceTrends(limit?: number | null): Promise<Response<Array<Entity.Tag>>>;
getInstanceDirectory(options?: {
limit?: number;
offset?: number;
order?: 'active' | 'new';
local?: boolean;
}): Promise<Response<Array<Entity.Account>>>;
getInstanceCustomEmojis(): Promise<Response<Array<Entity.Emoji>>>;
getInstanceAnnouncements(with_dismissed?: boolean | null): Promise<Response<Array<Entity.Announcement>>>;
dismissInstanceAnnouncement(id: string): Promise<Response<{}>>;
createEmojiReaction(_id: string, _emoji: string): Promise<Response<Entity.Status>>;
deleteEmojiReaction(_id: string, _emoji: string): Promise<Response<Entity.Status>>;
getEmojiReactions(_id: string): Promise<Response<Array<Entity.Reaction>>>;
getEmojiReaction(_id: string, _emoji: string): Promise<Response<Entity.Reaction>>;
userSocket(): WebSocket;
publicSocket(): WebSocket;
localSocket(): WebSocket;
tagSocket(tag: string): WebSocket;
listSocket(list_id: string): WebSocket;
directSocket(): WebSocket;
}

File diff suppressed because it is too large Load diff

View file

@ -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<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}, pathIsFullyQualified?: boolean): Promise<Response<T>>;
put<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
putForm<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
patch<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
patchForm<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
post<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
postForm<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
del<T = any>(path: string, params?: any, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
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<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}, pathIsFullyQualified?: boolean): Promise<Response<T>>;
put<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
putForm<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
patch<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
patchForm<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
post<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
postForm<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
del<T>(path: string, params?: {}, headers?: {
[key: string]: string;
}): Promise<Response<T>>;
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;

Some files were not shown because too many files have changed in this diff Show more