bruce-models 0.6.8 → 0.7.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 +221 -212
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +214 -205
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account.js +244 -244
  6. package/dist/lib/account/account.js.map +1 -1
  7. package/dist/lib/ann-document/ann-document.js +116 -116
  8. package/dist/lib/api/abstract-api.js +267 -267
  9. package/dist/lib/api/api.js +85 -85
  10. package/dist/lib/api/bruce-api.js +202 -202
  11. package/dist/lib/api/bruce-api.js.map +1 -1
  12. package/dist/lib/api/cam-api.js +132 -132
  13. package/dist/lib/api/global-api.js +131 -131
  14. package/dist/lib/api/idm-api.js +132 -132
  15. package/dist/lib/bruce-models.js +83 -83
  16. package/dist/lib/calculator/calculator.js +158 -158
  17. package/dist/lib/client-file/client-file.js +188 -185
  18. package/dist/lib/client-file/client-file.js.map +1 -1
  19. package/dist/lib/common/bounds.js +2 -2
  20. package/dist/lib/common/bruce-event.js +48 -48
  21. package/dist/lib/common/bruce-variable.js +54 -54
  22. package/dist/lib/common/cache.js +86 -86
  23. package/dist/lib/common/camera.js +11 -11
  24. package/dist/lib/common/cartes.js +55 -55
  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 +60 -60
  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.js +136 -136
  33. package/dist/lib/data-lab/data-lab.js +90 -90
  34. package/dist/lib/entity/entity-attachment-type.js +132 -132
  35. package/dist/lib/entity/entity-attachment.js +208 -208
  36. package/dist/lib/entity/entity-comment.js +132 -132
  37. package/dist/lib/entity/entity-link.js +132 -132
  38. package/dist/lib/entity/entity-lod.js +189 -189
  39. package/dist/lib/entity/entity-relation-type.js +150 -150
  40. package/dist/lib/entity/entity-relation.js +189 -189
  41. package/dist/lib/entity/entity-source.js +176 -176
  42. package/dist/lib/entity/entity-tag.js +229 -229
  43. package/dist/lib/entity/entity-type.js +163 -163
  44. package/dist/lib/entity/entity.js +349 -349
  45. package/dist/lib/entity/getters/batched-data-getter.js +91 -91
  46. package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
  47. package/dist/lib/entity/getters/entity-globe.js +135 -135
  48. package/dist/lib/entity/getters/view-monitor.js +2 -2
  49. package/dist/lib/import/import-cad.js +82 -82
  50. package/dist/lib/import/import-csv.js +51 -51
  51. package/dist/lib/import/import-json.js +51 -51
  52. package/dist/lib/import/import-kml.js +51 -51
  53. package/dist/lib/import/imported-file.js +121 -121
  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 +172 -172
  58. package/dist/lib/project/project-view-tile-source.js +115 -115
  59. package/dist/lib/project/project-view.js +166 -166
  60. package/dist/lib/project/zoom-control.js +17 -17
  61. package/dist/lib/server/pending-action.js +106 -106
  62. package/dist/lib/server/task.js +113 -113
  63. package/dist/lib/style/style.js +152 -152
  64. package/dist/lib/tileset/tileset-cad.js +2 -2
  65. package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
  66. package/dist/lib/tileset/tileset-entities.js +2 -2
  67. package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
  68. package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
  69. package/dist/lib/tileset/tileset-map-tiles.js +2 -2
  70. package/dist/lib/tileset/tileset-pointcloud.js +2 -2
  71. package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
  72. package/dist/lib/tileset/tileset.js +403 -397
  73. package/dist/lib/tileset/tileset.js.map +1 -1
  74. package/dist/lib/ucs/ucs.js +135 -135
  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/account/account.d.ts +1 -0
  85. package/package.json +1 -1
@@ -1,398 +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
- return __generator(this, function (_a) {
192
- if (!tilesetId || !file) {
193
- throw ("Tileset ID and file are required.");
194
- }
195
- return [2 /*return*/, api.UPLOAD("tileset/uploadFile/" + tilesetId + "/files", file, { onProgress: onProgress })];
196
- });
197
- });
198
- }
199
- Tileset.UploadFile = UploadFile;
200
- function DeleteFile(api, tilesetId, file) {
201
- return __awaiter(this, void 0, void 0, function () {
202
- return __generator(this, function (_a) {
203
- switch (_a.label) {
204
- case 0:
205
- if (!tilesetId || !file) {
206
- throw ("Tileset ID and file are required.");
207
- }
208
- return [4 /*yield*/, api.DELETE("tileset/deleteFile/" + tilesetId + "/files/" + file)];
209
- case 1:
210
- _a.sent();
211
- api.Cache.Remove(GetCacheKey(tilesetId, true));
212
- return [2 /*return*/];
213
- }
214
- });
215
- });
216
- }
217
- Tileset.DeleteFile = DeleteFile;
218
- function UploadSrcFile(api, tilesetId, file, onProgress) {
219
- return __awaiter(this, void 0, void 0, function () {
220
- return __generator(this, function (_a) {
221
- switch (_a.label) {
222
- case 0:
223
- if (!tilesetId || !file) {
224
- throw ("Tileset ID and file are required.");
225
- }
226
- return [4 /*yield*/, api.UPLOAD("tileset/uploadFile/" + tilesetId + "/src", file, { onProgress: onProgress })];
227
- case 1:
228
- _a.sent();
229
- api.Cache.Remove(GetCacheKey(tilesetId, true));
230
- return [2 /*return*/];
231
- }
232
- });
233
- });
234
- }
235
- Tileset.UploadSrcFile = UploadSrcFile;
236
- function DeleteSrcFile(api, tilesetId, file) {
237
- return __awaiter(this, void 0, void 0, function () {
238
- return __generator(this, function (_a) {
239
- switch (_a.label) {
240
- case 0:
241
- if (!tilesetId || !file) {
242
- throw ("Tileset ID and file are required.");
243
- }
244
- return [4 /*yield*/, api.DELETE("tileset/deleteFile/" + tilesetId + "/src/" + file)];
245
- case 1:
246
- _a.sent();
247
- api.Cache.Remove(GetCacheKey(tilesetId, true));
248
- return [2 /*return*/];
249
- }
250
- });
251
- });
252
- }
253
- Tileset.DeleteSrcFile = DeleteSrcFile;
254
- function GetFileUrl(api, tilesetId, file) {
255
- if (!tilesetId) {
256
- throw ("Tileset ID is required.");
257
- }
258
- if (!file) {
259
- file = "";
260
- }
261
- return api.GetBaseUrl() + ("tileset/getFile/" + tilesetId + "/files/" + file);
262
- }
263
- Tileset.GetFileUrl = GetFileUrl;
264
- function GetSrcFileUrl(api, tilesetId, file) {
265
- if (!tilesetId) {
266
- throw ("Tileset ID is required.");
267
- }
268
- if (!file) {
269
- file = "";
270
- }
271
- return api.GetBaseUrl() + ("tileset/getFile/" + tilesetId + "/src/" + file);
272
- }
273
- Tileset.GetSrcFileUrl = GetSrcFileUrl;
274
- function GetPublicFileUrl(api, tilesetId, file) {
275
- if (!tilesetId) {
276
- throw ("Tileset ID is required.");
277
- }
278
- if (!file) {
279
- file = "";
280
- }
281
- return api.GetBaseUrl() + ("tileset/file/" + tilesetId + "/" + file);
282
- }
283
- Tileset.GetPublicFileUrl = GetPublicFileUrl;
284
- function Generate(api, tilesetId) {
285
- return __awaiter(this, void 0, void 0, function () {
286
- var res;
287
- return __generator(this, function (_a) {
288
- switch (_a.label) {
289
- case 0:
290
- if (!tilesetId) {
291
- throw ("Tileset ID is required.");
292
- }
293
- return [4 /*yield*/, api.GET("tileset/generate/" + tilesetId, api_1.Api.PrepReqParams())];
294
- case 1:
295
- res = _a.sent();
296
- return [2 /*return*/, res.ID];
297
- }
298
- });
299
- });
300
- }
301
- Tileset.Generate = Generate;
302
- var Publish;
303
- (function (Publish) {
304
- function GetCacheKey(accountId, tilesetId) {
305
- if (!tilesetId) {
306
- tilesetId = "";
307
- }
308
- return api_1.Api.ECacheKey.PublishTileset + api_1.Api.ECacheKey.Id + accountId + api_1.Api.ECacheKey.Id + tilesetId;
309
- }
310
- Publish.GetCacheKey = GetCacheKey;
311
- function Update(api, data) {
312
- return __awaiter(this, void 0, void 0, function () {
313
- var res, req;
314
- return __generator(this, function (_a) {
315
- switch (_a.label) {
316
- case 0:
317
- 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"])) {
318
- throw ("Tileset ID, client account ID, and user ID are required.");
319
- }
320
- if (!data.ID) {
321
- data.ID = 0;
322
- }
323
- return [4 /*yield*/, api.POST("tileset/" + data.ID, data)];
324
- case 1:
325
- res = _a.sent();
326
- req = {
327
- "ClientAccount.ID": data["EnabledFor.ClientAccount.ID"]
328
- };
329
- data.ID = res.ID;
330
- return [4 /*yield*/, api.POST("tileset/" + data.ID + "/enableForAccounts", req)];
331
- case 2:
332
- _a.sent();
333
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"], data["Tileset.ID"]));
334
- api.Cache.Remove(GetCacheKey(data["PublishedBy.ClientAccount.ID"]));
335
- return [2 /*return*/, data];
336
- }
337
- });
338
- });
339
- }
340
- Publish.Update = Update;
341
- function Get(api, accountId, tilesetId) {
342
- return __awaiter(this, void 0, void 0, function () {
343
- var cacheData, req;
344
- return __generator(this, function (_a) {
345
- if (!accountId || !tilesetId) {
346
- throw ("Client account ID and tileset ID are required.");
347
- }
348
- cacheData = api.Cache.Get(GetCacheKey(accountId, tilesetId));
349
- if (cacheData) {
350
- return [2 /*return*/, cacheData];
351
- }
352
- req = api.GET("tilesetByPublisher/" + accountId + "/" + tilesetId);
353
- api.Cache.Set(GetCacheKey(accountId, tilesetId), req);
354
- return [2 /*return*/, req];
355
- });
356
- });
357
- }
358
- Publish.Get = Get;
359
- function GetList(api, accountId) {
360
- return __awaiter(this, void 0, void 0, function () {
361
- var cacheData, req;
362
- var _this = this;
363
- return __generator(this, function (_a) {
364
- if (!accountId) {
365
- throw ("Client account ID is required.");
366
- }
367
- cacheData = api.Cache.Get(GetCacheKey(accountId));
368
- if (cacheData) {
369
- return [2 /*return*/, cacheData];
370
- }
371
- req = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
372
- var data, e_2;
373
- return __generator(this, function (_a) {
374
- switch (_a.label) {
375
- case 0:
376
- _a.trys.push([0, 2, , 3]);
377
- return [4 /*yield*/, api.GET("tilesets/enabledForAccount/" + accountId)];
378
- case 1:
379
- data = _a.sent();
380
- res(data.Items);
381
- return [3 /*break*/, 3];
382
- case 2:
383
- e_2 = _a.sent();
384
- rej(e_2);
385
- return [3 /*break*/, 3];
386
- case 3: return [2 /*return*/];
387
- }
388
- });
389
- }); });
390
- api.Cache.Set(GetCacheKey(accountId), req);
391
- return [2 /*return*/, req];
392
- });
393
- });
394
- }
395
- Publish.GetList = GetList;
396
- })(Publish = Tileset.Publish || (Tileset.Publish = {}));
397
- })(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 = {}));
398
404
  //# sourceMappingURL=tileset.js.map