@3dverse/api 0.12.0 → 0.13.0

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,13 @@ function multipartBody(fields, files) {
39
39
  }
40
40
  return form;
41
41
  }
42
+ function jsonOrMultipartBody(fields, files) {
43
+ const hasFile = Object.values(files).some((value) => Array.isArray(value) ? value.length > 0 : value !== void 0);
44
+ if (hasFile) {
45
+ return multipartBody(fields, files);
46
+ }
47
+ return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== void 0));
48
+ }
42
49
  function plainHeaders(headers) {
43
50
  return headers instanceof AxiosHeaders ? headers.toJSON() : { ...headers };
44
51
  }
@@ -757,7 +764,7 @@ function createImport({
757
764
  params: {
758
765
  folder_id
759
766
  },
760
- data: multipartBody(
767
+ data: jsonOrMultipartBody(
761
768
  {
762
769
  conversion_pipeline,
763
770
  remote_files,
@@ -768,10 +775,7 @@ function createImport({
768
775
  }
769
776
  ),
770
777
  onUploadProgress,
771
- headers: {
772
- "Content-Type": "multipart/form-data",
773
- ...plainHeaders(headers)
774
- }
778
+ headers
775
779
  });
776
780
  }
777
781
  function listImports({