forked from IQSS/dataverse-client-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetDatasetFileCounts.ts
36 lines (33 loc) · 1.86 KB
/
GetDatasetFileCounts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { IFilesRepository } from '../repositories/IFilesRepository'
import { DatasetNotNumberedVersion } from '../../../datasets'
import { FileCounts } from '../models/FileCounts'
import { FileSearchCriteria } from '../models/FileCriteria'
export class GetDatasetFileCounts implements UseCase<FileCounts> {
private filesRepository: IFilesRepository
constructor(filesRepository: IFilesRepository) {
this.filesRepository = filesRepository
}
/**
* Returns an instance of FileCounts, containing the requested Dataset total file count, as well as file counts for different file properties.
*
* @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers).
* @param {string | DatasetNotNumberedVersion} [datasetVersionId=DatasetNotNumberedVersion.LATEST] - The dataset version identifier, which can be a version-specific numeric string (for example, 1.0) or a DatasetNotNumberedVersion enum value. If this parameter is not set, the default value is: DatasetNotNumberedVersion.LATEST
* @param {boolean} [includeDeaccessioned=false] - Indicates whether to consider deaccessioned versions in the dataset search or not. The default value is false.
* @param {FileSearchCriteria} [fileSearchCriteria] - Supports filtering the files by different file properties (optional).
* @returns {Promise<FileCounts>}
*/
async execute(
datasetId: number | string,
datasetVersionId: string | DatasetNotNumberedVersion = DatasetNotNumberedVersion.LATEST,
includeDeaccessioned = false,
fileSearchCriteria?: FileSearchCriteria
): Promise<FileCounts> {
return await this.filesRepository.getDatasetFileCounts(
datasetId,
datasetVersionId,
includeDeaccessioned,
fileSearchCriteria
)
}
}