bruce-models 4.3.8 → 4.4.0

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.
@@ -1353,18 +1353,20 @@ var BruceApi;
1353
1353
  this.loadCancelled = false;
1354
1354
  // Indicates if loading the regional configuration was already called.
1355
1355
  this.configLoadAttempted = false;
1356
- let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket } = params;
1356
+ let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
1357
1357
  this.accountId = accountId;
1358
1358
  this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
1359
- // Backwards compatibility.
1360
- if (loadRegionalBaseUrl) {
1361
- loadConfig = true;
1362
- }
1363
- if (loadConfig) {
1364
- // Mark it as attempted right away because we don't want any external calls while it gets to that async point.
1365
- this.configLoadAttempted = true;
1359
+ if (!dummy) {
1360
+ // Backwards compatibility.
1361
+ if (loadRegionalBaseUrl) {
1362
+ loadConfig = true;
1363
+ }
1364
+ if (loadConfig) {
1365
+ // Mark it as attempted right away because we don't want any external calls while it gets to that async point.
1366
+ this.configLoadAttempted = true;
1367
+ }
1368
+ this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
1366
1369
  }
1367
- this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
1368
1370
  }
1369
1371
  /**
1370
1372
  * Loads regional base url and sets up message broker.
@@ -2775,6 +2777,115 @@ var ObjectUtils;
2775
2777
  ObjectUtils.UId = UId;
2776
2778
  })(ObjectUtils || (ObjectUtils = {}));
2777
2779
 
2780
+ /**
2781
+ * Describes an entity type schema attribute.
2782
+ */
2783
+ var EntityAttribute;
2784
+ (function (EntityAttribute) {
2785
+ let EType;
2786
+ (function (EType) {
2787
+ // Arbitrary text attribute.
2788
+ EType["String"] = "String";
2789
+ // Floating point number attribute.
2790
+ EType["Double"] = "Double";
2791
+ // Whole number attribute.
2792
+ EType["Integer"] = "Integer";
2793
+ // iso8601 date time string.
2794
+ EType["Datetime"] = "Datetime";
2795
+ // Group of attributes.
2796
+ EType["Structure"] = "Structure";
2797
+ // Nextspace vector geometry.
2798
+ EType["Geometry"] = "Geometry";
2799
+ // True/false attribute.
2800
+ EType["Boolean"] = "Boolean";
2801
+ })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
2802
+ /**
2803
+ * Returns an attribute from a provided hierarchy of attributes.
2804
+ * Eg: Use the path: ["Bruce", "ID"] to find the "ID" attribute.
2805
+ * @param items
2806
+ * @param path
2807
+ * @returns
2808
+ */
2809
+ function GetAttribute(items, path) {
2810
+ if (!items || !path || !path.length) {
2811
+ return null;
2812
+ }
2813
+ const key = path[0];
2814
+ const item = items.find((i) => i.Key === key);
2815
+ if (!item || !item.Structure || !path.length) {
2816
+ return item;
2817
+ }
2818
+ return GetAttribute(item.Structure, path.slice(1));
2819
+ }
2820
+ EntityAttribute.GetAttribute = GetAttribute;
2821
+ /**
2822
+ * Removes an attribute from a provided hierarchy of attributes.
2823
+ * Eg: Use the path: ["Bruce", "ID"] to remove the "ID" attribute.
2824
+ * This will mutate the items array.
2825
+ * @param items
2826
+ * @param path
2827
+ */
2828
+ function RemoveAttribute(items, path) {
2829
+ if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
2830
+ return;
2831
+ }
2832
+ const key = path[0];
2833
+ if (path.length === 1) {
2834
+ // If we're at the last key in the path, remove the item from the items array.
2835
+ const index = items.findIndex((i) => i.Key === key);
2836
+ if (index !== -1) {
2837
+ items.splice(index, 1);
2838
+ }
2839
+ return;
2840
+ }
2841
+ // If we're not at the end of the path, dig further.
2842
+ const item = items.find((i) => i.Key === key);
2843
+ if (item && item.Structure) {
2844
+ RemoveAttribute(item.Structure, path.slice(1));
2845
+ }
2846
+ }
2847
+ EntityAttribute.RemoveAttribute = RemoveAttribute;
2848
+ /**
2849
+ * Adds an attribute to a provided hierarchy of attributes.
2850
+ * Eg: Use the path: ["Bruce", "ID"] to add the "ID" attribute.
2851
+ * This will mutate the items array.
2852
+ * This requires the path to be valid and for a parent attribute to exist.
2853
+ * @param items
2854
+ * @param path
2855
+ * @param attribute
2856
+ */
2857
+ function AddAttribute(items, path, attribute) {
2858
+ if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
2859
+ return;
2860
+ }
2861
+ const key = path[0];
2862
+ if (path.length === 1) {
2863
+ // If we're at the last key in the path, add the attribute to the items array.
2864
+ const index = items.findIndex((i) => i.Key === key);
2865
+ if (index !== -1) {
2866
+ // Overwrite existing attribute if it already exists.
2867
+ items[index] = attribute;
2868
+ }
2869
+ else {
2870
+ // Add new attribute if it doesn't exist.
2871
+ items.push(attribute);
2872
+ }
2873
+ return;
2874
+ }
2875
+ // If we're not at the end of the path, dig further.
2876
+ let item = items.find((i) => i.Key === key);
2877
+ if (!item) {
2878
+ item = { Key: key, Structure: [] };
2879
+ items.push(item);
2880
+ }
2881
+ if (!item.Structure) {
2882
+ item.Structure = [];
2883
+ }
2884
+ AddAttribute(item.Structure, path.slice(1), attribute);
2885
+ }
2886
+ EntityAttribute.AddAttribute = AddAttribute;
2887
+ })(EntityAttribute || (EntityAttribute = {}));
2888
+
2778
2889
  /**
2779
2890
  * Describes the "Entity Type" concept within Nextspace.
2780
2891
  * An entity type is an "expectation" of what data "should" look like in a particular entity record.
@@ -2804,6 +2915,7 @@ var EntityType;
2804
2915
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
2805
2916
  try {
2806
2917
  const data = yield api.GET(`entitytype/${typeId}`, Api.PrepReqParams(reqParams));
2918
+ appendInternalAttrSchema(data);
2807
2919
  res({
2808
2920
  entityType: data
2809
2921
  });
@@ -2867,6 +2979,9 @@ var EntityType;
2867
2979
  }
2868
2980
  }
2869
2981
  const data = yield api.GET("entitytypes?" + urlParams.toString(), Api.PrepReqParams(reqParams));
2982
+ for (const item of data.Items) {
2983
+ appendInternalAttrSchema(item);
2984
+ }
2870
2985
  res({
2871
2986
  entityTypes: data.Items
2872
2987
  });
@@ -2907,6 +3022,7 @@ var EntityType;
2907
3022
  if (!data.Name) {
2908
3023
  data.Name = data.ID;
2909
3024
  }
3025
+ appendInternalAttrSchema(data);
2910
3026
  const res = yield api.POST(`entitytype/${data.ID}`, data, Api.PrepReqParams(reqParams));
2911
3027
  api.Cache.Remove(GetCacheKey(data.ID));
2912
3028
  api.Cache.RemoveByStartsWith(GetListCacheKey());
@@ -2995,6 +3111,176 @@ var EntityType;
2995
3111
  }
2996
3112
  EntityType.GetListCacheKey = GetListCacheKey;
2997
3113
  })(EntityType || (EntityType = {}));
3114
+ /**
3115
+ * Adds expected internal structure items even if they aren't there.
3116
+ * Our API should be including them but this is a safety net.
3117
+ * @param type
3118
+ */
3119
+ function appendInternalAttrSchema(type) {
3120
+ // Schema not loaded. We'll ignore.
3121
+ if (type == null || type.DataSchema == null) {
3122
+ return;
3123
+ }
3124
+ // Append internal attributes.
3125
+ if (!type.DataSchema.Structure) {
3126
+ type.DataSchema.Structure = [];
3127
+ }
3128
+ let bruce = type.DataSchema.Structure.find(a => a.Key == "Bruce");
3129
+ if (!bruce) {
3130
+ bruce = {
3131
+ Key: "Bruce",
3132
+ Name: "Bruce",
3133
+ Description: "Nextspace internal attributes.",
3134
+ Type: EntityAttribute.EType.Structure,
3135
+ Structure: [],
3136
+ IsIndexed: true,
3137
+ IsImportant: false
3138
+ };
3139
+ type.DataSchema.Structure.push(bruce);
3140
+ }
3141
+ if (!bruce.Structure) {
3142
+ bruce.Structure = [];
3143
+ }
3144
+ // Append any missing internal attributes.
3145
+ if (!bruce.Structure.find(x => x.Key == "Location")) {
3146
+ bruce.Structure.push({
3147
+ Key: "Location",
3148
+ Name: "Location",
3149
+ Description: "Location data.",
3150
+ Type: EntityAttribute.EType.Structure,
3151
+ Structure: [
3152
+ {
3153
+ Key: "latitude",
3154
+ Name: "Latitude",
3155
+ Type: EntityAttribute.EType.Double,
3156
+ IsIndexed: true,
3157
+ IsImportant: false
3158
+ },
3159
+ {
3160
+ Key: "longitude",
3161
+ Name: "Longitude",
3162
+ Type: EntityAttribute.EType.Double,
3163
+ IsIndexed: true,
3164
+ IsImportant: false
3165
+ },
3166
+ {
3167
+ Key: "altitude",
3168
+ Name: "Altitude",
3169
+ Type: EntityAttribute.EType.Double,
3170
+ IsIndexed: true,
3171
+ IsImportant: false
3172
+ }
3173
+ ]
3174
+ });
3175
+ }
3176
+ if (!bruce.Structure.find(x => x.Key == "Boundaries")) {
3177
+ bruce.Structure.push({
3178
+ Key: "Boundaries",
3179
+ Name: "Boundaries",
3180
+ Description: "Boundaries data.",
3181
+ Type: EntityAttribute.EType.Structure,
3182
+ Structure: [
3183
+ {
3184
+ Key: "minLongitude",
3185
+ Name: "Min Longitude",
3186
+ Type: EntityAttribute.EType.Double,
3187
+ IsIndexed: true,
3188
+ IsImportant: false
3189
+ },
3190
+ {
3191
+ Key: "maxLongitude",
3192
+ Name: "Max Longitude",
3193
+ Type: EntityAttribute.EType.Double,
3194
+ IsIndexed: true,
3195
+ IsImportant: false
3196
+ },
3197
+ {
3198
+ Key: "minLatitude",
3199
+ Name: "Min Latitude",
3200
+ Type: EntityAttribute.EType.Double,
3201
+ IsIndexed: true,
3202
+ IsImportant: false
3203
+ },
3204
+ {
3205
+ Key: "maxLatitude",
3206
+ Name: "Max Latitude",
3207
+ Type: EntityAttribute.EType.Double,
3208
+ IsIndexed: true,
3209
+ IsImportant: false
3210
+ },
3211
+ {
3212
+ Key: "minAltitude",
3213
+ Name: "Min Altitude",
3214
+ Type: EntityAttribute.EType.Double,
3215
+ IsIndexed: true,
3216
+ IsImportant: false
3217
+ },
3218
+ {
3219
+ Key: "maxAltitude",
3220
+ Name: "Max Altitude",
3221
+ Type: EntityAttribute.EType.Double,
3222
+ IsIndexed: true,
3223
+ IsImportant: false
3224
+ }
3225
+ ]
3226
+ });
3227
+ }
3228
+ if (!bruce.Structure.find(x => x.Key == "Transform")) {
3229
+ bruce.Structure.push({
3230
+ Key: "Transform",
3231
+ Name: "Transform",
3232
+ Description: "Transform data.",
3233
+ IsIndexed: true,
3234
+ IsImportant: false,
3235
+ Type: EntityAttribute.EType.Structure,
3236
+ Structure: [
3237
+ {
3238
+ Key: "heading",
3239
+ Name: "Heading",
3240
+ IsIndexed: true,
3241
+ IsImportant: false,
3242
+ Type: EntityAttribute.EType.Double
3243
+ },
3244
+ {
3245
+ Key: "pitch",
3246
+ Name: "Pitch",
3247
+ IsIndexed: true,
3248
+ IsImportant: false,
3249
+ Type: EntityAttribute.EType.Double
3250
+ },
3251
+ {
3252
+ Key: "roll",
3253
+ Name: "Roll",
3254
+ IsIndexed: true,
3255
+ IsImportant: false,
3256
+ Type: EntityAttribute.EType.Double
3257
+ },
3258
+ {
3259
+ Key: "scale",
3260
+ Name: "Scale",
3261
+ IsIndexed: true,
3262
+ IsImportant: false,
3263
+ Type: EntityAttribute.EType.Double
3264
+ }
3265
+ ]
3266
+ });
3267
+ }
3268
+ if (!bruce.Structure.find(x => x.Key == "VectorGeometry")) {
3269
+ bruce.Structure.push({
3270
+ Key: "VectorGeometry",
3271
+ Name: "Geometry",
3272
+ Description: "Geometry data.",
3273
+ Type: EntityAttribute.EType.Geometry,
3274
+ IsIndexed: true,
3275
+ IsImportant: false
3276
+ });
3277
+ }
3278
+ // Filter out migrated/outdated ones.
3279
+ // Removed from root and the internal structure.
3280
+ const OUTDATED_INTERNAL = ["position", "geometry", "location", "boundaries", "transform"];
3281
+ bruce.Structure = bruce.Structure.filter(a => !OUTDATED_INTERNAL.includes(a.Key));
3282
+ type.DataSchema.Structure = type.DataSchema.Structure.filter(a => !OUTDATED_INTERNAL.includes(a.Key));
3283
+ }
2998
3284
 
2999
3285
  /**
3000
3286
  * Utility to help with parsing and wrapping Nextspace paths.
@@ -7305,115 +7591,6 @@ var EntityTypeVisualSettings;
7305
7591
  })(EAction = EntityTypeVisualSettings.EAction || (EntityTypeVisualSettings.EAction = {}));
7306
7592
  })(EntityTypeVisualSettings || (EntityTypeVisualSettings = {}));
7307
7593
 
7308
- /**
7309
- * Describes an entity type schema attribute.
7310
- */
7311
- var EntityAttribute;
7312
- (function (EntityAttribute) {
7313
- let EType;
7314
- (function (EType) {
7315
- // Arbitrary text attribute.
7316
- EType["String"] = "String";
7317
- // Floating point number attribute.
7318
- EType["Double"] = "Double";
7319
- // Whole number attribute.
7320
- EType["Integer"] = "Integer";
7321
- // iso8601 date time string.
7322
- EType["Datetime"] = "Datetime";
7323
- // Group of attributes.
7324
- EType["Structure"] = "Structure";
7325
- // Nextspace vector geometry.
7326
- EType["Geometry"] = "Geometry";
7327
- // True/false attribute.
7328
- EType["Boolean"] = "Boolean";
7329
- })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
7330
- /**
7331
- * Returns an attribute from a provided hierarchy of attributes.
7332
- * Eg: Use the path: ["Bruce", "ID"] to find the "ID" attribute.
7333
- * @param items
7334
- * @param path
7335
- * @returns
7336
- */
7337
- function GetAttribute(items, path) {
7338
- if (!items || !path || !path.length) {
7339
- return null;
7340
- }
7341
- const key = path[0];
7342
- const item = items.find((i) => i.Key === key);
7343
- if (!item || !item.Structure || !path.length) {
7344
- return item;
7345
- }
7346
- return GetAttribute(item.Structure, path.slice(1));
7347
- }
7348
- EntityAttribute.GetAttribute = GetAttribute;
7349
- /**
7350
- * Removes an attribute from a provided hierarchy of attributes.
7351
- * Eg: Use the path: ["Bruce", "ID"] to remove the "ID" attribute.
7352
- * This will mutate the items array.
7353
- * @param items
7354
- * @param path
7355
- */
7356
- function RemoveAttribute(items, path) {
7357
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7358
- return;
7359
- }
7360
- const key = path[0];
7361
- if (path.length === 1) {
7362
- // If we're at the last key in the path, remove the item from the items array.
7363
- const index = items.findIndex((i) => i.Key === key);
7364
- if (index !== -1) {
7365
- items.splice(index, 1);
7366
- }
7367
- return;
7368
- }
7369
- // If we're not at the end of the path, dig further.
7370
- const item = items.find((i) => i.Key === key);
7371
- if (item && item.Structure) {
7372
- RemoveAttribute(item.Structure, path.slice(1));
7373
- }
7374
- }
7375
- EntityAttribute.RemoveAttribute = RemoveAttribute;
7376
- /**
7377
- * Adds an attribute to a provided hierarchy of attributes.
7378
- * Eg: Use the path: ["Bruce", "ID"] to add the "ID" attribute.
7379
- * This will mutate the items array.
7380
- * This requires the path to be valid and for a parent attribute to exist.
7381
- * @param items
7382
- * @param path
7383
- * @param attribute
7384
- */
7385
- function AddAttribute(items, path, attribute) {
7386
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7387
- return;
7388
- }
7389
- const key = path[0];
7390
- if (path.length === 1) {
7391
- // If we're at the last key in the path, add the attribute to the items array.
7392
- const index = items.findIndex((i) => i.Key === key);
7393
- if (index !== -1) {
7394
- // Overwrite existing attribute if it already exists.
7395
- items[index] = attribute;
7396
- }
7397
- else {
7398
- // Add new attribute if it doesn't exist.
7399
- items.push(attribute);
7400
- }
7401
- return;
7402
- }
7403
- // If we're not at the end of the path, dig further.
7404
- let item = items.find((i) => i.Key === key);
7405
- if (!item) {
7406
- item = { Key: key, Structure: [] };
7407
- items.push(item);
7408
- }
7409
- if (!item.Structure) {
7410
- item.Structure = [];
7411
- }
7412
- AddAttribute(item.Structure, path.slice(1), attribute);
7413
- }
7414
- EntityAttribute.AddAttribute = AddAttribute;
7415
- })(EntityAttribute || (EntityAttribute = {}));
7416
-
7417
7594
  /**
7418
7595
  * Describes the "Style" concept within Nextspace.
7419
7596
  * A legacy way of referring to styles is "entity display settings".
@@ -8170,7 +8347,14 @@ var ClientFile;
8170
8347
  if (!api) {
8171
8348
  api = ENVIRONMENT.Api().GetBruceApi();
8172
8349
  }
8173
- const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
8350
+ let ext = file.FileExt;
8351
+ if (!ext && file.OriginalFileName && file.OriginalFileName.includes(".")) {
8352
+ ext = file.OriginalFileName.split(".").pop();
8353
+ }
8354
+ if (ext && !ext.startsWith(".")) {
8355
+ ext = "." + ext;
8356
+ }
8357
+ const urlSuffix = ext ? `file/${file.ID}${ext}` : `file/${file.ID}`;
8174
8358
  const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
8175
8359
  if (cdnUrl) {
8176
8360
  return cdnUrl;
@@ -13345,7 +13529,7 @@ var DataSource;
13345
13529
  })(DataSource || (DataSource = {}));
13346
13530
 
13347
13531
  // This is updated with the package.json version on build.
13348
- const VERSION = "4.3.8";
13532
+ const VERSION = "4.4.0";
13349
13533
 
13350
13534
  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, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
13351
13535
  //# sourceMappingURL=bruce-models.es5.js.map