bruce-models 3.8.4 → 3.8.5
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 +225 -10
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +223 -9
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account-features.js +2 -0
- package/dist/lib/account/account-features.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 +2 -1
- package/dist/lib/bruce-models.js.map +1 -1
- package/dist/lib/entity/entity-historic-data.js +141 -0
- package/dist/lib/entity/entity-historic-data.js.map +1 -0
- package/dist/lib/entity/entity-type.js +47 -0
- package/dist/lib/entity/entity-type.js.map +1 -1
- package/dist/lib/entity/entity.js +48 -8
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/types/api/api.d.ts +2 -1
- package/dist/types/bruce-models.d.ts +2 -1
- package/dist/types/entity/entity-historic-data.d.ts +74 -0
- package/dist/types/entity/entity-type.d.ts +24 -0
- package/dist/types/entity/entity.d.ts +20 -0
- package/package.json +1 -1
package/dist/bruce-models.es5.js
CHANGED
|
@@ -72,6 +72,7 @@ var Api;
|
|
|
72
72
|
ECacheKey["ImportedFile"] = "importedfile";
|
|
73
73
|
ECacheKey["Plugin"] = "plugin";
|
|
74
74
|
ECacheKey["PluginIndexFile"] = "pluginindexfile";
|
|
75
|
+
ECacheKey["EntityHistoricData"] = "entityhistoricdata";
|
|
75
76
|
})(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
|
|
76
77
|
// 1 minute.
|
|
77
78
|
Api.DEFAULT_CACHE_DURATION = 60 * 1000;
|
|
@@ -2864,6 +2865,53 @@ var EntityType;
|
|
|
2864
2865
|
});
|
|
2865
2866
|
}
|
|
2866
2867
|
EntityType.Update = Update;
|
|
2868
|
+
/**
|
|
2869
|
+
* Starts a re-index background action on a specified Entity Type.
|
|
2870
|
+
* This will ensure searchable data follows the current schema version.
|
|
2871
|
+
* This will also perform certain data cleanup so that the data is consistent.
|
|
2872
|
+
* @param params
|
|
2873
|
+
* @returns
|
|
2874
|
+
*/
|
|
2875
|
+
function ReIndex(params) {
|
|
2876
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2877
|
+
let { api, entityTypeId: typeId, req } = params;
|
|
2878
|
+
if (!typeId) {
|
|
2879
|
+
throw ("Type ID is required.");
|
|
2880
|
+
}
|
|
2881
|
+
if (!api) {
|
|
2882
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
2883
|
+
}
|
|
2884
|
+
const urlParams = new URLSearchParams();
|
|
2885
|
+
if (params.dataTransformId) {
|
|
2886
|
+
urlParams.append("dataTransformID", String(params.dataTransformId));
|
|
2887
|
+
}
|
|
2888
|
+
const url = `entitytype/${typeId}/reindex?${urlParams.toString()}`;
|
|
2889
|
+
req = Api.PrepReqParams(req);
|
|
2890
|
+
const pa = yield api.POST(url, {}, req);
|
|
2891
|
+
return pa;
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
EntityType.ReIndex = ReIndex;
|
|
2895
|
+
/**
|
|
2896
|
+
* Counts the total number of Entities in an Entity Type.
|
|
2897
|
+
* @param params
|
|
2898
|
+
* @returns
|
|
2899
|
+
*/
|
|
2900
|
+
function Count(params) {
|
|
2901
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2902
|
+
let { entityTypeId, api, req } = params;
|
|
2903
|
+
if (!entityTypeId) {
|
|
2904
|
+
throw ("Type ID is required.");
|
|
2905
|
+
}
|
|
2906
|
+
if (!api) {
|
|
2907
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
2908
|
+
}
|
|
2909
|
+
const url = `entityType/${entityTypeId}/entitiesCount`;
|
|
2910
|
+
const { TotalEntities } = yield api.GET(url, Api.PrepReqParams(req));
|
|
2911
|
+
return TotalEntities;
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
EntityType.Count = Count;
|
|
2867
2915
|
/**
|
|
2868
2916
|
* Returns cache identifier for an entity type.
|
|
2869
2917
|
* Example: {
|
|
@@ -3003,7 +3051,7 @@ var Entity;
|
|
|
3003
3051
|
*/
|
|
3004
3052
|
function Get(params) {
|
|
3005
3053
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3006
|
-
let { api, entityId, req: reqParams, expandLocation, expandRelations, entityTypeId } = params;
|
|
3054
|
+
let { api, entityId, req: reqParams, expandLocation, expandRelations, entityTypeId, historicFrom, historicKey, historicTo } = params;
|
|
3007
3055
|
if (!entityId) {
|
|
3008
3056
|
throw ("Entity ID is required.");
|
|
3009
3057
|
}
|
|
@@ -3014,7 +3062,10 @@ var Entity;
|
|
|
3014
3062
|
entityId,
|
|
3015
3063
|
entityTypeId,
|
|
3016
3064
|
expandLocation,
|
|
3017
|
-
expandRelations
|
|
3065
|
+
expandRelations,
|
|
3066
|
+
historicFrom,
|
|
3067
|
+
historicKey,
|
|
3068
|
+
historicTo
|
|
3018
3069
|
});
|
|
3019
3070
|
const cache = api.GetCacheItem(key, reqParams);
|
|
3020
3071
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
@@ -3057,7 +3108,7 @@ var Entity;
|
|
|
3057
3108
|
*/
|
|
3058
3109
|
function GetListByIds(params) {
|
|
3059
3110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3060
|
-
let { api, entityIds, req: reqParams, expandRelations, expandLocation } = params;
|
|
3111
|
+
let { api, entityIds, req: reqParams, expandRelations, expandLocation, historicFrom, historicKey, historicTo } = params;
|
|
3061
3112
|
if (!entityIds.length) {
|
|
3062
3113
|
throw ("Entity IDs are required.");
|
|
3063
3114
|
}
|
|
@@ -3096,7 +3147,15 @@ var Entity;
|
|
|
3096
3147
|
const req = api.POST("entities", reqData, Api.PrepReqParams(reqParams));
|
|
3097
3148
|
for (let i = 0; i < reqIds.length; i++) {
|
|
3098
3149
|
const entityId = reqIds[i];
|
|
3099
|
-
const key = GetCacheKey({
|
|
3150
|
+
const key = GetCacheKey({
|
|
3151
|
+
entityId,
|
|
3152
|
+
expandLocation,
|
|
3153
|
+
expandRelations,
|
|
3154
|
+
entityTypeId: null,
|
|
3155
|
+
historicFrom: historicFrom,
|
|
3156
|
+
historicKey: historicKey,
|
|
3157
|
+
historicTo: historicTo
|
|
3158
|
+
});
|
|
3100
3159
|
const prom = new Promise((res) => __awaiter(this, void 0, void 0, function* () {
|
|
3101
3160
|
try {
|
|
3102
3161
|
const data = yield req;
|
|
@@ -3377,7 +3436,7 @@ var Entity;
|
|
|
3377
3436
|
function GetList(params) {
|
|
3378
3437
|
var _a;
|
|
3379
3438
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3380
|
-
let { api, filter, req: reqParams, viaCdn, viaCdnCacheToken, analysis, expandRelations } = params;
|
|
3439
|
+
let { api, filter, req: reqParams, viaCdn, viaCdnCacheToken, analysis, expandRelations, historicFrom, historicKey, historicTo } = params;
|
|
3381
3440
|
if (!api) {
|
|
3382
3441
|
api = ENVIRONMENT.Api().GetBruceApi();
|
|
3383
3442
|
}
|
|
@@ -3478,7 +3537,12 @@ var Entity;
|
|
|
3478
3537
|
api.SetCacheItem({
|
|
3479
3538
|
key: GetCacheKey({
|
|
3480
3539
|
entityId: id,
|
|
3481
|
-
expandRelations
|
|
3540
|
+
expandRelations,
|
|
3541
|
+
expandLocation: false,
|
|
3542
|
+
entityTypeId: filter.entityTypeId,
|
|
3543
|
+
historicFrom: historicFrom,
|
|
3544
|
+
historicKey: historicKey,
|
|
3545
|
+
historicTo: historicTo
|
|
3482
3546
|
}),
|
|
3483
3547
|
value: {
|
|
3484
3548
|
entity: entity
|
|
@@ -3626,11 +3690,23 @@ var Entity;
|
|
|
3626
3690
|
* @returns
|
|
3627
3691
|
*/
|
|
3628
3692
|
function GetCacheKey(params) {
|
|
3629
|
-
let { entityId, entityTypeId, expandLocation, expandRelations } = params;
|
|
3693
|
+
let { entityId, entityTypeId, expandLocation, expandRelations, historicFrom, historicKey, historicTo } = params;
|
|
3630
3694
|
if (!entityTypeId) {
|
|
3631
3695
|
entityTypeId = "";
|
|
3632
3696
|
}
|
|
3633
|
-
|
|
3697
|
+
if (!historicKey) {
|
|
3698
|
+
historicKey = "";
|
|
3699
|
+
}
|
|
3700
|
+
if (!historicFrom) {
|
|
3701
|
+
historicFrom = "";
|
|
3702
|
+
}
|
|
3703
|
+
if (!historicTo) {
|
|
3704
|
+
historicTo = "";
|
|
3705
|
+
}
|
|
3706
|
+
let key = `${Api.ECacheKey.Entity}${Api.ECacheKey.Id}${entityId}${String(entityTypeId)}`;
|
|
3707
|
+
key += `${String(Boolean(expandLocation))}${String(Boolean(expandRelations))}`;
|
|
3708
|
+
key += `${Api.ECacheKey.EntityHistoricData}${Api.ECacheKey.Id}${historicKey}${historicFrom}${historicTo}`;
|
|
3709
|
+
return key;
|
|
3634
3710
|
}
|
|
3635
3711
|
Entity.GetCacheKey = GetCacheKey;
|
|
3636
3712
|
/**
|
|
@@ -3647,6 +3723,18 @@ var Entity;
|
|
|
3647
3723
|
return `${Api.ECacheKey.Entity}${Api.ECacheKey.Id}${entityId}`;
|
|
3648
3724
|
}
|
|
3649
3725
|
Entity.GetContainsKey = GetContainsKey;
|
|
3726
|
+
/**
|
|
3727
|
+
* Returns cache identifier for entity records that have historic data.
|
|
3728
|
+
* @param attrKey
|
|
3729
|
+
* @returns
|
|
3730
|
+
*/
|
|
3731
|
+
function GetHistoricContainsKey(attrKey) {
|
|
3732
|
+
if (!attrKey) {
|
|
3733
|
+
attrKey = "";
|
|
3734
|
+
}
|
|
3735
|
+
return `${Api.ECacheKey.EntityHistoricData}${Api.ECacheKey.Id}${attrKey}`;
|
|
3736
|
+
}
|
|
3737
|
+
Entity.GetHistoricContainsKey = GetHistoricContainsKey;
|
|
3650
3738
|
})(Entity || (Entity = {}));
|
|
3651
3739
|
|
|
3652
3740
|
/**
|
|
@@ -6677,6 +6765,131 @@ var EntityAttribute;
|
|
|
6677
6765
|
EntityAttribute.AddAttribute = AddAttribute;
|
|
6678
6766
|
})(EntityAttribute || (EntityAttribute = {}));
|
|
6679
6767
|
|
|
6768
|
+
var EntityHistoricData;
|
|
6769
|
+
(function (EntityHistoricData) {
|
|
6770
|
+
/**
|
|
6771
|
+
* Returns historic data for an array of Entity IDs.
|
|
6772
|
+
* A maximum number of records will be returned per Entity ID, this information is returned in the response.
|
|
6773
|
+
* @param params
|
|
6774
|
+
* @returns
|
|
6775
|
+
*/
|
|
6776
|
+
function GetList(params) {
|
|
6777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6778
|
+
let { entityIds, attrKey, dateTimeFrom, dateTimeTo, api, req } = params;
|
|
6779
|
+
// Save time and just return a none response if no entity IDs are provided.
|
|
6780
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
|
|
6781
|
+
return {
|
|
6782
|
+
limitPerEntity: 0,
|
|
6783
|
+
recordsByIds: {}
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
if (!api) {
|
|
6787
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
6788
|
+
}
|
|
6789
|
+
if (typeof attrKey != "string") {
|
|
6790
|
+
attrKey = PathUtils.Wrap(attrKey);
|
|
6791
|
+
}
|
|
6792
|
+
const urlParams = new URLSearchParams();
|
|
6793
|
+
for (const entityId of entityIds) {
|
|
6794
|
+
urlParams.append("entityId", entityId);
|
|
6795
|
+
}
|
|
6796
|
+
urlParams.append("attrKey", attrKey);
|
|
6797
|
+
urlParams.append("dateTimeFrom", dateTimeFrom);
|
|
6798
|
+
urlParams.append("dateTimeTo", dateTimeTo);
|
|
6799
|
+
return yield api.GET(`v1/entity/historicData?${urlParams.toString()}`, Api.PrepReqParams(req));
|
|
6800
|
+
});
|
|
6801
|
+
}
|
|
6802
|
+
EntityHistoricData.GetList = GetList;
|
|
6803
|
+
/**
|
|
6804
|
+
* Returns historic data statistics for an array of Entity IDs.
|
|
6805
|
+
* @param params
|
|
6806
|
+
* @returns
|
|
6807
|
+
*/
|
|
6808
|
+
function GetStats(params) {
|
|
6809
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6810
|
+
let { entityIds, api, req } = params;
|
|
6811
|
+
// Save time and just return a none response if no entity IDs are provided.
|
|
6812
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
|
|
6813
|
+
return {
|
|
6814
|
+
stats: {}
|
|
6815
|
+
};
|
|
6816
|
+
}
|
|
6817
|
+
if (!api) {
|
|
6818
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
6819
|
+
}
|
|
6820
|
+
return yield api.POST("v1/entity/historicData/stats", {
|
|
6821
|
+
entityIds: entityIds
|
|
6822
|
+
}, Api.PrepReqParams(req));
|
|
6823
|
+
});
|
|
6824
|
+
}
|
|
6825
|
+
EntityHistoricData.GetStats = GetStats;
|
|
6826
|
+
/**
|
|
6827
|
+
* Creates or updates historic data records.
|
|
6828
|
+
* Please note that the expected input/output does not include internal fields found inside the "Bruce" attribute.
|
|
6829
|
+
* @param params
|
|
6830
|
+
* @returns
|
|
6831
|
+
*/
|
|
6832
|
+
function Update(params) {
|
|
6833
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6834
|
+
let { records, api, req } = params;
|
|
6835
|
+
// Save time and just return a none response if no records are provided.
|
|
6836
|
+
if (!(records === null || records === void 0 ? void 0 : records.length)) {
|
|
6837
|
+
return {
|
|
6838
|
+
records: []
|
|
6839
|
+
};
|
|
6840
|
+
}
|
|
6841
|
+
if (!api) {
|
|
6842
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
6843
|
+
}
|
|
6844
|
+
const res = yield api.POST("v1/entity/historicData", {
|
|
6845
|
+
records: records
|
|
6846
|
+
}, Api.PrepReqParams(req));
|
|
6847
|
+
// Kill cache for every unique attrKey.
|
|
6848
|
+
let attrKeys = records.map(r => r.attrKey);
|
|
6849
|
+
attrKeys = attrKeys.filter((v, i) => attrKeys.indexOf(v) === i);
|
|
6850
|
+
for (const attrKey of attrKeys) {
|
|
6851
|
+
api.Cache.RemoveByContains(Entity.GetHistoricContainsKey(attrKey));
|
|
6852
|
+
}
|
|
6853
|
+
return res;
|
|
6854
|
+
});
|
|
6855
|
+
}
|
|
6856
|
+
EntityHistoricData.Update = Update;
|
|
6857
|
+
/**
|
|
6858
|
+
* Deletes historic data records for an array of Entity IDs.
|
|
6859
|
+
* This deletes all records within a provided key + range.
|
|
6860
|
+
* @param params
|
|
6861
|
+
* @returns
|
|
6862
|
+
*/
|
|
6863
|
+
function Delete(params) {
|
|
6864
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6865
|
+
let { entityIds, attrKey, dateTimeFrom, dateTimeTo, api, req } = params;
|
|
6866
|
+
if (!(entityIds === null || entityIds === void 0 ? void 0 : entityIds.length)) {
|
|
6867
|
+
return;
|
|
6868
|
+
}
|
|
6869
|
+
if (!api) {
|
|
6870
|
+
api = ENVIRONMENT.Api().GetBruceApi();
|
|
6871
|
+
}
|
|
6872
|
+
if (!attrKey || !dateTimeFrom || !dateTimeTo) {
|
|
6873
|
+
throw new Error("Invalid parameters provided.");
|
|
6874
|
+
}
|
|
6875
|
+
if (typeof attrKey != "string") {
|
|
6876
|
+
attrKey = PathUtils.Wrap(attrKey);
|
|
6877
|
+
}
|
|
6878
|
+
const urlParams = new URLSearchParams();
|
|
6879
|
+
for (const entityId of entityIds) {
|
|
6880
|
+
urlParams.append("entityId", entityId);
|
|
6881
|
+
}
|
|
6882
|
+
urlParams.append("attrKey", attrKey);
|
|
6883
|
+
urlParams.append("dateTimeFrom", dateTimeFrom);
|
|
6884
|
+
urlParams.append("dateTimeTo", dateTimeTo);
|
|
6885
|
+
yield api.DELETE(`v1/entity/historicData?${urlParams.toString()}`, Api.PrepReqParams(req));
|
|
6886
|
+
// Kill cache for all Entity cached Entity records related to the attrKey.
|
|
6887
|
+
api.Cache.RemoveByContains(Entity.GetHistoricContainsKey(attrKey));
|
|
6888
|
+
});
|
|
6889
|
+
}
|
|
6890
|
+
EntityHistoricData.Delete = Delete;
|
|
6891
|
+
})(EntityHistoricData || (EntityHistoricData = {}));
|
|
6892
|
+
|
|
6680
6893
|
/**
|
|
6681
6894
|
* Utility for uploading files.
|
|
6682
6895
|
*/
|
|
@@ -10052,6 +10265,8 @@ var AccountFeatures;
|
|
|
10052
10265
|
EFeature["EntityJsonData"] = "Feature_Entity_JSONData";
|
|
10053
10266
|
// Flag to enable a text search against JSON data values.
|
|
10054
10267
|
// 'EntityJsonData' must also be enabled.
|
|
10268
|
+
// @WARNING: Please re-index all Entities first before enabling this feature.
|
|
10269
|
+
// Without this the raw 2D geometry will be indexed which will make it much slower, and may cause the update of the flag to fail.
|
|
10055
10270
|
EFeature["EntityLexicalSearch"] = "Feature_Entity_Lexical_Search";
|
|
10056
10271
|
})(EFeature = AccountFeatures.EFeature || (AccountFeatures.EFeature = {}));
|
|
10057
10272
|
/**
|
|
@@ -11166,7 +11381,7 @@ var DataSource;
|
|
|
11166
11381
|
})(DataSource || (DataSource = {}));
|
|
11167
11382
|
|
|
11168
11383
|
// This is updated with the package.json version on build.
|
|
11169
|
-
const VERSION = "3.8.
|
|
11384
|
+
const VERSION = "3.8.5";
|
|
11170
11385
|
|
|
11171
|
-
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
11386
|
+
export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
|
|
11172
11387
|
//# sourceMappingURL=bruce-models.es5.js.map
|