@emilgroup/translation-sdk 1.0.0 → 1.0.1-beta.4
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 +4 -0
- package/README.md +9 -26
- package/api/default-api.ts +124 -0
- package/api/translation-api.ts +170 -209
- package/api.ts +2 -4
- package/base.ts +140 -97
- package/common.ts +2 -3
- package/configuration.ts +9 -8
- package/dist/api/default-api.d.ts +70 -0
- package/dist/api/default-api.js +200 -0
- package/dist/api/translation-api.d.ts +139 -165
- package/dist/api/translation-api.js +125 -147
- package/dist/api.d.ts +1 -0
- package/dist/api.js +1 -0
- package/dist/base.d.ts +22 -13
- package/dist/base.js +125 -153
- package/dist/common.d.ts +0 -1
- package/dist/common.js +3 -4
- package/dist/configuration.d.ts +6 -7
- package/dist/configuration.js +8 -0
- package/dist/models/create-product-language-request-dto.d.ts +1 -1
- package/dist/models/get-product-language-response-class.d.ts +25 -0
- package/dist/models/get-product-language-response-class.js +15 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +3 -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/product-language-class.d.ts +4 -4
- package/models/create-product-language-request-dto.ts +1 -1
- package/models/get-product-language-response-class.ts +31 -0
- package/models/index.ts +3 -0
- package/models/inline-response200.ts +48 -0
- package/models/inline-response503.ts +48 -0
- package/models/product-language-class.ts +4 -4
- package/package.json +2 -5
- package/tsconfig.json +1 -0
package/dist/api.d.ts
CHANGED
package/dist/api.js
CHANGED
|
@@ -27,4 +27,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
27
27
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
__exportStar(require("./api/default-api"), exports);
|
|
30
31
|
__exportStar(require("./api/translation-api"), exports);
|
package/dist/base.d.ts
CHANGED
|
@@ -24,12 +24,22 @@ export declare const COLLECTION_FORMATS: {
|
|
|
24
24
|
};
|
|
25
25
|
export interface LoginClass {
|
|
26
26
|
accessToken: string;
|
|
27
|
-
permissions:
|
|
27
|
+
permissions: string;
|
|
28
|
+
}
|
|
29
|
+
export interface SwitchWorkspaceRequest {
|
|
30
|
+
username: string;
|
|
31
|
+
targetWorkspace: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SwitchWorkspaceResponseClass {
|
|
34
|
+
accessToken: string;
|
|
35
|
+
permissions: string;
|
|
28
36
|
}
|
|
29
37
|
export declare enum Environment {
|
|
30
38
|
Production = "https://apiv2.emil.de",
|
|
31
39
|
Test = "https://apiv2-test.emil.de",
|
|
32
|
-
|
|
40
|
+
Staging = "https://apiv2-staging.emil.de",
|
|
41
|
+
Development = "https://apiv2-dev.emil.de",
|
|
42
|
+
ProductionZurich = "https://eu-central-2.apiv2.emil.de"
|
|
33
43
|
}
|
|
34
44
|
export declare function resetRetry(): void;
|
|
35
45
|
/**
|
|
@@ -49,19 +59,18 @@ export interface RequestArgs {
|
|
|
49
59
|
export declare class BaseAPI {
|
|
50
60
|
protected basePath: string;
|
|
51
61
|
protected axios: AxiosInstance;
|
|
52
|
-
protected configuration: Configuration;
|
|
53
|
-
private
|
|
54
|
-
private password?;
|
|
62
|
+
protected configuration: Configuration | undefined;
|
|
63
|
+
private tokenData?;
|
|
55
64
|
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
56
|
-
initialize(env?: Environment): Promise<void>;
|
|
57
|
-
private loadCredentials;
|
|
58
|
-
private readConfigFile;
|
|
59
|
-
private readEnvVariables;
|
|
60
65
|
selectEnvironment(env: Environment): void;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
selectBasePath(path: string): void;
|
|
67
|
+
getPermissions(): Array<string>;
|
|
68
|
+
authorize(username: string, password: string, targetWorkspace?: string): Promise<void>;
|
|
69
|
+
switchWorkspace(targetWorkspace: string): Promise<void>;
|
|
70
|
+
refreshTokenInternal(): Promise<LoginClass>;
|
|
71
|
+
private storeTokenData;
|
|
72
|
+
loadTokenData(): void;
|
|
73
|
+
cleanTokenData(): void;
|
|
65
74
|
private attachInterceptor;
|
|
66
75
|
}
|
|
67
76
|
/**
|
package/dist/base.js
CHANGED
|
@@ -38,29 +38,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
38
38
|
};
|
|
39
39
|
return __assign.apply(this, arguments);
|
|
40
40
|
};
|
|
41
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
42
|
-
if (k2 === undefined) k2 = k;
|
|
43
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
44
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
45
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
46
|
-
}
|
|
47
|
-
Object.defineProperty(o, k2, desc);
|
|
48
|
-
}) : (function(o, m, k, k2) {
|
|
49
|
-
if (k2 === undefined) k2 = k;
|
|
50
|
-
o[k2] = m[k];
|
|
51
|
-
}));
|
|
52
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
53
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
54
|
-
}) : function(o, v) {
|
|
55
|
-
o["default"] = v;
|
|
56
|
-
});
|
|
57
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
58
|
-
if (mod && mod.__esModule) return mod;
|
|
59
|
-
var result = {};
|
|
60
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
61
|
-
__setModuleDefault(result, mod);
|
|
62
|
-
return result;
|
|
63
|
-
};
|
|
64
41
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
65
42
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
66
43
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -103,18 +80,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
103
80
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104
81
|
exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
105
82
|
var configuration_1 = require("./configuration");
|
|
83
|
+
var common_1 = require("./common");
|
|
106
84
|
// Some imports not used depending on template conditions
|
|
107
85
|
// @ts-ignore
|
|
108
86
|
var axios_1 = __importDefault(require("axios"));
|
|
109
|
-
var fs = __importStar(require("fs"));
|
|
110
|
-
var path = __importStar(require("path"));
|
|
111
|
-
var os = __importStar(require("os"));
|
|
112
87
|
exports.BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
|
|
113
|
-
var CONFIG_DIRECTORY = '.emil';
|
|
114
|
-
var CONFIG_FILENAME = 'credentials';
|
|
115
|
-
var KEY_USERNAME = 'emil_username';
|
|
116
|
-
var KEY_PASSWORD = 'emil_password';
|
|
117
|
-
var filePath = os.homedir() + path.sep + CONFIG_DIRECTORY + path.sep + CONFIG_FILENAME;
|
|
118
88
|
/**
|
|
119
89
|
*
|
|
120
90
|
* @export
|
|
@@ -129,7 +99,9 @@ var Environment;
|
|
|
129
99
|
(function (Environment) {
|
|
130
100
|
Environment["Production"] = "https://apiv2.emil.de";
|
|
131
101
|
Environment["Test"] = "https://apiv2-test.emil.de";
|
|
102
|
+
Environment["Staging"] = "https://apiv2-staging.emil.de";
|
|
132
103
|
Environment["Development"] = "https://apiv2-dev.emil.de";
|
|
104
|
+
Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
|
|
133
105
|
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
134
106
|
var _retry_count = 0;
|
|
135
107
|
var _retry = null;
|
|
@@ -138,6 +110,7 @@ function resetRetry() {
|
|
|
138
110
|
}
|
|
139
111
|
exports.resetRetry = resetRetry;
|
|
140
112
|
var NETWORK_ERROR_MESSAGE = "Network Error";
|
|
113
|
+
var TOKEN_DATA = 'APP_TOKEN';
|
|
141
114
|
/**
|
|
142
115
|
*
|
|
143
116
|
* @export
|
|
@@ -149,122 +122,105 @@ var BaseAPI = /** @class */ (function () {
|
|
|
149
122
|
if (axios === void 0) { axios = axios_1.default; }
|
|
150
123
|
this.basePath = basePath;
|
|
151
124
|
this.axios = axios;
|
|
125
|
+
this.loadTokenData();
|
|
152
126
|
if (configuration) {
|
|
127
|
+
var accessToken = this.tokenData.accessToken;
|
|
153
128
|
this.configuration = configuration;
|
|
154
129
|
this.basePath = configuration.basePath || this.basePath;
|
|
130
|
+
// Use config token if provided, otherwise use tokenData token
|
|
131
|
+
var configToken = this.configuration.accessToken;
|
|
132
|
+
var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
|
|
133
|
+
this.configuration.accessToken = configToken || storedToken;
|
|
155
134
|
}
|
|
156
135
|
else {
|
|
136
|
+
var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
|
|
157
137
|
this.configuration = new configuration_1.Configuration({
|
|
158
138
|
basePath: this.basePath,
|
|
139
|
+
accessToken: accessToken ? "Bearer ".concat(accessToken) : '',
|
|
140
|
+
username: username,
|
|
159
141
|
});
|
|
160
142
|
}
|
|
161
143
|
this.attachInterceptor(axios);
|
|
162
144
|
}
|
|
163
|
-
BaseAPI.prototype.
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
case 2:
|
|
176
|
-
_a.sent();
|
|
177
|
-
this.password = null; // to avoid keeping password loaded in memory.
|
|
178
|
-
_a.label = 3;
|
|
179
|
-
case 3: return [2 /*return*/];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
145
|
+
BaseAPI.prototype.selectEnvironment = function (env) {
|
|
146
|
+
this.selectBasePath(env);
|
|
147
|
+
};
|
|
148
|
+
BaseAPI.prototype.selectBasePath = function (path) {
|
|
149
|
+
this.configuration.basePath = path;
|
|
150
|
+
};
|
|
151
|
+
BaseAPI.prototype.getPermissions = function () {
|
|
152
|
+
var _a;
|
|
153
|
+
if (!((_a = this.tokenData) === null || _a === void 0 ? void 0 : _a.permissions)) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
return this.tokenData.permissions.split(',');
|
|
183
157
|
};
|
|
184
|
-
BaseAPI.prototype.
|
|
158
|
+
BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
|
|
185
159
|
return __awaiter(this, void 0, void 0, function () {
|
|
186
|
-
var
|
|
187
|
-
return __generator(this, function (
|
|
188
|
-
switch (
|
|
160
|
+
var options, response, _a, accessToken, permissions;
|
|
161
|
+
return __generator(this, function (_b) {
|
|
162
|
+
switch (_b.label) {
|
|
189
163
|
case 0:
|
|
190
|
-
|
|
191
|
-
|
|
164
|
+
options = {
|
|
165
|
+
method: 'POST',
|
|
166
|
+
url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
|
|
167
|
+
headers: { 'Content-Type': 'application/json' },
|
|
168
|
+
data: {
|
|
169
|
+
username: username,
|
|
170
|
+
password: password,
|
|
171
|
+
},
|
|
172
|
+
withCredentials: true,
|
|
173
|
+
};
|
|
174
|
+
return [4 /*yield*/, axios_1.default.request(options)];
|
|
192
175
|
case 1:
|
|
193
|
-
|
|
194
|
-
|
|
176
|
+
response = _b.sent();
|
|
177
|
+
_a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
|
|
178
|
+
this.configuration.username = username;
|
|
179
|
+
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
180
|
+
this.tokenData.username = username;
|
|
181
|
+
this.tokenData.accessToken = accessToken;
|
|
182
|
+
this.tokenData.permissions = permissions;
|
|
183
|
+
if (!targetWorkspace) return [3 /*break*/, 3];
|
|
184
|
+
return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
|
|
195
185
|
case 2:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return [3 /*break*/, 3];
|
|
186
|
+
_b.sent();
|
|
187
|
+
return [3 /*break*/, 4];
|
|
199
188
|
case 3:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return [2 /*return*/];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
BaseAPI.prototype.readConfigFile = function () {
|
|
210
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
-
var file, lines;
|
|
212
|
-
var _this = this;
|
|
213
|
-
return __generator(this, function (_a) {
|
|
214
|
-
switch (_a.label) {
|
|
215
|
-
case 0: return [4 /*yield*/, fs.promises.readFile(filePath, 'utf-8')];
|
|
216
|
-
case 1:
|
|
217
|
-
file = _a.sent();
|
|
218
|
-
lines = file.split(os.EOL)
|
|
219
|
-
.filter(Boolean);
|
|
220
|
-
lines.forEach(function (line) {
|
|
221
|
-
if (line.startsWith(KEY_USERNAME)) {
|
|
222
|
-
_this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
|
|
223
|
-
}
|
|
224
|
-
else if (line.startsWith(KEY_PASSWORD)) {
|
|
225
|
-
_this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
return [2 /*return*/];
|
|
189
|
+
// Only store if no workspace switch (since switchWorkspace will store after switching)
|
|
190
|
+
this.storeTokenData(__assign({}, this.tokenData));
|
|
191
|
+
_b.label = 4;
|
|
192
|
+
case 4: return [2 /*return*/];
|
|
229
193
|
}
|
|
230
194
|
});
|
|
231
195
|
});
|
|
232
196
|
};
|
|
233
|
-
BaseAPI.prototype.
|
|
234
|
-
if (process.env.EMIL_USERNAME) {
|
|
235
|
-
this.username = process.env.EMIL_USERNAME;
|
|
236
|
-
this.password = process.env.EMIL_PASSWORD || '';
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
return false;
|
|
240
|
-
};
|
|
241
|
-
BaseAPI.prototype.selectEnvironment = function (env) {
|
|
242
|
-
this.configuration.basePath = env;
|
|
243
|
-
};
|
|
244
|
-
BaseAPI.prototype.authorize = function (username, password) {
|
|
197
|
+
BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
|
|
245
198
|
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
-
var options, response, accessToken,
|
|
247
|
-
return __generator(this, function (
|
|
248
|
-
switch (
|
|
199
|
+
var options, response, _a, accessToken, permissions;
|
|
200
|
+
return __generator(this, function (_b) {
|
|
201
|
+
switch (_b.label) {
|
|
249
202
|
case 0:
|
|
250
203
|
options = {
|
|
251
204
|
method: 'POST',
|
|
252
|
-
url: "".concat(this.configuration.basePath, "/authservice/v1/
|
|
253
|
-
headers: {
|
|
205
|
+
url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
|
|
206
|
+
headers: {
|
|
207
|
+
'Content-Type': 'application/json',
|
|
208
|
+
'Authorization': "Bearer ".concat(this.configuration.accessToken),
|
|
209
|
+
},
|
|
254
210
|
data: {
|
|
255
|
-
username: username,
|
|
256
|
-
|
|
211
|
+
username: this.configuration.username,
|
|
212
|
+
targetWorkspace: targetWorkspace,
|
|
257
213
|
},
|
|
258
214
|
withCredentials: true,
|
|
259
215
|
};
|
|
260
216
|
return [4 /*yield*/, axios_1.default.request(options)];
|
|
261
217
|
case 1:
|
|
262
|
-
response =
|
|
263
|
-
|
|
264
|
-
this.configuration.username = username;
|
|
218
|
+
response = _b.sent();
|
|
219
|
+
_a = response.data, accessToken = _a.accessToken, permissions = _a.permissions;
|
|
265
220
|
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
266
|
-
|
|
267
|
-
this.
|
|
221
|
+
this.tokenData.accessToken = accessToken;
|
|
222
|
+
this.tokenData.permissions = permissions;
|
|
223
|
+
this.storeTokenData(__assign({}, this.tokenData));
|
|
268
224
|
return [2 /*return*/];
|
|
269
225
|
}
|
|
270
226
|
});
|
|
@@ -272,95 +228,111 @@ var BaseAPI = /** @class */ (function () {
|
|
|
272
228
|
};
|
|
273
229
|
BaseAPI.prototype.refreshTokenInternal = function () {
|
|
274
230
|
return __awaiter(this, void 0, void 0, function () {
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
|
|
231
|
+
var username, refreshTokenAxios, options, response;
|
|
232
|
+
var _this = this;
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
278
235
|
case 0:
|
|
279
|
-
|
|
280
|
-
if (!username
|
|
281
|
-
|
|
236
|
+
username = this.configuration.username;
|
|
237
|
+
if (!username) {
|
|
238
|
+
throw new Error('Failed to refresh token.');
|
|
282
239
|
}
|
|
240
|
+
refreshTokenAxios = axios_1.default.create();
|
|
241
|
+
refreshTokenAxios.interceptors.response.use(function (response) {
|
|
242
|
+
var permissions = response.data.permissions;
|
|
243
|
+
_this.tokenData.permissions = permissions;
|
|
244
|
+
_this.storeTokenData(_this.tokenData);
|
|
245
|
+
return response;
|
|
246
|
+
});
|
|
283
247
|
options = {
|
|
284
248
|
method: 'POST',
|
|
285
249
|
url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
|
|
286
250
|
headers: {
|
|
287
251
|
'Content-Type': 'application/json',
|
|
288
|
-
Cookie: refreshToken,
|
|
289
252
|
},
|
|
290
253
|
data: { username: username },
|
|
291
254
|
withCredentials: true,
|
|
292
255
|
};
|
|
293
|
-
return [4 /*yield*/,
|
|
256
|
+
return [4 /*yield*/, refreshTokenAxios.request(options)];
|
|
294
257
|
case 1:
|
|
295
|
-
|
|
296
|
-
return [2 /*return*/,
|
|
258
|
+
response = _a.sent();
|
|
259
|
+
return [2 /*return*/, response.data];
|
|
297
260
|
}
|
|
298
261
|
});
|
|
299
262
|
});
|
|
300
263
|
};
|
|
301
|
-
BaseAPI.prototype.
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
264
|
+
BaseAPI.prototype.storeTokenData = function (tokenData) {
|
|
265
|
+
if (typeof window !== 'undefined') {
|
|
266
|
+
(0, common_1.defaultStorage)().set(TOKEN_DATA, tokenData);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
BaseAPI.prototype.loadTokenData = function () {
|
|
270
|
+
if (typeof window !== 'undefined') {
|
|
271
|
+
this.tokenData = (0, common_1.defaultStorage)().get(TOKEN_DATA) || {};
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
this.tokenData = {};
|
|
305
275
|
}
|
|
306
|
-
return '';
|
|
307
276
|
};
|
|
308
|
-
BaseAPI.prototype.
|
|
309
|
-
|
|
277
|
+
BaseAPI.prototype.cleanTokenData = function () {
|
|
278
|
+
this.storeTokenData(null);
|
|
310
279
|
};
|
|
311
280
|
BaseAPI.prototype.attachInterceptor = function (axios) {
|
|
312
281
|
var _this = this;
|
|
313
282
|
axios.interceptors.response.use(function (res) {
|
|
314
283
|
return res;
|
|
315
284
|
}, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
316
|
-
var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
|
|
317
|
-
return __generator(this, function (
|
|
318
|
-
switch (
|
|
285
|
+
var originalConfig, _a, tokenString, permissions, accessToken, _error_1, _b, tokenString, permissions, accessToken, _error_2;
|
|
286
|
+
return __generator(this, function (_c) {
|
|
287
|
+
switch (_c.label) {
|
|
319
288
|
case 0:
|
|
320
289
|
originalConfig = err.config;
|
|
321
|
-
if (!err.response) return [3 /*break*/, 5];
|
|
322
|
-
if (!(err.response.status === 401
|
|
290
|
+
if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
|
|
291
|
+
if (!((err.response.status === 401 || err.response.status === 403)
|
|
292
|
+
&& !originalConfig._retry)) return [3 /*break*/, 4];
|
|
323
293
|
originalConfig._retry = true;
|
|
324
|
-
|
|
294
|
+
_c.label = 1;
|
|
325
295
|
case 1:
|
|
326
|
-
|
|
296
|
+
_c.trys.push([1, 3, , 4]);
|
|
327
297
|
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
328
298
|
case 2:
|
|
329
|
-
|
|
299
|
+
_a = _c.sent(), tokenString = _a.accessToken, permissions = _a.permissions;
|
|
330
300
|
accessToken = "Bearer ".concat(tokenString);
|
|
331
|
-
|
|
301
|
+
this.tokenData.permissions = permissions;
|
|
302
|
+
delete originalConfig.headers['Authorization'];
|
|
303
|
+
originalConfig.headers['Authorization'] = accessToken;
|
|
332
304
|
this.configuration.accessToken = accessToken;
|
|
333
|
-
|
|
305
|
+
this.tokenData.accessToken = tokenString;
|
|
306
|
+
this.storeTokenData(this.tokenData);
|
|
307
|
+
return [2 /*return*/, axios(originalConfig)];
|
|
334
308
|
case 3:
|
|
335
|
-
_error_1 =
|
|
309
|
+
_error_1 = _c.sent();
|
|
336
310
|
if (_error_1.response && _error_1.response.data) {
|
|
337
311
|
return [2 /*return*/, Promise.reject(_error_1.response.data)];
|
|
338
312
|
}
|
|
339
313
|
return [2 /*return*/, Promise.reject(_error_1)];
|
|
340
|
-
case 4:
|
|
341
|
-
if (err.response.status === 403 && err.response.data) {
|
|
342
|
-
return [2 /*return*/, Promise.reject(err.response.data)];
|
|
343
|
-
}
|
|
344
|
-
return [3 /*break*/, 9];
|
|
314
|
+
case 4: return [3 /*break*/, 9];
|
|
345
315
|
case 5:
|
|
346
316
|
if (!(err.message === NETWORK_ERROR_MESSAGE
|
|
347
|
-
&& err.isAxiosError
|
|
348
317
|
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
349
318
|
&& _retry_count < 4)) return [3 /*break*/, 9];
|
|
350
319
|
_retry_count++;
|
|
351
|
-
|
|
320
|
+
_c.label = 6;
|
|
352
321
|
case 6:
|
|
353
|
-
|
|
322
|
+
_c.trys.push([6, 8, , 9]);
|
|
354
323
|
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
355
324
|
case 7:
|
|
356
|
-
|
|
325
|
+
_b = _c.sent(), tokenString = _b.accessToken, permissions = _b.permissions;
|
|
357
326
|
accessToken = "Bearer ".concat(tokenString);
|
|
327
|
+
this.tokenData.permissions = permissions;
|
|
358
328
|
_retry = true;
|
|
359
329
|
originalConfig.headers['Authorization'] = accessToken;
|
|
360
330
|
this.configuration.accessToken = accessToken;
|
|
331
|
+
this.tokenData.accessToken = tokenString;
|
|
332
|
+
this.storeTokenData(this.tokenData);
|
|
361
333
|
return [2 /*return*/, axios.request(__assign({}, originalConfig))];
|
|
362
334
|
case 8:
|
|
363
|
-
_error_2 =
|
|
335
|
+
_error_2 = _c.sent();
|
|
364
336
|
if (_error_2.response && _error_2.response.data) {
|
|
365
337
|
return [2 /*return*/, Promise.reject(_error_2.response.data)];
|
|
366
338
|
}
|
package/dist/common.d.ts
CHANGED
package/dist/common.js
CHANGED
|
@@ -62,7 +62,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
62
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
63
|
exports.defaultStorage = exports.LocalStorage = exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
|
|
64
64
|
var base_1 = require("./base");
|
|
65
|
-
var url_1 = require("url");
|
|
66
65
|
/**
|
|
67
66
|
*
|
|
68
67
|
* @export
|
|
@@ -141,7 +140,7 @@ var setBearerAuthToObject = function (object, configuration) {
|
|
|
141
140
|
_b.label = 4;
|
|
142
141
|
case 4:
|
|
143
142
|
accessToken = _a;
|
|
144
|
-
object["Authorization"] =
|
|
143
|
+
object["Authorization"] = configuration.getBearerToken(accessToken);
|
|
145
144
|
_b.label = 5;
|
|
146
145
|
case 5: return [2 /*return*/];
|
|
147
146
|
}
|
|
@@ -171,7 +170,7 @@ var setOAuthToObject = function (object, name, scopes, configuration) {
|
|
|
171
170
|
_b.label = 4;
|
|
172
171
|
case 4:
|
|
173
172
|
localVarAccessTokenValue = _a;
|
|
174
|
-
object["Authorization"] =
|
|
173
|
+
object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
|
|
175
174
|
_b.label = 5;
|
|
176
175
|
case 5: return [2 /*return*/];
|
|
177
176
|
}
|
|
@@ -188,7 +187,7 @@ var setSearchParams = function (url) {
|
|
|
188
187
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
189
188
|
objects[_i - 1] = arguments[_i];
|
|
190
189
|
}
|
|
191
|
-
var searchParams = new
|
|
190
|
+
var searchParams = new URLSearchParams(url.search);
|
|
192
191
|
for (var _a = 0, objects_1 = objects; _a < objects_1.length; _a++) {
|
|
193
192
|
var object = objects_1[_a];
|
|
194
193
|
for (var key in object) {
|
package/dist/configuration.d.ts
CHANGED
|
@@ -68,13 +68,6 @@ export declare class Configuration {
|
|
|
68
68
|
* @type {new () => FormData}
|
|
69
69
|
*/
|
|
70
70
|
formDataCtor?: new () => any;
|
|
71
|
-
/**
|
|
72
|
-
* parameter for automatically refreshing access token for oauth2 security
|
|
73
|
-
*
|
|
74
|
-
* @type {string}
|
|
75
|
-
* @memberof Configuration
|
|
76
|
-
*/
|
|
77
|
-
refreshToken?: string;
|
|
78
71
|
constructor(param?: ConfigurationParameters);
|
|
79
72
|
/**
|
|
80
73
|
* Check if the given MIME is a JSON MIME.
|
|
@@ -87,4 +80,10 @@ export declare class Configuration {
|
|
|
87
80
|
* @return True if the given MIME is JSON, false otherwise.
|
|
88
81
|
*/
|
|
89
82
|
isJsonMime(mime: string): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Returns "Bearer" token.
|
|
85
|
+
* @param token - access token.
|
|
86
|
+
* @return Bearer token.
|
|
87
|
+
*/
|
|
88
|
+
getBearerToken(token?: string): string;
|
|
90
89
|
}
|
package/dist/configuration.js
CHANGED
|
@@ -39,6 +39,14 @@ var Configuration = /** @class */ (function () {
|
|
|
39
39
|
var jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
40
40
|
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Returns "Bearer" token.
|
|
44
|
+
* @param token - access token.
|
|
45
|
+
* @return Bearer token.
|
|
46
|
+
*/
|
|
47
|
+
Configuration.prototype.getBearerToken = function (token) {
|
|
48
|
+
return ('' + token).startsWith("Bearer") ? token : "Bearer " + token;
|
|
49
|
+
};
|
|
42
50
|
return Configuration;
|
|
43
51
|
}());
|
|
44
52
|
exports.Configuration = Configuration;
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
export interface CreateProductLanguageRequestDto {
|
|
18
18
|
/**
|
|
19
|
-
* A slug is a human-readable, unique identifier, used to identify a resource
|
|
19
|
+
* A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
|
|
20
20
|
* @type {string}
|
|
21
21
|
* @memberof CreateProductLanguageRequestDto
|
|
22
22
|
*/
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMIL TranslationService
|
|
3
|
+
* The EMIL TranslationService API description
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0
|
|
6
|
+
* Contact: kontakt@emil.de
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import { ProductLanguageClass } from './product-language-class';
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @interface GetProductLanguageResponseClass
|
|
17
|
+
*/
|
|
18
|
+
export interface GetProductLanguageResponseClass {
|
|
19
|
+
/**
|
|
20
|
+
* The requested product language.
|
|
21
|
+
* @type {ProductLanguageClass}
|
|
22
|
+
* @memberof GetProductLanguageResponseClass
|
|
23
|
+
*/
|
|
24
|
+
'productLanguage': ProductLanguageClass;
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* EMIL TranslationService
|
|
6
|
+
* The EMIL TranslationService API description
|
|
7
|
+
*
|
|
8
|
+
* The version of the OpenAPI document: 1.0
|
|
9
|
+
* Contact: kontakt@emil.de
|
|
10
|
+
*
|
|
11
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
+
* https://openapi-generator.tech
|
|
13
|
+
* Do not edit the class manually.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './create-product-language-request-dto';
|
|
2
2
|
export * from './create-product-language-response-class';
|
|
3
|
+
export * from './get-product-language-response-class';
|
|
4
|
+
export * from './inline-response200';
|
|
5
|
+
export * from './inline-response503';
|
|
3
6
|
export * from './list-product-languages-response-class';
|
|
4
7
|
export * from './list-translations-response-class';
|
|
5
8
|
export * from './product-language-class';
|
package/dist/models/index.js
CHANGED
|
@@ -16,6 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-product-language-request-dto"), exports);
|
|
18
18
|
__exportStar(require("./create-product-language-response-class"), exports);
|
|
19
|
+
__exportStar(require("./get-product-language-response-class"), exports);
|
|
20
|
+
__exportStar(require("./inline-response200"), exports);
|
|
21
|
+
__exportStar(require("./inline-response503"), exports);
|
|
19
22
|
__exportStar(require("./list-product-languages-response-class"), exports);
|
|
20
23
|
__exportStar(require("./list-translations-response-class"), exports);
|
|
21
24
|
__exportStar(require("./product-language-class"), exports);
|