@emilgroup/translation-sdk-node 1.1.0 → 1.21.1-beta.105

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/dist/base.js CHANGED
@@ -129,7 +129,9 @@ var Environment;
129
129
  (function (Environment) {
130
130
  Environment["Production"] = "https://apiv2.emil.de";
131
131
  Environment["Test"] = "https://apiv2-test.emil.de";
132
+ Environment["Staging"] = "https://apiv2-staging.emil.de";
132
133
  Environment["Development"] = "https://apiv2-dev.emil.de";
134
+ Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
133
135
  })(Environment = exports.Environment || (exports.Environment = {}));
134
136
  var _retry_count = 0;
135
137
  var _retry = null;
@@ -160,7 +162,7 @@ var BaseAPI = /** @class */ (function () {
160
162
  }
161
163
  this.attachInterceptor(axios);
162
164
  }
163
- BaseAPI.prototype.initialize = function (env) {
165
+ BaseAPI.prototype.initialize = function (env, targetWorkspace) {
164
166
  if (env === void 0) { env = Environment.Production; }
165
167
  return __awaiter(this, void 0, void 0, function () {
166
168
  return __generator(this, function (_a) {
@@ -171,7 +173,7 @@ var BaseAPI = /** @class */ (function () {
171
173
  case 1:
172
174
  _a.sent();
173
175
  if (!this.username) return [3 /*break*/, 3];
174
- return [4 /*yield*/, this.authorize(this.username, this.password)];
176
+ return [4 /*yield*/, this.authorize(this.username, this.password, targetWorkspace)];
175
177
  case 2:
176
178
  _a.sent();
177
179
  this.password = null; // to avoid keeping password loaded in memory.
@@ -241,7 +243,7 @@ var BaseAPI = /** @class */ (function () {
241
243
  BaseAPI.prototype.selectEnvironment = function (env) {
242
244
  this.configuration.basePath = env;
243
245
  };
244
- BaseAPI.prototype.authorize = function (username, password) {
246
+ BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
245
247
  return __awaiter(this, void 0, void 0, function () {
246
248
  var options, response, accessToken, refreshToken;
247
249
  return __generator(this, function (_a) {
@@ -265,6 +267,45 @@ var BaseAPI = /** @class */ (function () {
265
267
  this.configuration.accessToken = "Bearer ".concat(accessToken);
266
268
  refreshToken = this.extractRefreshToken(response);
267
269
  this.configuration.refreshToken = refreshToken;
270
+ if (!targetWorkspace) return [3 /*break*/, 3];
271
+ return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
272
+ case 2:
273
+ _a.sent();
274
+ _a.label = 3;
275
+ case 3: return [2 /*return*/];
276
+ }
277
+ });
278
+ });
279
+ };
280
+ BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
281
+ return __awaiter(this, void 0, void 0, function () {
282
+ var options, response, accessToken, refreshToken;
283
+ return __generator(this, function (_a) {
284
+ switch (_a.label) {
285
+ case 0:
286
+ options = {
287
+ method: 'POST',
288
+ url: "".concat(this.configuration.basePath, "/authservice/v1/workspaces/switch"),
289
+ headers: {
290
+ 'Content-Type': 'application/json',
291
+ 'Authorization': "Bearer ".concat(this.configuration.accessToken),
292
+ 'Cookie': this.configuration.refreshToken,
293
+ },
294
+ data: {
295
+ username: this.configuration.username,
296
+ targetWorkspace: targetWorkspace,
297
+ },
298
+ withCredentials: true,
299
+ };
300
+ return [4 /*yield*/, axios_1.default.request(options)];
301
+ case 1:
302
+ response = _a.sent();
303
+ accessToken = response.data.accessToken;
304
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
305
+ refreshToken = this.extractRefreshToken(response);
306
+ if (refreshToken) {
307
+ this.configuration.refreshToken = refreshToken;
308
+ }
268
309
  return [2 /*return*/];
269
310
  }
270
311
  });
@@ -328,7 +369,7 @@ var BaseAPI = /** @class */ (function () {
328
369
  case 2:
329
370
  tokenString = _a.sent();
330
371
  accessToken = "Bearer ".concat(tokenString);
331
- originalConfig.headers['Authorization'] = "Bearer ".concat(accessToken);
372
+ originalConfig.headers['Authorization'] = accessToken;
332
373
  this.configuration.accessToken = accessToken;
333
374
  return [2 /*return*/, axios.request(originalConfig)];
334
375
  case 3:
package/dist/common.js CHANGED
@@ -141,7 +141,7 @@ var setBearerAuthToObject = function (object, configuration) {
141
141
  _b.label = 4;
142
142
  case 4:
143
143
  accessToken = _a;
144
- object["Authorization"] = "Bearer " + accessToken;
144
+ object["Authorization"] = configuration.getBearerToken(accessToken);
145
145
  _b.label = 5;
146
146
  case 5: return [2 /*return*/];
147
147
  }
@@ -171,7 +171,7 @@ var setOAuthToObject = function (object, name, scopes, configuration) {
171
171
  _b.label = 4;
172
172
  case 4:
173
173
  localVarAccessTokenValue = _a;
174
- object["Authorization"] = "Bearer " + localVarAccessTokenValue;
174
+ object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
175
175
  _b.label = 5;
176
176
  case 5: return [2 /*return*/];
177
177
  }
@@ -87,4 +87,10 @@ export declare class Configuration {
87
87
  * @return True if the given MIME is JSON, false otherwise.
88
88
  */
89
89
  isJsonMime(mime: string): boolean;
90
+ /**
91
+ * Returns "Bearer" token.
92
+ * @param token - access token.
93
+ * @return Bearer token.
94
+ */
95
+ getBearerToken(token?: string): string;
90
96
  }
@@ -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 instead of a less human-readable identifier like an id.
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
  */
@@ -1,6 +1,8 @@
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';
4
6
  export * from './list-product-languages-response-class';
5
7
  export * from './list-translations-response-class';
6
8
  export * from './product-language-class';
@@ -17,6 +17,8 @@ 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);
20
22
  __exportStar(require("./list-product-languages-response-class"), exports);
21
23
  __exportStar(require("./list-translations-response-class"), exports);
22
24
  __exportStar(require("./product-language-class"), exports);
@@ -0,0 +1,54 @@
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
+ /**
13
+ *
14
+ * @export
15
+ * @interface InlineResponse200
16
+ */
17
+ export interface InlineResponse200 {
18
+ /**
19
+ *
20
+ * @type {string}
21
+ * @memberof InlineResponse200
22
+ */
23
+ 'status'?: string;
24
+ /**
25
+ *
26
+ * @type {{ [key: string]: { [key: string]: object; }; }}
27
+ * @memberof InlineResponse200
28
+ */
29
+ 'info'?: {
30
+ [key: string]: {
31
+ [key: string]: object;
32
+ };
33
+ } | null;
34
+ /**
35
+ *
36
+ * @type {{ [key: string]: { [key: string]: object; }; }}
37
+ * @memberof InlineResponse200
38
+ */
39
+ 'error'?: {
40
+ [key: string]: {
41
+ [key: string]: object;
42
+ };
43
+ } | null;
44
+ /**
45
+ *
46
+ * @type {{ [key: string]: { [key: string]: object; }; }}
47
+ * @memberof InlineResponse200
48
+ */
49
+ 'details'?: {
50
+ [key: string]: {
51
+ [key: string]: object;
52
+ };
53
+ };
54
+ }
@@ -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 });
@@ -0,0 +1,54 @@
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
+ /**
13
+ *
14
+ * @export
15
+ * @interface InlineResponse503
16
+ */
17
+ export interface InlineResponse503 {
18
+ /**
19
+ *
20
+ * @type {string}
21
+ * @memberof InlineResponse503
22
+ */
23
+ 'status'?: string;
24
+ /**
25
+ *
26
+ * @type {{ [key: string]: { [key: string]: object; }; }}
27
+ * @memberof InlineResponse503
28
+ */
29
+ 'info'?: {
30
+ [key: string]: {
31
+ [key: string]: object;
32
+ };
33
+ } | null;
34
+ /**
35
+ *
36
+ * @type {{ [key: string]: { [key: string]: object; }; }}
37
+ * @memberof InlineResponse503
38
+ */
39
+ 'error'?: {
40
+ [key: string]: {
41
+ [key: string]: object;
42
+ };
43
+ } | null;
44
+ /**
45
+ *
46
+ * @type {{ [key: string]: { [key: string]: object; }; }}
47
+ * @memberof InlineResponse503
48
+ */
49
+ 'details'?: {
50
+ [key: string]: {
51
+ [key: string]: object;
52
+ };
53
+ };
54
+ }
@@ -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 });
@@ -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 instead of a less human-readable identifier like an id.
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. Can be null in the default language.
44
- * @type {string}
43
+ * The translation status. It tells if the language is ready to be used in the product and how many fields are missing.
44
+ * @type {object}
45
45
  * @memberof ProductLanguageClass
46
46
  */
47
- 'translationStatus': string | null;
47
+ 'translationStatus': object | 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 instead of a less human-readable identifier like an id.
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,6 +1,8 @@
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';
4
6
  export * from './list-product-languages-response-class';
5
7
  export * from './list-translations-response-class';
6
8
  export * from './product-language-class';
@@ -0,0 +1,48 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL TranslationService
5
+ * The EMIL TranslationService 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
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface InlineResponse200
21
+ */
22
+ export interface InlineResponse200 {
23
+ /**
24
+ *
25
+ * @type {string}
26
+ * @memberof InlineResponse200
27
+ */
28
+ 'status'?: string;
29
+ /**
30
+ *
31
+ * @type {{ [key: string]: { [key: string]: object; }; }}
32
+ * @memberof InlineResponse200
33
+ */
34
+ 'info'?: { [key: string]: { [key: string]: object; }; } | null;
35
+ /**
36
+ *
37
+ * @type {{ [key: string]: { [key: string]: object; }; }}
38
+ * @memberof InlineResponse200
39
+ */
40
+ 'error'?: { [key: string]: { [key: string]: object; }; } | null;
41
+ /**
42
+ *
43
+ * @type {{ [key: string]: { [key: string]: object; }; }}
44
+ * @memberof InlineResponse200
45
+ */
46
+ 'details'?: { [key: string]: { [key: string]: object; }; };
47
+ }
48
+
@@ -0,0 +1,48 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL TranslationService
5
+ * The EMIL TranslationService 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
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface InlineResponse503
21
+ */
22
+ export interface InlineResponse503 {
23
+ /**
24
+ *
25
+ * @type {string}
26
+ * @memberof InlineResponse503
27
+ */
28
+ 'status'?: string;
29
+ /**
30
+ *
31
+ * @type {{ [key: string]: { [key: string]: object; }; }}
32
+ * @memberof InlineResponse503
33
+ */
34
+ 'info'?: { [key: string]: { [key: string]: object; }; } | null;
35
+ /**
36
+ *
37
+ * @type {{ [key: string]: { [key: string]: object; }; }}
38
+ * @memberof InlineResponse503
39
+ */
40
+ 'error'?: { [key: string]: { [key: string]: object; }; } | null;
41
+ /**
42
+ *
43
+ * @type {{ [key: string]: { [key: string]: object; }; }}
44
+ * @memberof InlineResponse503
45
+ */
46
+ 'details'?: { [key: string]: { [key: string]: object; }; };
47
+ }
48
+
@@ -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 instead of a less human-readable identifier like an id.
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. Can be null in the default language.
49
- * @type {string}
48
+ * The translation status. It tells if the language is ready to be used in the product and how many fields are missing.
49
+ * @type {object}
50
50
  * @memberof ProductLanguageClass
51
51
  */
52
- 'translationStatus': string | null;
52
+ 'translationStatus': object | null;
53
53
  /**
54
54
  * Time at which the object was created.
55
55
  * @type {string}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emilgroup/translation-sdk-node",
3
- "version": "1.1.0",
3
+ "version": "1.21.1-beta.105",
4
4
  "description": "OpenAPI client for @emilgroup/translation-sdk-node",
5
5
  "author": "OpenAPI-Generator Contributors",
6
6
  "keywords": [
@@ -23,7 +23,7 @@
23
23
  "url": "^0.11.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "^12.11.5",
26
+ "@types/node": "^12.11.5",
27
27
  "typescript": "^4.0"
28
28
  }
29
29
  }
package/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "module": "CommonJS",
6
6
  "noImplicitAny": true,
7
7
  "esModuleInterop": true,
8
+ "noImplicitOverride": true,
8
9
  "outDir": "dist",
9
10
  "rootDir": ".",
10
11
  "lib": [