refactor(api): 🔥 Remove old @versia/client version

This commit is contained in:
Jesse Wierzbinski 2025-03-22 18:04:47 +01:00
parent 54e282b03c
commit 8d1af1b0cd
No known key found for this signature in database
121 changed files with 649 additions and 756 deletions

View file

@ -2,7 +2,7 @@ import type { z } from "@hono/zod-openapi";
import type {
Application as ApplicationSchema,
CredentialApplication,
} from "@versia/client-ng/schemas";
} from "@versia/client/schemas";
import { Token, db } from "@versia/kit/db";
import { Applications } from "@versia/kit/tables";
import {

View file

@ -1,7 +1,7 @@
import { emojiValidatorWithColons, emojiValidatorWithIdentifiers } from "@/api";
import { proxyUrl } from "@/response";
import type { z } from "@hono/zod-openapi";
import type { CustomEmoji } from "@versia/client-ng/schemas";
import type { CustomEmoji } from "@versia/client/schemas";
import type { CustomEmojiExtension } from "@versia/federation/types";
import { type Instance, Media, db } from "@versia/kit/db";
import { Emojis, type Instances, type Medias } from "@versia/kit/tables";

View file

@ -1,5 +1,3 @@
import { z } from "@hono/zod-openapi";
import { RolePermission } from "@versia/client/types";
import type { Delete, LikeExtension } from "@versia/federation/types";
import { db } from "@versia/kit/db";
import {
@ -27,16 +25,6 @@ type LikeType = InferSelectModel<typeof Likes> & {
};
export class Like extends BaseInterface<typeof Likes, LikeType> {
public static schema = z.object({
id: z.string(),
name: z.string(),
permissions: z.array(z.nativeEnum(RolePermission)),
priority: z.number(),
description: z.string().nullable(),
visible: z.boolean(),
icon: z.string().nullable(),
});
public static $type: LikeType;
public async reload(): Promise<void> {

View file

@ -2,7 +2,7 @@ import { join } from "node:path";
import { mimeLookup } from "@/content_types.ts";
import { proxyUrl } from "@/response";
import type { z } from "@hono/zod-openapi";
import type { Attachment as AttachmentSchema } from "@versia/client-ng/schemas";
import type { Attachment as AttachmentSchema } from "@versia/client/schemas";
import type { ContentFormat } from "@versia/federation/types";
import { db } from "@versia/kit/db";
import { Medias } from "@versia/kit/tables";

View file

@ -4,7 +4,7 @@ import { sanitizedHtmlStrip } from "@/sanitization";
import { sentry } from "@/sentry";
import type { z } from "@hono/zod-openapi";
import { getLogger } from "@logtape/logtape";
import type { Status, Status as StatusSchema } from "@versia/client-ng/schemas";
import type { Status, Status as StatusSchema } from "@versia/client/schemas";
import { EntityValidator } from "@versia/federation";
import type {
ContentFormat,
@ -825,7 +825,6 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
pinned: data.pinned,
// TODO: Add polls
poll: null,
// @ts-expect-error broken recursive types
reblog: data.reblog
? await new Note(data.reblog as NoteTypeWithRelations).toApi(
userFetching,
@ -841,7 +840,6 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
visibility: data.visibility,
url: data.uri || this.getMastoUri().toString(),
bookmarked: false,
// @ts-expect-error broken recursive types
quote: data.quotingId
? ((await Note.fromId(data.quotingId, userFetching?.id).then(
(n) => n?.toApi(userFetching),
@ -850,8 +848,8 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
edited_at: data.updatedAt
? new Date(data.updatedAt).toISOString()
: null,
emoji_reactions: [],
plain_content: data.contentSource,
reactions: [],
text: data.contentSource,
};
}

View file

@ -1,5 +1,5 @@
import type { z } from "@hono/zod-openapi";
import type { Notification as NotificationSchema } from "@versia/client-ng/schemas";
import type { Notification as NotificationSchema } from "@versia/client/schemas";
import { Note, User, db } from "@versia/kit/db";
import { Notifications } from "@versia/kit/tables";
import {

View file

@ -1,5 +1,5 @@
import type { z } from "@hono/zod-openapi";
import type { WebPushSubscription as WebPushSubscriptionSchema } from "@versia/client-ng/schemas";
import type { WebPushSubscription as WebPushSubscriptionSchema } from "@versia/client/schemas";
import { type Token, type User, db } from "@versia/kit/db";
import { PushSubscriptions, Tokens } from "@versia/kit/tables";
import {

View file

@ -1,5 +1,5 @@
import { z } from "@hono/zod-openapi";
import type { Relationship as RelationshipSchema } from "@versia/client-ng/schemas";
import type { Relationship as RelationshipSchema } from "@versia/client/schemas";
import { db } from "@versia/kit/db";
import { Relationships } from "@versia/kit/tables";
import {

View file

@ -1,8 +1,7 @@
import { proxyUrl } from "@/response";
import type {
VersiaRole as APIRole,
RolePermission,
} from "@versia/client/types";
import type { z } from "@hono/zod-openapi";
import type { Role as RoleSchema } from "@versia/client/schemas";
import type { RolePermission } from "@versia/client/schemas";
import { db } from "@versia/kit/db";
import { RoleToUsers, Roles } from "@versia/kit/tables";
import {
@ -16,7 +15,6 @@ import {
} from "drizzle-orm";
import { config } from "~/config.ts";
import { BaseInterface } from "./base.ts";
type RoleType = InferSelectModel<typeof Roles>;
export class Role extends BaseInterface<typeof Roles> {
@ -208,7 +206,7 @@ export class Role extends BaseInterface<typeof Roles> {
return this.data.id;
}
public toApi(): APIRole {
public toApi(): z.infer<typeof RoleSchema> {
return {
id: this.id,
name: this.data.name,

View file

@ -1,5 +1,5 @@
import type { z } from "@hono/zod-openapi";
import type { Token as TokenSchema } from "@versia/client-ng/schemas";
import type { Token as TokenSchema } from "@versia/client/schemas";
import { type Application, User, db } from "@versia/kit/db";
import { Tokens } from "@versia/kit/tables";
import {

View file

@ -9,7 +9,8 @@ import type {
Account,
Mention as MentionSchema,
Source,
} from "@versia/client-ng/schemas";
} from "@versia/client/schemas";
import type { RolePermission } from "@versia/client/schemas";
import {
EntityValidator,
FederationRequester,
@ -30,7 +31,6 @@ import {
NoteToMentions,
Notes,
Notifications,
type RolePermissions,
UserToPinnedNotes,
Users,
} from "@versia/kit/tables";
@ -171,11 +171,11 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
return uri ? uri : new URL(`/users/${id}`, config.http.base_url);
}
public hasPermission(permission: RolePermissions): boolean {
public hasPermission(permission: RolePermission): boolean {
return this.getAllPermissions().includes(permission);
}
public getAllPermissions(): RolePermissions[] {
public getAllPermissions(): RolePermission[] {
return (
this.data.roles
.flatMap((role) => role.permissions)
@ -188,7 +188,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
acc.push(permission);
}
return acc;
}, [] as RolePermissions[])
}, [] as RolePermission[])
);
}