@ada-support/web-storage 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ export declare const createStorage: (storageProvider: Storage) => {
4
4
  readonly setItem: <K extends keyof StorageValueByKey>(key: K, value: StorageValueByKey[K]) => void;
5
5
  readonly getItem: <K_1 extends keyof StorageValueByKey>(key: K_1) => StorageValueByKey[K_1] | null;
6
6
  readonly removeItem: <K_2 extends keyof StorageValueByKey>(key: K_2) => void;
7
+ readonly clear: () => void;
7
8
  /** Stores a key/value pair within `ada-functional-storage` Storage key */
8
9
  readonly setFnItem: <K_3 extends keyof AdaFunctionalStorageValue>(key: K_3, value: AdaFunctionalStorageValue[K_3]) => void;
9
10
  /** Gets a value under `ada-functional-storage` Storage key */
@@ -41,6 +41,14 @@ var createStorage = function (storageProvider) {
41
41
  console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
42
42
  }
43
43
  },
44
+ clear: function () {
45
+ try {
46
+ storageProvider.clear();
47
+ }
48
+ catch (e) {
49
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
50
+ }
51
+ },
44
52
  /** Stores a key/value pair within `ada-functional-storage` Storage key */
45
53
  setFnItem: function (key, value) {
46
54
  var _a;
@@ -1,11 +1,11 @@
1
1
  export interface AdaFunctionalStorageValue {
2
2
  rolloutGroup: {
3
- [clientHandle: string]: "A" | "B";
3
+ [clientHandle: string]: "A" | "B" | undefined;
4
4
  };
5
5
  rolloutLastValue: {
6
- [clientHandle: string]: number;
6
+ [clientHandle: string]: number | undefined;
7
7
  };
8
8
  marketing_campaigns_shown: {
9
- [clientHandle: string]: string;
9
+ [clientHandle: string]: string | undefined;
10
10
  };
11
11
  }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const adaLocalStorage: {
3
3
  readonly setItem: <K extends keyof StorageValueByKey>(key: K, value: StorageValueByKey[K]) => void;
4
4
  readonly getItem: <K_1 extends keyof StorageValueByKey>(key: K_1) => StorageValueByKey[K_1] | null;
5
5
  readonly removeItem: <K_2 extends keyof StorageValueByKey>(key: K_2) => void;
6
+ readonly clear: () => void;
6
7
  readonly setFnItem: <K_3 extends keyof import("./functional-storage").AdaFunctionalStorageValue>(key: K_3, value: import("./functional-storage").AdaFunctionalStorageValue[K_3]) => void;
7
8
  readonly getFnItem: <K_4 extends keyof import("./functional-storage").AdaFunctionalStorageValue>(key: K_4) => import("./functional-storage").AdaFunctionalStorageValue[K_4] | null;
8
9
  };
@@ -10,6 +11,7 @@ export declare const adaSessionStorage: {
10
11
  readonly setItem: <K extends keyof StorageValueByKey>(key: K, value: StorageValueByKey[K]) => void;
11
12
  readonly getItem: <K_1 extends keyof StorageValueByKey>(key: K_1) => StorageValueByKey[K_1] | null;
12
13
  readonly removeItem: <K_2 extends keyof StorageValueByKey>(key: K_2) => void;
14
+ readonly clear: () => void;
13
15
  readonly setFnItem: <K_3 extends keyof import("./functional-storage").AdaFunctionalStorageValue>(key: K_3, value: import("./functional-storage").AdaFunctionalStorageValue[K_3]) => void;
14
16
  readonly getFnItem: <K_4 extends keyof import("./functional-storage").AdaFunctionalStorageValue>(key: K_4) => import("./functional-storage").AdaFunctionalStorageValue[K_4] | null;
15
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/web-storage",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "description": "A package to provide access to Web Storage API",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
@@ -5,7 +5,6 @@ const WEB_STORAGE_ACCESS_ERROR_MESSAGE = "Cannot access Web Storage API";
5
5
 
6
6
  export const createStorage = (storageProvider: Storage) => {
7
7
  const storage = {
8
-
9
8
  setItem: <K extends StorageKey>(key: K, value: StorageValueByKey[K]): void => {
10
9
  try {
11
10
  storageProvider.setItem(key, JSON.stringify(value));
@@ -34,6 +33,14 @@ export const createStorage = (storageProvider: Storage) => {
34
33
  }
35
34
  },
36
35
 
36
+ clear: () => {
37
+ try {
38
+ storageProvider.clear();
39
+ } catch (e) {
40
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
41
+ }
42
+ },
43
+
37
44
  /** Stores a key/value pair within `ada-functional-storage` Storage key */
38
45
  setFnItem: <K extends keyof AdaFunctionalStorageValue>(key: K, value: AdaFunctionalStorageValue[K]): void => {
39
46
  const currentValue = storage.getItem("ada-functional-storage") || {};
@@ -1,11 +1,11 @@
1
1
  export interface AdaFunctionalStorageValue {
2
2
  rolloutGroup: {
3
- [clientHandle: string]: "A" | "B";
3
+ [clientHandle: string]: "A" | "B" | undefined;
4
4
  };
5
5
  rolloutLastValue: {
6
- [clientHandle: string]: number;
6
+ [clientHandle: string]: number | undefined;
7
7
  };
8
8
  marketing_campaigns_shown: {
9
- [clientHandle: string]: string;
9
+ [clientHandle: string]: string | undefined;
10
10
  };
11
11
  }