///////////////////////////////////////////////////////////////////////////////////////////// // Copyright 2026 Garmin International, Inc. // Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you // may not use this file except in compliance with the Flexible and Interoperable Data // Transfer (FIT) Protocol License. ///////////////////////////////////////////////////////////////////////////////////////////// // ****WARNING**** This file is auto-generated! Do NOT edit this file. // Profile Version = 21.222.0Release // Tag = production/release/21.222.0-0-g71fae187 ///////////////////////////////////////////////////////////////////////////////////////////// import { Stream } from "./stream.js"; import { Mesg } from "./mesg.js"; import { FitMessages, DeveloperDataIdMesg, FieldDescriptionMesg } from "./mesgs.js"; /** Decodes FIT binary data from a {@link Stream}. */ export class Decoder { /** * Creates a FIT File Decoder. * @param stream - Stream representing the FIT file to decode. */ constructor(stream: Stream); /** * Inspects the file header to determine if the input stream is a FIT file. * @param stream - The stream to inspect. * @returns `true` if the stream is a FIT file. */ static isFIT(stream: Stream): boolean; /** * Inspects the file header to determine if the input stream is a FIT file. * @returns `true` if the stream is a FIT file. */ isFIT(): boolean; /** * Checks that the input stream is a FIT file and verifies both the header and file CRC values. * @returns `true` if the stream passes the {@link isFIT} and CRC checks. */ checkIntegrity(): boolean; /** * Read the messages from the stream. * @param options - Read options. See {@link DecoderOptions}. * @returns Object containing decoded messages, profile version, and any errors. */ read(options?: DecoderOptions): { messages: FitMessages; profileVersion: ProfileVersion; errors: Error[] }; } /** Describes a single field within a MesgDefinition. */ export interface FieldDefinition { /** Field definition number identifying the field within its message. */ fieldDefinitionNumber: number; /** Size in bytes of the field. */ size: number; /** FIT base type identifier for this field's values. */ baseType: number; /** The invalid value for this field's base type. */ invalidValue: number; /** Byte size of a single element of this field's base type. */ baseTypeSize: number; } /** Describes a single developer-defined field within a raw FIT message definition record. */ export interface DeveloperFieldDefinition { /** Developer field definition number, scoped to the developer data index. */ fieldDefinitionNumber: number; /** Size in bytes of the field. */ size: number; /** Index identifying the developer application that defined this field. */ developerDataIndex: number; } /** The definition record for a FIT message*/ export interface MesgDefinition { /** Raw record header byte. */ recordHeader: number; /** Local message number used to map messages to a definition. */ localMesgNum: number; /** Reserved byte from the definition record. */ reserved: number; /** Architecture byte: `0` = little-endian, `1` = big-endian. */ architecture: number; /** Endianness derived from `architecture` (`true` == little-endian or `false` == big-endian). */ endianness: boolean; /** Global message number identifying the message type in the FIT profile. */ globalMessageNumber: number; /** Number of fields in the message. */ numFields: number; /** Array of field definitions for the message. */ fieldDefinitions: FieldDefinition[]; /** Developer field definitions for the message. */ developerFieldDefinitions: DeveloperFieldDefinition[]; /** Total size in bytes of the combined fields. */ messageSize: number; /** Total size in bytes of the combined developer fields. */ developerDataSize: number; } /** Options controlling how {@link Decoder.read} decodes the FIT stream. */ export interface DecoderOptions { /** Callback invoked for each decoded message. */ mesgListener?: (mesgNum: number, mesg: Mesg) => void; /** Callback invoked for each decoded message definition. */ mesgDefinitionListener?: (mesgDefinition: MesgDefinition) => void; /** Callback invoked for each developer field description. */ fieldDescriptionListener?: (key: number, developerDataIdMesg: DeveloperDataIdMesg, fieldDescriptionMesg: FieldDescriptionMesg) => void; /** Expand sub fields. Default: `true`. */ expandSubFields?: boolean; /** Expand component fields. Default: `true`. */ expandComponents?: boolean; /** Apply scale and offset to numeric fields. Default: `true`. */ applyScaleAndOffset?: boolean; /** Convert type values to their string representations. Default: `true`. */ convertTypesToStrings?: boolean; /** Convert FIT epoch timestamps to `Date` objects. Default: `true`. */ convertDateTimesToDates?: boolean; /** Include fields not in the profile. Default: `false`. */ includeUnknownData?: boolean; /** Merge HR messages into record messages. Requires `applyScaleAndOffset` and `expandComponents`. Default: `true`. */ mergeHeartRates?: boolean; /** Decode memo glob messages. Default: `false`. */ decodeMemoGlobs?: boolean; /** Skip the FIT file header. Default: `false`. */ skipHeader?: boolean; /** Decode data bytes only, no header or CRC. Default: `false`. */ dataOnly?: boolean; /** @deprecated Default: `false`. */ legacyArrayMode?: boolean; } /** The FIT profile version embedded in a FIT file header. */ export interface ProfileVersion { /** Major version number. */ major: number; /** Minor version number (tenths). */ minor: number; }