bruce-models 7.1.74 → 7.1.76
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 +407 -5
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +407 -5
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api.js +3 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/entity/entity-historic-data.js +402 -4
- package/dist/lib/entity/entity-historic-data.js.map +1 -1
- package/dist/lib/entity/entity.js +1 -0
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/lib/project/menu-item.js.map +1 -1
- package/dist/types/api/api.d.ts +3 -0
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/entity/entity-historic-data.d.ts +222 -0
- package/dist/types/entity/entity.d.ts +10 -1
- package/dist/types/project/menu-item.d.ts +1 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -85,6 +85,9 @@ var Api;
|
|
|
85
85
|
ECacheKey["EntityHistoricData"] = "entityhistoricdata";
|
|
86
86
|
ECacheKey["EntityHistoricDataRec"] = "entityhistoricdatarec";
|
|
87
87
|
ECacheKey["EntityHistoricDataStats"] = "entityhistoricdatastats";
|
|
88
|
+
ECacheKey["EntityHistoricDataSeries"] = "entityhistoricdataseries";
|
|
89
|
+
ECacheKey["EntityHistoricDataAnalysis"] = "entityhistoricdataanalysis";
|
|
90
|
+
ECacheKey["EntityHistoricDataPage"] = "entityhistoricdatapage";
|
|
88
91
|
ECacheKey["AccountLimits"] = "accountlimits";
|
|
89
92
|
})(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
|
|
90
93
|
// 1 minute.
|
|
@@ -4841,9 +4844,16 @@ var PathUtils;
|
|
|
4841
4844
|
|
|
4842
4845
|
var EntityHistoricData;
|
|
4843
4846
|
(function (EntityHistoricData) {
|
|
4847
|
+
// How long a v3 historic read stays good when the caller says the data is not changing under it.
|
|
4848
|
+
// Historic records for a past range are immutable until something writes, and a write invalidates
|
|
4849
|
+
// through ClearCacheByEntityIds, so holding them is safe rather than merely convenient.
|
|
4850
|
+
EntityHistoricData.STATIC_CACHE_DURATION = 15 * 60 * 1000;
|
|
4851
|
+
// The live case genuinely gains records as it runs, so it keeps a short window.
|
|
4852
|
+
EntityHistoricData.LIVE_CACHE_DURATION = 30 * 1000;
|
|
4844
4853
|
/**
|
|
4845
4854
|
* Returns historic data for an array of Entity IDs.
|
|
4846
4855
|
* A maximum number of records will be returned per Entity ID, this information is returned in the response.
|
|
4856
|
+
* @deprecated Don't use.
|
|
4847
4857
|
* @param params
|
|
4848
4858
|
* @returns
|
|
4849
4859
|
*/
|
|
@@ -4939,6 +4949,7 @@ var EntityHistoricData;
|
|
|
4939
4949
|
EntityHistoricData.GetList = GetList;
|
|
4940
4950
|
/**
|
|
4941
4951
|
* Returns historic data statistics for an array of Entity IDs.
|
|
4952
|
+
* @deprecated Don't use.
|
|
4942
4953
|
* @param params
|
|
4943
4954
|
* @returns
|
|
4944
4955
|
*/
|
|
@@ -4978,6 +4989,7 @@ var EntityHistoricData;
|
|
|
4978
4989
|
/**
|
|
4979
4990
|
* Creates or updates historic data records.
|
|
4980
4991
|
* Please note that the expected input/output does not include internal fields found inside the "Bruce" attribute.
|
|
4992
|
+
* @deprecated Don't use.
|
|
4981
4993
|
* @param params
|
|
4982
4994
|
* @returns
|
|
4983
4995
|
*/
|
|
@@ -5015,6 +5027,7 @@ var EntityHistoricData;
|
|
|
5015
5027
|
/**
|
|
5016
5028
|
* Deletes historic data records for an array of Entity IDs.
|
|
5017
5029
|
* This deletes all records within a provided key + range.
|
|
5030
|
+
* @deprecated Don't use.
|
|
5018
5031
|
* @param params
|
|
5019
5032
|
* @returns
|
|
5020
5033
|
*/
|
|
@@ -5048,6 +5061,388 @@ var EntityHistoricData;
|
|
|
5048
5061
|
});
|
|
5049
5062
|
}
|
|
5050
5063
|
EntityHistoricData.Delete = Delete;
|
|
5064
|
+
/*
|
|
5065
|
+
* Returns how long a read may be held, based on whether the caller is tracking live data.
|
|
5066
|
+
*/
|
|
5067
|
+
function CacheDurationFor(live) {
|
|
5068
|
+
return live === false ? EntityHistoricData.STATIC_CACHE_DURATION : EntityHistoricData.LIVE_CACHE_DURATION;
|
|
5069
|
+
}
|
|
5070
|
+
/*
|
|
5071
|
+
* Shared body for the v3 historic reads, which all post to the same route.
|
|
5072
|
+
*/
|
|
5073
|
+
function BuildV3Filter(params) {
|
|
5074
|
+
const { entityIds, entityTypeId, attrKey, dateTimeFrom, dateTimeTo, scenario } = params;
|
|
5075
|
+
const body = {};
|
|
5076
|
+
if (entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) {
|
|
5077
|
+
body["Entity.ID"] = entityIds;
|
|
5078
|
+
}
|
|
5079
|
+
if (entityTypeId) {
|
|
5080
|
+
body["EntityType.ID"] = entityTypeId;
|
|
5081
|
+
}
|
|
5082
|
+
if (attrKey) {
|
|
5083
|
+
body["AttrKey"] = typeof attrKey == "string" ? attrKey : PathUtils.Wrap(attrKey);
|
|
5084
|
+
}
|
|
5085
|
+
if (dateTimeFrom) {
|
|
5086
|
+
body["DateTimeFrom"] = dateTimeFrom;
|
|
5087
|
+
}
|
|
5088
|
+
if (dateTimeTo) {
|
|
5089
|
+
body["DateTimeTo"] = dateTimeTo;
|
|
5090
|
+
}
|
|
5091
|
+
if (scenario) {
|
|
5092
|
+
body["Scenario"] = scenario;
|
|
5093
|
+
}
|
|
5094
|
+
return body;
|
|
5095
|
+
}
|
|
5096
|
+
/**
|
|
5097
|
+
* Returns a histogram of where historic records sit in time, without returning the records.
|
|
5098
|
+
* Answers "when does this data exist" for a timeline in one request, at a cost that does not grow with the number of records.
|
|
5099
|
+
* @param params
|
|
5100
|
+
* @returns
|
|
5101
|
+
*/
|
|
5102
|
+
function GetAnalysis(params) {
|
|
5103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5104
|
+
let { entityIds, entityTypeId, buckets, api, req } = params;
|
|
5105
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) && !entityTypeId) {
|
|
5106
|
+
return { analysis: [] };
|
|
5107
|
+
}
|
|
5108
|
+
if (!api) {
|
|
5109
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
5110
|
+
}
|
|
5111
|
+
req = Api.PrepReqParams(req);
|
|
5112
|
+
const body = BuildV3Filter(params);
|
|
5113
|
+
body["Analysis"] = true;
|
|
5114
|
+
if (buckets > 0) {
|
|
5115
|
+
body["Buckets"] = buckets;
|
|
5116
|
+
}
|
|
5117
|
+
const cacheKey = Api.ECacheKey.EntityHistoricDataAnalysis + Api.ECacheKey.Id + JSON.stringify(body);
|
|
5118
|
+
const cached = api.GetCacheItem(cacheKey, req);
|
|
5119
|
+
if (cached === null || cached === void 0 ? void 0 : cached.found) {
|
|
5120
|
+
return cached.data;
|
|
5121
|
+
}
|
|
5122
|
+
const prom = api.POST("v3/entities/getHistoric", body, req).then((res) => {
|
|
5123
|
+
return { analysis: ((res === null || res === void 0 ? void 0 : res.Items) || []) };
|
|
5124
|
+
});
|
|
5125
|
+
api.SetCacheItem({
|
|
5126
|
+
key: cacheKey,
|
|
5127
|
+
value: prom,
|
|
5128
|
+
req: req,
|
|
5129
|
+
duration: CacheDurationFor(params.live)
|
|
5130
|
+
});
|
|
5131
|
+
return prom;
|
|
5132
|
+
});
|
|
5133
|
+
}
|
|
5134
|
+
EntityHistoricData.GetAnalysis = GetAnalysis;
|
|
5135
|
+
/**
|
|
5136
|
+
* Returns the date range and record count per attribute key, in the shape GetStats returns.
|
|
5137
|
+
* Prefer GetAnalysis directly, which also carries the distribution.
|
|
5138
|
+
* @param params
|
|
5139
|
+
* @returns
|
|
5140
|
+
*/
|
|
5141
|
+
function GetRanges(params) {
|
|
5142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5143
|
+
// One bucket, since the distribution costs work to build and no caller of this reads it.
|
|
5144
|
+
const { analysis } = yield GetAnalysis(Object.assign(Object.assign({}, params), { buckets: 1 }));
|
|
5145
|
+
return {
|
|
5146
|
+
stats: (analysis || []).map(a => ({
|
|
5147
|
+
attrKey: a.AttrKey,
|
|
5148
|
+
dateTimeMin: a.DateTimeMin,
|
|
5149
|
+
dateTimeMax: a.DateTimeMax,
|
|
5150
|
+
count: a.Count
|
|
5151
|
+
}))
|
|
5152
|
+
};
|
|
5153
|
+
});
|
|
5154
|
+
}
|
|
5155
|
+
EntityHistoricData.GetRanges = GetRanges;
|
|
5156
|
+
/**
|
|
5157
|
+
* Returns a numeric attribute aggregated into time buckets, computed in the database.
|
|
5158
|
+
* This is what a chart wants: the reduction happens server-side, so the response is the size of
|
|
5159
|
+
* the plotted series rather than the size of the underlying records.
|
|
5160
|
+
* @param params
|
|
5161
|
+
* @returns
|
|
5162
|
+
*/
|
|
5163
|
+
function GetSeries(params) {
|
|
5164
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5165
|
+
let { entityIds, entityTypeId, valueAttrKey, aggregate, interval, api, req } = params;
|
|
5166
|
+
const empty = {
|
|
5167
|
+
AttrKey: null,
|
|
5168
|
+
Aggregate: aggregate || "avg",
|
|
5169
|
+
Interval: interval || "day",
|
|
5170
|
+
DateTimeMin: null,
|
|
5171
|
+
DateTimeMax: null,
|
|
5172
|
+
PointCount: 0,
|
|
5173
|
+
Points: []
|
|
5174
|
+
};
|
|
5175
|
+
if ((!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) && !entityTypeId) || !valueAttrKey) {
|
|
5176
|
+
return { series: empty };
|
|
5177
|
+
}
|
|
5178
|
+
if (!api) {
|
|
5179
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
5180
|
+
}
|
|
5181
|
+
req = Api.PrepReqParams(req);
|
|
5182
|
+
const body = BuildV3Filter(params);
|
|
5183
|
+
body["Select"] = { Type: "CALC" };
|
|
5184
|
+
body["selectAttrKey"] = typeof valueAttrKey == "string" ? valueAttrKey : PathUtils.Wrap(valueAttrKey);
|
|
5185
|
+
if (aggregate) {
|
|
5186
|
+
body["aggregate"] = aggregate;
|
|
5187
|
+
}
|
|
5188
|
+
if (interval) {
|
|
5189
|
+
body["interval"] = interval;
|
|
5190
|
+
}
|
|
5191
|
+
const cacheKey = Api.ECacheKey.EntityHistoricDataSeries + Api.ECacheKey.Id + JSON.stringify(body);
|
|
5192
|
+
const cached = api.GetCacheItem(cacheKey, req);
|
|
5193
|
+
if (cached === null || cached === void 0 ? void 0 : cached.found) {
|
|
5194
|
+
return cached.data;
|
|
5195
|
+
}
|
|
5196
|
+
const prom = api.POST("v3/entities/getHistoric", body, req).then((res) => {
|
|
5197
|
+
var _a;
|
|
5198
|
+
return { series: (((_a = res === null || res === void 0 ? void 0 : res.Items) === null || _a === void 0 ? void 0 : _a[0]) || empty) };
|
|
5199
|
+
});
|
|
5200
|
+
api.SetCacheItem({
|
|
5201
|
+
key: cacheKey,
|
|
5202
|
+
value: prom,
|
|
5203
|
+
req: req,
|
|
5204
|
+
duration: CacheDurationFor(params.live)
|
|
5205
|
+
});
|
|
5206
|
+
return prom;
|
|
5207
|
+
});
|
|
5208
|
+
}
|
|
5209
|
+
EntityHistoricData.GetSeries = GetSeries;
|
|
5210
|
+
/**
|
|
5211
|
+
* Returns one aggregated series per Entity, computed in the database in a single request.
|
|
5212
|
+
* @param params
|
|
5213
|
+
* @returns
|
|
5214
|
+
*/
|
|
5215
|
+
function GetSeriesByEntity(params) {
|
|
5216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5217
|
+
let { entityIds, entityTypeId, valueAttrKey, aggregate, interval, api, req } = params;
|
|
5218
|
+
if ((!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) && !entityTypeId) || !valueAttrKey) {
|
|
5219
|
+
return { seriesByIds: {} };
|
|
5220
|
+
}
|
|
5221
|
+
if (!api) {
|
|
5222
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
5223
|
+
}
|
|
5224
|
+
req = Api.PrepReqParams(req);
|
|
5225
|
+
const body = BuildV3Filter(params);
|
|
5226
|
+
body["Select"] = { Type: "CALC" };
|
|
5227
|
+
body["selectAttrKey"] = typeof valueAttrKey == "string" ? valueAttrKey : PathUtils.Wrap(valueAttrKey);
|
|
5228
|
+
body["GroupBy"] = "Entity";
|
|
5229
|
+
if (aggregate) {
|
|
5230
|
+
body["aggregate"] = aggregate;
|
|
5231
|
+
}
|
|
5232
|
+
if (interval) {
|
|
5233
|
+
body["interval"] = interval;
|
|
5234
|
+
}
|
|
5235
|
+
const cacheKey = Api.ECacheKey.EntityHistoricDataSeries + Api.ECacheKey.Id + JSON.stringify(body);
|
|
5236
|
+
const cached = api.GetCacheItem(cacheKey, req);
|
|
5237
|
+
if (cached === null || cached === void 0 ? void 0 : cached.found) {
|
|
5238
|
+
return cached.data;
|
|
5239
|
+
}
|
|
5240
|
+
const prom = api.POST("v3/entities/getHistoric", body, req).then((res) => {
|
|
5241
|
+
const seriesByIds = {};
|
|
5242
|
+
for (const series of ((res === null || res === void 0 ? void 0 : res.Items) || [])) {
|
|
5243
|
+
const entityId = series === null || series === void 0 ? void 0 : series["Entity.ID"];
|
|
5244
|
+
if (entityId) {
|
|
5245
|
+
seriesByIds[entityId] = series;
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
return { seriesByIds };
|
|
5249
|
+
});
|
|
5250
|
+
api.SetCacheItem({
|
|
5251
|
+
key: cacheKey,
|
|
5252
|
+
value: prom,
|
|
5253
|
+
req: req,
|
|
5254
|
+
duration: CacheDurationFor(params.live)
|
|
5255
|
+
});
|
|
5256
|
+
return prom;
|
|
5257
|
+
});
|
|
5258
|
+
}
|
|
5259
|
+
EntityHistoricData.GetSeriesByEntity = GetSeriesByEntity;
|
|
5260
|
+
/**
|
|
5261
|
+
* Returns one page of historic records, newest first by default.
|
|
5262
|
+
* @param params
|
|
5263
|
+
* @returns
|
|
5264
|
+
*/
|
|
5265
|
+
function GetPage(params) {
|
|
5266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5267
|
+
let { entityIds, entityTypeId, pageIndex, pageSize, orderBy, orderDir, api, req } = params;
|
|
5268
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) && !entityTypeId) {
|
|
5269
|
+
return { items: [], pageIndex: 0, pageSize: 0, sample: 0 };
|
|
5270
|
+
}
|
|
5271
|
+
if (!api) {
|
|
5272
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
5273
|
+
}
|
|
5274
|
+
req = Api.PrepReqParams(req);
|
|
5275
|
+
const body = BuildV3Filter(params);
|
|
5276
|
+
if (params.sample > 0) {
|
|
5277
|
+
body["Sample"] = params.sample;
|
|
5278
|
+
}
|
|
5279
|
+
else {
|
|
5280
|
+
body["PageIndex"] = pageIndex > 0 ? pageIndex : 0;
|
|
5281
|
+
if (pageSize > 0) {
|
|
5282
|
+
body["PageSize"] = pageSize;
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
if (orderBy) {
|
|
5286
|
+
body["OrderBy"] = orderBy;
|
|
5287
|
+
}
|
|
5288
|
+
if (orderDir) {
|
|
5289
|
+
body["OrderDir"] = orderDir;
|
|
5290
|
+
}
|
|
5291
|
+
const cacheKey = Api.ECacheKey.EntityHistoricDataPage + Api.ECacheKey.Id + JSON.stringify(body);
|
|
5292
|
+
const cached = api.GetCacheItem(cacheKey, req);
|
|
5293
|
+
if (cached === null || cached === void 0 ? void 0 : cached.found) {
|
|
5294
|
+
return cached.data;
|
|
5295
|
+
}
|
|
5296
|
+
const prom = api.POST("v3/entities/getHistoric", body, req).then((res) => {
|
|
5297
|
+
var _a, _b, _c;
|
|
5298
|
+
return {
|
|
5299
|
+
items: (res === null || res === void 0 ? void 0 : res.Items) || [],
|
|
5300
|
+
pageIndex: (_a = res === null || res === void 0 ? void 0 : res.PageIndex) !== null && _a !== void 0 ? _a : 0,
|
|
5301
|
+
pageSize: (_b = res === null || res === void 0 ? void 0 : res.PageSize) !== null && _b !== void 0 ? _b : 0,
|
|
5302
|
+
sample: (_c = res === null || res === void 0 ? void 0 : res.Sample) !== null && _c !== void 0 ? _c : 0
|
|
5303
|
+
};
|
|
5304
|
+
});
|
|
5305
|
+
api.SetCacheItem({
|
|
5306
|
+
key: cacheKey,
|
|
5307
|
+
value: prom,
|
|
5308
|
+
req: req,
|
|
5309
|
+
duration: CacheDurationFor(params.live)
|
|
5310
|
+
});
|
|
5311
|
+
return prom;
|
|
5312
|
+
});
|
|
5313
|
+
}
|
|
5314
|
+
EntityHistoricData.GetPage = GetPage;
|
|
5315
|
+
/*
|
|
5316
|
+
* Converts a v3 record into the flatter shape the render engines consume.
|
|
5317
|
+
*/
|
|
5318
|
+
function ToDataRecord(record) {
|
|
5319
|
+
const entity = (record === null || record === void 0 ? void 0 : record.Entity) || {};
|
|
5320
|
+
const bruce = entity.Bruce || {};
|
|
5321
|
+
const data = Object.assign({}, entity);
|
|
5322
|
+
delete data.Bruce;
|
|
5323
|
+
return {
|
|
5324
|
+
attrKey: record === null || record === void 0 ? void 0 : record.AttrKey,
|
|
5325
|
+
dateTime: record === null || record === void 0 ? void 0 : record.DateTime,
|
|
5326
|
+
entityId: record === null || record === void 0 ? void 0 : record["Entity.ID"],
|
|
5327
|
+
data: data,
|
|
5328
|
+
location: bruce.Location,
|
|
5329
|
+
transform: bruce.Transform,
|
|
5330
|
+
boundaries: bruce.Boundaries,
|
|
5331
|
+
geometry: bruce.VectorGeometry
|
|
5332
|
+
};
|
|
5333
|
+
}
|
|
5334
|
+
EntityHistoricData.ToDataRecord = ToDataRecord;
|
|
5335
|
+
/**
|
|
5336
|
+
* Returns records grouped per Entity.
|
|
5337
|
+
* @param params
|
|
5338
|
+
* @returns
|
|
5339
|
+
*/
|
|
5340
|
+
function GetRecordsByEntity(params) {
|
|
5341
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5342
|
+
const { entityIds, entityTypeId } = params;
|
|
5343
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length) && !entityTypeId) {
|
|
5344
|
+
return { recordsByIds: {}, sample: 0 };
|
|
5345
|
+
}
|
|
5346
|
+
const page = yield GetPage(Object.assign(Object.assign({}, params), { pageSize: params.sample > 0 ? undefined : (params.pageSize || 1000) }));
|
|
5347
|
+
const recordsByIds = {};
|
|
5348
|
+
for (const item of page.items) {
|
|
5349
|
+
const record = ToDataRecord(item);
|
|
5350
|
+
if (!record.entityId) {
|
|
5351
|
+
continue;
|
|
5352
|
+
}
|
|
5353
|
+
if (!recordsByIds[record.entityId]) {
|
|
5354
|
+
recordsByIds[record.entityId] = [];
|
|
5355
|
+
}
|
|
5356
|
+
recordsByIds[record.entityId].push(record);
|
|
5357
|
+
}
|
|
5358
|
+
for (const entityId of Object.keys(recordsByIds)) {
|
|
5359
|
+
recordsByIds[entityId].sort((a, b) => new Date(a.dateTime).getTime() - new Date(b.dateTime).getTime());
|
|
5360
|
+
}
|
|
5361
|
+
return { recordsByIds, sample: page.sample };
|
|
5362
|
+
});
|
|
5363
|
+
}
|
|
5364
|
+
EntityHistoricData.GetRecordsByEntity = GetRecordsByEntity;
|
|
5365
|
+
/*
|
|
5366
|
+
* Assembles a v3 record, nesting the platform managed values where a read reports them.
|
|
5367
|
+
*/
|
|
5368
|
+
function BuildRecord(params) {
|
|
5369
|
+
const { entityId, attrKey, dateTime, values, internal, scenario } = params;
|
|
5370
|
+
const entity = Object.assign({}, (values || {}));
|
|
5371
|
+
if (internal) {
|
|
5372
|
+
entity.Bruce = Object.assign(Object.assign({}, (entity.Bruce || {})), internal);
|
|
5373
|
+
}
|
|
5374
|
+
const record = {
|
|
5375
|
+
"Entity.ID": entityId,
|
|
5376
|
+
AttrKey: typeof attrKey == "string" ? attrKey : PathUtils.Wrap(attrKey),
|
|
5377
|
+
DateTime: dateTime,
|
|
5378
|
+
Entity: entity
|
|
5379
|
+
};
|
|
5380
|
+
if (scenario) {
|
|
5381
|
+
record.Scenario = scenario;
|
|
5382
|
+
}
|
|
5383
|
+
return record;
|
|
5384
|
+
}
|
|
5385
|
+
EntityHistoricData.BuildRecord = BuildRecord;
|
|
5386
|
+
/**
|
|
5387
|
+
* Creates or updates historic records.
|
|
5388
|
+
* @param params
|
|
5389
|
+
* @returns
|
|
5390
|
+
*/
|
|
5391
|
+
function Save(params) {
|
|
5392
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5393
|
+
let { records, scenario, api, req } = params;
|
|
5394
|
+
if (!(records === null || records === void 0 ? void 0 : records.length)) {
|
|
5395
|
+
return { records: [], warnings: [] };
|
|
5396
|
+
}
|
|
5397
|
+
if (!api) {
|
|
5398
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
5399
|
+
}
|
|
5400
|
+
const body = { Items: records };
|
|
5401
|
+
if (scenario) {
|
|
5402
|
+
body["Scenario"] = scenario;
|
|
5403
|
+
}
|
|
5404
|
+
const res = yield api.POST("v3/entities/historic", body, Api.PrepReqParams(req));
|
|
5405
|
+
const entityIds = records.map(r => r["Entity.ID"]).filter((v, i, a) => v && a.indexOf(v) === i);
|
|
5406
|
+
ClearCacheByEntityIds(api, entityIds);
|
|
5407
|
+
for (const attrKey of records.map(r => r.AttrKey).filter((v, i, a) => v && a.indexOf(v) === i)) {
|
|
5408
|
+
api.Cache.RemoveByContains(Entity.GetHistoricContainsKey(attrKey));
|
|
5409
|
+
}
|
|
5410
|
+
return {
|
|
5411
|
+
records: ((res === null || res === void 0 ? void 0 : res.Items) || []),
|
|
5412
|
+
warnings: ((res === null || res === void 0 ? void 0 : res.Warning) || [])
|
|
5413
|
+
};
|
|
5414
|
+
});
|
|
5415
|
+
}
|
|
5416
|
+
EntityHistoricData.Save = Save;
|
|
5417
|
+
/**
|
|
5418
|
+
* Deletes every historic record matching the filter, and reports how many were removed.
|
|
5419
|
+
* The filter is the one the reads accept, so a caller can delete exactly what it just listed.
|
|
5420
|
+
* @param params
|
|
5421
|
+
* @returns
|
|
5422
|
+
*/
|
|
5423
|
+
function DeleteRange(params) {
|
|
5424
|
+
var _a;
|
|
5425
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5426
|
+
let { entityIds, attrKey, dateTimeFrom, dateTimeTo, scenario, api, req } = params;
|
|
5427
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
|
|
5428
|
+
return { deleted: 0 };
|
|
5429
|
+
}
|
|
5430
|
+
if (!api) {
|
|
5431
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
5432
|
+
}
|
|
5433
|
+
if (!scenario && (!attrKey || !dateTimeFrom || !dateTimeTo)) {
|
|
5434
|
+
throw new Error("Deleting outside a Scenario requires attrKey, dateTimeFrom and dateTimeTo.");
|
|
5435
|
+
}
|
|
5436
|
+
const body = BuildV3Filter(params);
|
|
5437
|
+
const res = yield api.POST("v3/entities/deleteHistoric", body, Api.PrepReqParams(req));
|
|
5438
|
+
if (attrKey) {
|
|
5439
|
+
api.Cache.RemoveByContains(Entity.GetHistoricContainsKey(typeof attrKey == "string" ? attrKey : PathUtils.Wrap(attrKey)));
|
|
5440
|
+
}
|
|
5441
|
+
ClearCacheByEntityIds(api, entityIds);
|
|
5442
|
+
return { deleted: (_a = res === null || res === void 0 ? void 0 : res.Deleted) !== null && _a !== void 0 ? _a : 0 };
|
|
5443
|
+
});
|
|
5444
|
+
}
|
|
5445
|
+
EntityHistoricData.DeleteRange = DeleteRange;
|
|
5051
5446
|
function GetListCacheKey(entityIds, attrKey, dateTimeFrom, dateTimeTo) {
|
|
5052
5447
|
return Api.ECacheKey.EntityHistoricDataRec + Api.ECacheKey.Id + entityIds.join(",") + Api.ECacheKey.Id + attrKey + Api.ECacheKey.Id + dateTimeFrom + Api.ECacheKey.Id + dateTimeTo;
|
|
5053
5448
|
}
|
|
@@ -5066,15 +5461,21 @@ var EntityHistoricData;
|
|
|
5066
5461
|
if (!api || !(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
|
|
5067
5462
|
return;
|
|
5068
5463
|
}
|
|
5069
|
-
const
|
|
5070
|
-
|
|
5464
|
+
const PREFIXES = [
|
|
5465
|
+
Api.ECacheKey.EntityHistoricDataRec + Api.ECacheKey.Id,
|
|
5466
|
+
Api.ECacheKey.EntityHistoricDataStats + Api.ECacheKey.Id,
|
|
5467
|
+
Api.ECacheKey.EntityHistoricDataSeries + Api.ECacheKey.Id,
|
|
5468
|
+
Api.ECacheKey.EntityHistoricDataAnalysis + Api.ECacheKey.Id,
|
|
5469
|
+
Api.ECacheKey.EntityHistoricDataPage + Api.ECacheKey.Id
|
|
5470
|
+
];
|
|
5071
5471
|
api.Cache.RemoveByCallback((key) => {
|
|
5072
5472
|
let keyStr = String(key);
|
|
5073
|
-
|
|
5473
|
+
const prefix = PREFIXES.find(p => keyStr.startsWith(p));
|
|
5474
|
+
if (!prefix) {
|
|
5074
5475
|
return false;
|
|
5075
5476
|
}
|
|
5076
5477
|
// Shorten to speed up the next step.
|
|
5077
|
-
keyStr = keyStr.replace(
|
|
5478
|
+
keyStr = keyStr.replace(prefix, "");
|
|
5078
5479
|
// Look for any matching Entity IDs.
|
|
5079
5480
|
for (let i = 0; i < entityIds.length; i++) {
|
|
5080
5481
|
const entityId = entityIds[i];
|
|
@@ -6074,6 +6475,7 @@ var Entity;
|
|
|
6074
6475
|
(function (EOutlineKind) {
|
|
6075
6476
|
EOutlineKind["Entity"] = "ENTITY";
|
|
6076
6477
|
EOutlineKind["Attribute"] = "ATTRIBUTE";
|
|
6478
|
+
EOutlineKind["Reference"] = "REFERENCE";
|
|
6077
6479
|
})(EOutlineKind = Entity.EOutlineKind || (Entity.EOutlineKind = {}));
|
|
6078
6480
|
/**
|
|
6079
6481
|
* Returns an entity record for the given entity id.
|
|
@@ -19961,7 +20363,7 @@ var UrlUtils;
|
|
|
19961
20363
|
})(UrlUtils || (UrlUtils = {}));
|
|
19962
20364
|
|
|
19963
20365
|
// This is updated with the package.json version on build.
|
|
19964
|
-
const VERSION = "7.1.
|
|
20366
|
+
const VERSION = "7.1.76";
|
|
19965
20367
|
|
|
19966
20368
|
export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportUsd, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
|
|
19967
20369
|
//# sourceMappingURL=bruce-models.es5.js.map
|