Skip to content

Commit

Permalink
Change namespace definition for friendica entity
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Oct 7, 2023
1 parent 9ed2d65 commit b51089a
Show file tree
Hide file tree
Showing 38 changed files with 454 additions and 483 deletions.
2 changes: 1 addition & 1 deletion megalodon/src/friendica.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Array<FriendicaEntity.Account>>(parsed?.next.url, undefined, undefined, true)
const nextRes = await this.client.get<Array<FriendicaAPI.Entity.Account>>(parsed?.next.url, undefined, undefined, true)
converted = Object.assign({}, converted, {
data: [...converted.data, ...nextRes.data.map(a => FriendicaAPI.Converter.account(a))]
})
Expand Down
55 changes: 27 additions & 28 deletions megalodon/src/friendica/entities/account.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
/// <reference path="emoji.ts" />
/// <reference path="source.ts" />
/// <reference path="field.ts" />
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<Emoji>
moved: Account | null
fields: Array<Field>
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<Emoji>
moved: Account | null
fields: Array<Field>
bot: boolean
source?: Source
}
12 changes: 5 additions & 7 deletions megalodon/src/friendica/entities/activity.ts
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 4 additions & 6 deletions megalodon/src/friendica/entities/application.ts
Original file line number Diff line number Diff line change
@@ -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
}
25 changes: 12 additions & 13 deletions megalodon/src/friendica/entities/async_attachment.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/// <reference path="attachment.ts" />
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
}
84 changes: 41 additions & 43 deletions megalodon/src/friendica/entities/attachment.ts
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 14 additions & 16 deletions megalodon/src/friendica/entities/card.ts
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 4 additions & 6 deletions megalodon/src/friendica/entities/context.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// <reference path="status.ts" />
import { Status } from './status'

namespace FriendicaEntity {
export type Context = {
ancestors: Array<Status>
descendants: Array<Status>
}
export type Context = {
ancestors: Array<Status>
descendants: Array<Status>
}
16 changes: 7 additions & 9 deletions megalodon/src/friendica/entities/conversation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/// <reference path="account.ts" />
/// <reference path="status.ts" />
import { Account } from './account'
import { Status } from './status'

namespace FriendicaEntity {
export type Conversation = {
id: string
accounts: Array<Account>
last_status: Status | null
unread: boolean
}
export type Conversation = {
id: string
accounts: Array<Account>
last_status: Status | null
unread: boolean
}
12 changes: 5 additions & 7 deletions megalodon/src/friendica/entities/emoji.ts
Original file line number Diff line number Diff line change
@@ -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
}
12 changes: 5 additions & 7 deletions megalodon/src/friendica/entities/featured_tag.ts
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 4 additions & 6 deletions megalodon/src/friendica/entities/field.ts
Original file line number Diff line number Diff line change
@@ -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
}
20 changes: 9 additions & 11 deletions megalodon/src/friendica/entities/filter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
namespace FriendicaEntity {
export type Filter = {
id: string
phrase: string
context: Array<FilterContext>
expires_at: string | null
irreversible: boolean
whole_word: boolean
}

export type FilterContext = string
export type Filter = {
id: string
phrase: string
context: Array<FilterContext>
expires_at: string | null
irreversible: boolean
whole_word: boolean
}

export type FilterContext = string
48 changes: 23 additions & 25 deletions megalodon/src/friendica/entities/follow_request.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
/// <reference path="emoji.ts" />
/// <reference path="field.ts" />
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<Emoji>
fields: Array<Field>
}
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<Emoji>
fields: Array<Field>
}
10 changes: 4 additions & 6 deletions megalodon/src/friendica/entities/history.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace FriendicaEntity {
export type History = {
day: string
uses: number
accounts: number
}
export type History = {
day: string
uses: number
accounts: number
}
Loading

0 comments on commit b51089a

Please sign in to comment.