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.
@@ -2738,6 +2738,114 @@
2738
2738
  ObjectUtils.UId = UId;
2739
2739
  })(exports.ObjectUtils || (exports.ObjectUtils = {}));
2740
2740
 
2741
+ /**
2742
+ * Describes an entity type schema attribute.
2743
+ */
2744
+ (function (EntityAttribute) {
2745
+ let EType;
2746
+ (function (EType) {
2747
+ // Arbitrary text attribute.
2748
+ EType["String"] = "String";
2749
+ // Floating point number attribute.
2750
+ EType["Double"] = "Double";
2751
+ // Whole number attribute.
2752
+ EType["Integer"] = "Integer";
2753
+ // iso8601 date time string.
2754
+ EType["Datetime"] = "Datetime";
2755
+ // Group of attributes.
2756
+ EType["Structure"] = "Structure";
2757
+ // Nextspace vector geometry.
2758
+ EType["Geometry"] = "Geometry";
2759
+ // True/false attribute.
2760
+ EType["Boolean"] = "Boolean";
2761
+ })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
2762
+ /**
2763
+ * Returns an attribute from a provided hierarchy of attributes.
2764
+ * Eg: Use the path: ["Bruce", "ID"] to find the "ID" attribute.
2765
+ * @param items
2766
+ * @param path
2767
+ * @returns
2768
+ */
2769
+ function GetAttribute(items, path) {
2770
+ if (!items || !path || !path.length) {
2771
+ return null;
2772
+ }
2773
+ const key = path[0];
2774
+ const item = items.find((i) => i.Key === key);
2775
+ if (!item || !item.Structure || !path.length) {
2776
+ return item;
2777
+ }
2778
+ return GetAttribute(item.Structure, path.slice(1));
2779
+ }
2780
+ EntityAttribute.GetAttribute = GetAttribute;
2781
+ /**
2782
+ * Removes an attribute from a provided hierarchy of attributes.
2783
+ * Eg: Use the path: ["Bruce", "ID"] to remove the "ID" attribute.
2784
+ * This will mutate the items array.
2785
+ * @param items
2786
+ * @param path
2787
+ */
2788
+ function RemoveAttribute(items, path) {
2789
+ if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
2790
+ return;
2791
+ }
2792
+ const key = path[0];
2793
+ if (path.length === 1) {
2794
+ // If we're at the last key in the path, remove the item from the items array.
2795
+ const index = items.findIndex((i) => i.Key === key);
2796
+ if (index !== -1) {
2797
+ items.splice(index, 1);
2798
+ }
2799
+ return;
2800
+ }
2801
+ // If we're not at the end of the path, dig further.
2802
+ const item = items.find((i) => i.Key === key);
2803
+ if (item && item.Structure) {
2804
+ RemoveAttribute(item.Structure, path.slice(1));
2805
+ }
2806
+ }
2807
+ EntityAttribute.RemoveAttribute = RemoveAttribute;
2808
+ /**
2809
+ * Adds an attribute to a provided hierarchy of attributes.
2810
+ * Eg: Use the path: ["Bruce", "ID"] to add the "ID" attribute.
2811
+ * This will mutate the items array.
2812
+ * This requires the path to be valid and for a parent attribute to exist.
2813
+ * @param items
2814
+ * @param path
2815
+ * @param attribute
2816
+ */
2817
+ function AddAttribute(items, path, attribute) {
2818
+ if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
2819
+ return;
2820
+ }
2821
+ const key = path[0];
2822
+ if (path.length === 1) {
2823
+ // If we're at the last key in the path, add the attribute to the items array.
2824
+ const index = items.findIndex((i) => i.Key === key);
2825
+ if (index !== -1) {
2826
+ // Overwrite existing attribute if it already exists.
2827
+ items[index] = attribute;
2828
+ }
2829
+ else {
2830
+ // Add new attribute if it doesn't exist.
2831
+ items.push(attribute);
2832
+ }
2833
+ return;
2834
+ }
2835
+ // If we're not at the end of the path, dig further.
2836
+ let item = items.find((i) => i.Key === key);
2837
+ if (!item) {
2838
+ item = { Key: key, Structure: [] };
2839
+ items.push(item);
2840
+ }
2841
+ if (!item.Structure) {
2842
+ item.Structure = [];
2843
+ }
2844
+ AddAttribute(item.Structure, path.slice(1), attribute);
2845
+ }
2846
+ EntityAttribute.AddAttribute = AddAttribute;
2847
+ })(exports.EntityAttribute || (exports.EntityAttribute = {}));
2848
+
2741
2849
  (function (EntityType) {
2742
2850
  /**
2743
2851
  * Gets an entity type record.
@@ -2761,6 +2869,7 @@
2761
2869
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
2762
2870
  try {
2763
2871
  const data = yield api.GET(`entitytype/${typeId}`, exports.Api.PrepReqParams(reqParams));
2872
+ appendInternalAttrSchema(data);
2764
2873
  res({
2765
2874
  entityType: data
2766
2875
  });
@@ -2824,6 +2933,9 @@
2824
2933
  }
2825
2934
  }
2826
2935
  const data = yield api.GET("entitytypes?" + urlParams.toString(), exports.Api.PrepReqParams(reqParams));
2936
+ for (const item of data.Items) {
2937
+ appendInternalAttrSchema(item);
2938
+ }
2827
2939
  res({
2828
2940
  entityTypes: data.Items
2829
2941
  });
@@ -2864,6 +2976,7 @@
2864
2976
  if (!data.Name) {
2865
2977
  data.Name = data.ID;
2866
2978
  }
2979
+ appendInternalAttrSchema(data);
2867
2980
  const res = yield api.POST(`entitytype/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
2868
2981
  api.Cache.Remove(GetCacheKey(data.ID));
2869
2982
  api.Cache.RemoveByStartsWith(GetListCacheKey());
@@ -2952,6 +3065,176 @@
2952
3065
  }
2953
3066
  EntityType.GetListCacheKey = GetListCacheKey;
2954
3067
  })(exports.EntityType || (exports.EntityType = {}));
3068
+ /**
3069
+ * Adds expected internal structure items even if they aren't there.
3070
+ * Our API should be including them but this is a safety net.
3071
+ * @param type
3072
+ */
3073
+ function appendInternalAttrSchema(type) {
3074
+ // Schema not loaded. We'll ignore.
3075
+ if (type == null || type.DataSchema == null) {
3076
+ return;
3077
+ }
3078
+ // Append internal attributes.
3079
+ if (!type.DataSchema.Structure) {
3080
+ type.DataSchema.Structure = [];
3081
+ }
3082
+ let bruce = type.DataSchema.Structure.find(a => a.Key == "Bruce");
3083
+ if (!bruce) {
3084
+ bruce = {
3085
+ Key: "Bruce",
3086
+ Name: "Bruce",
3087
+ Description: "Nextspace internal attributes.",
3088
+ Type: exports.EntityAttribute.EType.Structure,
3089
+ Structure: [],
3090
+ IsIndexed: true,
3091
+ IsImportant: false
3092
+ };
3093
+ type.DataSchema.Structure.push(bruce);
3094
+ }
3095
+ if (!bruce.Structure) {
3096
+ bruce.Structure = [];
3097
+ }
3098
+ // Append any missing internal attributes.
3099
+ if (!bruce.Structure.find(x => x.Key == "Location")) {
3100
+ bruce.Structure.push({
3101
+ Key: "Location",
3102
+ Name: "Location",
3103
+ Description: "Location data.",
3104
+ Type: exports.EntityAttribute.EType.Structure,
3105
+ Structure: [
3106
+ {
3107
+ Key: "latitude",
3108
+ Name: "Latitude",
3109
+ Type: exports.EntityAttribute.EType.Double,
3110
+ IsIndexed: true,
3111
+ IsImportant: false
3112
+ },
3113
+ {
3114
+ Key: "longitude",
3115
+ Name: "Longitude",
3116
+ Type: exports.EntityAttribute.EType.Double,
3117
+ IsIndexed: true,
3118
+ IsImportant: false
3119
+ },
3120
+ {
3121
+ Key: "altitude",
3122
+ Name: "Altitude",
3123
+ Type: exports.EntityAttribute.EType.Double,
3124
+ IsIndexed: true,
3125
+ IsImportant: false
3126
+ }
3127
+ ]
3128
+ });
3129
+ }
3130
+ if (!bruce.Structure.find(x => x.Key == "Boundaries")) {
3131
+ bruce.Structure.push({
3132
+ Key: "Boundaries",
3133
+ Name: "Boundaries",
3134
+ Description: "Boundaries data.",
3135
+ Type: exports.EntityAttribute.EType.Structure,
3136
+ Structure: [
3137
+ {
3138
+ Key: "minLongitude",
3139
+ Name: "Min Longitude",
3140
+ Type: exports.EntityAttribute.EType.Double,
3141
+ IsIndexed: true,
3142
+ IsImportant: false
3143
+ },
3144
+ {
3145
+ Key: "maxLongitude",
3146
+ Name: "Max Longitude",
3147
+ Type: exports.EntityAttribute.EType.Double,
3148
+ IsIndexed: true,
3149
+ IsImportant: false
3150
+ },
3151
+ {
3152
+ Key: "minLatitude",
3153
+ Name: "Min Latitude",
3154
+ Type: exports.EntityAttribute.EType.Double,
3155
+ IsIndexed: true,
3156
+ IsImportant: false
3157
+ },
3158
+ {
3159
+ Key: "maxLatitude",
3160
+ Name: "Max Latitude",
3161
+ Type: exports.EntityAttribute.EType.Double,
3162
+ IsIndexed: true,
3163
+ IsImportant: false
3164
+ },
3165
+ {
3166
+ Key: "minAltitude",
3167
+ Name: "Min Altitude",
3168
+ Type: exports.EntityAttribute.EType.Double,
3169
+ IsIndexed: true,
3170
+ IsImportant: false
3171
+ },
3172
+ {
3173
+ Key: "maxAltitude",
3174
+ Name: "Max Altitude",
3175
+ Type: exports.EntityAttribute.EType.Double,
3176
+ IsIndexed: true,
3177
+ IsImportant: false
3178
+ }
3179
+ ]
3180
+ });
3181
+ }
3182
+ if (!bruce.Structure.find(x => x.Key == "Transform")) {
3183
+ bruce.Structure.push({
3184
+ Key: "Transform",
3185
+ Name: "Transform",
3186
+ Description: "Transform data.",
3187
+ IsIndexed: true,
3188
+ IsImportant: false,
3189
+ Type: exports.EntityAttribute.EType.Structure,
3190
+ Structure: [
3191
+ {
3192
+ Key: "heading",
3193
+ Name: "Heading",
3194
+ IsIndexed: true,
3195
+ IsImportant: false,
3196
+ Type: exports.EntityAttribute.EType.Double
3197
+ },
3198
+ {
3199
+ Key: "pitch",
3200
+ Name: "Pitch",
3201
+ IsIndexed: true,
3202
+ IsImportant: false,
3203
+ Type: exports.EntityAttribute.EType.Double
3204
+ },
3205
+ {
3206
+ Key: "roll",
3207
+ Name: "Roll",
3208
+ IsIndexed: true,
3209
+ IsImportant: false,
3210
+ Type: exports.EntityAttribute.EType.Double
3211
+ },
3212
+ {
3213
+ Key: "scale",
3214
+ Name: "Scale",
3215
+ IsIndexed: true,
3216
+ IsImportant: false,
3217
+ Type: exports.EntityAttribute.EType.Double
3218
+ }
3219
+ ]
3220
+ });
3221
+ }
3222
+ if (!bruce.Structure.find(x => x.Key == "VectorGeometry")) {
3223
+ bruce.Structure.push({
3224
+ Key: "VectorGeometry",
3225
+ Name: "Geometry",
3226
+ Description: "Geometry data.",
3227
+ Type: exports.EntityAttribute.EType.Geometry,
3228
+ IsIndexed: true,
3229
+ IsImportant: false
3230
+ });
3231
+ }
3232
+ // Filter out migrated/outdated ones.
3233
+ // Removed from root and the internal structure.
3234
+ const OUTDATED_INTERNAL = ["position", "geometry", "location", "boundaries", "transform"];
3235
+ bruce.Structure = bruce.Structure.filter(a => !OUTDATED_INTERNAL.includes(a.Key));
3236
+ type.DataSchema.Structure = type.DataSchema.Structure.filter(a => !OUTDATED_INTERNAL.includes(a.Key));
3237
+ }
2955
3238
 
2956
3239
  /**
2957
3240
  * Utility to help with parsing and wrapping Nextspace paths.
@@ -7170,114 +7453,6 @@
7170
7453
  })(EAction = EntityTypeVisualSettings.EAction || (EntityTypeVisualSettings.EAction = {}));
7171
7454
  })(exports.EntityTypeVisualSettings || (exports.EntityTypeVisualSettings = {}));
7172
7455
 
7173
- /**
7174
- * Describes an entity type schema attribute.
7175
- */
7176
- (function (EntityAttribute) {
7177
- let EType;
7178
- (function (EType) {
7179
- // Arbitrary text attribute.
7180
- EType["String"] = "String";
7181
- // Floating point number attribute.
7182
- EType["Double"] = "Double";
7183
- // Whole number attribute.
7184
- EType["Integer"] = "Integer";
7185
- // iso8601 date time string.
7186
- EType["Datetime"] = "Datetime";
7187
- // Group of attributes.
7188
- EType["Structure"] = "Structure";
7189
- // Nextspace vector geometry.
7190
- EType["Geometry"] = "Geometry";
7191
- // True/false attribute.
7192
- EType["Boolean"] = "Boolean";
7193
- })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
7194
- /**
7195
- * Returns an attribute from a provided hierarchy of attributes.
7196
- * Eg: Use the path: ["Bruce", "ID"] to find the "ID" attribute.
7197
- * @param items
7198
- * @param path
7199
- * @returns
7200
- */
7201
- function GetAttribute(items, path) {
7202
- if (!items || !path || !path.length) {
7203
- return null;
7204
- }
7205
- const key = path[0];
7206
- const item = items.find((i) => i.Key === key);
7207
- if (!item || !item.Structure || !path.length) {
7208
- return item;
7209
- }
7210
- return GetAttribute(item.Structure, path.slice(1));
7211
- }
7212
- EntityAttribute.GetAttribute = GetAttribute;
7213
- /**
7214
- * Removes an attribute from a provided hierarchy of attributes.
7215
- * Eg: Use the path: ["Bruce", "ID"] to remove the "ID" attribute.
7216
- * This will mutate the items array.
7217
- * @param items
7218
- * @param path
7219
- */
7220
- function RemoveAttribute(items, path) {
7221
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7222
- return;
7223
- }
7224
- const key = path[0];
7225
- if (path.length === 1) {
7226
- // If we're at the last key in the path, remove the item from the items array.
7227
- const index = items.findIndex((i) => i.Key === key);
7228
- if (index !== -1) {
7229
- items.splice(index, 1);
7230
- }
7231
- return;
7232
- }
7233
- // If we're not at the end of the path, dig further.
7234
- const item = items.find((i) => i.Key === key);
7235
- if (item && item.Structure) {
7236
- RemoveAttribute(item.Structure, path.slice(1));
7237
- }
7238
- }
7239
- EntityAttribute.RemoveAttribute = RemoveAttribute;
7240
- /**
7241
- * Adds an attribute to a provided hierarchy of attributes.
7242
- * Eg: Use the path: ["Bruce", "ID"] to add the "ID" attribute.
7243
- * This will mutate the items array.
7244
- * This requires the path to be valid and for a parent attribute to exist.
7245
- * @param items
7246
- * @param path
7247
- * @param attribute
7248
- */
7249
- function AddAttribute(items, path, attribute) {
7250
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7251
- return;
7252
- }
7253
- const key = path[0];
7254
- if (path.length === 1) {
7255
- // If we're at the last key in the path, add the attribute to the items array.
7256
- const index = items.findIndex((i) => i.Key === key);
7257
- if (index !== -1) {
7258
- // Overwrite existing attribute if it already exists.
7259
- items[index] = attribute;
7260
- }
7261
- else {
7262
- // Add new attribute if it doesn't exist.
7263
- items.push(attribute);
7264
- }
7265
- return;
7266
- }
7267
- // If we're not at the end of the path, dig further.
7268
- let item = items.find((i) => i.Key === key);
7269
- if (!item) {
7270
- item = { Key: key, Structure: [] };
7271
- items.push(item);
7272
- }
7273
- if (!item.Structure) {
7274
- item.Structure = [];
7275
- }
7276
- AddAttribute(item.Structure, path.slice(1), attribute);
7277
- }
7278
- EntityAttribute.AddAttribute = AddAttribute;
7279
- })(exports.EntityAttribute || (exports.EntityAttribute = {}));
7280
-
7281
7456
  (function (Style) {
7282
7457
  /**
7283
7458
  * Types of styles available.
@@ -13088,7 +13263,7 @@
13088
13263
  })(exports.DataSource || (exports.DataSource = {}));
13089
13264
 
13090
13265
  // This is updated with the package.json version on build.
13091
- const VERSION = "4.3.9";
13266
+ const VERSION = "4.4.0";
13092
13267
 
13093
13268
  exports.VERSION = VERSION;
13094
13269
  exports.AbstractApi = AbstractApi;