Skip to content

Commit bef8107

Browse files
committed
Merge origin/develop: union tree-listing additions with exportDatasetMetadata and setDefaultContributorRole; drop duplicated DatasetNotNumberedVersion import
2 parents f11ee66 + 2c4ca04 commit bef8107

25 files changed

Lines changed: 609 additions & 45 deletions

‎AGENTS.md‎

Lines changed: 166 additions & 0 deletions
Large diffs are not rendered by default.

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
1414
- Guestbooks: Added optional `includeStats` support to `getGuestbooksByCollectionId`, returning `usageCount` and `responseCount` when requested.
1515
- Files: Added `getFileCitationByFormat` use case, repository method, and `FileCitationFormat` enum to support Dataverse file citation exports in `EndNote`, `RIS`, `BibTeX`, `CSL`, and `Internal` formats.
1616
- Datasets: Added `getDatasetReviews` use case and repository method to support Dataverse endpoint `GET /datasets/{identifier}/reviews`, for retrieving review datasets associated with a dataset by persistent id or numeric id.
17+
- Datasets: Added `exportDatasetMetadata` use case, repository method, and `ExportedDatasetMetadata` response type to support exporting dataset metadata by numeric id or persistent id through Dataverse endpoint `GET /datasets/export`.
1718
- Collections: Added `allowedDatasetTypes` field to the [Collection](./src/collections/domain/models/Collection.ts) model. This field is optional and only populated the feature is enabled on the installation and configured on the collection.
1819
- Collections: Added theme information when retrieving a collection using `getCollection`.
20+
- Collections: Added `setDefaultContributorRole` use case.
1921
- Datasets: `listDatasetTreeNode` use case and repository method backing `GET /datasets/{id}/versions/{versionId}/tree` for paginated, lazy listing of folders/files inside a dataset version. Returns `FileTreePage` with folder-first ordering, opaque keyset cursors, and per-file `downloadUrl`. The per-file `access` marker is one of `retentionExpired`, `restricted`, `embargoed`, or `public` (resolved in that order), and folder `counts` carry the matching mutually exclusive `restricted`/`embargoed`/`retentionExpired` buckets.
2022
- Datasets: `iterateDatasetTreeNode` async generator that walks the cursor chain so callers can consume one folder's children without driving pagination by hand.
2123
- Core: re-export `DataverseApiAuthMechanism` from the public surface so consumers of the standalone reusable bundles (e.g. `dv-tree-view`, `dv-uploader`) can import it without reaching into `core/...`.

‎docs/useCases.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The different use cases currently available in the package are classified below,
2929
- [Update Collection Featured Items](#update-collection-featured-items)
3030
- [Delete Collection Featured Items](#delete-collection-featured-items)
3131
- [Delete a Collection Featured Item](#delete-a-collection-featured-item)
32+
- [Set Default Contributor Role](#set-default-contributor-role)
3233
- [Templates](#Templates)
3334
- [Templates read use cases](#templates-read-use-cases)
3435
- [Get a Template](#get-a-template)
@@ -46,6 +47,8 @@ The different use cases currently available in the package are classified below,
4647
- [Get a Dataset](#get-a-dataset)
4748
- [Get Dataset By Private URL Token](#get-dataset-by-private-url-token)
4849
- [Get Dataset Citation Text](#get-dataset-citation-text)
50+
- [Get Dataset Citation In Other Formats](#get-dataset-citation-in-other-formats)
51+
- [Export Dataset Metadata](#export-dataset-metadata)
4952
- [Get Dataset Citation Text By Private URL Token](#get-dataset-citation-text-by-private-url-token)
5053
- [Get Dataset Locks](#get-dataset-locks)
5154
- [Get Dataset Summary Field Names](#get-dataset-summary-field-names)
@@ -732,6 +735,27 @@ deleteCollectionFeaturedItem.execute(featuredItemId)
732735

733736
_See [use case](../src/collections/domain/useCases/DeleteCollectionFeaturedItem.ts)_ definition.
734737

738+
#### Set Default Contributor Role
739+
740+
Sets the default contributor role of a collection, given a collection identifier and a role alias.
741+
742+
##### Example call:
743+
744+
```typescript
745+
import { setDefaultContributorRole } from '@iqss/dataverse-client-javascript'
746+
747+
/* ... */
748+
749+
const collectionIdOrAlias = 12345
750+
const roleAlias = 'curator'
751+
752+
setDefaultContributorRole.execute(collectionIdOrAlias, roleAlias)
753+
754+
/* ... */
755+
```
756+
757+
_See [use case](../src/collections/domain/useCases/SetDefaultContributorRole.ts)_ definition.
758+
735759
## Templates
736760

737761
### Templates Read Use Cases
@@ -1055,6 +1079,37 @@ The `datasetId` parameter can be a string, for persistent identifiers, or a numb
10551079

10561080
There is an optional third parameter called `includeDeaccessioned`, which indicates whether to consider deaccessioned versions or not in the dataset search. If not set, the default value is `false`.
10571081

1082+
#### Export Dataset Metadata
1083+
1084+
Exports dataset metadata in a specified metadata export format.
1085+
1086+
##### Example call:
1087+
1088+
```typescript
1089+
import {
1090+
exportDatasetMetadata,
1091+
DatasetNotNumberedVersion,
1092+
ExportedDatasetMetadata
1093+
} from '@iqss/dataverse-client-javascript'
1094+
1095+
/* ... */
1096+
1097+
const datasetId = 'doi:10.77777/FK2/AAAAAA'
1098+
const exporter = 'ddi'
1099+
1100+
exportDatasetMetadata
1101+
.execute(datasetId, exporter, DatasetNotNumberedVersion.DRAFT)
1102+
.then((metadata: ExportedDatasetMetadata) => {
1103+
/* ... */
1104+
})
1105+
1106+
/* ... */
1107+
```
1108+
1109+
_See [use case](../src/datasets/domain/useCases/ExportDatasetMetadata.ts) implementation_.
1110+
1111+
The `datasetId` parameter can be a string for persistent identifiers or a number for numeric identifiers. The optional `version` parameter accepts `DatasetNotNumberedVersion.LATEST_PUBLISHED` or `DatasetNotNumberedVersion.DRAFT`. If not set, Dataverse defaults to `DatasetNotNumberedVersion.LATEST_PUBLISHED`. Draft exports require configured authentication with access to the draft.
1112+
10581113
#### Get Dataset Citation Text By Private URL Token
10591114

10601115
Returns the Dataset citation text, given an associated Private URL Token.

‎package-lock.json‎

Lines changed: 21 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/collections/domain/repositories/ICollectionsRepository.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { CollectionSummary } from '../models/CollectionSummary'
1414
import { AllowedStorageDrivers } from '../models/AllowedStorageDrivers'
1515
import { StorageDriver } from '../../../core/domain/models/StorageDriver'
1616
import { LinkingObjectType } from '../useCases/GetCollectionsForLinking'
17+
import { RoleAlias } from '../../../roles/domain/models/RoleAlias'
1718

1819
export interface ICollectionsRepository {
1920
getCollection(collectionIdOrAlias: number | string): Promise<Collection>
@@ -39,6 +40,10 @@ export interface ICollectionsRepository {
3940
getCollectionUserPermissions(
4041
collectionIdOrAlias: number | string
4142
): Promise<CollectionUserPermissions>
43+
setDefaultContributorRole(
44+
collectionIdOrAlias: number | string,
45+
roleAlias: RoleAlias | string
46+
): Promise<void>
4247
getCollectionItems(
4348
collectionId?: string,
4449
limit?: number,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { UseCase } from '../../../core/domain/useCases/UseCase'
2+
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
3+
import { ROOT_COLLECTION_ID } from '../models/Collection'
4+
import { RoleAlias } from '../../../roles/domain/models/RoleAlias'
5+
6+
export class SetDefaultContributorRole implements UseCase<void> {
7+
private collectionsRepository: ICollectionsRepository
8+
9+
constructor(collectionsRepository: ICollectionsRepository) {
10+
this.collectionsRepository = collectionsRepository
11+
}
12+
13+
/**
14+
* Sets the default Role that is assigned to contributors in the given collection.
15+
*
16+
* @param {number | string} [collectionIdOrAlias = ':root'] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId)
17+
* If this parameter is not set, the default value is: ':root'
18+
* @param {RoleAlias | string} [roleAlias] - The alias of the role to be assigned
19+
* @returns {Promise<void>}
20+
*/
21+
async execute(
22+
collectionIdOrAlias: number | string = ROOT_COLLECTION_ID,
23+
roleAlias: RoleAlias | string
24+
): Promise<void> {
25+
return await this.collectionsRepository.setDefaultContributorRole(
26+
collectionIdOrAlias,
27+
roleAlias
28+
)
29+
}
30+
}

‎src/collections/index.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { GetCollectionsForLinking } from './domain/useCases/GetCollectionsForLin
2020
import { SetCollectionStorageDriver } from './domain/useCases/SetCollectionStorageDriver'
2121
import { DeleteCollectionStorageDriver } from './domain/useCases/DeleteCollectionStorageDriver'
2222
import { GetAllowedCollectionStorageDrivers } from './domain/useCases/GetAllowedCollectionStorageDrivers'
23+
import { SetDefaultContributorRole } from './domain/useCases/SetDefaultContributorRole'
2324

2425
const collectionsRepository = new CollectionsRepository()
2526

@@ -46,6 +47,7 @@ const deleteCollectionStorageDriver = new DeleteCollectionStorageDriver(collecti
4647
const getAllowedCollectionStorageDrivers = new GetAllowedCollectionStorageDrivers(
4748
collectionsRepository
4849
)
50+
const setDefaultContributorRole = new SetDefaultContributorRole(collectionsRepository)
4951

5052
export {
5153
getCollection,
@@ -68,7 +70,8 @@ export {
6870
getCollectionsForLinking,
6971
setCollectionStorageDriver,
7072
deleteCollectionStorageDriver,
71-
getAllowedCollectionStorageDrivers
73+
getAllowedCollectionStorageDrivers,
74+
setDefaultContributorRole
7275
}
7376
export { Collection, CollectionInputLevel, CollectionTheme } from './domain/models/Collection'
7477
export { CollectionFacet } from './domain/models/CollectionFacet'

‎src/collections/infra/repositories/CollectionsRepository.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { CollectionSummary } from '../../domain/models/CollectionSummary'
4242
import { AllowedStorageDrivers } from '../../domain/models/AllowedStorageDrivers'
4343
import { StorageDriver } from '../../../core/domain/models/StorageDriver'
4444
import { LinkingObjectType } from '../../domain/useCases/GetCollectionsForLinking'
45+
import { RoleAlias } from '../../../roles/domain/models/RoleAlias'
4546

4647
export interface NewCollectionRequestPayload {
4748
alias: string
@@ -225,6 +226,20 @@ export class CollectionsRepository extends ApiRepository implements ICollections
225226
})
226227
}
227228

229+
public async setDefaultContributorRole(
230+
collectionIdOrAlias: number | string,
231+
roleAlias: RoleAlias | string
232+
): Promise<void> {
233+
return this.doPut(
234+
`/${this.collectionsResourceName}/${collectionIdOrAlias}/defaultContributorRole/${roleAlias}`,
235+
{}
236+
)
237+
.then(() => undefined)
238+
.catch((error) => {
239+
throw error
240+
})
241+
}
242+
228243
public async getCollectionItems(
229244
collectionId?: string,
230245
limit?: number,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type ExportedDatasetMetadata = {
2+
content: string
3+
contentType: string
4+
}

‎src/datasets/domain/repositories/IDatasetsRepository.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { StorageDriver } from '../../../core/domain/models/StorageDriver'
2020
import { DatasetUploadLimits } from '../models/DatasetUploadLimits'
2121
import { DatasetReview } from '../models/DatasetReview'
2222
import { FileTreePage, FileTreeInclude, FileTreeOrder } from '../models/FileTreePage'
23+
import { ExportedDatasetMetadata } from '../models/ExportedDatasetMetadata'
24+
import { DatasetNotNumberedVersion } from '../models/DatasetNotNumberedVersion'
2325

2426
export interface ListDatasetTreeNodeParams {
2527
datasetId: number | string
@@ -99,6 +101,11 @@ export interface IDatasetsRepository {
99101
format: CitationFormat,
100102
includeDeaccessioned?: boolean
101103
): Promise<FormattedCitation>
104+
exportDatasetMetadata(
105+
datasetId: number | string,
106+
exporter: string,
107+
version?: DatasetNotNumberedVersion.LATEST_PUBLISHED | DatasetNotNumberedVersion.DRAFT
108+
): Promise<ExportedDatasetMetadata>
102109
getDatasetAvailableDatasetTypes(): Promise<DatasetType[]>
103110
getDatasetAvailableDatasetType(datasetTypeId: number | string): Promise<DatasetType>
104111
addDatasetType(datasetType: DatasetTypeDTO): Promise<DatasetType>

0 commit comments

Comments
 (0)