Files
Toot-Worker/src/types.ts
T
2026-05-16 10:13:22 +08:00

309 lines
6.2 KiB
TypeScript

export type Json = Record<string, unknown>;
export type User = {
id: string;
username: string;
display_name: string;
note: string;
password_hash: string;
private_key_jwk: string;
public_key_jwk: string;
avatar_r2_key: string | null;
header_r2_key: string | null;
created_at: string;
};
export type OAuthApp = {
id: string;
client_id: string;
client_secret: string;
name: string;
redirect_uri: string;
scopes: string;
website: string | null;
created_at: string;
};
export type OAuthCode = {
code: string;
app_id: string;
user_id: string;
redirect_uri: string;
scopes: string;
expires_at: number;
};
export type Status = {
id: string;
user_id: string;
content: string;
summary: string;
sensitive: number;
language: string;
visibility: string;
in_reply_to_id: string | null;
activity_id: string;
object_id: string;
created_at: string;
url: string;
source_text: string;
edited_at: string | null;
};
export type DeletedStatus = {
id: string;
user_id: string;
object_id: string;
url: string;
deleted_at: string;
};
export type Media = {
id: string;
user_id: string;
status_id: string | null;
r2_key: string;
mime_type: string;
description: string | null;
size: number;
created_at: string;
};
export type Follow = {
id: string;
follower_actor: string;
local_user_id: string;
inbox: string;
accepted: number;
created_at: string;
};
export type OutgoingFollow = {
id: string;
local_user_id: string;
target_actor: string;
target_inbox: string;
activity_id: string;
accepted: number;
created_at: string;
};
export type Notification = {
id: string;
user_id: string;
type: string;
actor: string;
status_id: string | null;
read: number;
created_at: string;
};
export type Favourite = {
id: string;
status_id: string;
actor: string;
activity_id: string;
created_at: string;
};
export type Reblog = {
id: string;
status_id: string;
actor: string;
activity_id: string;
created_at: string;
};
export type Mention = {
status_id: string;
actor: string;
acct: string;
url: string;
};
export type Hashtag = {
status_id: string;
tag: string;
};
export type Bookmark = {
user_id: string;
status_id: string;
created_at: string;
};
export type PinnedStatus = {
user_id: string;
status_id: string;
created_at: string;
};
export type CachedStatus = {
id: string;
object_id: string;
actor: string;
content: string;
summary: string;
sensitive: number;
language: string;
visibility: string;
in_reply_to: string | null;
url: string;
published: string;
mentions_json: string;
tags_json: string;
local_recipients_json: string;
cached_at: string;
};
export type CachedStatusMention = {
actor: string;
acct: string;
url: string;
};
export type CachedStatusTag = {
name: string;
url: string | null;
};
export type CachedStatusAttachment = {
cached_status_id: string;
position: number;
url: string;
preview_url: string | null;
mime_type: string;
description: string | null;
};
export type Poll = {
id: string;
status_id: string;
user_id: string;
expires_at: string | null;
multiple: number;
hide_totals: number;
created_at: string;
};
export type PollOption = {
poll_id: string;
position: number;
title: string;
};
export type PollVote = {
poll_id: string;
position: number;
voter_actor: string;
created_at: string;
};
export type AccountList = {
id: string;
user_id: string;
title: string;
replies_policy: string;
exclusive: number;
created_at: string;
};
export type PushSubscription = {
id: string;
user_id: string;
endpoint: string;
server_key: string;
auth: string;
alerts_json: string;
policy: string;
created_at: string;
updated_at: string;
};
export type ScheduledStatus = {
id: string;
user_id: string;
params_json: string;
media_ids_json: string;
scheduled_at: string;
created_at: string;
};
export type Marker = {
user_id: string;
timeline: string;
last_read_id: string;
version: number;
updated_at: string;
};
export type OutgoingDelivery = {
id: string;
user_id: string;
inbox: string;
activity_id: string;
activity_json: string;
attempts: number;
next_attempt_at: string | null;
locked_until: string | null;
delivered_at: string | null;
failed_at: string | null;
last_error: string | null;
created_at: string;
updated_at: string;
};
export type OAuthToken = {
token: string;
user_id: string;
app_id: string;
scopes: string;
created_at: string;
last_used_at: string | null;
};
export type ActorCache = {
id: string;
local_id: string | null;
inbox: string;
shared_inbox: string | null;
preferred_username: string | null;
name: string | null;
summary: string | null;
icon_url: string | null;
public_key_id: string | null;
public_key_pem: string | null;
fetched_at: string;
};
export type RemoteActor = {
id: string;
type?: string;
inbox?: string;
endpoints?: { sharedInbox?: string };
preferredUsername?: string;
name?: string;
summary?: string;
icon?: { url?: string } | string;
publicKey?: {
id?: string;
owner?: string;
publicKeyPem?: string;
};
};
export type Session = {
userId: string;
appId: string;
scopes: string;
};
export const ACTIVITY_CONTEXT = "https://www.w3.org/ns/activitystreams";
export const SECURITY_CONTEXT = "https://w3id.org/security/v1";
export const PUBLIC_COLLECTION = "https://www.w3.org/ns/activitystreams#Public";
export const ACTOR_CACHE_TTL_MS = 1000 * 60 * 60 * 24;
export const SIGNATURE_MAX_SKEW_MS = 1000 * 60 * 60 * 12;
export const AVATAR_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160"><rect width="160" height="160" fill="#d8e1e8"/><circle cx="80" cy="56" r="28" fill="#6b7c8f"/><path d="M30 136c10-28 34-42 50-42s40 14 50 42" fill="#6b7c8f"/></svg>`;
export const HEADER_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1500 500"><defs><linearGradient id="g" x1="0" x2="1"><stop stop-color="#d8e1e8"/><stop offset="1" stop-color="#8aa0b6"/></linearGradient></defs><rect width="1500" height="500" fill="url(#g)"/><circle cx="220" cy="120" r="90" fill="#f7fbff" fill-opacity=".35"/><circle cx="1280" cy="380" r="120" fill="#f7fbff" fill-opacity=".2"/></svg>`;