mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-24227] Enable TS-strict for Collection Domain models (#15765)
* wip ts-strict * wip ts-strict * wip * cleanup * cleanup * fix story * fix story * fix story * wip * clean up CollectionAdminView construction * fix deprecated function call * fix cli * clean up * fix story * wip * fix cli * requested changes * clean up, fixing minor bugs, more type saftey * assign props in static ctor, clean up
This commit is contained in:
@@ -225,14 +225,15 @@ export class EditCommand {
|
||||
: req.users.map(
|
||||
(u) => new SelectionReadOnlyRequest(u.id, u.readOnly, u.hidePasswords, u.manage),
|
||||
);
|
||||
const request = new CollectionRequest();
|
||||
request.name = (await this.encryptService.encryptString(req.name, orgKey)).encryptedString;
|
||||
request.externalId = req.externalId;
|
||||
request.groups = groups;
|
||||
request.users = users;
|
||||
const request = new CollectionRequest({
|
||||
name: await this.encryptService.encryptString(req.name, orgKey),
|
||||
externalId: req.externalId,
|
||||
users,
|
||||
groups,
|
||||
});
|
||||
|
||||
const response = await this.apiService.putCollection(req.organizationId, id, request);
|
||||
const view = CollectionExport.toView(req);
|
||||
view.id = response.id;
|
||||
const view = CollectionExport.toView(req, response.id);
|
||||
const res = new OrganizationCollectionResponse(view, groups, users);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||
import { EncString } from "@bitwarden/common/key-management/crypto/models/enc-string";
|
||||
import { CardExport } from "@bitwarden/common/models/export/card.export";
|
||||
import { CipherExport } from "@bitwarden/common/models/export/cipher.export";
|
||||
import { CollectionExport } from "@bitwarden/common/models/export/collection.export";
|
||||
@@ -452,6 +451,7 @@ export class GetCommand extends DownloadCommand {
|
||||
const orgKeys = await firstValueFrom(this.keyService.activeUserOrgKeys$);
|
||||
decCollection = await collection.decrypt(
|
||||
orgKeys[collection.organizationId as OrganizationId],
|
||||
this.encryptService,
|
||||
);
|
||||
}
|
||||
} else if (id.trim() !== "") {
|
||||
@@ -497,9 +497,9 @@ export class GetCommand extends DownloadCommand {
|
||||
}
|
||||
|
||||
const response = await this.apiService.getCollectionAccessDetails(options.organizationId, id);
|
||||
const decCollection = new CollectionView(response);
|
||||
decCollection.name = await this.encryptService.decryptString(
|
||||
new EncString(response.name),
|
||||
const decCollection = await CollectionView.fromCollectionAccessDetails(
|
||||
response,
|
||||
this.encryptService,
|
||||
orgKey,
|
||||
);
|
||||
const groups =
|
||||
|
||||
@@ -211,7 +211,9 @@ export class ListCommand {
|
||||
}
|
||||
const collections = response.data
|
||||
.filter((c) => c.organizationId === options.organizationId)
|
||||
.map((r) => new Collection(new CollectionData(r as ApiCollectionDetailsResponse)));
|
||||
.map((r) =>
|
||||
Collection.fromCollectionData(new CollectionData(r as ApiCollectionDetailsResponse)),
|
||||
);
|
||||
const orgKeys = await firstValueFrom(this.keyService.orgKeys$(userId));
|
||||
if (orgKeys == null) {
|
||||
throw new Error("Organization keys not found.");
|
||||
|
||||
@@ -233,14 +233,14 @@ export class CreateCommand {
|
||||
: req.users.map(
|
||||
(u) => new SelectionReadOnlyRequest(u.id, u.readOnly, u.hidePasswords, u.manage),
|
||||
);
|
||||
const request = new CollectionRequest();
|
||||
request.name = (await this.encryptService.encryptString(req.name, orgKey)).encryptedString;
|
||||
request.externalId = req.externalId;
|
||||
request.groups = groups;
|
||||
request.users = users;
|
||||
const request = new CollectionRequest({
|
||||
name: await this.encryptService.encryptString(req.name, orgKey),
|
||||
externalId: req.externalId,
|
||||
groups,
|
||||
users,
|
||||
});
|
||||
const response = await this.apiService.postCollection(req.organizationId, request);
|
||||
const view = CollectionExport.toView(req);
|
||||
view.id = response.id;
|
||||
const view = CollectionExport.toView(req, response.id);
|
||||
const res = new OrganizationCollectionResponse(view, groups, users);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user