Remove megalodon

This commit is contained in:
Laura Hausmann 2023-10-05 14:36:14 +02:00
parent e33c7c5b0f
commit 0611651409
Signed by: zotan
GPG key ID: D044E84C5BE01605
180 changed files with 134 additions and 11397 deletions

9
.gitignore vendored
View file

@ -58,9 +58,6 @@ packages/backend/assets/LICENSE
!/packages/backend/queue/processors/db
!packages/backend/src/db
packages/megalodon/lib
packages/megalodon/.idea
# blender backups
*.blend1
*.blend2
@ -82,8 +79,4 @@ pnpm*
# Nix Development shell items
.devenv
.direnv
# Cargo cache for Docker
/.cargo-cache
/.cargo-target
.direnv

1755
.pnp.cjs generated

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/axios-npm-1.2.2-151da260f0-6e357491b3.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/dedent-npm-1.2.0-2b32a4a08e-239f12ddd4.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/expect-npm-29.6.2-d56284fd66-71f7b0c560.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/jest-npm-29.6.2-5eda7a13ff-dd63facd4e.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/lunr-npm-2.3.9-fa3aa9c2d6-176719e24f.zip (Stored with Git LFS) vendored

Binary file not shown.

BIN
.yarn/cache/marked-npm-4.3.0-e7ef9e874f-0db6817893.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/shiki-npm-0.14.3-bbc09f85cf-a4dd98e3b2.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/typescript-patch-0887b19144-2160f7ad97.zip (Stored with Git LFS) vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/ws-npm-8.12.0-4e21348613-818ff3f874.zip (Stored with Git LFS) vendored

Binary file not shown.

View file

@ -12,7 +12,6 @@ COPY packages/backend/package.json packages/backend/package.json
COPY packages/client/package.json packages/client/package.json
COPY packages/sw/package.json packages/sw/package.json
COPY packages/iceshrimp-js/package.json packages/iceshrimp-js/package.json
COPY packages/megalodon/package.json packages/megalodon/package.json
# Prepare yarn cache
COPY .yarn/cache .yarn/cache
@ -48,8 +47,6 @@ RUN apk add --no-cache --no-progress tini ffmpeg vips-dev zip unzip nodejs-curre
COPY . ./
COPY --from=build /iceshrimp/packages/megalodon /iceshrimp/packages/megalodon
# Copy node modules
COPY --from=build /iceshrimp/.yarn /iceshrimp/.yarn

View file

@ -36,8 +36,7 @@
"packages/backend",
"packages/client",
"packages/sw",
"packages/iceshrimp-js",
"packages/megalodon"
"packages/iceshrimp-js"
],
"resolutions": {
"chokidar": "^3.3.1"

View file

@ -6,4 +6,3 @@ This directory contains all of the packages Iceshrimp uses.
- `client`: Web interface written in Vue3 and TypeScript
- `sw`: Web [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) written in TypeScript
- `iceshrimp-js`: TypeScript SDK for both backend and client, also published on [NPM](https://www.npmjs.com/package/iceshrimp-js) for public use
- `megalodon`: TypeScript library used for partial Mastodon API compatibility

View file

@ -91,7 +91,6 @@
"koa-send": "5.0.1",
"koa-slow": "2.1.0",
"koa-views": "7.0.2",
"megalodon": "workspace:*",
"meilisearch": "0.33.0",
"mfm-js": "0.23.3",
"mime-types": "2.1.35",

View file

@ -1,5 +1,4 @@
import Router from "@koa/router";
import { getClient } from "@/server/api/mastodon/index.js";
import { MiscHelpers } from "@/server/api/mastodon/helpers/misc.js";
import authenticate from "@/server/api/authenticate.js";
import { argsToBools, limitToInt } from "@/server/api/mastodon/endpoints/timeline.js";

View file

@ -1,12 +1,9 @@
import { Converter } from "megalodon";
import Router from "@koa/router";
import axios from "axios";
import { argsToBools, convertPaginationArgsIds, limitToInt, normalizeUrlQuery } from "./timeline.js";
import { convertAccountId, convertSearchIds, convertStatusIds } from "../converters.js";
import { convertSearchIds } from "../converters.js";
import authenticate from "@/server/api/authenticate.js";
import { UserHelpers } from "@/server/api/mastodon/helpers/user.js";
import { SearchHelpers } from "@/server/api/mastodon/helpers/search.js";
import { MiscHelpers } from "@/server/api/mastodon/helpers/misc.js";
export function setupEndpointsSearch(router: Router): void {
router.get("/v1/search", async (ctx) => {

View file

@ -1,5 +1,4 @@
import Router from "@koa/router";
import { getClient } from "../index.js";
import { ParsedUrlQuery } from "querystring";
import { convertConversationIds, convertStatusIds, } from "../converters.js";
import { convertId, IdType } from "../../index.js";

View file

@ -1,5 +1,4 @@
import Router from "@koa/router";
import megalodon, { MegalodonInterface } from "megalodon";
import { setupEndpointsAuth } from "./endpoints/auth.js";
import { setupEndpointsAccount } from "./endpoints/account.js";
import { setupEndpointsStatus } from "./endpoints/status.js";
@ -13,17 +12,6 @@ import { HttpMethodEnum, koaBody } from "koa-body";
import multer from "@koa/multer";
import { setupEndpointsList } from "@/server/api/mastodon/endpoints/list.js";
export function getClient(
BASE_URL: string,
authorization: string | undefined,
): MegalodonInterface {
const accessTokenArr = authorization?.split(" ") ?? [null];
const accessToken = accessTokenArr[accessTokenArr.length - 1];
const generator = (megalodon as any).default;
const client = generator(BASE_URL, accessToken) as MegalodonInterface;
return client;
}
export function setupMastodonApi(router: Router, fileRouter: Router, upload: multer.Instance): void {
router.use(
koaBody({

View file

@ -1,83 +0,0 @@
{
"name": "megalodon",
"private": true,
"main": "./lib/src/index.js",
"typings": "./lib/src/index.d.ts",
"scripts": {
"build": "tsc -p ./",
"build:debug": "yarn build",
"lint": "rome check **/*.ts --apply",
"format": "rome format --write src/**/*.ts",
"doc": "typedoc --out ../docs ./src",
"test": "NODE_ENV=test jest -u --maxWorkers=3"
},
"jest": {
"moduleFileExtensions": [
"ts",
"js"
],
"moduleNameMapper": {
"^@/(.+)": "<rootDir>/src/$1",
"^~/(.+)": "<rootDir>/$1"
},
"testMatch": [
"**/test/**/*.spec.ts"
],
"preset": "ts-jest/presets/default",
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.json"
}
},
"testEnvironment": "node"
},
"dependencies": {
"@types/oauth": "^0.9.0",
"@types/ws": "^8.5.4",
"async-lock": "1.4.0",
"axios": "1.2.2",
"dayjs": "^1.11.7",
"form-data": "^4.0.0",
"https-proxy-agent": "^5.0.1",
"oauth": "^0.10.0",
"object-assign-deep": "^0.4.0",
"parse-link-header": "^2.0.0",
"socks-proxy-agent": "^7.0.0",
"typescript": "4.9.4",
"uuid": "^9.0.0",
"ws": "8.12.0"
},
"devDependencies": {
"@types/async-lock": "1.4.0",
"@types/core-js": "^2.5.0",
"@types/form-data": "^2.5.0",
"@types/jest": "^29.4.0",
"@types/node": "18.11.18",
"@types/object-assign-deep": "^0.4.0",
"@types/parse-link-header": "^2.0.0",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^5.0.0",
"jest": "^29.4.0",
"jest-worker": "^29.4.0",
"lodash": "^4.17.14",
"prettier": "^2.8.3",
"ts-jest": "^29.0.5",
"typedoc": "^0.23.24"
},
"directories": {
"lib": "lib",
"test": "test"
}
}

View file

@ -1 +0,0 @@
declare module "axios/lib/adapters/http";

View file

@ -1,13 +0,0 @@
export class RequestCanceledError extends Error {
public isCancel: boolean;
constructor(msg: string) {
super(msg);
this.isCancel = true;
Object.setPrototypeOf(this, RequestCanceledError);
}
}
export const isCancel = (value: any): boolean => {
return value && value.isCancel;
};

View file

@ -1,3 +0,0 @@
import MisskeyAPI from "./misskey/api_client";
export default MisskeyAPI.Converter;

View file

@ -1,3 +0,0 @@
export const NO_REDIRECT = "urn:ietf:wg:oauth:2.0:oob";
export const DEFAULT_SCOPE = ["read", "write", "follow"];
export const DEFAULT_UA = "megalodon";

View file

@ -1,27 +0,0 @@
/// <reference path="emoji.ts" />
/// <reference path="source.ts" />
/// <reference path="field.ts" />
namespace Entity {
export 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

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

View file

@ -1,34 +0,0 @@
/// <reference path="tag.ts" />
/// <reference path="emoji.ts" />
/// <reference path="reaction.ts" />
namespace Entity {
export 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>;
};
export type AnnouncementAccount = {
id: string;
username: string;
url: string;
acct: string;
};
export type AnnouncementStatus = {
id: string;
url: string;
};
}

View file

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

View file

@ -1,14 +0,0 @@
/// <reference path="attachment.ts" />
namespace Entity {
export 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

@ -1,49 +0,0 @@
namespace Entity {
export type Sub = {
// For Image, Gifv, and Video
width?: number;
height?: number;
size?: string;
aspect?: number;
// For Gifv and Video
frame_rate?: string;
// For Audio, Gifv, and Video
duration?: number;
bitrate?: number;
};
export type Focus = {
x: number;
y: number;
};
export 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;
};
export 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

@ -1,16 +0,0 @@
namespace Entity {
export 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

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

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