[mastodon-client] general code cleanup, rename megalodon package

This commit is contained in:
Laura Hausmann 2023-07-06 01:10:33 +02:00 committed by Laura Hausmann
parent fbeb809874
commit 8347855a11
16 changed files with 29 additions and 47 deletions

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": "workspace:*", "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",

View file

@ -1,5 +1,5 @@
import Router from "@koa/router"; import Router from "@koa/router";
import megalodon, { MegalodonInterface } from "@calckey/megalodon"; import megalodon, { MegalodonInterface } from "megalodon";
import { apiAuthMastodon } from "./endpoints/auth.js"; import { apiAuthMastodon } from "./endpoints/auth.js";
import { apiAccountMastodon } from "./endpoints/account.js"; import { apiAccountMastodon } from "./endpoints/account.js";
import { apiStatusMastodon } from "./endpoints/status.js"; import { apiStatusMastodon } from "./endpoints/status.js";

View file

@ -1,4 +1,4 @@
import { Entity } from "@calckey/megalodon"; import { Entity } from "megalodon";
import { convertId, IdType } from "../index.js"; import { convertId, IdType } from "../index.js";
function simpleConvert(data: any) { function simpleConvert(data: any) {
@ -21,6 +21,9 @@ export function convertFilter(filter: Entity.Filter) {
export function convertList(list: Entity.List) { export function convertList(list: Entity.List) {
return simpleConvert(list); return simpleConvert(list);
} }
export function convertFeaturedTag(tag: Entity.FeaturedTag) {
return simpleConvert(tag);
}
export function convertNotification(notification: Entity.Notification) { export function convertNotification(notification: Entity.Notification) {
notification.account = convertAccount(notification.account); notification.account = convertAccount(notification.account);

View file

@ -7,6 +7,7 @@ import { argsToBools, convertTimelinesArgsId, limitToInt } from "./timeline.js";
import { convertId, IdType } from "../../index.js"; import { convertId, IdType } from "../../index.js";
import { import {
convertAccount, convertAccount,
convertFeaturedTag,
convertList, convertList,
convertRelationship, convertRelationship,
convertStatus, convertStatus,
@ -174,7 +175,7 @@ export function apiAccountMastodon(router: Router): void {
const data = await client.getAccountFeaturedTags( const data = await client.getAccountFeaturedTags(
convertId(ctx.params.id, IdType.CalckeyId), convertId(ctx.params.id, IdType.CalckeyId),
); );
ctx.body = data.data.map((account) => convertAccount(account)); ctx.body = data.data.map((tag) => convertFeaturedTag(tag));
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
console.error(e.response.data); console.error(e.response.data);
@ -367,7 +368,7 @@ export function apiAccountMastodon(router: Router): void {
const client = getClient(BASE_URL, accessTokens); const client = getClient(BASE_URL, accessTokens);
try { try {
const data = await client.getFeaturedTags(); const data = await client.getFeaturedTags();
ctx.body = data.data.map((account) => convertAccount(account)); ctx.body = data.data.map((tag) => convertFeaturedTag(tag));
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
console.error(e.response.data); console.error(e.response.data);
@ -381,7 +382,7 @@ export function apiAccountMastodon(router: Router): void {
const client = getClient(BASE_URL, accessTokens); const client = getClient(BASE_URL, accessTokens);
try { try {
const data = await client.getFollowedTags(); const data = await client.getFollowedTags();
ctx.body = data.data.map((account) => convertAccount(account)); ctx.body = data.data;
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
console.error(e.response.data); console.error(e.response.data);

View file

@ -1,4 +1,4 @@
import megalodon, { MegalodonInterface } from "@calckey/megalodon"; import megalodon, { MegalodonInterface } from "megalodon";
import Router from "@koa/router"; import Router from "@koa/router";
import { koaBody } from "koa-body"; import { koaBody } from "koa-body";
import { getClient } from "../ApiMastodonCompatibleService.js"; import { getClient } from "../ApiMastodonCompatibleService.js";

View file

@ -1,4 +1,4 @@
import megalodon, { MegalodonInterface } from "@calckey/megalodon"; import megalodon, { MegalodonInterface } from "megalodon";
import Router from "@koa/router"; import Router from "@koa/router";
import { getClient } from "../ApiMastodonCompatibleService.js"; import { getClient } from "../ApiMastodonCompatibleService.js";
import { IdType, convertId } from "../../index.js"; import { IdType, convertId } from "../../index.js";

View file

@ -1,4 +1,4 @@
import { Entity } from "@calckey/megalodon"; import { Entity } from "megalodon";
import { fetchMeta } from "@/misc/fetch-meta.js"; import { fetchMeta } from "@/misc/fetch-meta.js";
import { Users, Notes } from "@/models/index.js"; import { Users, Notes } from "@/models/index.js";
import { IsNull, MoreThan } from "typeorm"; import { IsNull, MoreThan } from "typeorm";

View file

@ -1,4 +1,4 @@
import megalodon, { MegalodonInterface } from "@calckey/megalodon"; import megalodon, { MegalodonInterface } from "megalodon";
import Router from "@koa/router"; import Router from "@koa/router";
import { koaBody } from "koa-body"; import { koaBody } from "koa-body";
import { convertId, IdType } from "../../index.js"; import { convertId, IdType } from "../../index.js";

View file

@ -1,8 +1,8 @@
import megalodon, { MegalodonInterface } from "@calckey/megalodon"; import megalodon, { MegalodonInterface } from "megalodon";
import Router from "@koa/router"; import Router from "@koa/router";
import { getClient } from "../ApiMastodonCompatibleService.js"; import { getClient } from "../ApiMastodonCompatibleService.js";
import axios from "axios"; import axios from "axios";
import { Converter } from "@calckey/megalodon"; import { Converter } from "megalodon";
import { convertTimelinesArgsId, limitToInt } from "./timeline.js"; import { convertTimelinesArgsId, limitToInt } from "./timeline.js";
import { convertAccount, convertStatus } from "../converters.js"; import { convertAccount, convertStatus } from "../converters.js";

View file

@ -1,5 +1,5 @@
import Router from "@koa/router"; import Router from "@koa/router";
import megalodon, { Entity, MegalodonInterface } from "@calckey/megalodon"; import megalodon, { Entity, MegalodonInterface } from "megalodon";
import { getClient } from "../ApiMastodonCompatibleService.js"; import { getClient } from "../ApiMastodonCompatibleService.js";
import { statusModel } from "./status.js"; import { statusModel } from "./status.js";
import Autolinker from "autolinker"; import Autolinker from "autolinker";

View file

@ -25,7 +25,7 @@ import { readNotification } from "../common/read-notification.js";
import channels from "./channels/index.js"; import channels from "./channels/index.js";
import type Channel from "./channel.js"; import type Channel from "./channel.js";
import type { StreamEventEmitter, StreamMessages } from "./types.js"; import type { StreamEventEmitter, StreamMessages } from "./types.js";
import { Converter } from "@calckey/megalodon"; import { Converter } from "megalodon";
import { getClient } from "../mastodon/ApiMastodonCompatibleService.js"; import { getClient } from "../mastodon/ApiMastodonCompatibleService.js";
import { toTextWithReaction } from "../mastodon/endpoints/timeline.js"; import { toTextWithReaction } from "../mastodon/endpoints/timeline.js";

View file

@ -22,7 +22,7 @@ import { createTemp } from "@/misc/create-temp.js";
import { publishMainStream } from "@/services/stream.js"; import { publishMainStream } from "@/services/stream.js";
import * as Acct from "@/misc/acct.js"; import * as Acct from "@/misc/acct.js";
import { envOption } from "@/env.js"; import { envOption } from "@/env.js";
import megalodon, { MegalodonInterface } from "@calckey/megalodon"; import megalodon, { MegalodonInterface } from "megalodon";
import activityPub from "./activitypub.js"; import activityPub from "./activitypub.js";
import nodeinfo from "./nodeinfo.js"; import nodeinfo from "./nodeinfo.js";
import wellKnown from "./well-known.js"; import wellKnown from "./well-known.js";

View file

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

View file

@ -53,7 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = __importDefault(require("axios")); var axios_1 = __importDefault(require("axios"));
var dayjs_1 = __importDefault(require("dayjs")); var dayjs_1 = __importDefault(require("dayjs"));
var form_data_1 = __importDefault(require("form-data")); var form_data_1 = __importDefault(require("form-data"));
var default_1 = require("../default"); var default_1 = require("@/default");
var proxy_config_1 = __importDefault(require("../proxy_config")); var proxy_config_1 = __importDefault(require("../proxy_config"));
var web_socket_1 = __importDefault(require("./web_socket")); var web_socket_1 = __importDefault(require("./web_socket"));
var notification_1 = __importDefault(require("./notification")); var notification_1 = __importDefault(require("./notification"));

View file

@ -1,8 +1,6 @@
{ {
"name": "@calckey/megalodon", "name": "megalodon",
"private": false, "private": true,
"version": "5.1.23",
"description": "Mastodon+Calckey API client for node.js and browser",
"main": "./lib/src/index.js", "main": "./lib/src/index.js",
"typings": "./lib/src/index.d.ts", "typings": "./lib/src/index.d.ts",
"scripts": { "scripts": {
@ -11,26 +9,6 @@
"doc": "typedoc --out ../docs ./src", "doc": "typedoc --out ../docs ./src",
"test": "NODE_ENV=test jest -u --maxWorkers=3" "test": "NODE_ENV=test jest -u --maxWorkers=3"
}, },
"engines": {
"node": ">=15.0.0"
},
"repository": {
"type": "git",
"url": "git+https://codeberg.org/calckey/megalodon.git"
},
"keywords": [
"mastodon",
"client",
"api",
"streaming",
"rest",
"proxy"
],
"author": "thatonecalculator",
"license": "MIT",
"bugs": {
"url": "https://codeberg.org/calckey/megalodon/issues"
},
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [
"ts", "ts",
@ -54,7 +32,6 @@
}, },
"testEnvironment": "node" "testEnvironment": "node"
}, },
"homepage": "https://codeberg.org/calckey/megalodon",
"dependencies": { "dependencies": {
"@types/oauth": "^0.9.0", "@types/oauth": "^0.9.0",
"@types/ws": "^8.5.4", "@types/ws": "^8.5.4",
@ -78,6 +55,7 @@
"@types/object-assign-deep": "^0.4.0", "@types/object-assign-deep": "^0.4.0",
"@types/parse-link-header": "^2.0.0", "@types/parse-link-header": "^2.0.0",
"@types/uuid": "^9.0.0", "@types/uuid": "^9.0.0",
"@types/node": "18.11.18",
"@typescript-eslint/eslint-plugin": "^5.49.0", "@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0", "@typescript-eslint/parser": "^5.49.0",
"@types/async-lock": "1.4.0", "@types/async-lock": "1.4.0",

View file

@ -90,9 +90,6 @@ importers:
'@bull-board/ui': '@bull-board/ui':
specifier: 5.2.0 specifier: 5.2.0
version: 5.2.0 version: 5.2.0
'@calckey/megalodon':
specifier: workspace:*
version: link:../megalodon
'@discordapp/twemoji': '@discordapp/twemoji':
specifier: 14.1.2 specifier: 14.1.2
version: 14.1.2 version: 14.1.2
@ -267,6 +264,9 @@ importers:
koa-views: koa-views:
specifier: 7.0.2 specifier: 7.0.2
version: 7.0.2(@types/koa@2.13.5)(ejs@3.1.9)(pug@3.0.2) version: 7.0.2(@types/koa@2.13.5)(ejs@3.1.9)(pug@3.0.2)
megalodon:
specifier: workspace:*
version: link:../megalodon
meilisearch: meilisearch:
specifier: 0.33.0 specifier: 0.33.0
version: 0.33.0 version: 0.33.0
@ -983,6 +983,9 @@ importers:
'@types/jest': '@types/jest':
specifier: ^29.4.0 specifier: ^29.4.0
version: 29.4.0 version: 29.4.0
'@types/node':
specifier: 18.11.18
version: 18.11.18
'@types/object-assign-deep': '@types/object-assign-deep':
specifier: ^0.4.0 specifier: ^0.4.0
version: 0.4.0 version: 0.4.0