forked from CharlieDigital/coderev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomainModels.ts
133 lines (113 loc) · 3.24 KB
/
domainModels.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* Domain specific model types built off of the base model types.
*/
import { Archivable, EmbeddedRef, Entity, MediaRef } from "./models";
/**
* Defines the role types for the users on the workspace.
*/
export type CollaboratorRole = "owner" | "editor" | "reviewer";
/**
* This type is used to model invites which include a pending property to indicate
* that the invitation has not yet been accepted.
*/
export type CollaboratorRef = EmbeddedRef & {
/**
* When this is true, the collaborator has only been invited and has not yet
* joined the trip.
*/
pending: boolean;
/**
* The role for the collaborator
*/
role: CollaboratorRole;
};
/**
* Defines a workspace which contains a set of notes.
*/
export type Workspace = {
/**
* A description for the workspace
*/
description?: string;
/**
* The collaborators who have created accounts to work on this trip. The refs
* point to user profiles. The key is the UID. This will always contain
* the user who created the trip.
*/
collaborators: Record<string, CollaboratorRef>;
/**
* When present, this value is an invite code that allows any user with a link
* to join the trip. This can simplify sending out individual invites.
*/
inviteCode?: string;
/**
* Represents a set of content which every workspace is associated with. A content
* set can be associated with multiple workspaces. For example, a set of documents
* can be shared by multiple teams in different workspaces.
*/
sources: Record<string, MediaRef>;
} & Entity & Archivable;
/**
* The context type of a comment so we know what the comment is attached to.
*/
export type ContextType =
| "source"
| "comment"
/**
* Defines a comment
*/
export type ReviewComment = {
/**
* A UID for this comment used for updates and deletion.
*/
uid: string;
/**
* The body of the comment.
*/
text: string
/**
* Represents a range in the source that the comment is referencing.
*/
sourceRange?: number[]
/**
* Determines the type of context for this comment.
*/
contextType: ContextType
/**
* The UID of the context which references either a source file or another comment.
*/
contextUid: string
/**
* The reference to the author of the comment and also includes the timestamp.
*/
author: EmbeddedRef
}
/**
* This document represents a candidate review. When we create it, we copy over
* the media refs from the workspace.
*/
export type CandidateReview = {
/**
* The UID of the workspace that is referenced by this review.
*/
workspaceUid: string;
/**
* Copy this value so we don't need to have permissions to read the workspace.
*/
workspaceName: string;
/**
* The email address of the candidate that this review is assigned to.
*/
email: string;
/**
* Represents a set of content which every workspace is associated with. A content
* set can be associated with multiple workspaces. For example, a set of documents
* can be shared by multiple teams in different workspaces.
*/
sources: Record<string, MediaRef>;
/**
* The comments attached to this review. The key is a unique ID for the
* comment.
*/
comments: Record<string, ReviewComment>;
} & Entity & Archivable;