diff --git a/app/database/models/app/global.ts b/app/database/models/app/global.ts index 18decdee4..f8942dfde 100644 --- a/app/database/models/app/global.ts +++ b/app/database/models/app/global.ts @@ -7,6 +7,8 @@ import {json} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; import {safeParseJSON} from '@utils/helpers'; +import type GlobalModelInterface from '@typings/database/models/app/global'; + const {GLOBAL} = MM_TABLES.APP; // TODO : add TS definitions to sanitizer function signature. @@ -15,7 +17,7 @@ const {GLOBAL} = MM_TABLES.APP; * The Global model will act as a dictionary of name-value pairs. The value field can be a JSON object or any other * data type. It will hold information that applies to the whole app ( e.g. sidebar settings for tablets) */ -export default class GlobalModel extends Model { +export default class GlobalModel extends Model implements GlobalModelInterface { /** table (name) : global */ static table = GLOBAL; diff --git a/app/database/models/app/info.ts b/app/database/models/app/info.ts index ef2bd7871..490210ebf 100644 --- a/app/database/models/app/info.ts +++ b/app/database/models/app/info.ts @@ -5,6 +5,7 @@ import {Model} from '@nozbe/watermelondb'; import {field} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; +import InfoModelInterface from '@typings/database/models/app/info'; const {INFO} = MM_TABLES.APP; @@ -12,7 +13,7 @@ const {INFO} = MM_TABLES.APP; * The App model will hold information - such as the version number, build number and creation date - * for the Mattermost mobile app. */ -export default class InfoModel extends Model { +export default class InfoModel extends Model implements InfoModelInterface { /** table (name) : info */ static table = INFO; diff --git a/app/database/models/app/servers.ts b/app/database/models/app/servers.ts index 1629db8b3..2dd4f558c 100644 --- a/app/database/models/app/servers.ts +++ b/app/database/models/app/servers.ts @@ -6,13 +6,15 @@ import {field} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; +import type ServersModelInterface from '@typings/database/models/app/servers'; + const {SERVERS} = MM_TABLES.APP; /** * The Server model will help us to identify the various servers a user will log in; in the context of * multi-server support system. The db_path field will hold the App-Groups file-path */ -export default class ServersModel extends Model { +export default class ServersModel extends Model implements ServersModelInterface { /** table (name) : servers */ static table = SERVERS; diff --git a/app/database/models/server/channel.ts b/app/database/models/server/channel.ts index b6d7ee3d1..070d56b1a 100644 --- a/app/database/models/server/channel.ts +++ b/app/database/models/server/channel.ts @@ -1,13 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; +import {Query, Relation} from '@nozbe/watermelondb'; import {children, field, immutableRelation} from '@nozbe/watermelondb/decorators'; import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type CategoryChannelModel from '@typings/database/models/servers/category_channel'; +import type ChannelModelInterface from '@typings/database/models/servers/channel'; import type ChannelInfoModel from '@typings/database/models/servers/channel_info'; import type ChannelMembershipModel from '@typings/database/models/servers/channel_membership'; import type DraftModel from '@typings/database/models/servers/draft'; @@ -35,7 +36,7 @@ const { /** * The Channel model represents a channel in the Mattermost app. */ -export default class ChannelModel extends Model { +export default class ChannelModel extends Model implements ChannelModelInterface { /** table (name) : Channel */ static table = CHANNEL; @@ -101,16 +102,16 @@ export default class ChannelModel extends Model { @field('type') type!: ChannelType; /** members : Users belonging to this channel */ - @children(CHANNEL_MEMBERSHIP) members!: ChannelMembershipModel[]; + @children(CHANNEL_MEMBERSHIP) members!: Query; /** drafts : All drafts for this channel */ - @children(DRAFT) drafts!: DraftModel[]; + @children(DRAFT) drafts!: Query; /** posts : All posts made in that channel */ - @children(POST) posts!: PostModel[]; + @children(POST) posts!: Query; /** postsInChannel : a section of the posts for that channel bounded by a range */ - @children(POSTS_IN_CHANNEL) postsInChannel!: PostsInChannelModel[]; + @children(POSTS_IN_CHANNEL) postsInChannel!: Query; /** team : The TEAM to which this CHANNEL belongs */ @immutableRelation(TEAM, 'team_id') team!: Relation; diff --git a/app/database/models/server/channel_info.ts b/app/database/models/server/channel_info.ts index 56dc4de6b..0c44d64cd 100644 --- a/app/database/models/server/channel_info.ts +++ b/app/database/models/server/channel_info.ts @@ -8,6 +8,7 @@ import Model from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type ChannelModel from '@typings/database/models/servers/channel'; +import type ChannelInfoInterface from '@typings/database/models/servers/channel_info'; const {CHANNEL, CHANNEL_INFO} = MM_TABLES.SERVER; @@ -16,7 +17,7 @@ const {CHANNEL, CHANNEL_INFO} = MM_TABLES.SERVER; * In a Separation of Concerns approach, ChannelInfo will provide additional information about a channel but on a more * specific level. */ -export default class ChannelInfoModel extends Model { +export default class ChannelInfoModel extends Model implements ChannelInfoInterface { /** table (name) : ChannelInfo */ static table = CHANNEL_INFO; diff --git a/app/database/models/server/channel_membership.ts b/app/database/models/server/channel_membership.ts index b2422a411..d9311e7ec 100644 --- a/app/database/models/server/channel_membership.ts +++ b/app/database/models/server/channel_membership.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type ChannelModel from '@typings/database/models/servers/channel'; +import type ChannelMembershipModelInterface from '@typings/database/models/servers/channel_membership'; import type UserModel from '@typings/database/models/servers/user'; const {CHANNEL, CHANNEL_MEMBERSHIP, USER} = MM_TABLES.SERVER; @@ -16,7 +17,7 @@ const {CHANNEL, CHANNEL_MEMBERSHIP, USER} = MM_TABLES.SERVER; * The ChannelMembership model represents the 'association table' where many channels have users and many users are on * channels ( N:N relationship between model Users and model Channel) */ -export default class ChannelMembershipModel extends Model { +export default class ChannelMembershipModel extends Model implements ChannelMembershipModelInterface { /** table (name) : ChannelMembership */ static table = CHANNEL_MEMBERSHIP; diff --git a/app/database/models/server/custom_emoji.ts b/app/database/models/server/custom_emoji.ts index b20bf616f..dc16eaf99 100644 --- a/app/database/models/server/custom_emoji.ts +++ b/app/database/models/server/custom_emoji.ts @@ -6,10 +6,12 @@ import {field} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; +import type CustomEmojiModelInterface from '@typings/database/models/servers/custom_emoji'; + const {CUSTOM_EMOJI} = MM_TABLES.SERVER; /** The CustomEmoji model describes all the custom emojis used in the Mattermost app */ -export default class CustomEmojiModel extends Model { +export default class CustomEmojiModel extends Model implements CustomEmojiModelInterface { /** table (name) : CustomEmoji */ static table = CUSTOM_EMOJI; diff --git a/app/database/models/server/draft.ts b/app/database/models/server/draft.ts index 04bc5d867..f651029d0 100644 --- a/app/database/models/server/draft.ts +++ b/app/database/models/server/draft.ts @@ -7,12 +7,14 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import {safeParseJSON} from '@utils/helpers'; +import type DraftModelInterface from '@typings/database/models/servers/draft'; + const {CHANNEL, DRAFT, POST} = MM_TABLES.SERVER; /** * The Draft model represents the draft state of messages in Direct/Group messages and in channels */ -export default class DraftModel extends Model { +export default class DraftModel extends Model implements DraftModelInterface { /** table (name) : Draft */ static table = DRAFT; diff --git a/app/database/models/server/file.ts b/app/database/models/server/file.ts index 7d5158471..2394dcf3b 100644 --- a/app/database/models/server/file.ts +++ b/app/database/models/server/file.ts @@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; +import type FileModelInterface from '@typings/database/models/servers/file'; import type PostModel from '@typings/database/models/servers/post'; const {FILE, POST} = MM_TABLES.SERVER; @@ -14,7 +15,7 @@ const {FILE, POST} = MM_TABLES.SERVER; /** * The File model works in pair with the Post model. It hosts information about the files attached to a Post */ -export default class FileModel extends Model { +export default class FileModel extends Model implements FileModelInterface { /** table (name) : File */ static table = FILE; diff --git a/app/database/models/server/my_channel.ts b/app/database/models/server/my_channel.ts index c78660ec8..719b44172 100644 --- a/app/database/models/server/my_channel.ts +++ b/app/database/models/server/my_channel.ts @@ -8,13 +8,14 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type ChannelModel from '@typings/database/models/servers/channel'; +import type MyChannelModelInterface from '@typings/database/models/servers/my_channel'; const {CATEGORY_CHANNEL, CHANNEL, MY_CHANNEL} = MM_TABLES.SERVER; /** * MyChannel is an extension of the Channel model but it lists only the Channels the app's user belongs to */ -export default class MyChannelModel extends Model { +export default class MyChannelModel extends Model implements MyChannelModelInterface { /** table (name) : MyChannel */ static table = MY_CHANNEL; diff --git a/app/database/models/server/my_channel_settings.ts b/app/database/models/server/my_channel_settings.ts index 29602b32e..c84e8ae4d 100644 --- a/app/database/models/server/my_channel_settings.ts +++ b/app/database/models/server/my_channel_settings.ts @@ -9,6 +9,7 @@ import {MM_TABLES} from '@constants/database'; import {safeParseJSON} from '@utils/helpers'; import type ChannelModel from '@typings/database/models/servers/channel'; +import type MyChannelSettingsModelInterface from '@typings/database/models/servers/my_channel_settings'; const {CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER; @@ -16,11 +17,11 @@ const {CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER; * The MyChannelSettings model represents the specific user's configuration to * the channel this user belongs to. */ -export default class MyChannelSettingsModel extends Model { +export default class MyChannelSettingsModel extends Model implements MyChannelSettingsModelInterface { /** table (name) : MyChannelSettings */ static table = MY_CHANNEL_SETTINGS; - /** notify_props : Configurations with regards to this channel */ + /** notify_props : Configurations in regard to this channel */ @json('notify_props', safeParseJSON) notifyProps!: ChannelNotifyProps; /** channel : The relation pointing to the CHANNEL table */ diff --git a/app/database/models/server/my_team.ts b/app/database/models/server/my_team.ts index b9f1ffabe..ffd430398 100644 --- a/app/database/models/server/my_team.ts +++ b/app/database/models/server/my_team.ts @@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; +import type MyTeamModelInterface from '@typings/database/models/servers/my_team'; import type TeamModel from '@typings/database/models/servers/team'; const {TEAM, MY_TEAM} = MM_TABLES.SERVER; @@ -14,7 +15,7 @@ const {TEAM, MY_TEAM} = MM_TABLES.SERVER; /** * MyTeam represents only the teams that the current user belongs to */ -export default class MyTeamModel extends Model { +export default class MyTeamModel extends Model implements MyTeamModelInterface { /** table (name) : MyTeam */ static table = MY_TEAM; diff --git a/app/database/models/server/post.ts b/app/database/models/server/post.ts index e0d7caeb8..a62c2c611 100644 --- a/app/database/models/server/post.ts +++ b/app/database/models/server/post.ts @@ -11,6 +11,7 @@ import {safeParseJSON} from '@utils/helpers'; import type ChannelModel from '@typings/database/models/servers/channel'; import type DraftModel from '@typings/database/models/servers/draft'; import type FileModel from '@typings/database/models/servers/file'; +import type PostModelInterface from '@typings/database/models/servers/post'; import type PostInThreadModel from '@typings/database/models/servers/posts_in_thread'; import type ReactionModel from '@typings/database/models/servers/reaction'; import type ThreadModel from '@typings/database/models/servers/thread'; @@ -21,7 +22,7 @@ const {CHANNEL, DRAFT, FILE, POST, POSTS_IN_THREAD, REACTION, THREAD, USER} = MM /** * The Post model is the building block of communication in the Mattermost app. */ -export default class PostModel extends Model { +export default class PostModel extends Model implements PostModelInterface { /** table (name) : Post */ static table = POST; @@ -96,7 +97,7 @@ export default class PostModel extends Model { @json('props', safeParseJSON) props!: any; // A draft can be associated with this post for as long as this post is a parent post - @lazy draft = this.collections.get(DRAFT).query(Q.on(POST, 'id', this.id)) as Query; + @lazy drafts = this.collections.get(DRAFT).query(Q.on(POST, 'id', this.id)) as Query; @lazy root = this.collection.query(Q.where('id', this.rootId)) as Query; @@ -125,7 +126,7 @@ export default class PostModel extends Model { async destroyPermanently() { await this.reactions.destroyAllPermanently(); await this.files.destroyAllPermanently(); - await this.draft.destroyAllPermanently(); + await this.drafts.destroyAllPermanently(); await this.collections.get(POSTS_IN_THREAD).query( Q.where('root_id', this.id), ).destroyAllPermanently(); diff --git a/app/database/models/server/posts_in_channel.ts b/app/database/models/server/posts_in_channel.ts index 99dfe7631..4b3e00b58 100644 --- a/app/database/models/server/posts_in_channel.ts +++ b/app/database/models/server/posts_in_channel.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type ChannelModel from '@typings/database/models/servers/channel'; +import type PostsInChannelModelInterface from '@typings/database/models/servers/posts_in_channel'; const {CHANNEL, POSTS_IN_CHANNEL} = MM_TABLES.SERVER; @@ -15,7 +16,7 @@ const {CHANNEL, POSTS_IN_CHANNEL} = MM_TABLES.SERVER; * PostsInChannel model helps us to combine adjacent posts together without leaving * gaps in between for an efficient user reading experience of posts. */ -export default class PostsInChannelModel extends Model { +export default class PostsInChannelModel extends Model implements PostsInChannelModelInterface { /** table (name) : PostsInChannel */ static table = POSTS_IN_CHANNEL; diff --git a/app/database/models/server/posts_in_thread.ts b/app/database/models/server/posts_in_thread.ts index bf4fcd5a7..45116e747 100644 --- a/app/database/models/server/posts_in_thread.ts +++ b/app/database/models/server/posts_in_thread.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type PostModel from '@typings/database/models/servers/post'; +import type PostsInThreadModelInterface from '@typings/database/models/servers/posts_in_thread'; const {POST, POSTS_IN_THREAD} = MM_TABLES.SERVER; @@ -15,7 +16,7 @@ const {POST, POSTS_IN_THREAD} = MM_TABLES.SERVER; * PostsInThread model helps us to combine adjacent threads together without leaving * gaps in between for an efficient user reading experience for threads. */ -export default class PostsInThreadModel extends Model { +export default class PostsInThreadModel extends Model implements PostsInThreadModelInterface { /** table (name) : PostsInThread */ static table = POSTS_IN_THREAD; diff --git a/app/database/models/server/preference.ts b/app/database/models/server/preference.ts index 03f14dade..e04c990d0 100644 --- a/app/database/models/server/preference.ts +++ b/app/database/models/server/preference.ts @@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; +import type PreferenceModelInterface from '@typings/database/models/servers/preference'; import type UserModel from '@typings/database/models/servers/user'; const {PREFERENCE, USER} = MM_TABLES.SERVER; @@ -15,7 +16,7 @@ const {PREFERENCE, USER} = MM_TABLES.SERVER; * The Preference model hold information about the user's preference in the app. * This includes settings about the account, the themes, etc. */ -export default class PreferenceModel extends Model { +export default class PreferenceModel extends Model implements PreferenceModelInterface { /** table (name) : Preference */ static table = PREFERENCE; diff --git a/app/database/models/server/reaction.ts b/app/database/models/server/reaction.ts index d9b3ce226..bc2dc0576 100644 --- a/app/database/models/server/reaction.ts +++ b/app/database/models/server/reaction.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type PostModel from '@typings/database/models/servers/post'; +import type ReactionModelInterface from '@typings/database/models/servers/reaction'; import type UserModel from '@typings/database/models/servers/user'; const {POST, REACTION, USER} = MM_TABLES.SERVER; @@ -15,7 +16,7 @@ const {POST, REACTION, USER} = MM_TABLES.SERVER; /** * The Reaction Model is used to present the reactions a user had on a particular post */ -export default class ReactionModel extends Model { +export default class ReactionModel extends Model implements ReactionModelInterface { /** table (name) : Reaction */ static table = REACTION; diff --git a/app/database/models/server/role.ts b/app/database/models/server/role.ts index 094e4d63c..929b5b053 100644 --- a/app/database/models/server/role.ts +++ b/app/database/models/server/role.ts @@ -7,10 +7,12 @@ import {field, json} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; import {safeParseJSON} from '@utils/helpers'; +import type RoleModelInterface from '@typings/database/models/servers/role'; + const {ROLE} = MM_TABLES.SERVER; /** The Role model will describe the set of permissions for each role */ -export default class RoleModel extends Model { +export default class RoleModel extends Model implements RoleModelInterface { /** table (name) : Role */ static table = ROLE; diff --git a/app/database/models/server/slash_command.ts b/app/database/models/server/slash_command.ts index 3fcf85801..4e23637dd 100644 --- a/app/database/models/server/slash_command.ts +++ b/app/database/models/server/slash_command.ts @@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; +import type SlashCommandModelInterface from '@typings/database/models/servers/slash_command'; import type TeamModel from '@typings/database/models/servers/team'; const {SLASH_COMMAND, TEAM} = MM_TABLES.SERVER; @@ -14,7 +15,7 @@ const {SLASH_COMMAND, TEAM} = MM_TABLES.SERVER; /** * The SlashCommand model describes the commands of the various commands available in each team. */ -export default class SlashCommandModel extends Model { +export default class SlashCommandModel extends Model implements SlashCommandModelInterface { /** table (name) : SlashCommand */ static table = SLASH_COMMAND; diff --git a/app/database/models/server/system.ts b/app/database/models/server/system.ts index a5de14a75..79b9b8de6 100644 --- a/app/database/models/server/system.ts +++ b/app/database/models/server/system.ts @@ -7,6 +7,8 @@ import {json} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; import {safeParseJSON} from '@utils/helpers'; +import type SystemModelInterface from '@typings/database/models/servers/system'; + const {SYSTEM} = MM_TABLES.SERVER; /** @@ -14,7 +16,7 @@ const {SYSTEM} = MM_TABLES.SERVER; * will mostly hold configuration information about the client, the licences and some * custom data (e.g. recent emoji used) */ -export default class SystemModel extends Model { +export default class SystemModel extends Model implements SystemModelInterface { /** table (name) : System */ static table = SYSTEM; diff --git a/app/database/models/server/team.ts b/app/database/models/server/team.ts index 5583f1dbb..74cb56384 100644 --- a/app/database/models/server/team.ts +++ b/app/database/models/server/team.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Q, Relation} from '@nozbe/watermelondb'; +import {Q, Query, Relation} from '@nozbe/watermelondb'; import {children, field, immutableRelation, lazy} from '@nozbe/watermelondb/decorators'; import Model, {Associations} from '@nozbe/watermelondb/Model'; @@ -11,6 +11,7 @@ import type CategoryModel from '@typings/database/models/servers/category'; import type ChannelModel from '@typings/database/models/servers/channel'; import type MyTeamModel from '@typings/database/models/servers/my_team'; import type SlashCommandModel from '@typings/database/models/servers/slash_command'; +import type TeamModelInterface from '@typings/database/models/servers/team'; import type TeamChannelHistoryModel from '@typings/database/models/servers/team_channel_history'; import type TeamMembershipModel from '@typings/database/models/servers/team_membership'; import type TeamSearchHistoryModel from '@typings/database/models/servers/team_search_history'; @@ -32,7 +33,7 @@ const { /** * A Team houses and enables communication to happen across channels and users. */ -export default class TeamModel extends Model { +export default class TeamModel extends Model implements TeamModelInterface { /** table (name) : Team */ static table = TEAM; @@ -89,25 +90,25 @@ export default class TeamModel extends Model { @field('allowed_domains') allowedDomains!: string; /** categories : All the categories associated with this team */ - @children(CATEGORY) categories!: CategoryModel[]; + @children(CATEGORY) categories!: Query; /** channels : All the channels associated with this team */ - @children(CHANNEL) channels!: ChannelModel[]; + @children(CHANNEL) channels!: Query; /** myTeam : Retrieves additional information about the team that this user is possibly part of. */ @immutableRelation(MY_TEAM, 'id') myTeam!: Relation; /** slashCommands : All the slash commands associated with this team */ - @children(SLASH_COMMAND) slashCommands!: SlashCommandModel[]; + @children(SLASH_COMMAND) slashCommands!: Query; /** teamChannelHistory : A history of the channels in this team that has been visited, ordered by the most recent and capped to the last 5 */ @immutableRelation(TEAM_CHANNEL_HISTORY, 'id') teamChannelHistory!: Relation; /** members : All the users associated with this team */ - @children(TEAM_MEMBERSHIP) members!: TeamMembershipModel[]; + @children(TEAM_MEMBERSHIP) members!: Query; /** teamSearchHistories : All the searches performed on this team */ - @children(TEAM_SEARCH_HISTORY) teamSearchHistories!: TeamSearchHistoryModel[]; + @children(TEAM_SEARCH_HISTORY) teamSearchHistories!: Query; /** threads : All threads belonging to a team */ @lazy threads = this.collections.get(THREAD).query( diff --git a/app/database/models/server/team_channel_history.ts b/app/database/models/server/team_channel_history.ts index b7ff76a15..afd84b54d 100644 --- a/app/database/models/server/team_channel_history.ts +++ b/app/database/models/server/team_channel_history.ts @@ -9,6 +9,7 @@ import {MM_TABLES} from '@constants/database'; import {safeParseJSON} from '@utils/helpers'; import type TeamModel from '@typings/database/models/servers/team'; +import type TeamChannelHistoryModelInterface from '@typings/database/models/servers/team_channel_history'; const {TEAM, TEAM_CHANNEL_HISTORY} = MM_TABLES.SERVER; @@ -16,7 +17,7 @@ const {TEAM, TEAM_CHANNEL_HISTORY} = MM_TABLES.SERVER; * The TeamChannelHistory model helps keeping track of the last channel visited * by the user. */ -export default class TeamChannelHistoryModel extends Model { +export default class TeamChannelHistoryModel extends Model implements TeamChannelHistoryModelInterface { /** table (name) : TeamChannelHistory */ static table = TEAM_CHANNEL_HISTORY; diff --git a/app/database/models/server/team_membership.ts b/app/database/models/server/team_membership.ts index a6c6dabb7..399dc7b4e 100644 --- a/app/database/models/server/team_membership.ts +++ b/app/database/models/server/team_membership.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type TeamModel from '@typings/database/models/servers/team'; +import type TeamMembershipModelInterface from '@typings/database/models/servers/team_membership'; import type UserModel from '@typings/database/models/servers/user'; const {TEAM, TEAM_MEMBERSHIP, USER} = MM_TABLES.SERVER; @@ -16,7 +17,7 @@ const {TEAM, TEAM_MEMBERSHIP, USER} = MM_TABLES.SERVER; * The TeamMembership model represents the 'association table' where many teams have users and many users are in * teams (relationship type N:N) */ -export default class TeamMembershipModel extends Model { +export default class TeamMembershipModel extends Model implements TeamMembershipModelInterface { /** table (name) : TeamMembership */ static table = TEAM_MEMBERSHIP; diff --git a/app/database/models/server/team_search_history.ts b/app/database/models/server/team_search_history.ts index bd9bad1b5..1118cc7b2 100644 --- a/app/database/models/server/team_search_history.ts +++ b/app/database/models/server/team_search_history.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type TeamModel from '@typings/database/models/servers/team'; +import type TeamSearchHistoryModelInterface from '@typings/database/models/servers/team_search_history'; const {TEAM, TEAM_SEARCH_HISTORY} = MM_TABLES.SERVER; @@ -15,7 +16,7 @@ const {TEAM, TEAM_SEARCH_HISTORY} = MM_TABLES.SERVER; * The TeamSearchHistory model holds the term searched within a team. The searches are performed * at team level in the app. */ -export default class TeamSearchHistoryModel extends Model { +export default class TeamSearchHistoryModel extends Model implements TeamSearchHistoryModelInterface { /** table (name) : TeamSearchHistory */ static table = TEAM_SEARCH_HISTORY; diff --git a/app/database/models/server/terms_of_service.ts b/app/database/models/server/terms_of_service.ts index 6cd1f33b1..95990f96f 100644 --- a/app/database/models/server/terms_of_service.ts +++ b/app/database/models/server/terms_of_service.ts @@ -6,12 +6,14 @@ import {field} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; +import type TermsOfServiceModelInterface from '@typings/database/models/servers/terms_of_service'; + const {TERMS_OF_SERVICE} = MM_TABLES.SERVER; /** * The model for Terms of Service */ -export default class TermsOfServiceModel extends Model { +export default class TermsOfServiceModel extends Model implements TermsOfServiceModelInterface { /** table (name) : TermsOfService */ static table = TERMS_OF_SERVICE; diff --git a/app/database/models/server/thread.ts b/app/database/models/server/thread.ts index e28ae7990..3aa7ef2d8 100644 --- a/app/database/models/server/thread.ts +++ b/app/database/models/server/thread.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type PostModel from '@typings/database/models/servers/post'; +import type ThreadModelInterface from '@typings/database/models/servers/thread'; import type ThreadInTeamModel from '@typings/database/models/servers/thread_in_team'; import type ThreadParticipantModel from '@typings/database/models/servers/thread_participant'; @@ -16,7 +17,7 @@ const {POST, THREAD, THREAD_PARTICIPANT, THREADS_IN_TEAM} = MM_TABLES.SERVER; /** * The Thread model contains thread information of a post. */ -export default class ThreadModel extends Model { +export default class ThreadModel extends Model implements ThreadModelInterface { /** table (name) : Thread */ static table = THREAD; diff --git a/app/database/models/server/thread_in_team.ts b/app/database/models/server/thread_in_team.ts index beaf8533a..4d6e6ee93 100644 --- a/app/database/models/server/thread_in_team.ts +++ b/app/database/models/server/thread_in_team.ts @@ -9,6 +9,7 @@ import {MM_TABLES} from '@constants/database'; import type TeamModel from '@typings/database/models/servers/team'; import type ThreadModel from '@typings/database/models/servers/thread'; +import type ThreadInTeamModelInterface from '@typings/database/models/servers/thread_in_team'; const {TEAM, THREAD, THREADS_IN_TEAM} = MM_TABLES.SERVER; @@ -16,7 +17,7 @@ const {TEAM, THREAD, THREADS_IN_TEAM} = MM_TABLES.SERVER; * ThreadInTeam model helps us to combine adjacent threads together without leaving * gaps in between for an efficient user reading experience for threads. */ -export default class ThreadInTeamModel extends Model { +export default class ThreadInTeamModel extends Model implements ThreadInTeamModelInterface { /** table (name) : ThreadsInTeam */ static table = THREADS_IN_TEAM; diff --git a/app/database/models/server/thread_participant.ts b/app/database/models/server/thread_participant.ts index d5951fd9a..a70f10bc8 100644 --- a/app/database/models/server/thread_participant.ts +++ b/app/database/models/server/thread_participant.ts @@ -8,6 +8,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; import type ThreadModel from '@typings/database/models/servers/thread'; +import type ThreadParticipantModelInterface from '@typings/database/models/servers/thread_participant'; import type UserModel from '@typings/database/models/servers/user'; const {THREAD, THREAD_PARTICIPANT, USER} = MM_TABLES.SERVER; @@ -15,7 +16,7 @@ const {THREAD, THREAD_PARTICIPANT, USER} = MM_TABLES.SERVER; /** * The Thread Participants model contains participants data of a thread. */ -export default class ThreadParticipantModel extends Model { +export default class ThreadParticipantModel extends Model implements ThreadParticipantModelInterface { /** table (name) : ThreadParticipant */ static table = THREAD_PARTICIPANT; @@ -33,7 +34,7 @@ export default class ThreadParticipantModel extends Model { @field('thread_id') threadId!: string; /** user_id : user id of the participant. */ - @field('user_id') userId!: number; + @field('user_id') userId!: string; /** thread : The related record of the Thread model */ @immutableRelation(THREAD, 'thread_id') thread!: Relation; diff --git a/types/database/models/servers/post.d.ts b/types/database/models/servers/post.d.ts index aad0773f4..c5245c331 100644 --- a/types/database/models/servers/post.d.ts +++ b/types/database/models/servers/post.d.ts @@ -69,7 +69,7 @@ export default class PostModel extends Model { /** props : Additional attributes for this props */ props: any; - /** drafts : Every drafts associated with this Post */ + /** drafts : Every draft associated with this Post */ drafts: Query; /** files: All the files associated with this Post */