Skip to content

Commit d098005

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/configurable-uploads
# Conflicts: # CHANGELOG.md # test/functional/collections/UpdateCollectionFeaturedItems.test.ts # test/testHelpers/html/htmlNormalizer.ts # test/unit/testHelpers/htmlNormalizer.test.ts
2 parents 1f6dba6 + 4281c37 commit d098005

31 files changed

Lines changed: 904 additions & 138 deletions

‎CHANGELOG.md‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
88

99
### Added
1010

11-
- Guestbooks: Added `editGuestbook` use case.
12-
- Guestbooks: Added `getGuestbookResponsesByGuestbookId` use case and repository support for retrieving paginated guestbook responses with total count as structured JSON.
13-
- Guestbooks: Added `downloadGuestbookResponsesByCollectionId` and `downloadGuestbookResponsesOfAGuestbook` use cases and repository support for exporting guestbook responses as raw CSV content.
14-
- Guestbooks: Added optional `includeStats` support to `getGuestbooksByCollectionId`, returning `usageCount` and `responseCount` when requested.
15-
- Files: Added `getFileCitationByFormat` use case, repository method, and `FileCitationFormat` enum to support Dataverse file citation exports in `EndNote`, `RIS`, `BibTeX`, `CSL`, and `Internal` formats.
16-
- 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`.
18-
- 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.
19-
- Collections: Added theme information when retrieving a collection using `getCollection`.
20-
- Collections: Added `setDefaultContributorRole` use case.
2111
- 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.
2212
- Datasets: `iterateDatasetTreeNode` async generator that walks the cursor chain so callers can consume one folder's children without driving pagination by hand.
2313
- 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/...`.
@@ -32,6 +22,27 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
3222

3323
### Removed
3424

25+
## [v2.3.0] -- 2026-10-08
26+
27+
### Added
28+
29+
- Datasets: Added optional `templateId` support to `createDataset` requests and `getDataset` responses.
30+
- Guestbooks: Added `editGuestbook` use case.
31+
- Guestbooks: Added `getGuestbookResponsesByGuestbookId` use case and repository support for retrieving paginated guestbook responses with total count as structured JSON.
32+
- Guestbooks: Added `downloadGuestbookResponsesByCollectionId` and `downloadGuestbookResponsesOfAGuestbook` use cases and repository support for exporting guestbook responses as raw CSV content.
33+
- Guestbooks: Added optional `includeStats` support to `getGuestbooksByCollectionId`, returning `usageCount` and `responseCount` when requested.
34+
- Files: Added `getFileCitationByFormat` use case, repository method, and `FileCitationFormat` enum to support Dataverse file citation exports in `EndNote`, `RIS`, `BibTeX`, `CSL`, and `Internal` formats.
35+
- 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.
36+
- 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`.
37+
- Datasets: Added `getDatasetVersions` use case.
38+
- 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.
39+
- Collections: Added theme information when retrieving a collection using `getCollection`.
40+
- Collections: Added `setDefaultContributorRole` use case.
41+
42+
### Changed
43+
44+
- Files: Added an optional dataset `version` parameter to `getFileCitationByFormat` for version-specific file citation exports.
45+
3546
## [v2.2.0] -- 2026-04-24
3647

3748
### Added
@@ -59,7 +70,7 @@ This changelog follows the principles of [Keep a Changelog](https://keepachangel
5970

6071
### Changed
6172

62-
- Add pagination query parameters to Dataset Version Summaries and File Version Summaries use cases.
73+
- Add pagination query parameters to Dataset Version Summeries and File Version Summaries use cases.
6374
- Templates: Rename `CreateDatasetTemplateDTO` to `CreateTemplateDTO`.
6475
- Templates: Rename `createDatasetTemplate` repository method to `createTemplate`.
6576
- Templates: Rename `getDatasetTemplates` repository method to `getTemplatesByCollectionId`.

‎docs/useCases.md‎

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The different use cases currently available in the package are classified below,
5555
- [Get User Permissions on a Dataset](#get-user-permissions-on-a-dataset)
5656
- [Get Differences between Two Dataset Versions](#get-differences-between-two-dataset-versions)
5757
- [List All Datasets](#list-all-datasets)
58+
- [Get Dataset Versions](#get-dataset-versions)
5859
- [Get Dataset Versions Summaries](#get-dataset-versions-summaries)
5960
- [Get Dataset Linked Collections](#get-dataset-linked-collections)
6061
- [Get Dataset Available Categories](#get-dataset-available-categories)
@@ -999,6 +1000,8 @@ There is an optional third parameter called `includeDeaccessioned`, which indica
9991000

10001001
There is an optional fourth parameter called `keepRawFields`, which indicates whether or not to keep the metadata fields as they are and avoid the transformation to Markdown. The default value is `false`.
10011002

1003+
When the dataset is associated with a template, the returned `Dataset` includes the optional `templateId` field containing that template's numeric identifier.
1004+
10021005
#### Get Dataset By Private URL Token
10031006

10041007
Returns a [Dataset](../src/datasets/domain/models/Dataset.ts) instance, given an associated Private URL Token.
@@ -1286,6 +1289,34 @@ Note that `collectionId` is an optional parameter to filter datasets by collecti
12861289

12871290
The `DatasetPreviewSubset`returned instance contains a property called `totalDatasetCount` which is necessary for pagination.
12881291

1292+
#### Get Dataset Versions
1293+
1294+
Returns an array of [Dataset](../src/datasets/domain/models/Dataset.ts) that contains information about every specific version.
1295+
1296+
##### Example call:
1297+
1298+
```typescript
1299+
import { getDatasetVersions } from '@iqss/dataverse-client-javascript'
1300+
1301+
/* ... */
1302+
1303+
const datasetId = 'doi:10.77777/FK2/AAAAAA'
1304+
1305+
getDatasetVersions.execute(datasetId).then((datasetVersions: DatasetVersionSubset) => {
1306+
/* ... */
1307+
})
1308+
1309+
/* ... */
1310+
```
1311+
1312+
_See [use case](../src/datasets/domain/useCases/GetDatasetVersions.ts) implementation_.
1313+
1314+
- The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
1315+
- **limit**: (number) Limit for pagination.
1316+
- **offset**: (number) Offset for pagination.
1317+
- **excludeMetadataBlocks**: (boolean) Exclude metadata blocks (default: false).
1318+
- Note that the **excludeFiles** parameter, which is available on Dataverse's "List Versions of a Dataset" API, is not available here. The list of files can be retrieved using the separate use case [List Files in a Dataset](#list-files-in-a-dataset).
1319+
12891320
#### Get Dataset Versions Summaries
12901321

12911322
Returns the total count of versions and an array of [DatasetVersionSummaryInfo](../src/datasets/domain/models/DatasetVersionSummaryInfo.ts) that contains information about what changed in every specific version.
@@ -1451,7 +1482,7 @@ createDataset.execute(datasetDTO).then((newDatasetIds: CreatedDatasetIdentifiers
14511482

14521483
_See [use case](../src/datasets/domain/useCases/CreateDataset.ts) implementation_.
14531484

1454-
The above example creates the new dataset in the root collection since no collection identifier is specified. If you want to create the dataset in a different collection, you must add the collection identifier as a second parameter in the use case call. If you want the dataset type to be anything other than dataset, first [check available dataset types](#get-dataset-available-dataset-types) and then add the name of the dataset type as the third parameter.
1485+
The above example creates the new dataset in the root collection since no collection identifier is specified. If you want to create the dataset in a different collection, you must add the collection identifier as a second parameter in the use case call. If you want the dataset type to be anything other than dataset, first [check available dataset types](#get-dataset-available-dataset-types) and then add the name of the dataset type as the third parameter. To create from an applicable metadata template, set its numeric identifier as `datasetDTO.templateId`; the SDK sends it as the top-level `templateId` field in the request body.
14551486

14561487
The use case returns a [CreatedDatasetIdentifiers](../src/datasets/domain/models/CreatedDatasetIdentifiers.ts) object, which includes the persistent and numeric identifiers of the created dataset.
14571488

@@ -2093,9 +2124,11 @@ import { FileCitationFormat, getFileCitationByFormat } from '@iqss/dataverse-cli
20932124

20942125
const fileId = 3
20952126

2096-
getFileCitationByFormat.execute(fileId, FileCitationFormat.BIBTEX).then((citationText: string) => {
2097-
/* ... */
2098-
})
2127+
getFileCitationByFormat
2128+
.execute(fileId, FileCitationFormat.BIBTEX, '1.0')
2129+
.then((citationText: string) => {
2130+
/* ... */
2131+
})
20992132

21002133
/* ... */
21012134
```
@@ -2104,6 +2137,8 @@ _See [use case](../src/files/domain/useCases/GetFileCitationByFormat.ts) impleme
21042137

21052138
The `fileId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
21062139

2140+
The optional third parameter, `version`, selects the **dataset version** whose file metadata is used in the citation. It accepts a numbered version such as `1.0`, or `DatasetNotNumberedVersion.DRAFT`, `LATEST`, or `LATEST_PUBLISHED` (`:draft`, `:latest`, `:latest-published`). When omitted, no version query parameter is sent, it will return the `:latest`.
2141+
21072142
The `format` parameter must be one of the available [FileCitationFormat](../src/files/domain/models/FileCitationFormat.ts) enum values: `FileCitationFormat.ENDNOTE`, `FileCitationFormat.RIS`, `FileCitationFormat.BIBTEX`, `FileCitationFormat.CSL`, or `FileCitationFormat.INTERNAL`.
21082143

21092144
#### Get File Counts in a Dataset

‎package-lock.json‎

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

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iqss/dataverse-client-javascript",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"description": "Dataverse API wrapper package for JavaScript/TypeScript-based applications",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
@@ -43,6 +43,7 @@
4343
"homepage": "https://github.com/IQSS/dataverse-client-javascript#readme",
4444
"devDependencies": {
4545
"@types/jest": "^29.5.12",
46+
"@types/jsdom": "^20.0.1",
4647
"@typescript-eslint/eslint-plugin": "5.51.0",
4748
"@typescript-eslint/parser": "5.51.0",
4849
"@web-std/file": "3.0.3",
@@ -56,6 +57,7 @@
5657
"husky": "9.1.7",
5758
"jest": "^29.4.3",
5859
"jest-environment-jsdom": "29.7.0",
60+
"jsdom": "^20.0.3",
5961
"prettier": "2.8.4",
6062
"testcontainers": "^10.11.0",
6163
"ts-jest": "^29.0.5",

‎src/access/infra/repositories/AccessRepository.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class AccessRepository extends ApiRepository implements IAccessRepository
142142
return fetchHeaders
143143
}
144144

145-
private async parseResponseBody(response: Response): Promise<any> {
145+
private async parseResponseBody(response: Response): Promise<FetchResponseBody | string> {
146146
const contentType = response.headers.get('content-type') ?? ''
147147

148148
if (contentType.includes('application/json')) {
@@ -158,7 +158,7 @@ export class AccessRepository extends ApiRepository implements IAccessRepository
158158
}
159159
}
160160

161-
private buildFetchErrorMessage(status: number, responseData: any): string {
161+
private buildFetchErrorMessage(status: number, responseData: FetchResponseBody | string): string {
162162
const message =
163163
typeof responseData === 'string'
164164
? responseData
@@ -167,8 +167,8 @@ export class AccessRepository extends ApiRepository implements IAccessRepository
167167
return `[${status}] ${message}`
168168
}
169169

170-
private getSignedUrlOrThrow(responseData: any): string {
171-
const signedUrl = responseData?.data?.signedUrl
170+
private getSignedUrlOrThrow(responseData: FetchResponseBody | string): string {
171+
const signedUrl = typeof responseData === 'string' ? undefined : responseData?.data?.signedUrl
172172

173173
if (typeof signedUrl !== 'string' || signedUrl.length === 0) {
174174
throw new WriteError('Missing signedUrl in access download response.')
@@ -177,3 +177,11 @@ export class AccessRepository extends ApiRepository implements IAccessRepository
177177
return signedUrl
178178
}
179179
}
180+
181+
interface FetchResponseBody {
182+
message?: string
183+
data?: {
184+
message?: string
185+
signedUrl?: unknown
186+
}
187+
}

‎src/datasets/domain/dtos/DatasetDTO.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DatasetLicense } from '../models/Dataset'
22

33
export interface DatasetDTO {
44
license?: DatasetLicense
5+
templateId?: number
56
metadataBlockValues: DatasetMetadataBlockValuesDTO[]
67
}
78

‎src/datasets/domain/models/Dataset.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface Dataset {
1313
publicationDate?: string
1414
citationDate?: string
1515
guestbookId?: number
16+
templateId?: number
1617
metadataBlocks: DatasetMetadataBlocks
1718
isPartOf: DvObjectOwnerNode
1819
datasetType?: string
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Dataset, DatasetMetadataBlocks } from './Dataset'
2+
3+
export interface DatasetVersionSubset {
4+
versions: Array<Omit<Dataset, 'metadataBlocks'> & { metadataBlocks?: DatasetMetadataBlocks }>
5+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { MetadataBlock } from '../../../metadataBlocks'
99
import { DatasetVersionDiff } from '../models/DatasetVersionDiff'
1010
import { DatasetDownloadCount } from '../models/DatasetDownloadCount'
1111
import { DatasetVersionSummarySubset } from '../models/DatasetVersionSummaryInfo'
12+
import { DatasetVersionSubset } from '../models/DatasetVersionSubset'
1213
import { DatasetLinkedCollection } from '../models/DatasetLinkedCollection'
1314
import { CitationFormat } from '../models/CitationFormat'
1415
import { FormattedCitation } from '../models/FormattedCitation'
@@ -90,6 +91,13 @@ export interface IDatasetsRepository {
9091
limit?: number,
9192
offset?: number
9293
): Promise<DatasetVersionSummarySubset>
94+
getDatasetVersions(
95+
datasetId: number | string,
96+
limit?: number,
97+
offset?: number,
98+
excludeMetadataBlocks?: boolean,
99+
keepRawFields?: boolean
100+
): Promise<DatasetVersionSubset>
93101
deleteDatasetDraft(datasetId: number | string): Promise<void>
94102
linkDataset(datasetId: number | string, collectionIdOrAlias: number | string): Promise<void>
95103
unlinkDataset(datasetId: number | string, collectionIdOrAlias: number | string): Promise<void>

‎src/datasets/domain/useCases/CreateDataset.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class CreateDataset extends DatasetWriteUseCase<CreatedDatasetIdentifiers
1818
/**
1919
* Creates a new Dataset in a collection, given a DatasetDTO object and an optional collection identifier, which defaults to :root.
2020
*
21-
* @param {DatasetDTO} [newDataset] - DatasetDTO object including the new dataset metadata field values for each metadata block.
21+
* @param {DatasetDTO} [newDataset] - DatasetDTO object including the new dataset metadata field values for each metadata block and, optionally, the template ID to apply.
2222
* @param {string} [collectionId] - Specifies the collection identifier where the new dataset should be created (optional, defaults to :root).
2323
* @param {string} [datasetType] - Specifies the dataset type (optional, when omitted, defaults to "dataset").
2424
* @returns {Promise<CreatedDatasetIdentifiers>}

0 commit comments

Comments
 (0)