@emilgroup/insurance-sdk 1.3.0 → 1.4.0-beta.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.
- package/base.ts +47 -32
- package/dist/base.d.ts +2 -1
- package/dist/base.js +36 -20
- package/dist/storage.d.ts +15 -0
- package/dist/storage.js +32 -0
- package/package.json +2 -3
- package/storage.ts +41 -0
package/base.ts
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* Do not edit the class manually.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
import { Configuration } from "./configuration";
|
|
16
|
+
import { defaultStorage } from './storage';
|
|
17
17
|
// Some imports not used depending on template conditions
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
@@ -34,7 +34,6 @@ export const COLLECTION_FORMATS = {
|
|
|
34
34
|
export interface LoginClass {
|
|
35
35
|
accessToken: string;
|
|
36
36
|
permissions: Array<string>;
|
|
37
|
-
newPasswordRequired: boolean;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
export enum Environment {
|
|
@@ -42,6 +41,13 @@ export enum Environment {
|
|
|
42
41
|
Test = 'https://apiv2-test.emil.de',
|
|
43
42
|
}
|
|
44
43
|
|
|
44
|
+
let _retry_count = 0
|
|
45
|
+
let _retry = null
|
|
46
|
+
|
|
47
|
+
export function resetRetry() {
|
|
48
|
+
_retry_count = 0
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
/**
|
|
46
52
|
*
|
|
47
53
|
* @export
|
|
@@ -52,6 +58,11 @@ export interface RequestArgs {
|
|
|
52
58
|
options: AxiosRequestConfig;
|
|
53
59
|
}
|
|
54
60
|
|
|
61
|
+
interface TokenData {
|
|
62
|
+
accessToken?: string;
|
|
63
|
+
username?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
56
67
|
|
|
57
68
|
/**
|
|
@@ -62,20 +73,25 @@ const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
|
62
73
|
export class BaseAPI {
|
|
63
74
|
protected configuration: Configuration;
|
|
64
75
|
private lastRequestConfig?: AxiosRequestConfig;
|
|
76
|
+
private tokenData?: TokenData;
|
|
65
77
|
|
|
66
78
|
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
79
|
+
this.tokenData = defaultStorage.get<TokenData>('TOKEN') || {};
|
|
80
|
+
|
|
67
81
|
if (configuration) {
|
|
68
82
|
this.configuration = configuration;
|
|
69
83
|
this.basePath = configuration.basePath || this.basePath;
|
|
70
84
|
} else {
|
|
71
85
|
this.configuration = new Configuration({
|
|
72
86
|
basePath: this.basePath,
|
|
87
|
+
accessToken: this.tokenData?.accessToken ? `Bearer ${this.tokenData.accessToken}` : null,
|
|
88
|
+
username: this.tokenData?.username ? this.tokenData.username : null,
|
|
73
89
|
});
|
|
74
90
|
}
|
|
75
91
|
|
|
76
92
|
this.attachInterceptor(axios);
|
|
77
93
|
}
|
|
78
|
-
|
|
94
|
+
|
|
79
95
|
selectEnvironment(env: Environment) {
|
|
80
96
|
this.configuration.basePath = env;
|
|
81
97
|
}
|
|
@@ -98,6 +114,12 @@ export class BaseAPI {
|
|
|
98
114
|
this.configuration.username = username;
|
|
99
115
|
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
100
116
|
|
|
117
|
+
this.tokenData = {
|
|
118
|
+
username,
|
|
119
|
+
accessToken,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
defaultStorage.set<TokenData>('TOKEN', this.tokenData);
|
|
101
123
|
}
|
|
102
124
|
|
|
103
125
|
async refreshToken(): Promise<string> {
|
|
@@ -119,6 +141,12 @@ export class BaseAPI {
|
|
|
119
141
|
|
|
120
142
|
const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
|
|
121
143
|
|
|
144
|
+
this.tokenData = {
|
|
145
|
+
accessToken,
|
|
146
|
+
username
|
|
147
|
+
};
|
|
148
|
+
defaultStorage.set<TokenData>('TOKEN', this.tokenData);
|
|
149
|
+
|
|
122
150
|
return accessToken;
|
|
123
151
|
}
|
|
124
152
|
|
|
@@ -140,25 +168,19 @@ export class BaseAPI {
|
|
|
140
168
|
},
|
|
141
169
|
async (err) => {
|
|
142
170
|
let originalConfig = err.config;
|
|
143
|
-
if (err.response) {
|
|
171
|
+
if (err.response && !(err.response instanceof XMLHttpRequest)) {
|
|
144
172
|
// Access Token was expired
|
|
145
|
-
if (err.response.status === 401 && !originalConfig._retry) {
|
|
173
|
+
if ((err.response.status === 401 || err.response.status === 403) && !originalConfig._retry) {
|
|
146
174
|
originalConfig._retry = true;
|
|
147
175
|
try {
|
|
148
176
|
const tokenString = await this.refreshToken();
|
|
149
177
|
const accessToken = `Bearer ${tokenString}`;
|
|
150
178
|
|
|
151
|
-
|
|
152
|
-
localVarHeaderParameter['Authorization'] = accessToken;
|
|
153
|
-
|
|
154
|
-
originalConfig.headers = {
|
|
155
|
-
...originalConfig.headers,
|
|
156
|
-
...localVarHeaderParameter,
|
|
157
|
-
};
|
|
179
|
+
originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
|
|
158
180
|
|
|
159
181
|
this.configuration.accessToken = accessToken;
|
|
160
182
|
|
|
161
|
-
return axios(originalConfig);
|
|
183
|
+
return axios.request(originalConfig);
|
|
162
184
|
} catch (_error) {
|
|
163
185
|
if (_error.response && _error.response.data) {
|
|
164
186
|
return Promise.reject(_error.response.data);
|
|
@@ -166,37 +188,30 @@ export class BaseAPI {
|
|
|
166
188
|
return Promise.reject(_error);
|
|
167
189
|
}
|
|
168
190
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
191
|
+
} else if (err.message === NETWORK_ERROR_MESSAGE
|
|
192
|
+
&& err.isAxiosError
|
|
193
|
+
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
194
|
+
&& _retry_count < 4
|
|
195
|
+
) {
|
|
196
|
+
_retry_count++;
|
|
173
197
|
try {
|
|
174
198
|
const tokenString = await this.refreshToken();
|
|
175
199
|
const accessToken = `Bearer ${tokenString}`;
|
|
176
200
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
this.lastRequestConfig.headers = {
|
|
181
|
-
...originalConfig.headers,
|
|
182
|
-
...localVarHeaderParameter,
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
originalConfig = {
|
|
186
|
-
...this.lastRequestConfig,
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
originalConfig._retry = true;
|
|
201
|
+
_retry = true;
|
|
202
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
190
203
|
|
|
191
204
|
this.configuration.accessToken = accessToken;
|
|
192
205
|
|
|
193
|
-
return axios(
|
|
206
|
+
return axios.request({
|
|
207
|
+
...originalConfig,
|
|
208
|
+
});
|
|
194
209
|
} catch (_error) {
|
|
195
210
|
if (_error.response && _error.response.data) {
|
|
196
211
|
return Promise.reject(_error.response.data);
|
|
197
212
|
}
|
|
198
213
|
return Promise.reject(_error);
|
|
199
|
-
}
|
|
214
|
+
}
|
|
200
215
|
}
|
|
201
216
|
return Promise.reject(err);
|
|
202
217
|
}
|
package/dist/base.d.ts
CHANGED
|
@@ -25,12 +25,12 @@ export declare const COLLECTION_FORMATS: {
|
|
|
25
25
|
export interface LoginClass {
|
|
26
26
|
accessToken: string;
|
|
27
27
|
permissions: Array<string>;
|
|
28
|
-
newPasswordRequired: boolean;
|
|
29
28
|
}
|
|
30
29
|
export declare enum Environment {
|
|
31
30
|
Production = "https://apiv2.emil.de",
|
|
32
31
|
Test = "https://apiv2-test.emil.de"
|
|
33
32
|
}
|
|
33
|
+
export declare function resetRetry(): void;
|
|
34
34
|
/**
|
|
35
35
|
*
|
|
36
36
|
* @export
|
|
@@ -50,6 +50,7 @@ export declare class BaseAPI {
|
|
|
50
50
|
protected axios: AxiosInstance;
|
|
51
51
|
protected configuration: Configuration;
|
|
52
52
|
private lastRequestConfig?;
|
|
53
|
+
private tokenData?;
|
|
53
54
|
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
54
55
|
selectEnvironment(env: Environment): void;
|
|
55
56
|
authorize(username: string, password: string): Promise<void>;
|
package/dist/base.js
CHANGED
|
@@ -78,8 +78,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
78
78
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
79
79
|
};
|
|
80
80
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
-
exports.RequiredError = exports.BaseAPI = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
81
|
+
exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
82
82
|
var configuration_1 = require("./configuration");
|
|
83
|
+
var storage_1 = require("./storage");
|
|
83
84
|
// Some imports not used depending on template conditions
|
|
84
85
|
// @ts-ignore
|
|
85
86
|
var axios_1 = __importDefault(require("axios"));
|
|
@@ -99,6 +100,12 @@ var Environment;
|
|
|
99
100
|
Environment["Production"] = "https://apiv2.emil.de";
|
|
100
101
|
Environment["Test"] = "https://apiv2-test.emil.de";
|
|
101
102
|
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
103
|
+
var _retry_count = 0;
|
|
104
|
+
var _retry = null;
|
|
105
|
+
function resetRetry() {
|
|
106
|
+
_retry_count = 0;
|
|
107
|
+
}
|
|
108
|
+
exports.resetRetry = resetRetry;
|
|
102
109
|
var NETWORK_ERROR_MESSAGE = "Network Error";
|
|
103
110
|
/**
|
|
104
111
|
*
|
|
@@ -109,8 +116,10 @@ var BaseAPI = /** @class */ (function () {
|
|
|
109
116
|
function BaseAPI(configuration, basePath, axios) {
|
|
110
117
|
if (basePath === void 0) { basePath = exports.BASE_PATH; }
|
|
111
118
|
if (axios === void 0) { axios = axios_1.default; }
|
|
119
|
+
var _a, _b;
|
|
112
120
|
this.basePath = basePath;
|
|
113
121
|
this.axios = axios;
|
|
122
|
+
this.tokenData = storage_1.defaultStorage.get('TOKEN') || {};
|
|
114
123
|
if (configuration) {
|
|
115
124
|
this.configuration = configuration;
|
|
116
125
|
this.basePath = configuration.basePath || this.basePath;
|
|
@@ -118,6 +127,8 @@ var BaseAPI = /** @class */ (function () {
|
|
|
118
127
|
else {
|
|
119
128
|
this.configuration = new configuration_1.Configuration({
|
|
120
129
|
basePath: this.basePath,
|
|
130
|
+
accessToken: ((_a = this.tokenData) === null || _a === void 0 ? void 0 : _a.accessToken) ? "Bearer ".concat(this.tokenData.accessToken) : null,
|
|
131
|
+
username: ((_b = this.tokenData) === null || _b === void 0 ? void 0 : _b.username) ? this.tokenData.username : null,
|
|
121
132
|
});
|
|
122
133
|
}
|
|
123
134
|
this.attachInterceptor(axios);
|
|
@@ -147,6 +158,11 @@ var BaseAPI = /** @class */ (function () {
|
|
|
147
158
|
accessToken = response.data.accessToken;
|
|
148
159
|
this.configuration.username = username;
|
|
149
160
|
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
161
|
+
this.tokenData = {
|
|
162
|
+
username: username,
|
|
163
|
+
accessToken: accessToken,
|
|
164
|
+
};
|
|
165
|
+
storage_1.defaultStorage.set('TOKEN', this.tokenData);
|
|
150
166
|
return [2 /*return*/];
|
|
151
167
|
}
|
|
152
168
|
});
|
|
@@ -174,6 +190,11 @@ var BaseAPI = /** @class */ (function () {
|
|
|
174
190
|
return [4 /*yield*/, axios_1.default.request(options)];
|
|
175
191
|
case 1:
|
|
176
192
|
accessToken = (_a.sent()).data.accessToken;
|
|
193
|
+
this.tokenData = {
|
|
194
|
+
accessToken: accessToken,
|
|
195
|
+
username: username
|
|
196
|
+
};
|
|
197
|
+
storage_1.defaultStorage.set('TOKEN', this.tokenData);
|
|
177
198
|
return [2 /*return*/, accessToken];
|
|
178
199
|
}
|
|
179
200
|
});
|
|
@@ -194,13 +215,13 @@ var BaseAPI = /** @class */ (function () {
|
|
|
194
215
|
axios.interceptors.response.use(function (res) {
|
|
195
216
|
return res;
|
|
196
217
|
}, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
197
|
-
var originalConfig, tokenString, accessToken,
|
|
218
|
+
var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
|
|
198
219
|
return __generator(this, function (_a) {
|
|
199
220
|
switch (_a.label) {
|
|
200
221
|
case 0:
|
|
201
222
|
originalConfig = err.config;
|
|
202
|
-
if (!err.response) return [3 /*break*/, 5];
|
|
203
|
-
if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
|
|
223
|
+
if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
|
|
224
|
+
if (!((err.response.status === 401 || err.response.status === 403) && !originalConfig._retry)) return [3 /*break*/, 4];
|
|
204
225
|
originalConfig._retry = true;
|
|
205
226
|
_a.label = 1;
|
|
206
227
|
case 1:
|
|
@@ -209,24 +230,22 @@ var BaseAPI = /** @class */ (function () {
|
|
|
209
230
|
case 2:
|
|
210
231
|
tokenString = _a.sent();
|
|
211
232
|
accessToken = "Bearer ".concat(tokenString);
|
|
212
|
-
|
|
213
|
-
localVarHeaderParameter['Authorization'] = accessToken;
|
|
214
|
-
originalConfig.headers = __assign(__assign({}, originalConfig.headers), localVarHeaderParameter);
|
|
233
|
+
originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
|
|
215
234
|
this.configuration.accessToken = accessToken;
|
|
216
|
-
return [2 /*return*/, axios(originalConfig)];
|
|
235
|
+
return [2 /*return*/, axios.request(originalConfig)];
|
|
217
236
|
case 3:
|
|
218
237
|
_error_1 = _a.sent();
|
|
219
238
|
if (_error_1.response && _error_1.response.data) {
|
|
220
239
|
return [2 /*return*/, Promise.reject(_error_1.response.data)];
|
|
221
240
|
}
|
|
222
241
|
return [2 /*return*/, Promise.reject(_error_1)];
|
|
223
|
-
case 4:
|
|
224
|
-
if (err.response.status === 403 && err.response.data) {
|
|
225
|
-
return [2 /*return*/, Promise.reject(err.response.data)];
|
|
226
|
-
}
|
|
227
|
-
return [3 /*break*/, 9];
|
|
242
|
+
case 4: return [3 /*break*/, 9];
|
|
228
243
|
case 5:
|
|
229
|
-
if (!(err.message === NETWORK_ERROR_MESSAGE
|
|
244
|
+
if (!(err.message === NETWORK_ERROR_MESSAGE
|
|
245
|
+
&& err.isAxiosError
|
|
246
|
+
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
247
|
+
&& _retry_count < 4)) return [3 /*break*/, 9];
|
|
248
|
+
_retry_count++;
|
|
230
249
|
_a.label = 6;
|
|
231
250
|
case 6:
|
|
232
251
|
_a.trys.push([6, 8, , 9]);
|
|
@@ -234,13 +253,10 @@ var BaseAPI = /** @class */ (function () {
|
|
|
234
253
|
case 7:
|
|
235
254
|
tokenString = _a.sent();
|
|
236
255
|
accessToken = "Bearer ".concat(tokenString);
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this.lastRequestConfig.headers = __assign(__assign({}, originalConfig.headers), localVarHeaderParameter);
|
|
240
|
-
originalConfig = __assign({}, this.lastRequestConfig);
|
|
241
|
-
originalConfig._retry = true;
|
|
256
|
+
_retry = true;
|
|
257
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
242
258
|
this.configuration.accessToken = accessToken;
|
|
243
|
-
return [2 /*return*/, axios(originalConfig)];
|
|
259
|
+
return [2 /*return*/, axios.request(__assign({}, originalConfig))];
|
|
244
260
|
case 8:
|
|
245
261
|
_error_2 = _a.sent();
|
|
246
262
|
if (_error_2.response && _error_2.response.data) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IStorageConverter<D, SD> {
|
|
2
|
+
toStorageData(data: D): SD;
|
|
3
|
+
fromStorageData(storageData: SD): D;
|
|
4
|
+
}
|
|
5
|
+
export interface IStorage {
|
|
6
|
+
get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
|
|
7
|
+
set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class LocalStorage implements IStorage {
|
|
10
|
+
readonly storage: Storage;
|
|
11
|
+
constructor();
|
|
12
|
+
get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
|
|
13
|
+
set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const defaultStorage: IStorage;
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultStorage = exports.LocalStorage = void 0;
|
|
4
|
+
var LocalStorage = /** @class */ (function () {
|
|
5
|
+
function LocalStorage() {
|
|
6
|
+
this.storage = localStorage;
|
|
7
|
+
}
|
|
8
|
+
LocalStorage.prototype.get = function (key, converter) {
|
|
9
|
+
var jsonValue = this.storage.getItem(key);
|
|
10
|
+
if (jsonValue === null) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
var value = JSON.parse(jsonValue);
|
|
14
|
+
if (converter !== undefined) {
|
|
15
|
+
return converter.fromStorageData(value);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
LocalStorage.prototype.set = function (key, value, converter) {
|
|
22
|
+
var valueToStore = value;
|
|
23
|
+
if (converter !== undefined) {
|
|
24
|
+
valueToStore = converter.toStorageData(value);
|
|
25
|
+
}
|
|
26
|
+
var jsonValue = JSON.stringify(valueToStore);
|
|
27
|
+
this.storage.setItem(key, jsonValue);
|
|
28
|
+
};
|
|
29
|
+
return LocalStorage;
|
|
30
|
+
}());
|
|
31
|
+
exports.LocalStorage = LocalStorage;
|
|
32
|
+
exports.defaultStorage = new LocalStorage();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emilgroup/insurance-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-beta.1",
|
|
4
4
|
"description": "OpenAPI client for @emilgroup/insurance-sdk",
|
|
5
5
|
"author": "OpenAPI-Generator Contributors",
|
|
6
6
|
"keywords": [
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"prepare": "npm run build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"axios": "^0.
|
|
22
|
-
|
|
21
|
+
"axios": "^0.27.2"
|
|
23
22
|
},
|
|
24
23
|
"devDependencies": {
|
|
25
24
|
|
package/storage.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface IStorageConverter<D, SD> {
|
|
2
|
+
toStorageData( data: D ): SD;
|
|
3
|
+
fromStorageData( storageData: SD ): D;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface IStorage {
|
|
7
|
+
get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null;
|
|
8
|
+
set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class LocalStorage implements IStorage {
|
|
12
|
+
readonly storage: Storage;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this.storage = localStorage;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null {
|
|
19
|
+
const jsonValue = this.storage.getItem( key );
|
|
20
|
+
if ( jsonValue === null ) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const value = JSON.parse( jsonValue );
|
|
24
|
+
if ( converter !== undefined ) {
|
|
25
|
+
return converter.fromStorageData( value );
|
|
26
|
+
} else {
|
|
27
|
+
return value as T;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void {
|
|
32
|
+
let valueToStore: any = value;
|
|
33
|
+
if ( converter !== undefined ) {
|
|
34
|
+
valueToStore = converter.toStorageData( value );
|
|
35
|
+
}
|
|
36
|
+
const jsonValue = JSON.stringify( valueToStore );
|
|
37
|
+
this.storage.setItem( key, jsonValue );
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const defaultStorage: IStorage = new LocalStorage();
|