index.ts 181 KB
Newer Older
Stefan Probst's avatar
Stefan Probst committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * SSHOC Marketplace API
 *
 * Social Sciences and Humanities Open Cloud Marketplace
 *
 * License: Apache 2.0
 * Version: 0.1.1
 */

/* eslint-disable @typescript-eslint/no-namespace */

import type {
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult,
} from 'react-query'
Stefan Probst's avatar
Stefan Probst committed
18
import { useMutation, useQuery } from 'react-query'
Stefan Probst's avatar
Stefan Probst committed
19

Stefan Probst's avatar
Stefan Probst committed
20
export type LicenseTypeDto = {
Stefan Probst's avatar
Stefan Probst committed
21
22
23
24
  code?: string
  label?: string
}

Stefan Probst's avatar
Stefan Probst committed
25
export type ItemRelationDto = {
26
  code?: string
Stefan Probst's avatar
Stefan Probst committed
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
  label?: string
}

export type ItemRelationId = {
  code?: string
}

export type ItemBasicDto = {
  id?: number /* int64 */
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  version?: string
  persistentId?: string
}

export type ItemRelatedItemDto = {
  subject?: ItemBasicDto
  object?: ItemBasicDto
  relation?: ItemRelationDto
52
53
}

Stefan Probst's avatar
Stefan Probst committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
export type ActorDto = {
  id?: number /* int64 */
  name?: string
  externalIds?: Array<ActorExternalIdDto>
  website?: string
  email?: string
  affiliations?: Array<ActorDto>
}

export type ActorExternalIdDto = {
  identifierService?: ActorSourceDto
  identifier?: string
}

Stefan Probst's avatar
Stefan Probst committed
68
export type ActorSourceDto = {
Stefan Probst's avatar
Stefan Probst committed
69
70
71
72
  code?: string
  label?: string
}

Stefan Probst's avatar
Stefan Probst committed
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
export type PaginatedActors = {
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
  actors?: Array<ActorDto>
}

export type ActorCore = {
  name?: string
  externalIds?: Array<ActorExternalIdCore>
  website?: string
  email?: string
  affiliations?: Array<ActorId>
}

export type ActorExternalIdCore = {
  identifierService: ActorSourceId
  identifier: string
}

export type ActorId = {
  id?: number /* int64 */
}

export type ActorSourceId = {
  code?: string
}

export type ActorRoleDto = {
  code?: string
  label?: string
}

Stefan Probst's avatar
Stefan Probst committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
export type ConceptBasicDto = {
  code?: string
  vocabulary?: VocabularyBasicDto
  label?: string
  notation?: string
  definition?: string
  uri?: string
}

export type ItemContributorDto = {
  actor?: ActorDto
  role?: ActorRoleDto
}

export type ItemExternalIdDto = {
  identifierService?: ItemSourceDto
  identifier?: string
}

127
export type ItemMediaDto = {
Stefan Probst's avatar
Stefan Probst committed
128
  info?: MediaDetails
129
130
131
  caption?: string
}

Stefan Probst's avatar
Stefan Probst committed
132
133
134
135
136
export type ItemSourceDto = {
  code?: string
  label?: string
}

137
138
139
140
export type ItemThumbnailId = {
  mediaId?: string /* uuid */
}

Stefan Probst's avatar
Stefan Probst committed
141
142
143
144
145
146
147
export type LicenseDto = {
  code?: string
  label?: string
  types?: Array<LicenseTypeDto>
  accessibleAt?: string
}

148
149
150
151
152
153
154
155
156
157
158
export type MediaDetails = {
  mediaId?: string /* uuid */
  category?: 'image' | 'video' | 'object' | 'thumbnail'
  location?: MediaLocation
  filename?: string
  mimeType?: string
  hasThumbnail?: boolean
}

export type MediaLocation = {
  sourceUrl?: string /* url */
Stefan Probst's avatar
Stefan Probst committed
159
160
}

Stefan Probst's avatar
Stefan Probst committed
161
162
163
164
165
166
167
168
169
export type PaginatedWorkflows = {
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
  workflows?: Array<WorkflowDto>
}

Stefan Probst's avatar
Stefan Probst committed
170
171
172
173
174
175
176
export type PropertyDto = {
  id?: number /* int64 */
  type?: PropertyTypeDto
  value?: string
  concept?: ConceptBasicDto
}

Stefan Probst's avatar
Stefan Probst committed
177
178
179
180
181
182
183
184
185
186
export type PropertyTypeDto = {
  code?: string
  label?: string
  type?: 'concept' | 'string' | 'url' | 'int' | 'float' | 'date'
  groupName?: string
  hidden?: boolean
  ord?: number /* int32 */
  allowedVocabularies?: Array<VocabularyBasicDto>
}

Stefan Probst's avatar
Stefan Probst committed
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
export type RelatedItemDto = {
  id?: number /* int64 */
  persistentId?: string
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  description?: string
  relation?: ItemRelationDto
}

export type SourceBasicDto = {
  id?: number /* int64 */
  label?: string
  url?: string
  urlTemplate?: string
}

Stefan Probst's avatar
Stefan Probst committed
209
export type StepDto = {
Stefan Probst's avatar
Stefan Probst committed
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
  id?: number /* int64 */
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  version?: string
  persistentId?: string
  description?: string
  licenses?: Array<LicenseDto>
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  externalIds?: Array<ItemExternalIdDto>
  accessibleAt?: Array<string>
  source?: SourceBasicDto
  sourceItemId?: string
  relatedItems?: Array<RelatedItemDto>
230
231
  media?: Array<ItemMediaDto>
  thumbnail?: ItemThumbnailId
Stefan Probst's avatar
Stefan Probst committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
  informationContributor?: UserDto
  lastInfoUpdate?: string
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
  olderVersions?: Array<ItemBasicDto>
  newerVersions?: Array<ItemBasicDto>
}

export type UserDto = {
  id?: number /* int64 */
  username?: string
  displayName?: string
249
  status?: 'during-registration' | 'enabled' | 'locked'
Stefan Probst's avatar
Stefan Probst committed
250
251
252
253
254
  registrationDate?: string
  role?: 'contributor' | 'system-contributor' | 'moderator' | 'administrator'
  email?: string
}

Stefan Probst's avatar
Stefan Probst committed
255
256
export type VocabularyBasicDto = {
  code?: string
Stefan Probst's avatar
Stefan Probst committed
257
  label?: string
Stefan Probst's avatar
Stefan Probst committed
258
  accessibleAt?: string
Stefan Probst's avatar
Stefan Probst committed
259
260
}

Stefan Probst's avatar
Stefan Probst committed
261
export type WorkflowDto = {
Stefan Probst's avatar
Stefan Probst committed
262
  id?: number /* int64 */
Stefan Probst's avatar
Stefan Probst committed
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
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  version?: string
  persistentId?: string
  description?: string
  licenses?: Array<LicenseDto>
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  externalIds?: Array<ItemExternalIdDto>
  accessibleAt?: Array<string>
  source?: SourceBasicDto
  sourceItemId?: string
  relatedItems?: Array<RelatedItemDto>
  media?: Array<ItemMediaDto>
  thumbnail?: ItemThumbnailId
  informationContributor?: UserDto
  lastInfoUpdate?: string
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
  olderVersions?: Array<ItemBasicDto>
  newerVersions?: Array<ItemBasicDto>
  composedOf?: Array<StepDto>
296
297
}

Stefan Probst's avatar
Stefan Probst committed
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
export type ActorRoleId = {
  code?: string
}

export type ConceptId = {
  code?: string
  vocabulary?: VocabularyId
  uri?: string
}

export type ItemContributorId = {
  actor?: ActorId
  role?: ActorRoleId
}

export type ItemExternalIdCore = {
Stefan Probst's avatar
Stefan Probst committed
314
  identifierService: ItemExternalIdId
Stefan Probst's avatar
Stefan Probst committed
315
316
317
  identifier: string
}

318
319
320
321
322
export type ItemExternalIdId = {
  code?: string
}

export type ItemMediaCore = {
Stefan Probst's avatar
Stefan Probst committed
323
  info?: MediaDetailsId
324
325
326
  caption?: string
}

Stefan Probst's avatar
Stefan Probst committed
327
export type LicenseId = {
Stefan Probst's avatar
Stefan Probst committed
328
329
330
  code?: string
}

Stefan Probst's avatar
Stefan Probst committed
331
332
export type MediaDetailsId = {
  mediaId?: string /* uuid */
Stefan Probst's avatar
Stefan Probst committed
333
334
335
336
337
338
339
340
341
342
343
344
345
}

export type PropertyCore = {
  type?: PropertyTypeId
  value?: string
  concept?: ConceptId
}

export type PropertyTypeId = {
  code?: string
}

export type RelatedItemCore = {
346
  persistentId?: string
Stefan Probst's avatar
Stefan Probst committed
347
348
349
350
351
352
353
  relation?: ItemRelationId
}

export type SourceId = {
  id?: number /* int64 */
}

Stefan Probst's avatar
Stefan Probst committed
354
export type StepCore = {
Stefan Probst's avatar
Stefan Probst committed
355
356
357
358
359
360
361
362
  label?: string
  version?: string
  description?: string
  licenses?: Array<LicenseId>
  contributors?: Array<ItemContributorId>
  externalIds?: Array<ItemExternalIdCore>
  properties?: Array<PropertyCore>
  relatedItems?: Array<RelatedItemCore>
363
364
  media?: Array<ItemMediaCore>
  thumbnail?: ItemThumbnailId
Stefan Probst's avatar
Stefan Probst committed
365
366
367
  accessibleAt?: Array<string>
  source?: SourceId
  sourceItemId?: string
Stefan Probst's avatar
Stefan Probst committed
368
  stepNo?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
369
370
}

Stefan Probst's avatar
Stefan Probst committed
371
372
export type VocabularyId = {
  code?: string
373
374
}

Stefan Probst's avatar
Stefan Probst committed
375
376
377
378
379
380
381
382
383
384
385
386
387
388
export type WorkflowCore = {
  label?: string
  version?: string
  description?: string
  licenses?: Array<LicenseId>
  contributors?: Array<ItemContributorId>
  externalIds?: Array<ItemExternalIdCore>
  properties?: Array<PropertyCore>
  relatedItems?: Array<RelatedItemCore>
  media?: Array<ItemMediaCore>
  thumbnail?: ItemThumbnailId
  accessibleAt?: Array<string>
  source?: SourceId
  sourceItemId?: string
Stefan Probst's avatar
Stefan Probst committed
389
390
}

Stefan Probst's avatar
Stefan Probst committed
391
392
393
394
395
396
397
398
399
export type OAuthRegistrationData = {
  id?: number /* int64 */
  displayName?: string
  email?: string
  acceptedRegulations?: boolean
}

export type ConceptRelationDto = {
  code?: string
Stefan Probst's avatar
Stefan Probst committed
400
401
402
  label?: string
}

Stefan Probst's avatar
Stefan Probst committed
403
export type PaginatedLicenses = {
Stefan Probst's avatar
Stefan Probst committed
404
405
406
407
408
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
409
  licenses?: Array<LicenseDto>
Stefan Probst's avatar
Stefan Probst committed
410
411
}

Stefan Probst's avatar
Stefan Probst committed
412
413
414
415
416
417
418
export type ItemSourceCore = {
  code?: string
  label: string
  ord?: number /* int32 */
}

export type PublicationDto = {
Stefan Probst's avatar
Stefan Probst committed
419
420
421
422
423
424
425
426
  id?: number /* int64 */
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
Stefan Probst's avatar
Stefan Probst committed
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
  label?: string
  version?: string
  persistentId?: string
  description?: string
  licenses?: Array<LicenseDto>
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  externalIds?: Array<ItemExternalIdDto>
  accessibleAt?: Array<string>
  source?: SourceBasicDto
  sourceItemId?: string
  relatedItems?: Array<RelatedItemDto>
  media?: Array<ItemMediaDto>
  thumbnail?: ItemThumbnailId
  informationContributor?: UserDto
  lastInfoUpdate?: string
Stefan Probst's avatar
Stefan Probst committed
443
444
445
446
447
448
449
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
Stefan Probst's avatar
Stefan Probst committed
450
451
452
453
  olderVersions?: Array<ItemBasicDto>
  newerVersions?: Array<ItemBasicDto>
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
454
455
}

Stefan Probst's avatar
Stefan Probst committed
456
export type PublicationCore = {
Stefan Probst's avatar
Stefan Probst committed
457
  label?: string
Stefan Probst's avatar
Stefan Probst committed
458
459
460
461
462
463
464
465
466
467
468
469
470
471
  version?: string
  description?: string
  licenses?: Array<LicenseId>
  contributors?: Array<ItemContributorId>
  externalIds?: Array<ItemExternalIdCore>
  properties?: Array<PropertyCore>
  relatedItems?: Array<RelatedItemCore>
  media?: Array<ItemMediaCore>
  thumbnail?: ItemThumbnailId
  accessibleAt?: Array<string>
  source?: SourceId
  sourceItemId?: string
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
472
473
}

Stefan Probst's avatar
Stefan Probst committed
474
export type PaginatedPublications = {
Stefan Probst's avatar
Stefan Probst committed
475
476
477
478
479
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
480
  publications?: Array<PublicationDto>
Stefan Probst's avatar
Stefan Probst committed
481
482
}

Stefan Probst's avatar
Stefan Probst committed
483
export type ActorRoleCore = {
Stefan Probst's avatar
Stefan Probst committed
484
  code?: string
Stefan Probst's avatar
Stefan Probst committed
485
486
  label: string
  ord?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
487
488
}

Stefan Probst's avatar
Stefan Probst committed
489
490
491
492
493
494
495
export type PaginatedSources = {
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
  sources?: Array<SourceDto>
Stefan Probst's avatar
Stefan Probst committed
496
497
}

Stefan Probst's avatar
Stefan Probst committed
498
export type SourceDto = {
Stefan Probst's avatar
Stefan Probst committed
499
  id?: number /* int64 */
Stefan Probst's avatar
Stefan Probst committed
500
501
502
503
  label?: string
  url?: string
  urlTemplate?: string
  lastHarvestedDate?: string
Stefan Probst's avatar
Stefan Probst committed
504
505
}

Stefan Probst's avatar
Stefan Probst committed
506
export type SourceCore = {
Stefan Probst's avatar
Stefan Probst committed
507
  label?: string
Stefan Probst's avatar
Stefan Probst committed
508
509
  url?: string
  urlTemplate?: string
Stefan Probst's avatar
Stefan Probst committed
510
511
}

Stefan Probst's avatar
Stefan Probst committed
512
export type ToolCore = {
Stefan Probst's avatar
Stefan Probst committed
513
514
515
516
517
518
519
520
  label?: string
  version?: string
  description?: string
  licenses?: Array<LicenseId>
  contributors?: Array<ItemContributorId>
  externalIds?: Array<ItemExternalIdCore>
  properties?: Array<PropertyCore>
  relatedItems?: Array<RelatedItemCore>
521
522
  media?: Array<ItemMediaCore>
  thumbnail?: ItemThumbnailId
Stefan Probst's avatar
Stefan Probst committed
523
524
525
526
527
  accessibleAt?: Array<string>
  source?: SourceId
  sourceItemId?: string
}

Stefan Probst's avatar
Stefan Probst committed
528
export type ToolDto = {
Stefan Probst's avatar
Stefan Probst committed
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
  id?: number /* int64 */
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  version?: string
  persistentId?: string
  description?: string
  licenses?: Array<LicenseDto>
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  externalIds?: Array<ItemExternalIdDto>
  accessibleAt?: Array<string>
  source?: SourceBasicDto
  sourceItemId?: string
  relatedItems?: Array<RelatedItemDto>
549
550
  media?: Array<ItemMediaDto>
  thumbnail?: ItemThumbnailId
Stefan Probst's avatar
Stefan Probst committed
551
552
553
554
555
556
557
558
559
560
561
562
563
  informationContributor?: UserDto
  lastInfoUpdate?: string
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
  olderVersions?: Array<ItemBasicDto>
  newerVersions?: Array<ItemBasicDto>
}

Stefan Probst's avatar
Stefan Probst committed
564
export type PaginatedTools = {
Stefan Probst's avatar
Stefan Probst committed
565
566
567
568
569
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
570
  tools?: Array<ToolDto>
Stefan Probst's avatar
Stefan Probst committed
571
572
}

Stefan Probst's avatar
Stefan Probst committed
573
export type CountedPropertyType = {
Stefan Probst's avatar
Stefan Probst committed
574
  code?: string
Stefan Probst's avatar
Stefan Probst committed
575
576
577
  label?: string
  count?: number /* int64 */
  checked?: boolean
Stefan Probst's avatar
Stefan Probst committed
578
579
}

Stefan Probst's avatar
Stefan Probst committed
580
export type PaginatedSearchConcepts = {
Stefan Probst's avatar
Stefan Probst committed
581
582
583
584
585
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
586
587
588
  q?: string
  concepts?: Array<SearchConcept>
  types?: Record<string, CountedPropertyType>
Stefan Probst's avatar
Stefan Probst committed
589
590
}

Stefan Probst's avatar
Stefan Probst committed
591
export type SearchConcept = {
Stefan Probst's avatar
Stefan Probst committed
592
  code?: string
Stefan Probst's avatar
Stefan Probst committed
593
  vocabulary?: VocabularyId
Stefan Probst's avatar
Stefan Probst committed
594
595
596
597
  label?: string
  notation?: string
  definition?: string
  uri?: string
Stefan Probst's avatar
Stefan Probst committed
598
  types?: Array<PropertyTypeId>
Stefan Probst's avatar
Stefan Probst committed
599
600
}

Stefan Probst's avatar
Stefan Probst committed
601
602
603
604
605
606
607
608
export type CheckedCount = {
  count?: number /* int64 */
  checked?: boolean
}

export type LabeledCheckedCount = {
  count?: number /* int64 */
  checked?: boolean
Stefan Probst's avatar
Stefan Probst committed
609
610
611
  label?: string
}

Stefan Probst's avatar
Stefan Probst committed
612
export type PaginatedSearchItems = {
Stefan Probst's avatar
Stefan Probst committed
613
614
615
616
617
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
618
619
620
621
622
  q?: string
  order?: Array<'score' | 'label' | 'modified-on'>
  items?: Array<SearchItem>
  categories?: Record<string, LabeledCheckedCount>
  facets?: Record<string, Record<string, CheckedCount>>
Stefan Probst's avatar
Stefan Probst committed
623
624
}

Stefan Probst's avatar
Stefan Probst committed
625
626
627
export type SearchItem = {
  id?: number /* int64 */
  persistentId?: string
Stefan Probst's avatar
Stefan Probst committed
628
  label?: string
Stefan Probst's avatar
Stefan Probst committed
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
  description?: string
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
  owner?: string
Stefan Probst's avatar
Stefan Probst committed
647
648
}

Stefan Probst's avatar
Stefan Probst committed
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
export type SuggestedSearchPhrases = {
  phrase?: string
  suggestions?: Array<string>
}

export type ItemCommentCore = {
  body?: string
}

export type ItemCommentDto = {
  id?: number /* int64 */
  body?: string
  creator?: UserDto
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
}

export type PaginatedPropertyTypes = {
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
  propertyTypes?: Array<PropertyTypeDto>
}

export type PropertyTypeCore = {
  code?: string
  label?: string
  type?: 'concept' | 'string' | 'url' | 'int' | 'float' | 'date'
  groupName?: string
  hidden?: boolean
  ord?: number /* int32 */
  allowedVocabularies?: Array<string>
}

export type PropertyTypeReorder = {
  code: string
  ord?: number /* int32 */
}

export type PropertyTypesReordering = {
  shifts: Array<PropertyTypeReorder>
}

Stefan Probst's avatar
Stefan Probst committed
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
export type Resource = {
  open?: boolean
  file?: string /* binary */
  url?: string /* url */
  readable?: boolean
  uri?: string /* uri */
  filename?: string
  description?: string
  inputStream?: {}
}

export type MediaUploadInfo = {
  mediaId?: string /* uuid */
  filename?: string
  mimeType?: string
  nextChunkNo?: number /* int32 */
}

export type LoginData = {
  username?: string
  password?: string
}

export type PaginatedUsers = {
Stefan Probst's avatar
Stefan Probst committed
718
719
720
721
722
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
723
  users?: Array<UserDto>
Stefan Probst's avatar
Stefan Probst committed
724
725
}

Stefan Probst's avatar
Stefan Probst committed
726
727
728
729
export type ActorSourceCore = {
  code?: string
  label: string
  ord?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
730
731
}

Stefan Probst's avatar
Stefan Probst committed
732
733
734
735
export type MediaSourceDto = {
  code?: string
  serviceUrl?: string
  mediaCategory?: 'image' | 'video' | 'object' | 'thumbnail'
Stefan Probst's avatar
Stefan Probst committed
736
737
}

Stefan Probst's avatar
Stefan Probst committed
738
739
740
741
742
export type MediaSourceCore = {
  code?: string
  serviceUrl?: string
  mediaCategory?: 'image' | 'video' | 'object' | 'thumbnail'
  ord?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
743
744
}

Stefan Probst's avatar
Stefan Probst committed
745
746
747
748
749
750
751
752
753
754
755
756
export type ImplicitGrantTokenData = {
  token?: string
  registration?: boolean
}

export type OAuthRegistrationDto = {
  id?: number /* int64 */
  displayName?: string
  email?: string
}

export type DatasetDto = {
Stefan Probst's avatar
Stefan Probst committed
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
  id?: number /* int64 */
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  version?: string
  persistentId?: string
  description?: string
  licenses?: Array<LicenseDto>
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  externalIds?: Array<ItemExternalIdDto>
  accessibleAt?: Array<string>
  source?: SourceBasicDto
  sourceItemId?: string
  relatedItems?: Array<RelatedItemDto>
  media?: Array<ItemMediaDto>
  thumbnail?: ItemThumbnailId
  informationContributor?: UserDto
  lastInfoUpdate?: string
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
  olderVersions?: Array<ItemBasicDto>
  newerVersions?: Array<ItemBasicDto>
Stefan Probst's avatar
Stefan Probst committed
790
791
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
792
793
}

Stefan Probst's avatar
Stefan Probst committed
794
export type DatasetCore = {
Stefan Probst's avatar
Stefan Probst committed
795
796
797
798
799
800
801
802
803
804
805
806
807
  label?: string
  version?: string
  description?: string
  licenses?: Array<LicenseId>
  contributors?: Array<ItemContributorId>
  externalIds?: Array<ItemExternalIdCore>
  properties?: Array<PropertyCore>
  relatedItems?: Array<RelatedItemCore>
  media?: Array<ItemMediaCore>
  thumbnail?: ItemThumbnailId
  accessibleAt?: Array<string>
  source?: SourceId
  sourceItemId?: string
Stefan Probst's avatar
Stefan Probst committed
808
809
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
810
811
}

Stefan Probst's avatar
Stefan Probst committed
812
export type PaginatedDatasets = {
Stefan Probst's avatar
Stefan Probst committed
813
814
815
816
817
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
818
  datasets?: Array<DatasetDto>
Stefan Probst's avatar
Stefan Probst committed
819
820
}

Stefan Probst's avatar
Stefan Probst committed
821
export type TrainingMaterialDto = {
Stefan Probst's avatar
Stefan Probst committed
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
  id?: number /* int64 */
  category?:
    | 'tool-or-service'
    | 'training-material'
    | 'publication'
    | 'dataset'
    | 'workflow'
    | 'step'
  label?: string
  version?: string
  persistentId?: string
  description?: string
  licenses?: Array<LicenseDto>
  contributors?: Array<ItemContributorDto>
  properties?: Array<PropertyDto>
  externalIds?: Array<ItemExternalIdDto>
  accessibleAt?: Array<string>
  source?: SourceBasicDto
  sourceItemId?: string
  relatedItems?: Array<RelatedItemDto>
  media?: Array<ItemMediaDto>
  thumbnail?: ItemThumbnailId
  informationContributor?: UserDto
  lastInfoUpdate?: string
  status?:
    | 'draft'
    | 'ingested'
    | 'suggested'
    | 'approved'
    | 'disapproved'
    | 'deprecated'
  olderVersions?: Array<ItemBasicDto>
  newerVersions?: Array<ItemBasicDto>
Stefan Probst's avatar
Stefan Probst committed
855
856
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
857
858
}

Stefan Probst's avatar
Stefan Probst committed
859
export type TrainingMaterialCore = {
Stefan Probst's avatar
Stefan Probst committed
860
861
862
863
864
865
866
867
868
869
870
871
872
  label?: string
  version?: string
  description?: string
  licenses?: Array<LicenseId>
  contributors?: Array<ItemContributorId>
  externalIds?: Array<ItemExternalIdCore>
  properties?: Array<PropertyCore>
  relatedItems?: Array<RelatedItemCore>
  media?: Array<ItemMediaCore>
  thumbnail?: ItemThumbnailId
  accessibleAt?: Array<string>
  source?: SourceId
  sourceItemId?: string
Stefan Probst's avatar
Stefan Probst committed
873
874
  dateCreated?: string
  dateLastUpdated?: string
Stefan Probst's avatar
Stefan Probst committed
875
876
}

Stefan Probst's avatar
Stefan Probst committed
877
export type PaginatedTrainingMaterials = {
Stefan Probst's avatar
Stefan Probst committed
878
879
880
881
882
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
883
  trainingMaterials?: Array<TrainingMaterialDto>
Stefan Probst's avatar
Stefan Probst committed
884
885
}

Stefan Probst's avatar
Stefan Probst committed
886
887
888
889
890
891
892
export type PaginatedVocabularies = {
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
  vocabularies?: Array<VocabularyBasicDto>
Stefan Probst's avatar
Stefan Probst committed
893
894
}

Stefan Probst's avatar
Stefan Probst committed
895
896
897
export type ConceptDto = {
  code?: string
  vocabulary?: VocabularyBasicDto
Stefan Probst's avatar
Stefan Probst committed
898
  label?: string
Stefan Probst's avatar
Stefan Probst committed
899
900
901
902
  notation?: string
  definition?: string
  uri?: string
  relatedConcepts?: Array<RelatedConceptDto>
Stefan Probst's avatar
Stefan Probst committed
903
904
}

Stefan Probst's avatar
Stefan Probst committed
905
export type PaginatedConcepts = {
Stefan Probst's avatar
Stefan Probst committed
906
907
908
909
910
  hits?: number /* int64 */
  count?: number /* int32 */
  page?: number /* int32 */
  perpage?: number /* int32 */
  pages?: number /* int32 */
Stefan Probst's avatar
Stefan Probst committed
911
  concepts?: Array<ConceptDto>
Stefan Probst's avatar
Stefan Probst committed
912
913
}

Stefan Probst's avatar
Stefan Probst committed
914
915
916
export type RelatedConceptDto = {
  code?: string
  vocabulary?: VocabularyBasicDto
Stefan Probst's avatar
Stefan Probst committed
917
  label?: string
Stefan Probst's avatar
Stefan Probst committed
918
919
920
921
922
923
924
925
926
927
  notation?: string
  definition?: string
  uri?: string
  relation?: ConceptRelationDto
}

export type VocabularyDto = {
  code?: string
  label?: string
  accessibleAt?: string
Stefan Probst's avatar
Stefan Probst committed
928
  description?: string
Stefan Probst's avatar
Stefan Probst committed
929
  conceptResults?: PaginatedConcepts
Stefan Probst's avatar
Stefan Probst committed
930
931
}

Stefan Probst's avatar
Stefan Probst committed
932
933
const defaultBaseUrl =
  process.env.SSHOC_API_BASE_URL ?? process.env.NEXT_PUBLIC_SSHOC_API_BASE_URL
Stefan Probst's avatar
Stefan Probst committed
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956

export { defaultBaseUrl as baseUrl }

export class HttpError extends Error {
  response: Response
  statusCode: number

  constructor(response: Response, message?: string) {
    super((message ?? response.statusText) || 'Unexpected HTTP error.')
    this.name = 'HttpError'
    this.response = response
    this.statusCode = response.status
  }
}

function createUrl(
  path: string,
  baseUrl = defaultBaseUrl,
  query: Record<string, unknown> = {},
) {
  const url = new URL(path, baseUrl)
  Object.entries(query).forEach(([key, value]) => {
    if (Array.isArray(value)) {
Stefan Probst's avatar
Stefan Probst committed
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
      value.forEach((v) => {
        if (v != null) {
          url.searchParams.append(key, String(v))
        }
      })
    } else if (value != null) {
      url.searchParams.set(key, String(value))
    }
  })
  return url.toString()
}

type RequestOptions<T> = {
  hooks?: {
    request?: (request: Request) => Request
    response?: (response: Response) => Promise<T>
  }
  token?: string
}
export async function request<T = unknown>({
  path,
  baseUrl,
  query,
  options,
  hooks = {},
  token,
  returnType = 'json',
}: {
  path: string
  baseUrl?: string
  query?: Record<string, unknown>
  options?: RequestInit
  hooks?: RequestOptions<T>['hooks']
  token?: RequestOptions<T>['token']
  returnType?: 'json'
}): Promise<T> {
  const url = createUrl(path, baseUrl, query)
  const req = new Request(url, options)
  const request = typeof hooks.request === 'function' ? hooks.request(req) : req
  if (token !== undefined && token.length > 0) {
    request.headers.set('Authorization', token)
  }
  const response = await fetch(request)
  if (!response.ok) {
For faster browsing, not all history is shown. View entire blame