@emilgroup/document-sdk-node 1.0.0 → 1.2.0
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/.openapi-generator/FILES +1 -0
- package/README.md +2 -2
- package/api.ts +0 -5
- package/base.ts +271 -242
- package/common.ts +61 -0
- package/dist/api/document-templates-api.js +1 -1
- package/dist/api/documents-api.js +1 -1
- package/dist/api/layouts-api.js +1 -1
- package/dist/api/searchable-document-owners-api.js +1 -1
- package/dist/api/searchable-documents-api.js +1 -1
- package/dist/api.d.ts +0 -4
- package/dist/api.js +0 -6
- package/dist/base.d.ts +6 -5
- package/dist/base.js +45 -16
- package/dist/common.d.ts +26 -0
- package/dist/common.js +35 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/models/create-document-request-dto.d.ts +4 -4
- package/dist/models/document-class.d.ts +3 -3
- package/dist/models/html-template-class.d.ts +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/dist/models/create-presigned-post-request-dto.d.ts +0 -103
- package/dist/models/create-presigned-post-request-dto.js +0 -51
- package/dist/models/create-presigned-post-response-class.d.ts +0 -30
- package/dist/models/create-presigned-post-response-class.js +0 -15
- package/models/create-presigned-post-request-dto.ts +0 -113
- package/models/create-presigned-post-response-class.ts +0 -36
package/.openapi-generator/FILES
CHANGED
package/README.md
CHANGED
|
@@ -17,11 +17,11 @@ Although this package can be used in both TypeScript and JavaScript, it is inten
|
|
|
17
17
|
Navigate to the folder of your consuming project and run one of the following commands:
|
|
18
18
|
|
|
19
19
|
```
|
|
20
|
-
npm install @emilgroup/document-sdk-node@1.
|
|
20
|
+
npm install @emilgroup/document-sdk-node@1.2.0 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/document-sdk-node@1.
|
|
24
|
+
yarn add @emilgroup/document-sdk-node@1.2.0
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `DocumentsApi`.
|
package/api.ts
CHANGED
|
@@ -37,8 +37,3 @@ export * from './api/layouts-api';
|
|
|
37
37
|
export * from './api/searchable-document-owners-api';
|
|
38
38
|
export * from './api/searchable-documents-api';
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
export enum Environment {
|
|
42
|
-
Production = 'https://apiv2.emil.de',
|
|
43
|
-
Test = 'https://apiv2-test.emil.de',
|
|
44
|
-
}
|
package/base.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* EMIL
|
|
5
|
-
* The EMIL
|
|
4
|
+
* EMIL DocumentService
|
|
5
|
+
* The EMIL DocumentService API description
|
|
6
6
|
*
|
|
7
7
|
* The version of the OpenAPI document: 1.0
|
|
8
8
|
*
|
|
@@ -13,243 +13,272 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
16
|
+
import { Configuration } from "./configuration";
|
|
17
|
+
// Some imports not used depending on template conditions
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
20
|
+
import * as fs from 'fs';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import * as os from 'os';
|
|
23
|
+
|
|
24
|
+
export const BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
|
|
25
|
+
const CONFIG_DIRECTORY = '.emil';
|
|
26
|
+
const CONFIG_FILENAME = 'credentials';
|
|
27
|
+
const KEY_USERNAME = 'emil_username';
|
|
28
|
+
const KEY_PASSWORD = 'emil_password';
|
|
29
|
+
|
|
30
|
+
const filePath = os.homedir() + path.sep + CONFIG_DIRECTORY + path.sep + CONFIG_FILENAME;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export const COLLECTION_FORMATS = {
|
|
36
|
+
csv: ",",
|
|
37
|
+
ssv: " ",
|
|
38
|
+
tsv: "\t",
|
|
39
|
+
pipes: "|",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export interface LoginClass {
|
|
43
|
+
accessToken: string;
|
|
44
|
+
permissions: Array<string>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export enum Environment {
|
|
48
|
+
Production = 'https://apiv2.emil.de',
|
|
49
|
+
Test = 'https://apiv2-test.emil.de',
|
|
50
|
+
Development = 'https://apiv2-dev.emil.de',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let _retry_count = 0
|
|
54
|
+
let _retry = null
|
|
55
|
+
|
|
56
|
+
export function resetRetry() {
|
|
57
|
+
_retry_count = 0
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @export
|
|
63
|
+
* @interface RequestArgs
|
|
64
|
+
*/
|
|
65
|
+
export interface RequestArgs {
|
|
66
|
+
url: string;
|
|
67
|
+
options: AxiosRequestConfig;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @export
|
|
75
|
+
* @class BaseAPI
|
|
76
|
+
*/
|
|
77
|
+
export class BaseAPI {
|
|
78
|
+
protected configuration: Configuration;
|
|
79
|
+
private username?: string;
|
|
80
|
+
private password?: string;
|
|
81
|
+
|
|
82
|
+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
83
|
+
if (configuration) {
|
|
84
|
+
this.configuration = configuration;
|
|
85
|
+
this.basePath = configuration.basePath || this.basePath;
|
|
86
|
+
} else {
|
|
87
|
+
this.configuration = new Configuration({
|
|
88
|
+
basePath: this.basePath,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.attachInterceptor(axios);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async initialize(env: Environment = Environment.Production) {
|
|
96
|
+
this.configuration.basePath = env;
|
|
97
|
+
|
|
98
|
+
await this.loadCredentials();
|
|
99
|
+
|
|
100
|
+
if (this.username) {
|
|
101
|
+
await this.authorize(this.username, this.password);
|
|
102
|
+
this.password = null; // to avoid keeping password loaded in memory.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private async loadCredentials() {
|
|
107
|
+
try {
|
|
108
|
+
await this.readConfigFile();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.warn(`No credentials file found. Check that ${filePath} exists.`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.readEnvVariables();
|
|
114
|
+
|
|
115
|
+
if (!this.username) {
|
|
116
|
+
console.info(`No credentials found in credentials file or environment variables. Either provide some or use
|
|
117
|
+
authorize() function.`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private async readConfigFile() {
|
|
122
|
+
const file = await fs.promises.readFile(filePath, 'utf-8');
|
|
123
|
+
|
|
124
|
+
const lines = file.split(os.EOL)
|
|
125
|
+
.filter(Boolean);
|
|
126
|
+
|
|
127
|
+
lines.forEach((line: string) => {
|
|
128
|
+
if (line.startsWith(KEY_USERNAME)) {
|
|
129
|
+
this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
|
|
130
|
+
} else if (line.startsWith(KEY_PASSWORD)) {
|
|
131
|
+
this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private readEnvVariables(): boolean {
|
|
137
|
+
if (process.env.EMIL_USERNAME) {
|
|
138
|
+
this.username = process.env.EMIL_USERNAME;
|
|
139
|
+
this.password = process.env.EMIL_PASSWORD || '';
|
|
140
|
+
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
selectEnvironment(env: Environment) {
|
|
148
|
+
this.configuration.basePath = env;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async authorize(username: string, password: string): Promise<void> {
|
|
152
|
+
const options: AxiosRequestConfig = {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
url: `${this.configuration.basePath}/authservice/v1/login`,
|
|
155
|
+
headers: { 'Content-Type': 'application/json' },
|
|
156
|
+
data: {
|
|
157
|
+
username,
|
|
158
|
+
password,
|
|
159
|
+
},
|
|
160
|
+
withCredentials: true,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const response = await globalAxios.request<LoginClass>(options);
|
|
164
|
+
|
|
165
|
+
const { data: { accessToken } } = response;
|
|
166
|
+
this.configuration.username = username;
|
|
167
|
+
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
168
|
+
|
|
169
|
+
const refreshToken = this.extractRefreshToken(response)
|
|
170
|
+
this.configuration.refreshToken = refreshToken;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async refreshTokenInternal(): Promise<string> {
|
|
174
|
+
const { username, refreshToken } = this.configuration;
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if (!username || !refreshToken) {
|
|
178
|
+
return '';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const options: AxiosRequestConfig = {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
|
|
184
|
+
headers: {
|
|
185
|
+
'Content-Type': 'application/json',
|
|
186
|
+
Cookie: refreshToken,
|
|
187
|
+
},
|
|
188
|
+
data: { username: username },
|
|
189
|
+
withCredentials: true,
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
|
|
193
|
+
|
|
194
|
+
return accessToken;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private extractRefreshToken(response: AxiosResponse): string {
|
|
198
|
+
if (response.headers && response.headers['set-cookie']
|
|
199
|
+
&& response.headers['set-cookie'].length > 0) {
|
|
200
|
+
|
|
201
|
+
return `${response.headers['set-cookie'][0].split(';')[0]};`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
getConfiguration(): Configuration {
|
|
208
|
+
return this.configuration;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private attachInterceptor(axios: AxiosInstance) {
|
|
212
|
+
axios.interceptors.response.use(
|
|
213
|
+
(res) => {
|
|
214
|
+
return res;
|
|
215
|
+
},
|
|
216
|
+
async (err) => {
|
|
217
|
+
let originalConfig = err.config;
|
|
218
|
+
if (err.response) {
|
|
219
|
+
// Access Token was expired
|
|
220
|
+
if (err.response.status === 401 && !originalConfig._retry) {
|
|
221
|
+
originalConfig._retry = true;
|
|
222
|
+
try {
|
|
223
|
+
const tokenString = await this.refreshTokenInternal();
|
|
224
|
+
const accessToken = `Bearer ${tokenString}`;
|
|
225
|
+
|
|
226
|
+
originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
|
|
227
|
+
|
|
228
|
+
this.configuration.accessToken = accessToken;
|
|
229
|
+
|
|
230
|
+
return axios.request(originalConfig);
|
|
231
|
+
} catch (_error) {
|
|
232
|
+
if (_error.response && _error.response.data) {
|
|
233
|
+
return Promise.reject(_error.response.data);
|
|
234
|
+
}
|
|
235
|
+
return Promise.reject(_error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (err.response.status === 403 && err.response.data) {
|
|
239
|
+
return Promise.reject(err.response.data);
|
|
240
|
+
}
|
|
241
|
+
} else if(err.message === NETWORK_ERROR_MESSAGE
|
|
242
|
+
&& err.isAxiosError
|
|
243
|
+
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
244
|
+
&& _retry_count < 4
|
|
245
|
+
){
|
|
246
|
+
_retry_count++;
|
|
247
|
+
try {
|
|
248
|
+
const tokenString = await this.refreshTokenInternal();
|
|
249
|
+
const accessToken = `Bearer ${tokenString}`;
|
|
250
|
+
|
|
251
|
+
_retry = true;
|
|
252
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
253
|
+
|
|
254
|
+
this.configuration.accessToken = accessToken;
|
|
255
|
+
|
|
256
|
+
return axios.request({
|
|
257
|
+
...originalConfig,
|
|
258
|
+
});
|
|
259
|
+
} catch (_error) {
|
|
260
|
+
if (_error.response && _error.response.data) {
|
|
261
|
+
return Promise.reject(_error.response.data);
|
|
262
|
+
}
|
|
263
|
+
return Promise.reject(_error);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return Promise.reject(err);
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
*
|
|
274
|
+
* @export
|
|
275
|
+
* @class RequiredError
|
|
276
|
+
* @extends {Error}
|
|
277
|
+
*/
|
|
278
|
+
export class RequiredError extends Error {
|
|
279
|
+
name: "RequiredError" = "RequiredError";
|
|
280
|
+
constructor(public field: string, msg?: string) {
|
|
281
|
+
super(msg);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
package/common.ts
CHANGED
|
@@ -136,3 +136,64 @@ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxi
|
|
|
136
136
|
return axios.request<T, R>(axiosRequestArgs);
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
+
|
|
140
|
+
/* tslint:disable */
|
|
141
|
+
/* eslint-disable */
|
|
142
|
+
/**
|
|
143
|
+
* EMIL DocumentService
|
|
144
|
+
* The EMIL DocumentService API description
|
|
145
|
+
*
|
|
146
|
+
* The version of the OpenAPI document: 1.0
|
|
147
|
+
*
|
|
148
|
+
*
|
|
149
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
150
|
+
* https://openapi-generator.tech
|
|
151
|
+
* Do not edit the class manually.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
export interface IStorageConverter<D, SD> {
|
|
156
|
+
toStorageData( data: D ): SD;
|
|
157
|
+
fromStorageData( storageData: SD ): D;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface IStorage {
|
|
161
|
+
get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null;
|
|
162
|
+
set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export class LocalStorage implements IStorage {
|
|
166
|
+
readonly storage: Storage;
|
|
167
|
+
|
|
168
|
+
constructor() {
|
|
169
|
+
this.storage = localStorage;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null {
|
|
173
|
+
const jsonValue = this.storage.getItem( key );
|
|
174
|
+
if ( jsonValue === null ) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const value = JSON.parse( jsonValue );
|
|
178
|
+
if ( converter !== undefined ) {
|
|
179
|
+
return converter.fromStorageData( value );
|
|
180
|
+
} else {
|
|
181
|
+
return value as T;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void {
|
|
186
|
+
let valueToStore: any = value;
|
|
187
|
+
if ( converter !== undefined ) {
|
|
188
|
+
valueToStore = converter.toStorageData( value );
|
|
189
|
+
}
|
|
190
|
+
const jsonValue = JSON.stringify( valueToStore );
|
|
191
|
+
this.storage.setItem( key, jsonValue );
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let _defaultStorage: IStorage = null;
|
|
196
|
+
|
|
197
|
+
export const defaultStorage = (): IStorage => {
|
|
198
|
+
return _defaultStorage || (_defaultStorage = new LocalStorage());
|
|
199
|
+
};
|
|
@@ -53,7 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
53
53
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
54
54
|
function step(op) {
|
|
55
55
|
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
-
while (_) try {
|
|
56
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
57
57
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
58
58
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
59
|
switch (op[0]) {
|
|
@@ -53,7 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
53
53
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
54
54
|
function step(op) {
|
|
55
55
|
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
-
while (_) try {
|
|
56
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
57
57
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
58
58
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
59
|
switch (op[0]) {
|
package/dist/api/layouts-api.js
CHANGED
|
@@ -53,7 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
53
53
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
54
54
|
function step(op) {
|
|
55
55
|
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
-
while (_) try {
|
|
56
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
57
57
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
58
58
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
59
|
switch (op[0]) {
|