bruce-models 4.3.9 → 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.
@@ -2777,6 +2777,115 @@ var ObjectUtils;
2777
2777
  ObjectUtils.UId = UId;
2778
2778
  })(ObjectUtils || (ObjectUtils = {}));
2779
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
+
2780
2889
  /**
2781
2890
  * Describes the "Entity Type" concept within Nextspace.
2782
2891
  * An entity type is an "expectation" of what data "should" look like in a particular entity record.
@@ -2806,6 +2915,7 @@ var EntityType;
2806
2915
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
2807
2916
  try {
2808
2917
  const data = yield api.GET(`entitytype/${typeId}`, Api.PrepReqParams(reqParams));
2918
+ appendInternalAttrSchema(data);
2809
2919
  res({
2810
2920
  entityType: data
2811
2921
  });
@@ -2869,6 +2979,9 @@ var EntityType;
2869
2979
  }
2870
2980
  }
2871
2981
  const data = yield api.GET("entitytypes?" + urlParams.toString(), Api.PrepReqParams(reqParams));
2982
+ for (const item of data.Items) {
2983
+ appendInternalAttrSchema(item);
2984
+ }
2872
2985
  res({
2873
2986
  entityTypes: data.Items
2874
2987
  });
@@ -2909,6 +3022,7 @@ var EntityType;
2909
3022
  if (!data.Name) {
2910
3023
  data.Name = data.ID;
2911
3024
  }
3025
+ appendInternalAttrSchema(data);
2912
3026
  const res = yield api.POST(`entitytype/${data.ID}`, data, Api.PrepReqParams(reqParams));
2913
3027
  api.Cache.Remove(GetCacheKey(data.ID));
2914
3028
  api.Cache.RemoveByStartsWith(GetListCacheKey());
@@ -2997,6 +3111,176 @@ var EntityType;
2997
3111
  }
2998
3112
  EntityType.GetListCacheKey = GetListCacheKey;
2999
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
+ }
3000
3284
 
3001
3285
  /**
3002
3286
  * Utility to help with parsing and wrapping Nextspace paths.
@@ -7307,115 +7591,6 @@ var EntityTypeVisualSettings;
7307
7591
  })(EAction = EntityTypeVisualSettings.EAction || (EntityTypeVisualSettings.EAction = {}));
7308
7592
  })(EntityTypeVisualSettings || (EntityTypeVisualSettings = {}));
7309
7593
 
7310
- /**
7311
- * Describes an entity type schema attribute.
7312
- */
7313
- var EntityAttribute;
7314
- (function (EntityAttribute) {
7315
- let EType;
7316
- (function (EType) {
7317
- // Arbitrary text attribute.
7318
- EType["String"] = "String";
7319
- // Floating point number attribute.
7320
- EType["Double"] = "Double";
7321
- // Whole number attribute.
7322
- EType["Integer"] = "Integer";
7323
- // iso8601 date time string.
7324
- EType["Datetime"] = "Datetime";
7325
- // Group of attributes.
7326
- EType["Structure"] = "Structure";
7327
- // Nextspace vector geometry.
7328
- EType["Geometry"] = "Geometry";
7329
- // True/false attribute.
7330
- EType["Boolean"] = "Boolean";
7331
- })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
7332
- /**
7333
- * Returns an attribute from a provided hierarchy of attributes.
7334
- * Eg: Use the path: ["Bruce", "ID"] to find the "ID" attribute.
7335
- * @param items
7336
- * @param path
7337
- * @returns
7338
- */
7339
- function GetAttribute(items, path) {
7340
- if (!items || !path || !path.length) {
7341
- return null;
7342
- }
7343
- const key = path[0];
7344
- const item = items.find((i) => i.Key === key);
7345
- if (!item || !item.Structure || !path.length) {
7346
- return item;
7347
- }
7348
- return GetAttribute(item.Structure, path.slice(1));
7349
- }
7350
- EntityAttribute.GetAttribute = GetAttribute;
7351
- /**
7352
- * Removes an attribute from a provided hierarchy of attributes.
7353
- * Eg: Use the path: ["Bruce", "ID"] to remove the "ID" attribute.
7354
- * This will mutate the items array.
7355
- * @param items
7356
- * @param path
7357
- */
7358
- function RemoveAttribute(items, path) {
7359
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7360
- return;
7361
- }
7362
- const key = path[0];
7363
- if (path.length === 1) {
7364
- // If we're at the last key in the path, remove the item from the items array.
7365
- const index = items.findIndex((i) => i.Key === key);
7366
- if (index !== -1) {
7367
- items.splice(index, 1);
7368
- }
7369
- return;
7370
- }
7371
- // If we're not at the end of the path, dig further.
7372
- const item = items.find((i) => i.Key === key);
7373
- if (item && item.Structure) {
7374
- RemoveAttribute(item.Structure, path.slice(1));
7375
- }
7376
- }
7377
- EntityAttribute.RemoveAttribute = RemoveAttribute;
7378
- /**
7379
- * Adds an attribute to a provided hierarchy of attributes.
7380
- * Eg: Use the path: ["Bruce", "ID"] to add the "ID" attribute.
7381
- * This will mutate the items array.
7382
- * This requires the path to be valid and for a parent attribute to exist.
7383
- * @param items
7384
- * @param path
7385
- * @param attribute
7386
- */
7387
- function AddAttribute(items, path, attribute) {
7388
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7389
- return;
7390
- }
7391
- const key = path[0];
7392
- if (path.length === 1) {
7393
- // If we're at the last key in the path, add the attribute to the items array.
7394
- const index = items.findIndex((i) => i.Key === key);
7395
- if (index !== -1) {
7396
- // Overwrite existing attribute if it already exists.
7397
- items[index] = attribute;
7398
- }
7399
- else {
7400
- // Add new attribute if it doesn't exist.
7401
- items.push(attribute);
7402
- }
7403
- return;
7404
- }
7405
- // If we're not at the end of the path, dig further.
7406
- let item = items.find((i) => i.Key === key);
7407
- if (!item) {
7408
- item = { Key: key, Structure: [] };
7409
- items.push(item);
7410
- }
7411
- if (!item.Structure) {
7412
- item.Structure = [];
7413
- }
7414
- AddAttribute(item.Structure, path.slice(1), attribute);
7415
- }
7416
- EntityAttribute.AddAttribute = AddAttribute;
7417
- })(EntityAttribute || (EntityAttribute = {}));
7418
-
7419
7594
  /**
7420
7595
  * Describes the "Style" concept within Nextspace.
7421
7596
  * A legacy way of referring to styles is "entity display settings".
@@ -13354,7 +13529,7 @@ var DataSource;
13354
13529
  })(DataSource || (DataSource = {}));
13355
13530
 
13356
13531
  // This is updated with the package.json version on build.
13357
- const VERSION = "4.3.9";
13532
+ const VERSION = "4.4.0";
13358
13533
 
13359
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 };
13360
13535
  //# sourceMappingURL=bruce-models.es5.js.map