bruce-models 1.9.6 → 1.9.8

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.
Files changed (83) hide show
  1. package/dist/bruce-models.es5.js +10 -4
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +10 -4
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account-settings.js +2 -2
  6. package/dist/lib/account/account.js +185 -185
  7. package/dist/lib/ann-document/ann-document.js +86 -86
  8. package/dist/lib/api/abstract-api.js +246 -246
  9. package/dist/lib/api/api-getters.js +134 -134
  10. package/dist/lib/api/api.js +93 -93
  11. package/dist/lib/api/bruce-api.js +216 -216
  12. package/dist/lib/api/cam-api.js +82 -82
  13. package/dist/lib/api/global-api.js +81 -81
  14. package/dist/lib/api/idm-api.js +82 -82
  15. package/dist/lib/bruce-models.js +86 -86
  16. package/dist/lib/calculator/calculator.js +341 -335
  17. package/dist/lib/calculator/calculator.js.map +1 -1
  18. package/dist/lib/client-file/client-file.js +245 -245
  19. package/dist/lib/common/bounds.js +61 -61
  20. package/dist/lib/common/bruce-event.js +46 -46
  21. package/dist/lib/common/bruce-variable.js +60 -60
  22. package/dist/lib/common/cache.js +165 -165
  23. package/dist/lib/common/camera.js +11 -11
  24. package/dist/lib/common/cartes.js +123 -123
  25. package/dist/lib/common/carto.js +60 -60
  26. package/dist/lib/common/color.js +86 -86
  27. package/dist/lib/common/delay-queue.js +56 -56
  28. package/dist/lib/common/dictionary.js +2 -2
  29. package/dist/lib/common/geometry.js +120 -120
  30. package/dist/lib/common/transform.js +2 -2
  31. package/dist/lib/common/utc.js +39 -39
  32. package/dist/lib/custom-form/custom-form-content.js +26 -26
  33. package/dist/lib/custom-form/custom-form.js +106 -106
  34. package/dist/lib/data-lab/data-lab.js +49 -49
  35. package/dist/lib/entity/entity-attachment-type.js +83 -83
  36. package/dist/lib/entity/entity-attachment.js +122 -122
  37. package/dist/lib/entity/entity-attribute.js +29 -29
  38. package/dist/lib/entity/entity-comment.js +82 -82
  39. package/dist/lib/entity/entity-coords.js +149 -149
  40. package/dist/lib/entity/entity-link.js +82 -82
  41. package/dist/lib/entity/entity-lod-category.js +100 -100
  42. package/dist/lib/entity/entity-lod.js +185 -185
  43. package/dist/lib/entity/entity-relation-type.js +109 -109
  44. package/dist/lib/entity/entity-relation.js +132 -132
  45. package/dist/lib/entity/entity-source.js +136 -136
  46. package/dist/lib/entity/entity-tag.js +149 -149
  47. package/dist/lib/entity/entity-type-visual-settings.js +13 -13
  48. package/dist/lib/entity/entity-type.js +113 -113
  49. package/dist/lib/entity/entity.js +319 -319
  50. package/dist/lib/entity/getters/batched-data-getter.js +84 -84
  51. package/dist/lib/entity/getters/entity-filter-getter.js +303 -303
  52. package/dist/lib/entity/getters/entity-globe.js +211 -211
  53. package/dist/lib/entity/getters/view-monitor.js +2 -2
  54. package/dist/lib/import/import-cad.js +53 -53
  55. package/dist/lib/import/import-csv.js +23 -23
  56. package/dist/lib/import/import-json.js +23 -23
  57. package/dist/lib/import/import-kml.js +23 -23
  58. package/dist/lib/import/imported-file.js +91 -91
  59. package/dist/lib/internal/uploader.js +76 -76
  60. package/dist/lib/markup/markup.js +185 -185
  61. package/dist/lib/plugin/plugin.js +83 -83
  62. package/dist/lib/program-key/program-key.js +111 -111
  63. package/dist/lib/project/menu-item.js +121 -121
  64. package/dist/lib/project/project-view-bookmark.js +147 -147
  65. package/dist/lib/project/project-view-legacy-tile.js +77 -77
  66. package/dist/lib/project/project-view-tile.js +125 -125
  67. package/dist/lib/project/project-view.js +133 -133
  68. package/dist/lib/project/zoom-control.js +17 -17
  69. package/dist/lib/server/message-broker.js +142 -142
  70. package/dist/lib/server/pending-action.js +71 -71
  71. package/dist/lib/server/task.js +63 -63
  72. package/dist/lib/style/style.js +117 -117
  73. package/dist/lib/tileset/tileset.js +415 -415
  74. package/dist/lib/user/permission.js +20 -20
  75. package/dist/lib/user/session.js +137 -137
  76. package/dist/lib/user/user-group.js +94 -94
  77. package/dist/lib/user/user.js +446 -446
  78. package/dist/lib/util/encrypt-utils.js +19 -19
  79. package/dist/lib/util/math-utils.js +40 -40
  80. package/dist/lib/util/object-utils.js +17 -17
  81. package/dist/lib/util/path-utils.js +61 -61
  82. package/dist/lib/util/url-utils.js +94 -94
  83. package/package.json +1 -1
@@ -1,416 +1,416 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Tileset = void 0;
13
- const api_1 = require("../api/api");
14
- const uploader_1 = require("../internal/uploader");
15
- /**
16
- * Describes the "Tileset" concept in Bruce.
17
- *
18
- * Tilesets come in three possible variants,
19
- * 1- A set of instructions to generate a tileset.
20
- * 2- Settings to load a tileset hosted elsewhere.
21
- * 3- A set of user-provided files to serve.
22
- *
23
- * Read the individual tileset-type settings for each variant.
24
- */
25
- var Tileset;
26
- (function (Tileset) {
27
- function GetCacheKey(tilesetId, loadFiles) {
28
- return `${api_1.Api.ECacheKey.Tileset}${api_1.Api.ECacheKey.Id}${tilesetId}${api_1.Api.ECacheKey.Id}${loadFiles}`;
29
- }
30
- Tileset.GetCacheKey = GetCacheKey;
31
- function GetListCacheKey() {
32
- return api_1.Api.ECacheKey.Tileset;
33
- }
34
- Tileset.GetListCacheKey = GetListCacheKey;
35
- let EType;
36
- (function (EType) {
37
- EType["PointCloud"] = "POINT_CLOUD";
38
- EType["GeoMap"] = "GEO_MAP";
39
- EType["EntitiesMap"] = "ENTITIES_MAP";
40
- EType["EntitiesSet"] = "ENTITIES_SET";
41
- EType["Cad"] = "MODEL";
42
- EType["Terrain"] = "GEO_TERR";
43
- EType["ExternalTerrain"] = "EXTERNAL_TERR";
44
- EType["ExternalGeoMap"] = "EXTERNAL_MAP";
45
- EType["LegacyEntitiesSet"] = "D";
46
- EType["LegacyStatic"] = "S";
47
- EType["LegacyExternal"] = "X";
48
- })(EType = Tileset.EType || (Tileset.EType = {}));
49
- let EPivot;
50
- (function (EPivot) {
51
- EPivot["None"] = "none";
52
- EPivot["Box"] = "box";
53
- EPivot["Weight"] = "weight";
54
- EPivot["UCS"] = "ucs";
55
- })(EPivot = Tileset.EPivot || (Tileset.EPivot = {}));
56
- function Get(params) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const { api, tilesetId, loadFiles, req: reqParams } = params;
59
- if (!tilesetId) {
60
- throw ("Tileset ID is required.");
61
- }
62
- const cacheData = api.GetCacheItem(GetCacheKey(tilesetId, loadFiles), reqParams);
63
- if (cacheData) {
64
- return cacheData;
65
- }
66
- const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
67
- try {
68
- const data = yield api.GET(`tileset/get/${tilesetId}?noFiles=${Boolean(loadFiles) ? 0 : 1}`, reqParams);
69
- res({
70
- tileset: data
71
- });
72
- }
73
- catch (e) {
74
- rej(e);
75
- }
76
- }));
77
- api.Cache.Set(GetCacheKey(tilesetId, loadFiles), prom, api_1.Api.DEFAULT_CACHE_DURATION);
78
- return prom;
79
- });
80
- }
81
- Tileset.Get = Get;
82
- /**
83
- * Returns tileset types for given tileset ids.
84
- * @param params
85
- * @returns
86
- */
87
- function GetTypes(params) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- // Our api is auto-converting legacy types right now which makes it impossible to know what they are.
90
- // This uses the legacy end-point which doesn't do that...
91
- const { api, tilesetIds, req: reqParams } = params;
92
- const mapping = {};
93
- if (tilesetIds.length == 1) {
94
- const tileset = yield api.GET("ui.tileset/" + tilesetIds[0], api_1.Api.PrepReqParams(reqParams));
95
- if (tileset) {
96
- mapping[tilesetIds[0]] = tileset.Type;
97
- }
98
- }
99
- else if (tilesetIds.length > 1) {
100
- const tilesets = yield api.GET("ui.tilesets", api_1.Api.PrepReqParams(reqParams));
101
- for (const tileset of tilesets) {
102
- if (tilesetIds.indexOf(tileset.ID) >= 0) {
103
- mapping[tileset.ID] = tileset.Type;
104
- }
105
- }
106
- }
107
- return {
108
- typeMapping: mapping
109
- };
110
- });
111
- }
112
- Tileset.GetTypes = GetTypes;
113
- function GetList(params) {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- const { api, req: reqParams } = params;
116
- const cacheData = api.GetCacheItem(GetListCacheKey(), reqParams);
117
- if (cacheData) {
118
- return cacheData;
119
- }
120
- const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
121
- try {
122
- const data = yield api.GET("tileset/getList", reqParams);
123
- res({
124
- tilesets: data
125
- });
126
- }
127
- catch (e) {
128
- rej(e);
129
- }
130
- }));
131
- api.Cache.Set(GetListCacheKey(), req, api_1.Api.DEFAULT_CACHE_DURATION);
132
- return req;
133
- });
134
- }
135
- Tileset.GetList = GetList;
136
- function Delete(params) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- const { api, tilesetId, req: reqParams } = params;
139
- if (!tilesetId) {
140
- throw ("Tileset ID is required.");
141
- }
142
- yield api.DELETE(`tileset/delete/${tilesetId}`, reqParams);
143
- api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset + api_1.Api.ECacheKey.Id + tilesetId);
144
- api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset);
145
- });
146
- }
147
- Tileset.Delete = Delete;
148
- function Update(params) {
149
- return __awaiter(this, void 0, void 0, function* () {
150
- let { api, tileset: data, req: reqParams } = params;
151
- if (!(data === null || data === void 0 ? void 0 : data.name) || !(data === null || data === void 0 ? void 0 : data.type)) {
152
- throw ("Tileset name and type are required.");
153
- }
154
- let isNew = !data.id;
155
- if (isNew) {
156
- const res = yield api.GET(`tileset/new?type=${data.type}&name=${api_1.Api.Encode(data.name)}`, reqParams);
157
- data = Object.assign(Object.assign(Object.assign({}, res), data), { settings: Object.assign(Object.assign({}, res.settings), data.settings), id: res.id });
158
- }
159
- yield api.POST(`tileset/update/${data.id}`, data, api_1.Api.PrepReqParams(reqParams));
160
- api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset + api_1.Api.ECacheKey.Id + data.id);
161
- api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset);
162
- return {
163
- tileset: data
164
- };
165
- });
166
- }
167
- Tileset.Update = Update;
168
- function UploadFile(params) {
169
- return __awaiter(this, void 0, void 0, function* () {
170
- let { api, file, req, tilesetId, onProgress } = params;
171
- if (!tilesetId || !file) {
172
- throw ("Tileset ID and file are required.");
173
- }
174
- const size = file === null || file === void 0 ? void 0 : file.size;
175
- if (!size) {
176
- throw ("You cannot upload a 0byte sized file.");
177
- }
178
- req = api_1.Api.PrepReqParams(req);
179
- if (size > uploader_1.Uploader.MIN_LARGE_FILE_SIZE) {
180
- yield uploader_1.Uploader.DoMultiPartUpload({
181
- api,
182
- file,
183
- urlSuffix: `tileset/uploadFileEx/${tilesetId}/add`,
184
- req,
185
- onProgress
186
- });
187
- }
188
- else {
189
- req.onProgress = (progress) => {
190
- const percent = Math.round((progress.loaded / file.size) * 100);
191
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
192
- percent: percent,
193
- uploaded: false
194
- });
195
- };
196
- yield api.UPLOAD(`tileset/uploadFile/${tilesetId}/files`, file, req);
197
- }
198
- api.Cache.Remove(GetCacheKey(tilesetId, true));
199
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
200
- percent: 100,
201
- uploaded: true
202
- });
203
- });
204
- }
205
- Tileset.UploadFile = UploadFile;
206
- function DeleteFile(params) {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- const { api, tilesetId, file, req: reqParams } = params;
209
- if (!tilesetId || !file) {
210
- throw ("Tileset ID and file are required.");
211
- }
212
- yield api.DELETE(`tileset/deleteFile/${tilesetId}/files/${file}`, reqParams);
213
- api.Cache.Remove(GetCacheKey(tilesetId, true));
214
- });
215
- }
216
- Tileset.DeleteFile = DeleteFile;
217
- function UploadSrcFile(params) {
218
- return __awaiter(this, void 0, void 0, function* () {
219
- let { api, file, req, tilesetId, onProgress } = params;
220
- if (!tilesetId || !file) {
221
- throw ("Tileset ID and file are required.");
222
- }
223
- const size = file === null || file === void 0 ? void 0 : file.size;
224
- if (!size) {
225
- throw ("You cannot upload a 0byte sized file.");
226
- }
227
- req = api_1.Api.PrepReqParams(req);
228
- if (size > uploader_1.Uploader.MIN_LARGE_FILE_SIZE) {
229
- yield uploader_1.Uploader.DoMultiPartUpload({
230
- api,
231
- file,
232
- urlSuffix: `tileset/uploadFileEx/${tilesetId}/src`,
233
- req,
234
- onProgress
235
- });
236
- }
237
- else {
238
- req.onProgress = (progress) => {
239
- const percent = Math.round((progress.loaded / file.size) * 100);
240
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
241
- percent: percent,
242
- uploaded: false
243
- });
244
- };
245
- yield api.UPLOAD(`tileset/uploadFile/${tilesetId}/src`, file, req);
246
- }
247
- api.Cache.Remove(GetCacheKey(tilesetId, true));
248
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
249
- percent: 100,
250
- uploaded: true
251
- });
252
- return;
253
- });
254
- }
255
- Tileset.UploadSrcFile = UploadSrcFile;
256
- function DeleteSrcFile(params) {
257
- return __awaiter(this, void 0, void 0, function* () {
258
- const { api, tilesetId, file, req: reqParams } = params;
259
- if (!tilesetId || !file) {
260
- throw ("Tileset ID and file are required.");
261
- }
262
- yield api.DELETE(`tileset/deleteFile/${tilesetId}/src/${file}`, reqParams);
263
- api.Cache.Remove(GetCacheKey(tilesetId, true));
264
- });
265
- }
266
- Tileset.DeleteSrcFile = DeleteSrcFile;
267
- function GetFileUrl(params) {
268
- let { api, tilesetId, file } = params;
269
- if (!tilesetId) {
270
- throw ("Tileset ID is required.");
271
- }
272
- if (!file) {
273
- file = "";
274
- }
275
- return api.GetBaseUrl() + `tileset/getFile/${tilesetId}/files/${file}`;
276
- }
277
- Tileset.GetFileUrl = GetFileUrl;
278
- function GetSrcFileUrl(params) {
279
- let { api, tilesetId, file } = params;
280
- if (!tilesetId) {
281
- throw ("Tileset ID is required.");
282
- }
283
- if (!file) {
284
- file = "";
285
- }
286
- return api.GetBaseUrl() + `tileset/getFile/${tilesetId}/src/${file}`;
287
- }
288
- Tileset.GetSrcFileUrl = GetSrcFileUrl;
289
- function GetPublicFileUrl(params) {
290
- let { api, tilesetId, file } = params;
291
- if (!tilesetId) {
292
- throw ("Tileset ID is required.");
293
- }
294
- if (!file) {
295
- file = "";
296
- }
297
- return api.GetBaseUrl() + `tileset/file/${tilesetId}/${file}`;
298
- }
299
- Tileset.GetPublicFileUrl = GetPublicFileUrl;
300
- function Generate(params) {
301
- return __awaiter(this, void 0, void 0, function* () {
302
- const { api, tilesetId, req: reqParams } = params;
303
- if (!tilesetId) {
304
- throw ("Tileset ID is required.");
305
- }
306
- const res = yield api.GET(`tileset/generate/${tilesetId}`, api_1.Api.PrepReqParams(reqParams));
307
- return {
308
- pendingActionId: res.ID
309
- };
310
- });
311
- }
312
- Tileset.Generate = Generate;
313
- let Publish;
314
- (function (Publish) {
315
- function GetCacheKey(accountId, tilesetId) {
316
- if (!tilesetId) {
317
- tilesetId = "";
318
- }
319
- return api_1.Api.ECacheKey.PublishTileset + api_1.Api.ECacheKey.Id + accountId + api_1.Api.ECacheKey.Id + tilesetId;
320
- }
321
- Publish.GetCacheKey = GetCacheKey;
322
- function Update(params) {
323
- return __awaiter(this, void 0, void 0, function* () {
324
- const { api, published: data, req: reqParams } = params;
325
- if (!(data === null || data === void 0 ? void 0 : data["Tileset.ID"]) || !(data === null || data === void 0 ? void 0 : data["PublishedBy.ClientAccount.ID"]) || !(data === null || data === void 0 ? void 0 : data["PublishedBy.User.ID"])) {
326
- throw ("Tileset ID, client account ID, and user ID are required.");
327
- }
328
- if (!data.ID) {
329
- data.ID = 0;
330
- }
331
- const res = yield api.POST(`tileset/${data.ID}`, data, reqParams);
332
- const req = {
333
- "ClientAccount.ID": data["EnabledFor.ClientAccount.ID"]
334
- };
335
- data.ID = res.ID;
336
- yield api.POST(`tileset/${data.ID}/enableForAccounts`, req, reqParams);
337
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
338
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
339
- return {
340
- published: data
341
- };
342
- });
343
- }
344
- Publish.Update = Update;
345
- function Get(params) {
346
- return __awaiter(this, void 0, void 0, function* () {
347
- const { api, accountId, tilesetId, req: reqParams } = params;
348
- if (!accountId || !tilesetId) {
349
- throw ("Client account ID and tileset ID are required.");
350
- }
351
- const cacheData = api.GetCacheItem(GetCacheKey(accountId, tilesetId), reqParams);
352
- if (cacheData) {
353
- return cacheData;
354
- }
355
- const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
356
- try {
357
- const data = yield api.GET(`tilesetByPublisher/${accountId}/${tilesetId}`, reqParams);
358
- res({
359
- published: data
360
- });
361
- }
362
- catch (e) {
363
- rej(e);
364
- }
365
- }));
366
- api.Cache.Set(GetCacheKey(accountId, tilesetId), prom);
367
- return prom;
368
- });
369
- }
370
- Publish.Get = Get;
371
- function GetList(params) {
372
- return __awaiter(this, void 0, void 0, function* () {
373
- const { api, accountId, req: reqParams } = params;
374
- if (!accountId) {
375
- throw ("Client account ID is required.");
376
- }
377
- const cacheData = api.GetCacheItem(GetCacheKey(accountId), reqParams);
378
- if (cacheData) {
379
- return cacheData;
380
- }
381
- const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
382
- try {
383
- const data = yield api.GET(`tilesets/enabledForAccount/${accountId}`, reqParams);
384
- res({
385
- published: data.Items
386
- });
387
- }
388
- catch (e) {
389
- rej(e);
390
- }
391
- }));
392
- api.Cache.Set(GetCacheKey(accountId), req);
393
- return req;
394
- });
395
- }
396
- Publish.GetList = GetList;
397
- })(Publish = Tileset.Publish || (Tileset.Publish = {}));
398
- let Settings;
399
- (function (Settings) {
400
- let EMapTileSize;
401
- (function (EMapTileSize) {
402
- EMapTileSize[EMapTileSize["IMG_256"] = 256] = "IMG_256";
403
- EMapTileSize[EMapTileSize["IMG_512"] = 512] = "IMG_512";
404
- EMapTileSize[EMapTileSize["IMG_1024"] = 1024] = "IMG_1024";
405
- EMapTileSize[EMapTileSize["IMG_2048"] = 2048] = "IMG_2048";
406
- })(EMapTileSize = Settings.EMapTileSize || (Settings.EMapTileSize = {}));
407
- let EExternalMapType;
408
- (function (EExternalMapType) {
409
- EExternalMapType["TileMapImagery"] = "TileMapImagery";
410
- EExternalMapType["OpenStreetMapImagery"] = "OpenStreetMapImagery";
411
- EExternalMapType["MapBoxImagery"] = "MapBoxImagery";
412
- EExternalMapType["CesiumIon"] = "CesiumIon";
413
- })(EExternalMapType = Settings.EExternalMapType || (Settings.EExternalMapType = {}));
414
- })(Settings = Tileset.Settings || (Tileset.Settings = {}));
415
- })(Tileset = exports.Tileset || (exports.Tileset = {}));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Tileset = void 0;
13
+ const api_1 = require("../api/api");
14
+ const uploader_1 = require("../internal/uploader");
15
+ /**
16
+ * Describes the "Tileset" concept in Bruce.
17
+ *
18
+ * Tilesets come in three possible variants,
19
+ * 1- A set of instructions to generate a tileset.
20
+ * 2- Settings to load a tileset hosted elsewhere.
21
+ * 3- A set of user-provided files to serve.
22
+ *
23
+ * Read the individual tileset-type settings for each variant.
24
+ */
25
+ var Tileset;
26
+ (function (Tileset) {
27
+ function GetCacheKey(tilesetId, loadFiles) {
28
+ return `${api_1.Api.ECacheKey.Tileset}${api_1.Api.ECacheKey.Id}${tilesetId}${api_1.Api.ECacheKey.Id}${loadFiles}`;
29
+ }
30
+ Tileset.GetCacheKey = GetCacheKey;
31
+ function GetListCacheKey() {
32
+ return api_1.Api.ECacheKey.Tileset;
33
+ }
34
+ Tileset.GetListCacheKey = GetListCacheKey;
35
+ let EType;
36
+ (function (EType) {
37
+ EType["PointCloud"] = "POINT_CLOUD";
38
+ EType["GeoMap"] = "GEO_MAP";
39
+ EType["EntitiesMap"] = "ENTITIES_MAP";
40
+ EType["EntitiesSet"] = "ENTITIES_SET";
41
+ EType["Cad"] = "MODEL";
42
+ EType["Terrain"] = "GEO_TERR";
43
+ EType["ExternalTerrain"] = "EXTERNAL_TERR";
44
+ EType["ExternalGeoMap"] = "EXTERNAL_MAP";
45
+ EType["LegacyEntitiesSet"] = "D";
46
+ EType["LegacyStatic"] = "S";
47
+ EType["LegacyExternal"] = "X";
48
+ })(EType = Tileset.EType || (Tileset.EType = {}));
49
+ let EPivot;
50
+ (function (EPivot) {
51
+ EPivot["None"] = "none";
52
+ EPivot["Box"] = "box";
53
+ EPivot["Weight"] = "weight";
54
+ EPivot["UCS"] = "ucs";
55
+ })(EPivot = Tileset.EPivot || (Tileset.EPivot = {}));
56
+ function Get(params) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const { api, tilesetId, loadFiles, req: reqParams } = params;
59
+ if (!tilesetId) {
60
+ throw ("Tileset ID is required.");
61
+ }
62
+ const cacheData = api.GetCacheItem(GetCacheKey(tilesetId, loadFiles), reqParams);
63
+ if (cacheData) {
64
+ return cacheData;
65
+ }
66
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
67
+ try {
68
+ const data = yield api.GET(`tileset/get/${tilesetId}?noFiles=${Boolean(loadFiles) ? 0 : 1}`, reqParams);
69
+ res({
70
+ tileset: data
71
+ });
72
+ }
73
+ catch (e) {
74
+ rej(e);
75
+ }
76
+ }));
77
+ api.Cache.Set(GetCacheKey(tilesetId, loadFiles), prom, api_1.Api.DEFAULT_CACHE_DURATION);
78
+ return prom;
79
+ });
80
+ }
81
+ Tileset.Get = Get;
82
+ /**
83
+ * Returns tileset types for given tileset ids.
84
+ * @param params
85
+ * @returns
86
+ */
87
+ function GetTypes(params) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ // Our api is auto-converting legacy types right now which makes it impossible to know what they are.
90
+ // This uses the legacy end-point which doesn't do that...
91
+ const { api, tilesetIds, req: reqParams } = params;
92
+ const mapping = {};
93
+ if (tilesetIds.length == 1) {
94
+ const tileset = yield api.GET("ui.tileset/" + tilesetIds[0], api_1.Api.PrepReqParams(reqParams));
95
+ if (tileset) {
96
+ mapping[tilesetIds[0]] = tileset.Type;
97
+ }
98
+ }
99
+ else if (tilesetIds.length > 1) {
100
+ const tilesets = yield api.GET("ui.tilesets", api_1.Api.PrepReqParams(reqParams));
101
+ for (const tileset of tilesets) {
102
+ if (tilesetIds.indexOf(tileset.ID) >= 0) {
103
+ mapping[tileset.ID] = tileset.Type;
104
+ }
105
+ }
106
+ }
107
+ return {
108
+ typeMapping: mapping
109
+ };
110
+ });
111
+ }
112
+ Tileset.GetTypes = GetTypes;
113
+ function GetList(params) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ const { api, req: reqParams } = params;
116
+ const cacheData = api.GetCacheItem(GetListCacheKey(), reqParams);
117
+ if (cacheData) {
118
+ return cacheData;
119
+ }
120
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
121
+ try {
122
+ const data = yield api.GET("tileset/getList", reqParams);
123
+ res({
124
+ tilesets: data
125
+ });
126
+ }
127
+ catch (e) {
128
+ rej(e);
129
+ }
130
+ }));
131
+ api.Cache.Set(GetListCacheKey(), req, api_1.Api.DEFAULT_CACHE_DURATION);
132
+ return req;
133
+ });
134
+ }
135
+ Tileset.GetList = GetList;
136
+ function Delete(params) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ const { api, tilesetId, req: reqParams } = params;
139
+ if (!tilesetId) {
140
+ throw ("Tileset ID is required.");
141
+ }
142
+ yield api.DELETE(`tileset/delete/${tilesetId}`, reqParams);
143
+ api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset + api_1.Api.ECacheKey.Id + tilesetId);
144
+ api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset);
145
+ });
146
+ }
147
+ Tileset.Delete = Delete;
148
+ function Update(params) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ let { api, tileset: data, req: reqParams } = params;
151
+ if (!(data === null || data === void 0 ? void 0 : data.name) || !(data === null || data === void 0 ? void 0 : data.type)) {
152
+ throw ("Tileset name and type are required.");
153
+ }
154
+ let isNew = !data.id;
155
+ if (isNew) {
156
+ const res = yield api.GET(`tileset/new?type=${data.type}&name=${api_1.Api.Encode(data.name)}`, reqParams);
157
+ data = Object.assign(Object.assign(Object.assign({}, res), data), { settings: Object.assign(Object.assign({}, res.settings), data.settings), id: res.id });
158
+ }
159
+ yield api.POST(`tileset/update/${data.id}`, data, api_1.Api.PrepReqParams(reqParams));
160
+ api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset + api_1.Api.ECacheKey.Id + data.id);
161
+ api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Tileset);
162
+ return {
163
+ tileset: data
164
+ };
165
+ });
166
+ }
167
+ Tileset.Update = Update;
168
+ function UploadFile(params) {
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ let { api, file, req, tilesetId, onProgress } = params;
171
+ if (!tilesetId || !file) {
172
+ throw ("Tileset ID and file are required.");
173
+ }
174
+ const size = file === null || file === void 0 ? void 0 : file.size;
175
+ if (!size) {
176
+ throw ("You cannot upload a 0byte sized file.");
177
+ }
178
+ req = api_1.Api.PrepReqParams(req);
179
+ if (size > uploader_1.Uploader.MIN_LARGE_FILE_SIZE) {
180
+ yield uploader_1.Uploader.DoMultiPartUpload({
181
+ api,
182
+ file,
183
+ urlSuffix: `tileset/uploadFileEx/${tilesetId}/add`,
184
+ req,
185
+ onProgress
186
+ });
187
+ }
188
+ else {
189
+ req.onProgress = (progress) => {
190
+ const percent = Math.round((progress.loaded / file.size) * 100);
191
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
192
+ percent: percent,
193
+ uploaded: false
194
+ });
195
+ };
196
+ yield api.UPLOAD(`tileset/uploadFile/${tilesetId}/files`, file, req);
197
+ }
198
+ api.Cache.Remove(GetCacheKey(tilesetId, true));
199
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
200
+ percent: 100,
201
+ uploaded: true
202
+ });
203
+ });
204
+ }
205
+ Tileset.UploadFile = UploadFile;
206
+ function DeleteFile(params) {
207
+ return __awaiter(this, void 0, void 0, function* () {
208
+ const { api, tilesetId, file, req: reqParams } = params;
209
+ if (!tilesetId || !file) {
210
+ throw ("Tileset ID and file are required.");
211
+ }
212
+ yield api.DELETE(`tileset/deleteFile/${tilesetId}/files/${file}`, reqParams);
213
+ api.Cache.Remove(GetCacheKey(tilesetId, true));
214
+ });
215
+ }
216
+ Tileset.DeleteFile = DeleteFile;
217
+ function UploadSrcFile(params) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ let { api, file, req, tilesetId, onProgress } = params;
220
+ if (!tilesetId || !file) {
221
+ throw ("Tileset ID and file are required.");
222
+ }
223
+ const size = file === null || file === void 0 ? void 0 : file.size;
224
+ if (!size) {
225
+ throw ("You cannot upload a 0byte sized file.");
226
+ }
227
+ req = api_1.Api.PrepReqParams(req);
228
+ if (size > uploader_1.Uploader.MIN_LARGE_FILE_SIZE) {
229
+ yield uploader_1.Uploader.DoMultiPartUpload({
230
+ api,
231
+ file,
232
+ urlSuffix: `tileset/uploadFileEx/${tilesetId}/src`,
233
+ req,
234
+ onProgress
235
+ });
236
+ }
237
+ else {
238
+ req.onProgress = (progress) => {
239
+ const percent = Math.round((progress.loaded / file.size) * 100);
240
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
241
+ percent: percent,
242
+ uploaded: false
243
+ });
244
+ };
245
+ yield api.UPLOAD(`tileset/uploadFile/${tilesetId}/src`, file, req);
246
+ }
247
+ api.Cache.Remove(GetCacheKey(tilesetId, true));
248
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress({
249
+ percent: 100,
250
+ uploaded: true
251
+ });
252
+ return;
253
+ });
254
+ }
255
+ Tileset.UploadSrcFile = UploadSrcFile;
256
+ function DeleteSrcFile(params) {
257
+ return __awaiter(this, void 0, void 0, function* () {
258
+ const { api, tilesetId, file, req: reqParams } = params;
259
+ if (!tilesetId || !file) {
260
+ throw ("Tileset ID and file are required.");
261
+ }
262
+ yield api.DELETE(`tileset/deleteFile/${tilesetId}/src/${file}`, reqParams);
263
+ api.Cache.Remove(GetCacheKey(tilesetId, true));
264
+ });
265
+ }
266
+ Tileset.DeleteSrcFile = DeleteSrcFile;
267
+ function GetFileUrl(params) {
268
+ let { api, tilesetId, file } = params;
269
+ if (!tilesetId) {
270
+ throw ("Tileset ID is required.");
271
+ }
272
+ if (!file) {
273
+ file = "";
274
+ }
275
+ return api.GetBaseUrl() + `tileset/getFile/${tilesetId}/files/${file}`;
276
+ }
277
+ Tileset.GetFileUrl = GetFileUrl;
278
+ function GetSrcFileUrl(params) {
279
+ let { api, tilesetId, file } = params;
280
+ if (!tilesetId) {
281
+ throw ("Tileset ID is required.");
282
+ }
283
+ if (!file) {
284
+ file = "";
285
+ }
286
+ return api.GetBaseUrl() + `tileset/getFile/${tilesetId}/src/${file}`;
287
+ }
288
+ Tileset.GetSrcFileUrl = GetSrcFileUrl;
289
+ function GetPublicFileUrl(params) {
290
+ let { api, tilesetId, file } = params;
291
+ if (!tilesetId) {
292
+ throw ("Tileset ID is required.");
293
+ }
294
+ if (!file) {
295
+ file = "";
296
+ }
297
+ return api.GetBaseUrl() + `tileset/file/${tilesetId}/${file}`;
298
+ }
299
+ Tileset.GetPublicFileUrl = GetPublicFileUrl;
300
+ function Generate(params) {
301
+ return __awaiter(this, void 0, void 0, function* () {
302
+ const { api, tilesetId, req: reqParams } = params;
303
+ if (!tilesetId) {
304
+ throw ("Tileset ID is required.");
305
+ }
306
+ const res = yield api.GET(`tileset/generate/${tilesetId}`, api_1.Api.PrepReqParams(reqParams));
307
+ return {
308
+ pendingActionId: res.ID
309
+ };
310
+ });
311
+ }
312
+ Tileset.Generate = Generate;
313
+ let Publish;
314
+ (function (Publish) {
315
+ function GetCacheKey(accountId, tilesetId) {
316
+ if (!tilesetId) {
317
+ tilesetId = "";
318
+ }
319
+ return api_1.Api.ECacheKey.PublishTileset + api_1.Api.ECacheKey.Id + accountId + api_1.Api.ECacheKey.Id + tilesetId;
320
+ }
321
+ Publish.GetCacheKey = GetCacheKey;
322
+ function Update(params) {
323
+ return __awaiter(this, void 0, void 0, function* () {
324
+ const { api, published: data, req: reqParams } = params;
325
+ if (!(data === null || data === void 0 ? void 0 : data["Tileset.ID"]) || !(data === null || data === void 0 ? void 0 : data["PublishedBy.ClientAccount.ID"]) || !(data === null || data === void 0 ? void 0 : data["PublishedBy.User.ID"])) {
326
+ throw ("Tileset ID, client account ID, and user ID are required.");
327
+ }
328
+ if (!data.ID) {
329
+ data.ID = 0;
330
+ }
331
+ const res = yield api.POST(`tileset/${data.ID}`, data, reqParams);
332
+ const req = {
333
+ "ClientAccount.ID": data["EnabledFor.ClientAccount.ID"]
334
+ };
335
+ data.ID = res.ID;
336
+ yield api.POST(`tileset/${data.ID}/enableForAccounts`, req, reqParams);
337
+ api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
338
+ api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
339
+ return {
340
+ published: data
341
+ };
342
+ });
343
+ }
344
+ Publish.Update = Update;
345
+ function Get(params) {
346
+ return __awaiter(this, void 0, void 0, function* () {
347
+ const { api, accountId, tilesetId, req: reqParams } = params;
348
+ if (!accountId || !tilesetId) {
349
+ throw ("Client account ID and tileset ID are required.");
350
+ }
351
+ const cacheData = api.GetCacheItem(GetCacheKey(accountId, tilesetId), reqParams);
352
+ if (cacheData) {
353
+ return cacheData;
354
+ }
355
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
356
+ try {
357
+ const data = yield api.GET(`tilesetByPublisher/${accountId}/${tilesetId}`, reqParams);
358
+ res({
359
+ published: data
360
+ });
361
+ }
362
+ catch (e) {
363
+ rej(e);
364
+ }
365
+ }));
366
+ api.Cache.Set(GetCacheKey(accountId, tilesetId), prom);
367
+ return prom;
368
+ });
369
+ }
370
+ Publish.Get = Get;
371
+ function GetList(params) {
372
+ return __awaiter(this, void 0, void 0, function* () {
373
+ const { api, accountId, req: reqParams } = params;
374
+ if (!accountId) {
375
+ throw ("Client account ID is required.");
376
+ }
377
+ const cacheData = api.GetCacheItem(GetCacheKey(accountId), reqParams);
378
+ if (cacheData) {
379
+ return cacheData;
380
+ }
381
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
382
+ try {
383
+ const data = yield api.GET(`tilesets/enabledForAccount/${accountId}`, reqParams);
384
+ res({
385
+ published: data.Items
386
+ });
387
+ }
388
+ catch (e) {
389
+ rej(e);
390
+ }
391
+ }));
392
+ api.Cache.Set(GetCacheKey(accountId), req);
393
+ return req;
394
+ });
395
+ }
396
+ Publish.GetList = GetList;
397
+ })(Publish = Tileset.Publish || (Tileset.Publish = {}));
398
+ let Settings;
399
+ (function (Settings) {
400
+ let EMapTileSize;
401
+ (function (EMapTileSize) {
402
+ EMapTileSize[EMapTileSize["IMG_256"] = 256] = "IMG_256";
403
+ EMapTileSize[EMapTileSize["IMG_512"] = 512] = "IMG_512";
404
+ EMapTileSize[EMapTileSize["IMG_1024"] = 1024] = "IMG_1024";
405
+ EMapTileSize[EMapTileSize["IMG_2048"] = 2048] = "IMG_2048";
406
+ })(EMapTileSize = Settings.EMapTileSize || (Settings.EMapTileSize = {}));
407
+ let EExternalMapType;
408
+ (function (EExternalMapType) {
409
+ EExternalMapType["TileMapImagery"] = "TileMapImagery";
410
+ EExternalMapType["OpenStreetMapImagery"] = "OpenStreetMapImagery";
411
+ EExternalMapType["MapBoxImagery"] = "MapBoxImagery";
412
+ EExternalMapType["CesiumIon"] = "CesiumIon";
413
+ })(EExternalMapType = Settings.EExternalMapType || (Settings.EExternalMapType = {}));
414
+ })(Settings = Tileset.Settings || (Tileset.Settings = {}));
415
+ })(Tileset = exports.Tileset || (exports.Tileset = {}));
416
416
  //# sourceMappingURL=tileset.js.map