@hapl/api-queries 1.0.19 → 1.0.20
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/api-queries.cjs.development.js +19 -2
- package/dist/api-queries.cjs.development.js.map +1 -1
- package/dist/api-queries.cjs.production.min.js +1 -1
- package/dist/api-queries.cjs.production.min.js.map +1 -1
- package/dist/api-queries.esm.js +19 -2
- package/dist/api-queries.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/clients/v1/api/file/uploadFile.ts +10 -2
- package/src/clients/v1/api/file/uploadFiles.ts +10 -2
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer, AxiosRequestConfig } from 'axios';
|
|
2
2
|
import isNil from 'lodash/isNil';
|
|
3
|
+
import isString from 'lodash/isString';
|
|
3
4
|
import { File } from '../../types';
|
|
4
5
|
import { DEFAULT_BASE_URL } from '../../../constants';
|
|
5
6
|
|
|
@@ -36,8 +37,15 @@ export function uploadFileRequest({ baseURL = DEFAULT_BASE_URL, body, headers, o
|
|
|
36
37
|
onUploadProgress,
|
|
37
38
|
transformResponse: [
|
|
38
39
|
...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
|
|
39
|
-
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
40
|
-
if (
|
|
40
|
+
(data: SuccessData | ErrorData | string): ResultData | ResultError => {
|
|
41
|
+
if (isString(data)) {
|
|
42
|
+
const match = data.match(/<title>(.*?)<\/title>/i);
|
|
43
|
+
return match ? match[1] : data;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!data.success) {
|
|
47
|
+
return data.data.error || data.data.message;
|
|
48
|
+
}
|
|
41
49
|
|
|
42
50
|
return data.data[0];
|
|
43
51
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosResponse, AxiosError, AxiosResponseTransformer } from 'axios';
|
|
2
|
+
import isString from 'lodash/isString';
|
|
2
3
|
import { File } from '../../types';
|
|
3
4
|
import { DEFAULT_BASE_URL } from '../../../constants';
|
|
4
5
|
|
|
@@ -39,8 +40,15 @@ export function uploadFilesRequest({ baseURL = DEFAULT_BASE_URL, body, headers }
|
|
|
39
40
|
headers: { Accept: 'application/json', 'Content-Type': 'multipart/form-data', ...headers },
|
|
40
41
|
transformResponse: [
|
|
41
42
|
...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
|
|
42
|
-
(data: SuccessData | ErrorData): ResultData | ResultError => {
|
|
43
|
-
if (
|
|
43
|
+
(data: SuccessData | ErrorData | string): ResultData | ResultError => {
|
|
44
|
+
if (isString(data)) {
|
|
45
|
+
const match = data.match(/<title>(.*?)<\/title>/i);
|
|
46
|
+
return match ? match[1] : data;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!data.success) {
|
|
50
|
+
return data.data.error || data.data.message;
|
|
51
|
+
}
|
|
44
52
|
|
|
45
53
|
const ids: ResultData['ids'] = [];
|
|
46
54
|
const byId: ResultData['byId'] = {};
|