Remove megalodon

This commit is contained in:
Laura Hausmann 2023-10-05 14:36:14 +02:00
parent e33c7c5b0f
commit 0611651409
No known key found for this signature in database
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/queue/processors/db
!packages/backend/src/db !packages/backend/src/db
packages/megalodon/lib
packages/megalodon/.idea
# blender backups # blender backups
*.blend1 *.blend1
*.blend2 *.blend2
@ -82,8 +79,4 @@ pnpm*
# Nix Development shell items # Nix Development shell items
.devenv .devenv
.direnv .direnv
# Cargo cache for Docker
/.cargo-cache
/.cargo-target

1755
.pnp.cjs generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:de0502453eb5123991ca8651abc46e66ae1ea4fb5f1d16287351481f2b814d90
size 55363

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3b8dcf11f47e95a7d9fca627789e25445724cf16aa43db53b0cad72c42cd34c7
size 6381

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b609d4aa7fcd36642cdeaae414fb820bf24c06f01ccd3c84b1182084b0519bf2
size 3721

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.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:102cbaeaea0bc133ea9f98a996097f0ec835e8265ad7a23c48003e087f14eb66
size 10081

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ceb732470a6c1b6cd609d02e4ed607790ee50f3ed4a268dd32d684d6d10127f6
size 19740

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:853ef88be0eb5ed8061b67e6b02c355c258b6fb785fb8476d06325c058452901
size 2753

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dd169ff9a2264861357b1def4eb1f5a735f87a8431ddaa18d69d7b4cb9c91fef
size 16008

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c637d55317d0dd1ea27e19b8444b51ff7fa3dc049aded1f5700e31fd905bc0db
size 454641

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d99e84ba041f9e2a36ea4ad38ee0d6cafa0830436cb5adec8722b7908feb88bf
size 2446

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:39b507512936808f011a283496ce80cb84f6f7ee7a0b989571f5254f8e0020a1
size 6022

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.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:52750392ee792ac8cf682bd29c1132724e4ce3c839f90d20567ef8db68e96b56
size 86370

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.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5750375a0d9b2d0e94107f756921c48a675087f12f8197089c015ab6f44f2631
size 4858

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a2e76229ec47d60798729f4016d7296cfe825fc88a3ea8508816a4dd30e22645
size 4635

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eeb2ef721f623a970182556e640e5f89ed4a65a55283c7a2dbf2a3108235f3b8
size 8354

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cb054b300fb6883e04321ca67d2621a7dacb33524fa37f38fb27c7b9861c51ff
size 3666

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ec0fdfc70715b106e8ad67d6537c40091c1109ff587359ac5fefab549a79a8d5
size 4377

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:42f1baee31296104d275e7f81afcfa8cf13e274060dec070443575108d5e4d1e
size 10991

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.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7636a223c9390692e0adfc8a6aa31e44db3e3739c40e7126bd2774a1bea87fb9
size 36070

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.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ea314bae543c0a2daf90ee6659dee5c1e1e00a06116e8e5a6b456b2e28f653b0
size 356561

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.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d24fdac3f7c380bbe8a18254d8df10ba71f4842897c6f82275728b0fcaf41b54
size 94328

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ffbe0d07363acc50c3846eee8b989ecddac1f0584cf849dcedf1173e0d53352e
size 39763

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/client/package.json packages/client/package.json
COPY packages/sw/package.json packages/sw/package.json COPY packages/sw/package.json packages/sw/package.json
COPY packages/iceshrimp-js/package.json packages/iceshrimp-js/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 # Prepare yarn cache
COPY .yarn/cache .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 . ./
COPY --from=build /iceshrimp/packages/megalodon /iceshrimp/packages/megalodon
# Copy node modules # Copy node modules
COPY --from=build /iceshrimp/.yarn /iceshrimp/.yarn COPY --from=build /iceshrimp/.yarn /iceshrimp/.yarn

View File

@ -36,8 +36,7 @@
"packages/backend", "packages/backend",
"packages/client", "packages/client",
"packages/sw", "packages/sw",
"packages/iceshrimp-js", "packages/iceshrimp-js"
"packages/megalodon"
], ],
"resolutions": { "resolutions": {
"chokidar": "^3.3.1" "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 - `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 - `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 - `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-send": "5.0.1",
"koa-slow": "2.1.0", "koa-slow": "2.1.0",
"koa-views": "7.0.2", "koa-views": "7.0.2",
"megalodon": "workspace:*",
"meilisearch": "0.33.0", "meilisearch": "0.33.0",
"mfm-js": "0.23.3", "mfm-js": "0.23.3",
"mime-types": "2.1.35", "mime-types": "2.1.35",

View File

@ -1,5 +1,4 @@
import Router from "@koa/router"; import Router from "@koa/router";
import { getClient } from "@/server/api/mastodon/index.js";
import { MiscHelpers } from "@/server/api/mastodon/helpers/misc.js"; import { MiscHelpers } from "@/server/api/mastodon/helpers/misc.js";
import authenticate from "@/server/api/authenticate.js"; import authenticate from "@/server/api/authenticate.js";
import { argsToBools, limitToInt } from "@/server/api/mastodon/endpoints/timeline.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 Router from "@koa/router";
import axios from "axios";
import { argsToBools, convertPaginationArgsIds, limitToInt, normalizeUrlQuery } from "./timeline.js"; 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 authenticate from "@/server/api/authenticate.js";
import { UserHelpers } from "@/server/api/mastodon/helpers/user.js"; import { UserHelpers } from "@/server/api/mastodon/helpers/user.js";
import { SearchHelpers } from "@/server/api/mastodon/helpers/search.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 { export function setupEndpointsSearch(router: Router): void {
router.get("/v1/search", async (ctx) => { router.get("/v1/search", async (ctx) => {

View File

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

View File

@ -1,5 +1,4 @@
import Router from "@koa/router"; import Router from "@koa/router";
import megalodon, { MegalodonInterface } from "megalodon";
import { setupEndpointsAuth } from "./endpoints/auth.js"; import { setupEndpointsAuth } from "./endpoints/auth.js";
import { setupEndpointsAccount } from "./endpoints/account.js"; import { setupEndpointsAccount } from "./endpoints/account.js";
import { setupEndpointsStatus } from "./endpoints/status.js"; import { setupEndpointsStatus } from "./endpoints/status.js";
@ -13,17 +12,6 @@ import { HttpMethodEnum, koaBody } from "koa-body";
import multer from "@koa/multer"; import multer from "@koa/multer";
import { setupEndpointsList } from "@/server/api/mastodon/endpoints/list.js"; 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 { export function setupMastodonApi(router: Router, fileRouter: Router, upload: multer.Instance): void {
router.use( router.use(
koaBody({ 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