1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-25 00:53:22 +00:00
Files
browser/libs/common/src/admin-console/models/domain/policy.ts
2025-07-19 09:46:36 +10:00

43 lines
1.3 KiB
TypeScript

// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { ListResponse } from "../../../models/response/list.response";
import Domain from "../../../platform/models/domain/domain-base";
import { OrganizationId, PolicyId } from "../../../types/guid";
import { PolicyType } from "../../enums";
import { PolicyData } from "../data/policy.data";
import { PolicyResponse } from "../response/policy.response";
export class Policy extends Domain {
id: PolicyId;
organizationId: OrganizationId;
type: PolicyType;
data: any;
/**
* Warning: a user can be exempt from a policy even if the policy is enabled.
* @see {@link PolicyService} has methods to tell you whether a policy applies to a user.
*/
enabled: boolean;
constructor(obj?: PolicyData) {
super();
if (obj == null) {
return;
}
this.id = obj.id;
this.organizationId = obj.organizationId as OrganizationId;
this.type = obj.type;
this.data = obj.data;
this.enabled = obj.enabled;
}
static fromResponse(response: PolicyResponse): Policy {
return new Policy(new PolicyData(response));
}
static fromListResponse(response: ListResponse<PolicyResponse>): Policy[] | undefined {
return response.data?.map((d) => Policy.fromResponse(d)) ?? undefined;
}
}