bruce-models 4.8.2 → 4.8.3

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,27 @@ 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 = params.headers || {};
533
+ params.headers = Object.assign({}, params.headers);
534
+ if (this.ssidHeader && this.ssid) {
535
+ params.headers[this.ssidHeader] = this.ssid;
536
+ }
537
+ const formData = new FormData();
538
+ formData.append("file", blob);
539
+ if (params === null || params === void 0 ? void 0 : params.formData) {
540
+ for (const key in params.formData) {
541
+ formData.append(key, params.formData[key]);
586
542
  }
543
+ }
544
+ const res = yield fetch(url, {
545
+ headers: params.headers,
546
+ method: "POST",
547
+ body: formData
587
548
  });
549
+ return parseResult(res);
588
550
  });
589
551
  }
590
552
  }
@@ -14319,7 +14281,7 @@ var DataSource;
14319
14281
  })(DataSource || (DataSource = {}));
14320
14282
 
14321
14283
  // This is updated with the package.json version on build.
14322
- const VERSION = "4.8.2";
14284
+ const VERSION = "4.8.3";
14323
14285
 
14324
14286
  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
14287
  //# sourceMappingURL=bruce-models.es5.js.map