-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.ts
405 lines (343 loc) · 7.86 KB
/
interfaces.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
// Expose MongoDB ObjectId to be used in Repo and Viewer
import ObjectId from 'bson-objectid';
export { ObjectId };
import { Collection, UserRank } from './enums';
/**
* Database model for any document saved in the database.
* Should be used as a base interface for other database models.
*/
export interface IDocument {
_id: string | ObjectId;
}
export interface ITypeValueTuple {
type: string;
value: string;
}
export interface IDimensionTuple {
type: string;
value: string;
name: string;
}
export interface ICreationTuple {
technique: string;
program: string;
equipment: string;
date: string;
}
export interface IDescriptionValueTuple {
description: string;
value: string;
}
export interface IPlaceTuple {
name: string;
geopolarea: string;
address: IAddress;
}
/**
* Database model for addresses.
*/
export interface IAddress extends IDocument {
building: string;
number: string;
street: string;
postcode: string;
city: string;
country: string;
// Internal & only used to sort addresses
creation_date: number;
}
/**
* Database model for contact references.
*/
export interface IContact extends IDocument {
mail: string;
phonenumber: string;
note: string;
// Internal & only used to sort contact references
creation_date: number;
}
/**
* Generic object-based pseudo-map (not to be confused with Map).
* Key is always the _id of a metadata entity (DigitalEntity | PhysicalEntity)
* Value is whatever data is connected to the entity described by key
*/
export interface IRelatedMap<T> {
[relatedEntityId: string]: T | undefined;
}
/**
* Database model of a person. Makes use of IRelatedMap for roles,
* institutions and contact references.
*/
export interface IPerson extends IDocument {
prename: string;
name: string;
// relatedEntityId refers to the _id
// of the digital or physical entity
// a person refers to
roles: IRelatedMap<string[]>;
institutions: IRelatedMap<Array<IInstitution | IDocument>>;
contact_references: IRelatedMap<IContact | IDocument>;
}
/**
* Database model of an institution. Makes use of IRelatedMap for roles,
* notes and addresses.
*/
export interface IInstitution extends IDocument {
name: string;
university: string;
// relatedEntityId refers to the _id
// of the digital or physical entity
// a person refers to
roles: IRelatedMap<string[]>;
notes: IRelatedMap<string>;
addresses: IRelatedMap<IAddress | IDocument>;
}
/**
* Database model of a tag
*/
export interface ITag extends IDocument {
value: string;
}
/**
* Common interface between IPhysicalEntity and IDigitalEntity.
* Should not be used on its own.
*/
export interface IBaseEntity extends IDocument {
title: string;
description: string;
externalId: ITypeValueTuple[];
externalLink: IDescriptionValueTuple[];
biblioRefs: IDescriptionValueTuple[];
other: IDescriptionValueTuple[];
persons: IPerson[];
institutions: IInstitution[];
metadata_files: IFile[];
}
/**
* Database model of a physical entity. Uses IBaseEntity.
*/
export interface IPhysicalEntity extends IBaseEntity {
place: IPlaceTuple;
collection: string;
}
/**
* Database model of a digital entity. Uses IBaseEntity.
*/
export interface IDigitalEntity extends IBaseEntity {
type: string;
licence: string;
discipline: string[];
tags: ITag[];
dimensions: IDimensionTuple[];
creation: ICreationTuple[];
files: IFile[];
statement: string;
objecttype: string;
phyObjs: IPhysicalEntity[];
}
/**
* Userdata reduced to fullname, username and _id.
* May be displayed in public
*/
export interface IStrippedUserData extends IDocument {
fullname: string;
username: string;
}
/**
* Database model for users. Should not be displayed in public,
* as it contains the sessionID.
*/
export interface IUserData extends IDocument {
username: string;
sessionID: string;
fullname: string;
prename: string;
surname: string;
mail: string;
role: UserRank;
data: {
[key in Collection]: Array<string | null | any | ObjectId>;
};
}
/**
* Database model for groups. May be displayed in public,
* as it only contains stripped user data.
*/
export interface IGroup extends IDocument {
name: string;
creator: IStrippedUserData;
owners: IStrippedUserData[];
members: IStrippedUserData[];
}
/**
* Database model of an annotation.
*/
export interface IAnnotation extends IDocument {
validated: boolean;
identifier: string;
ranking: number;
creator: IAgent;
created: string;
generator: IAgent;
generated?: string;
motivation: string;
lastModificationDate?: string;
lastModifiedBy: IAgent;
positionXOnView?: number;
positionYOnView?: number;
body: IBody;
target: ITarget;
}
export interface IAgent extends IDocument {
type: string;
name: string;
homepage?: string;
}
export interface IBody {
type: string;
content: IContent;
}
export interface IContent {
type: string;
title: string;
description: string;
link?: string;
relatedPerspective: ICameraPerspective;
[key: string]: any;
}
export interface ICameraPerspective {
cameraType: string;
position: IVector3;
target: IVector3;
preview: string;
}
export interface IVector3 {
x: number;
y: number;
z: number;
}
export interface ITarget {
source: ISource;
selector: ISelector;
}
export interface ISource {
link?: string;
relatedEntity: string;
relatedCompilation?: string;
}
export interface ISelector {
referencePoint: IVector3;
referenceNormal: IVector3;
}
// Entity related
// TODO: remove file_ prefix and add migration
export interface IFile {
file_name: string;
file_link: string;
file_size: number;
file_format: string;
}
/**
* Describes any database model that can be protected by a whitelist of users
* or groups.
* Should not be used on its own.
*/
export interface IWhitelist {
whitelist: {
enabled: boolean;
persons: IStrippedUserData[];
groups: IGroup[];
};
}
export interface IColor {
r: number;
b: number;
g: number;
a: number;
}
export interface IPosition {
x: number;
y: number;
z: number;
}
export interface IEntitySettings {
position?: IPosition
preview: string;
cameraPositionInitial: {
position: IPosition;
target: IPosition;
};
background: {
color: IColor;
effect: boolean;
};
lights: IEntityLight[];
rotation: IPosition;
scale: number;
translate?: IPosition;
}
export interface IEntityLight {
type: string;
position: IPosition;
intensity: number;
}
/**
* Describes any database model that can be annotated/receive annotations.
* Should not be used on its own.
*/
interface IAnnotationList {
annotations: {
[id: string]: IAnnotation | IDocument;
};
}
/**
* Database model of an entity.
*
* An entity is what a user creates during the upload process and contains
* information about the files uploaded as well as a reference to the
* digital entity described/connected to the uploaded entity.
*
* Makes use of IWhitelist and IAnnotationList.
*/
export interface IEntity extends IWhitelist, IAnnotationList, IDocument {
name: string;
files: IFile[];
externalFile?: string;
relatedDigitalEntity: IDocument | IDigitalEntity;
creator: IStrippedUserData;
online: boolean;
finished: boolean;
mediaType: string;
dataSource: {
isExternal: boolean;
service: string;
};
processed: {
low: string;
medium: string;
high: string;
raw: string;
};
settings: IEntitySettings;
}
/**
* Database model of a compilation.
*
* A compilation contains a list of entities aswell as information on
* who created the compilation.
*
* Makes use of IWhitelist and IAnnotationList.
*/
export interface ICompilation extends IWhitelist, IAnnotationList, IDocument {
name: string;
description: string;
creator: IStrippedUserData;
password?: string | boolean;
entities: {
[id: string]: IEntity | IDocument;
};
}
export interface ISizedEvent {
width: number;
height: number;
}