1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 04:03:29 +00:00

chore(naming): rename AbstractStorageService to StorageService

This commit is contained in:
addisonbeck
2025-06-18 13:31:45 -04:00
parent 53bb9074ad
commit 7b4d467681
7 changed files with 18 additions and 16 deletions

View File

@@ -2,11 +2,11 @@ import { MockProxy, mock } from "jest-mock-extended";
import { Subject } from "rxjs";
import { StorageOptions } from "./storage-options";
import { AbstractStorageService, ObservableStorageService, StorageUpdate } from "./storage.service";
import { StorageService, ObservableStorageService, StorageUpdate } from "./storage.service";
const INTERNAL_KEY = "__internal__";
export class FakeStorageService implements AbstractStorageService, ObservableStorageService {
export class FakeStorageService implements StorageService, ObservableStorageService {
private store: Record<string, unknown>;
private updatesSubject = new Subject<StorageUpdate>();
private _valuesRequireDeserialization = false;
@@ -16,11 +16,11 @@ export class FakeStorageService implements AbstractStorageService, ObservableSto
* amount of calls. It is not recommended to use this to mock implementations as
* they are not respected.
*/
mock: MockProxy<AbstractStorageService>;
mock: MockProxy<StorageService>;
constructor(initial?: Record<string, unknown>) {
this.store = initial ?? {};
this.mock = mock<AbstractStorageService>();
this.mock = mock<StorageService>();
}
/**

View File

@@ -7,4 +7,6 @@ export * from "./storage-location";
export * from "./storage-location.enum";
export * from "./storage-options";
export * from "./storage-service.provider";
// Renamed to just "StorageService", to be removed when references are updated
export { StorageService as AbstractStorageService } from "./storage.service";
export * from "./storage.service";

View File

@@ -2,9 +2,9 @@
// @ts-strict-ignore
import { Subject } from "rxjs";
import { AbstractStorageService, StorageUpdate } from "./storage.service";
import { StorageService, StorageUpdate } from "./storage.service";
export class MemoryStorageService extends AbstractStorageService {
export class MemoryStorageService extends StorageService {
protected store = new Map<string, unknown>();
private updatesSubject = new Subject<StorageUpdate>();

View File

@@ -2,10 +2,10 @@
// @ts-strict-ignore
import { Subject } from "rxjs";
import { AbstractStorageService, ObservableStorageService, StorageUpdate } from "./storage.service";
import { StorageService, ObservableStorageService, StorageUpdate } from "./storage.service";
export class SerializedMemoryStorageService
extends AbstractStorageService
extends StorageService
implements ObservableStorageService
{
protected store: Record<string, string> = {};

View File

@@ -1,11 +1,11 @@
import { mock } from "jest-mock-extended";
import { StorageServiceProvider } from "./storage-service.provider";
import { AbstractStorageService, ObservableStorageService } from "./storage.service";
import { StorageService, ObservableStorageService } from "./storage.service";
describe("StorageServiceProvider", () => {
const mockDiskStorage = mock<AbstractStorageService & ObservableStorageService>();
const mockMemoryStorage = mock<AbstractStorageService & ObservableStorageService>();
const mockDiskStorage = mock<StorageService & ObservableStorageService>();
const mockMemoryStorage = mock<StorageService & ObservableStorageService>();
const sut = new StorageServiceProvider(mockDiskStorage, mockMemoryStorage);

View File

@@ -1,6 +1,6 @@
import { ClientLocations } from "./client-locations";
import { StorageLocation } from "./storage-location";
import { AbstractStorageService, ObservableStorageService } from "./storage.service";
import { StorageService, ObservableStorageService } from "./storage.service";
export type PossibleLocation = StorageLocation | ClientLocations[keyof ClientLocations];
@@ -9,8 +9,8 @@ export type PossibleLocation = StorageLocation | ClientLocations[keyof ClientLoc
*/
export class StorageServiceProvider {
constructor(
protected readonly diskStorageService: AbstractStorageService & ObservableStorageService,
protected readonly memoryStorageService: AbstractStorageService & ObservableStorageService,
protected readonly diskStorageService: StorageService & ObservableStorageService,
protected readonly memoryStorageService: StorageService & ObservableStorageService,
) {}
/**
@@ -26,7 +26,7 @@ export class StorageServiceProvider {
get(
defaultLocation: PossibleLocation,
overrides: Partial<ClientLocations>,
): [location: PossibleLocation, service: AbstractStorageService & ObservableStorageService] {
): [location: PossibleLocation, service: StorageService & ObservableStorageService] {
switch (defaultLocation) {
case "disk":
return [defaultLocation, this.diskStorageService];

View File

@@ -17,7 +17,7 @@ export interface ObservableStorageService {
get updates$(): Observable<StorageUpdate>;
}
export abstract class AbstractStorageService {
export abstract class StorageService {
abstract get valuesRequireDeserialization(): boolean;
abstract get<T>(key: string, options?: StorageOptions): Promise<T>;
abstract has(key: string, options?: StorageOptions): Promise<boolean>;