1
0

feat: add modelTypes

This commit is contained in:
Dominik Pschenitschni
2022-08-04 20:57:43 +02:00
parent 8416b1f448
commit 7d4ba6249e
91 changed files with 751 additions and 513 deletions

View File

@ -0,0 +1,5 @@
import type {Right} from '@/constants/rights'
export interface IAbstract {
maxRight: Right | null // FIXME: should this be readonly?
}

View File

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {IFile} from './IFile'
import type {IUser} from './IUser'
export interface IAttachment extends IAbstract {
id: number
taskId: number
createdBy: IUser
file: IFile
created: Date
}

View File

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export type AvatarProvider = 'default' | 'initials' | 'gravatar' | 'marble' | 'upload'
export interface IAvatar extends IAbstract {
avatarProvider: AvatarProvider
}

View File

@ -0,0 +1,12 @@
import type {IAbstract} from './IAbstract'
export interface IBackgroundImage extends IAbstract {
id: number
url: string
thumb: string
info: {
author: string
authorName: string
}
blurHash: string
}

17
src/modelTypes/IBucket.ts Normal file
View File

@ -0,0 +1,17 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
export interface IBucket extends IAbstract {
id: number
title: string
listId: number
limit: number
tasks: ITask[]
isDoneBucket: boolean
position: number
createdBy: IUser
created: Date
updated: Date
}

View File

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface ICaldavToken extends IAbstract {
id: number;
created: Date;
}

View File

@ -0,0 +1,6 @@
import type {IAbstract} from './IAbstract'
export interface IEmailUpdate extends IAbstract {
newEmail: string
password: string
}

10
src/modelTypes/IFile.ts Normal file
View File

@ -0,0 +1,10 @@
import type {IAbstract} from './IAbstract'
export interface IFile extends IAbstract {
id: number
mime: string
name: string
size: number
created: Date
}

15
src/modelTypes/ILabel.ts Normal file
View File

@ -0,0 +1,15 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
export interface ILabel extends IAbstract {
id: number
title: string
hexColor: string
description: string
createdBy: IUser
listId: number
textColor: string
created: Date
updated: Date
}

View File

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface ILabelTask extends IAbstract {
id: number
taskId: number
labelId: number
}

View File

@ -0,0 +1,17 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type { Right } from '@/constants/rights'
export interface ILinkShare extends IAbstract {
id: number
hash: string
right: Right
sharedBy: IUser
sharingType: number // FIXME: use correct numbers
listId: number
name: string
password: string
created: Date
updated: Date
}

26
src/modelTypes/IList.ts Normal file
View File

@ -0,0 +1,26 @@
import type {IAbstract} from './IAbstract'
import type {ITask} from './ITask'
import type {IUser} from './IUser'
import type {ISubscription} from './ISubscription'
import type {INamespace} from './INamespace'
export interface IList extends IAbstract {
id: number
title: string
description: string
owner: IUser
tasks: ITask[]
namespaceId: INamespace['id']
isArchived: boolean
hexColor: string
identifier: string
backgroundInformation: any // FIXME: improve type
isFavorite: boolean
subscription: ISubscription
position: number
backgroundBlurHash: string
created: Date
updated: Date
}

View File

@ -0,0 +1,9 @@
import type {IAbstract} from './IAbstract'
import type {IList} from './IList'
import type {INamespace} from './INamespace'
export interface IListDuplicate extends IAbstract {
listId: number
namespaceId: INamespace['id']
list: IList
}

View File

@ -0,0 +1,18 @@
import type {IAbstract} from './IAbstract'
import type {IList} from './IList'
import type {IUser} from './IUser'
import type {ISubscription} from './ISubscription'
export interface INamespace extends IAbstract {
id: number
title: string
description: string
owner: IUser
lists: IList[]
isArchived: boolean
hexColor: string
subscription: ISubscription
created: Date
updated: Date
}

View File

@ -0,0 +1,51 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
import type {ITaskComment} from './ITaskComment'
import type {ITeam} from './ITeam'
import type { IList } from './IList'
export const NOTIFICATION_NAMES = {
'TASK_COMMENT': 'task.comment',
'TASK_ASSIGNED': 'task.assigned',
'TASK_DELETED': 'task.deleted',
'LIST_CREATED': 'list.created',
'TEAM_MEMBER_ADDED': 'team.member.added',
} as const
interface Notification {
doer: IUser
}
interface NotificationTask extends Notification {
task: ITask
comment: ITaskComment
}
interface NotificationAssigned extends Notification {
task: ITask
assignee: IUser
}
interface NotificationDeleted extends Notification {
task: ITask
}
interface NotificationCreated extends Notification {
task: ITask
list: IList
}
interface NotificationMemberAdded extends Notification {
member: IUser
team: ITeam
}
export interface INotification extends IAbstract {
id: number
name: string
notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded
read: boolean
readAt: Date | null
created: Date
}

View File

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface IPasswordReset extends IAbstract {
token: string
newPassword: string
email: string
}

View File

@ -0,0 +1,6 @@
import type {IAbstract} from './IAbstract'
export interface IPasswordUpdate extends IAbstract {
newPassword: string
oldPassword: string
}

View File

@ -0,0 +1,14 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {IFilter} from '@/types/IFilter'
export interface ISavedFilter extends IAbstract {
id: number
title: string
description: string
filters: IFilter
owner: IUser
created: Date
updated: Date
}

View File

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
export interface ISubscription extends IAbstract {
id: number
entity: string // FIXME: correct type?
entityId: number // FIXME: correct type?
user: IUser
created: Date
}

50
src/modelTypes/ITask.ts Normal file
View File

@ -0,0 +1,50 @@
import type { Priority } from '@/constants/priorities'
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ILabel} from './ILabel'
import type {IAttachment} from './IAttachment'
import type {ISubscription} from './ISubscription'
import type {IList} from './IList'
import type {IBucket} from './IBucket'
import type {IRelationKind} from '@/types/IRelationKind'
import type {IRepeatAfter} from '@/types/IRepeatAfter'
import type {IRepeatMode} from '@/types/IRepeatMode'
export interface ITask extends IAbstract {
id: number
title: string
description: string
done: boolean
doneAt: Date | null
priority: Priority
labels: ILabel[]
assignees: IUser[]
dueDate: Date | null
startDate: Date | null
endDate: Date | null
repeatAfter: number | IRepeatAfter
repeatFromCurrentDate: boolean
repeatMode: IRepeatMode
reminderDates: Date[]
parentTaskId: ITask['id']
hexColor: string
percentDone: number
relatedTasks: Partial<Record<IRelationKind, ITask>>,
attachments: IAttachment[]
identifier: string
index: number
isFavorite: boolean
subscription: ISubscription
position: number
kanbanPosition: number
createdBy: IUser
created: Date
updated: Date
listId: IList['id'] // Meta, only used when creating a new task
bucketId: IBucket['id']
}

View File

@ -0,0 +1,9 @@
import type {IAbstract} from './IAbstract'
import type {ITask} from './ITask'
import type {IUser} from './IUser'
export interface ITaskAssignee extends IAbstract {
created: Date
userId: IUser['id']
taskId: ITask['id']
}

View File

@ -0,0 +1,13 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
export interface ITaskComment extends IAbstract {
id: number
taskId: ITask['id']
comment: string
author: IUser
created: Date
updated: Date
}

View File

@ -0,0 +1,15 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITask} from './ITask'
import type {IRelationKind} from '@/types/IRelationKind'
export interface ITaskRelation extends IAbstract {
id: number
otherTaskId: ITask['id']
taskId: ITask['id']
relationKind: IRelationKind
createdBy: IUser
created: Date
}

16
src/modelTypes/ITeam.ts Normal file
View File

@ -0,0 +1,16 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {ITeamMember} from './ITeamMember'
import type {Right} from '@/constants/rights'
export interface ITeam extends IAbstract {
id: number
name: string
description: string
members: ITeamMember[]
right: Right
createdBy: IUser
created: Date
updated: Date
}

View File

@ -0,0 +1,6 @@
import type {ITeamShareBase} from './ITeamShareBase'
import type {IList} from './IList'
export interface ITeamList extends ITeamShareBase {
listId: IList['id']
}

View File

@ -0,0 +1,7 @@
import type {IUser} from './IUser'
import type {IList} from './IList'
export interface ITeamMember extends IUser {
admin: boolean
teamId: IList['id']
}

View File

@ -0,0 +1,6 @@
import type {ITeamShareBase} from './ITeamShareBase'
import type {INamespace} from './INamespace'
export interface ITeamNamespace extends ITeamShareBase {
namespaceId: INamespace['id']
}

View File

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {ITeam} from './ITeam'
import type {Right} from '@/constants/rights'
export interface ITeamShareBase extends IAbstract {
teamId: ITeam['id']
right: Right
created: Date
updated: Date
}

7
src/modelTypes/ITotp.ts Normal file
View File

@ -0,0 +1,7 @@
import type {IAbstract} from './IAbstract'
export interface ITotp extends IAbstract {
secret: string
enabled: boolean
url: string
}

13
src/modelTypes/IUser.ts Normal file
View File

@ -0,0 +1,13 @@
import type {IAbstract} from './IAbstract'
import type {IUserSettings} from './IUserSettings'
export interface IUser extends IAbstract {
id: number
email: string
username: string
name: string
created: Date
updated: Date
settings: IUserSettings
}

View File

@ -0,0 +1,6 @@
import type {IUserShareBase} from './IUserShareBase'
import type {IList} from './IList'
export interface IUserList extends IUserShareBase {
listId: IList['id']
}

View File

@ -0,0 +1,6 @@
import type {IUserShareBase} from './IUserShareBase'
import type {INamespace} from './INamespace'
export interface IUserNamespace extends IUserShareBase {
namespaceId: INamespace['id']
}

View File

@ -0,0 +1,14 @@
import type {IAbstract} from './IAbstract'
import type {IList} from './IList'
export interface IUserSettings extends IAbstract {
name: string
emailRemindersEnabled: boolean
discoverableByName: boolean
discoverableByEmail: boolean
overdueTasksRemindersEnabled: boolean
defaultListId: undefined | IList['id']
weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6
timezone: string
}

View File

@ -0,0 +1,11 @@
import type {IAbstract} from './IAbstract'
import type {IUser} from './IUser'
import type {Right} from '@/constants/rights'
export interface IUserShareBase extends IAbstract {
userId: IUser['id']
right: Right
created: Date
updated: Date
}