mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
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
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:
parent
c0060f1baf
commit
5dfcfc548f
25 changed files with 256 additions and 260 deletions
|
|
@ -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 field’s 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 profile’s 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 profile’s 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.",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { config } from "~/config.ts";
|
||||
import { Id } from "./common.ts";
|
||||
|
||||
export const Attachment = z
|
||||
|
|
@ -51,16 +50,11 @@ export const Attachment = z
|
|||
},
|
||||
},
|
||||
}),
|
||||
description: z
|
||||
.string()
|
||||
.trim()
|
||||
.max(config.validation.media.max_description_characters)
|
||||
.nullable()
|
||||
.openapi({
|
||||
description:
|
||||
"Alternate text that describes what is in the media attachment, to be used for the visually impaired or when media attachments do not load.",
|
||||
example: "test media description",
|
||||
}),
|
||||
description: z.string().trim().nullable().openapi({
|
||||
description:
|
||||
"Alternate text that describes what is in the media attachment, to be used for the visually impaired or when media attachments do not load.",
|
||||
example: "test media description",
|
||||
}),
|
||||
blurhash: z.string().nullable().openapi({
|
||||
description:
|
||||
"A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet.",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { emojiValidator } from "@/api.ts";
|
||||
import { config } from "~/config.ts";
|
||||
import { emojiRegex } from "../regex.ts";
|
||||
import { Id, zBoolean } from "./common.ts";
|
||||
|
||||
export const CustomEmoji = z
|
||||
|
|
@ -14,9 +13,8 @@ export const CustomEmoji = z
|
|||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(config.validation.emojis.max_shortcode_characters)
|
||||
.regex(
|
||||
emojiValidator,
|
||||
emojiRegex,
|
||||
"Shortcode must only contain letters (any case), numbers, dashes or underscores.",
|
||||
)
|
||||
.openapi({
|
||||
|
|
@ -76,7 +74,6 @@ export const CustomEmoji = z
|
|||
/* Versia Server API extension */
|
||||
description: z
|
||||
.string()
|
||||
.max(config.validation.emojis.max_description_characters)
|
||||
.nullable()
|
||||
.openapi({
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import pkg from "~/package.json";
|
||||
import { Account } from "./account.ts";
|
||||
import { iso631 } from "./common.ts";
|
||||
import { Rule } from "./rule.ts";
|
||||
|
|
@ -48,7 +47,7 @@ export const Instance = z
|
|||
source_url: z.string().url().openapi({
|
||||
description:
|
||||
"The URL for the source code of the software running on this instance, in keeping with AGPL license requirements.",
|
||||
example: pkg.repository.url,
|
||||
example: "https://github.com/versia-pub/server",
|
||||
}),
|
||||
description: z.string().openapi({
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { config } from "~/config.ts";
|
||||
import { Id } from "./common.ts";
|
||||
import { CustomEmoji } from "./emoji.ts";
|
||||
|
||||
|
|
@ -9,7 +8,6 @@ export const PollOption = z
|
|||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(config.validation.polls.max_option_characters)
|
||||
.openapi({
|
||||
description: "The text value of the poll option.",
|
||||
example: "yes",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { config } from "~/config.ts";
|
||||
import { Account } from "./account.ts";
|
||||
import { Attachment } from "./attachment.ts";
|
||||
import { PreviewCard } from "./card.ts";
|
||||
|
|
@ -55,21 +54,10 @@ export const StatusSource = z
|
|||
description: "ID of the status in the database.",
|
||||
example: "c7db92a4-e472-4e94-a115-7411ee934ba1",
|
||||
}),
|
||||
text: z
|
||||
.string()
|
||||
.max(config.validation.notes.max_characters)
|
||||
.trim()
|
||||
.refine(
|
||||
(s) =>
|
||||
!config.validation.filters.note_content.some((filter) =>
|
||||
filter.test(s),
|
||||
),
|
||||
"Status contains blocked words",
|
||||
)
|
||||
.openapi({
|
||||
description: "The plain text used to compose the status.",
|
||||
example: "this is a status that will be edited",
|
||||
}),
|
||||
text: z.string().trim().openapi({
|
||||
description: "The plain text used to compose the status.",
|
||||
example: "this is a status that will be edited",
|
||||
}),
|
||||
spoiler_text: z.string().trim().min(1).max(1024).openapi({
|
||||
description:
|
||||
"The plain text used to compose the status’s subject or content warning.",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { config } from "~/config.ts";
|
||||
import { Id } from "./common.ts";
|
||||
import { RolePermission } from "./permissions.ts";
|
||||
|
||||
|
|
@ -55,15 +54,10 @@ export const Role = z
|
|||
/* Versia Server API extension */
|
||||
export const NoteReaction = z
|
||||
.object({
|
||||
name: z
|
||||
.string()
|
||||
.min(1)
|
||||
.max(config.validation.emojis.max_shortcode_characters)
|
||||
.trim()
|
||||
.openapi({
|
||||
description: "Custom Emoji shortcode or Unicode emoji.",
|
||||
example: "blobfox_coffee",
|
||||
}),
|
||||
name: z.string().min(1).trim().openapi({
|
||||
description: "Custom Emoji shortcode or Unicode emoji.",
|
||||
example: "blobfox_coffee",
|
||||
}),
|
||||
count: z.number().int().nonnegative().openapi({
|
||||
description: "Number of users who reacted with this emoji.",
|
||||
example: 5,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue