Skip to content
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

[PM-8634] - CLI - return updated folder when saving a folder #12894

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { 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 @@
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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 @@

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
Loading