bruce-models 1.9.7 → 1.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/bruce-models.es5.js +9 -3
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +9 -3
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account-settings.js +2 -2
  6. package/dist/lib/account/account.js +185 -185
  7. package/dist/lib/ann-document/ann-document.js +86 -86
  8. package/dist/lib/api/abstract-api.js +246 -246
  9. package/dist/lib/api/api-getters.js +134 -134
  10. package/dist/lib/api/api.js +93 -93
  11. package/dist/lib/api/bruce-api.js +216 -216
  12. package/dist/lib/api/cam-api.js +82 -82
  13. package/dist/lib/api/global-api.js +81 -81
  14. package/dist/lib/api/idm-api.js +82 -82
  15. package/dist/lib/bruce-models.js +86 -86
  16. package/dist/lib/calculator/calculator.js +341 -335
  17. package/dist/lib/calculator/calculator.js.map +1 -1
  18. package/dist/lib/client-file/client-file.js +245 -245
  19. package/dist/lib/common/bounds.js +61 -61
  20. package/dist/lib/common/bruce-event.js +46 -46
  21. package/dist/lib/common/bruce-variable.js +60 -60
  22. package/dist/lib/common/cache.js +165 -165
  23. package/dist/lib/common/camera.js +11 -11
  24. package/dist/lib/common/cartes.js +123 -123
  25. package/dist/lib/common/carto.js +60 -60
  26. package/dist/lib/common/color.js +86 -86
  27. package/dist/lib/common/delay-queue.js +56 -56
  28. package/dist/lib/common/dictionary.js +2 -2
  29. package/dist/lib/common/geometry.js +120 -120
  30. package/dist/lib/common/transform.js +2 -2
  31. package/dist/lib/common/utc.js +39 -39
  32. package/dist/lib/custom-form/custom-form-content.js +26 -26
  33. package/dist/lib/custom-form/custom-form.js +106 -106
  34. package/dist/lib/data-lab/data-lab.js +49 -49
  35. package/dist/lib/entity/entity-attachment-type.js +83 -83
  36. package/dist/lib/entity/entity-attachment.js +122 -122
  37. package/dist/lib/entity/entity-attribute.js +29 -29
  38. package/dist/lib/entity/entity-comment.js +82 -82
  39. package/dist/lib/entity/entity-coords.js +149 -149
  40. package/dist/lib/entity/entity-link.js +82 -82
  41. package/dist/lib/entity/entity-lod-category.js +100 -100
  42. package/dist/lib/entity/entity-lod.js +185 -185
  43. package/dist/lib/entity/entity-relation-type.js +109 -109
  44. package/dist/lib/entity/entity-relation.js +132 -132
  45. package/dist/lib/entity/entity-source.js +136 -136
  46. package/dist/lib/entity/entity-tag.js +149 -149
  47. package/dist/lib/entity/entity-type-visual-settings.js +13 -13
  48. package/dist/lib/entity/entity-type.js +113 -113
  49. package/dist/lib/entity/entity.js +319 -319
  50. package/dist/lib/entity/getters/batched-data-getter.js +84 -84
  51. package/dist/lib/entity/getters/entity-filter-getter.js +303 -303
  52. package/dist/lib/entity/getters/entity-globe.js +211 -211
  53. package/dist/lib/entity/getters/view-monitor.js +2 -2
  54. package/dist/lib/import/import-cad.js +53 -53
  55. package/dist/lib/import/import-csv.js +23 -23
  56. package/dist/lib/import/import-json.js +23 -23
  57. package/dist/lib/import/import-kml.js +23 -23
  58. package/dist/lib/import/imported-file.js +91 -91
  59. package/dist/lib/internal/uploader.js +76 -76
  60. package/dist/lib/markup/markup.js +185 -185
  61. package/dist/lib/plugin/plugin.js +83 -83
  62. package/dist/lib/program-key/program-key.js +111 -111
  63. package/dist/lib/project/menu-item.js +121 -121
  64. package/dist/lib/project/project-view-bookmark.js +147 -147
  65. package/dist/lib/project/project-view-legacy-tile.js +77 -77
  66. package/dist/lib/project/project-view-tile.js +125 -125
  67. package/dist/lib/project/project-view.js +133 -133
  68. package/dist/lib/project/zoom-control.js +17 -17
  69. package/dist/lib/server/message-broker.js +142 -142
  70. package/dist/lib/server/pending-action.js +71 -71
  71. package/dist/lib/server/task.js +63 -63
  72. package/dist/lib/style/style.js +117 -117
  73. package/dist/lib/tileset/tileset.js +415 -415
  74. package/dist/lib/user/permission.js +20 -20
  75. package/dist/lib/user/session.js +137 -137
  76. package/dist/lib/user/user-group.js +94 -94
  77. package/dist/lib/user/user.js +446 -446
  78. package/dist/lib/util/encrypt-utils.js +19 -19
  79. package/dist/lib/util/math-utils.js +40 -40
  80. package/dist/lib/util/object-utils.js +17 -17
  81. package/dist/lib/util/path-utils.js +61 -61
  82. package/dist/lib/util/url-utils.js +94 -94
  83. package/package.json +1 -1
@@ -1,101 +1,101 @@
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.EntityLodCategory = void 0;
13
- const api_1 = require("../api/api");
14
- var EntityLodCategory;
15
- (function (EntityLodCategory) {
16
- function GetCacheKey(id) {
17
- return api_1.Api.ECacheKey.LodCategory + api_1.Api.ECacheKey.Id + id;
18
- }
19
- EntityLodCategory.GetCacheKey = GetCacheKey;
20
- function GetListCacheKey() {
21
- return api_1.Api.ECacheKey.LodCategory;
22
- }
23
- EntityLodCategory.GetListCacheKey = GetListCacheKey;
24
- function GetList(params) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const { api, req: reqParams } = params;
27
- const cacheKey = api.GetCacheItem(GetListCacheKey(), reqParams);
28
- if (cacheKey) {
29
- return cacheKey;
30
- }
31
- const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
32
- try {
33
- const data = yield api.GET("lodCategories", api_1.Api.PrepReqParams(reqParams));
34
- res({
35
- categories: data.Items
36
- });
37
- }
38
- catch (e) {
39
- rej(e);
40
- }
41
- }));
42
- api.Cache.Set(GetListCacheKey(), req);
43
- return req;
44
- });
45
- }
46
- EntityLodCategory.GetList = GetList;
47
- function Get(params) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const { api, categoryId: id, req: reqParams } = params;
50
- if (!id) {
51
- throw ("Lod category id is required.");
52
- }
53
- const cacheData = api.GetCacheItem(GetCacheKey(id), reqParams);
54
- if (cacheData) {
55
- return cacheData;
56
- }
57
- const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
58
- try {
59
- const data = yield api.GET(`lodCategory/${id}`, api_1.Api.PrepReqParams(reqParams));
60
- res({
61
- category: data
62
- });
63
- }
64
- catch (e) {
65
- rej(e);
66
- }
67
- }));
68
- api.Cache.Set(GetCacheKey(id), req);
69
- return req;
70
- });
71
- }
72
- EntityLodCategory.Get = Get;
73
- function Delete(params) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const { api, categoryId: id, req: reqParams } = params;
76
- if (!id) {
77
- throw ("Lod category id is required.");
78
- }
79
- yield api.DELETE(`lodCategory/${id}`, api_1.Api.PrepReqParams(reqParams));
80
- api.Cache.Remove(GetCacheKey(id));
81
- api.Cache.Remove(GetListCacheKey());
82
- });
83
- }
84
- EntityLodCategory.Delete = Delete;
85
- function Update(params) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const { api, category: data, req: reqParams } = params;
88
- if (!data.Key || !data.Name) {
89
- throw ("Lod category key and name are required.");
90
- }
91
- const res = yield api.POST(`lodCategory/${data.Key}`, data, api_1.Api.PrepReqParams(reqParams));
92
- api.Cache.Remove(GetCacheKey(data.Key));
93
- api.Cache.Remove(GetListCacheKey());
94
- return {
95
- category: res
96
- };
97
- });
98
- }
99
- EntityLodCategory.Update = Update;
100
- })(EntityLodCategory = exports.EntityLodCategory || (exports.EntityLodCategory = {}));
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.EntityLodCategory = void 0;
13
+ const api_1 = require("../api/api");
14
+ var EntityLodCategory;
15
+ (function (EntityLodCategory) {
16
+ function GetCacheKey(id) {
17
+ return api_1.Api.ECacheKey.LodCategory + api_1.Api.ECacheKey.Id + id;
18
+ }
19
+ EntityLodCategory.GetCacheKey = GetCacheKey;
20
+ function GetListCacheKey() {
21
+ return api_1.Api.ECacheKey.LodCategory;
22
+ }
23
+ EntityLodCategory.GetListCacheKey = GetListCacheKey;
24
+ function GetList(params) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { api, req: reqParams } = params;
27
+ const cacheKey = api.GetCacheItem(GetListCacheKey(), reqParams);
28
+ if (cacheKey) {
29
+ return cacheKey;
30
+ }
31
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
32
+ try {
33
+ const data = yield api.GET("lodCategories", api_1.Api.PrepReqParams(reqParams));
34
+ res({
35
+ categories: data.Items
36
+ });
37
+ }
38
+ catch (e) {
39
+ rej(e);
40
+ }
41
+ }));
42
+ api.Cache.Set(GetListCacheKey(), req);
43
+ return req;
44
+ });
45
+ }
46
+ EntityLodCategory.GetList = GetList;
47
+ function Get(params) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const { api, categoryId: id, req: reqParams } = params;
50
+ if (!id) {
51
+ throw ("Lod category id is required.");
52
+ }
53
+ const cacheData = api.GetCacheItem(GetCacheKey(id), reqParams);
54
+ if (cacheData) {
55
+ return cacheData;
56
+ }
57
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ const data = yield api.GET(`lodCategory/${id}`, api_1.Api.PrepReqParams(reqParams));
60
+ res({
61
+ category: data
62
+ });
63
+ }
64
+ catch (e) {
65
+ rej(e);
66
+ }
67
+ }));
68
+ api.Cache.Set(GetCacheKey(id), req);
69
+ return req;
70
+ });
71
+ }
72
+ EntityLodCategory.Get = Get;
73
+ function Delete(params) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const { api, categoryId: id, req: reqParams } = params;
76
+ if (!id) {
77
+ throw ("Lod category id is required.");
78
+ }
79
+ yield api.DELETE(`lodCategory/${id}`, api_1.Api.PrepReqParams(reqParams));
80
+ api.Cache.Remove(GetCacheKey(id));
81
+ api.Cache.Remove(GetListCacheKey());
82
+ });
83
+ }
84
+ EntityLodCategory.Delete = Delete;
85
+ function Update(params) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const { api, category: data, req: reqParams } = params;
88
+ if (!data.Key || !data.Name) {
89
+ throw ("Lod category key and name are required.");
90
+ }
91
+ const res = yield api.POST(`lodCategory/${data.Key}`, data, api_1.Api.PrepReqParams(reqParams));
92
+ api.Cache.Remove(GetCacheKey(data.Key));
93
+ api.Cache.Remove(GetListCacheKey());
94
+ return {
95
+ category: res
96
+ };
97
+ });
98
+ }
99
+ EntityLodCategory.Update = Update;
100
+ })(EntityLodCategory = exports.EntityLodCategory || (exports.EntityLodCategory = {}));
101
101
  //# sourceMappingURL=entity-lod-category.js.map
@@ -1,186 +1,186 @@
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.EntityLod = void 0;
13
- const api_1 = require("../api/api");
14
- /**
15
- * Describes the "Entity LOD" concept within Bruce.
16
- * LOD stands for Level of Detail.
17
- * An lod record is a possible 2d/3d visualization of the entity record.
18
- * The most common kind is a GLB.
19
- */
20
- var EntityLod;
21
- (function (EntityLod) {
22
- function GetCacheKey(url) {
23
- return api_1.Api.ECacheKey.Lod + api_1.Api.ECacheKey.Id + url;
24
- }
25
- EntityLod.GetCacheKey = GetCacheKey;
26
- function GetTypeListKey(typeId, group) {
27
- return api_1.Api.ECacheKey.Lod + api_1.Api.ECacheKey.EntityType + typeId + api_1.Api.ECacheKey.Id + group;
28
- }
29
- EntityLod.GetTypeListKey = GetTypeListKey;
30
- function GetEntityListKey(entityId) {
31
- return api_1.Api.ECacheKey.Lod + api_1.Api.ECacheKey.Entity + entityId;
32
- }
33
- EntityLod.GetEntityListKey = GetEntityListKey;
34
- function GetUrl(params) {
35
- let { api, entityId, categoryId, level, strict } = params;
36
- if (!entityId) {
37
- throw ("Entity ID is required.");
38
- }
39
- if (!categoryId) {
40
- categoryId = "GLB";
41
- }
42
- if (!level) {
43
- level = 0;
44
- }
45
- let url = api.GetBaseUrl() + `entity/${entityId}/lod/${categoryId}/${level}`;
46
- if (strict) {
47
- url = url + "?strict=true";
48
- }
49
- return {
50
- url: url
51
- };
52
- }
53
- EntityLod.GetUrl = GetUrl;
54
- function GetUrlFileId(params) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const { api, url, req: reqParams } = params;
57
- if (!url) {
58
- throw ("Url is required.");
59
- }
60
- const cacheData = api.GetCacheItem(GetCacheKey(url), reqParams);
61
- if (cacheData) {
62
- return cacheData;
63
- }
64
- const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
65
- try {
66
- const record = yield api.get(url, api_1.Api.PrepReqParams(reqParams));
67
- res({
68
- clientFileId: record["ClientFile.ID"]
69
- });
70
- }
71
- catch (e) {
72
- rej(e);
73
- }
74
- }));
75
- api.Cache.Set(GetCacheKey(url), req, api_1.Api.DEFAULT_CACHE_DURATION);
76
- return req;
77
- });
78
- }
79
- EntityLod.GetUrlFileId = GetUrlFileId;
80
- function GetLods(params) {
81
- var _a;
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const { api, filter, req: reqParams } = params;
84
- if (!((_a = filter === null || filter === void 0 ? void 0 : filter.Items) === null || _a === void 0 ? void 0 : _a.length)) {
85
- throw ("Items are required.");
86
- }
87
- const data = yield api.POST("entity/getlods", filter, reqParams);
88
- return {
89
- lods: data.Items
90
- };
91
- });
92
- }
93
- EntityLod.GetLods = GetLods;
94
- function GetEntityLods(params) {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- const { api, entityId, req: reqParams } = params;
97
- if (!entityId) {
98
- throw ("Entity id is required.");
99
- }
100
- const cacheData = api.GetCacheItem(GetEntityListKey(entityId), reqParams);
101
- if (cacheData) {
102
- return cacheData;
103
- }
104
- const req = api.GET(`entity/${entityId}/lods?includeClientFiles=yes`, api_1.Api.PrepReqParams(reqParams));
105
- const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
106
- try {
107
- const data = yield req;
108
- res({
109
- lods: data.Items
110
- });
111
- }
112
- catch (e) {
113
- rej(e);
114
- }
115
- }));
116
- api.Cache.Set(GetEntityListKey(entityId), prom, api_1.Api.DEFAULT_CACHE_DURATION);
117
- return prom;
118
- });
119
- }
120
- EntityLod.GetEntityLods = GetEntityLods;
121
- /**
122
- * Returns lods for a specified entity type.
123
- * @param params
124
- */
125
- function GetTypeLods(params) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- let { api, entityTypeId: typeId, group, req: reqParams } = params;
128
- if (!group) {
129
- group = "DEFAULT";
130
- }
131
- const cacheData = api.GetCacheItem(GetTypeListKey(typeId, group), reqParams);
132
- if (cacheData) {
133
- return cacheData;
134
- }
135
- const url = `entityType/${typeId}/lods?includeClientFiles=yes` + (group ? "&group=" + group : "");
136
- const req = api.GET(url, api_1.Api.PrepReqParams(reqParams));
137
- const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
138
- try {
139
- const data = yield req;
140
- res({
141
- lods: data.Items
142
- });
143
- }
144
- catch (e) {
145
- rej(e);
146
- }
147
- }));
148
- api.Cache.Set(GetTypeListKey(typeId, group), prom, api_1.Api.DEFAULT_CACHE_DURATION);
149
- return prom;
150
- });
151
- }
152
- EntityLod.GetTypeLods = GetTypeLods;
153
- function Update(params) {
154
- return __awaiter(this, void 0, void 0, function* () {
155
- const { api, entityId, req: reqParams } = params;
156
- if (!params["ClientFile.ID"] || !params["LODCategory.Key"] || (!params.Level && params.Level !== 0)) {
157
- throw ("ClientFile.ID, LODCategory.Key and Level are required.");
158
- }
159
- const res = yield api.POST(`entity/${entityId}/lod/${params["LODCategory.Key"]}/${params.Level}`, {
160
- "Level": params.Level,
161
- "ClientFile.ID": params["ClientFile.ID"]
162
- }, api_1.Api.PrepReqParams(reqParams));
163
- api.Cache.Remove(GetEntityListKey(entityId));
164
- return res;
165
- });
166
- }
167
- EntityLod.Update = Update;
168
- function Delete(params) {
169
- return __awaiter(this, void 0, void 0, function* () {
170
- let { api, entityId, lodCategoryId, level, req: reqParams } = params;
171
- if (!entityId || !lodCategoryId) {
172
- throw ("Entity ID and LOD Category ID are required.");
173
- }
174
- level = +level;
175
- if (isNaN(level)) {
176
- throw ("Level is required. It must be a number.");
177
- }
178
- yield api.POST(`entity/${entityId}/deleteLODs`, {
179
- Items: [{ "LODCategory.Key": lodCategoryId, "Level": level }]
180
- }, api_1.Api.PrepReqParams(reqParams));
181
- api.Cache.Remove(GetEntityListKey(entityId));
182
- });
183
- }
184
- EntityLod.Delete = Delete;
185
- })(EntityLod = exports.EntityLod || (exports.EntityLod = {}));
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.EntityLod = void 0;
13
+ const api_1 = require("../api/api");
14
+ /**
15
+ * Describes the "Entity LOD" concept within Bruce.
16
+ * LOD stands for Level of Detail.
17
+ * An lod record is a possible 2d/3d visualization of the entity record.
18
+ * The most common kind is a GLB.
19
+ */
20
+ var EntityLod;
21
+ (function (EntityLod) {
22
+ function GetCacheKey(url) {
23
+ return api_1.Api.ECacheKey.Lod + api_1.Api.ECacheKey.Id + url;
24
+ }
25
+ EntityLod.GetCacheKey = GetCacheKey;
26
+ function GetTypeListKey(typeId, group) {
27
+ return api_1.Api.ECacheKey.Lod + api_1.Api.ECacheKey.EntityType + typeId + api_1.Api.ECacheKey.Id + group;
28
+ }
29
+ EntityLod.GetTypeListKey = GetTypeListKey;
30
+ function GetEntityListKey(entityId) {
31
+ return api_1.Api.ECacheKey.Lod + api_1.Api.ECacheKey.Entity + entityId;
32
+ }
33
+ EntityLod.GetEntityListKey = GetEntityListKey;
34
+ function GetUrl(params) {
35
+ let { api, entityId, categoryId, level, strict } = params;
36
+ if (!entityId) {
37
+ throw ("Entity ID is required.");
38
+ }
39
+ if (!categoryId) {
40
+ categoryId = "GLB";
41
+ }
42
+ if (!level) {
43
+ level = 0;
44
+ }
45
+ let url = api.GetBaseUrl() + `entity/${entityId}/lod/${categoryId}/${level}`;
46
+ if (strict) {
47
+ url = url + "?strict=true";
48
+ }
49
+ return {
50
+ url: url
51
+ };
52
+ }
53
+ EntityLod.GetUrl = GetUrl;
54
+ function GetUrlFileId(params) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ const { api, url, req: reqParams } = params;
57
+ if (!url) {
58
+ throw ("Url is required.");
59
+ }
60
+ const cacheData = api.GetCacheItem(GetCacheKey(url), reqParams);
61
+ if (cacheData) {
62
+ return cacheData;
63
+ }
64
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ const record = yield api.get(url, api_1.Api.PrepReqParams(reqParams));
67
+ res({
68
+ clientFileId: record["ClientFile.ID"]
69
+ });
70
+ }
71
+ catch (e) {
72
+ rej(e);
73
+ }
74
+ }));
75
+ api.Cache.Set(GetCacheKey(url), req, api_1.Api.DEFAULT_CACHE_DURATION);
76
+ return req;
77
+ });
78
+ }
79
+ EntityLod.GetUrlFileId = GetUrlFileId;
80
+ function GetLods(params) {
81
+ var _a;
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const { api, filter, req: reqParams } = params;
84
+ if (!((_a = filter === null || filter === void 0 ? void 0 : filter.Items) === null || _a === void 0 ? void 0 : _a.length)) {
85
+ throw ("Items are required.");
86
+ }
87
+ const data = yield api.POST("entity/getlods", filter, reqParams);
88
+ return {
89
+ lods: data.Items
90
+ };
91
+ });
92
+ }
93
+ EntityLod.GetLods = GetLods;
94
+ function GetEntityLods(params) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const { api, entityId, req: reqParams } = params;
97
+ if (!entityId) {
98
+ throw ("Entity id is required.");
99
+ }
100
+ const cacheData = api.GetCacheItem(GetEntityListKey(entityId), reqParams);
101
+ if (cacheData) {
102
+ return cacheData;
103
+ }
104
+ const req = api.GET(`entity/${entityId}/lods?includeClientFiles=yes`, api_1.Api.PrepReqParams(reqParams));
105
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
106
+ try {
107
+ const data = yield req;
108
+ res({
109
+ lods: data.Items
110
+ });
111
+ }
112
+ catch (e) {
113
+ rej(e);
114
+ }
115
+ }));
116
+ api.Cache.Set(GetEntityListKey(entityId), prom, api_1.Api.DEFAULT_CACHE_DURATION);
117
+ return prom;
118
+ });
119
+ }
120
+ EntityLod.GetEntityLods = GetEntityLods;
121
+ /**
122
+ * Returns lods for a specified entity type.
123
+ * @param params
124
+ */
125
+ function GetTypeLods(params) {
126
+ return __awaiter(this, void 0, void 0, function* () {
127
+ let { api, entityTypeId: typeId, group, req: reqParams } = params;
128
+ if (!group) {
129
+ group = "DEFAULT";
130
+ }
131
+ const cacheData = api.GetCacheItem(GetTypeListKey(typeId, group), reqParams);
132
+ if (cacheData) {
133
+ return cacheData;
134
+ }
135
+ const url = `entityType/${typeId}/lods?includeClientFiles=yes` + (group ? "&group=" + group : "");
136
+ const req = api.GET(url, api_1.Api.PrepReqParams(reqParams));
137
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
138
+ try {
139
+ const data = yield req;
140
+ res({
141
+ lods: data.Items
142
+ });
143
+ }
144
+ catch (e) {
145
+ rej(e);
146
+ }
147
+ }));
148
+ api.Cache.Set(GetTypeListKey(typeId, group), prom, api_1.Api.DEFAULT_CACHE_DURATION);
149
+ return prom;
150
+ });
151
+ }
152
+ EntityLod.GetTypeLods = GetTypeLods;
153
+ function Update(params) {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ const { api, entityId, req: reqParams } = params;
156
+ if (!params["ClientFile.ID"] || !params["LODCategory.Key"] || (!params.Level && params.Level !== 0)) {
157
+ throw ("ClientFile.ID, LODCategory.Key and Level are required.");
158
+ }
159
+ const res = yield api.POST(`entity/${entityId}/lod/${params["LODCategory.Key"]}/${params.Level}`, {
160
+ "Level": params.Level,
161
+ "ClientFile.ID": params["ClientFile.ID"]
162
+ }, api_1.Api.PrepReqParams(reqParams));
163
+ api.Cache.Remove(GetEntityListKey(entityId));
164
+ return res;
165
+ });
166
+ }
167
+ EntityLod.Update = Update;
168
+ function Delete(params) {
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ let { api, entityId, lodCategoryId, level, req: reqParams } = params;
171
+ if (!entityId || !lodCategoryId) {
172
+ throw ("Entity ID and LOD Category ID are required.");
173
+ }
174
+ level = +level;
175
+ if (isNaN(level)) {
176
+ throw ("Level is required. It must be a number.");
177
+ }
178
+ yield api.POST(`entity/${entityId}/deleteLODs`, {
179
+ Items: [{ "LODCategory.Key": lodCategoryId, "Level": level }]
180
+ }, api_1.Api.PrepReqParams(reqParams));
181
+ api.Cache.Remove(GetEntityListKey(entityId));
182
+ });
183
+ }
184
+ EntityLod.Delete = Delete;
185
+ })(EntityLod = exports.EntityLod || (exports.EntityLod = {}));
186
186
  //# sourceMappingURL=entity-lod.js.map