@emilgroup/document-sdk-node 1.0.0 → 1.1.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 +8 -0
- package/README.md +2 -2
- package/api/document-templates-api.ts +4 -2
- package/api/documents-api.ts +213 -4
- package/api/search-keywords-api.ts +164 -0
- package/api/searchable-document-owners-api.ts +18 -18
- package/api.ts +2 -5
- package/base.ts +271 -242
- package/common.ts +61 -0
- package/dist/api/document-templates-api.d.ts +4 -3
- package/dist/api/document-templates-api.js +1 -1
- package/dist/api/documents-api.d.ts +113 -4
- package/dist/api/documents-api.js +188 -5
- package/dist/api/layouts-api.js +1 -1
- package/dist/api/search-keywords-api.d.ts +92 -0
- package/dist/api/search-keywords-api.js +225 -0
- package/dist/api/searchable-document-owners-api.d.ts +15 -15
- package/dist/api/searchable-document-owners-api.js +9 -9
- package/dist/api/searchable-documents-api.js +1 -1
- package/dist/api.d.ts +1 -4
- package/dist/api.js +1 -6
- package/dist/base.d.ts +5 -4
- package/dist/base.js +42 -13
- 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-doc-template-request-dto.d.ts +9 -3
- package/dist/models/create-doc-template-response-class.d.ts +25 -0
- package/dist/models/create-doc-template-response-class.js +15 -0
- package/dist/models/create-document-request-dto.d.ts +16 -4
- package/dist/models/create-html-template-dto.d.ts +1 -1
- package/dist/models/create-presigned-post-request-dto.d.ts +33 -9
- package/dist/models/doc-template-class.d.ts +24 -18
- package/dist/models/document-class.d.ts +17 -5
- package/dist/models/get-signed-s3-key-url-response-class.d.ts +24 -0
- package/dist/models/get-signed-s3-key-url-response-class.js +15 -0
- package/dist/models/html-template-class.d.ts +8 -8
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +6 -0
- package/dist/models/layout-class.d.ts +10 -10
- package/dist/models/list-search-keywords-request-dto.d.ts +24 -0
- package/dist/models/list-search-keywords-request-dto.js +15 -0
- package/dist/models/list-search-keywords-response-class.d.ts +24 -0
- package/dist/models/list-search-keywords-response-class.js +15 -0
- package/dist/models/list-searchable-documents-response-class.d.ts +1 -1
- package/dist/models/update-doc-template-request-dto.d.ts +12 -6
- package/dist/models/update-document-request-dto.d.ts +6 -0
- package/index.ts +1 -1
- package/models/create-doc-template-request-dto.ts +9 -3
- package/models/create-doc-template-response-class.ts +31 -0
- package/models/create-document-request-dto.ts +12 -0
- package/models/create-html-template-dto.ts +1 -1
- package/models/create-presigned-post-request-dto.ts +31 -7
- package/models/doc-template-class.ts +24 -18
- package/models/document-class.ts +14 -2
- package/models/get-signed-s3-key-url-response-class.ts +30 -0
- package/models/html-template-class.ts +7 -7
- package/models/index.ts +6 -0
- package/models/layout-class.ts +10 -10
- package/models/list-search-keywords-request-dto.ts +30 -0
- package/models/list-search-keywords-response-class.ts +30 -0
- package/models/list-searchable-documents-response-class.ts +1 -1
- package/models/update-doc-template-request-dto.ts +12 -6
- package/models/update-document-request-dto.ts +6 -0
- package/package.json +2 -2
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 = "http://localhost".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 refreshToken(): 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.refreshToken();
|
|
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.refreshToken();
|
|
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
|
+
};
|
|
@@ -13,6 +13,7 @@ import { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
|
13
13
|
import { Configuration } from '../configuration';
|
|
14
14
|
import { RequestArgs, BaseAPI } from '../base';
|
|
15
15
|
import { CreateDocTemplateRequestDto } from '../models';
|
|
16
|
+
import { CreateDocTemplateResponseClass } from '../models';
|
|
16
17
|
import { GetDocTemplateResponseClass } from '../models';
|
|
17
18
|
import { ListDocTemplatesResponseClass } from '../models';
|
|
18
19
|
import { UpdateDocTemplateRequestDto } from '../models';
|
|
@@ -83,7 +84,7 @@ export declare const DocumentTemplatesApiFp: (configuration?: Configuration) =>
|
|
|
83
84
|
* @param {*} [options] Override http request option.
|
|
84
85
|
* @throws {RequiredError}
|
|
85
86
|
*/
|
|
86
|
-
createDocTemplate(createDocTemplateRequestDto: CreateDocTemplateRequestDto, authorization?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<
|
|
87
|
+
createDocTemplate(createDocTemplateRequestDto: CreateDocTemplateRequestDto, authorization?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateDocTemplateResponseClass>>;
|
|
87
88
|
/**
|
|
88
89
|
*
|
|
89
90
|
* @param {number} id
|
|
@@ -137,7 +138,7 @@ export declare const DocumentTemplatesApiFactory: (configuration?: Configuration
|
|
|
137
138
|
* @param {*} [options] Override http request option.
|
|
138
139
|
* @throws {RequiredError}
|
|
139
140
|
*/
|
|
140
|
-
createDocTemplate(createDocTemplateRequestDto: CreateDocTemplateRequestDto, authorization?: string, options?: any): AxiosPromise<
|
|
141
|
+
createDocTemplate(createDocTemplateRequestDto: CreateDocTemplateRequestDto, authorization?: string, options?: any): AxiosPromise<CreateDocTemplateResponseClass>;
|
|
141
142
|
/**
|
|
142
143
|
*
|
|
143
144
|
* @param {number} id
|
|
@@ -336,7 +337,7 @@ export declare class DocumentTemplatesApi extends BaseAPI {
|
|
|
336
337
|
* @throws {RequiredError}
|
|
337
338
|
* @memberof DocumentTemplatesApi
|
|
338
339
|
*/
|
|
339
|
-
createDocTemplate(requestParameters: DocumentTemplatesApiCreateDocTemplateRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<
|
|
340
|
+
createDocTemplate(requestParameters: DocumentTemplatesApiCreateDocTemplateRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateDocTemplateResponseClass, any>>;
|
|
340
341
|
/**
|
|
341
342
|
*
|
|
342
343
|
* @param {DocumentTemplatesApiDeleteDocTemplateRequest} requestParameters Request parameters.
|
|
@@ -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]) {
|