Skip to content

Commit ea487a0

Browse files
committed
Merge branch 'develop' into feat/317-get-dataset-templates
2 parents 6df006e + 68fcaa7 commit ea487a0

File tree

47 files changed

+1662
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1662
-10
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ node_modules
1010
# unit tests
1111
coverage
1212

13+
# macOS
14+
.DS_Store
15+
1316
# ignore npm lock
1417
package-json.lock
1518
.npmrc

docs/useCases.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The different use cases currently available in the package are classified below,
3737
- [List All Datasets](#list-all-datasets)
3838
- [Get Dataset Versions Summaries](#get-dataset-versions-summaries)
3939
- [Get Dataset Linked Collections](#get-dataset-linked-collections)
40+
- [Get Dataset Available Categories](#get-dataset-available-categories)
4041
- [Datasets write use cases](#datasets-write-use-cases)
4142
- [Create a Dataset](#create-a-dataset)
4243
- [Update a Dataset](#update-a-dataset)
@@ -64,6 +65,8 @@ The different use cases currently available in the package are classified below,
6465
- [Replace a File](#replace-a-file)
6566
- [Restrict or Unrestrict a File](#restrict-or-unrestrict-a-file)
6667
- [Update File Metadata](#update-file-metadata)
68+
- [Update File Categories](#update-file-categories)
69+
- [Update File Tabular Tags](#update-file-tabular-tags)
6770
- [Metadata Blocks](#metadata-blocks)
6871
- [Metadata Blocks read use cases](#metadata-blocks-read-use-cases)
6972
- [Get All Facetable Metadata Fields](#get-all-facetable-metadata-fields)
@@ -88,6 +91,11 @@ The different use cases currently available in the package are classified below,
8891
- [Get Application Terms of Use](#get-application-terms-of-use)
8992
- [Contact](#Contact)
9093
- [Send Feedback to Object Contacts](#send-feedback-to-object-contacts)
94+
- [Notifications](#Notifications)
95+
- [Get All Notifications by User](#get-all-notifications-by-user)
96+
- [Delete Notification](#delete-notification)
97+
- [Get Unread Count](#get-unread-count)
98+
- [Mark As Read](#mark-as-read)
9199
- [Search](#Search)
92100
- [Get Search Services](#get-search-services)
93101

@@ -564,6 +572,37 @@ The `datasetId` parameter can be a string, for persistent identifiers, or a numb
564572

565573
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`.
566574

575+
#### Get Dataset Citation In Other Formats
576+
577+
Retrieves the citation for a dataset in a specified bibliographic format.
578+
579+
##### Example call:
580+
581+
```typescript
582+
import { getDatasetCitationInOtherFormats } from '@iqss/dataverse-client-javascript'
583+
584+
/* ... */
585+
586+
const datasetId = 2
587+
const datasetVersionId = '1.0'
588+
589+
getDatasetCitationInOtherFormats
590+
.execute(datasetId, datasetVersionId, format)
591+
.then((citationText: FormattedCitation) => {
592+
/* ... */
593+
})
594+
595+
/* ... */
596+
```
597+
598+
_See [use case](../src/datasets/domain/useCases/GetDatasetCitationInOtherFormats.ts) implementation_.
599+
600+
Supported formats include 'EndNote' (XML), 'RIS' (plain text), 'BibTeX' (plain text), 'CSLJson' (JSON), and 'Internal' (HTML). The response contains the raw citation content in the requested format, the format type, and the content type (MIME type).
601+
602+
The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.
603+
604+
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`.
605+
567606
#### Get Dataset Citation Text By Private URL Token
568607

569608
Returns the Dataset citation text, given an associated Private URL Token.
@@ -1049,6 +1088,28 @@ The `includeMDC` parameter is optional.
10491088
- If MDC isn't enabled, the download count will return a total count, without `MDCStartDate`.
10501089
- If MDC is enabled but the `includeMDC` is false, the count will be limited to the time before `MDCStartDate`
10511090

1091+
#### Get Dataset Available Categories
1092+
1093+
Returns a list of available file categories that may be applied to the files of a given dataset.
1094+
1095+
###### Example call:
1096+
1097+
```typescript
1098+
import { getDatasetAvailableCategories } from '@iqss/dataverse-client-javascript'
1099+
1100+
/* ... */
1101+
1102+
const datasetId = 1
1103+
1104+
getDatasetAvailableCategories.execute(datasetId).then((categories: String[]) => {
1105+
/* ... */
1106+
})
1107+
```
1108+
1109+
_See [use case](../src/datasets/domain/useCases/GetDatasetAvailableCategories.ts) implementation_.
1110+
1111+
The `datasetId` parameter is a number for numeric identifiers or string for persistent identifiers.
1112+
10521113
## Files
10531114

10541115
### Files read use cases
@@ -2065,6 +2126,92 @@ In ContactDTO, it takes the following information:
20652126
- **body**: the email body to send.
20662127
- **fromEmail**: the email to list in the reply-to field.
20672128

2129+
## Notifications
2130+
2131+
#### Get All Notifications by User
2132+
2133+
Returns a [Notification](../src/notifications/domain/models/Notification.ts) array containing all notifications for the current authenticated user.
2134+
2135+
##### Example call:
2136+
2137+
```typescript
2138+
import { getAllNotificationsByUser } from '@iqss/dataverse-client-javascript'
2139+
2140+
/* ... */
2141+
2142+
getAllNotificationsByUser.execute().then((notifications: Notification[]) => {
2143+
/* ... */
2144+
})
2145+
2146+
/* ... */
2147+
```
2148+
2149+
_See [use case](../src/notifications/domain/useCases/GetAllNotificationsByUser.ts) implementation_.
2150+
2151+
#### Delete Notification
2152+
2153+
Deletes a specific notification for the current authenticated user by its ID.
2154+
2155+
##### Example call:
2156+
2157+
```typescript
2158+
import { deleteNotification } from '@iqss/dataverse-client-javascript'
2159+
2160+
/* ... */
2161+
2162+
const notificationId = 123
2163+
2164+
deleteNotification.execute(notificationId: number).then(() => {
2165+
/* ... */
2166+
})
2167+
2168+
/* ... */
2169+
```
2170+
2171+
_See [use case](../src/notifications/domain/useCases/DeleteNotification.ts) implementation_.
2172+
2173+
#### Get Unread Count
2174+
2175+
Returns the number of unread notifications for the current authenticated user.
2176+
2177+
##### Example call:
2178+
2179+
```typescript
2180+
import { getUnreadNotificationsCount } from '@iqss/dataverse-client-javascript'
2181+
2182+
/* ... */
2183+
2184+
getUnreadNotificationsCount.execute().then((count: number) => {
2185+
console.log(`You have ${count} unread notifications`)
2186+
})
2187+
2188+
/* ... */
2189+
```
2190+
2191+
_See [use case](../src/notifications/domain/useCases/GetUnreadNotificationsCount.ts) implementation_.
2192+
2193+
#### Mark As Read
2194+
2195+
Marks a specific notification as read for the current authenticated user. This operation is idempotent - marking an already-read notification as read will not cause an error.
2196+
2197+
##### Example call:
2198+
2199+
```typescript
2200+
import { markNotificationAsRead } from '@iqss/dataverse-client-javascript'
2201+
2202+
/* ... */
2203+
2204+
const notificationId = 123
2205+
2206+
markNotificationAsRead.execute(notificationId).then(() => {
2207+
console.log('Notification marked as read')
2208+
})
2209+
2210+
/* ... */
2211+
```
2212+
2213+
_See [use case](../src/notifications/domain/useCases/MarkNotificationAsRead.ts) implementation_.
2214+
20682215
## Search
20692216

20702217
#### Get Search Services
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { CollectionSummary } from './CollectionSummary'
2+
import { DatasetSummary } from '../../../datasets/domain/models/DatasetSummary'
3+
4+
export interface CollectionLinks {
5+
linkedCollections: CollectionSummary[]
6+
collectionsLinkingToThis: CollectionSummary[]
7+
linkedDatasets: DatasetSummary[]
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface CollectionSummary {
2+
id: number
3+
alias: string
4+
displayName: string
5+
}

src/collections/domain/repositories/ICollectionsRepository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CollectionSearchCriteria } from '../models/CollectionSearchCriteria'
99
import { CollectionUserPermissions } from '../models/CollectionUserPermissions'
1010
import { PublicationStatus } from '../../../core/domain/models/PublicationStatus'
1111
import { CollectionItemType } from '../../../collections/domain/models/CollectionItemType'
12+
import { CollectionLinks } from '../models/CollectionLinks'
1213

1314
export interface ICollectionsRepository {
1415
getCollection(collectionIdOrAlias: number | string): Promise<Collection>
@@ -50,5 +51,14 @@ export interface ICollectionsRepository {
5051
): Promise<FeaturedItem[]>
5152
deleteCollectionFeaturedItems(collectionIdOrAlias: number | string): Promise<void>
5253
deleteCollectionFeaturedItem(featuredItemId: number): Promise<void>
54+
linkCollection(
55+
linkedCollectionIdOrAlias: number | string,
56+
linkingCollectionIdOrAlias: number | string
57+
): Promise<void>
58+
unlinkCollection(
59+
linkedCollectionIdOrAlias: number | string,
60+
linkingCollectionIdOrAlias: number | string
61+
): Promise<void>
62+
getCollectionLinks(collectionIdOrAlias: number | string): Promise<CollectionLinks>
5363
getDatasetTemplates(collectionIdOrAlias: number | string): Promise<unknown>
5464
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { UseCase } from '../../../core/domain/useCases/UseCase'
2+
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
3+
import { CollectionLinks } from '../models/CollectionLinks'
4+
5+
export class GetCollectionLinks implements UseCase<CollectionLinks> {
6+
private collectionsRepository: ICollectionsRepository
7+
8+
constructor(collectionsRepository: ICollectionsRepository) {
9+
this.collectionsRepository = collectionsRepository
10+
}
11+
12+
/**
13+
* Returns a CollectionLinks object containing other collections this collection is linked to, the other collections linking to this collection, and datasets linked to this collection, given the collection identifier or alias.
14+
*
15+
* @param {number | string} [collectionIdOrAlias] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId)
16+
* If this parameter is not set, the default value is: ':root'
17+
* @returns {Promise<CollectionLinks>}
18+
*/
19+
async execute(collectionId: number | string): Promise<CollectionLinks> {
20+
return await this.collectionsRepository.getCollectionLinks(collectionId)
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { UseCase } from '../../../core/domain/useCases/UseCase'
2+
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
3+
4+
export class LinkCollection implements UseCase<void> {
5+
private collectionsRepository: ICollectionsRepository
6+
7+
constructor(collectionsRepository: ICollectionsRepository) {
8+
this.collectionsRepository = collectionsRepository
9+
}
10+
11+
/**
12+
* Creates a link between two collections. The linked collection will be linked to the linking collection.:
13+
*
14+
* @param {number| string} [linkedCollectionIdOrAlias] - The collection to be linked. Can be either a string (collection alias), or a number (collection id)
15+
* @param { number | string} [linkingCollectionIdOrAlias] - The collection that will be linking to the linked collection. Can be either a string (collection alias), or a number (collection id)
16+
* @returns {Promise<void>} -This method does not return anything upon successful completion.
17+
*/
18+
async execute(
19+
linkedCollectionIdOrAlias: number | string,
20+
linkingCollectionIdOrAlias: number | string
21+
): Promise<void> {
22+
return await this.collectionsRepository.linkCollection(
23+
linkedCollectionIdOrAlias,
24+
linkingCollectionIdOrAlias
25+
)
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { UseCase } from '../../../core/domain/useCases/UseCase'
2+
import { ICollectionsRepository } from '../repositories/ICollectionsRepository'
3+
4+
export class UnlinkCollection implements UseCase<void> {
5+
private collectionsRepository: ICollectionsRepository
6+
7+
constructor(collectionsRepository: ICollectionsRepository) {
8+
this.collectionsRepository = collectionsRepository
9+
}
10+
11+
/**
12+
* Unlinks a collection from the collection that links to it
13+
*
14+
* @param {number| string} [linkedCollectionIdOrAlias] - The collection that is linked. Can be either a string (collection alias), or a number (collection id)
15+
* @param { number | string} [linkingCollectionIdOrAlias] - The collection that links to the linked collection. Can be either a string (collection alias), or a number (collection id)
16+
* @returns {Promise<void>} -This method does not return anything upon successful completion.
17+
*/
18+
async execute(
19+
linkedCollectionIdOrAlias: number | string,
20+
linkingCollectionIdOrAlias: number | string
21+
): Promise<void> {
22+
return await this.collectionsRepository.unlinkCollection(
23+
linkedCollectionIdOrAlias,
24+
linkingCollectionIdOrAlias
25+
)
26+
}
27+
}

src/collections/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { DeleteCollectionFeaturedItems } from './domain/useCases/DeleteCollectio
1212
import { DeleteCollection } from './domain/useCases/DeleteCollection'
1313
import { GetMyDataCollectionItems } from './domain/useCases/GetMyDataCollectionItems'
1414
import { DeleteCollectionFeaturedItem } from './domain/useCases/DeleteCollectionFeaturedItem'
15+
import { LinkCollection } from './domain/useCases/LinkCollection'
16+
import { UnlinkCollection } from './domain/useCases/UnlinkCollection'
17+
import { GetCollectionLinks } from './domain/useCases/GetCollectionLinks'
1518

1619
const collectionsRepository = new CollectionsRepository()
1720

@@ -28,6 +31,9 @@ const updateCollectionFeaturedItems = new UpdateCollectionFeaturedItems(collecti
2831
const deleteCollectionFeaturedItems = new DeleteCollectionFeaturedItems(collectionsRepository)
2932
const deleteCollection = new DeleteCollection(collectionsRepository)
3033
const deleteCollectionFeaturedItem = new DeleteCollectionFeaturedItem(collectionsRepository)
34+
const linkCollection = new LinkCollection(collectionsRepository)
35+
const unlinkCollection = new UnlinkCollection(collectionsRepository)
36+
const getCollectionLinks = new GetCollectionLinks(collectionsRepository)
3137

3238
export {
3339
getCollection,
@@ -42,7 +48,10 @@ export {
4248
updateCollectionFeaturedItems,
4349
deleteCollectionFeaturedItems,
4450
deleteCollection,
45-
deleteCollectionFeaturedItem
51+
deleteCollectionFeaturedItem,
52+
linkCollection,
53+
unlinkCollection,
54+
getCollectionLinks
4655
}
4756
export { Collection, CollectionInputLevel } from './domain/models/Collection'
4857
export { CollectionFacet } from './domain/models/CollectionFacet'

0 commit comments

Comments
 (0)