1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-23920] Admin Console - adopt strongly typed guids (#15814)

Update organization, collection and policy to use strongly typed IDs
This commit is contained in:
Thomas Rittson
2025-08-06 15:27:52 +10:00
committed by GitHub
parent 598348fcc1
commit 61cd0c4f51
36 changed files with 122 additions and 67 deletions

View File

@@ -4,7 +4,10 @@ import { CollectionAccessSelectionView } from "./collection-access-selection.vie
import { CollectionAccessDetailsResponse } from "./collection.response";
import { CollectionView } from "./collection.view";
// TODO: this is used to represent the pseudo "Unassigned" collection as well as
// the user's personal vault (as a pseudo organization). This should be separated out into different values.
export const Unassigned = "unassigned";
export type Unassigned = typeof Unassigned;
export class CollectionAdminView extends CollectionView {
groups: CollectionAccessSelectionView[] = [];

View File

@@ -54,7 +54,7 @@ describe("Collection", () => {
it("Decrypt", async () => {
const collection = new Collection();
collection.id = "id";
collection.id = "id" as CollectionId;
collection.organizationId = "orgId" as OrganizationId;
collection.name = mockEnc("encName");
collection.externalId = "extId";

View File

@@ -1,5 +1,6 @@
import { EncString } from "@bitwarden/common/key-management/crypto/models/enc-string";
import Domain, { EncryptableKeys } from "@bitwarden/common/platform/models/domain/domain-base";
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { OrgKey } from "@bitwarden/common/types/key";
import { CollectionData } from "./collection.data";
@@ -13,8 +14,8 @@ export const CollectionTypes = {
export type CollectionType = (typeof CollectionTypes)[keyof typeof CollectionTypes];
export class Collection extends Domain {
id: string | undefined;
organizationId: string | undefined;
id: CollectionId | undefined;
organizationId: OrganizationId | undefined;
name: EncString | undefined;
externalId: string | undefined;
readOnly: boolean = false;

View File

@@ -2,6 +2,7 @@ import { Jsonify } from "type-fest";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { View } from "@bitwarden/common/models/view/view";
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { ITreeNodeObject } from "@bitwarden/common/vault/models/domain/tree-node";
import { Collection, CollectionType, CollectionTypes } from "./collection";
@@ -10,8 +11,8 @@ import { CollectionAccessDetailsResponse } from "./collection.response";
export const NestingDelimiter = "/";
export class CollectionView implements View, ITreeNodeObject {
id: string | undefined;
organizationId: string | undefined;
id: CollectionId | undefined;
organizationId: OrganizationId | undefined;
name: string = "";
externalId: string | undefined;
// readOnly applies to the items within a collection