Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-328] Move exporter to tools #5070

Merged
merged 20 commits into from
Apr 19, 2023
Merged

Conversation

djsmith85
Copy link
Contributor

@djsmith85 djsmith85 commented Mar 24, 2023

Type of change

- [ ] Bug fix
- [ ] New feature development
- [X] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

Re-structure code in preparation for code ownership of the tools-team

Extract common/export.services and related files into their own lib -> libs/exporter

Code changes

  • Create and register new libs/exporter - 573c0b0
    • Create package.json
    • Create tsconfig
    • Create jest.config
    • Extend shared and root tsconfig and jest.configs
    • Register with eslint
  • Migrate exportService to libs/exporter - b46479c
    • 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 - 5126642
    • Moved components
    • Updated imports in jslib-services.module and jslib.module
  • Register libs/exporter with browser and fix imports - 25bfc3c
    • Move export.component into tools-subfolder
  • Register libs/exporter with cli and fix imports - 91fe936
    • Move export.command into tools-subfolder
  • Register libs/exporter with desktop and fix imports - 1d9ff87
    • Move export.component into tools-subfolder
  • Move export models to libs/exporter - 0720f3e
  • Update web imports - 6320e0c
  • Update package-lock.json - 6a145fa
  • Move export models back as it would create circular dependency - 4972870
    • Reponse models in common rely on export models which are in libs/exporter, which relies on common
  • Fix up web for event-export - 2cf40e9

Before you submit

  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team
  • Ensure that all UI additions follow WCAG AA requirements

Create package.json
Create tsconfig
Create jest.config
Extend shared and root tsconfig and jest.configs
Register with eslint
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)
Moved components
Updated imports in jslib-services.module and jslib.module
Move export.component into tools-subfolder
Move export.command into tools-subfolder
Move export.component into tools-subfolder
@github-actions github-actions bot added the needs-qa Marks a PR as requiring QA approval label Mar 24, 2023
Reponse models in common rely on export models which are in libs/exporter, which relies on common
@djsmith85 djsmith85 marked this pull request as ready for review March 24, 2023 01:44
@djsmith85 djsmith85 requested review from a team as code owners March 24, 2023 01:44
@djsmith85 djsmith85 requested a review from a team March 24, 2023 01:45
Comment on lines +1 to +11
export { CardExport } from "./card.export";
export { CipherWithIdExport } from "./cipher-with-ids.export";
export { CipherExport } from "./cipher.export";
export { CollectionWithIdExport } from "./collection-with-id.export";
export { CollectionExport } from "./collection.export";
export { FieldExport } from "./field.export";
export { FolderWithIdExport } from "./folder-with-id.export";
export { FolderExport } from "./folder.export";
export { IdentityExport } from "./identity.export";
export { LoginUriExport } from "./login-uri.export";
export { SecureNoteExport } from "./secure-note.export";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these be moved to the export module? Feels like internal implementation details for the export lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed previously with @MGibson1 and you, ideally these would move over into the export-package, but this would create a weird reference for the CLI which extends the export-models. As we currently do not plan to change this, due to the low-benefit to high work ratio, I'm proposing to keep them in libs/common/models/export.

@@ -0,0 +1,6 @@
import { EventView } from "@bitwarden/common/models/view/event.view";

export abstract class EventExportServiceAbstraction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we consider event exporters part of the export module? Those feel like a separate domain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I split it off, as it previously was part of the export.service. Which it definitely shouldn't be. Currently the event-export is only possible in the web-vault and could be moved their, if desired.
On the other hand, it might be benefical to have it in a lib to be also used in the CLI. This has not been discussed with Product, but it could be useful to have a CLI way of exporting and piping the output into a different tool (log-analyzer)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more thinking that libs/exporter should encompass the vault exporting capabilities, and events belongs to another module.

@djsmith85 djsmith85 requested a review from Hinton April 17, 2023 17:41
@@ -1,7 +1,7 @@
import { FieldType, LinkedIdType } from "../../enums";
import { EncString } from "../../models/domain/enc-string";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { EncString } from "../../models/domain/enc-string";
import { EncString } from "../domain/enc-string";

@@ -1,7 +1,7 @@
import { UriMatchType } from "../../enums";
import { EncString } from "../../models/domain/enc-string";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { EncString } from "../../models/domain/enc-string";
import { EncString } from "../domain/enc-string";

@@ -0,0 +1,6 @@
import { EventView } from "@bitwarden/common/models/view/event.view";

export abstract class EventExportServiceAbstraction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more thinking that libs/exporter should encompass the vault exporting capabilities, and events belongs to another module.

Comment on lines 9 to 10

export class EventExportService implements EventExportServiceAbstraction {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export class EventExportService implements EventExportServiceAbstraction {
@Injectable()
export class EventExportService implements EventExportServiceAbstraction {

@djsmith85 djsmith85 requested a review from Hinton April 18, 2023 15:26
@djsmith85 djsmith85 removed the needs-qa Marks a PR as requiring QA approval label Apr 19, 2023
@djsmith85 djsmith85 merged commit 192bb5a into master Apr 19, 2023
@djsmith85 djsmith85 deleted the pm-328-move-exporter-to-tools branch April 19, 2023 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants