Skip to content

Commit 3d38ff3

Browse files
committed
Merge branch 'develop' of github.com:IQSS/dataverse-client-javascript into 167-get-all-facets
2 parents 7fd61ba + 75c2f56 commit 3d38ff3

26 files changed

+1235
-354
lines changed

docs/useCases.md

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The different use cases currently available in the package are classified below,
1212
- [Collections read use cases](#collections-read-use-cases)
1313
- [Get a Collection](#get-a-collection)
1414
- [Get Collection Facets](#get-collection-facets)
15+
- [Get User Permissions on a Collection](#get-user-permissions-on-a-collection)
1516
- [Collections write use cases](#collections-write-use-cases)
1617
- [Create a Collection](#create-a-collection)
1718
- [Datasets](#Datasets)
@@ -130,6 +131,34 @@ The `collectionIdOrAlias` is a generic collection identifier, which can be eithe
130131

131132
If no collection identifier is specified, the default collection identifier; `root` will be used. If you want to search for a different collection, you must add the collection identifier as a parameter in the use case call.
132133

134+
#### Get User Permissions on a Collection
135+
136+
Returns an instance of [CollectionUserPermissions](../src/collections/domain/models/CollectionUserPermissions.ts) that includes the permissions that the calling user has on a particular Collection.
137+
138+
##### Example call:
139+
140+
```typescript
141+
import { getCollectionUserPermissions } from '@iqss/dataverse-client-javascript'
142+
143+
/* ... */
144+
145+
const collectionIdOrAlias = 12345
146+
147+
getCollectionUserPermissions
148+
.execute(collectionIdOrAlias)
149+
.then((permissions: CollectionUserPermissions) => {
150+
/* ... */
151+
})
152+
153+
/* ... */
154+
```
155+
156+
_See [use case](../src/collections/domain/useCases/GetCollectionUserPermissions.ts) implementation_.
157+
158+
The `collectionIdOrAlias` is a generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId).
159+
160+
If no collection identifier is specified, the default collection identifier; `root` will be used. If you want to search for a different collection, you must add the collection identifier as a parameter in the use case call.
161+
133162
### Collections Write Use Cases
134163

135164
#### Create a Collection
@@ -874,7 +903,7 @@ getDatasetFiles
874903
These use cases are designed to facilitate the uploading of files to a remote S3 storage and subsequently adding them to a dataset. This process involves two main steps / use cases:
875904

876905
1. Uploading a file to remote S3 storage and obtaining a storage identifier.
877-
2. Adding the uploaded file to the dataset using the obtained storage identifier.
906+
2. Adding one or more uploaded files to the dataset using the obtained storage identifiers.
878907

879908
This use case flow is entirely based on the Direct Upload API as described in the Dataverse documentation: https://guides.dataverse.org/en/latest/developers/s3-direct-upload-api.html
880909

@@ -911,35 +940,41 @@ The `progress` parameter represents a callback function that allows the caller t
911940

912941
The `abortController` is a built-in mechanism in modern web browsers that allows the cancellation of asynchronous operations. It works in conjunction with an associated AbortSignal, which will be passed to the file uploading API calls to monitor whether the operation should be aborted, if the caller decides to cancel the operation midway.
913942

914-
##### Add Uploaded File to the Dataset
943+
##### Add Uploaded Files to the Dataset
915944

916-
This use case involves adding a file that has been previously uploaded to remote storage to the dataset.
945+
This use case involves adding files that have been previously uploaded to remote storage to the dataset.
917946

918947
###### Example call:
919948

920949
```typescript
921-
import { addUploadedFileToDataset } from '@iqss/dataverse-client-javascript'
950+
import { addUploadedFilesToDataset } from '@iqss/dataverse-client-javascript'
951+
import { UploadedFileDTO } from '@iqss/dataverse-client-javascript'
922952

923953
/* ... */
924954

925955
const datasetId: number | string = 123
926-
const file: File = new File(['content'], 'example.txt', { type: 'text/plain' })
927-
const storageId: string = 'some-storage-identifier'
928-
929-
addUploadedFileToDataset.execute(datasetId, file, storageId).then(() => {
930-
console.log('File added to the dataset successfully.')
956+
const uploadedFileDTOs: UploadedFileDTO[] = [
957+
{
958+
fileName: 'the-file-name',
959+
storageId: 'localstack1://mybucket:19121faf7e7-2c40322ff54e',
960+
checksumType: 'md5',
961+
checksumValue: 'ede3d3b685b4e137ba4cb2521329a75e',
962+
mimeType: 'text/plain'
963+
}
964+
]
965+
966+
addUploadedFilesToDataset.execute(datasetId, uploadedFileDTOs).then(() => {
967+
console.log('Files added to the dataset successfully.')
931968
})
932969

933970
/* ... */
934971
```
935972

936-
_See [use case](../src/files/domain/useCases/AddUploadedFileToDataset.ts) implementation_.
973+
_See [use case](../src/files/domain/useCases/AddUploadedFilesToDataset.ts) implementation_.
937974

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

940-
The `file` parameter is a subclass of Blob (Binary Large Object) that represents a file.
941-
942-
The `storageId` parameter represents the storage identifier obtained after a successful call to the UploadFile use case.
977+
The `uploadedFileDTOs` parameter is an array of [UploadedFileDTO](../src/files/domain/dtos/UploadedFileDTO.ts) and includes properties related to the uploaded files. Some of these properties should be calculated from the uploaded File Blob objects and the resulting storage identifiers from the Upload File use case.
943978

944979
##### Error handling:
945980

0 commit comments

Comments
 (0)