Implement existing API types

This commit is contained in:
Melody Becker 2024-11-20 15:39:24 +01:00
parent e76490f637
commit a6291fd098
14 changed files with 108 additions and 21 deletions

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class AccountModel extends Model {}

View file

@ -0,0 +1,30 @@
import Model, { attr, hasMany, type AsyncHasMany } from '@ember-data/model'
import type RemoteServerModel from './remote-server'
import type CustomAccountFieldModel from './custom-account-field'
import type MediaMetadataModel from './media-metadata'
export default class AccountModel extends Model {
@attr declare createdAt: Date
@attr declare updatedAt: Date
@attr declare username: string
@attr declare originServer: RemoteServerModel
@attr declare originServerId: number
@attr declare displayName: string
@hasMany('custom-account-field')
declare customFields: AsyncHasMany<CustomAccountFieldModel>
@attr declare customFieldIds: Array<number>
@attr declare isBot: boolean
@attr declare description: string
@attr declare icon: MediaMetadataModel
@attr declare iconId: string
@attr declare banner: MediaMetadataModel
@attr declare bannerId: string
@attr declare background: MediaMetadataModel
@attr declare backgroundId: string
@attr declare relationIds: Array<number>
@attr declare indexable: boolean
@attr declare restrictedFollow: boolean
@attr declare identifiesAs: Array<string>
@attr declare pronouns: Array<string>
@attr declare roles: Array<string>
}

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class CustomAccountFieldModel extends Model {}

View file

@ -0,0 +1,10 @@
import Model, { attr } from '@ember-data/model'
export default class CustomAccountFieldModel extends Model {
@attr declare createdAt: Date
@attr declare updatedAt: Date
@attr declare key: string
@attr declare value: string
@attr declare verified?: boolean
@attr declare belongsToId: string
}

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class EmoteModel extends Model {}

View file

@ -0,0 +1,11 @@
import Model, { attr } from '@ember-data/model'
import type MediaMetadataModel from './media-metadata'
import type RemoteServerModel from './remote-server'
export default class EmoteModel extends Model {
@attr declare metadataId: string
@attr declare metadata: MediaMetadataModel
@attr declare name: string
@attr declare serverId: number
@attr declare server: RemoteServerModel
}

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class MediaMetadataModel extends Model {}

View file

@ -0,0 +1,12 @@
import Model, { attr } from '@ember-data/model'
export default class MediaMetadataModel extends Model {
@attr declare createdAt: Date
@attr declare updatedAt: Date
@attr declare isRemote: boolean
@attr declare url: string
@attr declare mimeType: string
@attr declare name: string
@attr declare altText: string
@attr declare blurred: boolean
}

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class NoteModel extends Model {}

View file

@ -0,0 +1,26 @@
import Model, { attr, hasMany, type AsyncHasMany } from '@ember-data/model'
import type RemoteServerModel from './remote-server'
import type AccountModel from './account'
import type MediaMetadataModel from './media-metadata'
export default class NoteModel extends Model {
@attr declare content: string
@attr declare originServer: RemoteServerModel
@attr declare originServerId: number
@attr declare reactionCount: number
@attr declare createdAt: Date
@attr declare updatedAt: Date
@attr declare author: AccountModel
@attr declare authorId: string
@attr declare contentWarning?: string
@attr declare inReplyToId?: string
@attr declare quotesId?: string
@attr declare emoteIds?: Array<string>
@hasMany('media-metadata')
declare attachments: AsyncHasMany<MediaMetadataModel>
@attr declare attachmentIds: Array<string>
@attr declare accessLevel: number
@hasMany('account') declare pings?: AsyncHasMany<AccountModel>
@attr declare pingIds?: Array<string>
@attr declare reactionIds: Array<number>
}

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class ReactionModel extends Model {}

View file

@ -0,0 +1,9 @@
import Model, { attr } from '@ember-data/model'
import type EmoteModel from './emote'
export default class ReactionModel extends Model {
@attr declare noteId: string
@attr declare reactorId: string
@attr declare emoteId: number
@attr declare emote: EmoteModel
}

View file

@ -1,3 +0,0 @@
import Model from '@ember-data/model';
export default class RelationModel extends Model {}

View file

@ -0,0 +1,10 @@
import Model, { attr } from '@ember-data/model'
export default class RelationModel extends Model {
@attr declare createdAt: Date
@attr declare updatedAt: Date
@attr declare fromId: string
@attr declare toId: string
@attr declare requested: boolean
@attr declare accepted: boolean
}