Skip to content

Commit

Permalink
return updated folder when saving a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jaasen-livefront committed Jan 15, 2025
1 parent 6f018e1 commit b42394d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions apps/cli/src/commands/edit.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { Folder } from "@bitwarden/common/vault/models/domain/folder";

Check warning on line 17 in apps/cli/src/commands/edit.command.ts

View check run for this annotation

Codecov / codecov/patch

apps/cli/src/commands/edit.command.ts#L17

Added line #L17 was not covered by tests
import { KeyService } from "@bitwarden/key-management";

import { OrganizationCollectionRequest } from "../admin-console/models/request/organization-collection.request";
Expand Down Expand Up @@ -152,8 +153,8 @@ export class EditCommand {
const userKey = await this.keyService.getUserKeyWithLegacySupport(activeUserId);
const encFolder = await this.folderService.encrypt(folderView, userKey);
try {
await this.folderApiService.save(encFolder, activeUserId);
const updatedFolder = await this.folderService.get(folder.id, activeUserId);
const folder = await this.folderApiService.save(encFolder, activeUserId);
const updatedFolder = new Folder(folder);

Check warning on line 157 in apps/cli/src/commands/edit.command.ts

View check run for this annotation

Codecov / codecov/patch

apps/cli/src/commands/edit.command.ts#L156-L157

Added lines #L156 - L157 were not covered by tests
const decFolder = await updatedFolder.decrypt();
const res = new FolderResponse(decFolder);
return Response.success(res);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// @ts-strict-ignore

import { UserId } from "../../../types/guid";
import { FolderData } from "../../models/data/folder.data";
import { Folder } from "../../models/domain/folder";
import { FolderResponse } from "../../models/response/folder.response";

export class FolderApiServiceAbstraction {
save: (folder: Folder, userId: UserId) => Promise<any>;
save: (folder: Folder, userId: UserId) => Promise<FolderData>;
delete: (id: string, userId: UserId) => Promise<any>;
get: (id: string) => Promise<FolderResponse>;
deleteAll: (userId: UserId) => Promise<void>;
Expand Down
3 changes: 2 additions & 1 deletion libs/common/src/vault/services/folder/folder-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class FolderApiService implements FolderApiServiceAbstraction {
private apiService: ApiService,
) {}

async save(folder: Folder, userId: UserId): Promise<any> {
async save(folder: Folder, userId: UserId): Promise<FolderData> {
const request = new FolderRequest(folder);

let response: FolderResponse;
Expand All @@ -26,6 +26,7 @@ export class FolderApiService implements FolderApiServiceAbstraction {

const data = new FolderData(response);
await this.folderService.upsert(data, userId);
return data;

Check warning on line 29 in libs/common/src/vault/services/folder/folder-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/common/src/vault/services/folder/folder-api.service.ts#L29

Added line #L29 was not covered by tests
}

async delete(id: string, userId: UserId): Promise<any> {
Expand Down

0 comments on commit b42394d

Please sign in to comment.