2025-07-07 03:42:35 +02:00
import { z } from "zod/v4" ;
2025-02-05 22:49:07 +01:00
import { Account } from "./account.ts" ;
2025-02-12 23:25:22 +01:00
import { Attachment } from "./attachment.ts" ;
2025-02-05 22:49:07 +01:00
import { PreviewCard } from "./card.ts" ;
2025-02-15 02:47:29 +01:00
import { Id , iso631 , zBoolean } from "./common.ts" ;
2025-02-11 18:22:39 +01:00
import { CustomEmoji } from "./emoji.ts" ;
2025-02-05 22:49:07 +01:00
import { FilterResult } from "./filters.ts" ;
2025-02-12 23:04:44 +01:00
import { Poll } from "./poll.ts" ;
import { Tag } from "./tag.ts" ;
2025-02-11 18:22:39 +01:00
import { NoteReaction } from "./versia.ts" ;
2025-02-05 22:49:07 +01:00
export const Mention = z
. object ( {
2025-07-07 03:42:35 +02:00
id : Account.shape.id.meta ( {
2025-02-05 22:49:07 +01:00
description : "The account ID of the mentioned user." ,
example : "b9dcb548-bd4d-42af-8b48-3693e6d298e6" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#Mention-id" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
username : Account.shape.username.meta ( {
2025-02-05 22:49:07 +01:00
description : "The username of the mentioned user." ,
example : "lexi" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#Mention-username" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
url : Account.shape.url.meta ( {
2025-02-05 22:49:07 +01:00
description : "The location of the mentioned user’ s profile." ,
example : "https://beta.versia.social/@lexi" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#Mention-url" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
acct : Account.shape.acct.meta ( {
2025-02-05 22:49:07 +01:00
description :
"The webfinger acct: URI of the mentioned user. Equivalent to username for local users, or username@domain for remote users." ,
example : "lexi@beta.versia.social" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#Mention-acct" ,
} ,
} ) ,
} )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-02-05 22:49:07 +01:00
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#Mention" ,
} ,
2025-07-07 03:42:35 +02:00
id : "Mention" ,
2025-02-05 22:49:07 +01:00
} ) ;
2025-02-14 16:44:32 +01:00
export const StatusSource = z
. object ( {
2025-07-07 03:42:35 +02:00
id : Id.meta ( {
2025-02-14 16:44:32 +01:00
description : "ID of the status in the database." ,
example : "c7db92a4-e472-4e94-a115-7411ee934ba1" ,
} ) ,
2025-07-07 03:42:35 +02:00
text : z.string ( ) . trim ( ) . meta ( {
2025-05-13 11:51:59 +02:00
description : "The plain text used to compose the status." ,
example : "this is a status that will be edited" ,
} ) ,
2025-06-23 18:53:40 +02:00
// min(0) because some masto-fe clients send empty spoiler_text
// when they don't want to set it.
2025-07-07 03:42:35 +02:00
spoiler_text : z.string ( ) . trim ( ) . min ( 0 ) . max ( 1024 ) . meta ( {
2025-02-14 16:44:32 +01:00
description :
"The plain text used to compose the status’ s subject or content warning." ,
example : "" ,
} ) ,
} )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-02-14 16:44:32 +01:00
externalDocs : {
url : "https://docs.joinmastodon.org/entities/StatusSource" ,
} ,
2025-07-07 03:42:35 +02:00
id : "StatusSource" ,
2025-02-14 16:44:32 +01:00
} ) ;
2025-07-07 03:42:35 +02:00
export const Status = z
2025-03-24 15:25:40 +01:00
. object ( {
2025-07-07 03:42:35 +02:00
id : Id.meta ( {
2025-03-24 15:25:40 +01:00
description : "ID of the status in the database." ,
example : "2de861d3-a3dd-42ee-ba38-2c7d3f4af588" ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#id" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
uri : z.url ( ) . meta ( {
description : "URI of the status used for federation." ,
example :
"https://beta.versia.social/@lexi/2de861d3-a3dd-42ee-ba38-2c7d3f4af588" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#uri" ,
} ,
} ) ,
2025-03-24 15:25:40 +01:00
url : z
. url ( )
. nullable ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description : "A link to the status’ s HTML representation." ,
example :
"https://beta.versia.social/@lexi/2de861d3-a3dd-42ee-ba38-2c7d3f4af588" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#url" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
account : Account.meta ( {
2025-03-24 15:25:40 +01:00
description : "The account that authored this status." ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#account" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
in_reply_to_id : Id.nullable ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "ID of the status being replied to." ,
example : "c41c9fe9-919a-4d35-a921-d3e79a5c95f8" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#in_reply_to_id" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
in_reply_to_account_id : Account.shape.id.nullable ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"ID of the account that authored the status being replied to." ,
example : "7b9b3ec6-1013-4cc6-8902-94ad00cf2ccc" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#in_reply_to_account_id" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-03-22 18:04:47 +01:00
2025-07-07 03:42:35 +02:00
content : z.string ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "HTML-encoded status content." ,
example : "<p>hello world</p>" ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#content" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
created_at : z.iso.datetime ( ) . meta ( {
description : "The date when this status was created." ,
example : "2025-01-07T14:11:00.000Z" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#created_at" ,
} ,
} ) ,
edited_at : z.iso
2025-03-24 15:25:40 +01:00
. datetime ( )
. nullable ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description : "Timestamp of when the status was last edited." ,
example : "2025-01-07T14:11:00.000Z" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#edited_at" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
emojis : z.array ( CustomEmoji ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"Custom emoji to be used when rendering status content." ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#emojis" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-03-24 15:25:40 +01:00
replies_count : z
. number ( )
. int ( )
. nonnegative ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description : "How many replies this status has received." ,
example : 1 ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#replies_count" ,
} ,
} ) ,
reblogs_count : z
. number ( )
. int ( )
. nonnegative ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description : "How many boosts this status has received." ,
example : 6 ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#reblogs_count" ,
} ,
} ) ,
favourites_count : z
. number ( )
. int ( )
. nonnegative ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description : "How many favourites this status has received." ,
example : 11 ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#favourites_count" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
reblogged : zBoolean.optional ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"If the current token has an authorized user: Have you boosted this status?" ,
example : false ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#reblogged" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
favourited : zBoolean.optional ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"If the current token has an authorized user: Have you favourited this status?" ,
example : true ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#favourited" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
muted : zBoolean.optional ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"If the current token has an authorized user: Have you muted notifications for this status’ s conversation?" ,
example : false ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#muted" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
sensitive : zBoolean.meta ( {
2025-03-24 15:25:40 +01:00
description : "Is this status marked as sensitive content?" ,
example : false ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#sensitive" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
spoiler_text : z.string ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"Subject or summary line, below which status content is collapsed until expanded." ,
example : "lewd text" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#spoiler_text" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
visibility : z.enum ( [ "public" , "unlisted" , "private" , "direct" ] ) . meta ( {
description : "Visibility of this status." ,
example : "public" ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#visibility" ,
} ,
} ) ,
media_attachments : z.array ( Attachment ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "Media that is attached to this status." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#media_attachments" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
mentions : z.array ( Mention ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "Mentions of users within the status content." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#mentions" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
tags : z.array ( Tag ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "Hashtags used within the status content." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#tags" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
card : PreviewCard.nullable ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description :
"Preview card for links included within status content." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#card" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
poll : Poll.nullable ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "The poll attached to the status." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#poll" ,
} ,
} ) ,
application : z
. object ( {
2025-07-07 03:42:35 +02:00
name : z.string ( ) . meta ( {
2025-02-05 22:49:07 +01:00
description :
2025-03-24 15:25:40 +01:00
"The name of the application that posted this status." ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#application-name" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-03-24 15:25:40 +01:00
website : z
. url ( )
. nullable ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description :
"The website associated with the application that posted this status." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#application-website" ,
} ,
} ) ,
} )
. optional ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description : "The application used to post this status." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#application" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
language : iso631.nullable ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "Primary language of this status." ,
example : "en" ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#language" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
get reblog() {
return Status . nullable ( ) . meta ( {
description : "The status being reblogged." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#reblog" ,
} ,
} ) ;
} ,
get quote() {
return Status . nullable ( ) ;
} ,
2025-03-24 15:25:40 +01:00
text : z
. string ( )
. nullable ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description :
"Plain-text source of a status. Returned instead of content when status is deleted, so the user may redraft from the source text without the client having to reverse-engineer the original text from the HTML content." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#text" ,
} ,
} ) ,
2025-07-07 03:42:35 +02:00
pinned : zBoolean.optional ( ) . meta ( {
2025-02-05 22:49:07 +01:00
description :
2025-03-24 15:25:40 +01:00
"If the current token has an authorized user: Have you pinned this status? Only appears if the status is pinnable." ,
example : true ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#pinned" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-07-07 03:42:35 +02:00
reactions : z.array ( NoteReaction ) . meta ( { } ) ,
bookmarked : zBoolean.optional ( ) . meta ( {
2025-02-05 22:49:07 +01:00
description :
2025-03-24 15:25:40 +01:00
"If the current token has an authorized user: Have you bookmarked this status?" ,
example : false ,
2025-02-05 22:49:07 +01:00
externalDocs : {
2025-03-24 15:25:40 +01:00
url : "https://docs.joinmastodon.org/entities/Status/#bookmarked" ,
2025-02-05 22:49:07 +01:00
} ,
} ) ,
2025-03-24 15:25:40 +01:00
filtered : z
. array ( FilterResult )
. optional ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description :
"If the current token has an authorized user: The filter and keywords that matched this status." ,
externalDocs : {
url : "https://docs.joinmastodon.org/entities/Status/#filtered" ,
} ,
} ) ,
} )
2025-07-07 03:42:35 +02:00
. meta ( {
id : "Status" ,
2025-03-29 03:30:06 +01:00
} ) ;
2025-03-22 17:32:46 +01:00
2025-03-24 15:25:40 +01:00
export const ScheduledStatus = z
. object ( {
2025-07-07 03:42:35 +02:00
id : Id.meta ( {
2025-03-24 15:25:40 +01:00
description : "ID of the scheduled status in the database." ,
example : "2de861d3-a3dd-42ee-ba38-2c7d3f4af588" ,
2025-03-22 17:32:46 +01:00
} ) ,
2025-07-07 03:42:35 +02:00
scheduled_at : z.iso.datetime ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "When the status will be scheduled." ,
example : "2025-01-07T14:11:00.000Z" ,
} ) ,
media_attachments : Status.shape.media_attachments ,
params : z.object ( {
2025-07-07 03:42:35 +02:00
text : z.string ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "Text to be used as status content." ,
example : "Hello, world!" ,
} ) ,
poll : Status.shape.poll ,
media_ids : z
. array ( Id )
. nullable ( )
2025-07-07 03:42:35 +02:00
. meta ( {
2025-03-24 15:25:40 +01:00
description :
"IDs of the MediaAttachments that will be attached to the status." ,
example : [ "1234567890" , "1234567891" ] ,
} ) ,
sensitive : Status.shape.sensitive ,
spoiler_text : Status.shape.spoiler_text ,
visibility : Status.shape.visibility ,
in_reply_to_id : Status.shape.in_reply_to_id ,
/** Versia Server API Extension */
2025-07-07 03:42:35 +02:00
quote_id : z.string ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "ID of the status being quoted." ,
example : "c5d62a13-f340-4e7d-8942-7fd14be688dc" ,
} ) ,
language : Status.shape.language ,
2025-07-07 03:42:35 +02:00
scheduled_at : z.null ( ) . meta ( {
2025-03-22 17:32:46 +01:00
description :
2025-03-24 15:25:40 +01:00
"When the status will be scheduled. This will be null because the status is only scheduled once." ,
example : null ,
} ) ,
2025-07-07 03:42:35 +02:00
idempotency : z.string ( ) . nullable ( ) . meta ( {
2025-03-24 15:25:40 +01:00
description : "Idempotency key to prevent duplicate statuses." ,
example : "1234567890" ,
2025-03-22 17:32:46 +01:00
} ) ,
} ) ,
2025-03-24 15:25:40 +01:00
} )
2025-07-07 03:42:35 +02:00
. meta ( {
id : "ScheduledStatus" ,
2025-03-29 03:30:06 +01:00
} ) ;