-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.ts
167 lines (142 loc) · 3.57 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
// @see https://github.com/eslint-community/eslint-plugin-n/issues/66
// eslint-disable-next-line n/no-missing-import
import type { Geometry } from "geojson";
import type { InternationalizedLabel, IsoDateString, UrlString } from "./types.js";
export interface Dataset {
id:
| "http://data.biographynet.nl/"
| "http://ldf.fi/nbf/data"
| "http://www.intavia.eu/sbi"
| "https://apis.acdh.oeaw.ac.at/data";
}
export interface Gender {
id: string;
label: InternationalizedLabel;
}
export interface CulturalHeritageObjectType {
id: string;
label: InternationalizedLabel;
}
export interface GroupType {
id: string;
label: InternationalizedLabel;
}
export interface HistoricalEventType {
id: string;
label: InternationalizedLabel;
}
// export interface MediaKind {
// id: string;
// label: InternationalizedLabel;
// }
export interface MediaResource {
id: string;
label: InternationalizedLabel;
description?: string;
attribution?: string;
url: UrlString;
// TODO: Should be an actual vocabulary.
// kind: MediaKind;
kind: "document" | "embed" | "image" | "link" | "video";
}
export interface VocabularyEntry {
id: string;
label: InternationalizedLabel;
related?: Array<{
relation_type: "broader" | "narrower" | "same-as";
related_vocabulary: VocabularyEntry["id"];
}>;
}
export interface PlaceType {
id: string;
label: InternationalizedLabel;
}
export interface Source {
citation: string;
}
export interface Biography {
id: string;
title?: string;
abstract?: string;
text: string;
citation?: string;
}
export interface EntityRelationRole {
id: string;
label: InternationalizedLabel;
}
export interface EventKind {
id: string;
label: InternationalizedLabel;
}
export interface EventEntityRelation {
// description?: string;
entity: Entity["id"];
role: EntityRelationRole["id"];
// source?: Source;
}
export interface EntityEventRelation {
// description?: string;
event: Event["id"];
role: EntityRelationRole["id"];
// source?: Source;
}
export interface Event {
id: string;
label: InternationalizedLabel;
description?: string;
kind: EventKind["id"];
// source?: Source;
startDate?: IsoDateString;
endDate?: IsoDateString;
media?: Array<MediaResource["id"]>;
relations: Array<EventEntityRelation>;
}
interface EntityBase {
id: string;
label: InternationalizedLabel;
description?: string;
alternativeLabels?: Array<InternationalizedLabel>;
// source?: Source;
linkedIds?: Array<{ url: UrlString; label: string }>;
media?: Array<MediaResource["id"]>;
biographies?: Array<Biography["id"]>;
relations: Array<EntityEventRelation>;
}
export interface CulturalHeritageObject extends EntityBase {
kind: "cultural-heritage-object";
type?: CulturalHeritageObjectType;
}
export interface Group extends EntityBase {
kind: "group";
type?: GroupType;
}
export interface HistoricalEvent extends EntityBase {
kind: "historical-event";
type?: HistoricalEventType;
}
export interface Person extends EntityBase {
kind: "person";
gender?: Gender;
occupations?: Array<Pick<VocabularyEntry, "id" | "label">>;
}
export interface Place extends EntityBase {
kind: "place";
type?: PlaceType;
geometry?: Geometry;
}
export type Entity = CulturalHeritageObject | Group | HistoricalEvent | Person | Place;
export type EntityKind = Entity["kind"];
export type EntityMap = {
[Kind in EntityKind]: Extract<Entity, { kind: Kind }>;
};
export const entityKinds: Array<EntityKind> = [
"cultural-heritage-object",
"group",
"historical-event",
"person",
"place",
];
export function isEntityKind(value: string): value is EntityKind {
return entityKinds.includes(value as EntityKind);
}