bruce-models 4.8.2 → 4.8.4

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.
@@ -526,65 +526,30 @@ class AbstractApi {
526
526
  */
527
527
  upload(url, blob, params) {
528
528
  return __awaiter(this, void 0, void 0, function* () {
529
- return new Promise((res, rej) => {
530
- try {
531
- let xhr = new XMLHttpRequest();
532
- const headers = params === null || params === void 0 ? void 0 : params.headers;
533
- if (headers) {
534
- const headerKeys = Object.keys(headers);
535
- for (let i = 0; i < headerKeys.length; i++) {
536
- const key = headerKeys[i];
537
- const value = headers[key];
538
- xhr.setRequestHeader(key, value);
539
- }
540
- }
541
- if (params === null || params === void 0 ? void 0 : params.onProgress) {
542
- if (xhr.upload) {
543
- xhr.upload.onprogress = params === null || params === void 0 ? void 0 : params.onProgress;
544
- }
545
- else {
546
- xhr.addEventListener("progress", params === null || params === void 0 ? void 0 : params.onProgress);
547
- }
548
- }
549
- xhr.onreadystatechange = (e) => {
550
- if (xhr.readyState == 4) {
551
- if (xhr.status >= 400 || xhr.status < 200) {
552
- rej(e);
553
- }
554
- else {
555
- try {
556
- res(JSON.parse(xhr.responseText));
557
- }
558
- catch (e) {
559
- console.error(e, xhr.responseText);
560
- res(xhr.responseText);
561
- }
562
- }
563
- }
564
- };
565
- xhr.open("POST", url, true);
566
- if (this.ssidHeader && this.ssid) {
567
- xhr.setRequestHeader(this.ssidHeader, this.ssid);
568
- }
569
- let formData;
570
- if ((params === null || params === void 0 ? void 0 : params.formData) instanceof FormData) {
571
- formData = params === null || params === void 0 ? void 0 : params.formData;
572
- }
573
- else {
574
- formData = new FormData();
575
- if (params === null || params === void 0 ? void 0 : params.formData) {
576
- for (const key in params.formData) {
577
- formData.append(key, params.formData[key]);
578
- }
579
- }
580
- }
581
- formData.append("file", blob);
582
- xhr.send(formData);
583
- }
584
- catch (e) {
585
- rej(e);
529
+ if (!params) {
530
+ params = {};
531
+ }
532
+ params.headers = Object.assign({}, params.headers);
533
+ if (this.ssidHeader && this.ssid) {
534
+ params.headers[this.ssidHeader] = this.ssid;
535
+ }
536
+ const formData = params.formData instanceof FormData ? params.formData : new FormData();
537
+ if (formData.has("file")) {
538
+ formData.delete("file");
539
+ }
540
+ formData.append("file", blob);
541
+ // If the provided form data was a plain object, append its properties to the form data.
542
+ if (params.formData && !(params.formData instanceof FormData)) {
543
+ for (let key in params.formData) {
544
+ formData.append(key, params.formData[key]);
586
545
  }
546
+ }
547
+ const res = yield fetch(url, {
548
+ headers: params.headers,
549
+ method: "POST",
550
+ body: formData
587
551
  });
552
+ return parseResult(res);
588
553
  });
589
554
  }
590
555
  }
@@ -14319,7 +14284,7 @@ var DataSource;
14319
14284
  })(DataSource || (DataSource = {}));
14320
14285
 
14321
14286
  // This is updated with the package.json version on build.
14322
- const VERSION = "4.8.2";
14287
+ const VERSION = "4.8.4";
14323
14288
 
14324
14289
  export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
14325
14290
  //# sourceMappingURL=bruce-models.es5.js.map