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.
@@ -1334,18 +1334,20 @@
1334
1334
  this.loadCancelled = false;
1335
1335
  // Indicates if loading the regional configuration was already called.
1336
1336
  this.configLoadAttempted = false;
1337
- let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket } = params;
1337
+ let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
1338
1338
  this.accountId = accountId;
1339
1339
  this.env = env !== null && env !== void 0 ? env : exports.Api.EEnv.PROD;
1340
- // Backwards compatibility.
1341
- if (loadRegionalBaseUrl) {
1342
- loadConfig = true;
1343
- }
1344
- if (loadConfig) {
1345
- // Mark it as attempted right away because we don't want any external calls while it gets to that async point.
1346
- this.configLoadAttempted = true;
1340
+ if (!dummy) {
1341
+ // Backwards compatibility.
1342
+ if (loadRegionalBaseUrl) {
1343
+ loadConfig = true;
1344
+ }
1345
+ if (loadConfig) {
1346
+ // Mark it as attempted right away because we don't want any external calls while it gets to that async point.
1347
+ this.configLoadAttempted = true;
1348
+ }
1349
+ this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
1347
1350
  }
1348
- this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
1349
1351
  }
1350
1352
  /**
1351
1353
  * Loads regional base url and sets up message broker.
@@ -2736,6 +2738,114 @@
2736
2738
  ObjectUtils.UId = UId;
2737
2739
  })(exports.ObjectUtils || (exports.ObjectUtils = {}));
2738
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
+
2739
2849
  (function (EntityType) {
2740
2850
  /**
2741
2851
  * Gets an entity type record.
@@ -2759,6 +2869,7 @@
2759
2869
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
2760
2870
  try {
2761
2871
  const data = yield api.GET(`entitytype/${typeId}`, exports.Api.PrepReqParams(reqParams));
2872
+ appendInternalAttrSchema(data);
2762
2873
  res({
2763
2874
  entityType: data
2764
2875
  });
@@ -2822,6 +2933,9 @@
2822
2933
  }
2823
2934
  }
2824
2935
  const data = yield api.GET("entitytypes?" + urlParams.toString(), exports.Api.PrepReqParams(reqParams));
2936
+ for (const item of data.Items) {
2937
+ appendInternalAttrSchema(item);
2938
+ }
2825
2939
  res({
2826
2940
  entityTypes: data.Items
2827
2941
  });
@@ -2862,6 +2976,7 @@
2862
2976
  if (!data.Name) {
2863
2977
  data.Name = data.ID;
2864
2978
  }
2979
+ appendInternalAttrSchema(data);
2865
2980
  const res = yield api.POST(`entitytype/${data.ID}`, data, exports.Api.PrepReqParams(reqParams));
2866
2981
  api.Cache.Remove(GetCacheKey(data.ID));
2867
2982
  api.Cache.RemoveByStartsWith(GetListCacheKey());
@@ -2950,6 +3065,176 @@
2950
3065
  }
2951
3066
  EntityType.GetListCacheKey = GetListCacheKey;
2952
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
+ }
2953
3238
 
2954
3239
  /**
2955
3240
  * Utility to help with parsing and wrapping Nextspace paths.
@@ -7168,114 +7453,6 @@
7168
7453
  })(EAction = EntityTypeVisualSettings.EAction || (EntityTypeVisualSettings.EAction = {}));
7169
7454
  })(exports.EntityTypeVisualSettings || (exports.EntityTypeVisualSettings = {}));
7170
7455
 
7171
- /**
7172
- * Describes an entity type schema attribute.
7173
- */
7174
- (function (EntityAttribute) {
7175
- let EType;
7176
- (function (EType) {
7177
- // Arbitrary text attribute.
7178
- EType["String"] = "String";
7179
- // Floating point number attribute.
7180
- EType["Double"] = "Double";
7181
- // Whole number attribute.
7182
- EType["Integer"] = "Integer";
7183
- // iso8601 date time string.
7184
- EType["Datetime"] = "Datetime";
7185
- // Group of attributes.
7186
- EType["Structure"] = "Structure";
7187
- // Nextspace vector geometry.
7188
- EType["Geometry"] = "Geometry";
7189
- // True/false attribute.
7190
- EType["Boolean"] = "Boolean";
7191
- })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
7192
- /**
7193
- * Returns an attribute from a provided hierarchy of attributes.
7194
- * Eg: Use the path: ["Bruce", "ID"] to find the "ID" attribute.
7195
- * @param items
7196
- * @param path
7197
- * @returns
7198
- */
7199
- function GetAttribute(items, path) {
7200
- if (!items || !path || !path.length) {
7201
- return null;
7202
- }
7203
- const key = path[0];
7204
- const item = items.find((i) => i.Key === key);
7205
- if (!item || !item.Structure || !path.length) {
7206
- return item;
7207
- }
7208
- return GetAttribute(item.Structure, path.slice(1));
7209
- }
7210
- EntityAttribute.GetAttribute = GetAttribute;
7211
- /**
7212
- * Removes an attribute from a provided hierarchy of attributes.
7213
- * Eg: Use the path: ["Bruce", "ID"] to remove the "ID" attribute.
7214
- * This will mutate the items array.
7215
- * @param items
7216
- * @param path
7217
- */
7218
- function RemoveAttribute(items, path) {
7219
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7220
- return;
7221
- }
7222
- const key = path[0];
7223
- if (path.length === 1) {
7224
- // If we're at the last key in the path, remove the item from the items array.
7225
- const index = items.findIndex((i) => i.Key === key);
7226
- if (index !== -1) {
7227
- items.splice(index, 1);
7228
- }
7229
- return;
7230
- }
7231
- // If we're not at the end of the path, dig further.
7232
- const item = items.find((i) => i.Key === key);
7233
- if (item && item.Structure) {
7234
- RemoveAttribute(item.Structure, path.slice(1));
7235
- }
7236
- }
7237
- EntityAttribute.RemoveAttribute = RemoveAttribute;
7238
- /**
7239
- * Adds an attribute to a provided hierarchy of attributes.
7240
- * Eg: Use the path: ["Bruce", "ID"] to add the "ID" attribute.
7241
- * This will mutate the items array.
7242
- * This requires the path to be valid and for a parent attribute to exist.
7243
- * @param items
7244
- * @param path
7245
- * @param attribute
7246
- */
7247
- function AddAttribute(items, path, attribute) {
7248
- if (!items || !(path === null || path === void 0 ? void 0 : path.length)) {
7249
- return;
7250
- }
7251
- const key = path[0];
7252
- if (path.length === 1) {
7253
- // If we're at the last key in the path, add the attribute to the items array.
7254
- const index = items.findIndex((i) => i.Key === key);
7255
- if (index !== -1) {
7256
- // Overwrite existing attribute if it already exists.
7257
- items[index] = attribute;
7258
- }
7259
- else {
7260
- // Add new attribute if it doesn't exist.
7261
- items.push(attribute);
7262
- }
7263
- return;
7264
- }
7265
- // If we're not at the end of the path, dig further.
7266
- let item = items.find((i) => i.Key === key);
7267
- if (!item) {
7268
- item = { Key: key, Structure: [] };
7269
- items.push(item);
7270
- }
7271
- if (!item.Structure) {
7272
- item.Structure = [];
7273
- }
7274
- AddAttribute(item.Structure, path.slice(1), attribute);
7275
- }
7276
- EntityAttribute.AddAttribute = AddAttribute;
7277
- })(exports.EntityAttribute || (exports.EntityAttribute = {}));
7278
-
7279
7456
  (function (Style) {
7280
7457
  /**
7281
7458
  * Types of styles available.
@@ -8009,7 +8186,14 @@
8009
8186
  if (!api) {
8010
8187
  api = exports.ENVIRONMENT.Api().GetBruceApi();
8011
8188
  }
8012
- const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
8189
+ let ext = file.FileExt;
8190
+ if (!ext && file.OriginalFileName && file.OriginalFileName.includes(".")) {
8191
+ ext = file.OriginalFileName.split(".").pop();
8192
+ }
8193
+ if (ext && !ext.startsWith(".")) {
8194
+ ext = "." + ext;
8195
+ }
8196
+ const urlSuffix = ext ? `file/${file.ID}${ext}` : `file/${file.ID}`;
8013
8197
  const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
8014
8198
  if (cdnUrl) {
8015
8199
  return cdnUrl;
@@ -13079,7 +13263,7 @@
13079
13263
  })(exports.DataSource || (exports.DataSource = {}));
13080
13264
 
13081
13265
  // This is updated with the package.json version on build.
13082
- const VERSION = "4.3.8";
13266
+ const VERSION = "4.4.0";
13083
13267
 
13084
13268
  exports.VERSION = VERSION;
13085
13269
  exports.AbstractApi = AbstractApi;