@ps-aux/api-client-axios 0.0.6-rc-2 → 0.0.7-rc-1
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-client-axios/src/t.d.ts +1 -1
- package/dist/browser.esm.js +22 -1
- package/dist/browser.js +22 -1
- package/dist/node.esm.js +22 -1
- package/dist/node.js +22 -1
- package/package.json +5 -3
- package/src/AxiosOpenApiHttpClient.ts +31 -1
- package/src/t.ts +1 -1
package/dist/browser.esm.js
CHANGED
|
@@ -296,10 +296,12 @@ const springBootUrlConverter = () => ({ query, path }) => {
|
|
|
296
296
|
params: undefined,
|
|
297
297
|
};
|
|
298
298
|
};
|
|
299
|
+
const fileResFilenameRegex = /filename="([^"]+)"/;
|
|
299
300
|
const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter()) => {
|
|
300
301
|
return {
|
|
301
302
|
request: (req) => {
|
|
302
303
|
const { query, type, body } = req;
|
|
304
|
+
const isBlobResponse = req.format === 'document';
|
|
303
305
|
const data = type === ContentType.FormData ? convertToFormData(body, platform) : body;
|
|
304
306
|
return axios
|
|
305
307
|
.request({
|
|
@@ -312,11 +314,30 @@ const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter())
|
|
|
312
314
|
headers: {
|
|
313
315
|
ContentType: type,
|
|
314
316
|
},
|
|
317
|
+
responseType: isBlobResponse ? 'blob' : 'json'
|
|
315
318
|
})
|
|
316
|
-
.then(
|
|
319
|
+
.then(r => {
|
|
320
|
+
const { data } = r;
|
|
321
|
+
if (isBlobResponse) {
|
|
322
|
+
const contDist = r.headers['content-disposition'];
|
|
323
|
+
const fileName = getFileName(contDist);
|
|
324
|
+
const type = r.headers['content-type'];
|
|
325
|
+
return new File([data], fileName, {
|
|
326
|
+
type
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return data;
|
|
330
|
+
});
|
|
317
331
|
},
|
|
318
332
|
};
|
|
319
333
|
};
|
|
334
|
+
const getFileName = (contentDispositionHeader) => {
|
|
335
|
+
if (!contentDispositionHeader)
|
|
336
|
+
return 'download-file';
|
|
337
|
+
const match = contentDispositionHeader.match(fileResFilenameRegex);
|
|
338
|
+
const fileName = match ? match[1] : 'downloaded-file';
|
|
339
|
+
return fileName;
|
|
340
|
+
};
|
|
320
341
|
|
|
321
342
|
class BrowserPlatFormHelper {
|
|
322
343
|
isFile = (obj) => obj instanceof File;
|
package/dist/browser.js
CHANGED
|
@@ -298,10 +298,12 @@ const springBootUrlConverter = () => ({ query, path }) => {
|
|
|
298
298
|
params: undefined,
|
|
299
299
|
};
|
|
300
300
|
};
|
|
301
|
+
const fileResFilenameRegex = /filename="([^"]+)"/;
|
|
301
302
|
const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter()) => {
|
|
302
303
|
return {
|
|
303
304
|
request: (req) => {
|
|
304
305
|
const { query, type, body } = req;
|
|
306
|
+
const isBlobResponse = req.format === 'document';
|
|
305
307
|
const data = type === ContentType.FormData ? convertToFormData(body, platform) : body;
|
|
306
308
|
return axios
|
|
307
309
|
.request({
|
|
@@ -314,11 +316,30 @@ const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter())
|
|
|
314
316
|
headers: {
|
|
315
317
|
ContentType: type,
|
|
316
318
|
},
|
|
319
|
+
responseType: isBlobResponse ? 'blob' : 'json'
|
|
317
320
|
})
|
|
318
|
-
.then(
|
|
321
|
+
.then(r => {
|
|
322
|
+
const { data } = r;
|
|
323
|
+
if (isBlobResponse) {
|
|
324
|
+
const contDist = r.headers['content-disposition'];
|
|
325
|
+
const fileName = getFileName(contDist);
|
|
326
|
+
const type = r.headers['content-type'];
|
|
327
|
+
return new File([data], fileName, {
|
|
328
|
+
type
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return data;
|
|
332
|
+
});
|
|
319
333
|
},
|
|
320
334
|
};
|
|
321
335
|
};
|
|
336
|
+
const getFileName = (contentDispositionHeader) => {
|
|
337
|
+
if (!contentDispositionHeader)
|
|
338
|
+
return 'download-file';
|
|
339
|
+
const match = contentDispositionHeader.match(fileResFilenameRegex);
|
|
340
|
+
const fileName = match ? match[1] : 'downloaded-file';
|
|
341
|
+
return fileName;
|
|
342
|
+
};
|
|
322
343
|
|
|
323
344
|
class BrowserPlatFormHelper {
|
|
324
345
|
isFile = (obj) => obj instanceof File;
|
package/dist/node.esm.js
CHANGED
|
@@ -298,10 +298,12 @@ const springBootUrlConverter = () => ({ query, path }) => {
|
|
|
298
298
|
params: undefined,
|
|
299
299
|
};
|
|
300
300
|
};
|
|
301
|
+
const fileResFilenameRegex = /filename="([^"]+)"/;
|
|
301
302
|
const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter()) => {
|
|
302
303
|
return {
|
|
303
304
|
request: (req) => {
|
|
304
305
|
const { query, type, body } = req;
|
|
306
|
+
const isBlobResponse = req.format === 'document';
|
|
305
307
|
const data = type === ContentType.FormData ? convertToFormData(body, platform) : body;
|
|
306
308
|
return axios
|
|
307
309
|
.request({
|
|
@@ -314,11 +316,30 @@ const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter())
|
|
|
314
316
|
headers: {
|
|
315
317
|
ContentType: type,
|
|
316
318
|
},
|
|
319
|
+
responseType: isBlobResponse ? 'blob' : 'json'
|
|
317
320
|
})
|
|
318
|
-
.then(
|
|
321
|
+
.then(r => {
|
|
322
|
+
const { data } = r;
|
|
323
|
+
if (isBlobResponse) {
|
|
324
|
+
const contDist = r.headers['content-disposition'];
|
|
325
|
+
const fileName = getFileName(contDist);
|
|
326
|
+
const type = r.headers['content-type'];
|
|
327
|
+
return new File([data], fileName, {
|
|
328
|
+
type
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return data;
|
|
332
|
+
});
|
|
319
333
|
},
|
|
320
334
|
};
|
|
321
335
|
};
|
|
336
|
+
const getFileName = (contentDispositionHeader) => {
|
|
337
|
+
if (!contentDispositionHeader)
|
|
338
|
+
return 'download-file';
|
|
339
|
+
const match = contentDispositionHeader.match(fileResFilenameRegex);
|
|
340
|
+
const fileName = match ? match[1] : 'downloaded-file';
|
|
341
|
+
return fileName;
|
|
342
|
+
};
|
|
322
343
|
|
|
323
344
|
class NodePlatFormHelper {
|
|
324
345
|
isFile = (obj) => {
|
package/dist/node.js
CHANGED
|
@@ -300,10 +300,12 @@ const springBootUrlConverter = () => ({ query, path }) => {
|
|
|
300
300
|
params: undefined,
|
|
301
301
|
};
|
|
302
302
|
};
|
|
303
|
+
const fileResFilenameRegex = /filename="([^"]+)"/;
|
|
303
304
|
const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter()) => {
|
|
304
305
|
return {
|
|
305
306
|
request: (req) => {
|
|
306
307
|
const { query, type, body } = req;
|
|
308
|
+
const isBlobResponse = req.format === 'document';
|
|
307
309
|
const data = type === ContentType.FormData ? convertToFormData(body, platform) : body;
|
|
308
310
|
return axios
|
|
309
311
|
.request({
|
|
@@ -316,11 +318,30 @@ const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter())
|
|
|
316
318
|
headers: {
|
|
317
319
|
ContentType: type,
|
|
318
320
|
},
|
|
321
|
+
responseType: isBlobResponse ? 'blob' : 'json'
|
|
319
322
|
})
|
|
320
|
-
.then(
|
|
323
|
+
.then(r => {
|
|
324
|
+
const { data } = r;
|
|
325
|
+
if (isBlobResponse) {
|
|
326
|
+
const contDist = r.headers['content-disposition'];
|
|
327
|
+
const fileName = getFileName(contDist);
|
|
328
|
+
const type = r.headers['content-type'];
|
|
329
|
+
return new File([data], fileName, {
|
|
330
|
+
type
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return data;
|
|
334
|
+
});
|
|
321
335
|
},
|
|
322
336
|
};
|
|
323
337
|
};
|
|
338
|
+
const getFileName = (contentDispositionHeader) => {
|
|
339
|
+
if (!contentDispositionHeader)
|
|
340
|
+
return 'download-file';
|
|
341
|
+
const match = contentDispositionHeader.match(fileResFilenameRegex);
|
|
342
|
+
const fileName = match ? match[1] : 'downloaded-file';
|
|
343
|
+
return fileName;
|
|
344
|
+
};
|
|
324
345
|
|
|
325
346
|
class NodePlatFormHelper {
|
|
326
347
|
isFile = (obj) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ps-aux/api-client-axios",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-rc-1",
|
|
4
4
|
"main": "dist/node.js",
|
|
5
5
|
"module": "dist/node.esm.js",
|
|
6
6
|
"browser": "dist/browser.esm.js",
|
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "rollup -c",
|
|
10
10
|
"dev": "rollup -c --watch",
|
|
11
|
+
"publish": "npm run build && npm publish",
|
|
11
12
|
"tc": "tsc"
|
|
12
13
|
},
|
|
13
14
|
"author": "",
|
|
14
15
|
"license": "ISC",
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"flat": "5.0.2",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
18
|
+
"form-data": "^4.0.0",
|
|
19
|
+
"qs": "^6.11.2",
|
|
20
|
+
"rambda": "^8.5.0"
|
|
19
21
|
},
|
|
20
22
|
"devDependencies": {
|
|
21
23
|
"@types/flat": "^5.0.4",
|
|
@@ -22,6 +22,8 @@ export const springBootUrlConverter: () => UrlConverter = () => ({ query, path }
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
const fileResFilenameRegex = /filename="([^"]+)"/
|
|
26
|
+
|
|
25
27
|
export const createHttpClient = (
|
|
26
28
|
axios: AxiosInstance,
|
|
27
29
|
platform: PlatformHelper,
|
|
@@ -31,6 +33,8 @@ export const createHttpClient = (
|
|
|
31
33
|
request: (req) => {
|
|
32
34
|
const { query, type, body } = req
|
|
33
35
|
|
|
36
|
+
const isBlobResponse = req.format === 'document'
|
|
37
|
+
|
|
34
38
|
const data =
|
|
35
39
|
type === ContentType.FormData ? convertToFormData(body, platform) : body
|
|
36
40
|
|
|
@@ -45,8 +49,34 @@ export const createHttpClient = (
|
|
|
45
49
|
headers: {
|
|
46
50
|
ContentType: type,
|
|
47
51
|
},
|
|
52
|
+
responseType: isBlobResponse ? 'blob' : 'json'
|
|
53
|
+
})
|
|
54
|
+
.then(r => {
|
|
55
|
+
const { data } = r
|
|
56
|
+
if (isBlobResponse) {
|
|
57
|
+
const contDist = r.headers['content-disposition']
|
|
58
|
+
const fileName = getFileName(contDist)
|
|
59
|
+
|
|
60
|
+
const type = r.headers['content-type']
|
|
61
|
+
|
|
62
|
+
return new File([data as Blob], fileName, {
|
|
63
|
+
type
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return data
|
|
48
68
|
})
|
|
49
|
-
.then((r) => r.data)
|
|
50
69
|
},
|
|
51
70
|
}
|
|
52
71
|
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const getFileName = (contentDispositionHeader?: string):string => {
|
|
75
|
+
if (!contentDispositionHeader)
|
|
76
|
+
return 'download-file'
|
|
77
|
+
|
|
78
|
+
const match = contentDispositionHeader.match(fileResFilenameRegex)
|
|
79
|
+
const fileName = match ? match[1] : 'downloaded-file'
|
|
80
|
+
|
|
81
|
+
return fileName
|
|
82
|
+
}
|