@3dverse/api 0.13.1 → 0.13.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/index.mjs CHANGED
@@ -39,6 +39,21 @@ function multipartBody(fields, files) {
39
39
  }
40
40
  return form;
41
41
  }
42
+ function jsonOrMultipartBodyOf(body) {
43
+ if (body === void 0) {
44
+ return void 0;
45
+ }
46
+ const isFile = (value) => value instanceof Blob || Array.isArray(value) && value.length > 0 && value.every((item) => item instanceof Blob);
47
+ const entries = Object.entries(body);
48
+ const files = entries.filter(([, value]) => isFile(value));
49
+ if (files.length === 0) {
50
+ return body;
51
+ }
52
+ return multipartBody(
53
+ Object.fromEntries(entries.filter(([, value]) => !isFile(value))),
54
+ Object.fromEntries(files)
55
+ );
56
+ }
42
57
  function plainHeaders(headers) {
43
58
  return headers instanceof AxiosHeaders ? headers.toJSON() : { ...headers };
44
59
  }
@@ -747,14 +762,15 @@ function listSourceFileAssets({
747
762
  function createImport({
748
763
  folder_id,
749
764
  body
750
- }, headers) {
765
+ }, onUploadProgress, headers) {
751
766
  return axiosInstance({
752
767
  method: "post",
753
768
  url: "/imports",
754
769
  params: {
755
770
  folder_id
756
771
  },
757
- data: body,
772
+ data: jsonOrMultipartBodyOf(body),
773
+ onUploadProgress,
758
774
  headers
759
775
  });
760
776
  }