bruce-models 7.1.19 → 7.1.21

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.
@@ -40,6 +40,7 @@ var Api;
40
40
  ECacheKey["Entity"] = "entity";
41
41
  ECacheKey["EntityType"] = "entitytype";
42
42
  ECacheKey["EntityTypeTrigger"] = "entitytypetrigger";
43
+ ECacheKey["DataFeed"] = "datafeed";
43
44
  ECacheKey["ProjectView"] = "projectview";
44
45
  ECacheKey["ProjectViewBookmark"] = "pvbookmark";
45
46
  ECacheKey["Tileset"] = "tileset";
@@ -5249,136 +5250,166 @@ var Calculator;
5249
5250
  if (type == "number" && field.type == EValueType.Color) {
5250
5251
  field.type = EValueType.Input;
5251
5252
  }
5252
- switch (field.type) {
5253
- case EValueType.Color:
5254
- if (type === "number") {
5255
- break;
5253
+ // Custom resolution.
5254
+ if (field.value instanceof Function) {
5255
+ value = field.value(data, tags);
5256
+ if (type == "number") {
5257
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
5258
+ value = Number(value);
5256
5259
  }
5257
- value = field.value;
5258
- value = assertColor(value);
5259
- if (value && type == "string") {
5260
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5260
+ else if (typeof value != "number") {
5261
+ value = null;
5261
5262
  }
5262
- break;
5263
- case EValueType.Gradient:
5264
- if (type === "number") {
5265
- break;
5266
- }
5267
- value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
5268
- value = assertColor(value);
5269
- if (value && type == "string") {
5270
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5263
+ }
5264
+ else if (type == "string") {
5265
+ if (typeof value == "number") {
5266
+ value = String(value);
5271
5267
  }
5272
- break;
5273
- case EValueType.RandomColor:
5274
- if (type === "number") {
5275
- break;
5268
+ else if (typeof value == "object") {
5269
+ if (isColor(value)) {
5270
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5271
+ }
5272
+ else {
5273
+ value = null;
5274
+ }
5276
5275
  }
5277
- value = Color.RandomColor();
5276
+ }
5277
+ else if (type == "color") {
5278
5278
  value = assertColor(value);
5279
- if (value && type == "string") {
5280
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5281
- }
5282
- break;
5283
- case EValueType.TagColor:
5284
- if (type === "number") {
5279
+ }
5280
+ }
5281
+ else {
5282
+ switch (field.type) {
5283
+ case EValueType.Color:
5284
+ if (type === "number") {
5285
+ break;
5286
+ }
5287
+ value = field.value;
5288
+ value = assertColor(value);
5289
+ if (value && type == "string") {
5290
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5291
+ }
5285
5292
  break;
5286
- }
5287
- for (let i = 0; i < tags.length; i++) {
5288
- const tag = tags[i];
5289
- if (tag.Color) {
5290
- value = Color.ColorFromStr(tag.Color);
5291
- value = assertColor(value);
5292
- if (value) {
5293
- break;
5294
- }
5293
+ case EValueType.Gradient:
5294
+ if (type === "number") {
5295
+ break;
5295
5296
  }
5296
- }
5297
- if (value && type == "string") {
5298
- const cColor = value;
5299
- value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
5300
- }
5301
- break;
5302
- // Input can be an arbitrary value.
5303
- // Eg: Result is a colour, a number, a string.
5304
- // This means we first calculate the value, then validate it in the context of the desired type.
5305
- case EValueType.Input:
5306
- value = GetInputValue(field.value, data);
5307
- if (value != null) {
5308
- if (type == "number") {
5309
- if (typeof value == "string" && value != "" && value != null && value != undefined) {
5310
- value = Number(value);
5311
- }
5312
- else if (typeof value != "number") {
5313
- value = null;
5314
- }
5297
+ value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
5298
+ value = assertColor(value);
5299
+ if (value && type == "string") {
5300
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5301
+ }
5302
+ break;
5303
+ case EValueType.RandomColor:
5304
+ if (type === "number") {
5305
+ break;
5306
+ }
5307
+ value = Color.RandomColor();
5308
+ value = assertColor(value);
5309
+ if (value && type == "string") {
5310
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5311
+ }
5312
+ break;
5313
+ case EValueType.TagColor:
5314
+ if (type === "number") {
5315
+ break;
5315
5316
  }
5316
- else if (type == "string") {
5317
- if (typeof value == "number") {
5318
- value = String(value);
5317
+ for (let i = 0; i < tags.length; i++) {
5318
+ const tag = tags[i];
5319
+ if (tag.Color) {
5320
+ value = Color.ColorFromStr(tag.Color);
5321
+ value = assertColor(value);
5322
+ if (value) {
5323
+ break;
5324
+ }
5319
5325
  }
5320
- else if (typeof value == "object") {
5321
- if (isColor(value)) {
5322
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5326
+ }
5327
+ if (value && type == "string") {
5328
+ const cColor = value;
5329
+ value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
5330
+ }
5331
+ break;
5332
+ // Input can be an arbitrary value.
5333
+ // Eg: Result is a colour, a number, a string.
5334
+ // This means we first calculate the value, then validate it in the context of the desired type.
5335
+ case EValueType.Input:
5336
+ value = GetInputValue(field.value, data);
5337
+ if (value != null) {
5338
+ if (type == "number") {
5339
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
5340
+ value = Number(value);
5323
5341
  }
5324
- else {
5342
+ else if (typeof value != "number") {
5325
5343
  value = null;
5326
5344
  }
5327
5345
  }
5328
- }
5329
- else if (type == "color") {
5330
- value = assertColor(value);
5331
- }
5332
- }
5333
- break;
5334
- // Mapping can be an arbitrary value.
5335
- // Eg: mapping a value to a Client File ID, or a colour, or a number.
5336
- // This means we first calculate the value, then validate it in the context of the desired type.
5337
- case EValueType.Mapping:
5338
- value = GetMappingValue(field.value, data);
5339
- if (value != null) {
5340
- if (type == "number") {
5341
- if (typeof value == "string" && value != "" && value != null && value != undefined) {
5342
- value = Number(value);
5346
+ else if (type == "string") {
5347
+ if (typeof value == "number") {
5348
+ value = String(value);
5349
+ }
5350
+ else if (typeof value == "object") {
5351
+ if (isColor(value)) {
5352
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5353
+ }
5354
+ else {
5355
+ value = null;
5356
+ }
5357
+ }
5343
5358
  }
5344
- else if (typeof value != "number") {
5345
- value = null;
5359
+ else if (type == "color") {
5360
+ value = assertColor(value);
5346
5361
  }
5347
5362
  }
5348
- else if (type == "string") {
5349
- if (typeof value == "number") {
5350
- value = String(value);
5351
- }
5352
- else if (typeof value == "object") {
5353
- if (isColor(value)) {
5354
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5363
+ break;
5364
+ // Mapping can be an arbitrary value.
5365
+ // Eg: mapping a value to a Client File ID, or a colour, or a number.
5366
+ // This means we first calculate the value, then validate it in the context of the desired type.
5367
+ case EValueType.Mapping:
5368
+ value = GetMappingValue(field.value, data);
5369
+ if (value != null) {
5370
+ if (type == "number") {
5371
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
5372
+ value = Number(value);
5355
5373
  }
5356
- else {
5374
+ else if (typeof value != "number") {
5357
5375
  value = null;
5358
5376
  }
5359
5377
  }
5378
+ else if (type == "string") {
5379
+ if (typeof value == "number") {
5380
+ value = String(value);
5381
+ }
5382
+ else if (typeof value == "object") {
5383
+ if (isColor(value)) {
5384
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5385
+ }
5386
+ else {
5387
+ value = null;
5388
+ }
5389
+ }
5390
+ }
5391
+ else if (type == "color") {
5392
+ value = assertColor(typeof value === "number" ? String(value) : value);
5393
+ }
5360
5394
  }
5361
- else if (type == "color") {
5362
- value = assertColor(typeof value === "number" ? String(value) : value);
5363
- }
5395
+ break;
5396
+ }
5397
+ // Extra layer of validation.
5398
+ // This is a backup in case some branch above failed to convert into the right type.
5399
+ if (type == "number") {
5400
+ if (typeof value !== "number" || isNaN(value)) {
5401
+ value = null;
5364
5402
  }
5365
- break;
5366
- }
5367
- // Extra layer of validation.
5368
- // This is a backup in case some branch above failed to convert into the right type.
5369
- if (type == "number") {
5370
- if (typeof value !== "number" || isNaN(value)) {
5371
- value = null;
5372
5403
  }
5373
- }
5374
- else if (type == "color") {
5375
- if (typeof value !== "object" || !value) {
5376
- value = null;
5404
+ else if (type == "color") {
5405
+ if (typeof value !== "object" || !value) {
5406
+ value = null;
5407
+ }
5377
5408
  }
5378
- }
5379
- else if (type == "string") {
5380
- if (typeof value !== "string" || !value) {
5381
- value = null;
5409
+ else if (type == "string") {
5410
+ if (typeof value !== "string" || !value) {
5411
+ value = null;
5412
+ }
5382
5413
  }
5383
5414
  }
5384
5415
  if (value != null) {
@@ -15716,6 +15747,208 @@ var DataLabGroup;
15716
15747
  DataLabGroup.Delete = Delete;
15717
15748
  })(DataLabGroup || (DataLabGroup = {}));
15718
15749
 
15750
+ /**
15751
+ * Describes the "Data Feed" concept within Nextspace.
15752
+ * Each record represents one configured Data Feed endpoint.
15753
+ */
15754
+ var DataFeed;
15755
+ (function (DataFeed) {
15756
+ /**
15757
+ * Known data feed types.
15758
+ */
15759
+ let EType;
15760
+ (function (EType) {
15761
+ EType["WFS"] = "WFS";
15762
+ })(EType = DataFeed.EType || (DataFeed.EType = {}));
15763
+ /**
15764
+ * Returns details of a data feed by ID or Key.
15765
+ * @param params
15766
+ */
15767
+ function Get(params) {
15768
+ return __awaiter(this, void 0, void 0, function* () {
15769
+ let { api, dataFeedId, req: reqParams } = params;
15770
+ if (dataFeedId == null || dataFeedId === "") {
15771
+ throw ("Data Feed ID or Key is required.");
15772
+ }
15773
+ if (!api) {
15774
+ api = ENVIRONMENT.Api().GetBruceApi();
15775
+ }
15776
+ const key = GetCacheKey(dataFeedId);
15777
+ const cache = api.GetCacheItem(key, reqParams);
15778
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
15779
+ return cache.data;
15780
+ }
15781
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
15782
+ try {
15783
+ const data = yield api.GET(`dataFeed/${dataFeedId}`, Api.PrepReqParams(reqParams));
15784
+ res({
15785
+ dataFeed: ParseResponse(data)
15786
+ });
15787
+ }
15788
+ catch (e) {
15789
+ rej(e);
15790
+ }
15791
+ }));
15792
+ api.SetCacheItem({
15793
+ key,
15794
+ value: req,
15795
+ req: reqParams
15796
+ });
15797
+ return req;
15798
+ });
15799
+ }
15800
+ DataFeed.Get = Get;
15801
+ /**
15802
+ * Returns a list of all data feed records.
15803
+ * @param params
15804
+ */
15805
+ function GetList(params) {
15806
+ return __awaiter(this, void 0, void 0, function* () {
15807
+ if (!params) {
15808
+ params = {};
15809
+ }
15810
+ let { api, req: reqParams } = params;
15811
+ if (!api) {
15812
+ api = ENVIRONMENT.Api().GetBruceApi();
15813
+ }
15814
+ const key = GetListCacheKey();
15815
+ const cache = api.GetCacheItem(key, reqParams);
15816
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
15817
+ return cache.data;
15818
+ }
15819
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
15820
+ try {
15821
+ const data = yield api.GET("dataFeeds", Api.PrepReqParams(reqParams));
15822
+ res({
15823
+ dataFeeds: ParseListResponse(data)
15824
+ });
15825
+ }
15826
+ catch (e) {
15827
+ rej(e);
15828
+ }
15829
+ }));
15830
+ api.SetCacheItem({
15831
+ key,
15832
+ value: req,
15833
+ req: reqParams
15834
+ });
15835
+ return req;
15836
+ });
15837
+ }
15838
+ DataFeed.GetList = GetList;
15839
+ /**
15840
+ * Creates or updates a data feed record.
15841
+ * This calls: POST dataFeed/{data_feed_id} where 0 creates new.
15842
+ * @param params
15843
+ */
15844
+ function Update(params) {
15845
+ return __awaiter(this, void 0, void 0, function* () {
15846
+ let { api, dataFeed: data, req: reqParams } = params;
15847
+ if (!api) {
15848
+ api = ENVIRONMENT.Api().GetBruceApi();
15849
+ }
15850
+ if (!data) {
15851
+ data = {};
15852
+ }
15853
+ const id = data.ID && data.ID > 0 ? data.ID : 0;
15854
+ const res = yield api.POST(`dataFeed/${id}`, data, Api.PrepReqParams(reqParams));
15855
+ // Invalidate list and likely keys.
15856
+ api.Cache.Remove(GetListCacheKey());
15857
+ if (id > 0) {
15858
+ api.Cache.Remove(GetCacheKey(id));
15859
+ }
15860
+ if (data.Key) {
15861
+ api.Cache.Remove(GetCacheKey(data.Key));
15862
+ }
15863
+ const parsed = ParseResponse(res);
15864
+ if (parsed === null || parsed === void 0 ? void 0 : parsed.ID) {
15865
+ api.Cache.Remove(GetCacheKey(parsed.ID));
15866
+ }
15867
+ if (parsed === null || parsed === void 0 ? void 0 : parsed.Key) {
15868
+ api.Cache.Remove(GetCacheKey(parsed.Key));
15869
+ }
15870
+ return {
15871
+ dataFeed: parsed
15872
+ };
15873
+ });
15874
+ }
15875
+ DataFeed.Update = Update;
15876
+ /**
15877
+ * Deletes a data feed by numeric ID.
15878
+ * @param params
15879
+ */
15880
+ function Delete(params) {
15881
+ return __awaiter(this, void 0, void 0, function* () {
15882
+ let { api, dataFeedId, req: reqParams } = params;
15883
+ if (!dataFeedId || dataFeedId <= 0) {
15884
+ throw ("Data Feed ID is required.");
15885
+ }
15886
+ if (!api) {
15887
+ api = ENVIRONMENT.Api().GetBruceApi();
15888
+ }
15889
+ yield api.DELETE(`dataFeed/${dataFeedId}`, Api.PrepReqParams(reqParams));
15890
+ api.Cache.Remove(GetCacheKey(dataFeedId));
15891
+ api.Cache.Remove(GetListCacheKey());
15892
+ });
15893
+ }
15894
+ DataFeed.Delete = Delete;
15895
+ /**
15896
+ * Normalizes response from data feed get/update endpoints.
15897
+ */
15898
+ function ParseResponse(response) {
15899
+ var _a, _b, _c, _d, _e, _f;
15900
+ const parsed = parseObject$2(response);
15901
+ const parsedResult = (_a = parseObject$2(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
15902
+ return (_f = (_e = (_d = (_c = (_b = parsed === null || parsed === void 0 ? void 0 : parsed.DataFeed) !== null && _b !== void 0 ? _b : parsed === null || parsed === void 0 ? void 0 : parsed.BruceDataFeed) !== null && _c !== void 0 ? _c : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.DataFeed) !== null && _d !== void 0 ? _d : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.BruceDataFeed) !== null && _e !== void 0 ? _e : parsedResult) !== null && _f !== void 0 ? _f : parsed;
15903
+ }
15904
+ DataFeed.ParseResponse = ParseResponse;
15905
+ /**
15906
+ * Normalizes response from data feed list endpoint.
15907
+ */
15908
+ function ParseListResponse(response) {
15909
+ var _a, _b, _c, _d, _e, _f, _g, _h;
15910
+ const parsed = parseObject$2(response);
15911
+ const parsedResult = (_a = parseObject$2(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
15912
+ const list = (_h = (_g = (_f = (_e = (_d = (_c = (_b = parsed === null || parsed === void 0 ? void 0 : parsed.Items) !== null && _b !== void 0 ? _b : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.Items) !== null && _c !== void 0 ? _c : parsed === null || parsed === void 0 ? void 0 : parsed.DataFeeds) !== null && _d !== void 0 ? _d : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.DataFeeds) !== null && _e !== void 0 ? _e : parsed === null || parsed === void 0 ? void 0 : parsed.BruceDataFeeds) !== null && _f !== void 0 ? _f : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.BruceDataFeeds) !== null && _g !== void 0 ? _g : parsedResult) !== null && _h !== void 0 ? _h : parsed;
15913
+ if (Array.isArray(list)) {
15914
+ return list;
15915
+ }
15916
+ return [];
15917
+ }
15918
+ DataFeed.ParseListResponse = ParseListResponse;
15919
+ /**
15920
+ * Returns cache identifier for a data feed by ID/Key.
15921
+ * @param idOrKey
15922
+ * @returns
15923
+ */
15924
+ function GetCacheKey(idOrKey) {
15925
+ return `${Api.ECacheKey.DataFeed}${Api.ECacheKey.Id}${idOrKey}`;
15926
+ }
15927
+ DataFeed.GetCacheKey = GetCacheKey;
15928
+ /**
15929
+ * Returns cache identifier for the list of data feeds.
15930
+ * @returns
15931
+ */
15932
+ function GetListCacheKey() {
15933
+ return Api.ECacheKey.DataFeed;
15934
+ }
15935
+ DataFeed.GetListCacheKey = GetListCacheKey;
15936
+ })(DataFeed || (DataFeed = {}));
15937
+ function parseObject$2(data) {
15938
+ if (data == null || data == undefined) {
15939
+ return null;
15940
+ }
15941
+ if (typeof data == "string") {
15942
+ try {
15943
+ return JSON.parse(data);
15944
+ }
15945
+ catch (_a) {
15946
+ return null;
15947
+ }
15948
+ }
15949
+ return data;
15950
+ }
15951
+
15719
15952
  var ImportAssembly;
15720
15953
  (function (ImportAssembly) {
15721
15954
  function Analyze(params) {
@@ -17461,7 +17694,7 @@ var ChangeSet;
17461
17694
  })(ChangeSet || (ChangeSet = {}));
17462
17695
 
17463
17696
  // This is updated with the package.json version on build.
17464
- const VERSION = "7.1.19";
17697
+ const VERSION = "7.1.21";
17465
17698
 
17466
- 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, EntityTypeTrigger, 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, NavigatorChatClient, NavigatorMcpWebSocketClient, ChangeSet };
17699
+ 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, EntityTypeTrigger, 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, DataFeed, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking, NavigatorChatClient, NavigatorMcpWebSocketClient, ChangeSet };
17467
17700
  //# sourceMappingURL=bruce-models.es5.js.map