diff --git a/libs/common/src/state-migrations/migration-helper.ts b/libs/common/src/state-migrations/migration-helper.ts index d113b84fdb..315a343e9e 100644 --- a/libs/common/src/state-migrations/migration-helper.ts +++ b/libs/common/src/state-migrations/migration-helper.ts @@ -40,6 +40,18 @@ export class MigrationHelper { return this.storageService.save(key, value); } + /** + * Remove a value in the storage service at the given key. + * + * This is a brute force method to just remove a value in the storage service. If you can use {@link removeFromGlobal} or {@link removeFromUser}, you should. + * @param key location + * @returns void + */ + remove(key: string): Promise { + this.logService.info(`Removing ${key}`); + return this.storageService.remove(key); + } + /** * Gets a globally scoped value from a location derived through the key definition * @@ -65,6 +77,18 @@ export class MigrationHelper { return this.set(this.getGlobalKey(keyDefinition), value); } + /** + * Remove a globally scoped location derived through the key definition + * + * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService}, + * use {@link remove} for those. + * @param keyDefinition unique key definition + * @returns void + */ + removeFromGlobal(keyDefinition: KeyDefinitionLike): Promise { + return this.remove(this.getGlobalKey(keyDefinition)); + } + /** * Gets a user scoped value from a location derived through the user id and key definition * @@ -92,6 +116,18 @@ export class MigrationHelper { return this.set(this.getUserKey(userId, keyDefinition), value); } + /** + * Remove a user scoped location derived through the key definition + * + * This is for use with the state providers framework, DO NOT use for values stored with {@link StateService}, + * use {@link remove} for those. + * @param keyDefinition unique key definition + * @returns void + */ + removeFromUser(userId: string, keyDefinition: KeyDefinitionLike): Promise { + return this.remove(this.getUserKey(userId, keyDefinition)); + } + info(message: string): void { this.logService.info(message); }