Add use case for getting list of collections a user may create datasets in - #418
Add use case for getting list of collections a user may create datasets in#418vera wants to merge 6 commits into
Conversation
|
Hi @vera thanks for your PR! I was just reviewing the API that this use case is wrapping, and it has some issues with it - it doesn't have a paging option, and if the endpoint is called for a user such as an admin that returns a long list of collections, the performance is not good. UPDATE: after talking to the team, we think it's better to keep collectionList as a separate API, and add pagination and filtering to it. I created an issue for it here: IQSS/dataverse#12423 |
|
Putting this on hold, so it can be updated when IQSS/dataverse#12423 is completed |
…ns-for-creating # Conflicts: # src/collections/index.ts
|
@pdurbin has let me know that a PR for IQSS/dataverse#12423 (IQSS/dataverse#12436) is in the works. I'll update this PR with the new pagination and filtering params once that's merged. For now, I've just fixed merge conflicts. |
There was a problem hiding this comment.
Pull request overview
Adds a new Collections-domain use case to retrieve the list of Dataverse collections in which an authenticated user can create datasets, with repository support and public exports, plus usage documentation and a unit test.
Changes:
- Introduces
GetCollectionsForCreatinguse case and addsgetCollectionsForCreatingtoICollectionsRepository+CollectionsRepository. - Exports the new use case instance from
src/collections/index.ts. - Adds docs and a unit test for the new use case.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/collections/GetCollectionsForCreating.test.ts | Adds unit coverage for the new use case behavior (success + error propagation). |
| src/collections/infra/repositories/CollectionsRepository.ts | Implements the new API call and maps API payload to CollectionSummary[]. |
| src/collections/index.ts | Wires and exports getCollectionsForCreating for package consumers. |
| src/collections/domain/useCases/GetCollectionsForCreating.ts | Adds the use case class delegating to the repository method. |
| src/collections/domain/repositories/ICollectionsRepository.ts | Extends repository contract with getCollectionsForCreating(...). |
| docs/useCases.md | Documents the new use case and adds it to the collections read-use-cases list. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| public async getCollectionsForCreating(userIdentifier?: string): Promise<CollectionSummary[]> { | ||
| const queryParams = new URLSearchParams() | ||
|
|
| queryParams.set(GetMyDataCollectionItemsQueryParams.USER_IDENTIFIER, userIdentifier) | ||
| } | ||
|
|
||
| return this.doGet("/mydata/retrieve/collectionList", true, queryParams) |
| #### Get Collections for Creating | ||
|
|
||
| Returns an array of [CollectionSummary](../src/collections/domain/models/CollectionSummary.ts) (id, alias, displayName) representing the Dataverse collections which an authenticated user may create a new dataset in. | ||
|
|
|
Hi @vera , I thought this was Ready for Review, so I assigned Copilot to review it, sorry for interrupting! I see your comment here and realize you're still working on this PR now.
|
What this PR does / why we need it:
This PR adds code for getting the list of collections a user may create datasets in. (IQSS/dataverse#11681)
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:
/