@sambath999/localize-token 12.4.7 → 12.4.8
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/bundles/sambath999-localize-token.umd.js +26 -4
- package/bundles/sambath999-localize-token.umd.js.map +1 -1
- package/esm2015/localize-logindlg/localize-logindlg.module.js +1 -1
- package/esm2015/localize-logindlg/localize-logindlg.service.js +1 -1
- package/esm2015/localize-token/helpers/interfaces.js +1 -1
- package/esm2015/localize-token/helpers/loccalize.api.helper.js +25 -4
- package/esm2015/localize-token/localize.api.service.js +4 -3
- package/fesm2015/sambath999-localize-token.js +27 -5
- package/fesm2015/sambath999-localize-token.js.map +1 -1
- package/localize-token/helpers/interfaces.d.ts +1 -0
- package/localize-token/helpers/loccalize.api.helper.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1072,8 +1072,8 @@
|
|
|
1072
1072
|
});
|
|
1073
1073
|
});
|
|
1074
1074
|
};
|
|
1075
|
-
LocalizeApiHelper.prototype.createRequest = function (instance, method, url, body, options) {
|
|
1076
|
-
var request$ = instance.client.request(method, url, Object.assign(Object.assign({}, options), { body: body
|
|
1075
|
+
LocalizeApiHelper.prototype.createRequest = function (instance, method, url, body, options, onInvalidResponseBody) {
|
|
1076
|
+
var request$ = instance.client.request(method, url, Object.assign(Object.assign({}, options), { body: body })).pipe(rxjs.takeUntil(instance.destroy$()), rxjs.map(function (body) { return extractJsonFromResponse(body, onInvalidResponseBody); }), rxjs.catchError(function (error) {
|
|
1077
1077
|
// Convert to a non-observable error to handle in the promise
|
|
1078
1078
|
return rxjs.throwError(function () { return error; });
|
|
1079
1079
|
}));
|
|
@@ -1148,6 +1148,27 @@
|
|
|
1148
1148
|
};
|
|
1149
1149
|
return LocalizeApiHelper;
|
|
1150
1150
|
}());
|
|
1151
|
+
function extractJsonFromResponse(body, onError) {
|
|
1152
|
+
// If already an object, just return
|
|
1153
|
+
if (typeof body === 'object' && body !== null)
|
|
1154
|
+
return body;
|
|
1155
|
+
// If it's a string, try to extract JSON portion
|
|
1156
|
+
if (typeof body === 'string') {
|
|
1157
|
+
var firstBrace = body.indexOf('{');
|
|
1158
|
+
if (firstBrace !== -1) {
|
|
1159
|
+
var jsonString = body.substring(firstBrace);
|
|
1160
|
+
try {
|
|
1161
|
+
return JSON.parse(jsonString);
|
|
1162
|
+
}
|
|
1163
|
+
catch (e) {
|
|
1164
|
+
// If parsing fails, return original string
|
|
1165
|
+
onError === null || onError === void 0 ? void 0 : onError(body);
|
|
1166
|
+
return body;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return body;
|
|
1171
|
+
}
|
|
1151
1172
|
var ApiHelper = new LocalizeApiHelper();
|
|
1152
1173
|
|
|
1153
1174
|
var SCHEMES = LocalizeToken.httpHeaders;
|
|
@@ -1316,6 +1337,7 @@
|
|
|
1316
1337
|
});
|
|
1317
1338
|
};
|
|
1318
1339
|
LocalizeApiService.prototype.performRequest = function (options) {
|
|
1340
|
+
var _a;
|
|
1319
1341
|
return __awaiter(this, void 0, void 0, function () {
|
|
1320
1342
|
var buildOptions, request$, response;
|
|
1321
1343
|
var _this = this;
|
|
@@ -1326,10 +1348,10 @@
|
|
|
1326
1348
|
request$ = ApiHelper.createRequest({
|
|
1327
1349
|
client: this.httpClient,
|
|
1328
1350
|
destroy$: function () { return _this.destroy$; }
|
|
1329
|
-
}, options.method, options.requestUrl, options.requestBody, buildOptions);
|
|
1351
|
+
}, options.method, options.requestUrl, options.requestBody, buildOptions, (_a = this.config.onResponseBodyInvalid) === null || _a === void 0 ? void 0 : _a.bind(this));
|
|
1330
1352
|
// Set the isRequesting state to true before making the request
|
|
1331
1353
|
this.isRequestingSubject.next(true);
|
|
1332
|
-
return [4 /*yield*/, new Promise(function (resolve, reject) { return request$.subscribe({ next:
|
|
1354
|
+
return [4 /*yield*/, new Promise(function (resolve, reject) { return request$.subscribe({ next: resolve, error: reject }); })];
|
|
1333
1355
|
case 1:
|
|
1334
1356
|
response = _e.sent();
|
|
1335
1357
|
// Reset the isRequesting state after the request completes
|