mirror of
https://github.com/bitwarden/browser
synced 2026-02-01 17:23:37 +00:00
Add application model for risk insights reports following company architecture
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationData } from "../data/risk-insights-application.data";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplication } from "../domain/risk-insights-application";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationView } from "../view/risk-insights-application.view";
|
||||
|
||||
/**
|
||||
* Converts a RiskInsightsApplication API response
|
||||
*
|
||||
* - See {@link RiskInsightsApplication} for domain model
|
||||
* - See {@link RiskInsightsApplicationData} for data model
|
||||
* - See {@link RiskInsightsApplicationView} from View Model
|
||||
*/
|
||||
export class RiskInsightsApplicationApi extends BaseResponse {
|
||||
applicationName: string;
|
||||
isCritical: boolean = false;
|
||||
reviewedDate: string | undefined;
|
||||
|
||||
constructor(data: any) {
|
||||
super(data);
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.applicationName = this.getResponseProperty("applicationName");
|
||||
this.isCritical = this.getResponseProperty("isCritical") ?? false;
|
||||
this.reviewedDate = this.getResponseProperty("reviewedDate");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { RiskInsightsApplicationApi } from "../api/risk-insights-application.api";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplication } from "../domain/risk-insights-application";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationView } from "../view/risk-insights-application.view";
|
||||
|
||||
/**
|
||||
* Serializable data model for Application data in risk insights report
|
||||
*
|
||||
* - See {@link RiskInsightsApplication} for domain model
|
||||
* - See {@link RiskInsightsApplicationApi} for API model
|
||||
* - See {@link RiskInsightsApplicationView} from View Model
|
||||
*/
|
||||
|
||||
export class RiskInsightsApplicationData {
|
||||
applicationName: string;
|
||||
isCritical: boolean;
|
||||
reviewedDate: string | undefined;
|
||||
|
||||
constructor(data?: RiskInsightsApplicationApi) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.applicationName = data.applicationName;
|
||||
this.isCritical = data.isCritical;
|
||||
this.reviewedDate = data.reviewedDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import Domain from "@bitwarden/common/platform/models/domain/domain-base";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationApi } from "../api/risk-insights-application.api";
|
||||
import { RiskInsightsApplicationData } from "../data/risk-insights-application.data";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationView } from "../view/risk-insights-application.view";
|
||||
|
||||
/**
|
||||
* Domain model for Application data in Risk Insights containing encrypted properties
|
||||
*
|
||||
* - See {@link RiskInsightsApplicationApi} for API model
|
||||
* - See {@link RiskInsightsApplicationData} for data model
|
||||
* - See {@link RiskInsightsApplicationView} from View Model
|
||||
*/
|
||||
export class RiskInsightsApplication extends Domain {
|
||||
applicationName: string = ""; // TODO: Encrypt?
|
||||
isCritical: boolean = false;
|
||||
reviewedDate?: Date;
|
||||
|
||||
constructor(obj?: RiskInsightsApplicationData) {
|
||||
super();
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.applicationName = obj.applicationName;
|
||||
this.isCritical = obj.isCritical;
|
||||
this.reviewedDate = new Date(obj.reviewedDate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Jsonify } from "type-fest";
|
||||
|
||||
import { View } from "@bitwarden/common/models/view/view";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationApi } from "../api/risk-insights-application.api";
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { RiskInsightsApplicationData } from "../data/risk-insights-application.data";
|
||||
import { RiskInsightsApplication } from "../domain/risk-insights-application";
|
||||
|
||||
/**
|
||||
* View model for Application data in Risk Insights containing decrypted properties
|
||||
*
|
||||
* - See {@link RiskInsightsApplication} for domain model
|
||||
* - See {@link RiskInsightsApplicationData} for data model
|
||||
* - See {@link RiskInsightsApplicationApi} for API model
|
||||
*/
|
||||
export class RiskInsightsApplicationView implements View {
|
||||
applicationName: string = "";
|
||||
isCritical = false;
|
||||
reviewedDate?: Date;
|
||||
|
||||
constructor(a?: RiskInsightsApplication) {
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.applicationName = a.applicationName;
|
||||
this.isCritical = a.isCritical;
|
||||
this.reviewedDate = a.reviewedDate;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this;
|
||||
}
|
||||
|
||||
static fromJSON(obj: Partial<Jsonify<RiskInsightsApplicationView>>): RiskInsightsApplicationView {
|
||||
return Object.assign(new RiskInsightsApplicationView(), obj);
|
||||
}
|
||||
|
||||
// [TODO] SDK Mapping
|
||||
// toSdkRiskInsightsApplicationView(): SdkRiskInsightsApplicationView {}
|
||||
// static fromRiskInsightsApplicationView(obj?: SdkRiskInsightsApplicationView): RiskInsightsApplicationView | undefined {}
|
||||
}
|
||||
Reference in New Issue
Block a user