Skip to content

Commit 554dbe0

Browse files
authored
Merge pull request #429 from IQSS/424-use-cases-to-support-download-terms-of-use-and-guestbook
Use Cases of Download with Guestbooks - Tests are passing locally and in GH.
2 parents 1681f53 + b3bb1e5 commit 554dbe0

35 files changed

Lines changed: 1511 additions & 9 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
1616
- New Use Case: [Get a Template](./docs/useCases.md#get-a-template) under Templates.
1717
- New Use Case: [Delete a Template](./docs/useCases.md#delete-a-template) under Templates.
1818
- New Use Case: [Update Terms of Access](./docs/useCases.md#update-terms-of-access).
19+
- Guestbooks: Added use cases and repository support for guestbook creation, listing, and enabling/disabling.
20+
- Guestbooks: Added dataset-level guestbook assignment and removal support via `assignDatasetGuestbook` (`PUT /api/datasets/{identifier}/guestbook`) and `removeDatasetGuestbook` (`DELETE /api/datasets/{identifier}/guestbook`).
21+
- Datasets/Guestbooks: Added `guestbookId` in `getDataset` responses.
22+
- Access: Added`access` module for guestbook-at-request and download terms/guestbook submission endpoints.
1923
- DatasetType: Updated datasetType data model. Added two more fields: description and displayName.
2024

2125
### Changed

docs/useCases.md

Lines changed: 299 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ The different use cases currently available in the package are classified below,
124124
- [Get External Tools](#get-external-tools)
125125
- [Get Dataset External Tool Resolved](#get-dataset-external-tool-resolved)
126126
- [Get File External Tool Resolved](#get-file-external-tool-resolved)
127+
- [Guestbooks](#Guestbooks)
128+
- [Guestbooks read use cases](#guestbooks-read-use-cases)
129+
- [Get a Guestbook](#get-a-guestbook)
130+
- [Get Guestbooks By Collection Id](#get-guestbooks-by-collection-id)
131+
- [Guestbooks write use cases](#guestbooks-write-use-cases)
132+
- [Create a Guestbook](#create-a-guestbook)
133+
- [Set Guestbook Enabled](#set-guestbook-enabled)
134+
- [Assign Dataset Guestbook](#assign-dataset-guestbook)
135+
- [Remove Dataset Guestbook](#remove-dataset-guestbook)
136+
- [Access](#Access)
137+
- [Access write use cases](#access-write-use-cases)
138+
- [Submit Guestbook For Datafile Download](#submit-guestbook-for-datafile-download)
139+
- [Submit Guestbook For Datafiles Download](#submit-guestbook-for-datafiles-download)
140+
- [Submit Guestbook For Dataset Download](#submit-guestbook-for-dataset-download)
141+
- [Submit Guestbook For Dataset Version Download](#submit-guestbook-for-dataset-version-download)
127142

128143
## Collections
129144

@@ -1009,7 +1024,7 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetAvailableDatasetTypes.
10091024

10101025
#### Get Dataset Available Dataset Type
10111026

1012-
Returns an available dataset types that can be used at dataset creation.
1027+
Returns a single available dataset type that can be used at dataset creation.
10131028

10141029
###### Example call:
10151030

@@ -1018,13 +1033,31 @@ import { getDatasetAvailableDatasetType } from '@iqss/dataverse-client-javascrip
10181033

10191034
/* ... */
10201035

1021-
getDatasetAvailableDatasetType.execute().then((datasetType: DatasetType) => {
1036+
const datasetTypeIdOrName = 'dataset'
1037+
1038+
getDatasetAvailableDatasetType.execute(datasetTypeIdOrName).then((datasetType: DatasetType) => {
10221039
/* ... */
10231040
})
10241041
```
10251042

10261043
_See [use case](../src/datasets/domain/useCases/GetDatasetAvailableDatasetType.ts) implementation_.
10271044

1045+
The `datasetTypeIdOrName` parameter can be either the numeric dataset type id or its name.
1046+
1047+
Example returned value:
1048+
1049+
```typescript
1050+
{
1051+
id: 1,
1052+
name: 'dataset',
1053+
displayName: 'Dataset',
1054+
linkedMetadataBlocks: [],
1055+
availableLicenses: [],
1056+
description:
1057+
'A study, experiment, set of observations, or publication. A dataset can comprise a single file or multiple files.'
1058+
}
1059+
```
1060+
10281061
### Datasets Write Use Cases
10291062

10301063
#### Create a Dataset
@@ -1399,8 +1432,6 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetAvailableCategories.ts
13991432

14001433
The `datasetId` parameter is a number for numeric identifiers or string for persistent identifiers.
14011434

1402-
# <<<<<<< HEAD
1403-
14041435
#### Get Dataset Templates
14051436

14061437
Returns a [DatasetTemplate](../src/datasets/domain/models/DatasetTemplate.ts) array containing the dataset templates of the requested collection, given the collection identifier or alias.
@@ -1443,11 +1474,9 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetStorageDriver.ts) impl
14431474

14441475
The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
14451476

1446-
> > > > > > > develop
1447-
14481477
#### Add a Dataset Type
14491478

1450-
Adds a dataset types that can be used at dataset creation.
1479+
Adds a dataset type that can be used at dataset creation.
14511480

14521481
###### Example call:
14531482

@@ -1456,13 +1485,23 @@ import { addDatasetType } from '@iqss/dataverse-client-javascript'
14561485

14571486
/* ... */
14581487

1488+
const datasetType = {
1489+
name: 'software',
1490+
displayName: 'Software',
1491+
linkedMetadataBlocks: ['codeMeta20'],
1492+
availableLicenses: ['MIT', 'Apache-2.0'],
1493+
description: 'Software data and metadata.'
1494+
}
1495+
14591496
addDatasetType.execute(datasetType).then((datasetType: DatasetType) => {
14601497
/* ... */
14611498
})
14621499
```
14631500

14641501
_See [use case](../src/datasets/domain/useCases/AddDatasetType.ts) implementation_.
14651502

1503+
The `datasetType` parameter must match [DatasetTypeDTO](../src/datasets/domain/dtos/DatasetTypeDTO.ts) and includes all [DatasetType](../src/datasets/domain/models/DatasetType.ts) fields except `id`.
1504+
14661505
#### Link Dataset Type with Metadata Blocks
14671506

14681507
Link a dataset type with metadata blocks.
@@ -2792,3 +2831,256 @@ getFileExternalToolResolved
27922831
```
27932832

27942833
_See [use case](../src/externalTools/domain/useCases/GetfileExternalToolResolved.ts) implementation_.
2834+
2835+
## Guestbooks
2836+
2837+
### Guestbooks Read Use Cases
2838+
2839+
#### Get a Guestbook
2840+
2841+
Returns a [Guestbook](../src/guestbooks/domain/models/Guestbook.ts) by its id.
2842+
2843+
##### Example call:
2844+
2845+
```typescript
2846+
import { getGuestbook } from '@iqss/dataverse-client-javascript'
2847+
2848+
const guestbookId = 123
2849+
2850+
getGuestbook.execute(guestbookId).then((guestbook: Guestbook) => {
2851+
/* ... */
2852+
})
2853+
```
2854+
2855+
_See [use case](../src/guestbooks/domain/useCases/GetGuestbook.ts) implementation_.
2856+
2857+
#### Get Guestbooks By Collection Id
2858+
2859+
Returns all [Guestbook](../src/guestbooks/domain/models/Guestbook.ts) entries available for a collection.
2860+
2861+
##### Example call:
2862+
2863+
```typescript
2864+
import { getGuestbooksByCollectionId } from '@iqss/dataverse-client-javascript'
2865+
2866+
const collectionIdOrAlias = 'root'
2867+
2868+
getGuestbooksByCollectionId.execute(collectionIdOrAlias).then((guestbooks: Guestbook[]) => {
2869+
/* ... */
2870+
})
2871+
```
2872+
2873+
_See [use case](../src/guestbooks/domain/useCases/GetGuestbooksByCollectionId.ts) implementation_.
2874+
2875+
### Guestbooks Write Use Cases
2876+
2877+
#### Create a Guestbook
2878+
2879+
Creates a guestbook on a collection using [CreateGuestbookDTO](../src/guestbooks/domain/dtos/CreateGuestbookDTO.ts).
2880+
2881+
##### Example call:
2882+
2883+
```typescript
2884+
import { createGuestbook } from '@iqss/dataverse-client-javascript'
2885+
2886+
const collectionIdOrAlias = 'root'
2887+
const guestbook: CreateGuestbookDTO = {
2888+
name: 'my test guestbook',
2889+
enabled: true,
2890+
emailRequired: true,
2891+
nameRequired: true,
2892+
institutionRequired: false,
2893+
positionRequired: false,
2894+
customQuestions: [
2895+
{
2896+
question: 'Describe yourself',
2897+
required: false,
2898+
displayOrder: 1,
2899+
type: 'textarea',
2900+
hidden: false
2901+
}
2902+
]
2903+
}
2904+
2905+
createGuestbook.execute(guestbook, collectionIdOrAlias).then(() => {
2906+
/* ... */
2907+
})
2908+
```
2909+
2910+
_See [use case](../src/guestbooks/domain/useCases/CreateGuestbook.ts) implementation_.
2911+
2912+
#### Set Guestbook Enabled
2913+
2914+
Enables or disables a guestbook in a collection.
2915+
2916+
##### Example call:
2917+
2918+
```typescript
2919+
import { setGuestbookEnabled } from '@iqss/dataverse-client-javascript'
2920+
2921+
const collectionIdOrAlias = 'root'
2922+
const guestbookId = 123
2923+
const enabled = false
2924+
2925+
setGuestbookEnabled.execute(collectionIdOrAlias, guestbookId, false).then(() => {
2926+
/* ... */
2927+
})
2928+
```
2929+
2930+
_See [use case](../src/guestbooks/domain/useCases/SetGuestbookEnabled.ts) implementation_.
2931+
2932+
#### Assign Dataset Guestbook
2933+
2934+
Assigns a guestbook to a dataset using `PUT /api/datasets/{identifier}/guestbook`.
2935+
2936+
##### Example call:
2937+
2938+
```typescript
2939+
import { assignDatasetGuestbook } from '@iqss/dataverse-client-javascript'
2940+
2941+
const datasetIdOrPersistentId = 123
2942+
const guestbookId = 456
2943+
2944+
assignDatasetGuestbook.execute(datasetIdOrPersistentId, guestbookId).then(() => {
2945+
/* ... */
2946+
})
2947+
```
2948+
2949+
_See [use case](../src/guestbooks/domain/useCases/AssignDatasetGuestbook.ts) implementation_.
2950+
2951+
#### Remove Dataset Guestbook
2952+
2953+
Removes the guestbook assignment for a dataset using `DELETE /api/datasets/{identifier}/guestbook`.
2954+
2955+
##### Example call:
2956+
2957+
```typescript
2958+
import { removeDatasetGuestbook } from '@iqss/dataverse-client-javascript'
2959+
2960+
const datasetIdOrPersistentId = 123
2961+
2962+
removeDatasetGuestbook.execute(datasetIdOrPersistentId).then(() => {
2963+
/* ... */
2964+
})
2965+
```
2966+
2967+
_See [use case](../src/guestbooks/domain/useCases/RemoveDatasetGuestbook.ts) implementation_.
2968+
2969+
## Access
2970+
2971+
### Access Read Use Cases
2972+
2973+
### Access Write Use Cases
2974+
2975+
#### Submit Guestbook For Datafile Download
2976+
2977+
Submits guestbook answers for a datafile and returns a signed URL.
2978+
2979+
##### Example call:
2980+
2981+
```typescript
2982+
import { submitGuestbookForDatafileDownload } from '@iqss/dataverse-client-javascript'
2983+
2984+
submitGuestbookForDatafileDownload
2985+
.execute(10, {
2986+
guestbookResponse: {
2987+
answers: [
2988+
{ id: 123, value: 'Good' },
2989+
{ id: 124, value: ['Multi', 'Line'] }
2990+
]
2991+
}
2992+
})
2993+
.then((signedUrl: string) => {
2994+
/* ... */
2995+
})
2996+
```
2997+
2998+
_See [use case](../src/access/domain/useCases/SubmitGuestbookForDatafileDownload.ts) implementation_.
2999+
3000+
#### Submit Guestbook For Datafiles Download
3001+
3002+
Submits guestbook answers for multiple files and returns a signed URL.
3003+
3004+
##### Example call:
3005+
3006+
```typescript
3007+
import { submitGuestbookForDatafilesDownload } from '@iqss/dataverse-client-javascript'
3008+
3009+
submitGuestbookForDatafilesDownload
3010+
.execute([10, 11], {
3011+
guestbookResponse: {
3012+
answers: [
3013+
{ id: 123, value: 'Good' },
3014+
{ id: 124, value: ['Multi', 'Line'] },
3015+
{ id: 125, value: 'Yellow' }
3016+
]
3017+
}
3018+
})
3019+
.then((signedUrl: string) => {
3020+
/* ... */
3021+
})
3022+
```
3023+
3024+
_See [use case](../src/access/domain/useCases/SubmitGuestbookForDatafilesDownload.ts) implementation_.
3025+
3026+
#### Submit Guestbook For Dataset Download
3027+
3028+
Submits guestbook answers for dataset download and returns a signed URL.
3029+
3030+
##### Example call:
3031+
3032+
```typescript
3033+
import { submitGuestbookForDatasetDownload } from '@iqss/dataverse-client-javascript'
3034+
3035+
submitGuestbookForDatasetDownload
3036+
.execute('doi:10.5072/FK2/XXXXXX', {
3037+
guestbookResponse: {
3038+
answers: [
3039+
{ id: 123, value: 'Good' },
3040+
{ id: 124, value: ['Multi', 'Line'] },
3041+
{ id: 125, value: 'Yellow' }
3042+
]
3043+
}
3044+
})
3045+
.then((signedUrl: string) => {
3046+
/* ... */
3047+
})
3048+
```
3049+
3050+
_See [use case](../src/access/domain/useCases/SubmitGuestbookForDatasetDownload.ts) implementation_.
3051+
3052+
#### Submit Guestbook For Dataset Version Download
3053+
3054+
Submits guestbook answers for a specific dataset version and returns a signed URL.
3055+
3056+
##### Example call:
3057+
3058+
```typescript
3059+
import { submitGuestbookForDatasetVersionDownload } from '@iqss/dataverse-client-javascript'
3060+
3061+
submitGuestbookForDatasetVersionDownload
3062+
.execute(10, ':latest', {
3063+
guestbookResponse: {
3064+
name: 'Jane Doe',
3065+
email: 'jane@example.org',
3066+
institution: 'Example University',
3067+
position: 'Researcher',
3068+
answers: [
3069+
{ id: 123, value: 'Good' },
3070+
{ id: 124, value: ['Multi', 'Line'] },
3071+
{ id: 125, value: 'Yellow' }
3072+
]
3073+
}
3074+
})
3075+
.then((signedUrl: string) => {
3076+
/* ... */
3077+
})
3078+
```
3079+
3080+
_See [use case](../src/access/domain/useCases/SubmitGuestbookForDatasetVersionDownload.ts) implementation_.
3081+
3082+
The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
3083+
3084+
The `versionId` parameter accepts a numbered version such as `'1.0'` or a non-numbered version such as `':latest'`.
3085+
3086+
The third parameter must match [GuestbookResponseDTO](../src/access/domain/dtos/GuestbookResponseDTO.ts). The resolved value is a signed download URL as a string.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export interface GuestbookAnswerDTO {
2+
id: number | string
3+
value: string | string[]
4+
}
5+
6+
export interface GuestbookResponseDTO {
7+
guestbookResponse: {
8+
name?: string
9+
email?: string
10+
institution?: string
11+
position?: string
12+
answers?: GuestbookAnswerDTO[]
13+
}
14+
}

0 commit comments

Comments
 (0)