1- export class StorageError extends Error {
2- public name = 'StorageError' ;
3- constructor (
4- public code : 'RecordsCount' | 'RecordSize' | 'KeyType' | 'KeySize' ,
5- message : string ,
6- ) {
7- super ( message ) ;
8- }
1+ export interface StorageError extends Error {
2+ name : 'StorageError' ;
3+ code : 'RecordsCount' | 'RecordSize' | 'KeyType' | 'KeySize' ;
94}
5+
106export interface Storage <
117 BaseStorageTypes extends Record < string , any > = Record < string , unknown > ,
128> {
@@ -16,6 +12,7 @@ export interface Storage<
1612 * @param key - The key to set the value for.
1713 * @param value - The value to set for the key.
1814 * Can be any primitive type supported by `JSON.stringify`.
15+ * @throws Error when the API version is lower than 2025-04.
1916 * @throws StorageError when:
2017 * the extension exceeds its allotted storage limit.
2118 * the value exceeds its allotted storage limit.
@@ -35,6 +32,7 @@ export interface Storage<
3532 * @param key - The key to get the value for.
3633 * @returns The value of the key.
3734 * If no value for the key exists, the resolved value is undefined.
35+ * @throws Error when the API version is lower than 2025-04.
3836 * @throws StorageError when the key is not a string or exceeds its allotted size.
3937 */
4038 get <
@@ -46,12 +44,14 @@ export interface Storage<
4644
4745 /**
4846 * Clears the storage.
47+ * @throws Error when the API version is lower than 2025-04.
4948 */
5049 clear : ( ) => Promise < void > ;
5150
5251 /**
5352 * Deletes a key from the storage.
5453 *
54+ * @throws Error when the API version is lower than 2025-04.
5555 * @param key - The key to delete.
5656 */
5757 delete <
@@ -64,6 +64,7 @@ export interface Storage<
6464 /**
6565 * Gets all the keys and values in the storage.
6666 *
67+ * @throws Error when the API version is lower than 2025-04.
6768 * @returns An array containing all the keys and values in the storage.
6869 */
6970 entries <
0 commit comments