bruce-models 1.8.0 → 1.8.1
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/bruce-models.es5.js +206 -37
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +204 -36
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -0
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/client-file/client-file.js +85 -32
- package/dist/lib/client-file/client-file.js.map +1 -1
- package/dist/lib/internal/uploader.js +77 -0
- package/dist/lib/internal/uploader.js.map +1 -0
- package/dist/lib/tileset/tileset.js +59 -4
- package/dist/lib/tileset/tileset.js.map +1 -1
- package/dist/types/api/api.d.ts +1 -1
- package/dist/types/bruce-models.d.ts +1 -0
- package/dist/types/client-file/client-file.d.ts +11 -2
- package/dist/types/internal/uploader.d.ts +16 -0
- package/dist/types/tileset/tileset.d.ts +5 -2
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -4717,6 +4717,69 @@ var EntityAttribute;
|
|
|
4717
4717
|
EntityAttribute.GetAttribute = GetAttribute;
|
|
4718
4718
|
})(EntityAttribute || (EntityAttribute = {}));
|
|
4719
4719
|
|
|
4720
|
+
var Uploader;
|
|
4721
|
+
(function (Uploader) {
|
|
4722
|
+
Uploader.MIN_LARGE_FILE_SIZE = 100000000; // 100MB.
|
|
4723
|
+
function DoMultiPartUpload(params) {
|
|
4724
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4725
|
+
const { file, api, urlSuffix: url, req, onProgress } = params;
|
|
4726
|
+
const FILE_PORTION_SIZE = 100000000; // 100MB.
|
|
4727
|
+
let fileSize = file.size;
|
|
4728
|
+
let fileOffset = 0;
|
|
4729
|
+
let filePartsCount = fileSize / FILE_PORTION_SIZE;
|
|
4730
|
+
let t = Math.trunc(filePartsCount);
|
|
4731
|
+
filePartsCount = filePartsCount > t ? t + 1 : t;
|
|
4732
|
+
let filePartIndex = 1;
|
|
4733
|
+
let uploadToken = ObjectUtils.UId();
|
|
4734
|
+
let data;
|
|
4735
|
+
while (fileOffset < fileSize) {
|
|
4736
|
+
let partSize = Math.min(FILE_PORTION_SIZE, fileSize - fileOffset);
|
|
4737
|
+
let retryCount = 5;
|
|
4738
|
+
let retryWait = 1000;
|
|
4739
|
+
while (retryCount > 0) {
|
|
4740
|
+
try {
|
|
4741
|
+
const blob = file.slice(fileOffset, fileOffset + partSize);
|
|
4742
|
+
const formData = new FormData();
|
|
4743
|
+
formData.append("originalFileName", file.name);
|
|
4744
|
+
formData.append("token", uploadToken);
|
|
4745
|
+
formData.append("count", "" + filePartsCount);
|
|
4746
|
+
formData.append("part", "" + filePartIndex);
|
|
4747
|
+
formData.append("file", blob);
|
|
4748
|
+
const reqParams = Api.PrepReqParams(req);
|
|
4749
|
+
reqParams.formData = formData;
|
|
4750
|
+
reqParams.onProgress = (progress) => {
|
|
4751
|
+
const sofar = fileOffset + progress.loaded;
|
|
4752
|
+
const percent = Math.round((sofar / file.size) * 100);
|
|
4753
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
4754
|
+
percent: percent,
|
|
4755
|
+
uploaded: false
|
|
4756
|
+
});
|
|
4757
|
+
};
|
|
4758
|
+
data = yield api.UPLOAD(url, blob, reqParams);
|
|
4759
|
+
retryCount = 0;
|
|
4760
|
+
}
|
|
4761
|
+
catch (up) {
|
|
4762
|
+
retryCount -= 1;
|
|
4763
|
+
if (retryCount <= 0) {
|
|
4764
|
+
throw up;
|
|
4765
|
+
}
|
|
4766
|
+
yield new Promise((res) => setTimeout(res, retryWait));
|
|
4767
|
+
retryWait = retryWait * 2;
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
fileOffset += partSize;
|
|
4771
|
+
filePartIndex++;
|
|
4772
|
+
}
|
|
4773
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
4774
|
+
percent: 100,
|
|
4775
|
+
uploaded: true
|
|
4776
|
+
});
|
|
4777
|
+
return data;
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4780
|
+
Uploader.DoMultiPartUpload = DoMultiPartUpload;
|
|
4781
|
+
})(Uploader || (Uploader = {}));
|
|
4782
|
+
|
|
4720
4783
|
/**
|
|
4721
4784
|
* Describes the "Client File" concept within Bruce.
|
|
4722
4785
|
* A client file is a record of a file uploaded to Bruce.
|
|
@@ -4783,33 +4846,67 @@ var ClientFile;
|
|
|
4783
4846
|
ClientFile.Delete = Delete;
|
|
4784
4847
|
function Upload(params) {
|
|
4785
4848
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4786
|
-
const { api, file, purpose, req } = params;
|
|
4849
|
+
const { api, file, purpose, req, onProgress } = params;
|
|
4787
4850
|
if (!file) {
|
|
4788
4851
|
throw ("File is required.");
|
|
4789
4852
|
}
|
|
4790
|
-
|
|
4791
|
-
if (
|
|
4792
|
-
|
|
4793
|
-
"Purpose": purpose
|
|
4794
|
-
};
|
|
4853
|
+
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
4854
|
+
if (!size) {
|
|
4855
|
+
throw ("You cannot upload a 0byte sized file.");
|
|
4795
4856
|
}
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4857
|
+
let clientFile;
|
|
4858
|
+
if (size > Uploader.MIN_LARGE_FILE_SIZE) {
|
|
4859
|
+
clientFile = yield Uploader.DoMultiPartUpload({
|
|
4860
|
+
api,
|
|
4861
|
+
file,
|
|
4862
|
+
urlSuffix: "fileUpload",
|
|
4863
|
+
req,
|
|
4864
|
+
onProgress
|
|
4865
|
+
});
|
|
4866
|
+
}
|
|
4867
|
+
else {
|
|
4868
|
+
const reqParams = Api.PrepReqParams(Object.assign({}, req));
|
|
4869
|
+
reqParams.onProgress = (progress) => {
|
|
4870
|
+
const percent = Math.round((progress.loaded / file.size) * 100);
|
|
4871
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
4872
|
+
percent: percent,
|
|
4873
|
+
uploaded: false
|
|
4803
4874
|
});
|
|
4804
|
-
}
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4875
|
+
};
|
|
4876
|
+
clientFile = yield api.UPLOAD("file/uploadNew", file, req);
|
|
4877
|
+
}
|
|
4878
|
+
if ((clientFile === null || clientFile === void 0 ? void 0 : clientFile.ID) && purpose) {
|
|
4879
|
+
yield UpdatePurpose({
|
|
4880
|
+
api,
|
|
4881
|
+
fileId: clientFile.ID,
|
|
4882
|
+
purpose,
|
|
4883
|
+
req
|
|
4884
|
+
});
|
|
4885
|
+
}
|
|
4886
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
4887
|
+
percent: 100,
|
|
4888
|
+
uploaded: true
|
|
4889
|
+
});
|
|
4890
|
+
return {
|
|
4891
|
+
clientFile
|
|
4892
|
+
};
|
|
4810
4893
|
});
|
|
4811
4894
|
}
|
|
4812
4895
|
ClientFile.Upload = Upload;
|
|
4896
|
+
function UpdatePurpose(params) {
|
|
4897
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4898
|
+
let { api, fileId, purpose, req: reqParams } = params;
|
|
4899
|
+
if (!purpose) {
|
|
4900
|
+
purpose = "";
|
|
4901
|
+
}
|
|
4902
|
+
yield api.POST("file/updatepurpose/" + fileId + "/?Purpose=" + purpose, {
|
|
4903
|
+
Purpose: purpose
|
|
4904
|
+
}, Api.PrepReqParams(reqParams));
|
|
4905
|
+
const cacheKey = GetCacheKey(fileId);
|
|
4906
|
+
api.Cache.RemoveByContains(cacheKey);
|
|
4907
|
+
});
|
|
4908
|
+
}
|
|
4909
|
+
ClientFile.UpdatePurpose = UpdatePurpose;
|
|
4813
4910
|
/**
|
|
4814
4911
|
* Uploads a temp file.
|
|
4815
4912
|
* This will return a temp file id which can be used in various endpoints.
|
|
@@ -4818,23 +4915,41 @@ var ClientFile;
|
|
|
4818
4915
|
*/
|
|
4819
4916
|
function UploadTemp(params) {
|
|
4820
4917
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4821
|
-
const { api, file, req } = params;
|
|
4918
|
+
const { api, file, req, onProgress } = params;
|
|
4822
4919
|
if (!file) {
|
|
4823
4920
|
throw ("File is required.");
|
|
4824
4921
|
}
|
|
4825
|
-
const
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4922
|
+
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
4923
|
+
if (!size) {
|
|
4924
|
+
throw ("You cannot upload a 0byte sized file.");
|
|
4925
|
+
}
|
|
4926
|
+
let tempFile;
|
|
4927
|
+
if (size > Uploader.MIN_LARGE_FILE_SIZE) {
|
|
4928
|
+
tempFile = yield Uploader.DoMultiPartUpload({
|
|
4929
|
+
api,
|
|
4930
|
+
file,
|
|
4931
|
+
urlSuffix: "tempFileUpload",
|
|
4932
|
+
req,
|
|
4933
|
+
onProgress
|
|
4934
|
+
});
|
|
4935
|
+
}
|
|
4936
|
+
else {
|
|
4937
|
+
req.onProgress = (progress) => {
|
|
4938
|
+
const percent = Math.round((progress.loaded / file.size) * 100);
|
|
4939
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
4940
|
+
percent: percent,
|
|
4941
|
+
uploaded: false
|
|
4831
4942
|
});
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4943
|
+
};
|
|
4944
|
+
tempFile = yield api.UPLOAD("file/uploadTemp", file, req);
|
|
4945
|
+
}
|
|
4946
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
4947
|
+
percent: 100,
|
|
4948
|
+
uploaded: true
|
|
4949
|
+
});
|
|
4950
|
+
return {
|
|
4951
|
+
tempFileId: tempFile["TempFile.ID"]
|
|
4952
|
+
};
|
|
4838
4953
|
});
|
|
4839
4954
|
}
|
|
4840
4955
|
ClientFile.UploadTemp = UploadTemp;
|
|
@@ -5165,11 +5280,38 @@ var Tileset;
|
|
|
5165
5280
|
Tileset.Update = Update;
|
|
5166
5281
|
function UploadFile(params) {
|
|
5167
5282
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5168
|
-
const { api,
|
|
5283
|
+
const { api, file, req, tilesetId, onProgress } = params;
|
|
5169
5284
|
if (!tilesetId || !file) {
|
|
5170
5285
|
throw ("Tileset ID and file are required.");
|
|
5171
5286
|
}
|
|
5172
|
-
|
|
5287
|
+
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
5288
|
+
if (!size) {
|
|
5289
|
+
throw ("You cannot upload a 0byte sized file.");
|
|
5290
|
+
}
|
|
5291
|
+
if (size > Uploader.MIN_LARGE_FILE_SIZE) {
|
|
5292
|
+
yield Uploader.DoMultiPartUpload({
|
|
5293
|
+
api,
|
|
5294
|
+
file,
|
|
5295
|
+
urlSuffix: `tileset/uploadFileEx/${tilesetId}/add`,
|
|
5296
|
+
req,
|
|
5297
|
+
onProgress
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
else {
|
|
5301
|
+
req.onProgress = (progress) => {
|
|
5302
|
+
const percent = Math.round((progress.loaded / file.size) * 100);
|
|
5303
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
5304
|
+
percent: percent,
|
|
5305
|
+
uploaded: false
|
|
5306
|
+
});
|
|
5307
|
+
};
|
|
5308
|
+
yield api.UPLOAD(`tileset/uploadFile/${tilesetId}/files`, file, req);
|
|
5309
|
+
}
|
|
5310
|
+
api.Cache.Remove(GetCacheKey(tilesetId, true));
|
|
5311
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
5312
|
+
percent: 100,
|
|
5313
|
+
uploaded: true
|
|
5314
|
+
});
|
|
5173
5315
|
});
|
|
5174
5316
|
}
|
|
5175
5317
|
Tileset.UploadFile = UploadFile;
|
|
@@ -5186,12 +5328,39 @@ var Tileset;
|
|
|
5186
5328
|
Tileset.DeleteFile = DeleteFile;
|
|
5187
5329
|
function UploadSrcFile(params) {
|
|
5188
5330
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5189
|
-
const { api,
|
|
5331
|
+
const { api, file, req, tilesetId, onProgress } = params;
|
|
5190
5332
|
if (!tilesetId || !file) {
|
|
5191
5333
|
throw ("Tileset ID and file are required.");
|
|
5192
5334
|
}
|
|
5193
|
-
|
|
5335
|
+
const size = file === null || file === void 0 ? void 0 : file.size;
|
|
5336
|
+
if (!size) {
|
|
5337
|
+
throw ("You cannot upload a 0byte sized file.");
|
|
5338
|
+
}
|
|
5339
|
+
if (size > Uploader.MIN_LARGE_FILE_SIZE) {
|
|
5340
|
+
yield Uploader.DoMultiPartUpload({
|
|
5341
|
+
api,
|
|
5342
|
+
file,
|
|
5343
|
+
urlSuffix: `tileset/uploadFileEx/${tilesetId}/src`,
|
|
5344
|
+
req,
|
|
5345
|
+
onProgress
|
|
5346
|
+
});
|
|
5347
|
+
}
|
|
5348
|
+
else {
|
|
5349
|
+
req.onProgress = (progress) => {
|
|
5350
|
+
const percent = Math.round((progress.loaded / file.size) * 100);
|
|
5351
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
5352
|
+
percent: percent,
|
|
5353
|
+
uploaded: false
|
|
5354
|
+
});
|
|
5355
|
+
};
|
|
5356
|
+
yield api.UPLOAD(`tileset/uploadFile/${tilesetId}/src`, file, req);
|
|
5357
|
+
}
|
|
5194
5358
|
api.Cache.Remove(GetCacheKey(tilesetId, true));
|
|
5359
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
5360
|
+
percent: 100,
|
|
5361
|
+
uploaded: true
|
|
5362
|
+
});
|
|
5363
|
+
return;
|
|
5195
5364
|
});
|
|
5196
5365
|
}
|
|
5197
5366
|
Tileset.UploadSrcFile = UploadSrcFile;
|
|
@@ -7217,5 +7386,5 @@ var Markup;
|
|
|
7217
7386
|
})(Circle = Markup.Circle || (Markup.Circle = {}));
|
|
7218
7387
|
})(Markup || (Markup = {}));
|
|
7219
7388
|
|
|
7220
|
-
export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup };
|
|
7389
|
+
export { AnnDocument, CustomForm, CustomFormContent, AbstractApi, Api, BruceApi, CamApi, IdmApi, GlobalApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityGlobe, EntityFilterGetter, BatchedDataGetter, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, PendingAction, MessageBroker, Style, Tileset, Permission, Session, UserGroup, User, Account, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader };
|
|
7221
7390
|
//# sourceMappingURL=bruce-models.es5.js.map
|