-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
227af2b
commit 07e7d05
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/ui-extensions/src/surfaces/point-of-sale/api/storage-api/storage-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export interface StorageApi { | ||
storage: StorageApiContent; | ||
} | ||
|
||
export enum StorageApiErrorCode { | ||
DataSizeLimitExceeded = 'DATA_SIZE_LIMIT_EXCEEDED', | ||
} | ||
export class StorageApiError extends Error { | ||
constructor(message: string, public code: StorageApiErrorCode) { | ||
super(message); | ||
this.name = 'StorageApiError'; | ||
this.code = code; | ||
} | ||
} | ||
|
||
export interface StorageApiContent { | ||
/** | ||
* Get the value of a key from the storage | ||
* @param key | ||
* @returns the value of the key or undefined if the key does not exist | ||
*/ | ||
get(key: string): Promise<string | undefined>; | ||
|
||
/** | ||
* Set the value of a key in the storage | ||
* Value must be encoded as a string | ||
* @throws StorageApiError with code=StorageApiErrorCode.DataSizeLimitExceeded if the data size limit is exceeded | ||
* @param key | ||
* @param value | ||
*/ | ||
set(key: string, value: string): Promise<void>; | ||
} |