From aa9dca97980bd72930dc908b9ee6580d2224a2d2 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 7 Oct 2023 18:17:49 +0900 Subject: [PATCH 1/6] Change namespace definition --- megalodon/src/entities/account.ts | 67 +++++----- megalodon/src/entities/activity.ts | 12 +- megalodon/src/entities/announcement.ts | 69 +++++------ megalodon/src/entities/application.ts | 10 +- megalodon/src/entities/async_attachment.ts | 25 ++-- megalodon/src/entities/attachment.ts | 84 ++++++------- megalodon/src/entities/card.ts | 32 +++-- megalodon/src/entities/context.ts | 10 +- megalodon/src/entities/conversation.ts | 16 ++- megalodon/src/entities/emoji.ts | 14 +-- megalodon/src/entities/featured_tag.ts | 12 +- megalodon/src/entities/field.ts | 12 +- megalodon/src/entities/filter.ts | 20 ++- megalodon/src/entities/follow_request.ts | 48 ++++--- megalodon/src/entities/history.ts | 10 +- megalodon/src/entities/identity_proof.ts | 14 +-- megalodon/src/entities/instance.ts | 68 +++++----- megalodon/src/entities/list.ts | 14 +-- megalodon/src/entities/marker.ts | 24 ++-- megalodon/src/entities/mention.ts | 12 +- megalodon/src/entities/notification.ts | 29 +++-- megalodon/src/entities/poll.ts | 23 ++-- megalodon/src/entities/poll_option.ts | 6 - megalodon/src/entities/preferences.ts | 14 +-- megalodon/src/entities/push_subscription.ts | 26 ++-- megalodon/src/entities/reaction.ts | 18 ++- megalodon/src/entities/relationship.ts | 30 +++-- megalodon/src/entities/report.ts | 30 +++-- megalodon/src/entities/results.ts | 16 ++- megalodon/src/entities/role.ts | 6 +- megalodon/src/entities/scheduled_status.ts | 17 ++- megalodon/src/entities/source.ts | 17 ++- megalodon/src/entities/stats.ts | 10 +- megalodon/src/entities/status.ts | 90 +++++++------- megalodon/src/entities/status_params.ts | 20 ++- megalodon/src/entities/status_source.ts | 10 +- megalodon/src/entities/tag.ts | 14 +-- megalodon/src/entities/token.ts | 12 +- megalodon/src/entities/urls.ts | 6 +- megalodon/src/entity.ts | 131 ++++++++++++++------ megalodon/src/firefish.ts | 1 + megalodon/test/integration/mastodon.spec.ts | 1 + megalodon/test/integration/pleroma.spec.ts | 1 + 43 files changed, 543 insertions(+), 558 deletions(-) delete mode 100644 megalodon/src/entities/poll_option.ts diff --git a/megalodon/src/entities/account.ts b/megalodon/src/entities/account.ts index 89c0f17c4..0d8f34c59 100644 --- a/megalodon/src/entities/account.ts +++ b/megalodon/src/entities/account.ts @@ -1,35 +1,34 @@ -/// -/// -/// -/// -namespace Entity { - export type Account = { - id: string - username: string - acct: string - display_name: string - locked: boolean - discoverable?: boolean - group: boolean | null - noindex: boolean | null - suspended: boolean | null - limited: boolean | null - created_at: string - followers_count: number - following_count: number - statuses_count: number - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - emojis: Array - moved: Account | null - fields: Array - bot: boolean | null - source?: Source - role?: Role - mute_expires_at?: string - } +import { Emoji } from './emoji' +import { Field } from './field' +import { Source } from './source' +import { Role } from './role' + +export type Account = { + id: string + username: string + acct: string + display_name: string + locked: boolean + discoverable?: boolean + group: boolean | null + noindex: boolean | null + suspended: boolean | null + limited: boolean | null + created_at: string + followers_count: number + following_count: number + statuses_count: number + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + emojis: Array + moved: Account | null + fields: Array + bot: boolean | null + source?: Source + role?: Role + mute_expires_at?: string } diff --git a/megalodon/src/entities/activity.ts b/megalodon/src/entities/activity.ts index 2494916a9..a174a5eb9 100644 --- a/megalodon/src/entities/activity.ts +++ b/megalodon/src/entities/activity.ts @@ -1,8 +1,6 @@ -namespace Entity { - export type Activity = { - week: string - statuses: string - logins: string - registrations: string - } +export type Activity = { + week: string + statuses: string + logins: string + registrations: string } diff --git a/megalodon/src/entities/announcement.ts b/megalodon/src/entities/announcement.ts index 0db9c23bb..3417a9a6b 100644 --- a/megalodon/src/entities/announcement.ts +++ b/megalodon/src/entities/announcement.ts @@ -1,40 +1,39 @@ -/// +import { Emoji } from './emoji' +import { StatusTag } from './status' -namespace Entity { - export type Announcement = { - id: string - content: string - starts_at: string | null - ends_at: string | null - published: boolean - all_day: boolean - published_at: string - updated_at: string | null - read: boolean | null - mentions: Array - statuses: Array - tags: Array - emojis: Array - reactions: Array - } +export type Announcement = { + id: string + content: string + starts_at: string | null + ends_at: string | null + published: boolean + all_day: boolean + published_at: string + updated_at: string | null + read: boolean | null + mentions: Array + statuses: Array + tags: Array + emojis: Array + reactions: Array +} - export type AnnouncementAccount = { - id: string - username: string - url: string - acct: string - } +export type AnnouncementAccount = { + id: string + username: string + url: string + acct: string +} - export type AnnouncementStatus = { - id: string - url: string - } +export type AnnouncementStatus = { + id: string + url: string +} - export type AnnouncementReaction = { - name: string - count: number - me: boolean | null - url: string | null - static_url: string | null - } +export type AnnouncementReaction = { + name: string + count: number + me: boolean | null + url: string | null + static_url: string | null } diff --git a/megalodon/src/entities/application.ts b/megalodon/src/entities/application.ts index 3af64fcf9..884caff81 100644 --- a/megalodon/src/entities/application.ts +++ b/megalodon/src/entities/application.ts @@ -1,7 +1,5 @@ -namespace Entity { - export type Application = { - name: string - website?: string | null - vapid_key?: string | null - } +export type Application = { + name: string + website?: string | null + vapid_key?: string | null } diff --git a/megalodon/src/entities/async_attachment.ts b/megalodon/src/entities/async_attachment.ts index b383f90c5..de3b1f8f6 100644 --- a/megalodon/src/entities/async_attachment.ts +++ b/megalodon/src/entities/async_attachment.ts @@ -1,14 +1,13 @@ -/// -namespace Entity { - export type AsyncAttachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string | null - remote_url: string | null - preview_url: string - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +import { Meta } from './attachment' + +export type AsyncAttachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string | null + remote_url: string | null + preview_url: string + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/entities/attachment.ts b/megalodon/src/entities/attachment.ts index aab1deade..38d367642 100644 --- a/megalodon/src/entities/attachment.ts +++ b/megalodon/src/entities/attachment.ts @@ -1,49 +1,47 @@ -namespace Entity { - export type Sub = { - // For Image, Gifv, and Video - width?: number - height?: number - size?: string - aspect?: number +export type Sub = { + // For Image, Gifv, and Video + width?: number + height?: number + size?: string + aspect?: number - // For Gifv and Video - frame_rate?: string + // For Gifv and Video + frame_rate?: string - // For Audio, Gifv, and Video - duration?: number - bitrate?: number - } + // For Audio, Gifv, and Video + duration?: number + bitrate?: number +} - export type Focus = { - x: number - y: number - } +export type Focus = { + x: number + y: number +} - export type Meta = { - original?: Sub - small?: Sub - focus?: Focus - length?: string - duration?: number - fps?: number - size?: string - width?: number - height?: number - aspect?: number - audio_encode?: string - audio_bitrate?: string - audio_channel?: string - } +export type Meta = { + original?: Sub + small?: Sub + focus?: Focus + length?: string + duration?: number + fps?: number + size?: string + width?: number + height?: number + aspect?: number + audio_encode?: string + audio_bitrate?: string + audio_channel?: string +} - export type Attachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string - remote_url: string | null - preview_url: string | null - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +export type Attachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string + remote_url: string | null + preview_url: string | null + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/entities/card.ts b/megalodon/src/entities/card.ts index 1ef6f5e4d..e4199d72e 100644 --- a/megalodon/src/entities/card.ts +++ b/megalodon/src/entities/card.ts @@ -1,18 +1,16 @@ -namespace Entity { - export type Card = { - url: string - title: string - description: string - type: 'link' | 'photo' | 'video' | 'rich' - image: string | null - author_name: string | null - author_url: string | null - provider_name: string | null - provider_url: string | null - html: string | null - width: number | null - height: number | null - embed_url: string | null - blurhash: string | null - } +export type Card = { + url: string + title: string + description: string + type: 'link' | 'photo' | 'video' | 'rich' + image: string | null + author_name: string | null + author_url: string | null + provider_name: string | null + provider_url: string | null + html: string | null + width: number | null + height: number | null + embed_url: string | null + blurhash: string | null } diff --git a/megalodon/src/entities/context.ts b/megalodon/src/entities/context.ts index 3f2eda58f..14da5dd8d 100644 --- a/megalodon/src/entities/context.ts +++ b/megalodon/src/entities/context.ts @@ -1,8 +1,6 @@ -/// +import { Status } from './status' -namespace Entity { - export type Context = { - ancestors: Array - descendants: Array - } +export type Context = { + ancestors: Array + descendants: Array } diff --git a/megalodon/src/entities/conversation.ts b/megalodon/src/entities/conversation.ts index cdadf1e0f..83b900bec 100644 --- a/megalodon/src/entities/conversation.ts +++ b/megalodon/src/entities/conversation.ts @@ -1,11 +1,9 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace Entity { - export type Conversation = { - id: string - accounts: Array - last_status: Status | null - unread: boolean - } +export type Conversation = { + id: string + accounts: Array + last_status: Status | null + unread: boolean } diff --git a/megalodon/src/entities/emoji.ts b/megalodon/src/entities/emoji.ts index 546ef818f..3ab743eb6 100644 --- a/megalodon/src/entities/emoji.ts +++ b/megalodon/src/entities/emoji.ts @@ -1,9 +1,7 @@ -namespace Entity { - export type Emoji = { - shortcode: string - static_url: string - url: string - visible_in_picker: boolean - category?: string - } +export type Emoji = { + shortcode: string + static_url: string + url: string + visible_in_picker: boolean + category?: string } diff --git a/megalodon/src/entities/featured_tag.ts b/megalodon/src/entities/featured_tag.ts index 06ae6d7a9..15ddd85b8 100644 --- a/megalodon/src/entities/featured_tag.ts +++ b/megalodon/src/entities/featured_tag.ts @@ -1,8 +1,6 @@ -namespace Entity { - export type FeaturedTag = { - id: string - name: string - statuses_count: number - last_status_at: string - } +export type FeaturedTag = { + id: string + name: string + statuses_count: number + last_status_at: string } diff --git a/megalodon/src/entities/field.ts b/megalodon/src/entities/field.ts index 015744962..c465f3987 100644 --- a/megalodon/src/entities/field.ts +++ b/megalodon/src/entities/field.ts @@ -1,8 +1,6 @@ -namespace Entity { - export type Field = { - name: string - value: string - verified_at?: string | null - verified?: boolean | false - } +export type Field = { + name: string + value: string + verified_at?: string | null + verified?: boolean | false } diff --git a/megalodon/src/entities/filter.ts b/megalodon/src/entities/filter.ts index ffbacb728..cf1fa800e 100644 --- a/megalodon/src/entities/filter.ts +++ b/megalodon/src/entities/filter.ts @@ -1,12 +1,10 @@ -namespace Entity { - export type Filter = { - id: string - phrase: string - context: Array - expires_at: string | null - irreversible: boolean - whole_word: boolean - } - - export type FilterContext = string +export type Filter = { + id: string + phrase: string + context: Array + expires_at: string | null + irreversible: boolean + whole_word: boolean } + +export type FilterContext = string diff --git a/megalodon/src/entities/follow_request.ts b/megalodon/src/entities/follow_request.ts index 84ea4d02c..586c16be3 100644 --- a/megalodon/src/entities/follow_request.ts +++ b/megalodon/src/entities/follow_request.ts @@ -1,27 +1,25 @@ -/// -/// +import { Emoji } from './emoji' +import { Field } from './field' -namespace Entity { - export type FollowRequest = { - id: number - username: string - acct: string - display_name: string - locked: boolean - bot: boolean - discoverable?: boolean - group: boolean - created_at: string - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - followers_count: number - following_count: number - statuses_count: number - emojis: Array - fields: Array - } +export type FollowRequest = { + id: number + username: string + acct: string + display_name: string + locked: boolean + bot: boolean + discoverable?: boolean + group: boolean + created_at: string + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + followers_count: number + following_count: number + statuses_count: number + emojis: Array + fields: Array } diff --git a/megalodon/src/entities/history.ts b/megalodon/src/entities/history.ts index 070969426..6d38a71f9 100644 --- a/megalodon/src/entities/history.ts +++ b/megalodon/src/entities/history.ts @@ -1,7 +1,5 @@ -namespace Entity { - export type History = { - day: string - uses: number - accounts: number - } +export type History = { + day: string + uses: number + accounts: number } diff --git a/megalodon/src/entities/identity_proof.ts b/megalodon/src/entities/identity_proof.ts index ff857addb..882cd5bfb 100644 --- a/megalodon/src/entities/identity_proof.ts +++ b/megalodon/src/entities/identity_proof.ts @@ -1,9 +1,7 @@ -namespace Entity { - export type IdentityProof = { - provider: string - provider_username: string - updated_at: string - proof_url: string - profile_url: string - } +export type IdentityProof = { + provider: string + provider_username: string + updated_at: string + proof_url: string + profile_url: string } diff --git a/megalodon/src/entities/instance.ts b/megalodon/src/entities/instance.ts index 8f4808be8..0614cb39c 100644 --- a/megalodon/src/entities/instance.ts +++ b/megalodon/src/entities/instance.ts @@ -1,40 +1,38 @@ -/// -/// -/// +import { Account } from './account' +import { URLs } from './urls' +import { Stats } from './stats' -namespace Entity { - export type Instance = { - uri: string - title: string - description: string - email: string - version: string - thumbnail: string | null - urls: URLs | null - stats: Stats - languages: Array - registrations: boolean - approval_required: boolean - invites_enabled?: boolean - configuration: { - statuses: { - max_characters: number - max_media_attachments?: number - characters_reserved_per_url?: number - } - polls?: { - max_options: number - max_characters_per_option: number - min_expiration: number - max_expiration: number - } +export type Instance = { + uri: string + title: string + description: string + email: string + version: string + thumbnail: string | null + urls: URLs | null + stats: Stats + languages: Array + registrations: boolean + approval_required: boolean + invites_enabled?: boolean + configuration: { + statuses: { + max_characters: number + max_media_attachments?: number + characters_reserved_per_url?: number + } + polls?: { + max_options: number + max_characters_per_option: number + min_expiration: number + max_expiration: number } - contact_account?: Account - rules?: Array } + contact_account?: Account + rules?: Array +} - export type InstanceRule = { - id: string - text: string - } +export type InstanceRule = { + id: string + text: string } diff --git a/megalodon/src/entities/list.ts b/megalodon/src/entities/list.ts index 58c264aba..aa88a6e02 100644 --- a/megalodon/src/entities/list.ts +++ b/megalodon/src/entities/list.ts @@ -1,9 +1,7 @@ -namespace Entity { - export type List = { - id: string - title: string - replies_policy: RepliesPolicy | null - } - - export type RepliesPolicy = 'followed' | 'list' | 'none' +export type List = { + id: string + title: string + replies_policy: RepliesPolicy | null } + +export type RepliesPolicy = 'followed' | 'list' | 'none' diff --git a/megalodon/src/entities/marker.ts b/megalodon/src/entities/marker.ts index 33cb98a10..cd62b31e0 100644 --- a/megalodon/src/entities/marker.ts +++ b/megalodon/src/entities/marker.ts @@ -1,15 +1,13 @@ -namespace Entity { - export type Marker = { - home?: { - last_read_id: string - version: number - updated_at: string - } - notifications?: { - last_read_id: string - version: number - updated_at: string - unread_count?: number - } +export type Marker = { + home?: { + last_read_id: string + version: number + updated_at: string + } + notifications?: { + last_read_id: string + version: number + updated_at: string + unread_count?: number } } diff --git a/megalodon/src/entities/mention.ts b/megalodon/src/entities/mention.ts index 046912971..098633673 100644 --- a/megalodon/src/entities/mention.ts +++ b/megalodon/src/entities/mention.ts @@ -1,8 +1,6 @@ -namespace Entity { - export type Mention = { - id: string - username: string - url: string - acct: string - } +export type Mention = { + id: string + username: string + url: string + acct: string } diff --git a/megalodon/src/entities/notification.ts b/megalodon/src/entities/notification.ts index 23d13dab2..fb967889d 100644 --- a/megalodon/src/entities/notification.ts +++ b/megalodon/src/entities/notification.ts @@ -1,17 +1,16 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' +import { Reaction } from './reaction' -namespace Entity { - export type Notification = { - account: Account | null - created_at: string - id: string - status?: Status - emoji?: string - reaction?: Reaction - type: NotificationType - target?: Account - } - - export type NotificationType = string +export type Notification = { + account: Account | null + created_at: string + id: string + status?: Status + emoji?: string + reaction?: Reaction + type: NotificationType + target?: Account } + +export type NotificationType = string diff --git a/megalodon/src/entities/poll.ts b/megalodon/src/entities/poll.ts index 69706e8ae..d8861108e 100644 --- a/megalodon/src/entities/poll.ts +++ b/megalodon/src/entities/poll.ts @@ -1,13 +1,14 @@ -/// +export type Poll = { + id: string + expires_at: string | null + expired: boolean + multiple: boolean + votes_count: number + options: Array + voted: boolean +} -namespace Entity { - export type Poll = { - id: string - expires_at: string | null - expired: boolean - multiple: boolean - votes_count: number - options: Array - voted: boolean - } +export type PollOption = { + title: string + votes_count: number | null } diff --git a/megalodon/src/entities/poll_option.ts b/megalodon/src/entities/poll_option.ts deleted file mode 100644 index ae4c63849..000000000 --- a/megalodon/src/entities/poll_option.ts +++ /dev/null @@ -1,6 +0,0 @@ -namespace Entity { - export type PollOption = { - title: string - votes_count: number | null - } -} diff --git a/megalodon/src/entities/preferences.ts b/megalodon/src/entities/preferences.ts index cb5797c4c..e0646f6de 100644 --- a/megalodon/src/entities/preferences.ts +++ b/megalodon/src/entities/preferences.ts @@ -1,9 +1,7 @@ -namespace Entity { - export type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' - 'posting:default:sensitive': boolean - 'posting:default:language': string | null - 'reading:expand:media': 'default' | 'show_all' | 'hide_all' - 'reading:expand:spoilers': boolean - } +export type Preferences = { + 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' + 'posting:default:sensitive': boolean + 'posting:default:language': string | null + 'reading:expand:media': 'default' | 'show_all' | 'hide_all' + 'reading:expand:spoilers': boolean } diff --git a/megalodon/src/entities/push_subscription.ts b/megalodon/src/entities/push_subscription.ts index fe7464e8e..ae440143b 100644 --- a/megalodon/src/entities/push_subscription.ts +++ b/megalodon/src/entities/push_subscription.ts @@ -1,16 +1,14 @@ -namespace Entity { - export type Alerts = { - follow: boolean - favourite: boolean - mention: boolean - reblog: boolean - poll: boolean - } +export type Alerts = { + follow: boolean + favourite: boolean + mention: boolean + reblog: boolean + poll: boolean +} - export type PushSubscription = { - id: string - endpoint: string - server_key: string - alerts: Alerts - } +export type PushSubscription = { + id: string + endpoint: string + server_key: string + alerts: Alerts } diff --git a/megalodon/src/entities/reaction.ts b/megalodon/src/entities/reaction.ts index 6a011c09b..2a6e72532 100644 --- a/megalodon/src/entities/reaction.ts +++ b/megalodon/src/entities/reaction.ts @@ -1,12 +1,10 @@ -/// +import { Account } from './account' -namespace Entity { - export type Reaction = { - count: number - me: boolean - name: string - url?: string - static_url?: string - accounts?: Array - } +export type Reaction = { + count: number + me: boolean + name: string + url?: string + static_url?: string + accounts?: Array } diff --git a/megalodon/src/entities/relationship.ts b/megalodon/src/entities/relationship.ts index 283a1158c..36dcf0c1a 100644 --- a/megalodon/src/entities/relationship.ts +++ b/megalodon/src/entities/relationship.ts @@ -1,17 +1,15 @@ -namespace Entity { - export type Relationship = { - id: string - following: boolean - followed_by: boolean - blocking: boolean - blocked_by: boolean - muting: boolean - muting_notifications: boolean - requested: boolean - domain_blocking: boolean - showing_reblogs: boolean - endorsed: boolean - notifying: boolean - note: string | null - } +export type Relationship = { + id: string + following: boolean + followed_by: boolean + blocking: boolean + blocked_by: boolean + muting: boolean + muting_notifications: boolean + requested: boolean + domain_blocking: boolean + showing_reblogs: boolean + endorsed: boolean + notifying: boolean + note: string | null } diff --git a/megalodon/src/entities/report.ts b/megalodon/src/entities/report.ts index 353886a34..2be78233a 100644 --- a/megalodon/src/entities/report.ts +++ b/megalodon/src/entities/report.ts @@ -1,18 +1,16 @@ -/// +import { Account } from './account' -namespace Entity { - export type Report = { - id: string - action_taken: boolean - action_taken_at: string | null - status_ids: Array | null - rule_ids: Array | null - // These parameters don't exist in Pleroma - category: Category | null - comment: string | null - forwarded: boolean | null - target_account?: Account | null - } - - export type Category = 'spam' | 'violation' | 'other' +export type Report = { + id: string + action_taken: boolean + action_taken_at: string | null + status_ids: Array | null + rule_ids: Array | null + // These parameters don't exist in Pleroma + category: Category | null + comment: string | null + forwarded: boolean | null + target_account?: Account | null } + +export type Category = 'spam' | 'violation' | 'other' diff --git a/megalodon/src/entities/results.ts b/megalodon/src/entities/results.ts index fe168de67..17ee9190b 100644 --- a/megalodon/src/entities/results.ts +++ b/megalodon/src/entities/results.ts @@ -1,11 +1,9 @@ -/// -/// -/// +import { Account } from './account' +import { Status } from './status' +import { Tag } from './tag' -namespace Entity { - export type Results = { - accounts: Array - statuses: Array - hashtags: Array - } +export type Results = { + accounts: Array + statuses: Array + hashtags: Array } diff --git a/megalodon/src/entities/role.ts b/megalodon/src/entities/role.ts index caaae9ea1..2b5be2df5 100644 --- a/megalodon/src/entities/role.ts +++ b/megalodon/src/entities/role.ts @@ -1,5 +1,3 @@ -namespace Entity { - export type Role = { - name: string - } +export type Role = { + name: string } diff --git a/megalodon/src/entities/scheduled_status.ts b/megalodon/src/entities/scheduled_status.ts index 561a5b9f2..e37975db8 100644 --- a/megalodon/src/entities/scheduled_status.ts +++ b/megalodon/src/entities/scheduled_status.ts @@ -1,10 +1,9 @@ -/// -/// -namespace Entity { - export type ScheduledStatus = { - id: string - scheduled_at: string - params: StatusParams - media_attachments: Array | null - } +import { StatusParams } from './status_params' +import { Attachment } from './attachment' + +export type ScheduledStatus = { + id: string + scheduled_at: string + params: StatusParams + media_attachments: Array | null } diff --git a/megalodon/src/entities/source.ts b/megalodon/src/entities/source.ts index d87cf55d8..a82203909 100644 --- a/megalodon/src/entities/source.ts +++ b/megalodon/src/entities/source.ts @@ -1,10 +1,9 @@ -/// -namespace Entity { - export type Source = { - privacy: string | null - sensitive: boolean | null - language: string | null - note: string - fields: Array - } +import { Field } from './field' + +export type Source = { + privacy: string | null + sensitive: boolean | null + language: string | null + note: string + fields: Array } diff --git a/megalodon/src/entities/stats.ts b/megalodon/src/entities/stats.ts index 76f0bad34..b8a8db853 100644 --- a/megalodon/src/entities/stats.ts +++ b/megalodon/src/entities/stats.ts @@ -1,7 +1,5 @@ -namespace Entity { - export type Stats = { - user_count: number - status_count: number - domain_count: number - } +export type Stats = { + user_count: number + status_count: number + domain_count: number } diff --git a/megalodon/src/entities/status.ts b/megalodon/src/entities/status.ts index 295703e57..21797358d 100644 --- a/megalodon/src/entities/status.ts +++ b/megalodon/src/entities/status.ts @@ -1,49 +1,47 @@ -/// -/// -/// -/// -/// -/// -/// -/// +import { Account } from './account' +import { Application } from './application' +import { Emoji } from './emoji' +import { Attachment } from './attachment' +import { Mention } from './mention' +import { Reaction } from './reaction' +import { Card } from './card' +import { Poll } from './poll' -namespace Entity { - export type Status = { - id: string - uri: string - url: string - account: Account - in_reply_to_id: string | null - in_reply_to_account_id: string | null - reblog: Status | null - content: string - plain_content: string | null - created_at: string - emojis: Emoji[] - replies_count: number - reblogs_count: number - favourites_count: number - reblogged: boolean | null - favourited: boolean | null - muted: boolean | null - sensitive: boolean - spoiler_text: string - visibility: 'public' | 'unlisted' | 'private' | 'direct' - media_attachments: Array - mentions: Array - tags: Array - card: Card | null - poll: Poll | null - application: Application | null - language: string | null - pinned: boolean | null - emoji_reactions: Array - quote: boolean - bookmarked: boolean - } +export type Status = { + id: string + uri: string + url: string + account: Account + in_reply_to_id: string | null + in_reply_to_account_id: string | null + reblog: Status | null + content: string + plain_content: string | null + created_at: string + emojis: Emoji[] + replies_count: number + reblogs_count: number + favourites_count: number + reblogged: boolean | null + favourited: boolean | null + muted: boolean | null + sensitive: boolean + spoiler_text: string + visibility: 'public' | 'unlisted' | 'private' | 'direct' + media_attachments: Array + mentions: Array + tags: Array + card: Card | null + poll: Poll | null + application: Application | null + language: string | null + pinned: boolean | null + emoji_reactions: Array + quote: boolean + bookmarked: boolean +} - export type StatusTag = { - name: string - url: string - } +export type StatusTag = { + name: string + url: string } diff --git a/megalodon/src/entities/status_params.ts b/megalodon/src/entities/status_params.ts index 82d789086..6a758ad8c 100644 --- a/megalodon/src/entities/status_params.ts +++ b/megalodon/src/entities/status_params.ts @@ -1,12 +1,10 @@ -namespace Entity { - export type StatusParams = { - text: string - in_reply_to_id: string | null - media_ids: Array | null - sensitive: boolean | null - spoiler_text: string | null - visibility: 'public' | 'unlisted' | 'private' | 'direct' | null - scheduled_at: string | null - application_id: number | null - } +export type StatusParams = { + text: string + in_reply_to_id: string | null + media_ids: Array | null + sensitive: boolean | null + spoiler_text: string | null + visibility: 'public' | 'unlisted' | 'private' | 'direct' | null + scheduled_at: string | null + application_id: number | null } diff --git a/megalodon/src/entities/status_source.ts b/megalodon/src/entities/status_source.ts index 0de7030ed..82103f9a1 100644 --- a/megalodon/src/entities/status_source.ts +++ b/megalodon/src/entities/status_source.ts @@ -1,7 +1,5 @@ -namespace Entity { - export type StatusSource = { - id: string - text: string - spoiler_text: string - } +export type StatusSource = { + id: string + text: string + spoiler_text: string } diff --git a/megalodon/src/entities/tag.ts b/megalodon/src/entities/tag.ts index ddc5fe92b..2fae1efbe 100644 --- a/megalodon/src/entities/tag.ts +++ b/megalodon/src/entities/tag.ts @@ -1,10 +1,8 @@ -/// +import { History } from './history' -namespace Entity { - export type Tag = { - name: string - url: string - history: Array - following?: boolean - } +export type Tag = { + name: string + url: string + history: Array + following?: boolean } diff --git a/megalodon/src/entities/token.ts b/megalodon/src/entities/token.ts index 6fa28e39b..9cf3c1508 100644 --- a/megalodon/src/entities/token.ts +++ b/megalodon/src/entities/token.ts @@ -1,8 +1,6 @@ -namespace Entity { - export type Token = { - access_token: string - token_type: string - scope: string - created_at: number - } +export type Token = { + access_token: string + token_type: string + scope: string + created_at: number } diff --git a/megalodon/src/entities/urls.ts b/megalodon/src/entities/urls.ts index 4a980d589..5c1087420 100644 --- a/megalodon/src/entities/urls.ts +++ b/megalodon/src/entities/urls.ts @@ -1,5 +1,3 @@ -namespace Entity { - export type URLs = { - streaming_api: string - } +export type URLs = { + streaming_api: string } diff --git a/megalodon/src/entity.ts b/megalodon/src/entity.ts index 387981cec..024c4f3c4 100644 --- a/megalodon/src/entity.ts +++ b/megalodon/src/entity.ts @@ -1,40 +1,95 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +import * as account from './entities/account' +import * as activity from './entities/activity' +import * as announcement from './entities/announcement' +import * as application from './entities/application' +import * as async_attachment from './entities/async_attachment' +import * as attachment from './entities/attachment' +import * as card from './entities/card' +import * as context from './entities/context' +import * as conversation from './entities/conversation' +import * as emoji from './entities/emoji' +import * as featured_tag from './entities/featured_tag' +import * as field from './entities/field' +import * as filter from './entities/filter' +import * as follow_request from './entities/follow_request' +import * as history from './entities/history' +import * as identity_proof from './entities/identity_proof' +import * as instance from './entities/instance' +import * as list from './entities/list' +import * as marker from './entities/marker' +import * as mention from './entities/mention' +import * as notification from './entities/notification' +import * as poll from './entities/poll' +import * as preferences from './entities/preferences' +import * as push_subscription from './entities/push_subscription' +import * as reaction from './entities/reaction' +import * as relationship from './entities/relationship' +import * as report from './entities/report' +import * as results from './entities/results' +import * as role from './entities/role' +import * as scheduled_status from './entities/scheduled_status' +import * as source from './entities/source' +import * as stats from './entities/stats' +import * as status from './entities/status' +import * as status_params from './entities/status_params' +import * as status_source from './entities/status_source' +import * as tag from './entities/tag' +import * as token from './entities/token' +import * as urls from './entities/urls' + +export namespace Entity { + export type Account = account.Account + export type Activity = activity.Activity + export type Announcement = announcement.Announcement + export type AnnouncementAccount = announcement.AnnouncementAccount + export type AnnouncementStatus = announcement.AnnouncementStatus + export type AnnouncementReaction = announcement.AnnouncementReaction + export type Application = application.Application + export type AsyncAttachment = async_attachment.AsyncAttachment + export type Attachment = attachment.Attachment + export type Sub = attachment.Sub + export type Focus = attachment.Focus + export type Meta = attachment.Meta + export type Card = card.Card + export type Context = context.Context + export type Conversation = conversation.Conversation + export type Emoji = emoji.Emoji + export type FeaturedTag = featured_tag.FeaturedTag + export type Field = field.Field + export type Filter = filter.Filter + export type FilterContext = filter.FilterContext + export type FollowRequest = follow_request.FollowRequest + export type History = history.History + export type IdentityProof = identity_proof.IdentityProof + export type Instance = instance.Instance + export type InstanceRule = instance.InstanceRule + export type List = list.List + export type RepliesPolicy = list.RepliesPolicy + export type Marker = marker.Marker + export type Mention = mention.Mention + export type Notification = notification.Notification + export type NotificationType = notification.NotificationType + export type Poll = poll.Poll + export type PollOption = poll.PollOption + export type Preferences = preferences.Preferences + export type Alerts = push_subscription.Alerts + export type PushSubscription = push_subscription.PushSubscription + export type Reaction = reaction.Reaction + export type Relationship = relationship.Relationship + export type Report = report.Report + export type Category = report.Category + export type Results = results.Results + export type Role = role.Role + export type ScheduledStatus = scheduled_status.ScheduledStatus + export type Source = source.Source + export type Stats = stats.Stats + export type Status = status.Status + export type StatusTag = status.StatusTag + export type StatusParams = status_params.StatusParams + export type StatusSource = status_source.StatusSource + export type Tag = tag.Tag + export type Token = token.Token + export type URLs = urls.URLs +} export default Entity diff --git a/megalodon/src/firefish.ts b/megalodon/src/firefish.ts index 58fec1bb0..1e54b4faf 100644 --- a/megalodon/src/firefish.ts +++ b/megalodon/src/firefish.ts @@ -7,6 +7,7 @@ import * as FirefishOAuth from './firefish/oauth' import Response from './response' import { MegalodonInterface, WebSocketInterface, NoImplementedError, ArgumentError, UnexpectedError } from './megalodon' import { UnknownNotificationTypeError } from './notification' +import Entity from './entity' export default class Firefish implements MegalodonInterface { public client: FirefishAPI.Interface diff --git a/megalodon/test/integration/mastodon.spec.ts b/megalodon/test/integration/mastodon.spec.ts index 172d11a86..e5e465754 100644 --- a/megalodon/test/integration/mastodon.spec.ts +++ b/megalodon/test/integration/mastodon.spec.ts @@ -2,6 +2,7 @@ import MastodonEntity from '@/mastodon/entity' import MastodonNotificationType from '@/mastodon/notification' import Mastodon from '@/mastodon' import MegalodonNotificationType from '@/notification' +import Entity from '@/entity' import axios, { AxiosResponse, InternalAxiosRequestConfig, AxiosHeaders } from 'axios' jest.mock('axios') diff --git a/megalodon/test/integration/pleroma.spec.ts b/megalodon/test/integration/pleroma.spec.ts index 1e1f449e1..a28801fb1 100644 --- a/megalodon/test/integration/pleroma.spec.ts +++ b/megalodon/test/integration/pleroma.spec.ts @@ -2,6 +2,7 @@ import PleromaEntity from '@/pleroma/entity' import Pleroma from '@/pleroma' import MegalodonNotificationType from '@/notification' import PleromaNotificationType from '@/pleroma/notification' +import Entity from '@/entity' import axios, { AxiosResponse, InternalAxiosRequestConfig, AxiosHeaders } from 'axios' jest.mock('axios') From a3b4b58cf129d03a445ad317679dc4c54c563408 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 7 Oct 2023 18:21:37 +0900 Subject: [PATCH 2/6] Fix example entity --- example/browser/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/browser/src/index.ts b/example/browser/src/index.ts index 6c461e7ba..4a6ec726f 100644 --- a/example/browser/src/index.ts +++ b/example/browser/src/index.ts @@ -1,4 +1,4 @@ -import generator from 'megalodon' +import generator, { Entity } from 'megalodon' const BASE_URL: string = process.env.MASTODON_URL! const ACCESS_TOKEN: string = process.env.MASTODON_ACCESS_TOKEN! From 4dde6c7ca70d24cf97466e376b2418ab499f9eb3 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 7 Oct 2023 20:54:25 +0900 Subject: [PATCH 3/6] Change namespace definition for mastodon entity --- megalodon/src/mastodon.ts | 2 +- megalodon/src/mastodon/entities/account.ts | 67 +++++----- megalodon/src/mastodon/entities/activity.ts | 12 +- .../src/mastodon/entities/announcement.ts | 69 +++++------ .../src/mastodon/entities/application.ts | 10 +- .../src/mastodon/entities/async_attachment.ts | 25 ++-- megalodon/src/mastodon/entities/attachment.ts | 84 ++++++------- megalodon/src/mastodon/entities/card.ts | 32 +++-- megalodon/src/mastodon/entities/context.ts | 10 +- .../src/mastodon/entities/conversation.ts | 16 ++- megalodon/src/mastodon/entities/emoji.ts | 14 +-- .../src/mastodon/entities/featured_tag.ts | 12 +- megalodon/src/mastodon/entities/field.ts | 10 +- megalodon/src/mastodon/entities/filter.ts | 20 ++- megalodon/src/mastodon/entities/history.ts | 10 +- .../src/mastodon/entities/identity_proof.ts | 14 +-- megalodon/src/mastodon/entities/instance.ts | 86 +++++++------ megalodon/src/mastodon/entities/list.ts | 14 +-- megalodon/src/mastodon/entities/marker.ts | 22 ++-- megalodon/src/mastodon/entities/mention.ts | 12 +- .../src/mastodon/entities/notification.ts | 22 ++-- megalodon/src/mastodon/entities/poll.ts | 23 ++-- .../src/mastodon/entities/poll_option.ts | 6 - .../src/mastodon/entities/preferences.ts | 14 +-- .../mastodon/entities/push_subscription.ts | 26 ++-- .../src/mastodon/entities/relationship.ts | 32 +++-- megalodon/src/mastodon/entities/report.ts | 28 ++--- megalodon/src/mastodon/entities/results.ts | 16 ++- megalodon/src/mastodon/entities/role.ts | 6 +- .../src/mastodon/entities/scheduled_status.ts | 17 ++- megalodon/src/mastodon/entities/source.ts | 17 ++- megalodon/src/mastodon/entities/stats.ts | 10 +- megalodon/src/mastodon/entities/status.ts | 89 +++++++------ .../src/mastodon/entities/status_params.ts | 20 ++- .../src/mastodon/entities/status_source.ts | 10 +- megalodon/src/mastodon/entities/tag.ts | 14 +-- megalodon/src/mastodon/entities/token.ts | 12 +- megalodon/src/mastodon/entities/urls.ts | 6 +- megalodon/src/mastodon/entity.ts | 117 ++++++++++++------ megalodon/src/pleroma.ts | 3 +- megalodon/test/integration/pleroma.spec.ts | 2 +- .../test/unit/pleroma/api_client.spec.ts | 4 +- 42 files changed, 503 insertions(+), 532 deletions(-) delete mode 100644 megalodon/src/mastodon/entities/poll_option.ts diff --git a/megalodon/src/mastodon.ts b/megalodon/src/mastodon.ts index 5a009770c..415a8e583 100644 --- a/megalodon/src/mastodon.ts +++ b/megalodon/src/mastodon.ts @@ -562,7 +562,7 @@ export default class Mastodon implements MegalodonInterface { if (get_all && converted.headers.link) { let parsed = parseLinkHeader(converted.headers.link) while (parsed?.next) { - const nextRes = await this.client.get>(parsed?.next.url, undefined, undefined, true) + const nextRes = await this.client.get>(parsed?.next.url, undefined, undefined, true) converted = Object.assign({}, converted, { data: [...converted.data, ...nextRes.data.map(a => MastodonAPI.Converter.account(a))] }) diff --git a/megalodon/src/mastodon/entities/account.ts b/megalodon/src/mastodon/entities/account.ts index 9055fdd91..0e0631b16 100644 --- a/megalodon/src/mastodon/entities/account.ts +++ b/megalodon/src/mastodon/entities/account.ts @@ -1,35 +1,34 @@ -/// -/// -/// -/// -namespace MastodonEntity { - export type Account = { - id: string - username: string - acct: string - display_name: string - locked: boolean - discoverable?: boolean - group: boolean | null - noindex: boolean | null - suspended: boolean | null - limited: boolean | null - created_at: string - followers_count: number - following_count: number - statuses_count: number - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - emojis: Array - moved: Account | null - fields: Array - bot: boolean - source?: Source - role?: Role - mute_expires_at?: string - } +import { Emoji } from './emoji' +import { Field } from './field' +import { Source } from './source' +import { Role } from './role' + +export type Account = { + id: string + username: string + acct: string + display_name: string + locked: boolean + discoverable?: boolean + group: boolean | null + noindex: boolean | null + suspended: boolean | null + limited: boolean | null + created_at: string + followers_count: number + following_count: number + statuses_count: number + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + emojis: Array + moved: Account | null + fields: Array + bot: boolean + source?: Source + role?: Role + mute_expires_at?: string } diff --git a/megalodon/src/mastodon/entities/activity.ts b/megalodon/src/mastodon/entities/activity.ts index 3e84c9df0..a174a5eb9 100644 --- a/megalodon/src/mastodon/entities/activity.ts +++ b/megalodon/src/mastodon/entities/activity.ts @@ -1,8 +1,6 @@ -namespace MastodonEntity { - export type Activity = { - week: string - statuses: string - logins: string - registrations: string - } +export type Activity = { + week: string + statuses: string + logins: string + registrations: string } diff --git a/megalodon/src/mastodon/entities/announcement.ts b/megalodon/src/mastodon/entities/announcement.ts index 426112e76..d7e9ef89c 100644 --- a/megalodon/src/mastodon/entities/announcement.ts +++ b/megalodon/src/mastodon/entities/announcement.ts @@ -1,40 +1,39 @@ -/// +import { StatusTag } from './status' +import { Emoji } from './emoji' -namespace MastodonEntity { - export type Announcement = { - id: string - content: string - starts_at: string | null - ends_at: string | null - published: boolean - all_day: boolean - published_at: string - updated_at: string - read: boolean | null - mentions: Array - statuses: Array - tags: Array - emojis: Array - reactions: Array - } +export type Announcement = { + id: string + content: string + starts_at: string | null + ends_at: string | null + published: boolean + all_day: boolean + published_at: string + updated_at: string + read: boolean | null + mentions: Array + statuses: Array + tags: Array + emojis: Array + reactions: Array +} - export type AnnouncementAccount = { - id: string - username: string - url: string - acct: string - } +export type AnnouncementAccount = { + id: string + username: string + url: string + acct: string +} - export type AnnouncementStatus = { - id: string - url: string - } +export type AnnouncementStatus = { + id: string + url: string +} - export type AnnouncementReaction = { - name: string - count: number - me: boolean | null - url: string | null - static_url: string | null - } +export type AnnouncementReaction = { + name: string + count: number + me: boolean | null + url: string | null + static_url: string | null } diff --git a/megalodon/src/mastodon/entities/application.ts b/megalodon/src/mastodon/entities/application.ts index a3f07997e..884caff81 100644 --- a/megalodon/src/mastodon/entities/application.ts +++ b/megalodon/src/mastodon/entities/application.ts @@ -1,7 +1,5 @@ -namespace MastodonEntity { - export type Application = { - name: string - website?: string | null - vapid_key?: string | null - } +export type Application = { + name: string + website?: string | null + vapid_key?: string | null } diff --git a/megalodon/src/mastodon/entities/async_attachment.ts b/megalodon/src/mastodon/entities/async_attachment.ts index 45f574d64..de3b1f8f6 100644 --- a/megalodon/src/mastodon/entities/async_attachment.ts +++ b/megalodon/src/mastodon/entities/async_attachment.ts @@ -1,14 +1,13 @@ -/// -namespace MastodonEntity { - export type AsyncAttachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string | null - remote_url: string | null - preview_url: string - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +import { Meta } from './attachment' + +export type AsyncAttachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string | null + remote_url: string | null + preview_url: string + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/mastodon/entities/attachment.ts b/megalodon/src/mastodon/entities/attachment.ts index ec51c5bca..38d367642 100644 --- a/megalodon/src/mastodon/entities/attachment.ts +++ b/megalodon/src/mastodon/entities/attachment.ts @@ -1,49 +1,47 @@ -namespace MastodonEntity { - export type Sub = { - // For Image, Gifv, and Video - width?: number - height?: number - size?: string - aspect?: number +export type Sub = { + // For Image, Gifv, and Video + width?: number + height?: number + size?: string + aspect?: number - // For Gifv and Video - frame_rate?: string + // For Gifv and Video + frame_rate?: string - // For Audio, Gifv, and Video - duration?: number - bitrate?: number - } + // For Audio, Gifv, and Video + duration?: number + bitrate?: number +} - export type Focus = { - x: number - y: number - } +export type Focus = { + x: number + y: number +} - export type Meta = { - original?: Sub - small?: Sub - focus?: Focus - length?: string - duration?: number - fps?: number - size?: string - width?: number - height?: number - aspect?: number - audio_encode?: string - audio_bitrate?: string - audio_channel?: string - } +export type Meta = { + original?: Sub + small?: Sub + focus?: Focus + length?: string + duration?: number + fps?: number + size?: string + width?: number + height?: number + aspect?: number + audio_encode?: string + audio_bitrate?: string + audio_channel?: string +} - export type Attachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string - remote_url: string | null - preview_url: string | null - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +export type Attachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string + remote_url: string | null + preview_url: string | null + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/mastodon/entities/card.ts b/megalodon/src/mastodon/entities/card.ts index 9058de7f7..28a9207a5 100644 --- a/megalodon/src/mastodon/entities/card.ts +++ b/megalodon/src/mastodon/entities/card.ts @@ -1,18 +1,16 @@ -namespace MastodonEntity { - export type Card = { - url: string - title: string - description: string - type: 'link' | 'photo' | 'video' | 'rich' - image: string | null - author_name: string - author_url: string - provider_name: string - provider_url: string - html: string - width: number - height: number - embed_url: string - blurhash: string | null - } +export type Card = { + url: string + title: string + description: string + type: 'link' | 'photo' | 'video' | 'rich' + image: string | null + author_name: string + author_url: string + provider_name: string + provider_url: string + html: string + width: number + height: number + embed_url: string + blurhash: string | null } diff --git a/megalodon/src/mastodon/entities/context.ts b/megalodon/src/mastodon/entities/context.ts index c2b6e2682..14da5dd8d 100644 --- a/megalodon/src/mastodon/entities/context.ts +++ b/megalodon/src/mastodon/entities/context.ts @@ -1,8 +1,6 @@ -/// +import { Status } from './status' -namespace MastodonEntity { - export type Context = { - ancestors: Array - descendants: Array - } +export type Context = { + ancestors: Array + descendants: Array } diff --git a/megalodon/src/mastodon/entities/conversation.ts b/megalodon/src/mastodon/entities/conversation.ts index 0ee3f1d7f..83b900bec 100644 --- a/megalodon/src/mastodon/entities/conversation.ts +++ b/megalodon/src/mastodon/entities/conversation.ts @@ -1,11 +1,9 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace MastodonEntity { - export type Conversation = { - id: string - accounts: Array - last_status: Status | null - unread: boolean - } +export type Conversation = { + id: string + accounts: Array + last_status: Status | null + unread: boolean } diff --git a/megalodon/src/mastodon/entities/emoji.ts b/megalodon/src/mastodon/entities/emoji.ts index 543491432..3ab743eb6 100644 --- a/megalodon/src/mastodon/entities/emoji.ts +++ b/megalodon/src/mastodon/entities/emoji.ts @@ -1,9 +1,7 @@ -namespace MastodonEntity { - export type Emoji = { - shortcode: string - static_url: string - url: string - visible_in_picker: boolean - category?: string - } +export type Emoji = { + shortcode: string + static_url: string + url: string + visible_in_picker: boolean + category?: string } diff --git a/megalodon/src/mastodon/entities/featured_tag.ts b/megalodon/src/mastodon/entities/featured_tag.ts index a2628b98c..15ddd85b8 100644 --- a/megalodon/src/mastodon/entities/featured_tag.ts +++ b/megalodon/src/mastodon/entities/featured_tag.ts @@ -1,8 +1,6 @@ -namespace MastodonEntity { - export type FeaturedTag = { - id: string - name: string - statuses_count: number - last_status_at: string - } +export type FeaturedTag = { + id: string + name: string + statuses_count: number + last_status_at: string } diff --git a/megalodon/src/mastodon/entities/field.ts b/megalodon/src/mastodon/entities/field.ts index b6ada5d13..88b9eea1e 100644 --- a/megalodon/src/mastodon/entities/field.ts +++ b/megalodon/src/mastodon/entities/field.ts @@ -1,7 +1,5 @@ -namespace MastodonEntity { - export type Field = { - name: string - value: string - verified_at: string | null - } +export type Field = { + name: string + value: string + verified_at: string | null } diff --git a/megalodon/src/mastodon/entities/filter.ts b/megalodon/src/mastodon/entities/filter.ts index 1e17e61b2..cf1fa800e 100644 --- a/megalodon/src/mastodon/entities/filter.ts +++ b/megalodon/src/mastodon/entities/filter.ts @@ -1,12 +1,10 @@ -namespace MastodonEntity { - export type Filter = { - id: string - phrase: string - context: Array - expires_at: string | null - irreversible: boolean - whole_word: boolean - } - - export type FilterContext = string +export type Filter = { + id: string + phrase: string + context: Array + expires_at: string | null + irreversible: boolean + whole_word: boolean } + +export type FilterContext = string diff --git a/megalodon/src/mastodon/entities/history.ts b/megalodon/src/mastodon/entities/history.ts index cc1a3b4fb..6d38a71f9 100644 --- a/megalodon/src/mastodon/entities/history.ts +++ b/megalodon/src/mastodon/entities/history.ts @@ -1,7 +1,5 @@ -namespace MastodonEntity { - export type History = { - day: string - uses: number - accounts: number - } +export type History = { + day: string + uses: number + accounts: number } diff --git a/megalodon/src/mastodon/entities/identity_proof.ts b/megalodon/src/mastodon/entities/identity_proof.ts index a4dab9eaf..882cd5bfb 100644 --- a/megalodon/src/mastodon/entities/identity_proof.ts +++ b/megalodon/src/mastodon/entities/identity_proof.ts @@ -1,9 +1,7 @@ -namespace MastodonEntity { - export type IdentityProof = { - provider: string - provider_username: string - updated_at: string - proof_url: string - profile_url: string - } +export type IdentityProof = { + provider: string + provider_username: string + updated_at: string + proof_url: string + profile_url: string } diff --git a/megalodon/src/mastodon/entities/instance.ts b/megalodon/src/mastodon/entities/instance.ts index 842e2c6bb..2f8227eec 100644 --- a/megalodon/src/mastodon/entities/instance.ts +++ b/megalodon/src/mastodon/entities/instance.ts @@ -1,49 +1,47 @@ -/// -/// -/// +import { URLs } from './urls' +import { Stats } from './stats' +import { Account } from './account' -namespace MastodonEntity { - export type Instance = { - uri: string - title: string - description: string - email: string - version: string - thumbnail: string | null - urls: URLs - stats: Stats - languages: Array - registrations: boolean - approval_required: boolean - invites_enabled: boolean - max_toot_chars?: number - configuration: { - statuses: { - max_characters: number - max_media_attachments: number - characters_reserved_per_url: number - } - media_attachments: { - supported_mime_types: Array - image_size_limit: number - image_matrix_limit: number - video_size_limit: number - video_frame_limit: number - video_matrix_limit: number - } - polls: { - max_options: number - max_characters_per_option: number - min_expiration: number - max_expiration: number - } +export type Instance = { + uri: string + title: string + description: string + email: string + version: string + thumbnail: string | null + urls: URLs + stats: Stats + languages: Array + registrations: boolean + approval_required: boolean + invites_enabled: boolean + max_toot_chars?: number + configuration: { + statuses: { + max_characters: number + max_media_attachments: number + characters_reserved_per_url: number + } + media_attachments: { + supported_mime_types: Array + image_size_limit: number + image_matrix_limit: number + video_size_limit: number + video_frame_limit: number + video_matrix_limit: number + } + polls: { + max_options: number + max_characters_per_option: number + min_expiration: number + max_expiration: number } - contact_account: Account - rules: Array } + contact_account: Account + rules: Array +} - export type InstanceRule = { - id: string - text: string - } +export type InstanceRule = { + id: string + text: string } diff --git a/megalodon/src/mastodon/entities/list.ts b/megalodon/src/mastodon/entities/list.ts index 503499839..03274012b 100644 --- a/megalodon/src/mastodon/entities/list.ts +++ b/megalodon/src/mastodon/entities/list.ts @@ -1,9 +1,7 @@ -namespace MastodonEntity { - export type List = { - id: string - title: string - replies_policy: RepliesPolicy - } - - export type RepliesPolicy = 'followed' | 'list' | 'none' +export type List = { + id: string + title: string + replies_policy: RepliesPolicy } + +export type RepliesPolicy = 'followed' | 'list' | 'none' diff --git a/megalodon/src/mastodon/entities/marker.ts b/megalodon/src/mastodon/entities/marker.ts index 1b0983e2b..e347a09d3 100644 --- a/megalodon/src/mastodon/entities/marker.ts +++ b/megalodon/src/mastodon/entities/marker.ts @@ -1,14 +1,12 @@ -namespace MastodonEntity { - export type Marker = { - home: { - last_read_id: string - version: number - updated_at: string - } - notifications: { - last_read_id: string - version: number - updated_at: string - } +export type Marker = { + home: { + last_read_id: string + version: number + updated_at: string + } + notifications: { + last_read_id: string + version: number + updated_at: string } } diff --git a/megalodon/src/mastodon/entities/mention.ts b/megalodon/src/mastodon/entities/mention.ts index ddc99d93e..098633673 100644 --- a/megalodon/src/mastodon/entities/mention.ts +++ b/megalodon/src/mastodon/entities/mention.ts @@ -1,8 +1,6 @@ -namespace MastodonEntity { - export type Mention = { - id: string - username: string - url: string - acct: string - } +export type Mention = { + id: string + username: string + url: string + acct: string } diff --git a/megalodon/src/mastodon/entities/notification.ts b/megalodon/src/mastodon/entities/notification.ts index ad5519bae..b33b53c8b 100644 --- a/megalodon/src/mastodon/entities/notification.ts +++ b/megalodon/src/mastodon/entities/notification.ts @@ -1,14 +1,12 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace MastodonEntity { - export type Notification = { - account: Account - created_at: string - id: string - status?: Status - type: NotificationType - } - - export type NotificationType = string +export type Notification = { + account: Account + created_at: string + id: string + status?: Status + type: NotificationType } + +export type NotificationType = string diff --git a/megalodon/src/mastodon/entities/poll.ts b/megalodon/src/mastodon/entities/poll.ts index eaf09050f..d8861108e 100644 --- a/megalodon/src/mastodon/entities/poll.ts +++ b/megalodon/src/mastodon/entities/poll.ts @@ -1,13 +1,14 @@ -/// +export type Poll = { + id: string + expires_at: string | null + expired: boolean + multiple: boolean + votes_count: number + options: Array + voted: boolean +} -namespace MastodonEntity { - export type Poll = { - id: string - expires_at: string | null - expired: boolean - multiple: boolean - votes_count: number - options: Array - voted: boolean - } +export type PollOption = { + title: string + votes_count: number | null } diff --git a/megalodon/src/mastodon/entities/poll_option.ts b/megalodon/src/mastodon/entities/poll_option.ts deleted file mode 100644 index d3c14190f..000000000 --- a/megalodon/src/mastodon/entities/poll_option.ts +++ /dev/null @@ -1,6 +0,0 @@ -namespace MastodonEntity { - export type PollOption = { - title: string - votes_count: number | null - } -} diff --git a/megalodon/src/mastodon/entities/preferences.ts b/megalodon/src/mastodon/entities/preferences.ts index 3c8cc953c..e0646f6de 100644 --- a/megalodon/src/mastodon/entities/preferences.ts +++ b/megalodon/src/mastodon/entities/preferences.ts @@ -1,9 +1,7 @@ -namespace MastodonEntity { - export type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' - 'posting:default:sensitive': boolean - 'posting:default:language': string | null - 'reading:expand:media': 'default' | 'show_all' | 'hide_all' - 'reading:expand:spoilers': boolean - } +export type Preferences = { + 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' + 'posting:default:sensitive': boolean + 'posting:default:language': string | null + 'reading:expand:media': 'default' | 'show_all' | 'hide_all' + 'reading:expand:spoilers': boolean } diff --git a/megalodon/src/mastodon/entities/push_subscription.ts b/megalodon/src/mastodon/entities/push_subscription.ts index ad96ea685..ae440143b 100644 --- a/megalodon/src/mastodon/entities/push_subscription.ts +++ b/megalodon/src/mastodon/entities/push_subscription.ts @@ -1,16 +1,14 @@ -namespace MastodonEntity { - export type Alerts = { - follow: boolean - favourite: boolean - mention: boolean - reblog: boolean - poll: boolean - } +export type Alerts = { + follow: boolean + favourite: boolean + mention: boolean + reblog: boolean + poll: boolean +} - export type PushSubscription = { - id: string - endpoint: string - server_key: string - alerts: Alerts - } +export type PushSubscription = { + id: string + endpoint: string + server_key: string + alerts: Alerts } diff --git a/megalodon/src/mastodon/entities/relationship.ts b/megalodon/src/mastodon/entities/relationship.ts index 8e02df576..6b93e801b 100644 --- a/megalodon/src/mastodon/entities/relationship.ts +++ b/megalodon/src/mastodon/entities/relationship.ts @@ -1,18 +1,16 @@ -namespace MastodonEntity { - export type Relationship = { - id: string - following: boolean - followed_by: boolean - blocking: boolean - blocked_by: boolean - muting: boolean - muting_notifications: boolean - requested: boolean - domain_blocking: boolean - showing_reblogs: boolean - endorsed: boolean - notifying: boolean - note: string - languages: Array - } +export type Relationship = { + id: string + following: boolean + followed_by: boolean + blocking: boolean + blocked_by: boolean + muting: boolean + muting_notifications: boolean + requested: boolean + domain_blocking: boolean + showing_reblogs: boolean + endorsed: boolean + notifying: boolean + note: string + languages: Array } diff --git a/megalodon/src/mastodon/entities/report.ts b/megalodon/src/mastodon/entities/report.ts index 0eba265a3..fd62dbe80 100644 --- a/megalodon/src/mastodon/entities/report.ts +++ b/megalodon/src/mastodon/entities/report.ts @@ -1,17 +1,15 @@ -/// +import { Account } from './account' -namespace MastodonEntity { - export type Report = { - id: string - action_taken: boolean - action_taken_at: string | null - category: Category - comment: string - forwarded: boolean - status_ids: Array | null - rule_ids: Array | null - target_account: Account - } - - export type Category = 'spam' | 'violation' | 'other' +export type Report = { + id: string + action_taken: boolean + action_taken_at: string | null + category: Category + comment: string + forwarded: boolean + status_ids: Array | null + rule_ids: Array | null + target_account: Account } + +export type Category = 'spam' | 'violation' | 'other' diff --git a/megalodon/src/mastodon/entities/results.ts b/megalodon/src/mastodon/entities/results.ts index a1c906543..17ee9190b 100644 --- a/megalodon/src/mastodon/entities/results.ts +++ b/megalodon/src/mastodon/entities/results.ts @@ -1,11 +1,9 @@ -/// -/// -/// +import { Account } from './account' +import { Status } from './status' +import { Tag } from './tag' -namespace MastodonEntity { - export type Results = { - accounts: Array - statuses: Array - hashtags: Array - } +export type Results = { + accounts: Array + statuses: Array + hashtags: Array } diff --git a/megalodon/src/mastodon/entities/role.ts b/megalodon/src/mastodon/entities/role.ts index ebfad59c1..2b5be2df5 100644 --- a/megalodon/src/mastodon/entities/role.ts +++ b/megalodon/src/mastodon/entities/role.ts @@ -1,5 +1,3 @@ -namespace MastodonEntity { - export type Role = { - name: string - } +export type Role = { + name: string } diff --git a/megalodon/src/mastodon/entities/scheduled_status.ts b/megalodon/src/mastodon/entities/scheduled_status.ts index 2388311ac..68932fafb 100644 --- a/megalodon/src/mastodon/entities/scheduled_status.ts +++ b/megalodon/src/mastodon/entities/scheduled_status.ts @@ -1,10 +1,9 @@ -/// -/// -namespace MastodonEntity { - export type ScheduledStatus = { - id: string - scheduled_at: string - params: StatusParams - media_attachments: Array - } +import { Attachment } from './attachment' +import { StatusParams } from './status_params' + +export type ScheduledStatus = { + id: string + scheduled_at: string + params: StatusParams + media_attachments: Array } diff --git a/megalodon/src/mastodon/entities/source.ts b/megalodon/src/mastodon/entities/source.ts index c10460217..a82203909 100644 --- a/megalodon/src/mastodon/entities/source.ts +++ b/megalodon/src/mastodon/entities/source.ts @@ -1,10 +1,9 @@ -/// -namespace MastodonEntity { - export type Source = { - privacy: string | null - sensitive: boolean | null - language: string | null - note: string - fields: Array - } +import { Field } from './field' + +export type Source = { + privacy: string | null + sensitive: boolean | null + language: string | null + note: string + fields: Array } diff --git a/megalodon/src/mastodon/entities/stats.ts b/megalodon/src/mastodon/entities/stats.ts index 925da8501..b8a8db853 100644 --- a/megalodon/src/mastodon/entities/stats.ts +++ b/megalodon/src/mastodon/entities/stats.ts @@ -1,7 +1,5 @@ -namespace MastodonEntity { - export type Stats = { - user_count: number - status_count: number - domain_count: number - } +export type Stats = { + user_count: number + status_count: number + domain_count: number } diff --git a/megalodon/src/mastodon/entities/status.ts b/megalodon/src/mastodon/entities/status.ts index 9624e9c72..24363a591 100644 --- a/megalodon/src/mastodon/entities/status.ts +++ b/megalodon/src/mastodon/entities/status.ts @@ -1,49 +1,46 @@ -/// -/// -/// -/// -/// -/// -/// -/// +import { Account } from './account' +import { Application } from './application' +import { Attachment } from './attachment' +import { Mention } from './mention' +import { Emoji } from './emoji' +import { Card } from './card' +import { Poll } from './poll' -namespace MastodonEntity { - export type Status = { - id: string - uri: string - url: string - account: Account - in_reply_to_id: string | null - in_reply_to_account_id: string | null - reblog: Status | null - content: string - created_at: string - emojis: Emoji[] - replies_count: number - reblogs_count: number - favourites_count: number - reblogged: boolean | null - favourited: boolean | null - muted: boolean | null - sensitive: boolean - spoiler_text: string - visibility: 'public' | 'unlisted' | 'private' | 'direct' - media_attachments: Array - mentions: Array - tags: Array - card: Card | null - poll: Poll | null - application: Application | null - language: string | null - pinned: boolean | null - bookmarked?: boolean - // These parameters are unique parameters in fedibird.com for quote. - quote_id?: string - quote?: Status | null - } +export type Status = { + id: string + uri: string + url: string + account: Account + in_reply_to_id: string | null + in_reply_to_account_id: string | null + reblog: Status | null + content: string + created_at: string + emojis: Emoji[] + replies_count: number + reblogs_count: number + favourites_count: number + reblogged: boolean | null + favourited: boolean | null + muted: boolean | null + sensitive: boolean + spoiler_text: string + visibility: 'public' | 'unlisted' | 'private' | 'direct' + media_attachments: Array + mentions: Array + tags: Array + card: Card | null + poll: Poll | null + application: Application | null + language: string | null + pinned: boolean | null + bookmarked?: boolean + // These parameters are unique parameters in fedibird.com for quote. + quote_id?: string + quote?: Status | null +} - export type StatusTag = { - name: string - url: string - } +export type StatusTag = { + name: string + url: string } diff --git a/megalodon/src/mastodon/entities/status_params.ts b/megalodon/src/mastodon/entities/status_params.ts index 1b6ffb7dd..3f424bfef 100644 --- a/megalodon/src/mastodon/entities/status_params.ts +++ b/megalodon/src/mastodon/entities/status_params.ts @@ -1,12 +1,10 @@ -namespace MastodonEntity { - export type StatusParams = { - text: string - in_reply_to_id: string | null - media_ids: Array | null - sensitive: boolean | null - spoiler_text: string | null - visibility: 'public' | 'unlisted' | 'private' | 'direct' | null - scheduled_at: string | null - application_id: number - } +export type StatusParams = { + text: string + in_reply_to_id: string | null + media_ids: Array | null + sensitive: boolean | null + spoiler_text: string | null + visibility: 'public' | 'unlisted' | 'private' | 'direct' | null + scheduled_at: string | null + application_id: number } diff --git a/megalodon/src/mastodon/entities/status_source.ts b/megalodon/src/mastodon/entities/status_source.ts index f8ca42c03..82103f9a1 100644 --- a/megalodon/src/mastodon/entities/status_source.ts +++ b/megalodon/src/mastodon/entities/status_source.ts @@ -1,7 +1,5 @@ -namespace MastodonEntity { - export type StatusSource = { - id: string - text: string - spoiler_text: string - } +export type StatusSource = { + id: string + text: string + spoiler_text: string } diff --git a/megalodon/src/mastodon/entities/tag.ts b/megalodon/src/mastodon/entities/tag.ts index 8a10ad58b..2fae1efbe 100644 --- a/megalodon/src/mastodon/entities/tag.ts +++ b/megalodon/src/mastodon/entities/tag.ts @@ -1,10 +1,8 @@ -/// +import { History } from './history' -namespace MastodonEntity { - export type Tag = { - name: string - url: string - history: Array - following?: boolean - } +export type Tag = { + name: string + url: string + history: Array + following?: boolean } diff --git a/megalodon/src/mastodon/entities/token.ts b/megalodon/src/mastodon/entities/token.ts index 128663ecf..9cf3c1508 100644 --- a/megalodon/src/mastodon/entities/token.ts +++ b/megalodon/src/mastodon/entities/token.ts @@ -1,8 +1,6 @@ -namespace MastodonEntity { - export type Token = { - access_token: string - token_type: string - scope: string - created_at: number - } +export type Token = { + access_token: string + token_type: string + scope: string + created_at: number } diff --git a/megalodon/src/mastodon/entities/urls.ts b/megalodon/src/mastodon/entities/urls.ts index 4f6b55a4c..5c1087420 100644 --- a/megalodon/src/mastodon/entities/urls.ts +++ b/megalodon/src/mastodon/entities/urls.ts @@ -1,5 +1,3 @@ -namespace MastodonEntity { - export type URLs = { - streaming_api: string - } +export type URLs = { + streaming_api: string } diff --git a/megalodon/src/mastodon/entity.ts b/megalodon/src/mastodon/entity.ts index dcafdfe74..d64e7f031 100644 --- a/megalodon/src/mastodon/entity.ts +++ b/megalodon/src/mastodon/entity.ts @@ -1,39 +1,80 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +import * as account from './entities/account' +import * as activity from './entities/activity' +import * as announcement from './entities/announcement' +import * as application from './entities/application' +import * as async_attachment from './entities/async_attachment' +import * as attachment from './entities/attachment' +import * as card from './entities/card' +import * as context from './entities/context' +import * as conversation from './entities/conversation' +import * as emoji from './entities/emoji' +import * as featured_tag from './entities/featured_tag' +import * as field from './entities/field' +import * as filter from './entities/filter' +import * as history from './entities/history' +import * as identity_proof from './entities/identity_proof' +import * as instance from './entities/instance' +import * as list from './entities/list' +import * as marker from './entities/marker' +import * as mentition from './entities/mention' +import * as notification from './entities/notification' +import * as poll from './entities/poll' +import * as preferences from './entities/preferences' +import * as push_subscription from './entities/push_subscription' +import * as relationship from './entities/relationship' +import * as report from './entities/report' +import * as results from './entities/results' +import * as role from './entities/role' +import * as scheduled_status from './entities/scheduled_status' +import * as source from './entities/source' +import * as stats from './entities/stats' +import * as status from './entities/status' +import * as status_params from './entities/status_params' +import * as status_source from './entities/status_source' +import * as tag from './entities/tag' +import * as token from './entities/token' +import * as urls from './entities/urls' -export default MastodonEntity +export namespace Entity { + export type Account = account.Account + export type Activity = activity.Activity + export type Announcement = announcement.Announcement + export type Application = application.Application + export type AsyncAttachment = async_attachment.AsyncAttachment + export type Attachment = attachment.Attachment + export type Card = card.Card + export type Context = context.Context + export type Conversation = conversation.Conversation + export type Emoji = emoji.Emoji + export type FeaturedTag = featured_tag.FeaturedTag + export type Field = field.Field + export type Filter = filter.Filter + export type FilterContext = filter.FilterContext + export type History = history.History + export type IdentityProof = identity_proof.IdentityProof + export type Instance = instance.Instance + export type List = list.List + export type Marker = marker.Marker + export type Mention = mentition.Mention + export type Notification = notification.Notification + export type NotificationType = notification.NotificationType + export type Poll = poll.Poll + export type PollOption = poll.PollOption + export type Preferences = preferences.Preferences + export type PushSubscription = push_subscription.PushSubscription + export type Relationship = relationship.Relationship + export type Report = report.Report + export type Results = results.Results + export type Role = role.Role + export type ScheduledStatus = scheduled_status.ScheduledStatus + export type Source = source.Source + export type Stats = stats.Stats + export type Status = status.Status + export type StatusParams = status_params.StatusParams + export type StatusSource = status_source.StatusSource + export type Tag = tag.Tag + export type Token = token.Token + export type URLs = urls.URLs +} + +export default Entity diff --git a/megalodon/src/pleroma.ts b/megalodon/src/pleroma.ts index 78465d4bb..6fe6d07e1 100644 --- a/megalodon/src/pleroma.ts +++ b/megalodon/src/pleroma.ts @@ -6,6 +6,7 @@ import WebSocket from './pleroma/web_socket' import { MegalodonInterface, NoImplementedError, ArgumentError } from './megalodon' import Response from './response' import Entity from './entity' + import { NO_REDIRECT, DEFAULT_SCOPE, DEFAULT_UA } from './default' import { ProxyConfig } from './proxy_config' import OAuth from './oauth' @@ -566,7 +567,7 @@ export default class Pleroma implements MegalodonInterface { }) } } - return this.client.get>(`/api/v1/accounts/${id}/following`, params).then(res => { + return this.client.get>(`/api/v1/accounts/${id}/following`, params).then(res => { return Object.assign(res, { data: res.data.map(a => PleromaAPI.Converter.account(a)) }) diff --git a/megalodon/test/integration/pleroma.spec.ts b/megalodon/test/integration/pleroma.spec.ts index a28801fb1..c00499b65 100644 --- a/megalodon/test/integration/pleroma.spec.ts +++ b/megalodon/test/integration/pleroma.spec.ts @@ -66,7 +66,7 @@ const status: PleromaEntity.Status = { poll: null, application: { name: 'Web' - } as MastodonEntity.Application, + } as PleromaEntity.Application, language: null, pinned: null, bookmarked: false, diff --git a/megalodon/test/unit/pleroma/api_client.spec.ts b/megalodon/test/unit/pleroma/api_client.spec.ts index 98c9ec8e4..266531cc7 100644 --- a/megalodon/test/unit/pleroma/api_client.spec.ts +++ b/megalodon/test/unit/pleroma/api_client.spec.ts @@ -162,7 +162,7 @@ describe('api_client', () => { poll: null, application: { name: 'Web' - } as MastodonEntity.Application, + } as PleromaEntity.Application, language: null, pinned: null, bookmarked: false, @@ -209,7 +209,7 @@ describe('api_client', () => { poll: null, application: { name: 'Web' - } as MastodonEntity.Application, + } as PleromaEntity.Application, language: null, pinned: null, bookmarked: false, From 9ed2d654cf462d21f9d3e27213ebbe20fa5a4c04 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 7 Oct 2023 21:14:15 +0900 Subject: [PATCH 4/6] Change namespace definition for pleroma entity --- megalodon/src/pleroma/entities/account.ts | 59 +++++---- megalodon/src/pleroma/entities/activity.ts | 12 +- .../src/pleroma/entities/announcement.ts | 67 +++++----- megalodon/src/pleroma/entities/application.ts | 10 +- .../src/pleroma/entities/async_attachment.ts | 25 ++-- megalodon/src/pleroma/entities/attachment.ts | 84 ++++++------- megalodon/src/pleroma/entities/card.ts | 18 ++- megalodon/src/pleroma/entities/context.ts | 10 +- .../src/pleroma/entities/conversation.ts | 16 ++- megalodon/src/pleroma/entities/emoji.ts | 12 +- .../src/pleroma/entities/featured_tag.ts | 12 +- megalodon/src/pleroma/entities/field.ts | 10 +- megalodon/src/pleroma/entities/filter.ts | 20 ++- megalodon/src/pleroma/entities/history.ts | 10 +- .../src/pleroma/entities/identity_proof.ts | 14 +-- megalodon/src/pleroma/entities/instance.ts | 79 ++++++------ megalodon/src/pleroma/entities/list.ts | 8 +- megalodon/src/pleroma/entities/marker.ts | 16 ++- megalodon/src/pleroma/entities/mention.ts | 12 +- .../src/pleroma/entities/notification.ts | 26 ++-- megalodon/src/pleroma/entities/poll.ts | 23 ++-- megalodon/src/pleroma/entities/poll_option.ts | 6 - megalodon/src/pleroma/entities/preferences.ts | 14 +-- .../src/pleroma/entities/push_subscription.ts | 26 ++-- megalodon/src/pleroma/entities/reaction.ts | 14 +-- .../src/pleroma/entities/relationship.ts | 32 +++-- megalodon/src/pleroma/entities/report.ts | 8 +- megalodon/src/pleroma/entities/results.ts | 16 ++- .../src/pleroma/entities/scheduled_status.ts | 17 ++- megalodon/src/pleroma/entities/source.ts | 17 ++- megalodon/src/pleroma/entities/stats.ts | 10 +- megalodon/src/pleroma/entities/status.ts | 116 +++++++++-------- .../src/pleroma/entities/status_params.ts | 18 ++- .../src/pleroma/entities/status_source.ts | 10 +- megalodon/src/pleroma/entities/tag.ts | 14 +-- megalodon/src/pleroma/entities/token.ts | 12 +- megalodon/src/pleroma/entities/urls.ts | 6 +- megalodon/src/pleroma/entity.ts | 117 ++++++++++++------ 38 files changed, 483 insertions(+), 513 deletions(-) delete mode 100644 megalodon/src/pleroma/entities/poll_option.ts diff --git a/megalodon/src/pleroma/entities/account.ts b/megalodon/src/pleroma/entities/account.ts index 29d42643f..7c93f0861 100644 --- a/megalodon/src/pleroma/entities/account.ts +++ b/megalodon/src/pleroma/entities/account.ts @@ -1,31 +1,30 @@ -/// -/// -/// -namespace PleromaEntity { - export type Account = { - id: string - username: string - acct: string - display_name: string - locked: boolean - discoverable?: boolean - noindex: boolean | null - suspended: boolean | null - limited: boolean | null - created_at: string - followers_count: number - following_count: number - statuses_count: number - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - emojis: Array - moved: Account | null - fields: Array - bot: boolean - source?: Source - } +import { Emoji } from './emoji' +import { Field } from './field' +import { Source } from './source' + +export type Account = { + id: string + username: string + acct: string + display_name: string + locked: boolean + discoverable?: boolean + noindex: boolean | null + suspended: boolean | null + limited: boolean | null + created_at: string + followers_count: number + following_count: number + statuses_count: number + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + emojis: Array + moved: Account | null + fields: Array + bot: boolean + source?: Source } diff --git a/megalodon/src/pleroma/entities/activity.ts b/megalodon/src/pleroma/entities/activity.ts index f70ad168e..a174a5eb9 100644 --- a/megalodon/src/pleroma/entities/activity.ts +++ b/megalodon/src/pleroma/entities/activity.ts @@ -1,8 +1,6 @@ -namespace PleromaEntity { - export type Activity = { - week: string - statuses: string - logins: string - registrations: string - } +export type Activity = { + week: string + statuses: string + logins: string + registrations: string } diff --git a/megalodon/src/pleroma/entities/announcement.ts b/megalodon/src/pleroma/entities/announcement.ts index 247ad90c5..ee46101ab 100644 --- a/megalodon/src/pleroma/entities/announcement.ts +++ b/megalodon/src/pleroma/entities/announcement.ts @@ -1,39 +1,38 @@ -/// +import { StatusTag } from './status' +import { Emoji } from './emoji' -namespace PleromaEntity { - export type Announcement = { - id: string - content: string - starts_at: string | null - ends_at: string | null - published: boolean - all_day: boolean - published_at: string - updated_at: string - mentions: Array - statuses: Array - tags: Array - emojis: Array - reactions: Array - } +export type Announcement = { + id: string + content: string + starts_at: string | null + ends_at: string | null + published: boolean + all_day: boolean + published_at: string + updated_at: string + mentions: Array + statuses: Array + tags: Array + emojis: Array + reactions: Array +} - export type AnnouncementAccount = { - id: string - username: string - url: string - acct: string - } +export type AnnouncementAccount = { + id: string + username: string + url: string + acct: string +} - export type AnnouncementStatus = { - id: string - url: string - } +export type AnnouncementStatus = { + id: string + url: string +} - export type AnnouncementReaction = { - name: string - count: number - me: boolean | null - url: string | null - static_url: string | null - } +export type AnnouncementReaction = { + name: string + count: number + me: boolean | null + url: string | null + static_url: string | null } diff --git a/megalodon/src/pleroma/entities/application.ts b/megalodon/src/pleroma/entities/application.ts index 055592d6c..884caff81 100644 --- a/megalodon/src/pleroma/entities/application.ts +++ b/megalodon/src/pleroma/entities/application.ts @@ -1,7 +1,5 @@ -namespace PleromaEntity { - export type Application = { - name: string - website?: string | null - vapid_key?: string | null - } +export type Application = { + name: string + website?: string | null + vapid_key?: string | null } diff --git a/megalodon/src/pleroma/entities/async_attachment.ts b/megalodon/src/pleroma/entities/async_attachment.ts index 8784979cb..de3b1f8f6 100644 --- a/megalodon/src/pleroma/entities/async_attachment.ts +++ b/megalodon/src/pleroma/entities/async_attachment.ts @@ -1,14 +1,13 @@ -/// -namespace PleromaEntity { - export type AsyncAttachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string | null - remote_url: string | null - preview_url: string - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +import { Meta } from './attachment' + +export type AsyncAttachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string | null + remote_url: string | null + preview_url: string + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/pleroma/entities/attachment.ts b/megalodon/src/pleroma/entities/attachment.ts index 18d4371da..38d367642 100644 --- a/megalodon/src/pleroma/entities/attachment.ts +++ b/megalodon/src/pleroma/entities/attachment.ts @@ -1,49 +1,47 @@ -namespace PleromaEntity { - export type Sub = { - // For Image, Gifv, and Video - width?: number - height?: number - size?: string - aspect?: number +export type Sub = { + // For Image, Gifv, and Video + width?: number + height?: number + size?: string + aspect?: number - // For Gifv and Video - frame_rate?: string + // For Gifv and Video + frame_rate?: string - // For Audio, Gifv, and Video - duration?: number - bitrate?: number - } + // For Audio, Gifv, and Video + duration?: number + bitrate?: number +} - export type Focus = { - x: number - y: number - } +export type Focus = { + x: number + y: number +} - export type Meta = { - original?: Sub - small?: Sub - focus?: Focus - length?: string - duration?: number - fps?: number - size?: string - width?: number - height?: number - aspect?: number - audio_encode?: string - audio_bitrate?: string - audio_channel?: string - } +export type Meta = { + original?: Sub + small?: Sub + focus?: Focus + length?: string + duration?: number + fps?: number + size?: string + width?: number + height?: number + aspect?: number + audio_encode?: string + audio_bitrate?: string + audio_channel?: string +} - export type Attachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string - remote_url: string | null - preview_url: string | null - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +export type Attachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string + remote_url: string | null + preview_url: string | null + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/pleroma/entities/card.ts b/megalodon/src/pleroma/entities/card.ts index 9aca99a8c..a6009a95f 100644 --- a/megalodon/src/pleroma/entities/card.ts +++ b/megalodon/src/pleroma/entities/card.ts @@ -1,11 +1,9 @@ -namespace PleromaEntity { - export type Card = { - url: string - title: string - description: string - type: 'link' | 'photo' | 'video' | 'rich' - image: string | null - provider_name: string - provider_url: string - } +export type Card = { + url: string + title: string + description: string + type: 'link' | 'photo' | 'video' | 'rich' + image: string | null + provider_name: string + provider_url: string } diff --git a/megalodon/src/pleroma/entities/context.ts b/megalodon/src/pleroma/entities/context.ts index f297bd2c1..14da5dd8d 100644 --- a/megalodon/src/pleroma/entities/context.ts +++ b/megalodon/src/pleroma/entities/context.ts @@ -1,8 +1,6 @@ -/// +import { Status } from './status' -namespace PleromaEntity { - export type Context = { - ancestors: Array - descendants: Array - } +export type Context = { + ancestors: Array + descendants: Array } diff --git a/megalodon/src/pleroma/entities/conversation.ts b/megalodon/src/pleroma/entities/conversation.ts index 624e6da38..83b900bec 100644 --- a/megalodon/src/pleroma/entities/conversation.ts +++ b/megalodon/src/pleroma/entities/conversation.ts @@ -1,11 +1,9 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace PleromaEntity { - export type Conversation = { - id: string - accounts: Array - last_status: Status | null - unread: boolean - } +export type Conversation = { + id: string + accounts: Array + last_status: Status | null + unread: boolean } diff --git a/megalodon/src/pleroma/entities/emoji.ts b/megalodon/src/pleroma/entities/emoji.ts index 43ea22d77..2d383bbfb 100644 --- a/megalodon/src/pleroma/entities/emoji.ts +++ b/megalodon/src/pleroma/entities/emoji.ts @@ -1,8 +1,6 @@ -namespace PleromaEntity { - export type Emoji = { - shortcode: string - static_url: string - url: string - visible_in_picker: boolean - } +export type Emoji = { + shortcode: string + static_url: string + url: string + visible_in_picker: boolean } diff --git a/megalodon/src/pleroma/entities/featured_tag.ts b/megalodon/src/pleroma/entities/featured_tag.ts index a42e27f9d..15ddd85b8 100644 --- a/megalodon/src/pleroma/entities/featured_tag.ts +++ b/megalodon/src/pleroma/entities/featured_tag.ts @@ -1,8 +1,6 @@ -namespace PleromaEntity { - export type FeaturedTag = { - id: string - name: string - statuses_count: number - last_status_at: string - } +export type FeaturedTag = { + id: string + name: string + statuses_count: number + last_status_at: string } diff --git a/megalodon/src/pleroma/entities/field.ts b/megalodon/src/pleroma/entities/field.ts index 01803078a..88b9eea1e 100644 --- a/megalodon/src/pleroma/entities/field.ts +++ b/megalodon/src/pleroma/entities/field.ts @@ -1,7 +1,5 @@ -namespace PleromaEntity { - export type Field = { - name: string - value: string - verified_at: string | null - } +export type Field = { + name: string + value: string + verified_at: string | null } diff --git a/megalodon/src/pleroma/entities/filter.ts b/megalodon/src/pleroma/entities/filter.ts index 08a18089c..cf1fa800e 100644 --- a/megalodon/src/pleroma/entities/filter.ts +++ b/megalodon/src/pleroma/entities/filter.ts @@ -1,12 +1,10 @@ -namespace PleromaEntity { - export type Filter = { - id: string - phrase: string - context: Array - expires_at: string | null - irreversible: boolean - whole_word: boolean - } - - export type FilterContext = string +export type Filter = { + id: string + phrase: string + context: Array + expires_at: string | null + irreversible: boolean + whole_word: boolean } + +export type FilterContext = string diff --git a/megalodon/src/pleroma/entities/history.ts b/megalodon/src/pleroma/entities/history.ts index 9aaaeb8de..6d38a71f9 100644 --- a/megalodon/src/pleroma/entities/history.ts +++ b/megalodon/src/pleroma/entities/history.ts @@ -1,7 +1,5 @@ -namespace PleromaEntity { - export type History = { - day: string - uses: number - accounts: number - } +export type History = { + day: string + uses: number + accounts: number } diff --git a/megalodon/src/pleroma/entities/identity_proof.ts b/megalodon/src/pleroma/entities/identity_proof.ts index 463fdc681..882cd5bfb 100644 --- a/megalodon/src/pleroma/entities/identity_proof.ts +++ b/megalodon/src/pleroma/entities/identity_proof.ts @@ -1,9 +1,7 @@ -namespace PleromaEntity { - export type IdentityProof = { - provider: string - provider_username: string - updated_at: string - proof_url: string - profile_url: string - } +export type IdentityProof = { + provider: string + provider_username: string + updated_at: string + proof_url: string + profile_url: string } diff --git a/megalodon/src/pleroma/entities/instance.ts b/megalodon/src/pleroma/entities/instance.ts index 0b57e805e..f2b4bd5a4 100644 --- a/megalodon/src/pleroma/entities/instance.ts +++ b/megalodon/src/pleroma/entities/instance.ts @@ -1,46 +1,43 @@ -/// -/// -/// +import { URLs } from './urls' +import { Stats } from './stats' -namespace PleromaEntity { - export type Instance = { - uri: string - title: string - description: string - email: string - version: string - thumbnail: string | null - urls: URLs - stats: Stats - languages: Array - registrations: boolean - approval_required: boolean - max_toot_chars: number - max_media_attachments?: number - pleroma: { - metadata: { - account_activation_required: boolean - birthday_min_age: number - birthday_required: boolean - features: Array - federation: { - enabled: boolean - exclusions: boolean - } - fields_limits: { - max_fields: number - max_remote_fields: number - name_length: number - value_length: number - } - post_formats: Array +export type Instance = { + uri: string + title: string + description: string + email: string + version: string + thumbnail: string | null + urls: URLs + stats: Stats + languages: Array + registrations: boolean + approval_required: boolean + max_toot_chars: number + max_media_attachments?: number + pleroma: { + metadata: { + account_activation_required: boolean + birthday_min_age: number + birthday_required: boolean + features: Array + federation: { + enabled: boolean + exclusions: boolean } + fields_limits: { + max_fields: number + max_remote_fields: number + name_length: number + value_length: number + } + post_formats: Array } - poll_limits: { - max_expiration: number - min_expiration: number - max_option_chars: number - max_options: number - } + } + poll_limits: { + max_expiration: number + min_expiration: number + max_option_chars: number + max_options: number } } diff --git a/megalodon/src/pleroma/entities/list.ts b/megalodon/src/pleroma/entities/list.ts index a3d4362d9..7d6bd908e 100644 --- a/megalodon/src/pleroma/entities/list.ts +++ b/megalodon/src/pleroma/entities/list.ts @@ -1,6 +1,4 @@ -namespace PleromaEntity { - export type List = { - id: string - title: string - } +export type List = { + id: string + title: string } diff --git a/megalodon/src/pleroma/entities/marker.ts b/megalodon/src/pleroma/entities/marker.ts index 720d4a905..c856e066a 100644 --- a/megalodon/src/pleroma/entities/marker.ts +++ b/megalodon/src/pleroma/entities/marker.ts @@ -1,12 +1,10 @@ -namespace PleromaEntity { - export type Marker = { - notifications: { - last_read_id: string - version: number - updated_at: string - pleroma: { - unread_count: number - } +export type Marker = { + notifications: { + last_read_id: string + version: number + updated_at: string + pleroma: { + unread_count: number } } } diff --git a/megalodon/src/pleroma/entities/mention.ts b/megalodon/src/pleroma/entities/mention.ts index 0d68b4ec2..098633673 100644 --- a/megalodon/src/pleroma/entities/mention.ts +++ b/megalodon/src/pleroma/entities/mention.ts @@ -1,8 +1,6 @@ -namespace PleromaEntity { - export type Mention = { - id: string - username: string - url: string - acct: string - } +export type Mention = { + id: string + username: string + url: string + acct: string } diff --git a/megalodon/src/pleroma/entities/notification.ts b/megalodon/src/pleroma/entities/notification.ts index edfa456de..cd6d9ed55 100644 --- a/megalodon/src/pleroma/entities/notification.ts +++ b/megalodon/src/pleroma/entities/notification.ts @@ -1,16 +1,14 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace PleromaEntity { - export type Notification = { - account: Account - created_at: string - id: string - status?: Status - emoji?: string - type: NotificationType - target?: Account - } - - export type NotificationType = string +export type Notification = { + account: Account + created_at: string + id: string + status?: Status + emoji?: string + type: NotificationType + target?: Account } + +export type NotificationType = string diff --git a/megalodon/src/pleroma/entities/poll.ts b/megalodon/src/pleroma/entities/poll.ts index 82e0182ad..d8861108e 100644 --- a/megalodon/src/pleroma/entities/poll.ts +++ b/megalodon/src/pleroma/entities/poll.ts @@ -1,13 +1,14 @@ -/// +export type Poll = { + id: string + expires_at: string | null + expired: boolean + multiple: boolean + votes_count: number + options: Array + voted: boolean +} -namespace PleromaEntity { - export type Poll = { - id: string - expires_at: string | null - expired: boolean - multiple: boolean - votes_count: number - options: Array - voted: boolean - } +export type PollOption = { + title: string + votes_count: number | null } diff --git a/megalodon/src/pleroma/entities/poll_option.ts b/megalodon/src/pleroma/entities/poll_option.ts deleted file mode 100644 index 69717ca0f..000000000 --- a/megalodon/src/pleroma/entities/poll_option.ts +++ /dev/null @@ -1,6 +0,0 @@ -namespace PleromaEntity { - export type PollOption = { - title: string - votes_count: number | null - } -} diff --git a/megalodon/src/pleroma/entities/preferences.ts b/megalodon/src/pleroma/entities/preferences.ts index 99f8d6bca..e0646f6de 100644 --- a/megalodon/src/pleroma/entities/preferences.ts +++ b/megalodon/src/pleroma/entities/preferences.ts @@ -1,9 +1,7 @@ -namespace PleromaEntity { - export type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' - 'posting:default:sensitive': boolean - 'posting:default:language': string | null - 'reading:expand:media': 'default' | 'show_all' | 'hide_all' - 'reading:expand:spoilers': boolean - } +export type Preferences = { + 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' + 'posting:default:sensitive': boolean + 'posting:default:language': string | null + 'reading:expand:media': 'default' | 'show_all' | 'hide_all' + 'reading:expand:spoilers': boolean } diff --git a/megalodon/src/pleroma/entities/push_subscription.ts b/megalodon/src/pleroma/entities/push_subscription.ts index b3e14e68a..ae440143b 100644 --- a/megalodon/src/pleroma/entities/push_subscription.ts +++ b/megalodon/src/pleroma/entities/push_subscription.ts @@ -1,16 +1,14 @@ -namespace PleromaEntity { - export type Alerts = { - follow: boolean - favourite: boolean - mention: boolean - reblog: boolean - poll: boolean - } +export type Alerts = { + follow: boolean + favourite: boolean + mention: boolean + reblog: boolean + poll: boolean +} - export type PushSubscription = { - id: string - endpoint: string - server_key: string - alerts: Alerts - } +export type PushSubscription = { + id: string + endpoint: string + server_key: string + alerts: Alerts } diff --git a/megalodon/src/pleroma/entities/reaction.ts b/megalodon/src/pleroma/entities/reaction.ts index 662600f25..2746ea39e 100644 --- a/megalodon/src/pleroma/entities/reaction.ts +++ b/megalodon/src/pleroma/entities/reaction.ts @@ -1,10 +1,8 @@ -/// +import { Account } from './account' -namespace PleromaEntity { - export type Reaction = { - count: number - me: boolean - name: string - accounts?: Array - } +export type Reaction = { + count: number + me: boolean + name: string + accounts?: Array } diff --git a/megalodon/src/pleroma/entities/relationship.ts b/megalodon/src/pleroma/entities/relationship.ts index 039f8ec74..c2a51d4d4 100644 --- a/megalodon/src/pleroma/entities/relationship.ts +++ b/megalodon/src/pleroma/entities/relationship.ts @@ -1,18 +1,16 @@ -namespace PleromaEntity { - export type Relationship = { - id: string - following: boolean - followed_by: boolean - blocking: boolean - blocked_by: boolean - muting: boolean - muting_notifications: boolean - requested: boolean - domain_blocking: boolean - showing_reblogs: boolean - endorsed: boolean - subscribing: boolean - notifying: boolean - note: string - } +export type Relationship = { + id: string + following: boolean + followed_by: boolean + blocking: boolean + blocked_by: boolean + muting: boolean + muting_notifications: boolean + requested: boolean + domain_blocking: boolean + showing_reblogs: boolean + endorsed: boolean + subscribing: boolean + notifying: boolean + note: string } diff --git a/megalodon/src/pleroma/entities/report.ts b/megalodon/src/pleroma/entities/report.ts index 5b9c650a1..09f0b8705 100644 --- a/megalodon/src/pleroma/entities/report.ts +++ b/megalodon/src/pleroma/entities/report.ts @@ -1,6 +1,4 @@ -namespace PleromaEntity { - export type Report = { - id: string - action_taken: boolean - } +export type Report = { + id: string + action_taken: boolean } diff --git a/megalodon/src/pleroma/entities/results.ts b/megalodon/src/pleroma/entities/results.ts index cd42e3b09..17ee9190b 100644 --- a/megalodon/src/pleroma/entities/results.ts +++ b/megalodon/src/pleroma/entities/results.ts @@ -1,11 +1,9 @@ -/// -/// -/// +import { Account } from './account' +import { Status } from './status' +import { Tag } from './tag' -namespace PleromaEntity { - export type Results = { - accounts: Array - statuses: Array - hashtags: Array - } +export type Results = { + accounts: Array + statuses: Array + hashtags: Array } diff --git a/megalodon/src/pleroma/entities/scheduled_status.ts b/megalodon/src/pleroma/entities/scheduled_status.ts index 547d35fd8..3947e2156 100644 --- a/megalodon/src/pleroma/entities/scheduled_status.ts +++ b/megalodon/src/pleroma/entities/scheduled_status.ts @@ -1,10 +1,9 @@ -/// -/// -namespace PleromaEntity { - export type ScheduledStatus = { - id: string - scheduled_at: string - params: StatusParams - media_attachments: Array | null - } +import { Attachment } from './attachment' +import { StatusParams } from './status_params' + +export type ScheduledStatus = { + id: string + scheduled_at: string + params: StatusParams + media_attachments: Array | null } diff --git a/megalodon/src/pleroma/entities/source.ts b/megalodon/src/pleroma/entities/source.ts index f2fa74ab7..a82203909 100644 --- a/megalodon/src/pleroma/entities/source.ts +++ b/megalodon/src/pleroma/entities/source.ts @@ -1,10 +1,9 @@ -/// -namespace PleromaEntity { - export type Source = { - privacy: string | null - sensitive: boolean | null - language: string | null - note: string - fields: Array - } +import { Field } from './field' + +export type Source = { + privacy: string | null + sensitive: boolean | null + language: string | null + note: string + fields: Array } diff --git a/megalodon/src/pleroma/entities/stats.ts b/megalodon/src/pleroma/entities/stats.ts index ab3e77845..b8a8db853 100644 --- a/megalodon/src/pleroma/entities/stats.ts +++ b/megalodon/src/pleroma/entities/stats.ts @@ -1,7 +1,5 @@ -namespace PleromaEntity { - export type Stats = { - user_count: number - status_count: number - domain_count: number - } +export type Stats = { + user_count: number + status_count: number + domain_count: number } diff --git a/megalodon/src/pleroma/entities/status.ts b/megalodon/src/pleroma/entities/status.ts index 1949ec954..75721e6dd 100644 --- a/megalodon/src/pleroma/entities/status.ts +++ b/megalodon/src/pleroma/entities/status.ts @@ -1,64 +1,62 @@ -/// -/// -/// -/// -/// -/// -/// -/// +import { Account } from './account' +import { Emoji } from './emoji' +import { Application } from './application' +import { Attachment } from './attachment' +import { Mention } from './mention' +import { Card } from './card' +import { Reaction } from './reaction' +import { Poll } from './poll' -namespace PleromaEntity { - export type Status = { - id: string - uri: string - url: string - account: Account - in_reply_to_id: string | null - in_reply_to_account_id: string | null - reblog: Status | null - content: string - created_at: string - emojis: Emoji[] - replies_count: number - reblogs_count: number - favourites_count: number - reblogged: boolean | null - favourited: boolean | null - muted: boolean | null - sensitive: boolean - spoiler_text: string - visibility: 'public' | 'unlisted' | 'private' | 'direct' - media_attachments: Array - mentions: Array - tags: Array - card: Card | null - poll: Poll | null - application: Application | null - language: string | null - pinned: boolean | null - bookmarked?: boolean - // Reblogged status contains only local parameter. - pleroma: { - content?: { - 'text/plain': string - } - spoiler_text?: { - 'text/plain': string - } - conversation_id?: number - direct_conversation_id?: number | null - emoji_reactions?: Array - expires_at?: string - in_reply_to_account_acct?: string - local: boolean - parent_visible?: boolean - pinned_at?: string - thread_muted?: boolean +export type Status = { + id: string + uri: string + url: string + account: Account + in_reply_to_id: string | null + in_reply_to_account_id: string | null + reblog: Status | null + content: string + created_at: string + emojis: Emoji[] + replies_count: number + reblogs_count: number + favourites_count: number + reblogged: boolean | null + favourited: boolean | null + muted: boolean | null + sensitive: boolean + spoiler_text: string + visibility: 'public' | 'unlisted' | 'private' | 'direct' + media_attachments: Array + mentions: Array + tags: Array + card: Card | null + poll: Poll | null + application: Application | null + language: string | null + pinned: boolean | null + bookmarked?: boolean + // Reblogged status contains only local parameter. + pleroma: { + content?: { + 'text/plain': string } + spoiler_text?: { + 'text/plain': string + } + conversation_id?: number + direct_conversation_id?: number | null + emoji_reactions?: Array + expires_at?: string + in_reply_to_account_acct?: string + local: boolean + parent_visible?: boolean + pinned_at?: string + thread_muted?: boolean } +} - export type StatusTag = { - name: string - url: string - } +export type StatusTag = { + name: string + url: string } diff --git a/megalodon/src/pleroma/entities/status_params.ts b/megalodon/src/pleroma/entities/status_params.ts index eda13a0b9..af6579a99 100644 --- a/megalodon/src/pleroma/entities/status_params.ts +++ b/megalodon/src/pleroma/entities/status_params.ts @@ -1,11 +1,9 @@ -namespace PleromaEntity { - export type StatusParams = { - text: string - in_reply_to_id: string | null - media_ids?: Array | null - sensitive: boolean | null - spoiler_text: string | null - visibility: 'public' | 'unlisted' | 'private' | 'direct' | null - scheduled_at: string | null - } +export type StatusParams = { + text: string + in_reply_to_id: string | null + media_ids?: Array | null + sensitive: boolean | null + spoiler_text: string | null + visibility: 'public' | 'unlisted' | 'private' | 'direct' | null + scheduled_at: string | null } diff --git a/megalodon/src/pleroma/entities/status_source.ts b/megalodon/src/pleroma/entities/status_source.ts index 57d2bea78..82103f9a1 100644 --- a/megalodon/src/pleroma/entities/status_source.ts +++ b/megalodon/src/pleroma/entities/status_source.ts @@ -1,7 +1,5 @@ -namespace PleromaEntity { - export type StatusSource = { - id: string - text: string - spoiler_text: string - } +export type StatusSource = { + id: string + text: string + spoiler_text: string } diff --git a/megalodon/src/pleroma/entities/tag.ts b/megalodon/src/pleroma/entities/tag.ts index e323ec72c..2fae1efbe 100644 --- a/megalodon/src/pleroma/entities/tag.ts +++ b/megalodon/src/pleroma/entities/tag.ts @@ -1,10 +1,8 @@ -/// +import { History } from './history' -namespace PleromaEntity { - export type Tag = { - name: string - url: string - history: Array - following?: boolean - } +export type Tag = { + name: string + url: string + history: Array + following?: boolean } diff --git a/megalodon/src/pleroma/entities/token.ts b/megalodon/src/pleroma/entities/token.ts index 0ac565b51..9cf3c1508 100644 --- a/megalodon/src/pleroma/entities/token.ts +++ b/megalodon/src/pleroma/entities/token.ts @@ -1,8 +1,6 @@ -namespace PleromaEntity { - export type Token = { - access_token: string - token_type: string - scope: string - created_at: number - } +export type Token = { + access_token: string + token_type: string + scope: string + created_at: number } diff --git a/megalodon/src/pleroma/entities/urls.ts b/megalodon/src/pleroma/entities/urls.ts index 7ad6faf2b..5c1087420 100644 --- a/megalodon/src/pleroma/entities/urls.ts +++ b/megalodon/src/pleroma/entities/urls.ts @@ -1,5 +1,3 @@ -namespace PleromaEntity { - export type URLs = { - streaming_api: string - } +export type URLs = { + streaming_api: string } diff --git a/megalodon/src/pleroma/entity.ts b/megalodon/src/pleroma/entity.ts index bd486f62b..d47f3cd69 100644 --- a/megalodon/src/pleroma/entity.ts +++ b/megalodon/src/pleroma/entity.ts @@ -1,39 +1,80 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// > -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +import * as account from './entities/account' +import * as activity from './entities/activity' +import * as announcement from './entities/announcement' +import * as application from './entities/application' +import * as async_attachment from './entities/async_attachment' +import * as attachment from './entities/attachment' +import * as card from './entities/card' +import * as context from './entities/context' +import * as conversation from './entities/conversation' +import * as emoji from './entities/emoji' +import * as featured_tag from './entities/featured_tag' +import * as field from './entities/field' +import * as filter from './entities/filter' +import * as history from './entities/history' +import * as identity_proof from './entities/identity_proof' +import * as instance from './entities/instance' +import * as list from './entities/list' +import * as marker from './entities/marker' +import * as mentition from './entities/mention' +import * as notification from './entities/notification' +import * as poll from './entities/poll' +import * as preferences from './entities/preferences' +import * as push_subscription from './entities/push_subscription' +import * as reaction from './entities/reaction' +import * as relationship from './entities/relationship' +import * as report from './entities/report' +import * as results from './entities/results' +import * as scheduled_status from './entities/scheduled_status' +import * as source from './entities/source' +import * as stats from './entities/stats' +import * as status from './entities/status' +import * as status_params from './entities/status_params' +import * as status_source from './entities/status_source' +import * as tag from './entities/tag' +import * as token from './entities/token' +import * as urls from './entities/urls' -export default PleromaEntity +export namespace Entity { + export type Account = account.Account + export type Activity = activity.Activity + export type Announcement = announcement.Announcement + export type Application = application.Application + export type AsyncAttachment = async_attachment.AsyncAttachment + export type Attachment = attachment.Attachment + export type Card = card.Card + export type Context = context.Context + export type Conversation = conversation.Conversation + export type Emoji = emoji.Emoji + export type FeaturedTag = featured_tag.FeaturedTag + export type Field = field.Field + export type Filter = filter.Filter + export type FilterContext = filter.FilterContext + export type History = history.History + export type IdentityProof = identity_proof.IdentityProof + export type Instance = instance.Instance + export type List = list.List + export type Marker = marker.Marker + export type Mention = mentition.Mention + export type Notification = notification.Notification + export type NotificationType = notification.NotificationType + export type Poll = poll.Poll + export type PollOption = poll.PollOption + export type Preferences = preferences.Preferences + export type PushSubscription = push_subscription.PushSubscription + export type Reaction = reaction.Reaction + export type Relationship = relationship.Relationship + export type Report = report.Report + export type Results = results.Results + export type ScheduledStatus = scheduled_status.ScheduledStatus + export type Source = source.Source + export type Stats = stats.Stats + export type Status = status.Status + export type StatusParams = status_params.StatusParams + export type StatusSource = status_source.StatusSource + export type Tag = tag.Tag + export type Token = token.Token + export type URLs = urls.URLs +} + +export default Entity From b51089a6b7cc25df0ca5087f7bb49a22dbc600a6 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 7 Oct 2023 21:48:13 +0900 Subject: [PATCH 5/6] Change namespace definition for friendica entity --- megalodon/src/friendica.ts | 2 +- megalodon/src/friendica/entities/account.ts | 55 +++++---- megalodon/src/friendica/entities/activity.ts | 12 +- .../src/friendica/entities/application.ts | 10 +- .../friendica/entities/async_attachment.ts | 25 ++-- .../src/friendica/entities/attachment.ts | 84 +++++++------ megalodon/src/friendica/entities/card.ts | 30 +++-- megalodon/src/friendica/entities/context.ts | 10 +- .../src/friendica/entities/conversation.ts | 16 ++- megalodon/src/friendica/entities/emoji.ts | 12 +- .../src/friendica/entities/featured_tag.ts | 12 +- megalodon/src/friendica/entities/field.ts | 10 +- megalodon/src/friendica/entities/filter.ts | 20 ++- .../src/friendica/entities/follow_request.ts | 48 ++++---- megalodon/src/friendica/entities/history.ts | 10 +- .../src/friendica/entities/identity_proof.ts | 14 +-- megalodon/src/friendica/entities/instance.ts | 48 ++++---- megalodon/src/friendica/entities/list.ts | 14 +-- megalodon/src/friendica/entities/marker.ts | 22 ++-- megalodon/src/friendica/entities/mention.ts | 12 +- .../src/friendica/entities/notification.ts | 22 ++-- megalodon/src/friendica/entities/poll.ts | 23 ++-- .../src/friendica/entities/poll_option.ts | 6 - .../src/friendica/entities/preferences.ts | 14 +-- .../friendica/entities/push_subscription.ts | 26 ++-- .../src/friendica/entities/relationship.ts | 30 +++-- megalodon/src/friendica/entities/report.ts | 26 ++-- megalodon/src/friendica/entities/results.ts | 16 ++- .../friendica/entities/scheduled_status.ts | 17 ++- megalodon/src/friendica/entities/source.ts | 17 ++- megalodon/src/friendica/entities/stats.ts | 10 +- megalodon/src/friendica/entities/status.ts | 88 +++++++------- .../src/friendica/entities/status_params.ts | 20 ++- .../src/friendica/entities/status_source.ts | 10 +- megalodon/src/friendica/entities/tag.ts | 14 +-- megalodon/src/friendica/entities/token.ts | 12 +- megalodon/src/friendica/entities/urls.ts | 6 +- megalodon/src/friendica/entity.ts | 114 ++++++++++++------ 38 files changed, 454 insertions(+), 483 deletions(-) delete mode 100644 megalodon/src/friendica/entities/poll_option.ts diff --git a/megalodon/src/friendica.ts b/megalodon/src/friendica.ts index 109ec0d44..4e7c27777 100644 --- a/megalodon/src/friendica.ts +++ b/megalodon/src/friendica.ts @@ -486,7 +486,7 @@ export default class Friendica implements MegalodonInterface { if (get_all && converted.headers.link) { let parsed = parseLinkHeader(converted.headers.link) while (parsed?.next) { - const nextRes = await this.client.get>(parsed?.next.url, undefined, undefined, true) + const nextRes = await this.client.get>(parsed?.next.url, undefined, undefined, true) converted = Object.assign({}, converted, { data: [...converted.data, ...nextRes.data.map(a => FriendicaAPI.Converter.account(a))] }) diff --git a/megalodon/src/friendica/entities/account.ts b/megalodon/src/friendica/entities/account.ts index 670a58371..dfd1afcdc 100644 --- a/megalodon/src/friendica/entities/account.ts +++ b/megalodon/src/friendica/entities/account.ts @@ -1,29 +1,28 @@ -/// -/// -/// -namespace FriendicaEntity { - export type Account = { - id: string - username: string - acct: string - display_name: string - locked: boolean - discoverable?: boolean - group: boolean | null - created_at: string - followers_count: number - following_count: number - statuses_count: number - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - emojis: Array - moved: Account | null - fields: Array - bot: boolean - source?: Source - } +import { Emoji } from './emoji' +import { Field } from './field' +import { Source } from './source' + +export type Account = { + id: string + username: string + acct: string + display_name: string + locked: boolean + discoverable?: boolean + group: boolean | null + created_at: string + followers_count: number + following_count: number + statuses_count: number + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + emojis: Array + moved: Account | null + fields: Array + bot: boolean + source?: Source } diff --git a/megalodon/src/friendica/entities/activity.ts b/megalodon/src/friendica/entities/activity.ts index 4db360d23..a174a5eb9 100644 --- a/megalodon/src/friendica/entities/activity.ts +++ b/megalodon/src/friendica/entities/activity.ts @@ -1,8 +1,6 @@ -namespace FriendicaEntity { - export type Activity = { - week: string - statuses: string - logins: string - registrations: string - } +export type Activity = { + week: string + statuses: string + logins: string + registrations: string } diff --git a/megalodon/src/friendica/entities/application.ts b/megalodon/src/friendica/entities/application.ts index 5e54ce82d..884caff81 100644 --- a/megalodon/src/friendica/entities/application.ts +++ b/megalodon/src/friendica/entities/application.ts @@ -1,7 +1,5 @@ -namespace FriendicaEntity { - export type Application = { - name: string - website?: string | null - vapid_key?: string | null - } +export type Application = { + name: string + website?: string | null + vapid_key?: string | null } diff --git a/megalodon/src/friendica/entities/async_attachment.ts b/megalodon/src/friendica/entities/async_attachment.ts index 76934af66..de3b1f8f6 100644 --- a/megalodon/src/friendica/entities/async_attachment.ts +++ b/megalodon/src/friendica/entities/async_attachment.ts @@ -1,14 +1,13 @@ -/// -namespace FriendicaEntity { - export type AsyncAttachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string | null - remote_url: string | null - preview_url: string - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +import { Meta } from './attachment' + +export type AsyncAttachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string | null + remote_url: string | null + preview_url: string + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/friendica/entities/attachment.ts b/megalodon/src/friendica/entities/attachment.ts index 04be0e72d..38d367642 100644 --- a/megalodon/src/friendica/entities/attachment.ts +++ b/megalodon/src/friendica/entities/attachment.ts @@ -1,49 +1,47 @@ -namespace FriendicaEntity { - export type Sub = { - // For Image, Gifv, and Video - width?: number - height?: number - size?: string - aspect?: number +export type Sub = { + // For Image, Gifv, and Video + width?: number + height?: number + size?: string + aspect?: number - // For Gifv and Video - frame_rate?: string + // For Gifv and Video + frame_rate?: string - // For Audio, Gifv, and Video - duration?: number - bitrate?: number - } + // For Audio, Gifv, and Video + duration?: number + bitrate?: number +} - export type Focus = { - x: number - y: number - } +export type Focus = { + x: number + y: number +} - export type Meta = { - original?: Sub - small?: Sub - focus?: Focus - length?: string - duration?: number - fps?: number - size?: string - width?: number - height?: number - aspect?: number - audio_encode?: string - audio_bitrate?: string - audio_channel?: string - } +export type Meta = { + original?: Sub + small?: Sub + focus?: Focus + length?: string + duration?: number + fps?: number + size?: string + width?: number + height?: number + aspect?: number + audio_encode?: string + audio_bitrate?: string + audio_channel?: string +} - export type Attachment = { - id: string - type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' - url: string - remote_url: string | null - preview_url: string | null - text_url: string | null - meta: Meta | null - description: string | null - blurhash: string | null - } +export type Attachment = { + id: string + type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' + url: string + remote_url: string | null + preview_url: string | null + text_url: string | null + meta: Meta | null + description: string | null + blurhash: string | null } diff --git a/megalodon/src/friendica/entities/card.ts b/megalodon/src/friendica/entities/card.ts index c23471983..042923528 100644 --- a/megalodon/src/friendica/entities/card.ts +++ b/megalodon/src/friendica/entities/card.ts @@ -1,17 +1,15 @@ -namespace FriendicaEntity { - export type Card = { - url: string - title: string - description: string - type: 'link' | 'photo' | 'video' | 'rich' - image: string | null - author_name: string - author_url: string - provider_name: string - provider_url: string - html: string - width: number - height: number - blurhash: string | null - } +export type Card = { + url: string + title: string + description: string + type: 'link' | 'photo' | 'video' | 'rich' + image: string | null + author_name: string + author_url: string + provider_name: string + provider_url: string + html: string + width: number + height: number + blurhash: string | null } diff --git a/megalodon/src/friendica/entities/context.ts b/megalodon/src/friendica/entities/context.ts index 9c977544a..14da5dd8d 100644 --- a/megalodon/src/friendica/entities/context.ts +++ b/megalodon/src/friendica/entities/context.ts @@ -1,8 +1,6 @@ -/// +import { Status } from './status' -namespace FriendicaEntity { - export type Context = { - ancestors: Array - descendants: Array - } +export type Context = { + ancestors: Array + descendants: Array } diff --git a/megalodon/src/friendica/entities/conversation.ts b/megalodon/src/friendica/entities/conversation.ts index 550ae7081..83b900bec 100644 --- a/megalodon/src/friendica/entities/conversation.ts +++ b/megalodon/src/friendica/entities/conversation.ts @@ -1,11 +1,9 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace FriendicaEntity { - export type Conversation = { - id: string - accounts: Array - last_status: Status | null - unread: boolean - } +export type Conversation = { + id: string + accounts: Array + last_status: Status | null + unread: boolean } diff --git a/megalodon/src/friendica/entities/emoji.ts b/megalodon/src/friendica/entities/emoji.ts index a0d92e6bc..2d383bbfb 100644 --- a/megalodon/src/friendica/entities/emoji.ts +++ b/megalodon/src/friendica/entities/emoji.ts @@ -1,8 +1,6 @@ -namespace FriendicaEntity { - export type Emoji = { - shortcode: string - static_url: string - url: string - visible_in_picker: boolean - } +export type Emoji = { + shortcode: string + static_url: string + url: string + visible_in_picker: boolean } diff --git a/megalodon/src/friendica/entities/featured_tag.ts b/megalodon/src/friendica/entities/featured_tag.ts index 14dd1a826..15ddd85b8 100644 --- a/megalodon/src/friendica/entities/featured_tag.ts +++ b/megalodon/src/friendica/entities/featured_tag.ts @@ -1,8 +1,6 @@ -namespace FriendicaEntity { - export type FeaturedTag = { - id: string - name: string - statuses_count: number - last_status_at: string - } +export type FeaturedTag = { + id: string + name: string + statuses_count: number + last_status_at: string } diff --git a/megalodon/src/friendica/entities/field.ts b/megalodon/src/friendica/entities/field.ts index 299ca0a45..88b9eea1e 100644 --- a/megalodon/src/friendica/entities/field.ts +++ b/megalodon/src/friendica/entities/field.ts @@ -1,7 +1,5 @@ -namespace FriendicaEntity { - export type Field = { - name: string - value: string - verified_at: string | null - } +export type Field = { + name: string + value: string + verified_at: string | null } diff --git a/megalodon/src/friendica/entities/filter.ts b/megalodon/src/friendica/entities/filter.ts index a71a936ab..cf1fa800e 100644 --- a/megalodon/src/friendica/entities/filter.ts +++ b/megalodon/src/friendica/entities/filter.ts @@ -1,12 +1,10 @@ -namespace FriendicaEntity { - export type Filter = { - id: string - phrase: string - context: Array - expires_at: string | null - irreversible: boolean - whole_word: boolean - } - - export type FilterContext = string +export type Filter = { + id: string + phrase: string + context: Array + expires_at: string | null + irreversible: boolean + whole_word: boolean } + +export type FilterContext = string diff --git a/megalodon/src/friendica/entities/follow_request.ts b/megalodon/src/friendica/entities/follow_request.ts index 83f5bf9ba..586c16be3 100644 --- a/megalodon/src/friendica/entities/follow_request.ts +++ b/megalodon/src/friendica/entities/follow_request.ts @@ -1,27 +1,25 @@ -/// -/// +import { Emoji } from './emoji' +import { Field } from './field' -namespace FriendicaEntity { - export type FollowRequest = { - id: number - username: string - acct: string - display_name: string - locked: boolean - bot: boolean - discoverable?: boolean - group: boolean - created_at: string - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - followers_count: number - following_count: number - statuses_count: number - emojis: Array - fields: Array - } +export type FollowRequest = { + id: number + username: string + acct: string + display_name: string + locked: boolean + bot: boolean + discoverable?: boolean + group: boolean + created_at: string + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + followers_count: number + following_count: number + statuses_count: number + emojis: Array + fields: Array } diff --git a/megalodon/src/friendica/entities/history.ts b/megalodon/src/friendica/entities/history.ts index 8f9cd6bd6..6d38a71f9 100644 --- a/megalodon/src/friendica/entities/history.ts +++ b/megalodon/src/friendica/entities/history.ts @@ -1,7 +1,5 @@ -namespace FriendicaEntity { - export type History = { - day: string - uses: number - accounts: number - } +export type History = { + day: string + uses: number + accounts: number } diff --git a/megalodon/src/friendica/entities/identity_proof.ts b/megalodon/src/friendica/entities/identity_proof.ts index fb6166c65..882cd5bfb 100644 --- a/megalodon/src/friendica/entities/identity_proof.ts +++ b/megalodon/src/friendica/entities/identity_proof.ts @@ -1,9 +1,7 @@ -namespace FriendicaEntity { - export type IdentityProof = { - provider: string - provider_username: string - updated_at: string - proof_url: string - profile_url: string - } +export type IdentityProof = { + provider: string + provider_username: string + updated_at: string + proof_url: string + profile_url: string } diff --git a/megalodon/src/friendica/entities/instance.ts b/megalodon/src/friendica/entities/instance.ts index a86390eb0..76c8fe2a3 100644 --- a/megalodon/src/friendica/entities/instance.ts +++ b/megalodon/src/friendica/entities/instance.ts @@ -1,28 +1,26 @@ -/// -/// -/// +import { URLs } from './urls' +import { Stats } from './stats' +import { Account } from './account' -namespace FriendicaEntity { - export type Instance = { - uri: string - title: string - description: string - email: string - version: string - thumbnail: string | null - urls: URLs | null - stats: Stats - languages: Array - registrations: boolean - approval_required: boolean - invites_enabled: boolean - max_toot_chars: number - contact_account: Account - rules: Array - } +export type Instance = { + uri: string + title: string + description: string + email: string + version: string + thumbnail: string | null + urls: URLs | null + stats: Stats + languages: Array + registrations: boolean + approval_required: boolean + invites_enabled: boolean + max_toot_chars: number + contact_account: Account + rules: Array +} - export type InstanceRule = { - id: string - text: string - } +export type InstanceRule = { + id: string + text: string } diff --git a/megalodon/src/friendica/entities/list.ts b/megalodon/src/friendica/entities/list.ts index 90487aec2..03274012b 100644 --- a/megalodon/src/friendica/entities/list.ts +++ b/megalodon/src/friendica/entities/list.ts @@ -1,9 +1,7 @@ -namespace FriendicaEntity { - export type List = { - id: string - title: string - replies_policy: RepliesPolicy - } - - export type RepliesPolicy = 'followed' | 'list' | 'none' +export type List = { + id: string + title: string + replies_policy: RepliesPolicy } + +export type RepliesPolicy = 'followed' | 'list' | 'none' diff --git a/megalodon/src/friendica/entities/marker.ts b/megalodon/src/friendica/entities/marker.ts index 4ec41a07d..e347a09d3 100644 --- a/megalodon/src/friendica/entities/marker.ts +++ b/megalodon/src/friendica/entities/marker.ts @@ -1,14 +1,12 @@ -namespace FriendicaEntity { - export type Marker = { - home: { - last_read_id: string - version: number - updated_at: string - } - notifications: { - last_read_id: string - version: number - updated_at: string - } +export type Marker = { + home: { + last_read_id: string + version: number + updated_at: string + } + notifications: { + last_read_id: string + version: number + updated_at: string } } diff --git a/megalodon/src/friendica/entities/mention.ts b/megalodon/src/friendica/entities/mention.ts index 0e93333fe..098633673 100644 --- a/megalodon/src/friendica/entities/mention.ts +++ b/megalodon/src/friendica/entities/mention.ts @@ -1,8 +1,6 @@ -namespace FriendicaEntity { - export type Mention = { - id: string - username: string - url: string - acct: string - } +export type Mention = { + id: string + username: string + url: string + acct: string } diff --git a/megalodon/src/friendica/entities/notification.ts b/megalodon/src/friendica/entities/notification.ts index acdbfb927..b33b53c8b 100644 --- a/megalodon/src/friendica/entities/notification.ts +++ b/megalodon/src/friendica/entities/notification.ts @@ -1,14 +1,12 @@ -/// -/// +import { Account } from './account' +import { Status } from './status' -namespace FriendicaEntity { - export type Notification = { - account: Account - created_at: string - id: string - status?: Status - type: NotificationType - } - - export type NotificationType = string +export type Notification = { + account: Account + created_at: string + id: string + status?: Status + type: NotificationType } + +export type NotificationType = string diff --git a/megalodon/src/friendica/entities/poll.ts b/megalodon/src/friendica/entities/poll.ts index 4ac2262c5..d8861108e 100644 --- a/megalodon/src/friendica/entities/poll.ts +++ b/megalodon/src/friendica/entities/poll.ts @@ -1,13 +1,14 @@ -/// +export type Poll = { + id: string + expires_at: string | null + expired: boolean + multiple: boolean + votes_count: number + options: Array + voted: boolean +} -namespace FriendicaEntity { - export type Poll = { - id: string - expires_at: string | null - expired: boolean - multiple: boolean - votes_count: number - options: Array - voted: boolean - } +export type PollOption = { + title: string + votes_count: number | null } diff --git a/megalodon/src/friendica/entities/poll_option.ts b/megalodon/src/friendica/entities/poll_option.ts deleted file mode 100644 index f9628ddd8..000000000 --- a/megalodon/src/friendica/entities/poll_option.ts +++ /dev/null @@ -1,6 +0,0 @@ -namespace FriendicaEntity { - export type PollOption = { - title: string - votes_count: number | null - } -} diff --git a/megalodon/src/friendica/entities/preferences.ts b/megalodon/src/friendica/entities/preferences.ts index dec8b511b..e0646f6de 100644 --- a/megalodon/src/friendica/entities/preferences.ts +++ b/megalodon/src/friendica/entities/preferences.ts @@ -1,9 +1,7 @@ -namespace FriendicaEntity { - export type Preferences = { - 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' - 'posting:default:sensitive': boolean - 'posting:default:language': string | null - 'reading:expand:media': 'default' | 'show_all' | 'hide_all' - 'reading:expand:spoilers': boolean - } +export type Preferences = { + 'posting:default:visibility': 'public' | 'unlisted' | 'private' | 'direct' + 'posting:default:sensitive': boolean + 'posting:default:language': string | null + 'reading:expand:media': 'default' | 'show_all' | 'hide_all' + 'reading:expand:spoilers': boolean } diff --git a/megalodon/src/friendica/entities/push_subscription.ts b/megalodon/src/friendica/entities/push_subscription.ts index 857a98f27..ae440143b 100644 --- a/megalodon/src/friendica/entities/push_subscription.ts +++ b/megalodon/src/friendica/entities/push_subscription.ts @@ -1,16 +1,14 @@ -namespace FriendicaEntity { - export type Alerts = { - follow: boolean - favourite: boolean - mention: boolean - reblog: boolean - poll: boolean - } +export type Alerts = { + follow: boolean + favourite: boolean + mention: boolean + reblog: boolean + poll: boolean +} - export type PushSubscription = { - id: string - endpoint: string - server_key: string - alerts: Alerts - } +export type PushSubscription = { + id: string + endpoint: string + server_key: string + alerts: Alerts } diff --git a/megalodon/src/friendica/entities/relationship.ts b/megalodon/src/friendica/entities/relationship.ts index bba3099a8..36dcf0c1a 100644 --- a/megalodon/src/friendica/entities/relationship.ts +++ b/megalodon/src/friendica/entities/relationship.ts @@ -1,17 +1,15 @@ -namespace FriendicaEntity { - export type Relationship = { - id: string - following: boolean - followed_by: boolean - blocking: boolean - blocked_by: boolean - muting: boolean - muting_notifications: boolean - requested: boolean - domain_blocking: boolean - showing_reblogs: boolean - endorsed: boolean - notifying: boolean - note: string | null - } +export type Relationship = { + id: string + following: boolean + followed_by: boolean + blocking: boolean + blocked_by: boolean + muting: boolean + muting_notifications: boolean + requested: boolean + domain_blocking: boolean + showing_reblogs: boolean + endorsed: boolean + notifying: boolean + note: string | null } diff --git a/megalodon/src/friendica/entities/report.ts b/megalodon/src/friendica/entities/report.ts index f20d6d2db..c4fffbb23 100644 --- a/megalodon/src/friendica/entities/report.ts +++ b/megalodon/src/friendica/entities/report.ts @@ -1,16 +1,14 @@ -/// +import { Account } from './account' -namespace FriendicaEntity { - export type Report = { - id: string - action_taken: boolean - category: Category - comment: string - forwarded: boolean - status_ids: Array | null - rule_ids: Array | null - target_account: Account - } - - export type Category = 'spam' | 'violation' | 'other' +export type Report = { + id: string + action_taken: boolean + category: Category + comment: string + forwarded: boolean + status_ids: Array | null + rule_ids: Array | null + target_account: Account } + +export type Category = 'spam' | 'violation' | 'other' diff --git a/megalodon/src/friendica/entities/results.ts b/megalodon/src/friendica/entities/results.ts index 7af235657..17ee9190b 100644 --- a/megalodon/src/friendica/entities/results.ts +++ b/megalodon/src/friendica/entities/results.ts @@ -1,11 +1,9 @@ -/// -/// -/// +import { Account } from './account' +import { Status } from './status' +import { Tag } from './tag' -namespace FriendicaEntity { - export type Results = { - accounts: Array - statuses: Array - hashtags: Array - } +export type Results = { + accounts: Array + statuses: Array + hashtags: Array } diff --git a/megalodon/src/friendica/entities/scheduled_status.ts b/megalodon/src/friendica/entities/scheduled_status.ts index da292f700..68932fafb 100644 --- a/megalodon/src/friendica/entities/scheduled_status.ts +++ b/megalodon/src/friendica/entities/scheduled_status.ts @@ -1,10 +1,9 @@ -/// -/// -namespace FriendicaEntity { - export type ScheduledStatus = { - id: string - scheduled_at: string - params: StatusParams - media_attachments: Array - } +import { Attachment } from './attachment' +import { StatusParams } from './status_params' + +export type ScheduledStatus = { + id: string + scheduled_at: string + params: StatusParams + media_attachments: Array } diff --git a/megalodon/src/friendica/entities/source.ts b/megalodon/src/friendica/entities/source.ts index 4033e911e..a82203909 100644 --- a/megalodon/src/friendica/entities/source.ts +++ b/megalodon/src/friendica/entities/source.ts @@ -1,10 +1,9 @@ -/// -namespace FriendicaEntity { - export type Source = { - privacy: string | null - sensitive: boolean | null - language: string | null - note: string - fields: Array - } +import { Field } from './field' + +export type Source = { + privacy: string | null + sensitive: boolean | null + language: string | null + note: string + fields: Array } diff --git a/megalodon/src/friendica/entities/stats.ts b/megalodon/src/friendica/entities/stats.ts index 8ef290b7b..b8a8db853 100644 --- a/megalodon/src/friendica/entities/stats.ts +++ b/megalodon/src/friendica/entities/stats.ts @@ -1,7 +1,5 @@ -namespace FriendicaEntity { - export type Stats = { - user_count: number - status_count: number - domain_count: number - } +export type Stats = { + user_count: number + status_count: number + domain_count: number } diff --git a/megalodon/src/friendica/entities/status.ts b/megalodon/src/friendica/entities/status.ts index 9d2e8b966..3b35c1af6 100644 --- a/megalodon/src/friendica/entities/status.ts +++ b/megalodon/src/friendica/entities/status.ts @@ -1,48 +1,46 @@ -/// -/// -/// -/// -/// -/// -/// +import { Account } from './account' +import { Emoji } from './emoji' +import { Attachment } from './attachment' +import { Application } from './application' +import { Mention } from './mention' +import { Card } from './card' +import { Poll } from './poll' -namespace FriendicaEntity { - export type Status = { - id: string - uri: string - url: string - account: Account - in_reply_to_id: string | null - in_reply_to_account_id: string | null - reblog: Status | null - content: string - created_at: string - emojis: Emoji[] - replies_count: number - reblogs_count: number - favourites_count: number - reblogged: boolean | null - favourited: boolean | null - muted: boolean | null - sensitive: boolean - spoiler_text: string - visibility: 'public' | 'unlisted' | 'private' | 'direct' - media_attachments: Array - mentions: Array - tags: Array - card: Card | null - poll: Poll | null - application: Application | null - language: string | null - pinned: boolean | null - bookmarked?: boolean - // These parameters are unique parameters in fedibird.com for quote. - quote_id?: string - quote?: Status | null - } +export type Status = { + id: string + uri: string + url: string + account: Account + in_reply_to_id: string | null + in_reply_to_account_id: string | null + reblog: Status | null + content: string + created_at: string + emojis: Emoji[] + replies_count: number + reblogs_count: number + favourites_count: number + reblogged: boolean | null + favourited: boolean | null + muted: boolean | null + sensitive: boolean + spoiler_text: string + visibility: 'public' | 'unlisted' | 'private' | 'direct' + media_attachments: Array + mentions: Array + tags: Array + card: Card | null + poll: Poll | null + application: Application | null + language: string | null + pinned: boolean | null + bookmarked?: boolean + // These parameters are unique parameters in fedibird.com for quote. + quote_id?: string + quote?: Status | null +} - export type StatusTag = { - name: string - url: string - } +export type StatusTag = { + name: string + url: string } diff --git a/megalodon/src/friendica/entities/status_params.ts b/megalodon/src/friendica/entities/status_params.ts index 6a14af837..eecb3bb79 100644 --- a/megalodon/src/friendica/entities/status_params.ts +++ b/megalodon/src/friendica/entities/status_params.ts @@ -1,12 +1,10 @@ -namespace FriendicaEntity { - export type StatusParams = { - text: string - in_reply_to_id: string | null - media_ids: Array | null - sensitive: boolean | null - spoiler_text: string | null - visibility: 'public' | 'unlisted' | 'private' | null - scheduled_at: string | null - application_id: string - } +export type StatusParams = { + text: string + in_reply_to_id: string | null + media_ids: Array | null + sensitive: boolean | null + spoiler_text: string | null + visibility: 'public' | 'unlisted' | 'private' | null + scheduled_at: string | null + application_id: string } diff --git a/megalodon/src/friendica/entities/status_source.ts b/megalodon/src/friendica/entities/status_source.ts index 2b5ee9bd0..82103f9a1 100644 --- a/megalodon/src/friendica/entities/status_source.ts +++ b/megalodon/src/friendica/entities/status_source.ts @@ -1,7 +1,5 @@ -namespace FriendicaEntity { - export type StatusSource = { - id: string - text: string - spoiler_text: string - } +export type StatusSource = { + id: string + text: string + spoiler_text: string } diff --git a/megalodon/src/friendica/entities/tag.ts b/megalodon/src/friendica/entities/tag.ts index f7998d22f..2fae1efbe 100644 --- a/megalodon/src/friendica/entities/tag.ts +++ b/megalodon/src/friendica/entities/tag.ts @@ -1,10 +1,8 @@ -/// +import { History } from './history' -namespace FriendicaEntity { - export type Tag = { - name: string - url: string - history: Array - following?: boolean - } +export type Tag = { + name: string + url: string + history: Array + following?: boolean } diff --git a/megalodon/src/friendica/entities/token.ts b/megalodon/src/friendica/entities/token.ts index 904d68651..9cf3c1508 100644 --- a/megalodon/src/friendica/entities/token.ts +++ b/megalodon/src/friendica/entities/token.ts @@ -1,8 +1,6 @@ -namespace FriendicaEntity { - export type Token = { - access_token: string - token_type: string - scope: string - created_at: number - } +export type Token = { + access_token: string + token_type: string + scope: string + created_at: number } diff --git a/megalodon/src/friendica/entities/urls.ts b/megalodon/src/friendica/entities/urls.ts index 8c736b9ef..5c1087420 100644 --- a/megalodon/src/friendica/entities/urls.ts +++ b/megalodon/src/friendica/entities/urls.ts @@ -1,5 +1,3 @@ -namespace FriendicaEntity { - export type URLs = { - streaming_api: string - } +export type URLs = { + streaming_api: string } diff --git a/megalodon/src/friendica/entity.ts b/megalodon/src/friendica/entity.ts index 6d64f061c..b2164281d 100644 --- a/megalodon/src/friendica/entity.ts +++ b/megalodon/src/friendica/entity.ts @@ -1,38 +1,78 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +import * as account from './entities/account' +import * as activity from './entities/activity' +import * as application from './entities/application' +import * as async_attachment from './entities/async_attachment' +import * as attachment from './entities/attachment' +import * as card from './entities/card' +import * as context from './entities/context' +import * as conversation from './entities/conversation' +import * as emoji from './entities/emoji' +import * as featured_tag from './entities/featured_tag' +import * as follow_request from './entities/follow_request' +import * as field from './entities/field' +import * as filter from './entities/filter' +import * as history from './entities/history' +import * as identity_proof from './entities/identity_proof' +import * as instance from './entities/instance' +import * as list from './entities/list' +import * as marker from './entities/marker' +import * as mentition from './entities/mention' +import * as notification from './entities/notification' +import * as poll from './entities/poll' +import * as preferences from './entities/preferences' +import * as push_subscription from './entities/push_subscription' +import * as relationship from './entities/relationship' +import * as report from './entities/report' +import * as results from './entities/results' +import * as scheduled_status from './entities/scheduled_status' +import * as source from './entities/source' +import * as stats from './entities/stats' +import * as status from './entities/status' +import * as status_params from './entities/status_params' +import * as status_source from './entities/status_source' +import * as tag from './entities/tag' +import * as token from './entities/token' +import * as urls from './entities/urls' -export default FriendicaEntity +export namespace Entity { + export type Account = account.Account + export type Activity = activity.Activity + export type Application = application.Application + export type AsyncAttachment = async_attachment.AsyncAttachment + export type Attachment = attachment.Attachment + export type Card = card.Card + export type Context = context.Context + export type Conversation = conversation.Conversation + export type Emoji = emoji.Emoji + export type FeaturedTag = featured_tag.FeaturedTag + export type Field = field.Field + export type Filter = filter.Filter + export type FilterContext = filter.FilterContext + export type FollowRequest = follow_request.FollowRequest + export type History = history.History + export type IdentityProof = identity_proof.IdentityProof + export type Instance = instance.Instance + export type List = list.List + export type Marker = marker.Marker + export type Mention = mentition.Mention + export type Notification = notification.Notification + export type NotificationType = notification.NotificationType + export type Poll = poll.Poll + export type PollOption = poll.PollOption + export type Preferences = preferences.Preferences + export type PushSubscription = push_subscription.PushSubscription + export type Relationship = relationship.Relationship + export type Report = report.Report + export type Results = results.Results + export type ScheduledStatus = scheduled_status.ScheduledStatus + export type Source = source.Source + export type Stats = stats.Stats + export type Status = status.Status + export type StatusParams = status_params.StatusParams + export type StatusSource = status_source.StatusSource + export type Tag = tag.Tag + export type Token = token.Token + export type URLs = urls.URLs +} + +export default Entity From 1b7df2dfbe2cc9d43bcf508b800609688eda36a1 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Sat, 7 Oct 2023 22:57:56 +0900 Subject: [PATCH 6/6] Change namespace definition for firefish entity --- megalodon/src/firefish.ts | 8 +- .../src/firefish/entities/announcement.ts | 18 ++- megalodon/src/firefish/entities/app.ts | 16 +-- megalodon/src/firefish/entities/blocking.ts | 14 +- .../src/firefish/entities/createdNote.ts | 8 +- megalodon/src/firefish/entities/emoji.ts | 10 +- megalodon/src/firefish/entities/favorite.ts | 14 +- megalodon/src/firefish/entities/field.ts | 10 +- megalodon/src/firefish/entities/file.ts | 34 +++-- megalodon/src/firefish/entities/follow.ts | 18 ++- .../src/firefish/entities/followRequest.ts | 12 +- megalodon/src/firefish/entities/hashtag.ts | 6 +- megalodon/src/firefish/entities/instance.ts | 132 +++++++++--------- megalodon/src/firefish/entities/list.ts | 12 +- megalodon/src/firefish/entities/meta.ts | 50 ++++--- megalodon/src/firefish/entities/mute.ts | 14 +- megalodon/src/firefish/entities/note.ts | 56 ++++---- .../src/firefish/entities/notification.ts | 26 ++-- megalodon/src/firefish/entities/poll.ts | 20 ++- megalodon/src/firefish/entities/reaction.ts | 14 +- megalodon/src/firefish/entities/relation.ts | 22 ++- megalodon/src/firefish/entities/session.ts | 8 +- megalodon/src/firefish/entities/stats.ts | 14 +- megalodon/src/firefish/entities/user.ts | 34 +++-- megalodon/src/firefish/entities/userDetail.ts | 92 ++++++------ megalodon/src/firefish/entity.ts | 80 +++++++---- 26 files changed, 362 insertions(+), 380 deletions(-) diff --git a/megalodon/src/firefish.ts b/megalodon/src/firefish.ts index 1e54b4faf..ef5ca52ad 100644 --- a/megalodon/src/firefish.ts +++ b/megalodon/src/firefish.ts @@ -1972,7 +1972,7 @@ export default class Firefish implements MegalodonInterface { account_id?: string exclude_unreviewed?: boolean } - ): Promise> { + ): Promise> { let params = { query: q } @@ -2010,7 +2010,7 @@ export default class Firefish implements MegalodonInterface { account_id?: string exclude_unreviewed?: boolean } - ): Promise> { + ): Promise> { let params = { query: q } @@ -2092,13 +2092,13 @@ export default class Firefish implements MegalodonInterface { exclude_unreviewed?: boolean } ): Promise> { - let accounts: Array = [] + let accounts: Array = [] try { accounts = await this.searchAccounts(q, options) } catch (e) { console.warn(e) } - let statuses: Array = [] + let statuses: Array = [] try { statuses = await this.searchStatuses(q, options) } catch (e) { diff --git a/megalodon/src/firefish/entities/announcement.ts b/megalodon/src/firefish/entities/announcement.ts index f470b0680..383a90a0c 100644 --- a/megalodon/src/firefish/entities/announcement.ts +++ b/megalodon/src/firefish/entities/announcement.ts @@ -1,11 +1,9 @@ -namespace FirefishEntity { - export type Announcement = { - id: string - createdAt: string - updatedAt: string | null - text: string - title: string - imageurl: string | null - isRead?: boolean - } +export type Announcement = { + id: string + createdAt: string + updatedAt: string | null + text: string + title: string + imageurl: string | null + isRead?: boolean } diff --git a/megalodon/src/firefish/entities/app.ts b/megalodon/src/firefish/entities/app.ts index 6e2bd346a..0906bf256 100644 --- a/megalodon/src/firefish/entities/app.ts +++ b/megalodon/src/firefish/entities/app.ts @@ -1,10 +1,8 @@ -namespace FirefishEntity { - export type App = { - id: string - name: string - callbackUrl: string | null - permission: Array - secret?: string - isAuthorized?: boolean - } +export type App = { + id: string + name: string + callbackUrl: string | null + permission: Array + secret?: string + isAuthorized?: boolean } diff --git a/megalodon/src/firefish/entities/blocking.ts b/megalodon/src/firefish/entities/blocking.ts index 0514b0359..0bd3a8a04 100644 --- a/megalodon/src/firefish/entities/blocking.ts +++ b/megalodon/src/firefish/entities/blocking.ts @@ -1,10 +1,8 @@ -/// +import { UserDetail } from './userDetail' -namespace FirefishEntity { - export type Blocking = { - id: string - createdAt: string - blockeeId: string - blockee: UserDetail - } +export type Blocking = { + id: string + createdAt: string + blockeeId: string + blockee: UserDetail } diff --git a/megalodon/src/firefish/entities/createdNote.ts b/megalodon/src/firefish/entities/createdNote.ts index 2e58aa6db..aec065395 100644 --- a/megalodon/src/firefish/entities/createdNote.ts +++ b/megalodon/src/firefish/entities/createdNote.ts @@ -1,7 +1,5 @@ -/// +import { Note } from './note' -namespace FirefishEntity { - export type CreatedNote = { - createdNote: Note - } +export type CreatedNote = { + createdNote: Note } diff --git a/megalodon/src/firefish/entities/emoji.ts b/megalodon/src/firefish/entities/emoji.ts index a97c8c61a..079b368f5 100644 --- a/megalodon/src/firefish/entities/emoji.ts +++ b/megalodon/src/firefish/entities/emoji.ts @@ -1,7 +1,5 @@ -namespace FirefishEntity { - export type Emoji = { - name: string - url: string - category: string | null - } +export type Emoji = { + name: string + url: string + category: string | null } diff --git a/megalodon/src/firefish/entities/favorite.ts b/megalodon/src/firefish/entities/favorite.ts index 4d7c14ddf..8dc63730d 100644 --- a/megalodon/src/firefish/entities/favorite.ts +++ b/megalodon/src/firefish/entities/favorite.ts @@ -1,10 +1,8 @@ -/// +import { Note } from './note' -namespace FirefishEntity { - export type Favorite = { - id: string - createdAt: string - noteId: string - note: Note - } +export type Favorite = { + id: string + createdAt: string + noteId: string + note: Note } diff --git a/megalodon/src/firefish/entities/field.ts b/megalodon/src/firefish/entities/field.ts index 66a08f53f..8dc9706f9 100644 --- a/megalodon/src/firefish/entities/field.ts +++ b/megalodon/src/firefish/entities/field.ts @@ -1,7 +1,5 @@ -namespace FirefishEntity { - export type Field = { - name: string - value: string - verified?: boolean - } +export type Field = { + name: string + value: string + verified?: boolean } diff --git a/megalodon/src/firefish/entities/file.ts b/megalodon/src/firefish/entities/file.ts index 4d216e810..425aaa484 100644 --- a/megalodon/src/firefish/entities/file.ts +++ b/megalodon/src/firefish/entities/file.ts @@ -1,20 +1,18 @@ -namespace FirefishEntity { - export type File = { - id: string - createdAt: string - name: string - type: string - md5: string - size: number - isSensitive: boolean - blurhash: string | null - properties: { - width?: number - height?: number - avgColor?: string - } - url: string | null - thumbnailUrl: string | null - comment: string | null +export type File = { + id: string + createdAt: string + name: string + type: string + md5: string + size: number + isSensitive: boolean + blurhash: string | null + properties: { + width?: number + height?: number + avgColor?: string } + url: string | null + thumbnailUrl: string | null + comment: string | null } diff --git a/megalodon/src/firefish/entities/follow.ts b/megalodon/src/firefish/entities/follow.ts index 5567670e7..5726b6daf 100644 --- a/megalodon/src/firefish/entities/follow.ts +++ b/megalodon/src/firefish/entities/follow.ts @@ -1,12 +1,10 @@ -/// +import { UserDetail } from './userDetail' -namespace FirefishEntity { - export type Follow = { - id: string - createdAt: string - followeeId: string - followerId: string - follower: UserDetail - followee: UserDetail - } +export type Follow = { + id: string + createdAt: string + followeeId: string + followerId: string + follower: UserDetail + followee: UserDetail } diff --git a/megalodon/src/firefish/entities/followRequest.ts b/megalodon/src/firefish/entities/followRequest.ts index 71a14abc1..eec1c3c84 100644 --- a/megalodon/src/firefish/entities/followRequest.ts +++ b/megalodon/src/firefish/entities/followRequest.ts @@ -1,9 +1,7 @@ -/// +import { User } from './user' -namespace FirefishEntity { - export type FollowRequest = { - id: string - follower: User - followee: User - } +export type FollowRequest = { + id: string + follower: User + followee: User } diff --git a/megalodon/src/firefish/entities/hashtag.ts b/megalodon/src/firefish/entities/hashtag.ts index 93a3df1b0..7c49e3dcd 100644 --- a/megalodon/src/firefish/entities/hashtag.ts +++ b/megalodon/src/firefish/entities/hashtag.ts @@ -1,5 +1,3 @@ -namespace FirefishEntity { - export type Hashtag = { - tag: string - } +export type Hashtag = { + tag: string } diff --git a/megalodon/src/firefish/entities/instance.ts b/megalodon/src/firefish/entities/instance.ts index 2171fed7a..d31f56afe 100644 --- a/megalodon/src/firefish/entities/instance.ts +++ b/megalodon/src/firefish/entities/instance.ts @@ -1,75 +1,73 @@ -/// +import { Field } from './field' -namespace FirefishEntity { - export type URLs = { - streaming_api: string - } +export type URLs = { + streaming_api: string +} - export type AccountEmoji = { - shortcode: string - static_url: string - url: string - visible_in_picker: boolean - } +export type AccountEmoji = { + shortcode: string + static_url: string + url: string + visible_in_picker: boolean +} - export type Instance = { - uri: string - title: string - short_description: string - description: string - email: string - version: string - urls: URLs - stats: { - user_count: number - status_count: number - domain_count: number +export type Instance = { + uri: string + title: string + short_description: string + description: string + email: string + version: string + urls: URLs + stats: { + user_count: number + status_count: number + domain_count: number + } + thumbnail: string | null + languages: Array + registrations: boolean + approval_required: boolean + invites_enabled: boolean + configuration: { + statuses: { + max_characters: number + max_media_attachments: number + characters_reserved_per_url: number } - thumbnail: string | null - languages: Array - registrations: boolean - approval_required: boolean - invites_enabled: boolean - configuration: { - statuses: { - max_characters: number - max_media_attachments: number - characters_reserved_per_url: number - } - media_attachments: { - supported_mime_types: Array - image_size_limit: number - image_matrix_limit: number - video_size_limit: number - video_frame_rate_limit: number - video_matrix_limit: number - } - polls: { - max_options: number - max_characters_per_option: number - min_expiration: number - max_expiration: number - } + media_attachments: { + supported_mime_types: Array + image_size_limit: number + image_matrix_limit: number + video_size_limit: number + video_frame_rate_limit: number + video_matrix_limit: number } - contact_account: { - id: string - username: string - acct: string - display_name: string - locked: boolean - created_at: string - followers_count: number - following_count: number - statuses_count: number - note: string - url: string - avatar: string - avatar_static: string - header: string - header_static: string - emojis: Array - fields: Array - bot: boolean + polls: { + max_options: number + max_characters_per_option: number + min_expiration: number + max_expiration: number } } + contact_account: { + id: string + username: string + acct: string + display_name: string + locked: boolean + created_at: string + followers_count: number + following_count: number + statuses_count: number + note: string + url: string + avatar: string + avatar_static: string + header: string + header_static: string + emojis: Array + fields: Array + bot: boolean + } } diff --git a/megalodon/src/firefish/entities/list.ts b/megalodon/src/firefish/entities/list.ts index e81a27d10..23ea5906a 100644 --- a/megalodon/src/firefish/entities/list.ts +++ b/megalodon/src/firefish/entities/list.ts @@ -1,8 +1,6 @@ -namespace FirefishEntity { - export type List = { - id: string - createdAt: string - name: string - userIds?: Array - } +export type List = { + id: string + createdAt: string + name: string + userIds?: Array } diff --git a/megalodon/src/firefish/entities/meta.ts b/megalodon/src/firefish/entities/meta.ts index 3a5a52731..728be9430 100644 --- a/megalodon/src/firefish/entities/meta.ts +++ b/megalodon/src/firefish/entities/meta.ts @@ -1,29 +1,27 @@ -/// +import { Emoji } from './emoji' -namespace FirefishEntity { - export type Meta = { - maintainerName: string | null - maintainerEmail: string | null - name: string - version: string - uri: string - description: string | null - langs: Array - disableRegistration: boolean - disableLocalTimeline: boolean - bannerUrl: string - maxNoteTextLength: number - emojis: Array - features: { - registration: boolean - emailRequiredForSignup: boolean - elasticsearch: boolean - hcaptcha: boolean - recaptcha: boolean - turnstile: boolean - objectStorage: boolean - serviceWorker: boolean - miauth: boolean - } +export type Meta = { + maintainerName: string | null + maintainerEmail: string | null + name: string + version: string + uri: string + description: string | null + langs: Array + disableRegistration: boolean + disableLocalTimeline: boolean + bannerUrl: string + maxNoteTextLength: number + emojis: Array + features: { + registration: boolean + emailRequiredForSignup: boolean + elasticsearch: boolean + hcaptcha: boolean + recaptcha: boolean + turnstile: boolean + objectStorage: boolean + serviceWorker: boolean + miauth: boolean } } diff --git a/megalodon/src/firefish/entities/mute.ts b/megalodon/src/firefish/entities/mute.ts index bbc497276..9bfecfe36 100644 --- a/megalodon/src/firefish/entities/mute.ts +++ b/megalodon/src/firefish/entities/mute.ts @@ -1,10 +1,8 @@ -/// +import { UserDetail } from './userDetail' -namespace FirefishEntity { - export type Mute = { - id: string - createdAt: string - muteeId: string - mutee: UserDetail - } +export type Mute = { + id: string + createdAt: string + muteeId: string + mutee: UserDetail } diff --git a/megalodon/src/firefish/entities/note.ts b/megalodon/src/firefish/entities/note.ts index 47ea48202..700279deb 100644 --- a/megalodon/src/firefish/entities/note.ts +++ b/megalodon/src/firefish/entities/note.ts @@ -1,31 +1,29 @@ -/// -/// -/// -/// +import { User } from './user' +import { Emoji } from './emoji' +import { File } from './file' +import { Poll } from './poll' -namespace FirefishEntity { - export type Note = { - id: string - createdAt: string - userId: string - user: User - text: string | null - cw?: string | null - visibility: 'public' | 'home' | 'followers' | 'specified' | 'hidden' - renoteCount: number - repliesCount: number - reactions: { [key: string]: number } - emojis?: Array | null - fileIds?: Array - files?: Array - replyId?: string | null - renoteId?: string | null - uri?: string - reply?: Note - renote?: Note - tags?: Array - poll?: Poll | null - mentions?: Array - myReaction?: string | null - } +export type Note = { + id: string + createdAt: string + userId: string + user: User + text: string | null + cw?: string | null + visibility: 'public' | 'home' | 'followers' | 'specified' | 'hidden' + renoteCount: number + repliesCount: number + reactions: { [key: string]: number } + emojis?: Array | null + fileIds?: Array + files?: Array + replyId?: string | null + renoteId?: string | null + uri?: string + reply?: Note + renote?: Note + tags?: Array + poll?: Poll | null + mentions?: Array + myReaction?: string | null } diff --git a/megalodon/src/firefish/entities/notification.ts b/megalodon/src/firefish/entities/notification.ts index 9b693248a..a9ddfbfd6 100644 --- a/megalodon/src/firefish/entities/notification.ts +++ b/megalodon/src/firefish/entities/notification.ts @@ -1,16 +1,14 @@ -/// -/// +import { User } from './user' +import { Note } from './note' -namespace FirefishEntity { - export type Notification = { - id: string - createdAt: string - type: NotificationType - userId?: string | null - user?: User - note?: Note - reaction?: string | null - } - - export type NotificationType = string +export type Notification = { + id: string + createdAt: string + type: NotificationType + userId?: string | null + user?: User + note?: Note + reaction?: string | null } + +export type NotificationType = string diff --git a/megalodon/src/firefish/entities/poll.ts b/megalodon/src/firefish/entities/poll.ts index 16f6bcb15..eec760434 100644 --- a/megalodon/src/firefish/entities/poll.ts +++ b/megalodon/src/firefish/entities/poll.ts @@ -1,13 +1,11 @@ -namespace FirefishEntity { - export type Choice = { - text: string - votes: number - isVoted?: boolean - } +export type Choice = { + text: string + votes: number + isVoted?: boolean +} - export type Poll = { - multiple: boolean - expiresAt: string - choices: Array - } +export type Poll = { + multiple: boolean + expiresAt: string + choices: Array } diff --git a/megalodon/src/firefish/entities/reaction.ts b/megalodon/src/firefish/entities/reaction.ts index 5ebfeaff7..ed5f9cd39 100644 --- a/megalodon/src/firefish/entities/reaction.ts +++ b/megalodon/src/firefish/entities/reaction.ts @@ -1,10 +1,8 @@ -/// +import { User } from './user' -namespace FirefishEntity { - export type Reaction = { - id: string - createdAt: string - user: User - type: string - } +export type Reaction = { + id: string + createdAt: string + user: User + type: string } diff --git a/megalodon/src/firefish/entities/relation.ts b/megalodon/src/firefish/entities/relation.ts index a2444a414..9516b954b 100644 --- a/megalodon/src/firefish/entities/relation.ts +++ b/megalodon/src/firefish/entities/relation.ts @@ -1,13 +1,11 @@ -namespace FirefishEntity { - export type Relation = { - id: string - isFollowing: boolean - hasPendingFollowRequestFromYou: boolean - hasPendingFollowRequestToYou: boolean - isFollowed: boolean - isBlocking: boolean - isBlocked: boolean - isMuted: boolean - isRenoteMuted: boolean - } +export type Relation = { + id: string + isFollowing: boolean + hasPendingFollowRequestFromYou: boolean + hasPendingFollowRequestToYou: boolean + isFollowed: boolean + isBlocking: boolean + isBlocked: boolean + isMuted: boolean + isRenoteMuted: boolean } diff --git a/megalodon/src/firefish/entities/session.ts b/megalodon/src/firefish/entities/session.ts index ca86820ab..980e4a1a9 100644 --- a/megalodon/src/firefish/entities/session.ts +++ b/megalodon/src/firefish/entities/session.ts @@ -1,6 +1,4 @@ -namespace FirefishEntity { - export type Session = { - token: string - url: string - } +export type Session = { + token: string + url: string } diff --git a/megalodon/src/firefish/entities/stats.ts b/megalodon/src/firefish/entities/stats.ts index 81806f42d..455e298bb 100644 --- a/megalodon/src/firefish/entities/stats.ts +++ b/megalodon/src/firefish/entities/stats.ts @@ -1,9 +1,7 @@ -namespace FirefishEntity { - export type Stats = { - notesCount: number - originalNotesCount: number - usersCount: number - originalUsersCount: number - instances: number - } +export type Stats = { + notesCount: number + originalNotesCount: number + usersCount: number + originalUsersCount: number + instances: number } diff --git a/megalodon/src/firefish/entities/user.ts b/megalodon/src/firefish/entities/user.ts index cac62414e..75db623f2 100644 --- a/megalodon/src/firefish/entities/user.ts +++ b/megalodon/src/firefish/entities/user.ts @@ -1,20 +1,18 @@ -/// +import { Emoji } from './emoji' -namespace FirefishEntity { - export type User = { - id: string - name: string | null - username: string - host: string | null - avatarUrl: string | null - avatarBlurhash: string | null - avatarColor: string | null - isAdmin?: boolean - isModerator?: boolean - isBot?: boolean - isCat?: boolean - isIndexable?: boolean - speakAsCat?: boolean - emojis: Array - } +export type User = { + id: string + name: string | null + username: string + host: string | null + avatarUrl: string | null + avatarBlurhash: string | null + avatarColor: string | null + isAdmin?: boolean + isModerator?: boolean + isBot?: boolean + isCat?: boolean + isIndexable?: boolean + speakAsCat?: boolean + emojis: Array } diff --git a/megalodon/src/firefish/entities/userDetail.ts b/megalodon/src/firefish/entities/userDetail.ts index 6cbb600bf..8f185ac77 100644 --- a/megalodon/src/firefish/entities/userDetail.ts +++ b/megalodon/src/firefish/entities/userDetail.ts @@ -1,49 +1,47 @@ -/// -/// -/// +import { Emoji } from './emoji' +import { Note } from './note' +import { Field } from './field' -namespace FirefishEntity { - export type UserDetail = { - id: string - name: string | null - username: string - host: string | null - avatarUrl: string | null - avatarBlurhash: string | null - avatarColor: string | null - isAdmin?: boolean - isModerator?: boolean - isBot?: boolean - isCat?: boolean - isIndexable?: boolean - speakAsCat?: boolean - emojis: Array - url: string | null - uri: string | null - movedToUri: string | null - createdAt: string - updatedAt: string | null - bannerUrl: string | null - bannerBlurhash: string | null - bannerColor: string | null - isLocked: boolean - isSilenced: boolean - isSuspended: boolean - description: string | null - lang: string | null - fields: Array - followersCount: number - followingCount: number - notesCount: number - pinnedNoteIds: Array - pinnedNotes: Array - isFollowing?: boolean - isFollowed?: boolean - hasPendingFollowRequestFromYou?: boolean - hasPendintFollowRequestToYou?: boolean - isBlocking?: boolean - isBlocked?: boolean - isMuted?: boolean - isRenoteMuted?: boolean - } +export type UserDetail = { + id: string + name: string | null + username: string + host: string | null + avatarUrl: string | null + avatarBlurhash: string | null + avatarColor: string | null + isAdmin?: boolean + isModerator?: boolean + isBot?: boolean + isCat?: boolean + isIndexable?: boolean + speakAsCat?: boolean + emojis: Array + url: string | null + uri: string | null + movedToUri: string | null + createdAt: string + updatedAt: string | null + bannerUrl: string | null + bannerBlurhash: string | null + bannerColor: string | null + isLocked: boolean + isSilenced: boolean + isSuspended: boolean + description: string | null + lang: string | null + fields: Array + followersCount: number + followingCount: number + notesCount: number + pinnedNoteIds: Array + pinnedNotes: Array + isFollowing?: boolean + isFollowed?: boolean + hasPendingFollowRequestFromYou?: boolean + hasPendintFollowRequestToYou?: boolean + isBlocking?: boolean + isBlocked?: boolean + isMuted?: boolean + isRenoteMuted?: boolean } diff --git a/megalodon/src/firefish/entity.ts b/megalodon/src/firefish/entity.ts index a2cb2382f..07f277e29 100644 --- a/megalodon/src/firefish/entity.ts +++ b/megalodon/src/firefish/entity.ts @@ -1,26 +1,56 @@ -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +import * as announcement from './entities/announcement' +import * as app from './entities/app' +import * as blocking from './entities/blocking' +import * as created_note from './entities/createdNote' +import * as emoji from './entities/emoji' +import * as favorite from './entities/favorite' +import * as field from './entities/field' +import * as file from './entities/file' +import * as follow from './entities/follow' +import * as follow_request from './entities/followRequest' +import * as hashtag from './entities/hashtag' +import * as instance from './entities/instance' +import * as list from './entities/list' +import * as meta from './entities/meta' +import * as mute from './entities/mute' +import * as note from './entities/note' +import * as notification from './entities/notification' +import * as poll from './entities/poll' +import * as reaction from './entities/reaction' +import * as relation from './entities/relation' +import * as session from './entities/session' +import * as stats from './entities/stats' +import * as user from './entities/user' +import * as user_detail from './entities/userDetail' -export default FirefishEntity +export namespace Entity { + export type Announcement = announcement.Announcement + export type App = app.App + export type Blocking = blocking.Blocking + export type CreatedNote = created_note.CreatedNote + export type Emoji = emoji.Emoji + export type Favorite = favorite.Favorite + export type Field = field.Field + export type File = file.File + export type Follow = follow.Follow + export type FollowRequest = follow_request.FollowRequest + export type Hashtag = hashtag.Hashtag + export type Instance = instance.Instance + export type AccountEmoji = instance.AccountEmoji + export type List = list.List + export type Meta = meta.Meta + export type Mute = mute.Mute + export type Note = note.Note + export type Notification = notification.Notification + export type NotificationType = notification.NotificationType + export type Poll = poll.Poll + export type Choice = poll.Choice + export type Reaction = reaction.Reaction + export type Relation = relation.Relation + export type Session = session.Session + export type Stats = stats.Stats + export type User = user.User + export type UserDetail = user_detail.UserDetail +} + +export default Entity