@tolgee/cli 2.10.1 → 2.10.2
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/client/ApiClient.js +13 -2
- package/package.json +1 -1
package/dist/client/ApiClient.js
CHANGED
@@ -11,7 +11,7 @@ import createClient from 'openapi-fetch';
|
|
11
11
|
import base32Decode from 'base32-decode';
|
12
12
|
import { API_KEY_PAK_PREFIX, USER_AGENT } from '../constants.js';
|
13
13
|
import { getApiKeyInformation } from './getApiKeyInformation.js';
|
14
|
-
import { debug } from '../utils/logger.js';
|
14
|
+
import { debug, isDebugEnabled } from '../utils/logger.js';
|
15
15
|
import { errorFromLoadable } from './errorFromLoadable.js';
|
16
16
|
function parseResponse(response, parseAs) {
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -62,7 +62,18 @@ export function createApiClient({ baseUrl, apiKey, projectId, autoThrow = false,
|
|
62
62
|
debug(`[HTTP] Requesting: ${request.method} ${request.url}`);
|
63
63
|
},
|
64
64
|
onResponse: (_a) => __awaiter(this, [_a], void 0, function* ({ response, options }) {
|
65
|
-
|
65
|
+
let responseText = `[HTTP] Response: ${response.url} [${response.status}]`;
|
66
|
+
const apiVersion = response.headers.get('x-tolgee-version');
|
67
|
+
if (apiVersion) {
|
68
|
+
responseText += ` [${response.headers.get('x-tolgee-version')}]`;
|
69
|
+
}
|
70
|
+
if (!response.ok && isDebugEnabled()) {
|
71
|
+
const clonedBody = yield response.clone().text();
|
72
|
+
if (clonedBody) {
|
73
|
+
responseText += ` [${clonedBody}]`;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
debug(responseText);
|
66
77
|
if (autoThrow && !response.ok) {
|
67
78
|
const loadable = yield parseResponse(response, options.parseAs);
|
68
79
|
throw new Error(`Tolgee request error ${response.url} ${errorFromLoadable(loadable)}`);
|