@sports-alliance/sports-lib 7.0.2 → 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.
- package/lib/cjs/activities/devices/device.d.ts +1 -0
- package/lib/cjs/activities/devices/device.interface.d.ts +1 -0
- package/lib/cjs/activities/devices/device.js +1 -0
- package/lib/cjs/activities/devices/device.json.interface.d.ts +1 -0
- package/lib/cjs/data/data.array.d.ts +2 -3
- package/lib/cjs/data/data.array.js +1 -1
- package/lib/cjs/data/data.bare.d.ts +2 -1
- package/lib/cjs/data/data.d.ts +5 -5
- package/lib/cjs/data/data.number.d.ts +1 -2
- package/lib/cjs/data/data.position.d.ts +2 -3
- package/lib/cjs/data/data.position.js +1 -1
- package/lib/cjs/data/data.string.d.ts +2 -3
- package/lib/cjs/data/data.string.js +1 -1
- package/lib/cjs/events/adapters/importers/fit/importer.fit.js +2 -1
- package/lib/cjs/events/adapters/importers/json/importer.json.js +3 -0
- package/lib/cjs/events/adapters/importers/tcx/utils.tcx.js +4 -1
- package/lib/esm/activities/devices/device.d.ts +1 -0
- package/lib/esm/activities/devices/device.interface.d.ts +1 -0
- package/lib/esm/activities/devices/device.js +1 -0
- package/lib/esm/activities/devices/device.json.interface.d.ts +1 -0
- package/lib/esm/data/data.array.d.ts +2 -3
- package/lib/esm/data/data.array.js +1 -1
- package/lib/esm/data/data.bare.d.ts +2 -1
- package/lib/esm/data/data.d.ts +5 -5
- package/lib/esm/data/data.number.d.ts +1 -2
- package/lib/esm/data/data.position.d.ts +2 -3
- package/lib/esm/data/data.position.js +1 -1
- package/lib/esm/data/data.string.d.ts +2 -3
- package/lib/esm/data/data.string.js +1 -1
- package/lib/esm/events/adapters/importers/fit/importer.fit.js +2 -1
- package/lib/esm/events/adapters/importers/json/importer.json.js +3 -0
- package/lib/esm/events/adapters/importers/tcx/utils.tcx.js +4 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ class Device {
|
|
|
11
11
|
type: this.type,
|
|
12
12
|
index: (0, helpers_1.isNumber)(this.index) ? this.index || null : null,
|
|
13
13
|
batteryStatus: this.batteryStatus || null,
|
|
14
|
+
batteryLevel: this.batteryLevel || null,
|
|
14
15
|
name: this.name || null,
|
|
15
16
|
batteryVoltage: this.batteryVoltage || null,
|
|
16
17
|
manufacturer: this.manufacturer || null,
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Data } from './data';
|
|
2
|
-
|
|
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
|
}
|
package/lib/cjs/data/data.d.ts
CHANGED
|
@@ -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:
|
|
10
|
-
protected constructor(value:
|
|
11
|
-
setValue(value:
|
|
12
|
-
getValue(formatForDataType?: string):
|
|
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
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
-
|
|
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
|
|
@@ -8,6 +8,7 @@ export class Device {
|
|
|
8
8
|
type: this.type,
|
|
9
9
|
index: isNumber(this.index) ? this.index || null : null,
|
|
10
10
|
batteryStatus: this.batteryStatus || null,
|
|
11
|
+
batteryLevel: this.batteryLevel || null,
|
|
11
12
|
name: this.name || null,
|
|
12
13
|
batteryVoltage: this.batteryVoltage || null,
|
|
13
14
|
manufacturer: this.manufacturer || null,
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Data } from './data';
|
|
2
|
-
|
|
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
|
}
|
package/lib/esm/data/data.d.ts
CHANGED
|
@@ -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:
|
|
10
|
-
protected constructor(value:
|
|
11
|
-
setValue(value:
|
|
12
|
-
getValue(formatForDataType?: string):
|
|
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
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
-
|
|
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
|
+
"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",
|