@emilgroup/task-sdk 1.0.1-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/.openapi-generator/FILES +51 -0
- package/.openapi-generator/VERSION +1 -0
- package/.openapi-generator-ignore +23 -0
- package/README.md +51 -0
- package/api/categories-api.ts +651 -0
- package/api/default-api.ts +124 -0
- package/api/hub-spot-api.ts +165 -0
- package/api/priorities-api.ts +284 -0
- package/api/statuses-api.ts +651 -0
- package/api/tasks-api.ts +651 -0
- package/api.ts +37 -0
- package/base.ts +331 -0
- package/common.ts +198 -0
- package/configuration.ts +110 -0
- package/dist/api/categories-api.d.ts +366 -0
- package/dist/api/categories-api.js +626 -0
- package/dist/api/default-api.d.ts +70 -0
- package/dist/api/default-api.js +200 -0
- package/dist/api/hub-spot-api.d.ts +97 -0
- package/dist/api/hub-spot-api.js +224 -0
- package/dist/api/priorities-api.d.ts +162 -0
- package/dist/api/priorities-api.js +324 -0
- package/dist/api/statuses-api.d.ts +366 -0
- package/dist/api/statuses-api.js +626 -0
- package/dist/api/tasks-api.d.ts +366 -0
- package/dist/api/tasks-api.js +626 -0
- package/dist/api.d.ts +17 -0
- package/dist/api.js +35 -0
- package/dist/base.d.ts +86 -0
- package/dist/base.js +367 -0
- package/dist/common.d.ts +91 -0
- package/dist/common.js +276 -0
- package/dist/configuration.d.ts +89 -0
- package/dist/configuration.js +52 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +36 -0
- package/dist/models/category-class.d.ts +60 -0
- package/dist/models/category-class.js +15 -0
- package/dist/models/create-category-request-dto.d.ts +24 -0
- package/dist/models/create-category-request-dto.js +15 -0
- package/dist/models/create-category-response-class.d.ts +25 -0
- package/dist/models/create-category-response-class.js +15 -0
- package/dist/models/create-hub-spot-ticket-request-dto.d.ts +31 -0
- package/dist/models/create-hub-spot-ticket-request-dto.js +15 -0
- package/dist/models/create-hub-spot-ticket-response-class.d.ts +25 -0
- package/dist/models/create-hub-spot-ticket-response-class.js +15 -0
- package/dist/models/create-priority-request-dto.d.ts +24 -0
- package/dist/models/create-priority-request-dto.js +15 -0
- package/dist/models/create-priority-response-class.d.ts +25 -0
- package/dist/models/create-priority-response-class.js +15 -0
- package/dist/models/create-status-request-dto.d.ts +24 -0
- package/dist/models/create-status-request-dto.js +15 -0
- package/dist/models/create-status-response-class.d.ts +25 -0
- package/dist/models/create-status-response-class.js +15 -0
- package/dist/models/create-task-request-dto.d.ts +54 -0
- package/dist/models/create-task-request-dto.js +15 -0
- package/dist/models/create-task-response-class.d.ts +25 -0
- package/dist/models/create-task-response-class.js +15 -0
- package/dist/models/get-category-response-class.d.ts +25 -0
- package/dist/models/get-category-response-class.js +15 -0
- package/dist/models/get-priority-response-class.d.ts +25 -0
- package/dist/models/get-priority-response-class.js +15 -0
- package/dist/models/get-status-response-class.d.ts +25 -0
- package/dist/models/get-status-response-class.js +15 -0
- package/dist/models/get-task-response-class.d.ts +25 -0
- package/dist/models/get-task-response-class.js +15 -0
- package/dist/models/hub-spot-ticket-class.d.ts +49 -0
- package/dist/models/hub-spot-ticket-class.js +15 -0
- package/dist/models/hub-spot-ticket-error-class.d.ts +30 -0
- package/dist/models/hub-spot-ticket-error-class.js +15 -0
- package/dist/models/hub-spot-ticket-name-value-dto.d.ts +30 -0
- package/dist/models/hub-spot-ticket-name-value-dto.js +15 -0
- package/dist/models/index.d.ts +32 -0
- package/dist/models/index.js +48 -0
- package/dist/models/inline-response200.d.ts +54 -0
- package/dist/models/inline-response200.js +15 -0
- package/dist/models/inline-response503.d.ts +54 -0
- package/dist/models/inline-response503.js +15 -0
- package/dist/models/list-categories-response-class.d.ts +43 -0
- package/dist/models/list-categories-response-class.js +15 -0
- package/dist/models/list-statuses-response-class.d.ts +43 -0
- package/dist/models/list-statuses-response-class.js +15 -0
- package/dist/models/list-tasks-response-class.d.ts +43 -0
- package/dist/models/list-tasks-response-class.js +15 -0
- package/dist/models/priority-class.d.ts +60 -0
- package/dist/models/priority-class.js +15 -0
- package/dist/models/status-class.d.ts +60 -0
- package/dist/models/status-class.js +15 -0
- package/dist/models/task-class.d.ts +99 -0
- package/dist/models/task-class.js +15 -0
- package/dist/models/update-category-request-dto.d.ts +30 -0
- package/dist/models/update-category-request-dto.js +15 -0
- package/dist/models/update-category-response-class.d.ts +25 -0
- package/dist/models/update-category-response-class.js +15 -0
- package/dist/models/update-status-request-dto.d.ts +30 -0
- package/dist/models/update-status-request-dto.js +15 -0
- package/dist/models/update-status-response-class.d.ts +25 -0
- package/dist/models/update-status-response-class.js +15 -0
- package/dist/models/update-task-request-dto.d.ts +60 -0
- package/dist/models/update-task-request-dto.js +15 -0
- package/dist/models/update-task-response-class.d.ts +25 -0
- package/dist/models/update-task-response-class.js +15 -0
- package/git_push.sh +57 -0
- package/index.ts +19 -0
- package/models/category-class.ts +66 -0
- package/models/create-category-request-dto.ts +30 -0
- package/models/create-category-response-class.ts +31 -0
- package/models/create-hub-spot-ticket-request-dto.ts +37 -0
- package/models/create-hub-spot-ticket-response-class.ts +31 -0
- package/models/create-priority-request-dto.ts +30 -0
- package/models/create-priority-response-class.ts +31 -0
- package/models/create-status-request-dto.ts +30 -0
- package/models/create-status-response-class.ts +31 -0
- package/models/create-task-request-dto.ts +60 -0
- package/models/create-task-response-class.ts +31 -0
- package/models/get-category-response-class.ts +31 -0
- package/models/get-priority-response-class.ts +31 -0
- package/models/get-status-response-class.ts +31 -0
- package/models/get-task-response-class.ts +31 -0
- package/models/hub-spot-ticket-class.ts +55 -0
- package/models/hub-spot-ticket-error-class.ts +36 -0
- package/models/hub-spot-ticket-name-value-dto.ts +36 -0
- package/models/index.ts +32 -0
- package/models/inline-response200.ts +48 -0
- package/models/inline-response503.ts +48 -0
- package/models/list-categories-response-class.ts +49 -0
- package/models/list-statuses-response-class.ts +49 -0
- package/models/list-tasks-response-class.ts +49 -0
- package/models/priority-class.ts +66 -0
- package/models/status-class.ts +66 -0
- package/models/task-class.ts +105 -0
- package/models/update-category-request-dto.ts +36 -0
- package/models/update-category-response-class.ts +31 -0
- package/models/update-status-request-dto.ts +36 -0
- package/models/update-status-response-class.ts +31 -0
- package/models/update-task-request-dto.ts +66 -0
- package/models/update-task-response-class.ts +31 -0
- package/package.json +26 -0
- package/tsconfig.json +23 -0
package/api.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL TaskService
|
|
5
|
+
* The EMIL Task API description
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0
|
|
8
|
+
* Contact: kontakt@emil.de
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import { Configuration } from './configuration';
|
|
17
|
+
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
18
|
+
// Some imports not used depending on template conditions
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';
|
|
23
|
+
import { CategoriesApi } from './api';
|
|
24
|
+
import { DefaultApi } from './api';
|
|
25
|
+
import { HubSpotApi } from './api';
|
|
26
|
+
import { PrioritiesApi } from './api';
|
|
27
|
+
import { StatusesApi } from './api';
|
|
28
|
+
import { TasksApi } from './api';
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export * from './api/categories-api';
|
|
32
|
+
export * from './api/default-api';
|
|
33
|
+
export * from './api/hub-spot-api';
|
|
34
|
+
export * from './api/priorities-api';
|
|
35
|
+
export * from './api/statuses-api';
|
|
36
|
+
export * from './api/tasks-api';
|
|
37
|
+
|
package/base.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL TaskService
|
|
5
|
+
* The EMIL Task API description
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0
|
|
8
|
+
* Contact: kontakt@emil.de
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import { Configuration } from "./configuration";
|
|
17
|
+
import { defaultStorage } from "./common";
|
|
18
|
+
// Some imports not used depending on template conditions
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export const BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
*/
|
|
28
|
+
export const COLLECTION_FORMATS = {
|
|
29
|
+
csv: ",",
|
|
30
|
+
ssv: " ",
|
|
31
|
+
tsv: "\t",
|
|
32
|
+
pipes: "|",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export interface LoginClass {
|
|
36
|
+
accessToken: string;
|
|
37
|
+
permissions: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SwitchWorkspaceRequest {
|
|
41
|
+
username: string;
|
|
42
|
+
targetWorkspace: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SwitchWorkspaceResponseClass {
|
|
46
|
+
accessToken: string;
|
|
47
|
+
permissions: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export enum Environment {
|
|
51
|
+
Production = 'https://apiv2.emil.de',
|
|
52
|
+
Test = 'https://apiv2-test.emil.de',
|
|
53
|
+
Staging = 'https://apiv2-staging.emil.de',
|
|
54
|
+
Development = 'https://apiv2-dev.emil.de',
|
|
55
|
+
ProductionZurich = 'https://eu-central-2.apiv2.emil.de',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let _retry_count = 0
|
|
59
|
+
let _retry = null
|
|
60
|
+
|
|
61
|
+
export function resetRetry() {
|
|
62
|
+
_retry_count = 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @export
|
|
68
|
+
* @interface RequestArgs
|
|
69
|
+
*/
|
|
70
|
+
export interface RequestArgs {
|
|
71
|
+
url: string;
|
|
72
|
+
options: AxiosRequestConfig;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface TokenData {
|
|
76
|
+
accessToken?: string;
|
|
77
|
+
username?: string;
|
|
78
|
+
permissions?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
82
|
+
const TOKEN_DATA = 'APP_TOKEN';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @export
|
|
87
|
+
* @class BaseAPI
|
|
88
|
+
*/
|
|
89
|
+
export class BaseAPI {
|
|
90
|
+
protected configuration: Configuration | undefined;
|
|
91
|
+
private tokenData?: TokenData;
|
|
92
|
+
|
|
93
|
+
constructor(configuration?: Configuration,
|
|
94
|
+
protected basePath: string = BASE_PATH,
|
|
95
|
+
protected axios: AxiosInstance = globalAxios) {
|
|
96
|
+
|
|
97
|
+
this.loadTokenData();
|
|
98
|
+
|
|
99
|
+
if (configuration) {
|
|
100
|
+
const { accessToken } = this.tokenData;
|
|
101
|
+
this.configuration = configuration;
|
|
102
|
+
this.basePath = configuration.basePath || this.basePath;
|
|
103
|
+
|
|
104
|
+
// Use config token if provided, otherwise use tokenData token
|
|
105
|
+
const configToken = this.configuration.accessToken;
|
|
106
|
+
const storedToken = accessToken ? `Bearer ${accessToken}` : '';
|
|
107
|
+
this.configuration.accessToken = configToken || storedToken;
|
|
108
|
+
} else {
|
|
109
|
+
const { accessToken, username } = this.tokenData;
|
|
110
|
+
|
|
111
|
+
this.configuration = new Configuration({
|
|
112
|
+
basePath: this.basePath,
|
|
113
|
+
accessToken: accessToken ? `Bearer ${accessToken}` : '',
|
|
114
|
+
username,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.attachInterceptor(axios);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
selectEnvironment(env: Environment) {
|
|
122
|
+
this.selectBasePath(env);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
selectBasePath(path: string) {
|
|
126
|
+
this.configuration.basePath = path;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getPermissions(): Array<string> {
|
|
130
|
+
if (!this.tokenData?.permissions) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return this.tokenData.permissions.split(',');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
|
|
138
|
+
const options: AxiosRequestConfig = {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
url: `${this.configuration.basePath}/authservice/v1/login`,
|
|
141
|
+
headers: { 'Content-Type': 'application/json' },
|
|
142
|
+
data: {
|
|
143
|
+
username,
|
|
144
|
+
password,
|
|
145
|
+
},
|
|
146
|
+
withCredentials: true,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const response = await globalAxios.request<LoginClass>(options);
|
|
150
|
+
|
|
151
|
+
const { data: { accessToken, permissions } } = response;
|
|
152
|
+
|
|
153
|
+
this.configuration.username = username;
|
|
154
|
+
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
155
|
+
this.tokenData.username = username;
|
|
156
|
+
this.tokenData.accessToken = accessToken;
|
|
157
|
+
this.tokenData.permissions = permissions;
|
|
158
|
+
|
|
159
|
+
// Switch workspace if provided
|
|
160
|
+
if (targetWorkspace) {
|
|
161
|
+
await this.switchWorkspace(targetWorkspace);
|
|
162
|
+
} else {
|
|
163
|
+
// Only store if no workspace switch (since switchWorkspace will store after switching)
|
|
164
|
+
this.storeTokenData({
|
|
165
|
+
...this.tokenData
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.storeTokenData({
|
|
170
|
+
...this.tokenData
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async switchWorkspace(targetWorkspace: string): Promise<void> {
|
|
175
|
+
const options: AxiosRequestConfig = {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
|
|
178
|
+
headers: {
|
|
179
|
+
'Content-Type': 'application/json',
|
|
180
|
+
'Authorization': `Bearer ${this.configuration.accessToken}`,
|
|
181
|
+
},
|
|
182
|
+
data: {
|
|
183
|
+
username: this.configuration.username,
|
|
184
|
+
targetWorkspace,
|
|
185
|
+
} as SwitchWorkspaceRequest,
|
|
186
|
+
withCredentials: true,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
|
|
190
|
+
|
|
191
|
+
const { data: { accessToken, permissions } } = response;
|
|
192
|
+
|
|
193
|
+
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
194
|
+
this.tokenData.accessToken = accessToken;
|
|
195
|
+
this.tokenData.permissions = permissions;
|
|
196
|
+
|
|
197
|
+
this.storeTokenData({
|
|
198
|
+
...this.tokenData
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async refreshTokenInternal(): Promise<LoginClass> {
|
|
203
|
+
const { username } = this.configuration;
|
|
204
|
+
|
|
205
|
+
if (!username) {
|
|
206
|
+
throw new Error('Failed to refresh token.');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const refreshTokenAxios = globalAxios.create()
|
|
210
|
+
refreshTokenAxios.interceptors.response.use(response => {
|
|
211
|
+
const { permissions } = response.data;
|
|
212
|
+
|
|
213
|
+
this.tokenData.permissions = permissions;
|
|
214
|
+
this.storeTokenData(this.tokenData);
|
|
215
|
+
|
|
216
|
+
return response;
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const options: AxiosRequestConfig = {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
|
|
222
|
+
headers: {
|
|
223
|
+
'Content-Type': 'application/json',
|
|
224
|
+
},
|
|
225
|
+
data: { username: username },
|
|
226
|
+
withCredentials: true,
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const response = await refreshTokenAxios.request<LoginClass>(options);
|
|
230
|
+
return response.data;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private storeTokenData(tokenData?: TokenData) {
|
|
234
|
+
if (typeof window !== 'undefined') {
|
|
235
|
+
defaultStorage().set<TokenData>(TOKEN_DATA, tokenData);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
public loadTokenData() {
|
|
240
|
+
if (typeof window !== 'undefined') {
|
|
241
|
+
this.tokenData = defaultStorage().get<TokenData>(TOKEN_DATA) || {};
|
|
242
|
+
} else {
|
|
243
|
+
this.tokenData = {};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
public cleanTokenData() {
|
|
248
|
+
this.storeTokenData(null);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private attachInterceptor(axios: AxiosInstance) {
|
|
252
|
+
axios.interceptors.response.use(
|
|
253
|
+
(res) => {
|
|
254
|
+
return res;
|
|
255
|
+
},
|
|
256
|
+
async (err) => {
|
|
257
|
+
let originalConfig = err.config;
|
|
258
|
+
if (err.response && !(err.response instanceof XMLHttpRequest)) { // sometimes buggy and is of type request
|
|
259
|
+
// Access Token was expired
|
|
260
|
+
if ((err.response.status === 401 || err.response.status === 403)
|
|
261
|
+
&& !originalConfig._retry) {
|
|
262
|
+
originalConfig._retry = true;
|
|
263
|
+
try {
|
|
264
|
+
const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
|
|
265
|
+
const accessToken = `Bearer ${tokenString}`;
|
|
266
|
+
this.tokenData.permissions = permissions;
|
|
267
|
+
|
|
268
|
+
delete originalConfig.headers['Authorization']
|
|
269
|
+
|
|
270
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
271
|
+
|
|
272
|
+
this.configuration.accessToken = accessToken;
|
|
273
|
+
this.tokenData.accessToken = tokenString;
|
|
274
|
+
|
|
275
|
+
this.storeTokenData(this.tokenData);
|
|
276
|
+
|
|
277
|
+
return axios(originalConfig);
|
|
278
|
+
} catch (_error) {
|
|
279
|
+
if (_error.response && _error.response.data) {
|
|
280
|
+
return Promise.reject(_error.response.data);
|
|
281
|
+
}
|
|
282
|
+
return Promise.reject(_error);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
} else if (err.message === NETWORK_ERROR_MESSAGE
|
|
286
|
+
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
287
|
+
&& _retry_count < 4
|
|
288
|
+
) {
|
|
289
|
+
_retry_count++;
|
|
290
|
+
try {
|
|
291
|
+
const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
|
|
292
|
+
const accessToken = `Bearer ${tokenString}`;
|
|
293
|
+
this.tokenData.permissions = permissions;
|
|
294
|
+
|
|
295
|
+
_retry = true;
|
|
296
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
297
|
+
|
|
298
|
+
this.configuration.accessToken = accessToken;
|
|
299
|
+
this.tokenData.accessToken = tokenString;
|
|
300
|
+
|
|
301
|
+
this.storeTokenData(this.tokenData);
|
|
302
|
+
|
|
303
|
+
return axios.request({
|
|
304
|
+
...originalConfig,
|
|
305
|
+
});
|
|
306
|
+
} catch (_error) {
|
|
307
|
+
if (_error.response && _error.response.data) {
|
|
308
|
+
return Promise.reject(_error.response.data);
|
|
309
|
+
}
|
|
310
|
+
return Promise.reject(_error);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return Promise.reject(err);
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
*
|
|
321
|
+
* @export
|
|
322
|
+
* @class RequiredError
|
|
323
|
+
* @extends {Error}
|
|
324
|
+
*/
|
|
325
|
+
export class RequiredError extends Error {
|
|
326
|
+
override name: "RequiredError" = "RequiredError";
|
|
327
|
+
constructor(public field: string, msg?: string) {
|
|
328
|
+
super(msg);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
package/common.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL TaskService
|
|
5
|
+
* The EMIL Task API description
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0
|
|
8
|
+
* Contact: kontakt@emil.de
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import { Configuration } from "./configuration";
|
|
17
|
+
import { RequiredError, RequestArgs } from "./base";
|
|
18
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @export
|
|
22
|
+
*/
|
|
23
|
+
export const DUMMY_BASE_URL = 'https://example.com'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @throws {RequiredError}
|
|
28
|
+
* @export
|
|
29
|
+
*/
|
|
30
|
+
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
|
31
|
+
if (paramValue === null || paramValue === undefined) {
|
|
32
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
*/
|
|
40
|
+
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
|
41
|
+
if (configuration && configuration.apiKey) {
|
|
42
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
43
|
+
? await configuration.apiKey(keyParamName)
|
|
44
|
+
: await configuration.apiKey;
|
|
45
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @export
|
|
52
|
+
*/
|
|
53
|
+
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
|
|
54
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
55
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @export
|
|
62
|
+
*/
|
|
63
|
+
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
|
64
|
+
if (configuration && configuration.accessToken) {
|
|
65
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
66
|
+
? await configuration.accessToken()
|
|
67
|
+
: await configuration.accessToken;
|
|
68
|
+
object["Authorization"] = configuration.getBearerToken(accessToken);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @export
|
|
75
|
+
*/
|
|
76
|
+
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
|
|
77
|
+
if (configuration && configuration.accessToken) {
|
|
78
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
79
|
+
? await configuration.accessToken(name, scopes)
|
|
80
|
+
: await configuration.accessToken;
|
|
81
|
+
object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @export
|
|
88
|
+
*/
|
|
89
|
+
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
|
90
|
+
const searchParams = new URLSearchParams(url.search);
|
|
91
|
+
for (const object of objects) {
|
|
92
|
+
for (const key in object) {
|
|
93
|
+
if (Array.isArray(object[key])) {
|
|
94
|
+
searchParams.delete(key);
|
|
95
|
+
for (const item of object[key]) {
|
|
96
|
+
searchParams.append(key, item);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
searchParams.set(key, object[key]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
url.search = searchParams.toString();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @export
|
|
109
|
+
*/
|
|
110
|
+
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
|
111
|
+
const nonString = typeof value !== 'string';
|
|
112
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
113
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
114
|
+
: nonString;
|
|
115
|
+
return needsSerialization
|
|
116
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
117
|
+
: (value || "");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @export
|
|
123
|
+
*/
|
|
124
|
+
export const toPathString = function (url: URL) {
|
|
125
|
+
return url.pathname + url.search + url.hash
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
*
|
|
130
|
+
* @export
|
|
131
|
+
*/
|
|
132
|
+
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
|
133
|
+
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
134
|
+
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
|
|
135
|
+
return axios.request<T, R>(axiosRequestArgs);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* tslint:disable */
|
|
140
|
+
/* eslint-disable */
|
|
141
|
+
/**
|
|
142
|
+
* EMIL TaskService
|
|
143
|
+
* The EMIL Task API description
|
|
144
|
+
*
|
|
145
|
+
* The version of the OpenAPI document: 1.0
|
|
146
|
+
* Contact: kontakt@emil.de
|
|
147
|
+
*
|
|
148
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
149
|
+
* https://openapi-generator.tech
|
|
150
|
+
* Do not edit the class manually.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
export interface IStorageConverter<D, SD> {
|
|
155
|
+
toStorageData( data: D ): SD;
|
|
156
|
+
fromStorageData( storageData: SD ): D;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface IStorage {
|
|
160
|
+
get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null;
|
|
161
|
+
set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export class LocalStorage implements IStorage {
|
|
165
|
+
readonly storage: Storage;
|
|
166
|
+
|
|
167
|
+
constructor() {
|
|
168
|
+
this.storage = localStorage;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null {
|
|
172
|
+
const jsonValue = this.storage.getItem( key );
|
|
173
|
+
if ( jsonValue === null ) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const value = JSON.parse( jsonValue );
|
|
177
|
+
if ( converter !== undefined ) {
|
|
178
|
+
return converter.fromStorageData( value );
|
|
179
|
+
} else {
|
|
180
|
+
return value as T;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void {
|
|
185
|
+
let valueToStore: any = value;
|
|
186
|
+
if ( converter !== undefined ) {
|
|
187
|
+
valueToStore = converter.toStorageData( value );
|
|
188
|
+
}
|
|
189
|
+
const jsonValue = JSON.stringify( valueToStore );
|
|
190
|
+
this.storage.setItem( key, jsonValue );
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let _defaultStorage: IStorage = null;
|
|
195
|
+
|
|
196
|
+
export const defaultStorage = (): IStorage => {
|
|
197
|
+
return _defaultStorage || (_defaultStorage = new LocalStorage());
|
|
198
|
+
};
|
package/configuration.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL TaskService
|
|
5
|
+
* The EMIL Task API description
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0
|
|
8
|
+
* Contact: kontakt@emil.de
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export interface ConfigurationParameters {
|
|
17
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
18
|
+
username?: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
21
|
+
basePath?: string;
|
|
22
|
+
baseOptions?: any;
|
|
23
|
+
formDataCtor?: new () => any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class Configuration {
|
|
27
|
+
/**
|
|
28
|
+
* parameter for apiKey security
|
|
29
|
+
* @param name security name
|
|
30
|
+
* @memberof Configuration
|
|
31
|
+
*/
|
|
32
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
33
|
+
/**
|
|
34
|
+
* parameter for basic security
|
|
35
|
+
*
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @memberof Configuration
|
|
38
|
+
*/
|
|
39
|
+
username?: string;
|
|
40
|
+
/**
|
|
41
|
+
* parameter for basic security
|
|
42
|
+
*
|
|
43
|
+
* @type {string}
|
|
44
|
+
* @memberof Configuration
|
|
45
|
+
*/
|
|
46
|
+
password?: string;
|
|
47
|
+
/**
|
|
48
|
+
* parameter for oauth2 security
|
|
49
|
+
* @param name security name
|
|
50
|
+
* @param scopes oauth2 scope
|
|
51
|
+
* @memberof Configuration
|
|
52
|
+
*/
|
|
53
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
54
|
+
/**
|
|
55
|
+
* override base path
|
|
56
|
+
*
|
|
57
|
+
* @type {string}
|
|
58
|
+
* @memberof Configuration
|
|
59
|
+
*/
|
|
60
|
+
basePath?: string;
|
|
61
|
+
/**
|
|
62
|
+
* base options for axios calls
|
|
63
|
+
*
|
|
64
|
+
* @type {any}
|
|
65
|
+
* @memberof Configuration
|
|
66
|
+
*/
|
|
67
|
+
baseOptions?: any;
|
|
68
|
+
/**
|
|
69
|
+
* The FormData constructor that will be used to create multipart form data
|
|
70
|
+
* requests. You can inject this here so that execution environments that
|
|
71
|
+
* do not support the FormData class can still run the generated client.
|
|
72
|
+
*
|
|
73
|
+
* @type {new () => FormData}
|
|
74
|
+
*/
|
|
75
|
+
formDataCtor?: new () => any;
|
|
76
|
+
|
|
77
|
+
constructor(param: ConfigurationParameters = {}) {
|
|
78
|
+
this.apiKey = param.apiKey;
|
|
79
|
+
this.username = param.username;
|
|
80
|
+
this.password = param.password;
|
|
81
|
+
this.accessToken = param.accessToken;
|
|
82
|
+
this.basePath = param.basePath;
|
|
83
|
+
this.baseOptions = param.baseOptions;
|
|
84
|
+
this.formDataCtor = param.formDataCtor;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Check if the given MIME is a JSON MIME.
|
|
89
|
+
* JSON MIME examples:
|
|
90
|
+
* application/json
|
|
91
|
+
* application/json; charset=UTF8
|
|
92
|
+
* APPLICATION/JSON
|
|
93
|
+
* application/vnd.company+json
|
|
94
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
95
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
96
|
+
*/
|
|
97
|
+
public isJsonMime(mime: string): boolean {
|
|
98
|
+
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
99
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns "Bearer" token.
|
|
104
|
+
* @param token - access token.
|
|
105
|
+
* @return Bearer token.
|
|
106
|
+
*/
|
|
107
|
+
public getBearerToken(token?: string): string {
|
|
108
|
+
return ('' + token).startsWith("Bearer") ? token : "Bearer " + token;
|
|
109
|
+
}
|
|
110
|
+
}
|