Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@garmin/fitsdk",
"version": "21.205.0",
"version": "21.208.0",
"description": "FIT JavaScript SDK",
"main": "src/index.js",
"types": "src/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/accumulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/bit-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/crc-calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
5 changes: 2 additions & 3 deletions src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -433,7 +433,6 @@ class Decoder {
fieldDefinition.size,
{
littleEndian: messageDefinition["endianness"],
convertInvalidToNull: !field?.hasComponents ?? false,
isArray: field?.array ?? fieldDefinition.size > fieldDefinition.baseTypeSize,
},
);
Expand Down
4 changes: 2 additions & 2 deletions src/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/fit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/mesg-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/output-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
8 changes: 4 additions & 4 deletions src/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


const Profile = {
version: {
major: 21,
minor: 205,
minor: 208,
patch: 0,
type: "Release"
},
Expand Down Expand Up @@ -18907,7 +18907,7 @@ const Profile = {
0: {
num: 0,
name: "weight",
type: "weight",
type: "uint16",
baseType: "uint16",
array: false,
scale: 100,
Expand Down
4 changes: 2 additions & 2 deletions src/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/crc-calculator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/decoder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/encoder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/mesg.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/mesgs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/profile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/stream.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/utils-hr-mesg.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/utils-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
4 changes: 2 additions & 2 deletions src/utils-memo-glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////

import Profile from "./profile.js";
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Transfer (FIT) Protocol License.
/////////////////////////////////////////////////////////////////////////////////////////////
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
// Profile Version = 21.205.0Release
// Tag = production/release/21.205.0-0-gb3c261eb
// Profile Version = 21.208.0Release
// Tag = production/release/21.208.0-0-g5209d509
/////////////////////////////////////////////////////////////////////////////////////////////


Expand Down
33 changes: 33 additions & 0 deletions test/decoder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Stream from "../src/stream.js";
import Data from "./data/test-data.js";
import HrData from "./data/test-data-expand-hr-mesgs.js";
import { uint16LE, uint32LE, uint64LE, buildFit } from "./utils/fit-builder.js";
import { encodeThenDecodeMesgs } from "./testUtils.js";

describe("Decoder Tests", () => {
describe("Decoder Constructor Tests", () => {
Expand Down Expand Up @@ -757,6 +758,38 @@ describe("Decoder Tests", () => {
}
});
});

describe("Invalid Value Tests", () => {
const invalidValueCases = [
{ label: "Enum", recordMesg: { activityType: FIT.BaseTypeDefinitions[FIT.BaseType.ENUM].invalid } },
{ label: "SInt8", recordMesg: { left_pco: FIT.BaseTypeDefinitions[FIT.BaseType.SINT8].invalid } },
{ label: "UInt8", recordMesg: { cadence: FIT.BaseTypeDefinitions[FIT.BaseType.UINT8].invalid } },
{ label: "SInt16", recordMesg: { grade: FIT.BaseTypeDefinitions[FIT.BaseType.SINT16].invalid / 100 } },
{ label: "UInt16", recordMesg: { power: FIT.BaseTypeDefinitions[FIT.BaseType.UINT16].invalid } },
{ label: "SInt32", recordMesg: { positionLat: FIT.BaseTypeDefinitions[FIT.BaseType.SINT32].invalid } },
{ label: "UInt32", recordMesg: { timestamp: FIT.BaseTypeDefinitions[FIT.BaseType.UINT32].invalid } },
];

test.each(invalidValueCases)("$label: Fields that have invalid values are dropped", ({ label, recordMesg }) => {
const { messages, errors } = encodeThenDecodeMesgs([
{ mesgNum: Profile.MesgNum.RECORD, mesg: { ...recordMesg, heartRate: 50 } },
]);

// The invalid fields should not be present
expect(messages.recordMesgs).toStrictEqual([{ heartRate: 50 }]);
});

test("Fields with components that have invalid values are dropped", () => {
const { messages, errors } = encodeThenDecodeMesgs([
{ mesgNum: Profile.MesgNum.RECORD, mesg: { speed: 65.535, heartRate: 60 } },
]);

expect(errors.length).toBe(0);

// The invalid speed field and its component should not be present
expect(messages.recordMesgs).toStrictEqual([{ heartRate: 60 }]);
});
});
});

const RECORD = Profile.MesgNum.RECORD;
Expand Down
Loading
Loading