mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor: ⬆️ Upgrade to Zod v4 and hono-openapi 0.5.0
This commit is contained in:
parent
add2429606
commit
24d4150da4
209 changed files with 1331 additions and 1622 deletions
|
|
@ -10,7 +10,7 @@ import {
|
|||
inArray,
|
||||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { Applications } from "../tables/schema.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
isNull,
|
||||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { Emojis, type Instances, type Medias } from "../tables/schema.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
@ -194,7 +194,7 @@ export class Emoji extends BaseInterface<typeof Emojis, EmojiType> {
|
|||
global: this.data.ownerId === null,
|
||||
description:
|
||||
this.media.data.content[this.media.getPreferredMimeType()]
|
||||
.description ?? null,
|
||||
?.description ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import sharp from "sharp";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { mimeLookup } from "@/content_types.ts";
|
||||
import { getMediaHash } from "../../../classes/media/media-hasher.ts";
|
||||
import { ApiError } from "../api-error.ts";
|
||||
|
|
@ -297,7 +297,7 @@ export class Media extends BaseInterface<typeof Medias> {
|
|||
const content = await Media.fileToContentFormat(file, url, {
|
||||
description:
|
||||
this.data.content[Object.keys(this.data.content)[0]]
|
||||
.description || undefined,
|
||||
?.description || undefined,
|
||||
});
|
||||
|
||||
await this.update({
|
||||
|
|
@ -319,7 +319,7 @@ export class Media extends BaseInterface<typeof Medias> {
|
|||
remote: true,
|
||||
description:
|
||||
this.data.content[Object.keys(this.data.content)[0]]
|
||||
.description || undefined,
|
||||
?.description || undefined,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -363,7 +363,7 @@ export class Media extends BaseInterface<typeof Medias> {
|
|||
content[type] = {
|
||||
...content[type],
|
||||
...metadata,
|
||||
};
|
||||
} as (typeof content)[keyof typeof content];
|
||||
}
|
||||
|
||||
await this.update({
|
||||
|
|
@ -490,6 +490,14 @@ export class Media extends BaseInterface<typeof Medias> {
|
|||
public toApiMeta(): z.infer<typeof AttachmentSchema.shape.meta> {
|
||||
const type = this.getPreferredMimeType();
|
||||
const data = this.data.content[type];
|
||||
|
||||
if (!data) {
|
||||
throw new ApiError(
|
||||
500,
|
||||
`No content for type ${type} in attachment ${this.id}`,
|
||||
);
|
||||
}
|
||||
|
||||
const size =
|
||||
data.width && data.height
|
||||
? `${data.width}x${data.height}`
|
||||
|
|
@ -533,7 +541,7 @@ export class Media extends BaseInterface<typeof Medias> {
|
|||
? new ProxiableUrl(thumbnailData.content).proxied
|
||||
: null,
|
||||
meta: this.toApiMeta(),
|
||||
description: data.description || null,
|
||||
description: data?.description || null,
|
||||
blurhash: this.data.blurhash,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import {
|
|||
} from "drizzle-orm";
|
||||
import { htmlToText } from "html-to-text";
|
||||
import { createRegExp, exactly, global } from "magic-regexp";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { mergeAndDeduplicate } from "@/lib.ts";
|
||||
import { sanitizedHtmlStrip } from "@/sanitization";
|
||||
import { versiaTextToHtml } from "../parsers.ts";
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
inArray,
|
||||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { Notifications } from "../tables/schema.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
@ -189,6 +189,7 @@ export class Notification extends BaseInterface<
|
|||
created_at: new Date(this.data.createdAt).toISOString(),
|
||||
id: this.data.id,
|
||||
type: this.data.type,
|
||||
event: undefined,
|
||||
status: this.data.status
|
||||
? await new Note(this.data.status).toApi(account)
|
||||
: undefined,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
inArray,
|
||||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { PushSubscriptions, Tokens } from "../tables/schema.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
type SQL,
|
||||
sql,
|
||||
} from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { Relationships, Users } from "../tables/schema.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
inArray,
|
||||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { Roles, RoleToUsers } from "../tables/schema.ts";
|
||||
import { BaseInterface } from "./base.ts";
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
inArray,
|
||||
type SQL,
|
||||
} from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { db } from "../tables/db.ts";
|
||||
import { Tokens } from "../tables/schema.ts";
|
||||
import type { Application } from "./application.ts";
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {
|
|||
sql,
|
||||
} from "drizzle-orm";
|
||||
import { htmlToText } from "html-to-text";
|
||||
import type { z } from "zod";
|
||||
import type { z } from "zod/v4";
|
||||
import { getBestContentType } from "@/content_types";
|
||||
import { randomString } from "@/math";
|
||||
import type { HttpVerb, KnownEntity } from "~/types/api.ts";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue