@ps-aux/api-client-axios 0.0.4 → 0.0.6-rc-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.
Files changed (38) hide show
  1. package/dist/api-client-axios/src/AxiosOpenApiHttpClient.d.ts +7 -0
  2. package/dist/api-client-axios/src/browser.d.ts +4 -0
  3. package/dist/api-client-axios/src/commonExports.d.ts +3 -0
  4. package/dist/api-client-axios/src/node.d.ts +4 -0
  5. package/dist/{platform → api-client-axios/src/platform}/browser.d.ts +2 -2
  6. package/dist/api-client-axios/src/platform/foo.d.ts +1 -0
  7. package/dist/{mytyp.d.ts → api-client-axios/src/t.d.ts} +1 -4
  8. package/dist/api-client-common/src/index.d.ts +9 -0
  9. package/dist/api-client-common/src/serializeQueryForSpringBoot.d.ts +5 -0
  10. package/dist/api-client-common/src/serializeQueryWithQs.d.ts +1 -0
  11. package/dist/browser.esm.js +340 -0
  12. package/dist/browser.js +344 -0
  13. package/dist/node.esm.js +352 -0
  14. package/dist/node.js +356 -0
  15. package/package.json +10 -11
  16. package/rollup.config.mjs +16 -9
  17. package/src/AxiosOpenApiHttpClient.ts +28 -11
  18. package/src/browser.ts +12 -0
  19. package/src/commonExports.ts +3 -0
  20. package/src/node.ts +11 -0
  21. package/src/platform/browser.ts +5 -5
  22. package/src/platform/foo.ts +1 -0
  23. package/src/platform/node.ts +3 -3
  24. package/src/{mytyp.ts → t.ts} +1 -6
  25. package/tsconfig.json +2 -1
  26. package/dist/AxiosOpenApiHttpClient.d.ts +0 -3
  27. package/dist/index.d.ts +0 -1
  28. package/dist/index.esm.js +0 -139
  29. package/dist/index.js +0 -139
  30. package/dist/platform/index.d.ts +0 -2
  31. package/dist/serializeQuery.d.ts +0 -1
  32. package/foo.sh +0 -3
  33. package/src/index.ts +0 -1
  34. package/src/platform/index.ts +0 -3
  35. package/src/serializeQuery.ts +0 -47
  36. /package/dist/{convertFormData.d.ts → api-client-axios/src/convertFormData.d.ts} +0 -0
  37. /package/dist/{platform → api-client-axios/src/platform}/node.d.ts +0 -0
  38. /package/dist/{platform → api-client-axios/src/platform}/types.d.ts +0 -0
@@ -0,0 +1,344 @@
1
+ 'use strict';
2
+
3
+ require('qs');
4
+
5
+ const ContentType = {
6
+ Json: 'application/json',
7
+ FormData: 'multipart/form-data',
8
+ };
9
+
10
+ const convertToFormData = (payload, platform) => {
11
+ const formData = platform.newFormData();
12
+ const addProp = (key, val) => {
13
+ if (Array.isArray(val) || platform.isFileList(val)) {
14
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
+ // @ts-ignore - seems that FileList is iterable despite the warning
16
+ // TODO change to other iteration method if this is not true
17
+ for (const valItem of val) {
18
+ addProp(key, valItem);
19
+ }
20
+ }
21
+ else if (typeof val === 'object' &&
22
+ val != null &&
23
+ !platform.isFile(val)) {
24
+ throw new Error(`Object serialization into FormData not supported for object: ${val}`);
25
+ }
26
+ else {
27
+ if (platform.isFile(val)) {
28
+ const { file, name } = platform.getFileAndName(val);
29
+ formData.append(key, file, name);
30
+ }
31
+ else {
32
+ formData.append(key, val);
33
+ }
34
+ }
35
+ };
36
+ Object.entries(payload).forEach(([key, val]) => addProp(key, val));
37
+ return formData;
38
+ };
39
+
40
+ const { isArray } = Array;
41
+
42
+ function fromPairs(listOfPairs){
43
+ const toReturn = {};
44
+ listOfPairs.forEach(([ prop, value ]) => toReturn[ prop ] = value);
45
+
46
+ return toReturn
47
+ }
48
+
49
+ function partitionObject(predicate, iterable){
50
+ const yes = {};
51
+ const no = {};
52
+ Object.entries(iterable).forEach(([ prop, value ]) => {
53
+ if (predicate(value, prop)){
54
+ yes[ prop ] = value;
55
+ } else {
56
+ no[ prop ] = value;
57
+ }
58
+ });
59
+
60
+ return [ yes, no ]
61
+ }
62
+
63
+ function partitionArray(
64
+ predicate, list, indexed = false
65
+ ){
66
+ const yes = [];
67
+ const no = [];
68
+ let counter = -1;
69
+
70
+ while (counter++ < list.length - 1){
71
+ if (
72
+ indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])
73
+ ){
74
+ yes.push(list[ counter ]);
75
+ } else {
76
+ no.push(list[ counter ]);
77
+ }
78
+ }
79
+
80
+ return [ yes, no ]
81
+ }
82
+
83
+ function partition(predicate, iterable){
84
+ if (arguments.length === 1){
85
+ return listHolder => partition(predicate, listHolder)
86
+ }
87
+ if (!isArray(iterable)) return partitionObject(predicate, iterable)
88
+
89
+ return partitionArray(predicate, iterable)
90
+ }
91
+
92
+ var flat = flatten$1;
93
+ flatten$1.flatten = flatten$1;
94
+ flatten$1.unflatten = unflatten;
95
+
96
+ function isBuffer (obj) {
97
+ return obj &&
98
+ obj.constructor &&
99
+ (typeof obj.constructor.isBuffer === 'function') &&
100
+ obj.constructor.isBuffer(obj)
101
+ }
102
+
103
+ function keyIdentity (key) {
104
+ return key
105
+ }
106
+
107
+ function flatten$1 (target, opts) {
108
+ opts = opts || {};
109
+
110
+ const delimiter = opts.delimiter || '.';
111
+ const maxDepth = opts.maxDepth;
112
+ const transformKey = opts.transformKey || keyIdentity;
113
+ const output = {};
114
+
115
+ function step (object, prev, currentDepth) {
116
+ currentDepth = currentDepth || 1;
117
+ Object.keys(object).forEach(function (key) {
118
+ const value = object[key];
119
+ const isarray = opts.safe && Array.isArray(value);
120
+ const type = Object.prototype.toString.call(value);
121
+ const isbuffer = isBuffer(value);
122
+ const isobject = (
123
+ type === '[object Object]' ||
124
+ type === '[object Array]'
125
+ );
126
+
127
+ const newKey = prev
128
+ ? prev + delimiter + transformKey(key)
129
+ : transformKey(key);
130
+
131
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length &&
132
+ (!opts.maxDepth || currentDepth < maxDepth)) {
133
+ return step(value, newKey, currentDepth + 1)
134
+ }
135
+
136
+ output[newKey] = value;
137
+ });
138
+ }
139
+
140
+ step(target);
141
+
142
+ return output
143
+ }
144
+
145
+ function unflatten (target, opts) {
146
+ opts = opts || {};
147
+
148
+ const delimiter = opts.delimiter || '.';
149
+ const overwrite = opts.overwrite || false;
150
+ const transformKey = opts.transformKey || keyIdentity;
151
+ const result = {};
152
+
153
+ const isbuffer = isBuffer(target);
154
+ if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
155
+ return target
156
+ }
157
+
158
+ // safely ensure that the key is
159
+ // an integer.
160
+ function getkey (key) {
161
+ const parsedKey = Number(key);
162
+
163
+ return (
164
+ isNaN(parsedKey) ||
165
+ key.indexOf('.') !== -1 ||
166
+ opts.object
167
+ ) ? key
168
+ : parsedKey
169
+ }
170
+
171
+ function addKeys (keyPrefix, recipient, target) {
172
+ return Object.keys(target).reduce(function (result, key) {
173
+ result[keyPrefix + delimiter + key] = target[key];
174
+
175
+ return result
176
+ }, recipient)
177
+ }
178
+
179
+ function isEmpty (val) {
180
+ const type = Object.prototype.toString.call(val);
181
+ const isArray = type === '[object Array]';
182
+ const isObject = type === '[object Object]';
183
+
184
+ if (!val) {
185
+ return true
186
+ } else if (isArray) {
187
+ return !val.length
188
+ } else if (isObject) {
189
+ return !Object.keys(val).length
190
+ }
191
+ }
192
+
193
+ target = Object.keys(target).reduce(function (result, key) {
194
+ const type = Object.prototype.toString.call(target[key]);
195
+ const isObject = (type === '[object Object]' || type === '[object Array]');
196
+ if (!isObject || isEmpty(target[key])) {
197
+ result[key] = target[key];
198
+ return result
199
+ } else {
200
+ return addKeys(
201
+ key,
202
+ result,
203
+ flatten$1(target[key], opts)
204
+ )
205
+ }
206
+ }, {});
207
+
208
+ Object.keys(target).forEach(function (key) {
209
+ const split = key.split(delimiter).map(transformKey);
210
+ let key1 = getkey(split.shift());
211
+ let key2 = getkey(split[0]);
212
+ let recipient = result;
213
+
214
+ while (key2 !== undefined) {
215
+ if (key1 === '__proto__') {
216
+ return
217
+ }
218
+
219
+ const type = Object.prototype.toString.call(recipient[key1]);
220
+ const isobject = (
221
+ type === '[object Object]' ||
222
+ type === '[object Array]'
223
+ );
224
+
225
+ // do not write over falsey, non-undefined values if overwrite is false
226
+ if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
227
+ return
228
+ }
229
+
230
+ if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {
231
+ recipient[key1] = (
232
+ typeof key2 === 'number' &&
233
+ !opts.object ? [] : {}
234
+ );
235
+ }
236
+
237
+ recipient = recipient[key1];
238
+ if (split.length > 0) {
239
+ key1 = getkey(split.shift());
240
+ key2 = getkey(split[0]);
241
+ }
242
+ }
243
+
244
+ // unflatten again for 'messy objects'
245
+ recipient[key1] = unflatten(target[key], opts);
246
+ });
247
+
248
+ return result
249
+ }
250
+
251
+ /**
252
+ * Brings the 1st level to the 0th level.
253
+ * Flats the object by nesting with '.' path separator.
254
+ */
255
+ const serializeQueryForSpringBoot = (obj) => {
256
+ const parts = [];
257
+ Object.entries(obj).forEach(([key, val]) => {
258
+ if (Array.isArray(val)) {
259
+ val.forEach((v) => {
260
+ parts.push([key, v]);
261
+ });
262
+ }
263
+ else if (typeof val === 'object') {
264
+ objectToParams(val).forEach(([key, val]) => {
265
+ parts.push([key, val.toString()]);
266
+ });
267
+ }
268
+ else {
269
+ parts.push([key, val]);
270
+ }
271
+ });
272
+ return parts.map((p) => `${p[0]}=${p[1]}`).join('&');
273
+ };
274
+ const flatten = (obj) => {
275
+ const r = flat.flatten(obj);
276
+ // { empty: {} } would be { empty: {} } instead of empty array
277
+ return Object.entries(r).filter(([k, v]) => typeof v !== 'object');
278
+ };
279
+ const objectToParams = (obj) => {
280
+ const [arrayProps, nonArrayProps] = partition((e) => Array.isArray(e[1]), Object.entries(obj));
281
+ const withoutArrayProps = fromPairs(nonArrayProps);
282
+ const res = flatten(withoutArrayProps);
283
+ arrayProps.forEach(([k, vals]) => {
284
+ vals.forEach((v) => res.push([k, v]));
285
+ });
286
+ return res;
287
+ };
288
+
289
+ const noOpUrlConverter = () => ({ query, path }) => {
290
+ return {
291
+ url: path,
292
+ params: query,
293
+ };
294
+ };
295
+ const springBootUrlConverter = () => ({ query, path }) => {
296
+ return {
297
+ url: path + (query ? `?${serializeQueryForSpringBoot(query)}` : ''),
298
+ params: undefined,
299
+ };
300
+ };
301
+ const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter()) => {
302
+ return {
303
+ request: (req) => {
304
+ const { query, type, body } = req;
305
+ const data = type === ContentType.FormData ? convertToFormData(body, platform) : body;
306
+ return axios
307
+ .request({
308
+ method: req.method,
309
+ // url: req.path + (query ? `?${serializeQueryForNestJs(query)}` : ''),
310
+ // params: req.query, // TODO make this customizable as different behaviour might be needed with different APIs
311
+ // url: req.path,
312
+ ...urlConverter(req),
313
+ data,
314
+ headers: {
315
+ ContentType: type,
316
+ },
317
+ })
318
+ .then((r) => r.data);
319
+ },
320
+ };
321
+ };
322
+
323
+ class BrowserPlatFormHelper {
324
+ isFile = (obj) => obj instanceof File;
325
+ getFileAndName = (obj) => {
326
+ if (!(obj instanceof File))
327
+ throw new Error(`Obj ${obj} is not a file`);
328
+ return {
329
+ file: obj,
330
+ name: obj.name,
331
+ };
332
+ };
333
+ isFileList = (obj) => obj instanceof FileList;
334
+ // @ts-ignore
335
+ newFormData = () => new FormData();
336
+ }
337
+
338
+ const createHttpClient = (axios, urlConverter = noOpUrlConverter()) => {
339
+ return createHttpClient$1(axios, new BrowserPlatFormHelper(), urlConverter);
340
+ };
341
+
342
+ exports.createHttpClient = createHttpClient;
343
+ exports.noOpUrlConverter = noOpUrlConverter;
344
+ exports.springBootUrlConverter = springBootUrlConverter;
@@ -0,0 +1,352 @@
1
+ import 'qs';
2
+ import NodeFormData from 'form-data';
3
+ import stream from 'stream';
4
+
5
+ const ContentType = {
6
+ Json: 'application/json',
7
+ FormData: 'multipart/form-data',
8
+ };
9
+
10
+ const convertToFormData = (payload, platform) => {
11
+ const formData = platform.newFormData();
12
+ const addProp = (key, val) => {
13
+ if (Array.isArray(val) || platform.isFileList(val)) {
14
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
+ // @ts-ignore - seems that FileList is iterable despite the warning
16
+ // TODO change to other iteration method if this is not true
17
+ for (const valItem of val) {
18
+ addProp(key, valItem);
19
+ }
20
+ }
21
+ else if (typeof val === 'object' &&
22
+ val != null &&
23
+ !platform.isFile(val)) {
24
+ throw new Error(`Object serialization into FormData not supported for object: ${val}`);
25
+ }
26
+ else {
27
+ if (platform.isFile(val)) {
28
+ const { file, name } = platform.getFileAndName(val);
29
+ formData.append(key, file, name);
30
+ }
31
+ else {
32
+ formData.append(key, val);
33
+ }
34
+ }
35
+ };
36
+ Object.entries(payload).forEach(([key, val]) => addProp(key, val));
37
+ return formData;
38
+ };
39
+
40
+ const { isArray } = Array;
41
+
42
+ function fromPairs(listOfPairs){
43
+ const toReturn = {};
44
+ listOfPairs.forEach(([ prop, value ]) => toReturn[ prop ] = value);
45
+
46
+ return toReturn
47
+ }
48
+
49
+ function partitionObject(predicate, iterable){
50
+ const yes = {};
51
+ const no = {};
52
+ Object.entries(iterable).forEach(([ prop, value ]) => {
53
+ if (predicate(value, prop)){
54
+ yes[ prop ] = value;
55
+ } else {
56
+ no[ prop ] = value;
57
+ }
58
+ });
59
+
60
+ return [ yes, no ]
61
+ }
62
+
63
+ function partitionArray(
64
+ predicate, list, indexed = false
65
+ ){
66
+ const yes = [];
67
+ const no = [];
68
+ let counter = -1;
69
+
70
+ while (counter++ < list.length - 1){
71
+ if (
72
+ indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])
73
+ ){
74
+ yes.push(list[ counter ]);
75
+ } else {
76
+ no.push(list[ counter ]);
77
+ }
78
+ }
79
+
80
+ return [ yes, no ]
81
+ }
82
+
83
+ function partition(predicate, iterable){
84
+ if (arguments.length === 1){
85
+ return listHolder => partition(predicate, listHolder)
86
+ }
87
+ if (!isArray(iterable)) return partitionObject(predicate, iterable)
88
+
89
+ return partitionArray(predicate, iterable)
90
+ }
91
+
92
+ var flat = flatten$1;
93
+ flatten$1.flatten = flatten$1;
94
+ flatten$1.unflatten = unflatten;
95
+
96
+ function isBuffer (obj) {
97
+ return obj &&
98
+ obj.constructor &&
99
+ (typeof obj.constructor.isBuffer === 'function') &&
100
+ obj.constructor.isBuffer(obj)
101
+ }
102
+
103
+ function keyIdentity (key) {
104
+ return key
105
+ }
106
+
107
+ function flatten$1 (target, opts) {
108
+ opts = opts || {};
109
+
110
+ const delimiter = opts.delimiter || '.';
111
+ const maxDepth = opts.maxDepth;
112
+ const transformKey = opts.transformKey || keyIdentity;
113
+ const output = {};
114
+
115
+ function step (object, prev, currentDepth) {
116
+ currentDepth = currentDepth || 1;
117
+ Object.keys(object).forEach(function (key) {
118
+ const value = object[key];
119
+ const isarray = opts.safe && Array.isArray(value);
120
+ const type = Object.prototype.toString.call(value);
121
+ const isbuffer = isBuffer(value);
122
+ const isobject = (
123
+ type === '[object Object]' ||
124
+ type === '[object Array]'
125
+ );
126
+
127
+ const newKey = prev
128
+ ? prev + delimiter + transformKey(key)
129
+ : transformKey(key);
130
+
131
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length &&
132
+ (!opts.maxDepth || currentDepth < maxDepth)) {
133
+ return step(value, newKey, currentDepth + 1)
134
+ }
135
+
136
+ output[newKey] = value;
137
+ });
138
+ }
139
+
140
+ step(target);
141
+
142
+ return output
143
+ }
144
+
145
+ function unflatten (target, opts) {
146
+ opts = opts || {};
147
+
148
+ const delimiter = opts.delimiter || '.';
149
+ const overwrite = opts.overwrite || false;
150
+ const transformKey = opts.transformKey || keyIdentity;
151
+ const result = {};
152
+
153
+ const isbuffer = isBuffer(target);
154
+ if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {
155
+ return target
156
+ }
157
+
158
+ // safely ensure that the key is
159
+ // an integer.
160
+ function getkey (key) {
161
+ const parsedKey = Number(key);
162
+
163
+ return (
164
+ isNaN(parsedKey) ||
165
+ key.indexOf('.') !== -1 ||
166
+ opts.object
167
+ ) ? key
168
+ : parsedKey
169
+ }
170
+
171
+ function addKeys (keyPrefix, recipient, target) {
172
+ return Object.keys(target).reduce(function (result, key) {
173
+ result[keyPrefix + delimiter + key] = target[key];
174
+
175
+ return result
176
+ }, recipient)
177
+ }
178
+
179
+ function isEmpty (val) {
180
+ const type = Object.prototype.toString.call(val);
181
+ const isArray = type === '[object Array]';
182
+ const isObject = type === '[object Object]';
183
+
184
+ if (!val) {
185
+ return true
186
+ } else if (isArray) {
187
+ return !val.length
188
+ } else if (isObject) {
189
+ return !Object.keys(val).length
190
+ }
191
+ }
192
+
193
+ target = Object.keys(target).reduce(function (result, key) {
194
+ const type = Object.prototype.toString.call(target[key]);
195
+ const isObject = (type === '[object Object]' || type === '[object Array]');
196
+ if (!isObject || isEmpty(target[key])) {
197
+ result[key] = target[key];
198
+ return result
199
+ } else {
200
+ return addKeys(
201
+ key,
202
+ result,
203
+ flatten$1(target[key], opts)
204
+ )
205
+ }
206
+ }, {});
207
+
208
+ Object.keys(target).forEach(function (key) {
209
+ const split = key.split(delimiter).map(transformKey);
210
+ let key1 = getkey(split.shift());
211
+ let key2 = getkey(split[0]);
212
+ let recipient = result;
213
+
214
+ while (key2 !== undefined) {
215
+ if (key1 === '__proto__') {
216
+ return
217
+ }
218
+
219
+ const type = Object.prototype.toString.call(recipient[key1]);
220
+ const isobject = (
221
+ type === '[object Object]' ||
222
+ type === '[object Array]'
223
+ );
224
+
225
+ // do not write over falsey, non-undefined values if overwrite is false
226
+ if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {
227
+ return
228
+ }
229
+
230
+ if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {
231
+ recipient[key1] = (
232
+ typeof key2 === 'number' &&
233
+ !opts.object ? [] : {}
234
+ );
235
+ }
236
+
237
+ recipient = recipient[key1];
238
+ if (split.length > 0) {
239
+ key1 = getkey(split.shift());
240
+ key2 = getkey(split[0]);
241
+ }
242
+ }
243
+
244
+ // unflatten again for 'messy objects'
245
+ recipient[key1] = unflatten(target[key], opts);
246
+ });
247
+
248
+ return result
249
+ }
250
+
251
+ /**
252
+ * Brings the 1st level to the 0th level.
253
+ * Flats the object by nesting with '.' path separator.
254
+ */
255
+ const serializeQueryForSpringBoot = (obj) => {
256
+ const parts = [];
257
+ Object.entries(obj).forEach(([key, val]) => {
258
+ if (Array.isArray(val)) {
259
+ val.forEach((v) => {
260
+ parts.push([key, v]);
261
+ });
262
+ }
263
+ else if (typeof val === 'object') {
264
+ objectToParams(val).forEach(([key, val]) => {
265
+ parts.push([key, val.toString()]);
266
+ });
267
+ }
268
+ else {
269
+ parts.push([key, val]);
270
+ }
271
+ });
272
+ return parts.map((p) => `${p[0]}=${p[1]}`).join('&');
273
+ };
274
+ const flatten = (obj) => {
275
+ const r = flat.flatten(obj);
276
+ // { empty: {} } would be { empty: {} } instead of empty array
277
+ return Object.entries(r).filter(([k, v]) => typeof v !== 'object');
278
+ };
279
+ const objectToParams = (obj) => {
280
+ const [arrayProps, nonArrayProps] = partition((e) => Array.isArray(e[1]), Object.entries(obj));
281
+ const withoutArrayProps = fromPairs(nonArrayProps);
282
+ const res = flatten(withoutArrayProps);
283
+ arrayProps.forEach(([k, vals]) => {
284
+ vals.forEach((v) => res.push([k, v]));
285
+ });
286
+ return res;
287
+ };
288
+
289
+ const noOpUrlConverter = () => ({ query, path }) => {
290
+ return {
291
+ url: path,
292
+ params: query,
293
+ };
294
+ };
295
+ const springBootUrlConverter = () => ({ query, path }) => {
296
+ return {
297
+ url: path + (query ? `?${serializeQueryForSpringBoot(query)}` : ''),
298
+ params: undefined,
299
+ };
300
+ };
301
+ const createHttpClient$1 = (axios, platform, urlConverter = noOpUrlConverter()) => {
302
+ return {
303
+ request: (req) => {
304
+ const { query, type, body } = req;
305
+ const data = type === ContentType.FormData ? convertToFormData(body, platform) : body;
306
+ return axios
307
+ .request({
308
+ method: req.method,
309
+ // url: req.path + (query ? `?${serializeQueryForNestJs(query)}` : ''),
310
+ // params: req.query, // TODO make this customizable as different behaviour might be needed with different APIs
311
+ // url: req.path,
312
+ ...urlConverter(req),
313
+ data,
314
+ headers: {
315
+ ContentType: type,
316
+ },
317
+ })
318
+ .then((r) => r.data);
319
+ },
320
+ };
321
+ };
322
+
323
+ class NodePlatFormHelper {
324
+ isFile = (obj) => {
325
+ if (typeof obj !== 'object')
326
+ return false;
327
+ const { file, name } = obj;
328
+ return typeof name === 'string' &&
329
+ (Buffer.isBuffer(file)
330
+ || file instanceof stream.Readable);
331
+ };
332
+ getFileAndName = (obj) => {
333
+ if (!this.isFile(obj))
334
+ throw new Error(`Obj ${obj} is not a file`);
335
+ return {
336
+ file: obj.file,
337
+ name: obj.name,
338
+ };
339
+ };
340
+ isFileList = (obj) => {
341
+ // No FileList in node?
342
+ return false;
343
+ };
344
+ // @ts-ignore
345
+ newFormData = () => new NodeFormData();
346
+ }
347
+
348
+ const createHttpClient = (axios, urlConverter = noOpUrlConverter()) => {
349
+ return createHttpClient$1(axios, new NodePlatFormHelper(), urlConverter);
350
+ };
351
+
352
+ export { createHttpClient, noOpUrlConverter, springBootUrlConverter };