Skip to content

Commit

Permalink
fix: add string type
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Feb 26, 2025
1 parent a279321 commit b681b76
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/useCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ replaceFile.execute(fileId, uploadedFileDTO)

_See [use case](../src/files/domain/useCases/ReplaceFile.ts) implementation_.

The `fileId` parameter should be a number, the numeric identifier.
The `fileId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.

The `uploadedFileDTO` parameter is a [UploadedFileDTO](../src/files/domain/dtos/UploadedFileDTO.ts) and includes properties related to the uploaded files. Some of these properties should be calculated from the uploaded File Blob objects and the resulting storage identifiers from the Upload File use case.

Expand Down
2 changes: 1 addition & 1 deletion src/files/domain/repositories/IFilesRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export interface IFilesRepository {

deleteFile(fileId: number | string): Promise<undefined>

replaceFile(fileId: number, uploadedFileDTO: UploadedFileDTO): Promise<undefined>
replaceFile(fileId: number | string, uploadedFileDTO: UploadedFileDTO): Promise<undefined>

restrictFile(fileId: number | string, restrict: boolean): Promise<undefined>
}
2 changes: 1 addition & 1 deletion src/files/domain/useCases/ReplaceFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ReplaceFile implements UseCase<void> {
* @returns {Promise<void>} A promise that resolves when the file has been successfully replaced.
* @throws {WriteError} - If there are errors while writing data.
*/
async execute(fileId: number, uploadedFileDTO: UploadedFileDTO): Promise<void> {
async execute(fileId: number | string, uploadedFileDTO: UploadedFileDTO): Promise<void> {
await this.filesRepository.replaceFile(fileId, uploadedFileDTO)
}
}
5 changes: 4 additions & 1 deletion src/files/infra/repositories/FilesRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ export class FilesRepository extends ApiRepository implements IFilesRepository {
})
}

public async replaceFile(fileId: number, uploadedFileDTO: UploadedFileDTO): Promise<undefined> {
public async replaceFile(
fileId: number | string,
uploadedFileDTO: UploadedFileDTO
): Promise<undefined> {
const requestBody: UploadedFileRequestBody = {
fileName: uploadedFileDTO.fileName,
checksum: {
Expand Down

0 comments on commit b681b76

Please sign in to comment.