refactor(api): ♻️ Replace old client library with new version (@versia/client)

This commit is contained in:
Jesse Wierzbinski 2024-08-26 19:40:15 +02:00
parent 7708bff31f
commit fbe86043b7
No known key found for this signature in database
45 changed files with 51 additions and 54 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -1,4 +1,4 @@
import type { Application as APIApplication } from "@lysand-org/client/types";
import type { Application as APIApplication } from "@versia/client/types";
import type { InferSelectModel } from "drizzle-orm";
import { db } from "~/drizzle/db";
import type { Applications } from "~/drizzle/schema";

View file

@ -1,4 +1,4 @@
import type { Notification as ApiNotification } from "@lysand-org/client/types";
import type { Notification as ApiNotification } from "@versia/client/types";
import type { InferSelectModel } from "drizzle-orm";
import { db } from "~/drizzle/db";
import type { Notifications } from "~/drizzle/schema";

View file

@ -323,8 +323,8 @@ avatars = []
# Bridges must be hosted separately from the main Versia Server process
[federation.bridge]
enabled = false
# Only lysand-ap exists for now
software = "lysand-ap"
# Only versia-ap exists for now
software = "versia-ap"
# If this is empty, any bridge with the correct token
# will be able to send data to your instance
allowed_ips = ["192.168.1.0/24"]

View file

@ -3346,7 +3346,7 @@
"anyOf": [
{
"type": "string",
"enum": ["lysand-ap"]
"enum": ["versia-ap"]
},
{
"type": "string"
@ -3372,7 +3372,7 @@
"additionalProperties": false,
"default": {
"enabled": false,
"software": "lysand-ap",
"software": "versia-ap",
"allowed_ips": [],
"token": ""
}
@ -3396,7 +3396,7 @@
},
"bridge": {
"enabled": false,
"software": "lysand-ap",
"software": "versia-ap",
"allowed_ips": [],
"token": ""
}

View file

@ -7,7 +7,7 @@ Versia Server supports the use of the Glitch-Soc fork of Mastodon's frontend. He
3. Change the config to enable Glitch-FE:
```toml
[frontend]
# Enable custom frontends (warning: not enabling this or Glitch will make Lysand only accessible via the Mastodon API)
# Enable custom frontends (warning: not enabling this or Glitch will make Versia Server only accessible via the Mastodon API)
# Frontends also control the OAuth flow, so if you disable this, you will need to use the Mastodon frontend
enabled = true
# The URL to reach the frontend at (should be on a local network)

View file

@ -1,4 +1,4 @@
import type { Source as ApiSource } from "@lysand-org/client/types";
import type { Source as ApiSource } from "@versia/client/types";
import type { ContentFormat } from "@versia/federation/types";
import type { Challenge } from "altcha-lib/types";
import { relations, sql } from "drizzle-orm";

View file

@ -105,10 +105,10 @@
"@inquirer/input": "^2.2.9",
"@json2csv/plainjs": "^7.0.6",
"@logtape/logtape": "npm:@jsr/logtape__logtape@0.4.2",
"@lysand-org/client": "^0.2.5",
"@oclif/core": "^4.0.19",
"@sentry/bun": "^8.26.0",
"@tufjs/canonical-json": "^2.0.0",
"@versia/client": "^0.1.0-rc.0",
"@versia/federation": "^0.1.0-rc.1",
"altcha-lib": "^0.5.1",
"blurhash": "^2.0.5",

View file

@ -484,14 +484,14 @@ export const configValidator = z.object({
bridge: z
.object({
enabled: z.boolean().default(false),
software: z.enum(["lysand-ap"]).or(z.string()),
software: z.enum(["versia-ap"]).or(z.string()),
allowed_ips: z.array(z.string().trim()).default([]),
token: z.string().default(""),
url: zUrl.optional(),
})
.default({
enabled: false,
software: "lysand-ap",
software: "versia-ap",
allowed_ips: [],
token: "",
})
@ -516,7 +516,7 @@ export const configValidator = z.object({
},
bridge: {
enabled: false,
software: "lysand-ap",
software: "versia-ap",
allowed_ips: [],
token: "",
},

View file

@ -2,7 +2,7 @@ import { proxyUrl } from "@/response";
import type {
AsyncAttachment as ApiAsyncAttachment,
Attachment as ApiAttachment,
} from "@lysand-org/client/types";
} from "@versia/client/types";
import type { ContentFormat } from "@versia/federation/types";
import {
type InferInsertModel,

View file

@ -1,6 +1,6 @@
import { emojiValidatorWithColons, emojiValidatorWithIdentifiers } from "@/api";
import { proxyUrl } from "@/response";
import type { Emoji as ApiEmoji } from "@lysand-org/client/types";
import type { Emoji as ApiEmoji } from "@versia/client/types";
import type { CustomEmojiExtension } from "@versia/federation/types";
import {
type InferInsertModel,

View file

@ -7,7 +7,7 @@ import { getLogger } from "@logtape/logtape";
import type {
Attachment as ApiAttachment,
Status as ApiStatus,
} from "@lysand-org/client/types";
} from "@versia/client/types";
import { EntityValidator } from "@versia/federation";
import type {
ContentFormat,

View file

@ -1,4 +1,4 @@
import type { Relationship as APIRelationship } from "@lysand-org/client/types";
import type { Relationship as APIRelationship } from "@versia/client/types";
import {
type InferInsertModel,
type InferSelectModel,

View file

@ -1,5 +1,5 @@
import { proxyUrl } from "@/response";
import type { RolePermission } from "@lysand-org/client/types";
import type { RolePermission } from "@versia/client/types";
import {
type InferInsertModel,
type InferSelectModel,

View file

@ -7,14 +7,14 @@ import { getLogger } from "@logtape/logtape";
import type {
Account as ApiAccount,
Mention as ApiMention,
} from "@lysand-org/client/types";
} from "@versia/client/types";
import {
EntityValidator,
FederationRequester,
type HttpVerb,
SignatureConstructor,
} from "@versia/federation";
import type { User as VersiaUser } from "@versia/federation/types";
import type { Collection, User as VersiaUser } from "@versia/federation/types";
import chalk from "chalk";
import {
type InferInsertModel,
@ -668,7 +668,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
* @returns The signed string and headers to send with the request
*/
async sign(
entity: KnownEntity,
entity: KnownEntity | Collection,
signatureUrl: string | URL,
signatureMethod: HttpVerb = "POST",
): Promise<{

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@lysand-org/client/types";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./block";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@lysand-org/client/types";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./follow";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./followers";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./following";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@lysand-org/client/types";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./mute";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@lysand-org/client/types";
import type { Status as ApiStatus } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./statuses";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@lysand-org/client/types";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./unmute";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -6,7 +6,7 @@ import {
idValidator,
} from "@/api";
import { zValidator } from "@hono/zod-validator";
import type { Marker as ApiMarker } from "@lysand-org/client/types";
import type { Marker as ApiMarker } from "@versia/client/types";
import { and, count, eq } from "drizzle-orm";
import { z } from "zod";
import { db } from "~/drizzle/db";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Notification as ApiNotification } from "@lysand-org/client/types";
import type { Notification as ApiNotification } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./dismiss";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Notification as ApiNotification } from "@lysand-org/client/types";
import type { Notification as ApiNotification } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Notification as ApiNotification } from "@lysand-org/client/types";
import type { Notification as ApiNotification } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Notification as ApiNotification } from "@lysand-org/client/types";
import type { Notification as ApiNotification } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Notification as ApiNotification } from "@lysand-org/client/types";
import type { Notification as ApiNotification } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./index";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@lysand-org/client/types";
import type { Status as ApiStatus } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./favourite";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./favourited_by";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@lysand-org/client/types";
import type { Account as ApiAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./reblogged_by";

View file

@ -1,6 +1,6 @@
import { apiRoute, applyConfig, auth, handleZodError } from "@/api";
import { zValidator } from "@hono/zod-validator";
import type { StatusSource as ApiStatusSource } from "@lysand-org/client/types";
import type { StatusSource as ApiStatusSource } from "@versia/client/types";
import { z } from "zod";
import { RolePermissions } from "~/drizzle/schema";
import { Note } from "~/packages/database-interface/note";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@lysand-org/client/types";
import type { Status as ApiStatus } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./unfavourite";

View file

@ -1,5 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@lysand-org/client/types";
import type { Status as ApiStatus } from "@versia/client/types";
import { eq } from "drizzle-orm";
import { db } from "~/drizzle/db";
import { Emojis } from "~/drizzle/schema";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@lysand-org/client/types";
import type { Status as ApiStatus } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./home";

View file

@ -1,5 +1,5 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@lysand-org/client/types";
import type { Status as ApiStatus } from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
import { meta } from "./public";

View file

@ -1,6 +1,6 @@
import { apiRoute, applyConfig } from "@/api";
import { proxyUrl } from "@/response";
import type { Instance as ApiInstance } from "@lysand-org/client/types";
import type { Instance as ApiInstance } from "@versia/client/types";
import { and, eq, isNull } from "drizzle-orm";
import { Users } from "~/drizzle/schema";
import manifest from "~/package.json";
@ -37,7 +37,6 @@ export default apiRoute((app) =>
domain: new URL(config.http.base_url).hostname,
title: config.instance.name,
version: "4.3.0-alpha.3+glitch",
// @ts-expect-error Temporary until package also gets the rebranding
versia_version: version,
source_url: "https://github.com/lysand-org/server",
description: config.instance.description,

View file

@ -5,7 +5,7 @@ import { afterAll, describe, expect, test } from "bun:test";
import type {
Account as ApiAccount,
Relationship as ApiRelationship,
} from "@lysand-org/client/types";
} from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "~/tests/utils";

View file

@ -6,7 +6,7 @@ import type {
AsyncAttachment as ApiAsyncAttachment,
Context as ApiContext,
Status as ApiStatus,
} from "@lysand-org/client/types";
} from "@versia/client/types";
import { config } from "~/packages/config-manager/index";
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "~/tests/utils";

View file

@ -5,7 +5,7 @@ import { afterAll, describe, expect, test } from "bun:test";
import type {
Application as ApiApplication,
Token as ApiToken,
} from "@lysand-org/client/types";
} from "@versia/client/types";
import { config } from "~/packages/config-manager";
import { getTestUsers, sendTestRequest, wrapRelativeUrl } from "./utils";

View file

@ -1,7 +1,6 @@
import type { Hono } from "@hono/hono";
import type { RouterRoute } from "@hono/hono/types";
import type {
Collection,
Delete,
Follow,
FollowAccept,
@ -62,5 +61,4 @@ export type KnownEntity =
| FollowReject
| Unfollow
| Delete
| LikeExtension
| Collection;
| LikeExtension;