refactor(api): ♻️ Make SDK and client package only use resources in their own package
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 1s
Build Docker Images / lint (push) Failing after 7s
Build Docker Images / check (push) Failing after 6s
Build Docker Images / tests (push) Failing after 6s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Mirror to Codeberg / Mirror (push) Failing after 0s
Nix Build / check (push) Failing after 1s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s

This commit is contained in:
Jesse Wierzbinski 2025-05-13 11:51:59 +02:00
parent c0060f1baf
commit 5dfcfc548f
No known key found for this signature in database
25 changed files with 256 additions and 260 deletions

View file

@ -1,6 +1,5 @@
import { z } from "zod";
import { userAddressValidator } from "@/api.ts";
import { config } from "~/config.ts";
import { userAddressRegex } from "../regex.ts";
import { iso631, zBoolean } from "./common.ts";
import { CustomEmoji } from "./emoji.ts";
import { Role } from "./versia.ts";
@ -11,7 +10,6 @@ export const Field = z
.string()
.trim()
.min(1)
.max(config.validation.accounts.max_field_name_characters)
.openapi({
description: "The key of a given fields key-value pair.",
example: "Freak level",
@ -23,7 +21,6 @@ export const Field = z
.string()
.trim()
.min(1)
.max(config.validation.accounts.max_field_value_characters)
.openapi({
description: "The value associated with the name key.",
example: "<p>High</p>",
@ -87,14 +84,6 @@ export const Source = z
.string()
.trim()
.min(0)
.max(config.validation.accounts.max_bio_characters)
.refine(
(s) =>
!config.validation.filters.bio.some((filter) =>
filter.test(s),
),
"Bio contains blocked words",
)
.openapi({
description: "Profile bio, in plain-text instead of in HTML.",
example: "ermmm what the meow meow",
@ -102,12 +91,9 @@ export const Source = z
url: "https://docs.joinmastodon.org/entities/Account/#source-note",
},
}),
fields: z
.array(Field)
.max(config.validation.accounts.max_field_count)
.openapi({
description: "Metadata about the account.",
}),
fields: z.array(Field).openapi({
description: "Metadata about the account.",
}),
})
.openapi({
description:
@ -135,25 +121,10 @@ const BaseAccount = z
.string()
.min(3)
.trim()
.max(config.validation.accounts.max_username_characters)
.regex(
/^[a-z0-9_-]+$/,
"Username can only contain letters, numbers, underscores and hyphens",
)
.refine(
(s) =>
!config.validation.filters.username.some((filter) =>
filter.test(s),
),
"Username contains blocked words",
)
.refine(
(s) =>
!config.validation.accounts.disallowed_usernames.some((u) =>
u.test(s),
),
"Username is disallowed",
)
.openapi({
description:
"The username of the account, not including domain.",
@ -166,7 +137,7 @@ const BaseAccount = z
.string()
.min(1)
.trim()
.regex(userAddressValidator, "Invalid user address")
.regex(userAddressRegex, "Invalid user address")
.openapi({
description:
"The Webfinger account URI. Equal to username for local users, or username@domain for remote users.",
@ -189,14 +160,6 @@ const BaseAccount = z
.string()
.min(3)
.trim()
.max(config.validation.accounts.max_displayname_characters)
.refine(
(s) =>
!config.validation.filters.displayname.some((filter) =>
filter.test(s),
),
"Display name contains blocked words",
)
.openapi({
description: "The profiles display name.",
example: "Lexi :flower:",
@ -207,15 +170,7 @@ const BaseAccount = z
note: z
.string()
.min(0)
.max(config.validation.accounts.max_bio_characters)
.trim()
.refine(
(s) =>
!config.validation.filters.bio.some((filter) =>
filter.test(s),
),
"Bio contains blocked words",
)
.openapi({
description: "The profiles bio or description.",
example: "<p>ermmm what the meow meow</p>",
@ -279,16 +234,13 @@ const BaseAccount = z
url: "https://docs.joinmastodon.org/entities/Account/#locked",
},
}),
fields: z
.array(Field)
.max(config.validation.accounts.max_field_count)
.openapi({
description:
"Additional metadata attached to a profile as name-value pairs.",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Account/#fields",
},
}),
fields: z.array(Field).openapi({
description:
"Additional metadata attached to a profile as name-value pairs.",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Account/#fields",
},
}),
emojis: z.array(CustomEmoji).openapi({
description:
"Custom emoji entities to be used when rendering the profile.",