mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[PM-328] Move exporter to tools (#5070)
* Create and register new libs/exporter Create package.json Create tsconfig Create jest.config Extend shared and root tsconfig and jest.configs Register with eslint * Migrate exportService to libs/exporter Move exportService (abstraction and impl) into libs/exporter Refactored exportService to be split into vault-export and event-export Created barrel-files for both exports Moved export.service.spec.ts into vault-export Created an export-helper, which helps build the filename (extract method refactor from ExportService) * Move components in libs/angular into tools-subfolder Moved components Updated imports in jslib-services.module and jslib.module * Register libs/exporter with browser and fix imports Move export.component into tools-subfolder * Register libs/exporter with cli and fix imports Move export.command into tools-subfolder * Register libs/exporter with desktop and fix imports Move export.component into tools-subfolder * Move export models to libs/exporter * Update web imports * Update package-lock.json * Move export models back as it would create circular dependency Reponse models in common rely on export models which are in libs/exporter, which relies on common * Fix up web for event-export * Update CODEOWNERS * Add export-models to team-tools-dev * Simplify domain import * Moving EventExport into web
This commit is contained in:
committed by
GitHub
parent
830af7b06d
commit
192bb5a7b3
@@ -4,7 +4,6 @@ import { concatMap, Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@@ -18,6 +17,7 @@ import { EventResponse } from "@bitwarden/common/models/response/event.response"
|
||||
|
||||
import { BaseEventsComponent } from "../../../common/base.events.component";
|
||||
import { EventService } from "../../../core";
|
||||
import { EventExportService } from "../../../tools/event-export";
|
||||
|
||||
const EVENT_SYSTEM_USER_TO_TRANSLATION: Record<EventSystemUser, string> = {
|
||||
[EventSystemUser.SCIM]: null, // SCIM acronym not able to be translated so just display SCIM
|
||||
@@ -41,7 +41,7 @@ export class EventsComponent extends BaseEventsComponent implements OnInit, OnDe
|
||||
private route: ActivatedRoute,
|
||||
eventService: EventService,
|
||||
i18nService: I18nService,
|
||||
exportService: ExportService,
|
||||
exportService: EventExportService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
private router: Router,
|
||||
logService: LogService,
|
||||
|
||||
@@ -5,7 +5,6 @@ import { ActivatedRoute } from "@angular/router";
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@@ -13,6 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { ExportComponent } from "../../../../tools/import-export/export.component";
|
||||
|
||||
@@ -26,7 +26,7 @@ export class OrganizationExportComponent extends ExportComponent {
|
||||
cryptoService: CryptoService,
|
||||
i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
exportService: ExportService,
|
||||
exportService: VaultExportServiceAbstraction,
|
||||
eventCollectionService: EventCollectionService,
|
||||
private route: ActivatedRoute,
|
||||
policyService: PolicyService,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Directive } from "@angular/core";
|
||||
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@@ -10,6 +9,7 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||
|
||||
import { EventService } from "../core";
|
||||
import { EventExportService } from "../tools/event-export";
|
||||
|
||||
@Directive()
|
||||
export abstract class BaseEventsComponent {
|
||||
@@ -29,7 +29,7 @@ export abstract class BaseEventsComponent {
|
||||
constructor(
|
||||
protected eventService: EventService,
|
||||
protected i18nService: I18nService,
|
||||
protected exportService: ExportService,
|
||||
protected exportService: EventExportService,
|
||||
protected platformUtilsService: PlatformUtilsService,
|
||||
protected logService: LogService,
|
||||
protected fileDownloadService: FileDownloadService
|
||||
|
||||
20
apps/web/src/app/tools/event-export/event-export.service.ts
Normal file
20
apps/web/src/app/tools/event-export/event-export.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import * as papa from "papaparse";
|
||||
|
||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||
import { ExportHelper } from "@bitwarden/exporter/export-helper";
|
||||
|
||||
import { EventExport } from "./event.export";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
export class EventExportService {
|
||||
async getEventExport(events: EventView[]): Promise<string> {
|
||||
return papa.unparse(events.map((e) => new EventExport(e)));
|
||||
}
|
||||
|
||||
getFileName(prefix: string = null, extension = "csv"): string {
|
||||
return ExportHelper.getFileName(prefix, extension);
|
||||
}
|
||||
}
|
||||
28
apps/web/src/app/tools/event-export/event.export.ts
Normal file
28
apps/web/src/app/tools/event-export/event.export.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||
|
||||
export class EventExport {
|
||||
message: string;
|
||||
appIcon: string;
|
||||
appName: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
userEmail: string;
|
||||
date: string;
|
||||
ip: string;
|
||||
type: string;
|
||||
installationId: string;
|
||||
|
||||
constructor(event: EventView) {
|
||||
this.message = event.humanReadableMessage;
|
||||
this.appIcon = event.appIcon;
|
||||
this.appName = event.appName;
|
||||
this.userId = event.userId;
|
||||
this.userName = event.userName;
|
||||
this.userEmail = event.userEmail;
|
||||
this.date = event.date;
|
||||
this.ip = event.ip;
|
||||
this.type = EventType[event.type];
|
||||
this.installationId = event.installationId;
|
||||
}
|
||||
}
|
||||
1
apps/web/src/app/tools/event-export/index.ts
Normal file
1
apps/web/src/app/tools/event-export/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./event-export.service";
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/tools/export/components/export.component";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service";
|
||||
import { ExportService } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
@@ -13,6 +12,7 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { EncryptedExportType } from "@bitwarden/common/enums";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/exporter/vault-export";
|
||||
|
||||
import { UserVerificationPromptComponent } from "../../components/user-verification-prompt.component";
|
||||
|
||||
@@ -29,7 +29,7 @@ export class ExportComponent extends BaseExportComponent {
|
||||
cryptoService: CryptoService,
|
||||
i18nService: I18nService,
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
exportService: ExportService,
|
||||
exportService: VaultExportServiceAbstraction,
|
||||
eventCollectionService: EventCollectionService,
|
||||
policyService: PolicyService,
|
||||
logService: LogService,
|
||||
|
||||
Reference in New Issue
Block a user