bruce-models 5.6.8 → 5.7.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.
@@ -555,12 +555,6 @@
555
555
  if (this.ssidHeader) {
556
556
  params.headers[this.ssidHeader] = this.GetSessionId();
557
557
  }
558
- /**
559
- * If we support the legacy request and need it for progress, then we diverge there.
560
- */
561
- if (window && window["XMLHttpRequest"] && params.onProgress) {
562
- return legacyUpload(url, blob, params);
563
- }
564
558
  const formData = params.formData instanceof FormData ? params.formData : new FormData();
565
559
  if (formData.has("file")) {
566
560
  formData.delete("file");
@@ -572,6 +566,12 @@
572
566
  formData.append(key, params.formData[key]);
573
567
  }
574
568
  }
569
+ /**
570
+ * If we support the legacy request and need it for progress, then we diverge there.
571
+ */
572
+ if (window && window["XMLHttpRequest"] && params.onProgress) {
573
+ return legacyUpload(url, params.headers, formData, params.onProgress, params.abortSignal);
574
+ }
575
575
  const res = yield fetch(url, {
576
576
  headers: params.headers,
577
577
  method: "POST",
@@ -587,34 +587,26 @@
587
587
  * Unfortunately, this is needed to track progress when it's supported.
588
588
  * Fetch doesn't have this capability.
589
589
  * @param url
590
- * @param blob
591
590
  * @param params
592
591
  */
593
- function legacyUpload(url, blob, params) {
594
- params = Object.assign({}, params);
595
- params.headers = Object.assign({}, params.headers);
596
- const formData = new FormData();
597
- formData.append("file", blob);
598
- if (params.formData && !(params.formData instanceof FormData)) {
599
- for (let key in params.formData) {
600
- if (key !== "file") {
601
- formData.append(key, params.formData[key]);
602
- }
603
- }
604
- }
592
+ function legacyUpload(url, headers, formData, onProgress, abortSignal) {
605
593
  return new Promise((resolve, reject) => {
606
594
  const xhr = new window["XMLHttpRequest"]();
607
595
  xhr.open("POST", url, true);
608
596
  // Set custom headers.
609
- if (params.headers) {
610
- Object.entries(params.headers).forEach(([key, value]) => {
597
+ if (headers) {
598
+ Object.keys(headers).forEach((key) => {
599
+ let value = headers[key];
600
+ if (!value) {
601
+ value = "";
602
+ }
611
603
  xhr.setRequestHeader(key, value);
612
604
  });
613
605
  }
614
606
  // Progress event.
615
607
  xhr.upload.onprogress = (event) => {
616
- if ((params === null || params === void 0 ? void 0 : params.onProgress) && event.lengthComputable) {
617
- params.onProgress(event);
608
+ if (onProgress && event.lengthComputable) {
609
+ onProgress(event);
618
610
  }
619
611
  };
620
612
  // Success and error handling.
@@ -627,8 +619,8 @@
627
619
  }
628
620
  };
629
621
  xhr.onerror = () => reject(new Error("Network error occurred during file upload."));
630
- if (params.abortSignal) {
631
- params.abortSignal.addEventListener("abort", () => {
622
+ if (abortSignal) {
623
+ abortSignal.addEventListener("abort", () => {
632
624
  xhr.abort();
633
625
  reject(new Error("Upload aborted."));
634
626
  });
@@ -8283,7 +8275,7 @@
8283
8275
  if (!api) {
8284
8276
  api = exports.ENVIRONMENT.Api().GetBruceApi();
8285
8277
  }
8286
- const FILE_PORTION_SIZE = 100000000; // 100MB.
8278
+ const FILE_PORTION_SIZE = 50000000; // 50MB.
8287
8279
  let fileSize = file.size;
8288
8280
  let fileOffset = 0;
8289
8281
  let filePartsCount = fileSize / FILE_PORTION_SIZE;
@@ -14968,7 +14960,7 @@
14968
14960
  })(exports.Scenario || (exports.Scenario = {}));
14969
14961
 
14970
14962
  // This is updated with the package.json version on build.
14971
- const VERSION = "5.6.8";
14963
+ const VERSION = "5.7.0";
14972
14964
 
14973
14965
  exports.VERSION = VERSION;
14974
14966
  exports.AbstractApi = AbstractApi;