♻️ Fully typed API
This commit is contained in:
14
app/types/api/activity.ts
Normal file
14
app/types/api/activity.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { SnPost } from './post'
|
||||
|
||||
// Activity interface (main response structure)
|
||||
export interface SnActivity {
|
||||
id: string;
|
||||
type: string;
|
||||
resource_identifier: string;
|
||||
meta: Record<string, unknown>;
|
||||
data: SnPost;
|
||||
visibility: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
6
app/types/api/index.ts
Normal file
6
app/types/api/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Re-export all types from separate files for easy importing
|
||||
export type { SnFileMeta, SnAttachment, SnPost } from './post'
|
||||
export type { SnVerification, SnPublisher } from './publisher'
|
||||
export type { SnActivity } from './activity'
|
||||
export type { SnVersion } from './version'
|
||||
export type { SnAccountLink, SnAccountBadge, SnAccountPerkSubscription, SnAccountProfile, SnAccount } from './user'
|
83
app/types/api/post.ts
Normal file
83
app/types/api/post.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
// File metadata interface
|
||||
import type { SnPublisher } from './publisher'
|
||||
|
||||
export interface SnFileMeta {
|
||||
blur?: string;
|
||||
exif?: Record<string, unknown>;
|
||||
xres?: number;
|
||||
yres?: number;
|
||||
bands?: number;
|
||||
ratio?: number;
|
||||
width?: number;
|
||||
coding?: number;
|
||||
format?: number | string;
|
||||
height?: number;
|
||||
xoffset?: number;
|
||||
yoffset?: number;
|
||||
filename?: string | null;
|
||||
orientation?: number;
|
||||
'vips-loader'?: string;
|
||||
interpretation?: number;
|
||||
'bits-per-sample'?: number;
|
||||
'resolution-unit'?: string;
|
||||
}
|
||||
|
||||
// Attachment interface
|
||||
export interface SnAttachment {
|
||||
id: string;
|
||||
name: string;
|
||||
file_meta: SnFileMeta;
|
||||
user_meta: Record<string, unknown> | null;
|
||||
sensitive_marks: string[];
|
||||
mime_type: string;
|
||||
hash: string;
|
||||
size: number;
|
||||
has_compression: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
||||
|
||||
// Post interface
|
||||
export interface SnPost {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
slug: string | null;
|
||||
edited_at: string | null;
|
||||
published_at: string;
|
||||
visibility: number;
|
||||
content: string;
|
||||
type: number;
|
||||
pin_mode: unknown | null;
|
||||
meta: unknown | null;
|
||||
sensitive_marks: string[];
|
||||
embed_view: unknown | null;
|
||||
views_unique: number;
|
||||
views_total: number;
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
awarded_score: number;
|
||||
reactions_count: Record<string, number>;
|
||||
replies_count: number;
|
||||
reactions_made: Record<string, unknown>;
|
||||
replied_gone: boolean;
|
||||
forwarded_gone: boolean;
|
||||
replied_post_id: string | null;
|
||||
replied_post: SnPost | null;
|
||||
forwarded_post_id: string | null;
|
||||
forwarded_post: SnPost | null;
|
||||
realm_id: string | null;
|
||||
realm: unknown | null;
|
||||
attachments: SnAttachment[];
|
||||
publisher_id: string;
|
||||
publisher: SnPublisher;
|
||||
awards: unknown | null;
|
||||
tags: string[];
|
||||
categories: string[];
|
||||
is_truncated: boolean;
|
||||
resource_identifier: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
30
app/types/api/publisher.ts
Normal file
30
app/types/api/publisher.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { SnAttachment } from './post'
|
||||
|
||||
// Verification interface
|
||||
export interface SnVerification {
|
||||
type: number;
|
||||
title: string;
|
||||
description: string;
|
||||
verified_by: string;
|
||||
}
|
||||
|
||||
// Publisher interface
|
||||
export interface SnPublisher {
|
||||
id: string;
|
||||
type: number;
|
||||
name: string;
|
||||
nick: string;
|
||||
bio: string;
|
||||
picture_id: string;
|
||||
background_id: string;
|
||||
picture: SnAttachment | null;
|
||||
background: SnAttachment | null;
|
||||
verification: SnVerification | null;
|
||||
account_id: string;
|
||||
realm_id: string | null;
|
||||
account: unknown | null;
|
||||
resource_identifier: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
92
app/types/api/user.ts
Normal file
92
app/types/api/user.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import type { SnAttachment } from './post'
|
||||
import type { SnVerification } from './publisher'
|
||||
|
||||
// Account link interface
|
||||
export interface SnAccountLink {
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
// Account badge interface
|
||||
export interface SnAccountBadge {
|
||||
id: string;
|
||||
type: string;
|
||||
label: string | null;
|
||||
caption: string | null;
|
||||
meta: Record<string, unknown>;
|
||||
activated_at: string;
|
||||
expired_at: string | null;
|
||||
account_id: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
||||
|
||||
// Account perk subscription interface
|
||||
export interface SnAccountPerkSubscription {
|
||||
id: string;
|
||||
identifier: string;
|
||||
begun_at: string;
|
||||
ended_at: string;
|
||||
is_active: boolean;
|
||||
is_available: boolean;
|
||||
is_free_trial: boolean;
|
||||
status: number;
|
||||
base_price: number;
|
||||
final_price: number;
|
||||
renewal_at: string;
|
||||
account_id: string;
|
||||
display_name: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
||||
|
||||
// Account profile interface
|
||||
export interface SnAccountProfile {
|
||||
id: string;
|
||||
first_name: string;
|
||||
middle_name: string;
|
||||
last_name: string;
|
||||
bio: string;
|
||||
gender: string;
|
||||
pronouns: string;
|
||||
time_zone: string;
|
||||
location: string;
|
||||
links: SnAccountLink[];
|
||||
birthday: string;
|
||||
last_seen_at: string;
|
||||
verification: SnVerification | null;
|
||||
active_badge: unknown | null;
|
||||
experience: number;
|
||||
level: number;
|
||||
social_credits: number;
|
||||
social_credits_level: number;
|
||||
leveling_progress: number;
|
||||
picture: SnAttachment | null;
|
||||
background: SnAttachment | null;
|
||||
account_id: string;
|
||||
resource_identifier: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
||||
|
||||
// Account interface
|
||||
export interface SnAccount {
|
||||
id: string;
|
||||
name: string;
|
||||
nick: string;
|
||||
language: string;
|
||||
region: string;
|
||||
activated_at: string;
|
||||
is_superuser: boolean;
|
||||
automated_id: string | null;
|
||||
profile: SnAccountProfile;
|
||||
contacts: unknown[];
|
||||
badges: SnAccountBadge[];
|
||||
perk_subscription: SnAccountPerkSubscription | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at: string | null;
|
||||
}
|
6
app/types/api/version.ts
Normal file
6
app/types/api/version.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Version interface
|
||||
export interface SnVersion {
|
||||
version: string;
|
||||
commit: string;
|
||||
updatedAt: string;
|
||||
}
|
Reference in New Issue
Block a user