@sports-alliance/sports-lib 7.0.3 → 7.0.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.
@@ -1,7 +1,6 @@
1
1
  import { DataBare } from './data.bare';
2
- export declare abstract class DataArray extends DataBare {
3
- protected value: string[];
2
+ export declare abstract class DataArray extends DataBare<string[]> {
4
3
  constructor(value: string[]);
5
- getValue(): string[];
4
+ getValue(formatForDataType?: string): string[];
6
5
  isValueTypeValid(value: any): boolean;
7
6
  }
@@ -7,7 +7,7 @@ class DataArray extends data_bare_1.DataBare {
7
7
  super(value);
8
8
  this.value = value;
9
9
  }
10
- getValue() {
10
+ getValue(formatForDataType) {
11
11
  return this.value;
12
12
  }
13
13
  isValueTypeValid(value) {
@@ -1,4 +1,5 @@
1
1
  import { Data } from './data';
2
- export declare abstract class DataBare extends Data {
2
+ import { DataPositionInterface } from './data.position.interface';
3
+ export declare abstract class DataBare<T extends number | string | boolean | string[] | DataPositionInterface = number | string | boolean | string[] | DataPositionInterface> extends Data<T> {
3
4
  static unit: string;
4
5
  }
@@ -1,15 +1,15 @@
1
1
  import { DataInterface, UnitSystem } from './data.interface';
2
2
  import { DataJSONInterface } from './data.json.interface';
3
3
  import { DataPositionInterface } from './data.position.interface';
4
- export declare abstract class Data implements DataInterface {
4
+ export declare abstract class Data<T extends number | string | boolean | string[] | DataPositionInterface = number | string | boolean | string[] | DataPositionInterface> implements DataInterface {
5
5
  static type: string;
6
6
  static unit: string;
7
7
  static displayType?: string;
8
8
  static unitSystem: UnitSystem;
9
- protected value: number | string | boolean | string[] | DataPositionInterface;
10
- protected constructor(value: string | number | boolean | string[] | DataPositionInterface);
11
- setValue(value: string | number | boolean | string[] | DataPositionInterface): this;
12
- getValue(formatForDataType?: string): string | number | boolean | string[] | DataPositionInterface;
9
+ protected value: T;
10
+ protected constructor(value: T);
11
+ setValue(value: number | string | boolean | string[] | DataPositionInterface): this;
12
+ getValue(formatForDataType?: string): T;
13
13
  getDisplayValue(): number | string | string[];
14
14
  getType(): string;
15
15
  getUnit(): string;
@@ -1,6 +1,5 @@
1
1
  import { DataBare } from './data.bare';
2
- export declare abstract class DataNumber extends DataBare {
3
- protected value: number;
2
+ export declare abstract class DataNumber extends DataBare<number> {
4
3
  constructor(value: number);
5
4
  getValue(formatForDataType?: string): number;
6
5
  isValueTypeValid(value: any): boolean;
@@ -1,10 +1,9 @@
1
1
  import { DataBare } from './data.bare';
2
2
  import { DataPositionInterface } from './data.position.interface';
3
- export declare class DataPosition extends DataBare {
3
+ export declare class DataPosition extends DataBare<DataPositionInterface> {
4
4
  static type: string;
5
- protected value: DataPositionInterface;
6
5
  constructor(value: DataPositionInterface);
7
- getValue(): DataPositionInterface;
6
+ getValue(formatForDataType?: string): DataPositionInterface;
8
7
  getDisplayValue(): string;
9
8
  isValueTypeValid(value: any): boolean;
10
9
  }
@@ -8,7 +8,7 @@ class DataPosition extends data_bare_1.DataBare {
8
8
  super(value);
9
9
  this.value = value;
10
10
  }
11
- getValue() {
11
+ getValue(formatForDataType) {
12
12
  return this.value;
13
13
  }
14
14
  getDisplayValue() {
@@ -1,7 +1,6 @@
1
1
  import { DataBare } from './data.bare';
2
- export declare abstract class DataString extends DataBare {
3
- protected value: string;
2
+ export declare abstract class DataString extends DataBare<string> {
4
3
  constructor(value: string);
5
- getValue(): string;
4
+ getValue(formatForDataType?: string): string;
6
5
  isValueTypeValid(value: any): boolean;
7
6
  }
@@ -7,7 +7,7 @@ class DataString extends data_bare_1.DataBare {
7
7
  super(value);
8
8
  this.value = value;
9
9
  }
10
- getValue() {
10
+ getValue(formatForDataType) {
11
11
  return this.value;
12
12
  }
13
13
  isValueTypeValid(value) {
@@ -429,8 +429,9 @@ class EventImporterFIT {
429
429
  return deviceInfos.map((deviceInfo) => {
430
430
  const device = new device_1.Device(deviceInfo.device_type);
431
431
  device.index = deviceInfo.device_index;
432
- device.name = importer_fit_ant_plus_device_names_1.ImporterFitAntPlusDeviceNames[deviceInfo.ant_device_number] || deviceInfo.ant_device_number;
432
+ device.name = deviceInfo.product_name || importer_fit_ant_plus_device_names_1.ImporterFitAntPlusDeviceNames[deviceInfo.ant_device_number] || deviceInfo.ant_device_number;
433
433
  device.batteryStatus = deviceInfo.battery_status;
434
+ device.batteryLevel = (0, helpers_1.isNumber)(deviceInfo.battery_level) ? deviceInfo.battery_level : deviceInfo.battery_soc;
434
435
  device.batteryVoltage = deviceInfo.battery_voltage;
435
436
  device.manufacturer = deviceInfo.manufacturer;
436
437
  device.serialNumber = deviceInfo.serial_number;
@@ -58,6 +58,9 @@ class EventImporterJSON {
58
58
  if (json.batteryStatus) {
59
59
  device.batteryStatus = json.batteryStatus;
60
60
  }
61
+ if (json.batteryLevel) {
62
+ device.batteryLevel = json.batteryLevel;
63
+ }
61
64
  if (json.batteryVoltage) {
62
65
  device.batteryVoltage = json.batteryVoltage;
63
66
  }
@@ -13,7 +13,10 @@ const findChildNodeValue = (fromNodeList, childNodeName) => {
13
13
  const predicate = (childNode) => childNode.nodeName === childNodeName || childNode.nodeName.match(childNodeName) !== null;
14
14
  let value = (_b = (_a = Array.from(fromNodeList).find(predicate)) === null || _a === void 0 ? void 0 : _a.firstChild) === null || _b === void 0 ? void 0 : _b.nodeValue;
15
15
  value = value !== undefined ? value : null;
16
- return value === null ? value : Number(value);
16
+ if (value === null) {
17
+ return null;
18
+ }
19
+ return Number(value);
17
20
  };
18
21
  exports.findChildNodeValue = findChildNodeValue;
19
22
  // Fetch activity track point extensions according https://www8.garmin.com/xmlschemas/ActivityExtensionv2.xsd schema
@@ -1,7 +1,6 @@
1
1
  import { DataBare } from './data.bare';
2
- export declare abstract class DataArray extends DataBare {
3
- protected value: string[];
2
+ export declare abstract class DataArray extends DataBare<string[]> {
4
3
  constructor(value: string[]);
5
- getValue(): string[];
4
+ getValue(formatForDataType?: string): string[];
6
5
  isValueTypeValid(value: any): boolean;
7
6
  }
@@ -4,7 +4,7 @@ export class DataArray extends DataBare {
4
4
  super(value);
5
5
  this.value = value;
6
6
  }
7
- getValue() {
7
+ getValue(formatForDataType) {
8
8
  return this.value;
9
9
  }
10
10
  isValueTypeValid(value) {
@@ -1,4 +1,5 @@
1
1
  import { Data } from './data';
2
- export declare abstract class DataBare extends Data {
2
+ import { DataPositionInterface } from './data.position.interface';
3
+ export declare abstract class DataBare<T extends number | string | boolean | string[] | DataPositionInterface = number | string | boolean | string[] | DataPositionInterface> extends Data<T> {
3
4
  static unit: string;
4
5
  }
@@ -1,15 +1,15 @@
1
1
  import { DataInterface, UnitSystem } from './data.interface';
2
2
  import { DataJSONInterface } from './data.json.interface';
3
3
  import { DataPositionInterface } from './data.position.interface';
4
- export declare abstract class Data implements DataInterface {
4
+ export declare abstract class Data<T extends number | string | boolean | string[] | DataPositionInterface = number | string | boolean | string[] | DataPositionInterface> implements DataInterface {
5
5
  static type: string;
6
6
  static unit: string;
7
7
  static displayType?: string;
8
8
  static unitSystem: UnitSystem;
9
- protected value: number | string | boolean | string[] | DataPositionInterface;
10
- protected constructor(value: string | number | boolean | string[] | DataPositionInterface);
11
- setValue(value: string | number | boolean | string[] | DataPositionInterface): this;
12
- getValue(formatForDataType?: string): string | number | boolean | string[] | DataPositionInterface;
9
+ protected value: T;
10
+ protected constructor(value: T);
11
+ setValue(value: number | string | boolean | string[] | DataPositionInterface): this;
12
+ getValue(formatForDataType?: string): T;
13
13
  getDisplayValue(): number | string | string[];
14
14
  getType(): string;
15
15
  getUnit(): string;
@@ -1,6 +1,5 @@
1
1
  import { DataBare } from './data.bare';
2
- export declare abstract class DataNumber extends DataBare {
3
- protected value: number;
2
+ export declare abstract class DataNumber extends DataBare<number> {
4
3
  constructor(value: number);
5
4
  getValue(formatForDataType?: string): number;
6
5
  isValueTypeValid(value: any): boolean;
@@ -1,10 +1,9 @@
1
1
  import { DataBare } from './data.bare';
2
2
  import { DataPositionInterface } from './data.position.interface';
3
- export declare class DataPosition extends DataBare {
3
+ export declare class DataPosition extends DataBare<DataPositionInterface> {
4
4
  static type: string;
5
- protected value: DataPositionInterface;
6
5
  constructor(value: DataPositionInterface);
7
- getValue(): DataPositionInterface;
6
+ getValue(formatForDataType?: string): DataPositionInterface;
8
7
  getDisplayValue(): string;
9
8
  isValueTypeValid(value: any): boolean;
10
9
  }
@@ -5,7 +5,7 @@ export class DataPosition extends DataBare {
5
5
  super(value);
6
6
  this.value = value;
7
7
  }
8
- getValue() {
8
+ getValue(formatForDataType) {
9
9
  return this.value;
10
10
  }
11
11
  getDisplayValue() {
@@ -1,7 +1,6 @@
1
1
  import { DataBare } from './data.bare';
2
- export declare abstract class DataString extends DataBare {
3
- protected value: string;
2
+ export declare abstract class DataString extends DataBare<string> {
4
3
  constructor(value: string);
5
- getValue(): string;
4
+ getValue(formatForDataType?: string): string;
6
5
  isValueTypeValid(value: any): boolean;
7
6
  }
@@ -4,7 +4,7 @@ export class DataString extends DataBare {
4
4
  super(value);
5
5
  this.value = value;
6
6
  }
7
- getValue() {
7
+ getValue(formatForDataType) {
8
8
  return this.value;
9
9
  }
10
10
  isValueTypeValid(value) {
@@ -423,8 +423,9 @@ export class EventImporterFIT {
423
423
  return deviceInfos.map((deviceInfo) => {
424
424
  const device = new Device(deviceInfo.device_type);
425
425
  device.index = deviceInfo.device_index;
426
- device.name = ImporterFitAntPlusDeviceNames[deviceInfo.ant_device_number] || deviceInfo.ant_device_number;
426
+ device.name = deviceInfo.product_name || ImporterFitAntPlusDeviceNames[deviceInfo.ant_device_number] || deviceInfo.ant_device_number;
427
427
  device.batteryStatus = deviceInfo.battery_status;
428
+ device.batteryLevel = isNumber(deviceInfo.battery_level) ? deviceInfo.battery_level : deviceInfo.battery_soc;
428
429
  device.batteryVoltage = deviceInfo.battery_voltage;
429
430
  device.manufacturer = deviceInfo.manufacturer;
430
431
  device.serialNumber = deviceInfo.serial_number;
@@ -55,6 +55,9 @@ export class EventImporterJSON {
55
55
  if (json.batteryStatus) {
56
56
  device.batteryStatus = json.batteryStatus;
57
57
  }
58
+ if (json.batteryLevel) {
59
+ device.batteryLevel = json.batteryLevel;
60
+ }
58
61
  if (json.batteryVoltage) {
59
62
  device.batteryVoltage = json.batteryVoltage;
60
63
  }
@@ -9,7 +9,10 @@ export const findChildNodeValue = (fromNodeList, childNodeName) => {
9
9
  const predicate = (childNode) => childNode.nodeName === childNodeName || childNode.nodeName.match(childNodeName) !== null;
10
10
  let value = (_b = (_a = Array.from(fromNodeList).find(predicate)) === null || _a === void 0 ? void 0 : _a.firstChild) === null || _b === void 0 ? void 0 : _b.nodeValue;
11
11
  value = value !== undefined ? value : null;
12
- return value === null ? value : Number(value);
12
+ if (value === null) {
13
+ return null;
14
+ }
15
+ return Number(value);
13
16
  };
14
17
  // Fetch activity track point extensions according https://www8.garmin.com/xmlschemas/ActivityExtensionv2.xsd schema
15
18
  export const findTrackPointExtensionValue = (childNodes, extensionName) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sports-alliance/sports-lib",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "description": "A Library to for importing / exporting and processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc",
5
5
  "keywords": [
6
6
  "gpx",