mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 19:23:52 +00:00
[PM-17563] [PM-19754] Migrate Security Task Module to libs/common (#14036)
* [PM-17563] Remove references to Angular from TaskService * [PM-17563] Move Task module to libs/common/vault to avoid Angular dependency * [PM-17563] Fix bad imports * [PM-17563] Fix a few more missed imports
This commit is contained in:
3
libs/common/src/vault/tasks/models/index.ts
Normal file
3
libs/common/src/vault/tasks/models/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./security-task";
|
||||
export * from "./security-task.data";
|
||||
export * from "./security-task.response";
|
||||
34
libs/common/src/vault/tasks/models/security-task.data.ts
Normal file
34
libs/common/src/vault/tasks/models/security-task.data.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Jsonify } from "type-fest";
|
||||
|
||||
import { CipherId, OrganizationId, SecurityTaskId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { SecurityTaskStatus, SecurityTaskType } from "../enums";
|
||||
|
||||
import { SecurityTaskResponse } from "./security-task.response";
|
||||
|
||||
export class SecurityTaskData {
|
||||
id: SecurityTaskId;
|
||||
organizationId: OrganizationId;
|
||||
cipherId: CipherId | undefined;
|
||||
type: SecurityTaskType;
|
||||
status: SecurityTaskStatus;
|
||||
creationDate: Date;
|
||||
revisionDate: Date;
|
||||
|
||||
constructor(response: SecurityTaskResponse) {
|
||||
this.id = response.id;
|
||||
this.organizationId = response.organizationId;
|
||||
this.cipherId = response.cipherId;
|
||||
this.type = response.type;
|
||||
this.status = response.status;
|
||||
this.creationDate = response.creationDate;
|
||||
this.revisionDate = response.revisionDate;
|
||||
}
|
||||
|
||||
static fromJSON(obj: Jsonify<SecurityTaskData>) {
|
||||
return Object.assign(new SecurityTaskData({} as SecurityTaskResponse), obj, {
|
||||
creationDate: new Date(obj.creationDate),
|
||||
revisionDate: new Date(obj.revisionDate),
|
||||
});
|
||||
}
|
||||
}
|
||||
28
libs/common/src/vault/tasks/models/security-task.response.ts
Normal file
28
libs/common/src/vault/tasks/models/security-task.response.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
|
||||
import { CipherId, OrganizationId, SecurityTaskId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { SecurityTaskStatus, SecurityTaskType } from "../enums";
|
||||
|
||||
export class SecurityTaskResponse extends BaseResponse {
|
||||
id: SecurityTaskId;
|
||||
organizationId: OrganizationId;
|
||||
/**
|
||||
* Optional cipherId for tasks that are related to a cipher.
|
||||
*/
|
||||
cipherId: CipherId | undefined;
|
||||
type: SecurityTaskType;
|
||||
status: SecurityTaskStatus;
|
||||
creationDate: Date;
|
||||
revisionDate: Date;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.id = this.getResponseProperty("Id");
|
||||
this.organizationId = this.getResponseProperty("OrganizationId");
|
||||
this.cipherId = this.getResponseProperty("CipherId") || undefined;
|
||||
this.type = this.getResponseProperty("Type");
|
||||
this.status = this.getResponseProperty("Status");
|
||||
this.creationDate = this.getResponseProperty("CreationDate");
|
||||
this.revisionDate = this.getResponseProperty("RevisionDate");
|
||||
}
|
||||
}
|
||||
28
libs/common/src/vault/tasks/models/security-task.ts
Normal file
28
libs/common/src/vault/tasks/models/security-task.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { CipherId, OrganizationId, SecurityTaskId } from "@bitwarden/common/types/guid";
|
||||
|
||||
import { SecurityTaskStatus, SecurityTaskType } from "../enums";
|
||||
|
||||
import { SecurityTaskData } from "./security-task.data";
|
||||
|
||||
export class SecurityTask {
|
||||
id: SecurityTaskId;
|
||||
organizationId: OrganizationId;
|
||||
/**
|
||||
* Optional cipherId for tasks that are related to a cipher.
|
||||
*/
|
||||
cipherId: CipherId | undefined;
|
||||
type: SecurityTaskType;
|
||||
status: SecurityTaskStatus;
|
||||
creationDate: Date;
|
||||
revisionDate: Date;
|
||||
|
||||
constructor(obj: SecurityTaskData) {
|
||||
this.id = obj.id;
|
||||
this.organizationId = obj.organizationId;
|
||||
this.cipherId = obj.cipherId;
|
||||
this.type = obj.type;
|
||||
this.status = obj.status;
|
||||
this.creationDate = obj.creationDate;
|
||||
this.revisionDate = obj.revisionDate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user