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