bruce-models 6.6.1 → 6.6.3
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.
- package/dist/bruce-models.es5.js +115 -76
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +115 -76
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api.js +1 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/common/cache.js +9 -8
- package/dist/lib/common/cache.js.map +1 -1
- package/dist/lib/common/lru-cache.js +6 -0
- package/dist/lib/common/lru-cache.js.map +1 -1
- package/dist/lib/entity/entity-lod.js +33 -1
- package/dist/lib/entity/entity-lod.js.map +1 -1
- package/dist/lib/tileset/tileset.js +18 -18
- package/dist/lib/tileset/tileset.js.map +1 -1
- package/dist/types/api/api.d.ts +1 -0
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/common/lru-cache.d.ts +2 -0
- package/dist/types/entity/entity-lod.d.ts +6 -0
- package/dist/types/tileset/tileset.d.ts +1 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -35,6 +35,7 @@ var Api;
|
|
|
35
35
|
(function (ECacheKey) {
|
|
36
36
|
ECacheKey["Id"] = ":";
|
|
37
37
|
ECacheKey["ListId"] = "::";
|
|
38
|
+
ECacheKey["FilterId"] = ":f:";
|
|
38
39
|
ECacheKey["Assembly"] = "assembly";
|
|
39
40
|
ECacheKey["Entity"] = "entity";
|
|
40
41
|
ECacheKey["EntityType"] = "entitytype";
|
|
@@ -150,9 +151,63 @@ var Api;
|
|
|
150
151
|
Api.PrepReqParams = PrepReqParams;
|
|
151
152
|
})(Api || (Api = {}));
|
|
152
153
|
|
|
154
|
+
/**
|
|
155
|
+
* A simple LRU cache implementation.
|
|
156
|
+
* LRU cache is a cache that evicts the least recently used item when it is full.
|
|
157
|
+
*/
|
|
158
|
+
class LRUCache {
|
|
159
|
+
constructor(capacity) {
|
|
160
|
+
this.capacity = capacity;
|
|
161
|
+
this.cache = new Map();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get a value from the cache.
|
|
165
|
+
* @param key
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
Get(key) {
|
|
169
|
+
const value = this.cache.get(key);
|
|
170
|
+
if (value) {
|
|
171
|
+
this.cache.delete(key);
|
|
172
|
+
this.cache.set(key, value);
|
|
173
|
+
}
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Set a value in the cache.
|
|
178
|
+
* @param key
|
|
179
|
+
* @param value
|
|
180
|
+
*/
|
|
181
|
+
Set(key, value) {
|
|
182
|
+
if (this.capacity <= 0) {
|
|
183
|
+
// Empty cache.
|
|
184
|
+
// Means we were configured to not cache anything.
|
|
185
|
+
this.cache.clear();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
else if (this.cache.size >= this.capacity) {
|
|
189
|
+
const leastRecentlyUsedKey = this.cache.keys().next().value;
|
|
190
|
+
this.cache.delete(leastRecentlyUsedKey);
|
|
191
|
+
}
|
|
192
|
+
this.cache.set(key, value);
|
|
193
|
+
}
|
|
194
|
+
Entries() {
|
|
195
|
+
return this.cache.entries();
|
|
196
|
+
}
|
|
197
|
+
Clear() {
|
|
198
|
+
this.cache.clear();
|
|
199
|
+
}
|
|
200
|
+
Delete(key) {
|
|
201
|
+
return this.cache.delete(key);
|
|
202
|
+
}
|
|
203
|
+
Keys() {
|
|
204
|
+
return this.cache.keys();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
153
208
|
class CacheControl {
|
|
154
209
|
constructor(id) {
|
|
155
|
-
this.memory = new
|
|
210
|
+
this.memory = new LRUCache(20000);
|
|
156
211
|
this.Disabled = false;
|
|
157
212
|
if (!id) {
|
|
158
213
|
id = "default";
|
|
@@ -179,7 +234,7 @@ class CacheControl {
|
|
|
179
234
|
data,
|
|
180
235
|
expires
|
|
181
236
|
};
|
|
182
|
-
this.memory.
|
|
237
|
+
this.memory.Set(id, record);
|
|
183
238
|
}
|
|
184
239
|
/**
|
|
185
240
|
* Returns the item with the given id.
|
|
@@ -191,7 +246,7 @@ class CacheControl {
|
|
|
191
246
|
return null;
|
|
192
247
|
}
|
|
193
248
|
id = String(id);
|
|
194
|
-
let record = this.memory.
|
|
249
|
+
let record = this.memory.Get(id);
|
|
195
250
|
if (!record) {
|
|
196
251
|
return {
|
|
197
252
|
data: null,
|
|
@@ -199,7 +254,7 @@ class CacheControl {
|
|
|
199
254
|
};
|
|
200
255
|
}
|
|
201
256
|
if (record.expires < Date.now()) {
|
|
202
|
-
this.memory.
|
|
257
|
+
this.memory.Delete(id);
|
|
203
258
|
return {
|
|
204
259
|
data: null,
|
|
205
260
|
found: false
|
|
@@ -214,7 +269,7 @@ class CacheControl {
|
|
|
214
269
|
* Removes all items from the cache.
|
|
215
270
|
*/
|
|
216
271
|
Clear() {
|
|
217
|
-
this.memory.
|
|
272
|
+
this.memory.Clear();
|
|
218
273
|
}
|
|
219
274
|
/**
|
|
220
275
|
* Removes the item with the given id.
|
|
@@ -222,7 +277,7 @@ class CacheControl {
|
|
|
222
277
|
*/
|
|
223
278
|
Remove(id) {
|
|
224
279
|
id = String(id);
|
|
225
|
-
this.memory.
|
|
280
|
+
this.memory.Delete(id);
|
|
226
281
|
}
|
|
227
282
|
/**
|
|
228
283
|
* Removes all items that match the callback.
|
|
@@ -230,10 +285,10 @@ class CacheControl {
|
|
|
230
285
|
* @param callback
|
|
231
286
|
*/
|
|
232
287
|
RemoveBy(callback) {
|
|
233
|
-
const memoryKeys = Array.from(this.memory.
|
|
288
|
+
const memoryKeys = Array.from(this.memory.Keys());
|
|
234
289
|
for (const key of memoryKeys) {
|
|
235
290
|
if (callback(key)) {
|
|
236
|
-
this.memory.
|
|
291
|
+
this.memory.Delete(key);
|
|
237
292
|
}
|
|
238
293
|
}
|
|
239
294
|
}
|
|
@@ -6237,54 +6292,6 @@ function getTimezoneName(timezone) {
|
|
|
6237
6292
|
return full;
|
|
6238
6293
|
}
|
|
6239
6294
|
|
|
6240
|
-
/**
|
|
6241
|
-
* A simple LRU cache implementation.
|
|
6242
|
-
* LRU cache is a cache that evicts the least recently used item when it is full.
|
|
6243
|
-
*/
|
|
6244
|
-
class LRUCache {
|
|
6245
|
-
constructor(capacity) {
|
|
6246
|
-
this.capacity = capacity;
|
|
6247
|
-
this.cache = new Map();
|
|
6248
|
-
}
|
|
6249
|
-
/**
|
|
6250
|
-
* Get a value from the cache.
|
|
6251
|
-
* @param key
|
|
6252
|
-
* @returns
|
|
6253
|
-
*/
|
|
6254
|
-
Get(key) {
|
|
6255
|
-
const value = this.cache.get(key);
|
|
6256
|
-
if (value) {
|
|
6257
|
-
this.cache.delete(key);
|
|
6258
|
-
this.cache.set(key, value);
|
|
6259
|
-
}
|
|
6260
|
-
return value;
|
|
6261
|
-
}
|
|
6262
|
-
/**
|
|
6263
|
-
* Set a value in the cache.
|
|
6264
|
-
* @param key
|
|
6265
|
-
* @param value
|
|
6266
|
-
*/
|
|
6267
|
-
Set(key, value) {
|
|
6268
|
-
if (this.capacity <= 0) {
|
|
6269
|
-
// Empty cache.
|
|
6270
|
-
// Means we were configured to not cache anything.
|
|
6271
|
-
this.cache.clear();
|
|
6272
|
-
return;
|
|
6273
|
-
}
|
|
6274
|
-
else if (this.cache.size >= this.capacity) {
|
|
6275
|
-
const leastRecentlyUsedKey = this.cache.keys().next().value;
|
|
6276
|
-
this.cache.delete(leastRecentlyUsedKey);
|
|
6277
|
-
}
|
|
6278
|
-
this.cache.set(key, value);
|
|
6279
|
-
}
|
|
6280
|
-
Entries() {
|
|
6281
|
-
return this.cache.entries();
|
|
6282
|
-
}
|
|
6283
|
-
Clear() {
|
|
6284
|
-
this.cache.clear();
|
|
6285
|
-
}
|
|
6286
|
-
}
|
|
6287
|
-
|
|
6288
6295
|
/**
|
|
6289
6296
|
* Describes the "Entity Attachment Type" concept within Nextspace.
|
|
6290
6297
|
* It is a record that describes the purpose of an attachment.
|
|
@@ -6940,7 +6947,18 @@ var EntityLod;
|
|
|
6940
6947
|
if (!api) {
|
|
6941
6948
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
6942
6949
|
}
|
|
6943
|
-
const
|
|
6950
|
+
const cacheKey = GetLodsFilterCacheKey(filter);
|
|
6951
|
+
const cache = api.GetCacheItem(cacheKey, reqParams);
|
|
6952
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
6953
|
+
return cache.data;
|
|
6954
|
+
}
|
|
6955
|
+
const prom = api.POST("entity/getlods", filter, reqParams);
|
|
6956
|
+
api.SetCacheItem({
|
|
6957
|
+
key: cacheKey,
|
|
6958
|
+
value: prom,
|
|
6959
|
+
req: reqParams
|
|
6960
|
+
});
|
|
6961
|
+
const data = yield prom;
|
|
6944
6962
|
return {
|
|
6945
6963
|
lods: data.Items
|
|
6946
6964
|
};
|
|
@@ -7044,6 +7062,7 @@ var EntityLod;
|
|
|
7044
7062
|
"ClientFile.ID": params["ClientFile.ID"]
|
|
7045
7063
|
}, Api.PrepReqParams(reqParams));
|
|
7046
7064
|
api.Cache.Remove(GetEntityListKey(entityId));
|
|
7065
|
+
api.Cache.RemoveByStartsWith(Api.ECacheKey.Lod + Api.ECacheKey.FilterId);
|
|
7047
7066
|
return res;
|
|
7048
7067
|
});
|
|
7049
7068
|
}
|
|
@@ -7069,6 +7088,7 @@ var EntityLod;
|
|
|
7069
7088
|
Items: [{ "LODCategory.Key": lodCategoryId, "Level": level }]
|
|
7070
7089
|
}, Api.PrepReqParams(reqParams));
|
|
7071
7090
|
api.Cache.Remove(GetEntityListKey(entityId));
|
|
7091
|
+
api.Cache.RemoveByStartsWith(Api.ECacheKey.Lod + Api.ECacheKey.FilterId);
|
|
7072
7092
|
});
|
|
7073
7093
|
}
|
|
7074
7094
|
EntityLod.Delete = Delete;
|
|
@@ -7115,6 +7135,25 @@ var EntityLod;
|
|
|
7115
7135
|
return Api.ECacheKey.Lod + Api.ECacheKey.Entity + entityId;
|
|
7116
7136
|
}
|
|
7117
7137
|
EntityLod.GetEntityListKey = GetEntityListKey;
|
|
7138
|
+
/**
|
|
7139
|
+
* Returns cache identifier for a GetLods filter.
|
|
7140
|
+
* @param filter
|
|
7141
|
+
* @returns
|
|
7142
|
+
*/
|
|
7143
|
+
function GetLodsFilterCacheKey(filter) {
|
|
7144
|
+
const filterStr = JSON.stringify({
|
|
7145
|
+
strict: Boolean(filter.strict),
|
|
7146
|
+
externalSources: Boolean(filter.externalSources),
|
|
7147
|
+
items: filter.Items.map(item => ({
|
|
7148
|
+
entityId: item.entityId || "",
|
|
7149
|
+
categoryId: item.categoryId || "",
|
|
7150
|
+
group: item.group || "DEFAULT",
|
|
7151
|
+
level: item.level || 0
|
|
7152
|
+
}))
|
|
7153
|
+
});
|
|
7154
|
+
return Api.ECacheKey.Lod + Api.ECacheKey.FilterId + btoa(filterStr);
|
|
7155
|
+
}
|
|
7156
|
+
EntityLod.GetLodsFilterCacheKey = GetLodsFilterCacheKey;
|
|
7118
7157
|
})(EntityLod || (EntityLod = {}));
|
|
7119
7158
|
|
|
7120
7159
|
/**
|
|
@@ -10069,18 +10108,22 @@ var Tileset;
|
|
|
10069
10108
|
*/
|
|
10070
10109
|
function GetList(params) {
|
|
10071
10110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10072
|
-
let { api, req: reqParams, assertLocation, expandSettings, type, pageIndex, pageSize, search, orderBy, sortOrder } = params;
|
|
10111
|
+
let { api, req: reqParams, assertLocation, expandSettings, type, pageIndex, pageSize, search, orderBy, sortOrder, tilesetIds } = params;
|
|
10073
10112
|
if (!api) {
|
|
10074
10113
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
10075
10114
|
}
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10115
|
+
let cacheKey = null;
|
|
10116
|
+
if (!(tilesetIds === null || tilesetIds === void 0 ? void 0 : tilesetIds.length) && !pageSize) {
|
|
10117
|
+
cacheKey = GetListCacheKey({
|
|
10118
|
+
assertLocation: assertLocation,
|
|
10119
|
+
expandSettings: expandSettings,
|
|
10120
|
+
type: type,
|
|
10121
|
+
orderBy: orderBy,
|
|
10122
|
+
sortOrder: sortOrder,
|
|
10123
|
+
search: search
|
|
10124
|
+
});
|
|
10125
|
+
}
|
|
10126
|
+
const cache = cacheKey ? api.GetCacheItem(cacheKey, reqParams) : null;
|
|
10084
10127
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
10085
10128
|
return cache.data;
|
|
10086
10129
|
}
|
|
@@ -10111,6 +10154,9 @@ var Tileset;
|
|
|
10111
10154
|
if (sortOrder) {
|
|
10112
10155
|
urlParams.append("SortOrder", sortOrder);
|
|
10113
10156
|
}
|
|
10157
|
+
if (tilesetIds === null || tilesetIds === void 0 ? void 0 : tilesetIds.length) {
|
|
10158
|
+
urlParams.append("ID", tilesetIds.join(","));
|
|
10159
|
+
}
|
|
10114
10160
|
const data = yield api.GET("tileset/getList?" + urlParams.toString(), reqParams);
|
|
10115
10161
|
// Convert legacy records.
|
|
10116
10162
|
// Commented out because it spams :)
|
|
@@ -10131,16 +10177,9 @@ var Tileset;
|
|
|
10131
10177
|
rej(e);
|
|
10132
10178
|
}
|
|
10133
10179
|
}));
|
|
10134
|
-
if (
|
|
10180
|
+
if (cacheKey) {
|
|
10135
10181
|
api.SetCacheItem({
|
|
10136
|
-
key:
|
|
10137
|
-
assertLocation: assertLocation,
|
|
10138
|
-
expandSettings: expandSettings,
|
|
10139
|
-
type: type,
|
|
10140
|
-
orderBy: orderBy,
|
|
10141
|
-
sortOrder: sortOrder,
|
|
10142
|
-
search: search
|
|
10143
|
-
}),
|
|
10182
|
+
key: cacheKey,
|
|
10144
10183
|
value: req,
|
|
10145
10184
|
req: reqParams
|
|
10146
10185
|
});
|
|
@@ -16393,7 +16432,7 @@ var Tracking;
|
|
|
16393
16432
|
})(Tracking || (Tracking = {}));
|
|
16394
16433
|
|
|
16395
16434
|
// This is updated with the package.json version on build.
|
|
16396
|
-
const VERSION = "6.6.
|
|
16435
|
+
const VERSION = "6.6.3";
|
|
16397
16436
|
|
|
16398
16437
|
export { VERSION, Assembly, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, UserMfaMethod, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking };
|
|
16399
16438
|
//# sourceMappingURL=bruce-models.es5.js.map
|