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