Skip to content

Add use case for setting default contributor#415

Open
vera wants to merge 3 commits into
IQSS:developfrom
vera:feat/set-default-contributor
Open

Add use case for setting default contributor#415
vera wants to merge 3 commits into
IQSS:developfrom
vera:feat/set-default-contributor

Conversation

@vera

@vera vera commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This PR adds code for setting the default contributor role of a collection.

Which issue(s) this PR closes:

/

Related Dataverse PRs:

/

Special notes for your reviewer:

/

Suggestions on how to test this:

I've added tests and docs on how to use.

Is there a release notes or changelog update needed for this change?:

Yes

Additional documentation:

@vera vera changed the title Set default contributor Add use case for setting default contributor Jan 26, 2026
@pdurbin pdurbin moved this to Ready for Triage in IQSS Dataverse Project Mar 31, 2026
@scolapasta scolapasta moved this from Ready for Triage to Ready for Review ⏩ in IQSS Dataverse Project Mar 31, 2026
@cmbz cmbz added the FY26 Sprint 20 FY26 Sprint 20 (2026-03-26 - 2026-04-08) label Apr 8, 2026
@ekraffmiller ekraffmiller added GREI Re-arch GREI re-architecture-related Size: 3 A percentage of a sprint. 2.1 hours. labels Apr 8, 2026
@cmbz cmbz added the FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) label Apr 8, 2026
@cmbz cmbz added the FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) label Apr 22, 2026
@cmbz cmbz added the FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) label May 6, 2026
@cmbz cmbz added the FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) label May 21, 2026
@cmbz cmbz added the FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) label Jun 3, 2026
@ChengShi-1 ChengShi-1 requested review from ChengShi-1 and Copilot June 5, 2026 20:49
@ChengShi-1 ChengShi-1 moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Collections use case to set a collection’s default contributor role (Dataverse endpoint for assigning the default role to users creating datasets in a collection), wiring it through the repository layer, public exports, docs, and unit tests.

Changes:

  • Add SetDefaultContributorRole use case and expose it from the collections public API.
  • Implement setDefaultContributorRole in CollectionsRepository and add it to ICollectionsRepository.
  • Document the new use case and add a unit test for the use case behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/unit/collections/SetDefaultContributorRole.test.ts Adds unit tests for the new use case.
src/collections/infra/repositories/CollectionsRepository.ts Adds repository method calling the Dataverse API endpoint via PUT.
src/collections/index.ts Exposes the new use case from the collections module.
src/collections/domain/useCases/SetDefaultContributorRole.ts Introduces the new use case implementation and JSDoc.
src/collections/domain/repositories/ICollectionsRepository.ts Extends the repository interface with the new method.
docs/useCases.md Documents the new use case and adds it to the use-cases list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +14
await expect(testSetDefaultContributorRole.execute(1, "curator")).resolves.toBeUndefined()
expect(collectionRepositoryStub.setDefaultContributorRole).toHaveBeenCalledWith(1, "curator")
Comment on lines +26 to +27
await expect(testSetDefaultContributorRole.execute(1, "curator")).rejects.toThrow(WriteError)
expect(collectionRepositoryStub.setDefaultContributorRole).toHaveBeenCalledWith(1, "curator")
Comment thread src/collections/domain/useCases/SetDefaultContributorRole.ts
Comment on lines +170 to +182
public async setDefaultContributorRole(
collectionIdOrAlias: number | string,
roleAlias: string
): Promise<void> {
return this.doPut(
`/${this.collectionsResourceName}/${collectionIdOrAlias}/defaultContributorRole/${roleAlias}`,
{}
)
.then(() => undefined)
.catch((error) => {
throw error
})
}
Comment thread docs/useCases.md
Comment on lines +580 to +595
#### Set Default Contributor Role

Sets the default contributor role of a collection, given a collection identifier and a role alias.

##### Example call:

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

/* ... */

const collectionIdOrAlias = 12345
const roleAlias = 'curator'

setDefaultContributorRole.execute(collectionIdOrAlias, roleAlias)

@ChengShi-1 ChengShi-1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Vera, thanks for your contribution! Here are some suggestions

  • Merge with dev to update
  • update Changelog.md
  • For roleAlias(see roles in Dataverse), we could have a built-in reference to export, similar toFileCitationFormat.ts in js-dataverse
    • For example, export enum RoleAlias { ADMIN = 'Admin', ...}
  • add integration test proving the setDefault is working in different conditions
    • Successfully set a role, if possible, please check GET collection return a correct roleAlias
    • If this parameter is not set, the default value is: ':root'
    • maybe a few error conditions
  • run npm run format npx prettier . --check before your commit to clear the format

@cmbz cmbz added the FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 20 FY26 Sprint 20 (2026-03-26 - 2026-04-08) FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) FY26 Sprint 23 FY26 Sprint 23 (2026-05-06 - 2026-05-20) FY26 Sprint 24 FY26 Sprint 24 (2026-05-20 - 2026-06-03) FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) GREI Re-arch GREI re-architecture-related Size: 3 A percentage of a sprint. 2.1 hours.

Projects

Status: In Review 🔎

Development

Successfully merging this pull request may close these issues.

7 participants