-
Notifications
You must be signed in to change notification settings - Fork 10
add use cases for editing template to TemplatesRepository.ts #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
7f37fe1
a6df2e2
5cb432a
4b6149b
b98a2da
70d0228
2c483e5
503f81b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { CustomTerms } from '../../../datasets/domain/models/Dataset' | ||
|
|
||
| export interface UpdateTemplateLicenseTermsDTO { | ||
| name?: string | ||
| customTerms?: CustomTerms | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { TemplateFieldDTO, TemplateInstructionDTO } from './CreateTemplateDTO' | ||
|
|
||
| export interface UpdateTemplateMetadataDTO { | ||
| name?: string | ||
| fields?: TemplateFieldDTO[] | ||
| instructions?: TemplateInstructionDTO[] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { UpdateTemplateLicenseTermsDTO } from '../dtos/UpdateTemplateLicenseTermsDTO' | ||
| import { ITemplatesRepository } from '../repositories/ITemplatesRepository' | ||
|
|
||
| export class UpdateTemplateLicenseTerms implements UseCase<void> { | ||
| private templatesRepository: ITemplatesRepository | ||
|
|
||
| constructor(templatesRepository: ITemplatesRepository) { | ||
| this.templatesRepository = templatesRepository | ||
| } | ||
|
|
||
| /** | ||
| * Updates the license terms for a template with the given identifier. | ||
| * | ||
| * @param {number} templateId - The unique identifier of the template to update. | ||
| * @param {UpdateTemplateLicenseTermsDTO} payload - The license terms data to apply to the template. | ||
| * @returns {Promise<void>} A promise that resolves when the license terms have been updated. | ||
| */ | ||
| async execute(templateId: number, payload: UpdateTemplateLicenseTermsDTO): Promise<void> { | ||
| return await this.templatesRepository.updateTemplateLicenseTerms(templateId, payload) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { UpdateTemplateMetadataDTO } from '../dtos/UpdateTemplateMetadataDTO' | ||
| import { ITemplatesRepository } from '../repositories/ITemplatesRepository' | ||
|
|
||
| export class UpdateTemplateMetadata implements UseCase<void> { | ||
| private templatesRepository: ITemplatesRepository | ||
|
|
||
| constructor(templatesRepository: ITemplatesRepository) { | ||
| this.templatesRepository = templatesRepository | ||
| } | ||
|
|
||
| async execute( | ||
| templateId: number, | ||
| payload: UpdateTemplateMetadataDTO, | ||
| replace = false | ||
| ): Promise<void> { | ||
| return await this.templatesRepository.updateTemplateMetadata(templateId, payload, replace) | ||
| } | ||
|
Comment on lines
+12
to
+18
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
| import { TermsOfAccess } from '../../../datasets/domain/models/Dataset' | ||
| import { ITemplatesRepository } from '../repositories/ITemplatesRepository' | ||
|
|
||
| export class UpdateTemplateTermsOfAccess implements UseCase<void> { | ||
| private templatesRepository: ITemplatesRepository | ||
|
|
||
| constructor(templatesRepository: ITemplatesRepository) { | ||
| this.templatesRepository = templatesRepository | ||
| } | ||
|
|
||
ekraffmiller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Updates the terms of access for a template with the given identifier. | ||
| * | ||
| * @param {number} templateId - The unique identifier of the template to update. | ||
| * @param {TermsOfAccess} termsOfAccess - The new terms of access to apply to the template. | ||
| * @returns {Promise<void>} A promise that resolves when the terms of access have been updated. | ||
| */ | ||
| async execute(templateId: number, termsOfAccess: TermsOfAccess): Promise<void> { | ||
| return await this.templatesRepository.updateTemplateTermsOfAccess(templateId, termsOfAccess) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { TermsOfAccess } from '../../../../datasets/domain/models/Dataset' | ||
|
|
||
| export const transformTemplateTermsOfAccessToUpdatePayload = ( | ||
| terms: TermsOfAccess & { termsOfAccess?: string } | ||
| ) => { | ||
| const { | ||
| fileAccessRequest, | ||
| dataAccessPlace, | ||
| originalArchive, | ||
| availabilityStatus, | ||
| contactForAccess, | ||
| sizeOfCollection, | ||
| studyCompletion | ||
| } = terms | ||
|
|
||
| const termsOfAccess = terms.termsOfAccess ?? terms.termsOfAccessForRestrictedFiles | ||
|
|
||
| return { | ||
| customTermsOfAccess: { | ||
| fileAccessRequest, | ||
| termsOfAccess, | ||
| dataAccessPlace, | ||
| originalArchive, | ||
| availabilityStatus, | ||
| contactForAccess, | ||
| sizeOfCollection, | ||
| studyCompletion | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| POSTGRES_VERSION=17 | ||
| DATAVERSE_DB_USER=dataverse | ||
| SOLR_VERSION=9.8.0 | ||
| DATAVERSE_IMAGE_REGISTRY=docker.io | ||
| DATAVERSE_IMAGE_TAG=unstable | ||
| DATAVERSE_IMAGE_REGISTRY=ghcr.io | ||
| DATAVERSE_IMAGE_TAG=11912-edit-template-api | ||
|
||
| DATAVERSE_BOOTSTRAP_TIMEOUT=5m | ||
Uh oh!
There was an error while loading. Please reload this page.