@emilgroup/tenant-sdk 1.5.0 → 1.5.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/README.md +5 -22
- package/api/custom-schema-api.ts +0 -4
- package/api/data-report-api.ts +0 -4
- package/api/data-report-executor-api.ts +0 -4
- package/api/invite-organizations-api.ts +0 -4
- package/api/invite-users-api.ts +0 -4
- package/api/list-organization-invitations-api.ts +0 -4
- package/api/organizations-api.ts +0 -4
- package/api/re-invite-an-organization-api.ts +0 -4
- package/api/roles-api.ts +0 -4
- package/api/settings-api.ts +0 -4
- package/api/users-api.ts +0 -4
- package/api.ts +0 -4
- package/base.ts +59 -93
- package/common.ts +0 -1
- package/configuration.ts +0 -8
- package/dist/api/custom-schema-api.js +4 -8
- package/dist/api/data-report-api.js +5 -9
- package/dist/api/data-report-executor-api.js +1 -5
- package/dist/api/invite-organizations-api.js +1 -5
- package/dist/api/invite-users-api.js +5 -9
- package/dist/api/list-organization-invitations-api.js +1 -5
- package/dist/api/organizations-api.js +3 -7
- package/dist/api/re-invite-an-organization-api.js +1 -5
- package/dist/api/roles-api.js +1 -5
- package/dist/api/settings-api.js +1 -5
- package/dist/api/users-api.js +9 -13
- package/dist/base.d.ts +5 -9
- package/dist/base.js +40 -136
- package/dist/common.d.ts +0 -1
- package/dist/common.js +1 -2
- package/dist/configuration.d.ts +0 -7
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Emil Tenant SDK
|
|
2
2
|
|
|
3
|
-
This TypeScript/JavaScript client utilizes [axios](https://github.com/axios/axios). The generated
|
|
3
|
+
This TypeScript/JavaScript client utilizes [axios](https://github.com/axios/axios). The generated module can be used with client-based applications (i.e. React).
|
|
4
4
|
|
|
5
5
|
Language level
|
|
6
6
|
* ES5 - you must have a Promises/A+ library installed
|
|
@@ -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/tenant-sdk@1.5.
|
|
20
|
+
npm install @emilgroup/tenant-sdk@1.5.1 --save
|
|
21
21
|
```
|
|
22
22
|
or
|
|
23
23
|
```
|
|
24
|
-
yarn add @emilgroup/tenant-sdk@1.5.
|
|
24
|
+
yarn add @emilgroup/tenant-sdk@1.5.1
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
And then you can import `UsersApi`.
|
|
@@ -31,32 +31,15 @@ import { UsersApi } from '@emilgroup/tenant-sdk'
|
|
|
31
31
|
|
|
32
32
|
const usersApi = new UsersApi();
|
|
33
33
|
```
|
|
34
|
-
## Credentials
|
|
35
34
|
|
|
36
|
-
To use authentication protected endpoints, you have to first authorize. To do so, the
|
|
37
|
-
|
|
38
|
-
```shell
|
|
39
|
-
emil_username=XXXXX@XXXX.XXX
|
|
40
|
-
emil_password=XXXXXXXXXXXXXX
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
It is also possible to provide environment variables instead:
|
|
44
|
-
|
|
45
|
-
```shell
|
|
46
|
-
export EMIL_USERNAME=XXXXX@XXXX.XXX
|
|
47
|
-
export EMIL_PASSWORD=XXXXXXXXXXXXXX
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Example
|
|
51
|
-
|
|
52
|
-
Here is a basic functionning example:
|
|
35
|
+
To use authentication protected endpoints, you have to first authorize. To do so, use the `authorize` function in `UsersApi`:
|
|
53
36
|
|
|
54
37
|
```ts
|
|
55
38
|
async function listUsers(): Promise<Void> {
|
|
56
39
|
try {
|
|
57
40
|
const usersApi = new UsersApi();
|
|
58
41
|
|
|
59
|
-
await usersApi.
|
|
42
|
+
await usersApi.authorize('username', 'password');
|
|
60
43
|
|
|
61
44
|
const { data: { items } } = await usersApi.listUsers();
|
|
62
45
|
|
package/api/custom-schema-api.ts
CHANGED
|
@@ -32,10 +32,6 @@ import { ListCustomSchemasResponseClass } from '../models';
|
|
|
32
32
|
import { UpdateCustomSchemaRequestDto } from '../models';
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
import { UpdateCustomSchemaResponseClass } from '../models';
|
|
35
|
-
// URLSearchParams not necessarily used
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
import { URL, URLSearchParams } from 'url';
|
|
38
|
-
const FormData = require('form-data');
|
|
39
35
|
/**
|
|
40
36
|
* CustomSchemaApi - axios parameter creator
|
|
41
37
|
* @export
|
package/api/data-report-api.ts
CHANGED
|
@@ -32,10 +32,6 @@ import { ListDataReportsResponseClass } from '../models';
|
|
|
32
32
|
import { UpdateDataReportRequestDto } from '../models';
|
|
33
33
|
// @ts-ignore
|
|
34
34
|
import { UpdateDataReportResponseClass } from '../models';
|
|
35
|
-
// URLSearchParams not necessarily used
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
import { URL, URLSearchParams } from 'url';
|
|
38
|
-
const FormData = require('form-data');
|
|
39
35
|
/**
|
|
40
36
|
* DataReportApi - axios parameter creator
|
|
41
37
|
* @export
|
|
@@ -24,10 +24,6 @@ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } fr
|
|
|
24
24
|
import { RunDataReportRequestDto } from '../models';
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
import { RunDataReportResponseClass } from '../models';
|
|
27
|
-
// URLSearchParams not necessarily used
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
import { URL, URLSearchParams } from 'url';
|
|
30
|
-
const FormData = require('form-data');
|
|
31
27
|
/**
|
|
32
28
|
* DataReportExecutorApi - axios parameter creator
|
|
33
29
|
* @export
|
|
@@ -24,10 +24,6 @@ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } fr
|
|
|
24
24
|
import { InviteOrgRequestDto } from '../models';
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
import { OrgInvitationResponseClass } from '../models';
|
|
27
|
-
// URLSearchParams not necessarily used
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
import { URL, URLSearchParams } from 'url';
|
|
30
|
-
const FormData = require('form-data');
|
|
31
27
|
/**
|
|
32
28
|
* InviteOrganizationsApi - axios parameter creator
|
|
33
29
|
* @export
|
package/api/invite-users-api.ts
CHANGED
|
@@ -36,10 +36,6 @@ import { InviteUsersRequestDto } from '../models';
|
|
|
36
36
|
import { InviteUsersResponseClass } from '../models';
|
|
37
37
|
// @ts-ignore
|
|
38
38
|
import { ListInvitesResponseClass } from '../models';
|
|
39
|
-
// URLSearchParams not necessarily used
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
import { URL, URLSearchParams } from 'url';
|
|
42
|
-
const FormData = require('form-data');
|
|
43
39
|
/**
|
|
44
40
|
* InviteUsersApi - axios parameter creator
|
|
45
41
|
* @export
|
|
@@ -22,10 +22,6 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
|
|
|
22
22
|
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
import { ListOrgInvitationsResponseClass } from '../models';
|
|
25
|
-
// URLSearchParams not necessarily used
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
import { URL, URLSearchParams } from 'url';
|
|
28
|
-
const FormData = require('form-data');
|
|
29
25
|
/**
|
|
30
26
|
* ListOrganizationInvitationsApi - axios parameter creator
|
|
31
27
|
* @export
|
package/api/organizations-api.ts
CHANGED
|
@@ -28,10 +28,6 @@ import { ListOrganizationsResponseClass } from '../models';
|
|
|
28
28
|
import { UpdateOrganizationRequestDtoRest } from '../models';
|
|
29
29
|
// @ts-ignore
|
|
30
30
|
import { UpdateOrganizationResponseClass } from '../models';
|
|
31
|
-
// URLSearchParams not necessarily used
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
import { URL, URLSearchParams } from 'url';
|
|
34
|
-
const FormData = require('form-data');
|
|
35
31
|
/**
|
|
36
32
|
* OrganizationsApi - axios parameter creator
|
|
37
33
|
* @export
|
|
@@ -24,10 +24,6 @@ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } fr
|
|
|
24
24
|
import { OrgInvitationResponseClass } from '../models';
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
import { ReInviteOrgRequestDto } from '../models';
|
|
27
|
-
// URLSearchParams not necessarily used
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
import { URL, URLSearchParams } from 'url';
|
|
30
|
-
const FormData = require('form-data');
|
|
31
27
|
/**
|
|
32
28
|
* ReInviteAnOrganizationApi - axios parameter creator
|
|
33
29
|
* @export
|
package/api/roles-api.ts
CHANGED
|
@@ -22,10 +22,6 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
|
|
|
22
22
|
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
import { ListRolesResponseClass } from '../models';
|
|
25
|
-
// URLSearchParams not necessarily used
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
import { URL, URLSearchParams } from 'url';
|
|
28
|
-
const FormData = require('form-data');
|
|
29
25
|
/**
|
|
30
26
|
* RolesApi - axios parameter creator
|
|
31
27
|
* @export
|
package/api/settings-api.ts
CHANGED
|
@@ -22,10 +22,6 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
|
|
|
22
22
|
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
import { GetSettingsResponseClass } from '../models';
|
|
25
|
-
// URLSearchParams not necessarily used
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
import { URL, URLSearchParams } from 'url';
|
|
28
|
-
const FormData = require('form-data');
|
|
29
25
|
/**
|
|
30
26
|
* SettingsApi - axios parameter creator
|
|
31
27
|
* @export
|
package/api/users-api.ts
CHANGED
|
@@ -46,10 +46,6 @@ import { EnableUsersResponseClass } from '../models';
|
|
|
46
46
|
import { GetUserResponseClass } from '../models';
|
|
47
47
|
// @ts-ignore
|
|
48
48
|
import { ListUsersResponseClass } from '../models';
|
|
49
|
-
// URLSearchParams not necessarily used
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
import { URL, URLSearchParams } from 'url';
|
|
52
|
-
const FormData = require('form-data');
|
|
53
49
|
/**
|
|
54
50
|
* UsersApi - axios parameter creator
|
|
55
51
|
* @export
|
package/api.ts
CHANGED
|
@@ -15,10 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
import { Configuration } from './configuration';
|
|
17
17
|
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
18
|
-
// URLSearchParams not necessarily used
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
import { URL, URLSearchParams } from 'url';
|
|
21
|
-
import FormData from 'form-data'
|
|
22
18
|
// Some imports not used depending on template conditions
|
|
23
19
|
// @ts-ignore
|
|
24
20
|
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
|
package/base.ts
CHANGED
|
@@ -14,20 +14,13 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
import { Configuration } from "./configuration";
|
|
17
|
+
import { defaultStorage } from "./common";
|
|
17
18
|
// Some imports not used depending on template conditions
|
|
18
19
|
// @ts-ignore
|
|
19
20
|
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
21
|
|
|
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
22
|
|
|
30
|
-
const
|
|
23
|
+
export const BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
|
|
31
24
|
/**
|
|
32
25
|
*
|
|
33
26
|
* @export
|
|
@@ -67,7 +60,13 @@ export interface RequestArgs {
|
|
|
67
60
|
options: AxiosRequestConfig;
|
|
68
61
|
}
|
|
69
62
|
|
|
63
|
+
interface TokenData {
|
|
64
|
+
accessToken?: string;
|
|
65
|
+
username?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
70
68
|
const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
69
|
+
const TOKEN_DATA = 'APP_TOKEN';
|
|
71
70
|
|
|
72
71
|
/**
|
|
73
72
|
*
|
|
@@ -75,75 +74,31 @@ const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
|
75
74
|
* @class BaseAPI
|
|
76
75
|
*/
|
|
77
76
|
export class BaseAPI {
|
|
78
|
-
protected configuration: Configuration;
|
|
79
|
-
private
|
|
80
|
-
|
|
77
|
+
protected configuration: Configuration | undefined;
|
|
78
|
+
private tokenData?: TokenData;
|
|
79
|
+
|
|
80
|
+
constructor(configuration?: Configuration,
|
|
81
|
+
protected basePath: string = BASE_PATH,
|
|
82
|
+
protected axios: AxiosInstance = globalAxios) {
|
|
83
|
+
|
|
84
|
+
this.loadTokenData();
|
|
81
85
|
|
|
82
|
-
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
83
86
|
if (configuration) {
|
|
84
87
|
this.configuration = configuration;
|
|
85
88
|
this.basePath = configuration.basePath || this.basePath;
|
|
86
89
|
} else {
|
|
90
|
+
const { accessToken, username } = this.tokenData;
|
|
91
|
+
|
|
87
92
|
this.configuration = new Configuration({
|
|
88
93
|
basePath: this.basePath,
|
|
94
|
+
accessToken: accessToken ? `Bearer ${accessToken}` : '',
|
|
95
|
+
username,
|
|
89
96
|
});
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
this.attachInterceptor(axios);
|
|
93
100
|
}
|
|
94
101
|
|
|
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
102
|
selectEnvironment(env: Environment) {
|
|
148
103
|
this.configuration.basePath = env;
|
|
149
104
|
}
|
|
@@ -163,18 +118,21 @@ export class BaseAPI {
|
|
|
163
118
|
const response = await globalAxios.request<LoginClass>(options);
|
|
164
119
|
|
|
165
120
|
const { data: { accessToken } } = response;
|
|
121
|
+
|
|
166
122
|
this.configuration.username = username;
|
|
167
123
|
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
124
|
+
this.tokenData.username = username;
|
|
125
|
+
this.tokenData.accessToken = accessToken;
|
|
168
126
|
|
|
169
|
-
|
|
170
|
-
|
|
127
|
+
this.storeTokenData({
|
|
128
|
+
...this.tokenData
|
|
129
|
+
});
|
|
171
130
|
}
|
|
172
131
|
|
|
173
132
|
async refreshTokenInternal(): Promise<string> {
|
|
174
|
-
const { username
|
|
175
|
-
|
|
133
|
+
const { username } = this.configuration;
|
|
176
134
|
|
|
177
|
-
if (!username
|
|
135
|
+
if (!username) {
|
|
178
136
|
return '';
|
|
179
137
|
}
|
|
180
138
|
|
|
@@ -183,7 +141,6 @@ export class BaseAPI {
|
|
|
183
141
|
url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
|
|
184
142
|
headers: {
|
|
185
143
|
'Content-Type': 'application/json',
|
|
186
|
-
Cookie: refreshToken,
|
|
187
144
|
},
|
|
188
145
|
data: { username: username },
|
|
189
146
|
withCredentials: true,
|
|
@@ -194,18 +151,22 @@ export class BaseAPI {
|
|
|
194
151
|
return accessToken;
|
|
195
152
|
}
|
|
196
153
|
|
|
197
|
-
private
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return `${response.headers['set-cookie'][0].split(';')[0]};`;
|
|
154
|
+
private storeTokenData(tokenData?: TokenData) {
|
|
155
|
+
if (typeof window !== 'undefined') {
|
|
156
|
+
defaultStorage().set<TokenData>(TOKEN_DATA, tokenData);
|
|
202
157
|
}
|
|
158
|
+
}
|
|
203
159
|
|
|
204
|
-
|
|
160
|
+
public loadTokenData() {
|
|
161
|
+
if (typeof window !== 'undefined') {
|
|
162
|
+
this.tokenData = defaultStorage().get<TokenData>(TOKEN_DATA) || {};
|
|
163
|
+
} else {
|
|
164
|
+
this.tokenData = {};
|
|
165
|
+
}
|
|
205
166
|
}
|
|
206
167
|
|
|
207
|
-
|
|
208
|
-
|
|
168
|
+
public cleanTokenData() {
|
|
169
|
+
this.storeTokenData(null);
|
|
209
170
|
}
|
|
210
171
|
|
|
211
172
|
private attachInterceptor(axios: AxiosInstance) {
|
|
@@ -215,19 +176,25 @@ export class BaseAPI {
|
|
|
215
176
|
},
|
|
216
177
|
async (err) => {
|
|
217
178
|
let originalConfig = err.config;
|
|
218
|
-
if (err.response) {
|
|
179
|
+
if (err.response && !(err.response instanceof XMLHttpRequest)) { // sometimes buggy and is of type request
|
|
219
180
|
// Access Token was expired
|
|
220
|
-
if (err.response.status === 401
|
|
181
|
+
if ((err.response.status === 401 || err.response.status === 403)
|
|
182
|
+
&& !originalConfig._retry) {
|
|
221
183
|
originalConfig._retry = true;
|
|
222
184
|
try {
|
|
223
|
-
|
|
185
|
+
let tokenString = await this.refreshTokenInternal();
|
|
224
186
|
const accessToken = `Bearer ${tokenString}`;
|
|
225
187
|
|
|
226
|
-
originalConfig.headers['Authorization']
|
|
188
|
+
delete originalConfig.headers['Authorization']
|
|
189
|
+
|
|
190
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
227
191
|
|
|
228
192
|
this.configuration.accessToken = accessToken;
|
|
193
|
+
this.tokenData.accessToken = tokenString;
|
|
194
|
+
|
|
195
|
+
this.storeTokenData(this.tokenData);
|
|
229
196
|
|
|
230
|
-
return axios
|
|
197
|
+
return axios(originalConfig);
|
|
231
198
|
} catch (_error) {
|
|
232
199
|
if (_error.response && _error.response.data) {
|
|
233
200
|
return Promise.reject(_error.response.data);
|
|
@@ -235,23 +202,22 @@ export class BaseAPI {
|
|
|
235
202
|
return Promise.reject(_error);
|
|
236
203
|
}
|
|
237
204
|
}
|
|
238
|
-
|
|
239
|
-
return Promise.reject(err.response.data);
|
|
240
|
-
}
|
|
241
|
-
} else if(err.message === NETWORK_ERROR_MESSAGE
|
|
242
|
-
&& err.isAxiosError
|
|
205
|
+
} else if (err.message === NETWORK_ERROR_MESSAGE
|
|
243
206
|
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
244
207
|
&& _retry_count < 4
|
|
245
|
-
){
|
|
208
|
+
) {
|
|
246
209
|
_retry_count++;
|
|
247
210
|
try {
|
|
248
|
-
|
|
211
|
+
let tokenString = await this.refreshTokenInternal();
|
|
249
212
|
const accessToken = `Bearer ${tokenString}`;
|
|
250
213
|
|
|
251
214
|
_retry = true;
|
|
252
|
-
originalConfig.headers['Authorization'] = accessToken;
|
|
215
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
253
216
|
|
|
254
217
|
this.configuration.accessToken = accessToken;
|
|
218
|
+
this.tokenData.accessToken = tokenString;
|
|
219
|
+
|
|
220
|
+
this.storeTokenData(this.tokenData);
|
|
255
221
|
|
|
256
222
|
return axios.request({
|
|
257
223
|
...originalConfig,
|
|
@@ -261,7 +227,7 @@ export class BaseAPI {
|
|
|
261
227
|
return Promise.reject(_error.response.data);
|
|
262
228
|
}
|
|
263
229
|
return Promise.reject(_error);
|
|
264
|
-
}
|
|
230
|
+
}
|
|
265
231
|
}
|
|
266
232
|
return Promise.reject(err);
|
|
267
233
|
}
|
package/common.ts
CHANGED
package/configuration.ts
CHANGED
|
@@ -74,14 +74,6 @@ export class Configuration {
|
|
|
74
74
|
*/
|
|
75
75
|
formDataCtor?: new () => any;
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
* parameter for automatically refreshing access token for oauth2 security
|
|
79
|
-
*
|
|
80
|
-
* @type {string}
|
|
81
|
-
* @memberof Configuration
|
|
82
|
-
*/
|
|
83
|
-
refreshToken?: string;
|
|
84
|
-
|
|
85
77
|
constructor(param: ConfigurationParameters = {}) {
|
|
86
78
|
this.apiKey = param.apiKey;
|
|
87
79
|
this.username = param.username;
|
|
@@ -85,10 +85,6 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
85
85
|
var common_1 = require("../common");
|
|
86
86
|
// @ts-ignore
|
|
87
87
|
var base_1 = require("../base");
|
|
88
|
-
// URLSearchParams not necessarily used
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
var url_1 = require("url");
|
|
91
|
-
var FormData = require('form-data');
|
|
92
88
|
/**
|
|
93
89
|
* CustomSchemaApi - axios parameter creator
|
|
94
90
|
* @export
|
|
@@ -114,7 +110,7 @@ var CustomSchemaApiAxiosParamCreator = function (configuration) {
|
|
|
114
110
|
// verify required parameter 'createCustomSchemaRequestDto' is not null or undefined
|
|
115
111
|
(0, common_1.assertParamExists)('createCustomSchema', 'createCustomSchemaRequestDto', createCustomSchemaRequestDto);
|
|
116
112
|
localVarPath = "/tenantservice/v1/custom-schemas";
|
|
117
|
-
localVarUrlObj = new
|
|
113
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
118
114
|
if (configuration) {
|
|
119
115
|
baseOptions = configuration.baseOptions;
|
|
120
116
|
baseAccessToken = configuration.accessToken;
|
|
@@ -165,7 +161,7 @@ var CustomSchemaApiAxiosParamCreator = function (configuration) {
|
|
|
165
161
|
(0, common_1.assertParamExists)('getCustomSchema', 'code', code);
|
|
166
162
|
localVarPath = "/tenantservice/v1/custom-schemas/{code}"
|
|
167
163
|
.replace("{".concat("code", "}"), encodeURIComponent(String(code)));
|
|
168
|
-
localVarUrlObj = new
|
|
164
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
169
165
|
if (configuration) {
|
|
170
166
|
baseOptions = configuration.baseOptions;
|
|
171
167
|
baseAccessToken = configuration.accessToken;
|
|
@@ -218,7 +214,7 @@ var CustomSchemaApiAxiosParamCreator = function (configuration) {
|
|
|
218
214
|
switch (_a.label) {
|
|
219
215
|
case 0:
|
|
220
216
|
localVarPath = "/tenantservice/v1/custom-schemas";
|
|
221
|
-
localVarUrlObj = new
|
|
217
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
222
218
|
if (configuration) {
|
|
223
219
|
baseOptions = configuration.baseOptions;
|
|
224
220
|
baseAccessToken = configuration.accessToken;
|
|
@@ -287,7 +283,7 @@ var CustomSchemaApiAxiosParamCreator = function (configuration) {
|
|
|
287
283
|
(0, common_1.assertParamExists)('updateCustomSchema', 'updateCustomSchemaRequestDto', updateCustomSchemaRequestDto);
|
|
288
284
|
localVarPath = "/tenantservice/v1/custom-schemas/{code}"
|
|
289
285
|
.replace("{".concat("code", "}"), encodeURIComponent(String(code)));
|
|
290
|
-
localVarUrlObj = new
|
|
286
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
291
287
|
if (configuration) {
|
|
292
288
|
baseOptions = configuration.baseOptions;
|
|
293
289
|
baseAccessToken = configuration.accessToken;
|
|
@@ -85,10 +85,6 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
85
85
|
var common_1 = require("../common");
|
|
86
86
|
// @ts-ignore
|
|
87
87
|
var base_1 = require("../base");
|
|
88
|
-
// URLSearchParams not necessarily used
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
var url_1 = require("url");
|
|
91
|
-
var FormData = require('form-data');
|
|
92
88
|
/**
|
|
93
89
|
* DataReportApi - axios parameter creator
|
|
94
90
|
* @export
|
|
@@ -114,7 +110,7 @@ var DataReportApiAxiosParamCreator = function (configuration) {
|
|
|
114
110
|
// verify required parameter 'createDataReportRequestDto' is not null or undefined
|
|
115
111
|
(0, common_1.assertParamExists)('createCustomSchema', 'createDataReportRequestDto', createDataReportRequestDto);
|
|
116
112
|
localVarPath = "/tenantservice/v1/data-reports";
|
|
117
|
-
localVarUrlObj = new
|
|
113
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
118
114
|
if (configuration) {
|
|
119
115
|
baseOptions = configuration.baseOptions;
|
|
120
116
|
baseAccessToken = configuration.accessToken;
|
|
@@ -163,7 +159,7 @@ var DataReportApiAxiosParamCreator = function (configuration) {
|
|
|
163
159
|
(0, common_1.assertParamExists)('deleteAlert', 'id', id);
|
|
164
160
|
localVarPath = "/tenantservice/v1/data-reports/{id}"
|
|
165
161
|
.replace("{".concat("id", "}"), encodeURIComponent(String(id)));
|
|
166
|
-
localVarUrlObj = new
|
|
162
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
167
163
|
if (configuration) {
|
|
168
164
|
baseOptions = configuration.baseOptions;
|
|
169
165
|
baseAccessToken = configuration.accessToken;
|
|
@@ -212,7 +208,7 @@ var DataReportApiAxiosParamCreator = function (configuration) {
|
|
|
212
208
|
(0, common_1.assertParamExists)('getDataReport', 'code', code);
|
|
213
209
|
localVarPath = "/tenantservice/v1/data-reports/{code}"
|
|
214
210
|
.replace("{".concat("code", "}"), encodeURIComponent(String(code)));
|
|
215
|
-
localVarUrlObj = new
|
|
211
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
216
212
|
if (configuration) {
|
|
217
213
|
baseOptions = configuration.baseOptions;
|
|
218
214
|
baseAccessToken = configuration.accessToken;
|
|
@@ -265,7 +261,7 @@ var DataReportApiAxiosParamCreator = function (configuration) {
|
|
|
265
261
|
switch (_a.label) {
|
|
266
262
|
case 0:
|
|
267
263
|
localVarPath = "/tenantservice/v1/data-reports";
|
|
268
|
-
localVarUrlObj = new
|
|
264
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
269
265
|
if (configuration) {
|
|
270
266
|
baseOptions = configuration.baseOptions;
|
|
271
267
|
baseAccessToken = configuration.accessToken;
|
|
@@ -334,7 +330,7 @@ var DataReportApiAxiosParamCreator = function (configuration) {
|
|
|
334
330
|
(0, common_1.assertParamExists)('updateDataReport', 'updateDataReportRequestDto', updateDataReportRequestDto);
|
|
335
331
|
localVarPath = "/tenantservice/v1/data-reports/{code}"
|
|
336
332
|
.replace("{".concat("code", "}"), encodeURIComponent(String(code)));
|
|
337
|
-
localVarUrlObj = new
|
|
333
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
338
334
|
if (configuration) {
|
|
339
335
|
baseOptions = configuration.baseOptions;
|
|
340
336
|
baseAccessToken = configuration.accessToken;
|
|
@@ -85,10 +85,6 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
85
85
|
var common_1 = require("../common");
|
|
86
86
|
// @ts-ignore
|
|
87
87
|
var base_1 = require("../base");
|
|
88
|
-
// URLSearchParams not necessarily used
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
var url_1 = require("url");
|
|
91
|
-
var FormData = require('form-data');
|
|
92
88
|
/**
|
|
93
89
|
* DataReportExecutorApi - axios parameter creator
|
|
94
90
|
* @export
|
|
@@ -113,7 +109,7 @@ var DataReportExecutorApiAxiosParamCreator = function (configuration) {
|
|
|
113
109
|
// verify required parameter 'runDataReportRequestDto' is not null or undefined
|
|
114
110
|
(0, common_1.assertParamExists)('runDataReport', 'runDataReportRequestDto', runDataReportRequestDto);
|
|
115
111
|
localVarPath = "/tenantservice/v1/data-report-executor";
|
|
116
|
-
localVarUrlObj = new
|
|
112
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
117
113
|
if (configuration) {
|
|
118
114
|
baseOptions = configuration.baseOptions;
|
|
119
115
|
baseAccessToken = configuration.accessToken;
|
|
@@ -85,10 +85,6 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
85
85
|
var common_1 = require("../common");
|
|
86
86
|
// @ts-ignore
|
|
87
87
|
var base_1 = require("../base");
|
|
88
|
-
// URLSearchParams not necessarily used
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
var url_1 = require("url");
|
|
91
|
-
var FormData = require('form-data');
|
|
92
88
|
/**
|
|
93
89
|
* InviteOrganizationsApi - axios parameter creator
|
|
94
90
|
* @export
|
|
@@ -114,7 +110,7 @@ var InviteOrganizationsApiAxiosParamCreator = function (configuration) {
|
|
|
114
110
|
// verify required parameter 'inviteOrgRequestDto' is not null or undefined
|
|
115
111
|
(0, common_1.assertParamExists)('inviteOrg', 'inviteOrgRequestDto', inviteOrgRequestDto);
|
|
116
112
|
localVarPath = "/tenantservice/v1/invitations/organizations";
|
|
117
|
-
localVarUrlObj = new
|
|
113
|
+
localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
118
114
|
if (configuration) {
|
|
119
115
|
baseOptions = configuration.baseOptions;
|
|
120
116
|
baseAccessToken = configuration.accessToken;
|