1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-26 01:23:24 +00:00

[PM-25688] Remove ts-strict-ignore from FolderWithIdRequest and update importer service to use FolderRequest instead

This commit is contained in:
Shane
2026-02-24 12:04:17 -08:00
parent 7cca4d0256
commit 0ad90d6f7d
4 changed files with 5 additions and 24 deletions

View File

@@ -1,10 +1,10 @@
import { CipherRequest } from "../../vault/models/request/cipher.request";
import { FolderWithIdRequest } from "../../vault/models/request/folder-with-id.request";
import { FolderRequest } from "../../vault/models/request/folder.request";
import { KvpRequest } from "./kvp.request";
export class ImportCiphersRequest {
ciphers: CipherRequest[] = [];
folders: FolderWithIdRequest[] = [];
folders: FolderRequest[] = [];
folderRelationships: KvpRequest<number, number>[] = [];
}

View File

@@ -1,25 +1,12 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { Folder } from "../domain/folder";
import { FolderRequest } from "./folder.request";
export class FolderWithIdRequest extends FolderRequest {
/**
* Declared as `string` (not `string | null`) to satisfy the
* {@link UserKeyRotationDataProvider}`<TRequest extends { id: string } | { organizationId: string }>`
* constraint on `FolderService`.
*
* At runtime this is `null` for new import folders. PR #17077 enforced strict type-checking on
* folder models, changing this assignment to `folder.id ?? ""` — causing the importer to send
* `{"id":""}` instead of `{"id":null}`, which the server rejected.
* The `|| null` below restores the pre-migration behavior while `@ts-strict-ignore` above
* allows the `null` assignment against the `string` declaration.
*/
id: string;
constructor(folder: Folder) {
super(folder);
this.id = folder.id || null;
this.id = folder.id;
}
}

View File

@@ -294,11 +294,6 @@ describe("FolderWithIdRequest", () => {
const request = new FolderWithIdRequest(makeFolder(guid));
expect(request.id).toBe(guid);
});
it("sends null when folder id is empty string (new import folder)", () => {
const request = new FolderWithIdRequest(makeFolder(""));
expect(request.id).toBeNull();
});
});
function createCipher(options: Partial<CipherView> = {}) {

View File

@@ -24,7 +24,7 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
import { CipherType, toCipherTypeName } from "@bitwarden/common/vault/enums";
import { CipherRequest } from "@bitwarden/common/vault/models/request/cipher.request";
import { FolderWithIdRequest } from "@bitwarden/common/vault/models/request/folder-with-id.request";
import { FolderRequest } from "@bitwarden/common/vault/models/request/folder.request";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
import { RestrictedItemTypesService } from "@bitwarden/common/vault/services/restricted-item-types.service";
@@ -56,7 +56,6 @@ import {
KeePass2XmlImporter,
KeePassXCsvImporter,
KeeperCsvImporter,
// KeeperJsonImporter,
LastPassCsvImporter,
LogMeOnceCsvImporter,
MSecureCsvImporter,
@@ -388,7 +387,7 @@ export class ImportService implements ImportServiceAbstraction {
if (importResult.folders != null) {
for (let i = 0; i < importResult.folders.length; i++) {
const f = await this.folderService.encrypt(importResult.folders[i], userKey);
request.folders.push(new FolderWithIdRequest(f));
request.folders.push(new FolderRequest(f));
}
}
if (importResult.folderRelationships != null) {