Use Cases of Get and Delete a template #406
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restructures template-related functionality into a dedicated /templates module and adds new use cases for getting and deleting templates. The changes move template operations from the datasets and collections modules to a more appropriate domain-specific location.
Key Changes:
- Created new Templates module with dedicated use cases: CreateTemplate, GetTemplate, GetDatasetTemplates, and DeleteTemplate
- Migrated template functionality from datasets and collections modules to the new templates module
- Added comprehensive unit, integration, and functional tests for the new template operations
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/templates/domain/useCases/GetTemplate.ts | New use case for retrieving a single template by ID |
| src/templates/domain/useCases/DeleteTemplate.ts | New use case for deleting a template by ID |
| src/templates/domain/useCases/CreateTemplate.ts | Migrated and updated CreateTemplate use case from collections module |
| src/templates/domain/useCases/GetDatasetTemplates.ts | Migrated use case for getting templates by collection |
| src/templates/domain/repositories/ITemplatesRepository.ts | New repository interface defining template operations |
| src/templates/domain/models/Template.ts | Updated template model definitions (renamed from DatasetTemplate) |
| src/templates/infra/repositories/TemplatesRepository.ts | New repository implementation for template operations |
| src/templates/infra/repositories/transformers/templateTransformers.ts | Transformer logic migrated from datasets module |
| src/templates/infra/repositories/transformers/TemplatePayload.ts | Updated payload interface for templates |
| src/templates/index.ts | Module exports for templates domain |
| src/index.ts | Added templates module to main exports |
| test/unit/templates/*.test.ts | New unit tests for template use cases |
| test/integration/templates/TemplateRepository.test.ts | Comprehensive integration tests for template repository |
| test/functional/templates/createDatasetTemplate.test.ts | Updated functional test with new import paths |
| src/datasets/domain/useCases/GetDatasetTemplates.ts | Removed - migrated to templates module |
| src/datasets/infra/repositories/transformers/datasetTemplateTransformers.ts | Removed - migrated to templates module |
| src/collections/domain/useCases/CreateDatasetTemplate.ts | Removed - migrated to templates module |
| src/collections/infra/repositories/CollectionsRepository.ts | Removed createDatasetTemplate method |
| docs/useCases.md | Updated documentation with new Templates section and reorganized template use cases |
| CHANGELOG.md | Updated with new template use cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { Template } from '../models/Template' | ||
|
|
||
| export interface ITemplatesRepository { | ||
| createDatasetTemplate( |
There was a problem hiding this comment.
Naming inconsistency: The repository method is named createDatasetTemplate but the domain model is just Template (not DatasetTemplate). For consistency with the new template domain naming (where the model is Template and the use case is CreateTemplate), consider renaming this method to createTemplate.
| createDatasetTemplate( | |
| createTemplate( |
There was a problem hiding this comment.
I think this suggested change from createDatasetTemplate() to createTemplate() makes sense, given that the object is a Template, and now that the other method has changed to getTemplatesByCollectionId(). What do you think?
ekraffmiller
left a comment
There was a problem hiding this comment.
Looks good! I just have some suggestions about the naming conventions
| template: CreateDatasetTemplateDTO | ||
| ): Promise<void> | ||
| getTemplate(templateId: number): Promise<Template> | ||
| getDatasetTemplates(collectionIdOrAlias: number | string): Promise<Template[]> |
There was a problem hiding this comment.
The naming of the two get functions are a little confusing. At first glance, it seems like getDatasetTemplates() may be returning all Templates for a Dataset.
Instead of getDatasetTemplates(), can we change it to getTemplatesByCollectionId()? That way it is more clear what is being returned.
| * Creates a Dataset Template in the specified collection. | ||
| * Creates a template in the specified collection. | ||
| * | ||
| * @param {CreateDatasetTemplateDTO} template - Template definition payload. |
There was a problem hiding this comment.
| * @param {CreateDatasetTemplateDTO} template - Template definition payload. | |
| * @param {CreateTemplateDTO} template - Template definition payload. |
ekraffmiller
left a comment
There was a problem hiding this comment.
Hi @ChengShi-1 , thanks for the updates, I have a couple more comments, let me know what you think :)
| import { Template } from '../models/Template' | ||
|
|
||
| export interface ITemplatesRepository { | ||
| createDatasetTemplate( |
There was a problem hiding this comment.
I think this suggested change from createDatasetTemplate() to createTemplate() makes sense, given that the object is a Template, and now that the other method has changed to getTemplatesByCollectionId(). What do you think?
docs/useCases.md
Outdated
| - [Templates](#Templates) | ||
| - [Templates read use cases](#templates-read-use-cases) | ||
| - [Get a Template](#get-a-template) | ||
| - [Get Dataset Templates](#get-dataset-templates) |
There was a problem hiding this comment.
Need to update the useCase docs with the new function name
|
@ekraffmiller thanks for the suggestions, it makes sense to change to |
ekraffmiller
left a comment
There was a problem hiding this comment.
looks good! approved
What this PR does / why we need it:
Which issue(s) this PR closes:
Related Dataverse PRs:
Special notes for your reviewer:
Templateinstead ofDataset Template, besidesgetDatasetTemplatesuse caseSuggestions on how to test this:
Is there a release notes or changelog update needed for this change?:
YES
Additional documentation: