@emilgroup/translation-sdk 1.0.1-beta.4 → 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 +0 -3
- package/README.md +26 -9
- package/api/translation-api.ts +117 -141
- package/api.ts +4 -2
- package/base.ts +97 -140
- package/common.ts +3 -2
- package/configuration.ts +8 -9
- package/dist/api/translation-api.d.ts +106 -124
- package/dist/api/translation-api.js +93 -100
- package/dist/api.d.ts +0 -1
- package/dist/api.js +0 -1
- package/dist/base.d.ts +13 -22
- package/dist/base.js +153 -125
- package/dist/common.d.ts +1 -0
- package/dist/common.js +4 -3
- package/dist/configuration.d.ts +7 -6
- package/dist/configuration.js +0 -8
- package/dist/models/create-product-language-request-dto.d.ts +1 -1
- package/dist/models/index.d.ts +0 -2
- package/dist/models/index.js +0 -2
- package/dist/models/product-language-class.d.ts +4 -4
- package/models/create-product-language-request-dto.ts +1 -1
- package/models/index.ts +0 -2
- package/models/product-language-class.ts +4 -4
- package/package.json +5 -2
- package/tsconfig.json +0 -1
- package/api/default-api.ts +0 -124
- package/dist/api/default-api.d.ts +0 -70
- package/dist/api/default-api.js +0 -200
- package/dist/models/inline-response200.d.ts +0 -54
- package/dist/models/inline-response200.js +0 -15
- package/dist/models/inline-response503.d.ts +0 -54
- package/dist/models/inline-response503.js +0 -15
- package/models/inline-response200.ts +0 -48
- package/models/inline-response503.ts +0 -48
package/dist/base.d.ts
CHANGED
|
@@ -24,22 +24,12 @@ export declare const COLLECTION_FORMATS: {
|
|
|
24
24
|
};
|
|
25
25
|
export interface LoginClass {
|
|
26
26
|
accessToken: string;
|
|
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;
|
|
27
|
+
permissions: Array<string>;
|
|
36
28
|
}
|
|
37
29
|
export declare enum Environment {
|
|
38
30
|
Production = "https://apiv2.emil.de",
|
|
39
31
|
Test = "https://apiv2-test.emil.de",
|
|
40
|
-
|
|
41
|
-
Development = "https://apiv2-dev.emil.de",
|
|
42
|
-
ProductionZurich = "https://eu-central-2.apiv2.emil.de"
|
|
32
|
+
Development = "https://apiv2-dev.emil.de"
|
|
43
33
|
}
|
|
44
34
|
export declare function resetRetry(): void;
|
|
45
35
|
/**
|
|
@@ -59,18 +49,19 @@ export interface RequestArgs {
|
|
|
59
49
|
export declare class BaseAPI {
|
|
60
50
|
protected basePath: string;
|
|
61
51
|
protected axios: AxiosInstance;
|
|
62
|
-
protected configuration: Configuration
|
|
63
|
-
private
|
|
52
|
+
protected configuration: Configuration;
|
|
53
|
+
private username?;
|
|
54
|
+
private password?;
|
|
64
55
|
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
56
|
+
initialize(env?: Environment): Promise<void>;
|
|
57
|
+
private loadCredentials;
|
|
58
|
+
private readConfigFile;
|
|
59
|
+
private readEnvVariables;
|
|
65
60
|
selectEnvironment(env: Environment): void;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
refreshTokenInternal(): Promise<LoginClass>;
|
|
71
|
-
private storeTokenData;
|
|
72
|
-
loadTokenData(): void;
|
|
73
|
-
cleanTokenData(): void;
|
|
61
|
+
authorize(username: string, password: string): Promise<void>;
|
|
62
|
+
refreshTokenInternal(): Promise<string>;
|
|
63
|
+
private extractRefreshToken;
|
|
64
|
+
getConfiguration(): Configuration;
|
|
74
65
|
private attachInterceptor;
|
|
75
66
|
}
|
|
76
67
|
/**
|
package/dist/base.js
CHANGED
|
@@ -38,6 +38,29 @@ 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
|
+
};
|
|
41
64
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
42
65
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
66
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -80,11 +103,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
80
103
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
104
|
exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
|
|
82
105
|
var configuration_1 = require("./configuration");
|
|
83
|
-
var common_1 = require("./common");
|
|
84
106
|
// Some imports not used depending on template conditions
|
|
85
107
|
// @ts-ignore
|
|
86
108
|
var axios_1 = __importDefault(require("axios"));
|
|
109
|
+
var fs = __importStar(require("fs"));
|
|
110
|
+
var path = __importStar(require("path"));
|
|
111
|
+
var os = __importStar(require("os"));
|
|
87
112
|
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;
|
|
88
118
|
/**
|
|
89
119
|
*
|
|
90
120
|
* @export
|
|
@@ -99,9 +129,7 @@ var Environment;
|
|
|
99
129
|
(function (Environment) {
|
|
100
130
|
Environment["Production"] = "https://apiv2.emil.de";
|
|
101
131
|
Environment["Test"] = "https://apiv2-test.emil.de";
|
|
102
|
-
Environment["Staging"] = "https://apiv2-staging.emil.de";
|
|
103
132
|
Environment["Development"] = "https://apiv2-dev.emil.de";
|
|
104
|
-
Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
|
|
105
133
|
})(Environment = exports.Environment || (exports.Environment = {}));
|
|
106
134
|
var _retry_count = 0;
|
|
107
135
|
var _retry = null;
|
|
@@ -110,7 +138,6 @@ function resetRetry() {
|
|
|
110
138
|
}
|
|
111
139
|
exports.resetRetry = resetRetry;
|
|
112
140
|
var NETWORK_ERROR_MESSAGE = "Network Error";
|
|
113
|
-
var TOKEN_DATA = 'APP_TOKEN';
|
|
114
141
|
/**
|
|
115
142
|
*
|
|
116
143
|
* @export
|
|
@@ -122,105 +149,122 @@ var BaseAPI = /** @class */ (function () {
|
|
|
122
149
|
if (axios === void 0) { axios = axios_1.default; }
|
|
123
150
|
this.basePath = basePath;
|
|
124
151
|
this.axios = axios;
|
|
125
|
-
this.loadTokenData();
|
|
126
152
|
if (configuration) {
|
|
127
|
-
var accessToken = this.tokenData.accessToken;
|
|
128
153
|
this.configuration = configuration;
|
|
129
154
|
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;
|
|
134
155
|
}
|
|
135
156
|
else {
|
|
136
|
-
var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
|
|
137
157
|
this.configuration = new configuration_1.Configuration({
|
|
138
158
|
basePath: this.basePath,
|
|
139
|
-
accessToken: accessToken ? "Bearer ".concat(accessToken) : '',
|
|
140
|
-
username: username,
|
|
141
159
|
});
|
|
142
160
|
}
|
|
143
161
|
this.attachInterceptor(axios);
|
|
144
162
|
}
|
|
145
|
-
BaseAPI.prototype.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
163
|
+
BaseAPI.prototype.initialize = function (env) {
|
|
164
|
+
if (env === void 0) { env = Environment.Production; }
|
|
165
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
+
return __generator(this, function (_a) {
|
|
167
|
+
switch (_a.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
this.configuration.basePath = env;
|
|
170
|
+
return [4 /*yield*/, this.loadCredentials()];
|
|
171
|
+
case 1:
|
|
172
|
+
_a.sent();
|
|
173
|
+
if (!this.username) return [3 /*break*/, 3];
|
|
174
|
+
return [4 /*yield*/, this.authorize(this.username, this.password)];
|
|
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
|
+
});
|
|
157
183
|
};
|
|
158
|
-
BaseAPI.prototype.
|
|
184
|
+
BaseAPI.prototype.loadCredentials = function () {
|
|
159
185
|
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
var
|
|
161
|
-
return __generator(this, function (
|
|
162
|
-
switch (
|
|
186
|
+
var error_1;
|
|
187
|
+
return __generator(this, function (_a) {
|
|
188
|
+
switch (_a.label) {
|
|
163
189
|
case 0:
|
|
164
|
-
|
|
165
|
-
|
|
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)];
|
|
190
|
+
_a.trys.push([0, 2, , 3]);
|
|
191
|
+
return [4 /*yield*/, this.readConfigFile()];
|
|
175
192
|
case 1:
|
|
176
|
-
|
|
177
|
-
|
|
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)];
|
|
193
|
+
_a.sent();
|
|
194
|
+
return [3 /*break*/, 3];
|
|
185
195
|
case 2:
|
|
186
|
-
|
|
187
|
-
|
|
196
|
+
error_1 = _a.sent();
|
|
197
|
+
console.warn("No credentials file found. Check that ".concat(filePath, " exists."));
|
|
198
|
+
return [3 /*break*/, 3];
|
|
188
199
|
case 3:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
this.readEnvVariables();
|
|
201
|
+
if (!this.username) {
|
|
202
|
+
console.info("No credentials found in credentials file or environment variables. Either provide some or use \n authorize() function.");
|
|
203
|
+
}
|
|
204
|
+
return [2 /*return*/];
|
|
193
205
|
}
|
|
194
206
|
});
|
|
195
207
|
});
|
|
196
208
|
};
|
|
197
|
-
BaseAPI.prototype.
|
|
209
|
+
BaseAPI.prototype.readConfigFile = function () {
|
|
198
210
|
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
|
|
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*/];
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
BaseAPI.prototype.readEnvVariables = function () {
|
|
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) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
var options, response, accessToken, refreshToken;
|
|
247
|
+
return __generator(this, function (_a) {
|
|
248
|
+
switch (_a.label) {
|
|
202
249
|
case 0:
|
|
203
250
|
options = {
|
|
204
251
|
method: 'POST',
|
|
205
|
-
url: "".concat(this.configuration.basePath, "/authservice/v1/
|
|
206
|
-
headers: {
|
|
207
|
-
'Content-Type': 'application/json',
|
|
208
|
-
'Authorization': "Bearer ".concat(this.configuration.accessToken),
|
|
209
|
-
},
|
|
252
|
+
url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
|
|
253
|
+
headers: { 'Content-Type': 'application/json' },
|
|
210
254
|
data: {
|
|
211
|
-
username:
|
|
212
|
-
|
|
255
|
+
username: username,
|
|
256
|
+
password: password,
|
|
213
257
|
},
|
|
214
258
|
withCredentials: true,
|
|
215
259
|
};
|
|
216
260
|
return [4 /*yield*/, axios_1.default.request(options)];
|
|
217
261
|
case 1:
|
|
218
|
-
response =
|
|
219
|
-
|
|
262
|
+
response = _a.sent();
|
|
263
|
+
accessToken = response.data.accessToken;
|
|
264
|
+
this.configuration.username = username;
|
|
220
265
|
this.configuration.accessToken = "Bearer ".concat(accessToken);
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
this.storeTokenData(__assign({}, this.tokenData));
|
|
266
|
+
refreshToken = this.extractRefreshToken(response);
|
|
267
|
+
this.configuration.refreshToken = refreshToken;
|
|
224
268
|
return [2 /*return*/];
|
|
225
269
|
}
|
|
226
270
|
});
|
|
@@ -228,111 +272,95 @@ var BaseAPI = /** @class */ (function () {
|
|
|
228
272
|
};
|
|
229
273
|
BaseAPI.prototype.refreshTokenInternal = function () {
|
|
230
274
|
return __awaiter(this, void 0, void 0, function () {
|
|
231
|
-
var username,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
switch (_a.label) {
|
|
275
|
+
var _a, username, refreshToken, options, accessToken;
|
|
276
|
+
return __generator(this, function (_b) {
|
|
277
|
+
switch (_b.label) {
|
|
235
278
|
case 0:
|
|
236
|
-
|
|
237
|
-
if (!username) {
|
|
238
|
-
|
|
279
|
+
_a = this.configuration, username = _a.username, refreshToken = _a.refreshToken;
|
|
280
|
+
if (!username || !refreshToken) {
|
|
281
|
+
return [2 /*return*/, ''];
|
|
239
282
|
}
|
|
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
|
-
});
|
|
247
283
|
options = {
|
|
248
284
|
method: 'POST',
|
|
249
285
|
url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
|
|
250
286
|
headers: {
|
|
251
287
|
'Content-Type': 'application/json',
|
|
288
|
+
Cookie: refreshToken,
|
|
252
289
|
},
|
|
253
290
|
data: { username: username },
|
|
254
291
|
withCredentials: true,
|
|
255
292
|
};
|
|
256
|
-
return [4 /*yield*/,
|
|
293
|
+
return [4 /*yield*/, axios_1.default.request(options)];
|
|
257
294
|
case 1:
|
|
258
|
-
|
|
259
|
-
return [2 /*return*/,
|
|
295
|
+
accessToken = (_b.sent()).data.accessToken;
|
|
296
|
+
return [2 /*return*/, accessToken];
|
|
260
297
|
}
|
|
261
298
|
});
|
|
262
299
|
});
|
|
263
300
|
};
|
|
264
|
-
BaseAPI.prototype.
|
|
265
|
-
if (
|
|
266
|
-
|
|
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 = {};
|
|
301
|
+
BaseAPI.prototype.extractRefreshToken = function (response) {
|
|
302
|
+
if (response.headers && response.headers['set-cookie']
|
|
303
|
+
&& response.headers['set-cookie'].length > 0) {
|
|
304
|
+
return "".concat(response.headers['set-cookie'][0].split(';')[0], ";");
|
|
275
305
|
}
|
|
306
|
+
return '';
|
|
276
307
|
};
|
|
277
|
-
BaseAPI.prototype.
|
|
278
|
-
this.
|
|
308
|
+
BaseAPI.prototype.getConfiguration = function () {
|
|
309
|
+
return this.configuration;
|
|
279
310
|
};
|
|
280
311
|
BaseAPI.prototype.attachInterceptor = function (axios) {
|
|
281
312
|
var _this = this;
|
|
282
313
|
axios.interceptors.response.use(function (res) {
|
|
283
314
|
return res;
|
|
284
315
|
}, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
|
285
|
-
var originalConfig,
|
|
286
|
-
return __generator(this, function (
|
|
287
|
-
switch (
|
|
316
|
+
var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
|
|
317
|
+
return __generator(this, function (_a) {
|
|
318
|
+
switch (_a.label) {
|
|
288
319
|
case 0:
|
|
289
320
|
originalConfig = err.config;
|
|
290
|
-
if (!
|
|
291
|
-
if (!(
|
|
292
|
-
&& !originalConfig._retry)) return [3 /*break*/, 4];
|
|
321
|
+
if (!err.response) return [3 /*break*/, 5];
|
|
322
|
+
if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
|
|
293
323
|
originalConfig._retry = true;
|
|
294
|
-
|
|
324
|
+
_a.label = 1;
|
|
295
325
|
case 1:
|
|
296
|
-
|
|
326
|
+
_a.trys.push([1, 3, , 4]);
|
|
297
327
|
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
298
328
|
case 2:
|
|
299
|
-
|
|
329
|
+
tokenString = _a.sent();
|
|
300
330
|
accessToken = "Bearer ".concat(tokenString);
|
|
301
|
-
|
|
302
|
-
delete originalConfig.headers['Authorization'];
|
|
303
|
-
originalConfig.headers['Authorization'] = accessToken;
|
|
331
|
+
originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
|
|
304
332
|
this.configuration.accessToken = accessToken;
|
|
305
|
-
|
|
306
|
-
this.storeTokenData(this.tokenData);
|
|
307
|
-
return [2 /*return*/, axios(originalConfig)];
|
|
333
|
+
return [2 /*return*/, axios.request(originalConfig)];
|
|
308
334
|
case 3:
|
|
309
|
-
_error_1 =
|
|
335
|
+
_error_1 = _a.sent();
|
|
310
336
|
if (_error_1.response && _error_1.response.data) {
|
|
311
337
|
return [2 /*return*/, Promise.reject(_error_1.response.data)];
|
|
312
338
|
}
|
|
313
339
|
return [2 /*return*/, Promise.reject(_error_1)];
|
|
314
|
-
case 4:
|
|
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];
|
|
315
345
|
case 5:
|
|
316
346
|
if (!(err.message === NETWORK_ERROR_MESSAGE
|
|
347
|
+
&& err.isAxiosError
|
|
317
348
|
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
318
349
|
&& _retry_count < 4)) return [3 /*break*/, 9];
|
|
319
350
|
_retry_count++;
|
|
320
|
-
|
|
351
|
+
_a.label = 6;
|
|
321
352
|
case 6:
|
|
322
|
-
|
|
353
|
+
_a.trys.push([6, 8, , 9]);
|
|
323
354
|
return [4 /*yield*/, this.refreshTokenInternal()];
|
|
324
355
|
case 7:
|
|
325
|
-
|
|
356
|
+
tokenString = _a.sent();
|
|
326
357
|
accessToken = "Bearer ".concat(tokenString);
|
|
327
|
-
this.tokenData.permissions = permissions;
|
|
328
358
|
_retry = true;
|
|
329
359
|
originalConfig.headers['Authorization'] = accessToken;
|
|
330
360
|
this.configuration.accessToken = accessToken;
|
|
331
|
-
this.tokenData.accessToken = tokenString;
|
|
332
|
-
this.storeTokenData(this.tokenData);
|
|
333
361
|
return [2 /*return*/, axios.request(__assign({}, originalConfig))];
|
|
334
362
|
case 8:
|
|
335
|
-
_error_2 =
|
|
363
|
+
_error_2 = _a.sent();
|
|
336
364
|
if (_error_2.response && _error_2.response.data) {
|
|
337
365
|
return [2 /*return*/, Promise.reject(_error_2.response.data)];
|
|
338
366
|
}
|
package/dist/common.d.ts
CHANGED
package/dist/common.js
CHANGED
|
@@ -62,6 +62,7 @@ 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");
|
|
65
66
|
/**
|
|
66
67
|
*
|
|
67
68
|
* @export
|
|
@@ -140,7 +141,7 @@ var setBearerAuthToObject = function (object, configuration) {
|
|
|
140
141
|
_b.label = 4;
|
|
141
142
|
case 4:
|
|
142
143
|
accessToken = _a;
|
|
143
|
-
object["Authorization"] =
|
|
144
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
144
145
|
_b.label = 5;
|
|
145
146
|
case 5: return [2 /*return*/];
|
|
146
147
|
}
|
|
@@ -170,7 +171,7 @@ var setOAuthToObject = function (object, name, scopes, configuration) {
|
|
|
170
171
|
_b.label = 4;
|
|
171
172
|
case 4:
|
|
172
173
|
localVarAccessTokenValue = _a;
|
|
173
|
-
object["Authorization"] =
|
|
174
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
174
175
|
_b.label = 5;
|
|
175
176
|
case 5: return [2 /*return*/];
|
|
176
177
|
}
|
|
@@ -187,7 +188,7 @@ var setSearchParams = function (url) {
|
|
|
187
188
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
188
189
|
objects[_i - 1] = arguments[_i];
|
|
189
190
|
}
|
|
190
|
-
var searchParams = new URLSearchParams(url.search);
|
|
191
|
+
var searchParams = new url_1.URLSearchParams(url.search);
|
|
191
192
|
for (var _a = 0, objects_1 = objects; _a < objects_1.length; _a++) {
|
|
192
193
|
var object = objects_1[_a];
|
|
193
194
|
for (var key in object) {
|
package/dist/configuration.d.ts
CHANGED
|
@@ -68,6 +68,13 @@ 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;
|
|
71
78
|
constructor(param?: ConfigurationParameters);
|
|
72
79
|
/**
|
|
73
80
|
* Check if the given MIME is a JSON MIME.
|
|
@@ -80,10 +87,4 @@ export declare class Configuration {
|
|
|
80
87
|
* @return True if the given MIME is JSON, false otherwise.
|
|
81
88
|
*/
|
|
82
89
|
isJsonMime(mime: string): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Returns "Bearer" token.
|
|
85
|
-
* @param token - access token.
|
|
86
|
-
* @return Bearer token.
|
|
87
|
-
*/
|
|
88
|
-
getBearerToken(token?: string): string;
|
|
89
90
|
}
|
package/dist/configuration.js
CHANGED
|
@@ -39,14 +39,6 @@ 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
|
-
};
|
|
50
42
|
return Configuration;
|
|
51
43
|
}());
|
|
52
44
|
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
|
*/
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './create-product-language-request-dto';
|
|
2
2
|
export * from './create-product-language-response-class';
|
|
3
3
|
export * from './get-product-language-response-class';
|
|
4
|
-
export * from './inline-response200';
|
|
5
|
-
export * from './inline-response503';
|
|
6
4
|
export * from './list-product-languages-response-class';
|
|
7
5
|
export * from './list-translations-response-class';
|
|
8
6
|
export * from './product-language-class';
|
package/dist/models/index.js
CHANGED
|
@@ -17,8 +17,6 @@ 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
19
|
__exportStar(require("./get-product-language-response-class"), exports);
|
|
20
|
-
__exportStar(require("./inline-response200"), exports);
|
|
21
|
-
__exportStar(require("./inline-response503"), exports);
|
|
22
20
|
__exportStar(require("./list-product-languages-response-class"), exports);
|
|
23
21
|
__exportStar(require("./list-translations-response-class"), exports);
|
|
24
22
|
__exportStar(require("./product-language-class"), exports);
|
|
@@ -22,7 +22,7 @@ export interface ProductLanguageClass {
|
|
|
22
22
|
*/
|
|
23
23
|
'id': number;
|
|
24
24
|
/**
|
|
25
|
-
* A slug is a human-readable, unique identifier, used to identify a resource
|
|
25
|
+
* A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
|
|
26
26
|
* @type {string}
|
|
27
27
|
* @memberof ProductLanguageClass
|
|
28
28
|
*/
|
|
@@ -40,11 +40,11 @@ export interface ProductLanguageClass {
|
|
|
40
40
|
*/
|
|
41
41
|
'isActive': boolean;
|
|
42
42
|
/**
|
|
43
|
-
* The translation status. It tells if the language is ready to be used in the product
|
|
44
|
-
* @type {
|
|
43
|
+
* The translation status. It tells if the language is ready to be used in the product. Can be null in the default language.
|
|
44
|
+
* @type {string}
|
|
45
45
|
* @memberof ProductLanguageClass
|
|
46
46
|
*/
|
|
47
|
-
'translationStatus':
|
|
47
|
+
'translationStatus': string | null;
|
|
48
48
|
/**
|
|
49
49
|
* Time at which the object was created.
|
|
50
50
|
* @type {string}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export interface CreateProductLanguageRequestDto {
|
|
23
23
|
/**
|
|
24
|
-
* A slug is a human-readable, unique identifier, used to identify a resource
|
|
24
|
+
* A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
|
|
25
25
|
* @type {string}
|
|
26
26
|
* @memberof CreateProductLanguageRequestDto
|
|
27
27
|
*/
|
package/models/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './create-product-language-request-dto';
|
|
2
2
|
export * from './create-product-language-response-class';
|
|
3
3
|
export * from './get-product-language-response-class';
|
|
4
|
-
export * from './inline-response200';
|
|
5
|
-
export * from './inline-response503';
|
|
6
4
|
export * from './list-product-languages-response-class';
|
|
7
5
|
export * from './list-translations-response-class';
|
|
8
6
|
export * from './product-language-class';
|
|
@@ -27,7 +27,7 @@ export interface ProductLanguageClass {
|
|
|
27
27
|
*/
|
|
28
28
|
'id': number;
|
|
29
29
|
/**
|
|
30
|
-
* A slug is a human-readable, unique identifier, used to identify a resource
|
|
30
|
+
* A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
|
|
31
31
|
* @type {string}
|
|
32
32
|
* @memberof ProductLanguageClass
|
|
33
33
|
*/
|
|
@@ -45,11 +45,11 @@ export interface ProductLanguageClass {
|
|
|
45
45
|
*/
|
|
46
46
|
'isActive': boolean;
|
|
47
47
|
/**
|
|
48
|
-
* The translation status. It tells if the language is ready to be used in the product
|
|
49
|
-
* @type {
|
|
48
|
+
* The translation status. It tells if the language is ready to be used in the product. Can be null in the default language.
|
|
49
|
+
* @type {string}
|
|
50
50
|
* @memberof ProductLanguageClass
|
|
51
51
|
*/
|
|
52
|
-
'translationStatus':
|
|
52
|
+
'translationStatus': string | null;
|
|
53
53
|
/**
|
|
54
54
|
* Time at which the object was created.
|
|
55
55
|
* @type {string}
|