Skip to content

Commit 9483ed8

Browse files
committed
fix: optional replace
1 parent 803633e commit 9483ed8

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/files/domain/useCases/UpdateFileCategories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class UpdateFileCategories implements UseCase<void> {
1414
*
1515
* @param {number | string} [fileId] - The file identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers).
1616
* @param {string[]} [categories] - The categories to be added to the file.
17-
* @param {boolean} [replace] - If true, replaces the existing categories with the new ones. If false, adds the new categories to the existing ones.
17+
* @param {boolean} [replace](optional) - If true, replaces the existing categories with the new ones. If false, adds the new categories to the existing ones.
1818
* @returns {Promise<void>}
1919
*/
2020
async execute(fileId: number | string, categories: string[], replace?: boolean): Promise<void> {

src/files/domain/useCases/UpdateFileTabularTags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class UpdateFileTabularTags implements UseCase<void> {
1414
*
1515
* @param {number | string} [fileId] - The file identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers).
1616
* @param {string[]} [tabularTags] - The tabular tags to be added to the file.
17-
* @param {boolean} [replace] - If true, replaces the existing tabularTags with the new ones. If false, adds the new tabularTags to the existing ones.
17+
* @param {boolean} [replace](optional) - If true, replaces the existing tabularTags with the new ones. If false, adds the new tabularTags to the existing ones.
1818
* @returns {Promise<void>}
1919
*/
2020
async execute(fileId: number | string, tabularTags: string[], replace?: boolean): Promise<void> {

src/files/infra/repositories/FilesRepository.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,11 @@ export class FilesRepository extends ApiRepository implements IFilesRepository {
387387
tabularTags: string[],
388388
replace?: boolean
389389
): Promise<void> {
390+
const queryParams = replace !== undefined ? { replace } : {}
390391
return this.doPost(
391392
this.buildApiEndpoint(this.filesResourceName, 'metadata/tabularTags', fileId),
392393
{ tabularTags },
393-
{ replace: replace ?? false }
394+
queryParams
394395
)
395396
.then(() => undefined)
396397
.catch((error) => {
@@ -403,10 +404,11 @@ export class FilesRepository extends ApiRepository implements IFilesRepository {
403404
categories: string[],
404405
replace?: boolean
405406
): Promise<void> {
407+
const queryParams = replace !== undefined ? { replace } : {}
406408
return this.doPost(
407409
this.buildApiEndpoint(this.filesResourceName, 'metadata/categories', fileId),
408410
{ categories },
409-
{ replace: replace ?? false }
411+
queryParams
410412
)
411413
.then(() => undefined)
412414
.catch((error) => {

test/integration/files/FilesRepository.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ describe('FilesRepository', () => {
398398
})
399399

400400
test('should return error when file does not exist', async () => {
401-
const expectedError = new ReadError(`[404] File with ID ${nonExistentFiledId} not found.`)
401+
const expectedError = new ReadError(`[404] File with ID ${nonExistentFiledId} not found`)
402402

403403
await expect(sut.getFileDownloadCount(nonExistentFiledId)).rejects.toThrow(expectedError)
404404
})

0 commit comments

Comments
 (0)