/
createResourceFormats.ts
240 lines (205 loc) · 7.16 KB
/
createResourceFormats.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
/*
* Copyright © 2015-2019 the contributors (see Contributors.md).
*
* This file is part of Knora.
*
* Knora is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Knora is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with Knora. If not, see <http://www.gnu.org/licenses/>.
*/
import {basicMessageComponents} from "./basicMessageComponents"
/**
* This module contains interfaces that represent requests to create a new resource
* and the response to such a request.
*/
export module createResourceFormats {
/**
* Represents a property value in the response of a newly created resource.
*/
interface resultItem {
/**
* The property's value
*/
value:{
/**
* Text representation of the value
*/
textval: {
string: string;
}
/**
* Set if value is of type integer value
*/
ival: {
integer: number;
} | null;
/**
* Set if value is of type decimal value (floating point number)
*/
dval: {
decimal: number;
} | null;
/**
* Set if value is of type date value.
* Represents the start date.
*/
dateval1: {
string: string;
} | null;
/**
* Set if value is of type date value.
* Represents the end date.
*/
dateval2: {
string: string;
} | null;
/**
* Set if value is of type date value.
* Represents the precision of the start date.
*/
dateprecision1: {
string: string;
} | null;
/**
* Set if value is of type date value.
* Represents the precision of the end date.
*/
dateprecision2: {
string: string;
} | null;
/**
* Set if value is of type date value.
* Represents the date's calendar.
*/
calendar: {
string: string;
} | null;
/**
* Set if value is of type interval value.
* Represents the start of the interval.
*/
timeval1:{
decimal: number;
} | null;
/**
* Set if value is of type interval value.
* Represents the end of the interval.
*/
timeval2:{
decimal: number;
} | null;
/**
* The IRI of the property type the value belongs to
*/
property_id: {
string: basicMessageComponents.KnoraIRI;
}
/**
* The IRI of the person that created the value
*/
person_id: {
string: basicMessageComponents.KnoraIRI;
}
/**
* The order of the value
*/
order: {
integer: number;
}
/**
* The IRI of the resource the value belongs to.
*/
resource_id: {
string: basicMessageComponents.KnoraIRI;
}
}
/**
* The property value's IRI
*/
id: basicMessageComponents.KnoraIRI;
}
/**
* Represents a resource creation request without providing information about a digital representation.
*
* This definition describes the JSON to be sent as the HTTP body in a POST request to http://host/v1/resources
*
* However, this format may part of a HTTP Multipart request (in that case, do not set the content type to "application/json").
*
*/
export interface createResourceWithoutRepresentationRequest {
/**
* The IRI of the resource class the new resource belongs to.
*/
restype_id: basicMessageComponents.KnoraIRI;
/**
* A map of property types to property values to be assigned to the new resource.
* Each property type requests a specific value type. These assignments are defined in the project ontologies.
*
*/
properties:{
[index:string]:Array<basicMessageComponents.richtextValue>|Array<basicMessageComponents.linkValue>|Array<basicMessageComponents.integerValue>
|Array<basicMessageComponents.decimalValue>|Array<basicMessageComponents.booleanValue>|Array<basicMessageComponents.uriValue>
|Array<basicMessageComponents.dateValue>|Array<basicMessageComponents.colorValue>|Array<basicMessageComponents.geometryValue>
|Array<basicMessageComponents.hierarchicalListValue>|Array<basicMessageComponents.intervalValue>|Array<basicMessageComponents.timeValue>|Array<basicMessageComponents.geonameValue>;
}
/**
* The IRI of the project the new resource belongs to.
*/
project_id: basicMessageComponents.KnoraIRI;
/**
* The label describing the new resource.
*/
label: string;
}
/**
* Represents a resource creation request providing a digital representation (GUI-case).
*
* This definition describes the JSON to be sent as the HTTP body in a POST request to http://host/v1/resources
*/
export interface createResourceWithRepresentationRequest extends createResourceWithoutRepresentationRequest, basicMessageComponents.createOrChangeFileValueRequest {}
/**
* Represents the answer to a create resource request.
*/
export interface createResourceResponse extends basicMessageComponents.basicResponse {
/**
* The IRI of the new resource
*/
res_id: basicMessageComponents.KnoraIRI;
/**
* A map of property types to property values
*/
results: {
[index:string]:Array<resultItem>
}
}
/**
* Represents a request to change a resource's label.
*
* This definition describes the JSON to be sent as the HTTP body in a PUT request to http://host/v1/resources/label/resourceIri
*/
export interface changeResourceLabelRequest {
/**
* The new label of the resource.
*/
label: string;
}
export interface changeResourceLabelResponse extends basicMessageComponents.basicResponse {
/**
* The IRI of the resource whose label has been changed.
*/
res_id: basicMessageComponents.KnoraIRI;
/**
* The new label of the resource.
*/
label: string;
}
}