mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Add Typescript types for some API objects (#26602)
This commit is contained in:
parent
2054ee7cd5
commit
57f592fed5
45
app/javascript/mastodon/api_types/accounts.ts
Normal file
45
app/javascript/mastodon/api_types/accounts.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import type { ApiCustomEmojiJSON } from './custom_emoji';
|
||||||
|
|
||||||
|
export interface ApiAccountFieldJSON {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
verified_at: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiAccountRoleJSON {
|
||||||
|
color: string;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// See app/serializers/rest/account_serializer.rb
|
||||||
|
export interface ApiAccountJSON {
|
||||||
|
acct: string;
|
||||||
|
avatar: string;
|
||||||
|
avatar_static: string;
|
||||||
|
bot: boolean;
|
||||||
|
created_at: string;
|
||||||
|
discoverable: boolean;
|
||||||
|
display_name: string;
|
||||||
|
emojis: ApiCustomEmojiJSON[];
|
||||||
|
fields: ApiAccountFieldJSON[];
|
||||||
|
followers_count: number;
|
||||||
|
following_count: number;
|
||||||
|
group: boolean;
|
||||||
|
header: string;
|
||||||
|
header_static: string;
|
||||||
|
id: string;
|
||||||
|
last_status_at: string;
|
||||||
|
locked: boolean;
|
||||||
|
noindex: boolean;
|
||||||
|
note: string;
|
||||||
|
roles: ApiAccountJSON[];
|
||||||
|
statuses_count: number;
|
||||||
|
uri: string;
|
||||||
|
url: string;
|
||||||
|
username: string;
|
||||||
|
moved?: ApiAccountJSON;
|
||||||
|
suspended?: boolean;
|
||||||
|
limited?: boolean;
|
||||||
|
memorial?: boolean;
|
||||||
|
}
|
8
app/javascript/mastodon/api_types/custom_emoji.ts
Normal file
8
app/javascript/mastodon/api_types/custom_emoji.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// See app/serializers/rest/account_serializer.rb
|
||||||
|
export interface ApiCustomEmojiJSON {
|
||||||
|
shortcode: string;
|
||||||
|
static_url: string;
|
||||||
|
url: string;
|
||||||
|
category?: string;
|
||||||
|
visible_in_picker: boolean;
|
||||||
|
}
|
18
app/javascript/mastodon/api_types/relationships.ts
Normal file
18
app/javascript/mastodon/api_types/relationships.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// See app/serializers/rest/relationship_serializer.rb
|
||||||
|
export interface ApiRelationshipJSON {
|
||||||
|
blocked_by: boolean;
|
||||||
|
blocking: boolean;
|
||||||
|
domain_blocking: boolean;
|
||||||
|
endorsed: boolean;
|
||||||
|
followed_by: boolean;
|
||||||
|
following: boolean;
|
||||||
|
id: string;
|
||||||
|
languages: string[] | null;
|
||||||
|
muting_notifications: boolean;
|
||||||
|
muting: boolean;
|
||||||
|
note: string;
|
||||||
|
notifying: boolean;
|
||||||
|
requested_by: boolean;
|
||||||
|
requested: boolean;
|
||||||
|
showing_reblogs: boolean;
|
||||||
|
}
|
@ -4,6 +4,8 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
|||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
include FormattingHelper
|
include FormattingHelper
|
||||||
|
|
||||||
|
# Please update `app/javascript/mastodon/api_types/accounts.ts` when making changes to the attributes
|
||||||
|
|
||||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at,
|
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at,
|
||||||
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static,
|
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static,
|
||||||
:followers_count, :following_count, :statuses_count, :last_status_at
|
:followers_count, :following_count, :statuses_count, :last_status_at
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
|
# Please update `app/javascript/mastodon/api_types/custom_emoji.ts` when making changes to the attributes
|
||||||
|
|
||||||
attributes :shortcode, :url, :static_url, :visible_in_picker
|
attributes :shortcode, :url, :static_url, :visible_in_picker
|
||||||
|
|
||||||
attribute :category, if: :category_loaded?
|
attribute :category, if: :category_loaded?
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class REST::RelationshipSerializer < ActiveModel::Serializer
|
class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||||
|
# Please update `app/javascript/mastodon/api_types/relationships.ts` when making changes to the attributes
|
||||||
|
|
||||||
attributes :id, :following, :showing_reblogs, :notifying, :languages, :followed_by,
|
attributes :id, :following, :showing_reblogs, :notifying, :languages, :followed_by,
|
||||||
:blocking, :blocked_by, :muting, :muting_notifications,
|
:blocking, :blocked_by, :muting, :muting_notifications,
|
||||||
:requested, :requested_by, :domain_blocking, :endorsed, :note
|
:requested, :requested_by, :domain_blocking, :endorsed, :note
|
||||||
|
Loading…
Reference in New Issue
Block a user