Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel

### Added

- Datasets: Added `updateDatasetLicense` use case and repository method to support Dataverse endpoint `PUT /datasets/{id}/license`, for updating dataset license or custom terms.
- Datasets: Added `getDatasetStorageDriver` use case and repository method to support Dataverse endpoint `GET /datasets/{identifier}/storageDriver`, for retrieving dataset storage driver configuration with properties: name, type, label, directUpload, directDownload, and uploadOutOfBand.
- Datasets: Added `getDatasetUploadLimits` use case and repository method to support Dataverse endpoint `GET /datasets/{id}/uploadlimits`, for retrieving remaining storage upload quotas, if present.
- New Use Case: [Get Collections For Linking Use Case](./docs/useCases.md#get-collections-for-linking).
- New Use Case: [Update Dataset License](./docs/useCases.md#update-dataset-license) under Datasets.
- New Use Case: [Get Dataset Storage Driver](./docs/useCases.md#get-dataset-storage-driver) under Datasets.
- New Use Case: [Get Dataset Upload Limits](./docs/useCases.md#get-dataset-upload-limits) under Datasets.
- New Use Case: [Update Terms of Access](./docs/useCases.md#update-terms-of-access) under Datasets.
- New Use Case: [Create a Template](./docs/useCases.md#create-a-template) under Templates.
- New Use Case: [Get a Template](./docs/useCases.md#get-a-template) under Templates.
- New Use Case: [Delete a Template](./docs/useCases.md#delete-a-template) under Templates.
- Templates: Added `setTemplateAsDefault` use case and repository method to support Dataverse endpoint `POST /dataverses/{id}/template/default/{templateId}`.
- Templates: Added `unsetTemplateAsDefault` use case and repository method to support Dataverse endpoint `DELETE /dataverses/{id}/template/default`.
- New Use Case: [Update Terms of Access](./docs/useCases.md#update-terms-of-access).
- Guestbooks: Added use cases and repository support for guestbook creation, listing, and enabling/disabling.
- Guestbooks: Added dataset-level guestbook assignment and removal support via `assignDatasetGuestbook` (`PUT /api/datasets/{identifier}/guestbook`) and `removeDatasetGuestbook` (`DELETE /api/datasets/{identifier}/guestbook`).
- Datasets/Guestbooks: Added `guestbookId` in `getDataset` responses.
- Access: Added`access` module for guestbook-at-request and download terms/guestbook submission endpoints.
- New Use Case: [Set Template as Default](./docs/useCases.md#set-template-as-default) under Templates.
- New Use Case: [Unset Template as Default](./docs/useCases.md#unset-template-as-default) under Templates.
- New Use Case: [Create Guestbook](./docs/useCases.md#create-guestbook) under Guestbooks.
- New Use Case: [Get Guestbooks](./docs/useCases.md#get-guestbooks) under Guestbooks.
- New Use Case: [Enable Guestbook](./docs/useCases.md#enable-guestbook) under Guestbooks.
- New Use Case: [Disable Guestbook](./docs/useCases.md#disable-guestbook) under Guestbooks.
- New Use Case: [Assign Dataset Guestbook](./docs/useCases.md#assign-dataset-guestbook) under Guestbooks.
- New Use Case: [Remove Dataset Guestbook](./docs/useCases.md#remove-dataset-guestbook) under Guestbooks.
- New Use Case: [Get Publish Dataset Disclaimer Text](./docs/useCases.md#get-publish-dataset-disclaimer-text).
- New Use Case: [Get Dataset Publish Popup Custom Text](./docs/useCases.md#get-dataset-publish-popup-custom-text).
- New Use Case: [Get Allowed Collection Storage Drivers](./docs/useCases.md#get-allowed-collection-storage-drivers) under Collections.
- New Use Case: [Get Collection Storage Driver](./docs/useCases.md#get-collection-storage-driver) under Collections.
- New Use Case: [Set Collection Storage Driver](./docs/useCases.md#set-collection-storage-driver) under Collections.
- New Use Case: [Delete Collection Storage Driver](./docs/useCases.md#delete-collection-storage-driver) under Collections.
- New Use Case: [Get Collections For Linking](./docs/useCases.md#get-collections-for-linking) under Collections.
- Access: Added `access` module for guestbook-at-request and download terms/guestbook submission endpoints.
- DatasetType: Updated datasetType data model. Added two more fields: description and displayName.

### Changed
Expand All @@ -32,6 +39,8 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
- Templates: Rename `CreateDatasetTemplateDTO` to `CreateTemplateDTO`.
- Templates: Rename `createDatasetTemplate` repository method to `createTemplate`.
- Templates: Rename `getDatasetTemplates` repository method to `getTemplatesByCollectionId`.
- Datasets/Guestbooks: Added `guestbookId` in `getDataset` responses.
- DatasetType: Updated datasetType data model. Added two more fields: description and displayName.

### Fixed

Expand Down
116 changes: 115 additions & 1 deletion docs/useCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The different use cases currently available in the package are classified below,
- [Collections](#Collections)
- [Collections read use cases](#collections-read-use-cases)
- [Get a Collection](#get-a-collection)
- [Get Collection Storage Driver](#get-collection-storage-driver)
- [Get Allowed Collection Storage Drivers](#get-allowed-collection-storage-drivers)
- [Get Collection Facets](#get-collection-facets)
- [Get User Permissions on a Collection](#get-user-permissions-on-a-collection)
- [List All Collection Items](#list-all-collection-items)
Expand All @@ -19,6 +21,8 @@ The different use cases currently available in the package are classified below,
- [Get Collections for Linking](#get-collections-for-linking)
- [Collections write use cases](#collections-write-use-cases)
- [Create a Collection](#create-a-collection)
- [Set Collection Storage Driver](#set-collection-storage-driver)
- [Delete Collection Storage Driver](#delete-collection-storage-driver)
- [Update a Collection](#update-a-collection)
- [Publish a Collection](#publish-a-collection)
- [Delete a Collection](#delete-a-collection)
Expand Down Expand Up @@ -190,6 +194,65 @@ The `collectionIdOrAlias` is a generic collection identifier, which can be eithe

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.

#### Get Collection Storage Driver

Returns a [StorageDriver](../src/core/domain/models/StorageDriver.ts) instance describing the collection's assigned storage driver.

##### Example call:

```typescript
import { getCollectionStorageDriver } from '@iqss/dataverse-client-javascript'

/* ... */

const collectionIdOrAlias = 'classicLiterature'

getCollectionStorageDriver.execute(collectionIdOrAlias).then((storageDriver: StorageDriver) => {
/* ... */
})

// Pass true to resolve the effective driver after inheritance/default fallback
getCollectionStorageDriver
.execute(collectionIdOrAlias, true)
.then((storageDriver: StorageDriver) => {
/* ... */
})

/* ... */
```

_See [use case](../src/collections/domain/useCases/GetCollectionStorageDriver.ts) implementation_.

The `collectionIdOrAlias` is a generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId).

The optional `getEffective` parameter defaults to `false`. Set it to `true` to retrieve the effective storage driver after inheritance/default resolution.

#### Get Allowed Collection Storage Drivers

Returns an [AllowedStorageDrivers](../src/collections/domain/models/AllowedStorageDrivers.ts) object whose keys are driver labels and whose values are storage driver ids.

##### Example call:

```typescript
import { getAllowedCollectionStorageDrivers } from '@iqss/dataverse-client-javascript'

/* ... */

const collectionIdOrAlias = 'classicLiterature'

getAllowedCollectionStorageDrivers
.execute(collectionIdOrAlias)
.then((storageDrivers: AllowedStorageDrivers) => {
/* ... */
})

/* ... */
```

_See [use case](../src/collections/domain/useCases/GetAllowedCollectionStorageDrivers.ts) implementation_.

The `collectionIdOrAlias` is a generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId).

#### Get Collection Facets

Returns a [CollectionFacet](../src/collections/domain/models/CollectionFacet.ts) array containing the facets of the requested collection, given the collection identifier or alias.
Expand Down Expand Up @@ -460,6 +523,57 @@ The above example creates the new collection in the root collection since no col

The use case returns a number, which is the identifier of the created collection.

#### Set Collection Storage Driver

Assigns a storage driver to a collection by driver label and returns the backend success message.

##### Example call:

```typescript
import { setCollectionStorageDriver } from '@iqss/dataverse-client-javascript'

/* ... */

const collectionIdOrAlias = 'classicLiterature'
const driverLabel = 'Local Storage'

setCollectionStorageDriver.execute(collectionIdOrAlias, driverLabel).then((message: string) => {
/* ... */
})

/* ... */
```

_See [use case](../src/collections/domain/useCases/SetCollectionStorageDriver.ts) implementation_.

The `collectionIdOrAlias` is a generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId).

The `driverLabel` parameter must match the storage driver's label, not its id.

#### Delete Collection Storage Driver

Clears the directly assigned storage driver from a collection so it falls back to inherited/default storage, and returns the backend success message.

##### Example call:

```typescript
import { deleteCollectionStorageDriver } from '@iqss/dataverse-client-javascript'

/* ... */

const collectionIdOrAlias = 'classicLiterature'

deleteCollectionStorageDriver.execute(collectionIdOrAlias).then((message: string) => {
/* ... */
})

/* ... */
```

_See [use case](../src/collections/domain/useCases/DeleteCollectionStorageDriver.ts) implementation_.

The `collectionIdOrAlias` is a generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId).

#### Update a Collection

Updates an existing collection, given a collection identifier and a [CollectionDTO](../src/collections/domain/dtos/CollectionDTO.ts) including the updated collection data.
Expand Down Expand Up @@ -1491,7 +1605,7 @@ _See [use case](../src/datasets/domain/useCases/GetDatasetTemplates.ts)_ definit

#### Get Dataset Storage Driver

Returns a [StorageDriver](../src/datasets/domain/models/StorageDriver.ts) instance with storage driver configuration for a dataset, including properties like name, type, label, and upload/download capabilities.
Returns a [StorageDriver](../src/core/domain/models/StorageDriver.ts) instance with storage driver configuration for a dataset, including properties like name, type, label, and upload/download capabilities.

##### Example call:

Expand Down
1 change: 1 addition & 0 deletions src/collections/domain/models/AllowedStorageDrivers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type AllowedStorageDrivers = Record<string, string>
14 changes: 14 additions & 0 deletions src/collections/domain/repositories/ICollectionsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,24 @@ import { PublicationStatus } from '../../../core/domain/models/PublicationStatus
import { CollectionItemType } from '../../../collections/domain/models/CollectionItemType'
import { CollectionLinks } from '../models/CollectionLinks'
import { CollectionSummary } from '../models/CollectionSummary'
import { AllowedStorageDrivers } from '../models/AllowedStorageDrivers'
import { StorageDriver } from '../../../core/domain/models/StorageDriver'
import { LinkingObjectType } from '../useCases/GetCollectionsForLinking'

export interface ICollectionsRepository {
getCollection(collectionIdOrAlias: number | string): Promise<Collection>
getCollectionStorageDriver(
collectionIdOrAlias: number | string,
getEffective?: boolean
): Promise<StorageDriver>
setCollectionStorageDriver(
collectionIdOrAlias: number | string,
driverLabel: string
): Promise<string>
deleteCollectionStorageDriver(collectionIdOrAlias: number | string): Promise<string>
getAllowedCollectionStorageDrivers(
collectionIdOrAlias: number | string
): Promise<AllowedStorageDrivers>
createCollection(
collectionDTO: CollectionDTO,
parentCollectionId: number | string
Expand Down
14 changes: 14 additions & 0 deletions src/collections/domain/useCases/DeleteCollectionStorageDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'

export class DeleteCollectionStorageDriver implements UseCase<string> {
private collectionsRepository: ICollectionsRepository

constructor(collectionsRepository: ICollectionsRepository) {
this.collectionsRepository = collectionsRepository
}

async execute(collectionIdOrAlias: number | string): Promise<string> {
return this.collectionsRepository.deleteCollectionStorageDriver(collectionIdOrAlias)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
import { AllowedStorageDrivers } from '../models/AllowedStorageDrivers'

export class GetAllowedCollectionStorageDrivers implements UseCase<AllowedStorageDrivers> {
private collectionsRepository: ICollectionsRepository

constructor(collectionsRepository: ICollectionsRepository) {
this.collectionsRepository = collectionsRepository
}

async execute(collectionIdOrAlias: number | string): Promise<AllowedStorageDrivers> {
return this.collectionsRepository.getAllowedCollectionStorageDrivers(collectionIdOrAlias)
}
}
18 changes: 18 additions & 0 deletions src/collections/domain/useCases/GetCollectionStorageDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { StorageDriver } from '../../../core/domain/models/StorageDriver'
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'

export class GetCollectionStorageDriver implements UseCase<StorageDriver> {
private collectionsRepository: ICollectionsRepository

constructor(collectionsRepository: ICollectionsRepository) {
this.collectionsRepository = collectionsRepository
}

async execute(
collectionIdOrAlias: number | string,
getEffective = false
): Promise<StorageDriver> {
return this.collectionsRepository.getCollectionStorageDriver(collectionIdOrAlias, getEffective)
}
}
14 changes: 14 additions & 0 deletions src/collections/domain/useCases/SetCollectionStorageDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'

export class SetCollectionStorageDriver implements UseCase<string> {
private collectionsRepository: ICollectionsRepository

constructor(collectionsRepository: ICollectionsRepository) {
this.collectionsRepository = collectionsRepository
}

async execute(collectionIdOrAlias: number | string, driverLabel: string): Promise<string> {
return this.collectionsRepository.setCollectionStorageDriver(collectionIdOrAlias, driverLabel)
}
}
17 changes: 16 additions & 1 deletion src/collections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GetCollection } from './domain/useCases/GetCollection'
import { GetCollectionFacets } from './domain/useCases/GetCollectionFacets'
import { GetCollectionUserPermissions } from './domain/useCases/GetCollectionUserPermissions'
import { GetCollectionItems } from './domain/useCases/GetCollectionItems'
import { GetCollectionStorageDriver } from './domain/useCases/GetCollectionStorageDriver'
import { PublishCollection } from './domain/useCases/PublishCollection'
import { UpdateCollection } from './domain/useCases/UpdateCollection'
import { GetCollectionFeaturedItems } from './domain/useCases/GetCollectionFeaturedItems'
Expand All @@ -16,10 +17,14 @@ import { LinkCollection } from './domain/useCases/LinkCollection'
import { UnlinkCollection } from './domain/useCases/UnlinkCollection'
import { GetCollectionLinks } from './domain/useCases/GetCollectionLinks'
import { GetCollectionsForLinking } from './domain/useCases/GetCollectionsForLinking'
import { SetCollectionStorageDriver } from './domain/useCases/SetCollectionStorageDriver'
import { DeleteCollectionStorageDriver } from './domain/useCases/DeleteCollectionStorageDriver'
import { GetAllowedCollectionStorageDrivers } from './domain/useCases/GetAllowedCollectionStorageDrivers'

const collectionsRepository = new CollectionsRepository()

const getCollection = new GetCollection(collectionsRepository)
const getCollectionStorageDriver = new GetCollectionStorageDriver(collectionsRepository)
const createCollection = new CreateCollection(collectionsRepository)
const getCollectionFacets = new GetCollectionFacets(collectionsRepository)
const getCollectionUserPermissions = new GetCollectionUserPermissions(collectionsRepository)
Expand All @@ -36,9 +41,15 @@ const linkCollection = new LinkCollection(collectionsRepository)
const unlinkCollection = new UnlinkCollection(collectionsRepository)
const getCollectionLinks = new GetCollectionLinks(collectionsRepository)
const getCollectionsForLinking = new GetCollectionsForLinking(collectionsRepository)
const setCollectionStorageDriver = new SetCollectionStorageDriver(collectionsRepository)
const deleteCollectionStorageDriver = new DeleteCollectionStorageDriver(collectionsRepository)
const getAllowedCollectionStorageDrivers = new GetAllowedCollectionStorageDrivers(
collectionsRepository
)

export {
getCollection,
getCollectionStorageDriver,
createCollection,
getCollectionFacets,
getCollectionUserPermissions,
Expand All @@ -54,7 +65,10 @@ export {
linkCollection,
unlinkCollection,
getCollectionLinks,
getCollectionsForLinking
getCollectionsForLinking,
setCollectionStorageDriver,
deleteCollectionStorageDriver,
getAllowedCollectionStorageDrivers
}
export { Collection, CollectionInputLevel } from './domain/models/Collection'
export { CollectionFacet } from './domain/models/CollectionFacet'
Expand All @@ -66,3 +80,4 @@ export { CollectionSearchCriteria } from './domain/models/CollectionSearchCriter
export { FeaturedItem } from './domain/models/FeaturedItem'
export { FeaturedItemsDTO } from './domain/dtos/FeaturedItemsDTO'
export { CollectionSummary } from './domain/models/CollectionSummary'
export { AllowedStorageDrivers } from './domain/models/AllowedStorageDrivers'
Loading
Loading