bruce-models 6.6.2 → 6.6.4
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 +107 -61
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +107 -61
- 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 +43 -4
- package/dist/lib/entity/entity-lod.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/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,10 +6947,28 @@ var EntityLod;
|
|
|
6940
6947
|
if (!api) {
|
|
6941
6948
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
6942
6949
|
}
|
|
6943
|
-
const
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
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 yield cache.data;
|
|
6954
|
+
}
|
|
6955
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
6956
|
+
try {
|
|
6957
|
+
const data = yield api.POST("entity/getlods", filter, reqParams);
|
|
6958
|
+
res({
|
|
6959
|
+
lods: data.Items || []
|
|
6960
|
+
});
|
|
6961
|
+
}
|
|
6962
|
+
catch (e) {
|
|
6963
|
+
rej(e);
|
|
6964
|
+
}
|
|
6965
|
+
}));
|
|
6966
|
+
api.SetCacheItem({
|
|
6967
|
+
key: cacheKey,
|
|
6968
|
+
value: prom,
|
|
6969
|
+
req: reqParams
|
|
6970
|
+
});
|
|
6971
|
+
return yield prom;
|
|
6947
6972
|
});
|
|
6948
6973
|
}
|
|
6949
6974
|
EntityLod.GetLods = GetLods;
|
|
@@ -7044,6 +7069,7 @@ var EntityLod;
|
|
|
7044
7069
|
"ClientFile.ID": params["ClientFile.ID"]
|
|
7045
7070
|
}, Api.PrepReqParams(reqParams));
|
|
7046
7071
|
api.Cache.Remove(GetEntityListKey(entityId));
|
|
7072
|
+
api.Cache.RemoveByStartsWith(Api.ECacheKey.Lod + Api.ECacheKey.FilterId);
|
|
7047
7073
|
return res;
|
|
7048
7074
|
});
|
|
7049
7075
|
}
|
|
@@ -7069,6 +7095,7 @@ var EntityLod;
|
|
|
7069
7095
|
Items: [{ "LODCategory.Key": lodCategoryId, "Level": level }]
|
|
7070
7096
|
}, Api.PrepReqParams(reqParams));
|
|
7071
7097
|
api.Cache.Remove(GetEntityListKey(entityId));
|
|
7098
|
+
api.Cache.RemoveByStartsWith(Api.ECacheKey.Lod + Api.ECacheKey.FilterId);
|
|
7072
7099
|
});
|
|
7073
7100
|
}
|
|
7074
7101
|
EntityLod.Delete = Delete;
|
|
@@ -7115,6 +7142,25 @@ var EntityLod;
|
|
|
7115
7142
|
return Api.ECacheKey.Lod + Api.ECacheKey.Entity + entityId;
|
|
7116
7143
|
}
|
|
7117
7144
|
EntityLod.GetEntityListKey = GetEntityListKey;
|
|
7145
|
+
/**
|
|
7146
|
+
* Returns cache identifier for a GetLods filter.
|
|
7147
|
+
* @param filter
|
|
7148
|
+
* @returns
|
|
7149
|
+
*/
|
|
7150
|
+
function GetLodsFilterCacheKey(filter) {
|
|
7151
|
+
const filterStr = JSON.stringify({
|
|
7152
|
+
strict: Boolean(filter.strict),
|
|
7153
|
+
externalSources: Boolean(filter.externalSources),
|
|
7154
|
+
items: filter.Items.map(item => ({
|
|
7155
|
+
entityId: item.entityId || "",
|
|
7156
|
+
categoryId: item.categoryId || "",
|
|
7157
|
+
group: item.group || "DEFAULT",
|
|
7158
|
+
level: item.level || 0
|
|
7159
|
+
}))
|
|
7160
|
+
});
|
|
7161
|
+
return Api.ECacheKey.Lod + Api.ECacheKey.FilterId + btoa(filterStr);
|
|
7162
|
+
}
|
|
7163
|
+
EntityLod.GetLodsFilterCacheKey = GetLodsFilterCacheKey;
|
|
7118
7164
|
})(EntityLod || (EntityLod = {}));
|
|
7119
7165
|
|
|
7120
7166
|
/**
|
|
@@ -16393,7 +16439,7 @@ var Tracking;
|
|
|
16393
16439
|
})(Tracking || (Tracking = {}));
|
|
16394
16440
|
|
|
16395
16441
|
// This is updated with the package.json version on build.
|
|
16396
|
-
const VERSION = "6.6.
|
|
16442
|
+
const VERSION = "6.6.4";
|
|
16397
16443
|
|
|
16398
16444
|
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
16445
|
//# sourceMappingURL=bruce-models.es5.js.map
|