bruce-models 1.9.2 → 1.9.4

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.
@@ -1166,6 +1166,15 @@
1166
1166
  })).regions[0];
1167
1167
  if (region === null || region === void 0 ? void 0 : region.CDN) {
1168
1168
  this.EntityCdnUrl = (_b = region.CDN.entityURL) === null || _b === void 0 ? void 0 : _b[env];
1169
+ // We need to fix our configs.
1170
+ if (this.EntityCdnUrl) {
1171
+ if (this.EntityCdnUrl.includes("entitiesListForCDN")) {
1172
+ this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", this.accountId);
1173
+ }
1174
+ else {
1175
+ this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", "entitiesListForCDN/" + this.accountId);
1176
+ }
1177
+ }
1169
1178
  this.LegacyTilesetCdnUrl = (_c = region.CDN.legacyTilesetURL) === null || _c === void 0 ? void 0 : _c[env];
1170
1179
  }
1171
1180
  }
@@ -2022,18 +2031,24 @@
2022
2031
  * Needs to become ["Test", "Test1"].
2023
2032
  * We need to cull this in admin-ui.
2024
2033
  * @param path
2025
- * @returns
2034
+ * @returns Possible paths this legacy one could mean.
2026
2035
  */
2027
2036
  function parseLegacyPath(path) {
2028
2037
  if (!path) {
2029
2038
  return [];
2030
2039
  }
2040
+ const paths = [];
2031
2041
  if (path.startsWith("${") && path.endsWith("}")) {
2032
2042
  path = path.replace("${", "");
2033
2043
  path = path.replace("}", "");
2034
- return exports.PathUtils.ParseLegacy(path);
2035
- }
2036
- return exports.PathUtils.Parse(path);
2044
+ // Split by dots.
2045
+ paths.push(exports.PathUtils.ParseLegacy(path));
2046
+ // Take string as is.
2047
+ paths.push([path]);
2048
+ }
2049
+ // Split by backslashes.
2050
+ paths.push(exports.PathUtils.Parse(path));
2051
+ return paths;
2037
2052
  }
2038
2053
  (function (Calculator) {
2039
2054
  let EValueType;
@@ -2225,43 +2240,46 @@
2225
2240
  }
2226
2241
  Calculator.GetString = GetString;
2227
2242
  function GetMappingValue(value, entity) {
2228
- const attrPath = parseLegacyPath(value.field);
2229
- let eValue = exports.Entity.GetValue({
2230
- entity: entity,
2231
- path: attrPath
2232
- });
2233
- const isValueNum = !isNaN(+eValue);
2234
- for (let i = 0; i < value.values.length; i++) {
2235
- const option = value.values[i];
2236
- const mapValue = option.fieldValue;
2237
- const isMapValueNum = !isNaN(+mapValue);
2238
- if (isValueNum && isMapValueNum) {
2239
- if (+mapValue == +eValue) {
2240
- return option.appliedValue;
2241
- }
2242
- const mapSplit = mapValue.split("-");
2243
- if (mapSplit.length == 2) {
2244
- const min = mapSplit[0];
2245
- const max = mapSplit[1];
2246
- if (min != "") {
2247
- if (+eValue < +min) {
2248
- continue;
2249
- }
2243
+ const attrPaths = parseLegacyPath(value.field);
2244
+ for (let i = 0; i < attrPaths.length; i++) {
2245
+ const attrPath = attrPaths[i];
2246
+ let eValue = exports.Entity.GetValue({
2247
+ entity: entity,
2248
+ path: attrPath
2249
+ });
2250
+ const isValueNum = !isNaN(+eValue);
2251
+ for (let i = 0; i < value.values.length; i++) {
2252
+ const option = value.values[i];
2253
+ const mapValue = option.fieldValue;
2254
+ const isMapValueNum = !isNaN(+mapValue);
2255
+ if (isValueNum && isMapValueNum) {
2256
+ if (+mapValue == +eValue) {
2257
+ return option.appliedValue;
2250
2258
  }
2251
- if (max != "") {
2252
- if (+eValue > +max) {
2259
+ const mapSplit = mapValue.split("-");
2260
+ if (mapSplit.length == 2) {
2261
+ const min = mapSplit[0];
2262
+ const max = mapSplit[1];
2263
+ if (min != "") {
2264
+ if (+eValue < +min) {
2265
+ continue;
2266
+ }
2267
+ }
2268
+ if (max != "") {
2269
+ if (+eValue > +max) {
2270
+ continue;
2271
+ }
2272
+ }
2273
+ if (min == "" && max == "") {
2253
2274
  continue;
2254
2275
  }
2276
+ return option.appliedValue;
2255
2277
  }
2256
- if (min == "" && max == "") {
2257
- continue;
2258
- }
2259
- return option.appliedValue;
2260
2278
  }
2261
- }
2262
- else {
2263
- if (mapValue == eValue) {
2264
- return option.appliedValue;
2279
+ else {
2280
+ if (mapValue == eValue) {
2281
+ return option.appliedValue;
2282
+ }
2265
2283
  }
2266
2284
  }
2267
2285
  }
@@ -2269,31 +2287,34 @@
2269
2287
  }
2270
2288
  Calculator.GetMappingValue = GetMappingValue;
2271
2289
  function GetGradientValue(value, entity) {
2272
- const attrPath = parseLegacyPath(value.field);
2273
- let eValue = exports.Entity.GetValue({
2274
- entity: entity,
2275
- path: attrPath
2276
- });
2277
- eValue = Math.min(Math.max(eValue, value.min), value.max);
2278
- if (eValue < value.points[0].position) {
2279
- return exports.Color.ColorFromStr(value.points[0].color);
2280
- }
2281
- for (let i = 0; i < value.points.length - 1; i++) {
2282
- const pointA = value.points[i];
2283
- const pointB = value.points[i + 1];
2284
- if (eValue >= pointA.position && eValue <= pointB.position) {
2285
- if (pointA.position == pointB.position) {
2286
- return exports.Color.ColorFromStr(pointA.color);
2287
- }
2288
- const distance = (eValue - pointA.position) / (pointB.position - pointA.position);
2289
- const colorA = exports.Color.ColorFromStr(pointA.color);
2290
- const colorB = exports.Color.ColorFromStr(pointB.color);
2291
- return {
2292
- red: colorA.red + (colorB.red - colorA.red) * distance,
2293
- green: colorA.green + (colorB.green - colorA.green) * distance,
2294
- blue: colorA.blue + (colorB.blue - colorA.blue) * distance,
2295
- alpha: colorA.alpha + (colorB.alpha - colorA.alpha) * distance
2296
- };
2290
+ const attrPaths = parseLegacyPath(value.field);
2291
+ for (let i = 0; i < attrPaths.length; i++) {
2292
+ const attrPath = attrPaths[i];
2293
+ let eValue = exports.Entity.GetValue({
2294
+ entity: entity,
2295
+ path: attrPath
2296
+ });
2297
+ eValue = Math.min(Math.max(eValue, value.min), value.max);
2298
+ if (eValue < value.points[0].position) {
2299
+ return exports.Color.ColorFromStr(value.points[0].color);
2300
+ }
2301
+ for (let i = 0; i < value.points.length - 1; i++) {
2302
+ const pointA = value.points[i];
2303
+ const pointB = value.points[i + 1];
2304
+ if (eValue >= pointA.position && eValue <= pointB.position) {
2305
+ if (pointA.position == pointB.position) {
2306
+ return exports.Color.ColorFromStr(pointA.color);
2307
+ }
2308
+ const distance = (eValue - pointA.position) / (pointB.position - pointA.position);
2309
+ const colorA = exports.Color.ColorFromStr(pointA.color);
2310
+ const colorB = exports.Color.ColorFromStr(pointB.color);
2311
+ return {
2312
+ red: colorA.red + (colorB.red - colorA.red) * distance,
2313
+ green: colorA.green + (colorB.green - colorA.green) * distance,
2314
+ blue: colorA.blue + (colorB.blue - colorA.blue) * distance,
2315
+ alpha: colorA.alpha + (colorB.alpha - colorA.alpha) * distance
2316
+ };
2317
+ }
2297
2318
  }
2298
2319
  }
2299
2320
  return exports.Color.ColorFromStr(value.points[value.points.length - 1].color);