forked from CharlieDigital/coderev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.ts
225 lines (201 loc) · 4.88 KB
/
models.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/**
* Base model types
*/
/**
* A minimal reference that references an entity with a date;
*/
export type MinimalRef = {
/**
* The UID of the entity being referenced.
*/
uid: string;
/**
* UTC date and time that the reference was added.
*/
addedUtc: string;
};
/**
* An embedded reference.
*/
export type EmbeddedRef = {
/**
* The name of the entity being referenced.
*/
name: string;
/**
* The type of the referenced entity.
*/
entityType: string;
} & MinimalRef;
/**
* Interface definition for entities. This attaches fields to common types. All
* top level collections are composed of Entity instances.
*/
export interface Entity {
uid: string;
name: string;
createdAtUtc?: string;
updatedAtUtc?: string | null;
createdBy?: EmbeddedRef;
updatedBy?: EmbeddedRef;
schemaVersion?: string;
}
/**
* The type of media. A document can represent an uploaded PDF, for example.
*/
export type MediaType = "image" | "video" | "document";
/**
* Type that represents the media for a given trip, place, or story. Media is
* stored against a trip directly. Places and the story can then reference the
* same media and reference the media order differently within the local scope.
*/
export type MediaRef = {
/**
* A global lexorank for the media for ordering purposes.
*/
rank: string;
/**
* A full HTTP URL that points to the media location.
*/
url: string;
/**
* The extension for the media.
*/
ext: string;
/**
* The string path of the file that corresponds to the location in Firestore.
*/
path?: string;
/**
* A display title for the media
*/
title?: string;
/**
* A caption to display for the media
*/
caption?: string;
/**
* Alternate text for the media
*/
alt?: string;
/**
* The size of the media in bytes if it is stored.
*/
size?: number;
/**
* If specified, a fixed width of the media.
*/
width?: number;
/**
* If specified, a fixed height for the media.
*/
height?: number;
/**
* The type the media.
*/
type: MediaType;
/**
* When present, this means that the media ref has been marked for removal.
* We need to do this because there may be references to the media elsewhere
* that we don't want to break, but when the owning container is deleted, we want
* to have a full set of refs to delete.
*/
markAsRemovedUtc?: string;
} & MinimalRef;
/**
* The type of content that is being referenced.
*/
export type ContentType = "url" | "document";
/**
* Base type declaration for a profile which can be re-composed in other
* contexts where we don't want the internal details of the profile state.
*/
export type ProfileBase = {
/**
* The display name associated with the profile. This allows the user to provide
* a different name than the one received from the OAuth flow.
*/
displayName?: string;
/**
* The email address of the user.
*/
email: string;
/**
* When this value is undefined, the user has not yet activated a
* profile created on their behalf (e.g. via invite.). Once activated,
* the value is updated to the activation date.
*/
activatedUtc?: string;
/**
* A reference to a user photo.
*/
photo?: MediaRef;
};
/**
* User lifecycle events; the fields capture the date and time when the event
* occurred
*/
export type ProfileEvent = {
/**
* Present then the user has watched or decined the intro video (so we don't show
* it again)
*/
experiencedIntroVideo?: string;
/**
* The user experienced the survey prompt.
*/
experiencedSurvey?: string;
};
/**
* This type is used to hold boolean records like the opt-in for the email
* notification so we know what the user chose and when.
*/
export type BooleanRecord = {
/**
* The user selected value.
*/
active: boolean;
/**
* The UTC date and time the record was updated.
*/
updatedUtc: string;
};
/**
* A type which represents the OAuth scopes the profile has granted.
*/
export type OAuthScopes = {
google: string[];
};
/**
* Type for archivable entities.
*/
export type Archivable = {
/**
* When present, the UTC date and time that the workspace was archived.
*/
archivedAtUtc?: string;
}
/**
* Maps a user profile which represents local user configuration information.
* Profiles are a top level collection.
*/
export type Profile = {
/**
* User lifecycle events which indicate that the user has performed key steps
*/
events?: ProfileEvent;
/**
* The scopes which have been granted by this user. The actual tokens are stored
* elsewhere, but this allows us to determine which features to show to the user.
*/
scopes?: OAuthScopes;
/**
* When true, the user is opting in to receive emails.
*/
receiveEmails?: BooleanRecord;
/**
* User is opting in to receive feedback requests.
*/
receiveFeedbackRequests?: BooleanRecord;
} & ProfileBase &
Entity;