mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[SM-288] Rename models to follow naming convention (#3795)
This commit is contained in:
52
libs/common/src/models/export/field.export.ts
Normal file
52
libs/common/src/models/export/field.export.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { FieldType } from "../../enums/fieldType";
|
||||
import { LinkedIdType } from "../../enums/linkedIdType";
|
||||
import { EncString } from "../domain/enc-string";
|
||||
import { Field as FieldDomain } from "../domain/field";
|
||||
import { FieldView } from "../view/field.view";
|
||||
|
||||
export class FieldExport {
|
||||
static template(): FieldExport {
|
||||
const req = new FieldExport();
|
||||
req.name = "Field name";
|
||||
req.value = "Some value";
|
||||
req.type = FieldType.Text;
|
||||
return req;
|
||||
}
|
||||
|
||||
static toView(req: FieldExport, view = new FieldView()) {
|
||||
view.type = req.type;
|
||||
view.value = req.value;
|
||||
view.name = req.name;
|
||||
view.linkedId = req.linkedId;
|
||||
return view;
|
||||
}
|
||||
|
||||
static toDomain(req: FieldExport, domain = new FieldDomain()) {
|
||||
domain.type = req.type;
|
||||
domain.value = req.value != null ? new EncString(req.value) : null;
|
||||
domain.name = req.name != null ? new EncString(req.name) : null;
|
||||
domain.linkedId = req.linkedId;
|
||||
return domain;
|
||||
}
|
||||
|
||||
name: string;
|
||||
value: string;
|
||||
type: FieldType;
|
||||
linkedId: LinkedIdType;
|
||||
|
||||
constructor(o?: FieldView | FieldDomain) {
|
||||
if (o == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (o instanceof FieldView) {
|
||||
this.name = o.name;
|
||||
this.value = o.value;
|
||||
} else {
|
||||
this.name = o.name?.encryptedString;
|
||||
this.value = o.value?.encryptedString;
|
||||
}
|
||||
this.type = o.type;
|
||||
this.linkedId = o.linkedId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user