trackswap 0.2.2 → 0.2.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/README.md +16 -0
- package/dist/FIT/base.d.ts +30 -0
- package/dist/FIT/decoder.d.ts +48 -0
- package/dist/FIT/encoder.d.ts +96 -1
- package/dist/FIT/encoderCourse.d.ts +45 -0
- package/dist/FIT/encoderWorkout.d.ts +45 -0
- package/dist/FIT/health.d.ts +191 -4
- package/dist/FIT/index.d.ts +1 -1
- package/dist/FIT/mesg.d.ts +3 -0
- package/dist/FIT/middleware.d.ts +15 -0
- package/dist/FIT/plugins.d.ts +9 -0
- package/dist/FIT/processor.d.ts +24 -0
- package/dist/FIT/types/checksum_type.d.ts +6 -0
- package/dist/FIT/types/date_time_type.d.ts +3 -0
- package/dist/FIT/types/file.d.ts +63 -0
- package/dist/FIT/types/file_flags_type.d.ts +9 -0
- package/dist/FIT/types/local_date_time_type.d.ts +3 -0
- package/dist/FIT/types/mesg_count_type.d.ts +6 -0
- package/dist/FIT/types/mesg_num.d.ts +369 -0
- package/dist/FIT/types/message_index_type.d.ts +6591 -0
- package/dist/FIT/types/sport.d.ts +44 -44
- package/dist/FIT/types.d.ts +509 -0
- package/dist/GPX/base.d.ts +24 -0
- package/dist/GPX/converters.d.ts +44 -0
- package/dist/GPX/decoder.d.ts +66 -0
- package/dist/GPX/encoder.d.ts +109 -0
- package/dist/GPX/middleware.d.ts +9 -0
- package/dist/GPX/processor.d.ts +18 -0
- package/dist/GPX/types.d.ts +138 -0
- package/dist/TCX/base.d.ts +33 -0
- package/dist/TCX/converters.d.ts +33 -0
- package/dist/TCX/decoder.d.ts +54 -0
- package/dist/TCX/encoder.d.ts +116 -0
- package/dist/TCX/middleware.d.ts +12 -0
- package/dist/TCX/processor.d.ts +30 -0
- package/dist/TCX/types.d.ts +13 -0
- package/dist/TrackSwap.d.ts +4 -0
- package/dist/activity/base.d.ts +54 -0
- package/dist/activity/converters.d.ts +57 -0
- package/dist/activity/encoders.d.ts +34 -0
- package/dist/activity/metrics/MetricsCalculator.d.ts +30 -0
- package/dist/activity/processor.d.ts +31 -0
- package/dist/core/base.d.ts +46 -0
- package/dist/core/builtin-adapters.d.ts +1 -0
- package/dist/core/xml-utils.d.ts +24 -0
- package/dist/errors.d.ts +1 -1
- package/dist/fit-debug.d.ts +3 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/types.d.ts +102 -1
- package/dist/util.d.ts +9 -0
- package/package.json +3 -2
package/dist/FIT/health.d.ts
CHANGED
|
@@ -1,122 +1,309 @@
|
|
|
1
1
|
import { BaseFITStructurePlugin } from "./base.js";
|
|
2
2
|
import type { FITContext } from "./types.js";
|
|
3
|
+
/** High-level content categories detected in a decoded FIT file. */
|
|
3
4
|
export type FITPrimaryKind = 'activity' | 'health' | 'workout' | 'course' | 'device' | 'unknown';
|
|
5
|
+
/**
|
|
6
|
+
* Canonical metric identifiers emitted by the Health IR.
|
|
7
|
+
*
|
|
8
|
+
* Stable built-in identifiers include their physical unit where ambiguity
|
|
9
|
+
* would otherwise be likely (for example `_bpm`, `_m`, `_s`, and `_kcal`).
|
|
10
|
+
* Unstandardized values must use the `vendor:` namespace.
|
|
11
|
+
*
|
|
12
|
+
* Unit conventions:
|
|
13
|
+
* - heart/respiration rates: beats or breaths per minute;
|
|
14
|
+
* - distance/ascent/descent: metres;
|
|
15
|
+
* - activity durations: seconds;
|
|
16
|
+
* - energy: kilocalories;
|
|
17
|
+
* - SpO2: percent;
|
|
18
|
+
* - HRV RMSSD: milliseconds;
|
|
19
|
+
* - temperature and temperature deviations: degrees Celsius;
|
|
20
|
+
* - stress and Body Battery values: vendor-defined scores.
|
|
21
|
+
*/
|
|
4
22
|
export type HealthMetricCode = 'heart_rate_bpm' | 'resting_heart_rate_bpm' | 'resting_heart_rate_7_day_bpm' | 'steps' | 'distance_m' | 'active_time_s' | 'moderate_activity_time_s' | 'vigorous_activity_time_s' | 'active_energy_kcal' | 'total_energy_kcal' | 'stress_level' | 'respiration_rate_bpm' | 'spo2_percent' | 'body_battery_level' | 'body_battery_charged' | 'body_battery_drained' | 'hrv_rmssd_ms' | 'temperature_c' | 'wrist_temperature_c' | 'skin_temperature_deviation_c' | 'skin_temperature_7_day_deviation_c' | 'skin_temperature_nightly_c' | 'ascent_m' | 'descent_m' | `vendor:${string}`;
|
|
23
|
+
/**
|
|
24
|
+
* Measurement usability independently of the numeric value.
|
|
25
|
+
*
|
|
26
|
+
* Only `valid` values are safe to use in ordinary physiological aggregates.
|
|
27
|
+
* Other statuses are retained as observation and data-quality facts. When a
|
|
28
|
+
* FIT sentinel produces a non-valid status, `value` is normally omitted and
|
|
29
|
+
* the decoded sentinel may be retained in `attributes.rawValue` for audit.
|
|
30
|
+
*
|
|
31
|
+
* Status meanings:
|
|
32
|
+
* - `valid`: usable measurement;
|
|
33
|
+
* - `invalid`: malformed, impossible, or explicitly invalid source value;
|
|
34
|
+
* - `off_wrist`: wearable contact was absent;
|
|
35
|
+
* - `motion`: motion prevented a reliable measurement;
|
|
36
|
+
* - `low_confidence`: a value exists but source confidence is insufficient;
|
|
37
|
+
* - `not_enough_data`: the source could not collect enough evidence;
|
|
38
|
+
* - `recovering`: the source algorithm is still establishing a baseline;
|
|
39
|
+
* - `unidentified`: the source reported an unclassified state;
|
|
40
|
+
* - `gap`: expected sample was absent or represented by a blank sentinel;
|
|
41
|
+
* - `unknown`: source status could not be normalized safely.
|
|
42
|
+
*/
|
|
5
43
|
export type HealthValueStatus = 'valid' | 'invalid' | 'off_wrist' | 'motion' | 'low_confidence' | 'not_enough_data' | 'recovering' | 'unidentified' | 'gap' | 'unknown';
|
|
44
|
+
/** Pointer back to the decoded FIT message and field that produced a value. */
|
|
6
45
|
export type HealthMessagePointerV1 = {
|
|
46
|
+
/** Garmin FIT SDK message collection name, such as `monitoringMesgs`. */
|
|
7
47
|
messageName: string;
|
|
48
|
+
/** Zero-based index within the message collection. */
|
|
8
49
|
messageIndex: number;
|
|
50
|
+
/** Source field name when the normalized value came from one field. */
|
|
9
51
|
fieldName?: string;
|
|
52
|
+
/** Whether `fieldName` refers to a FIT developer field. */
|
|
10
53
|
developerField?: boolean;
|
|
11
54
|
};
|
|
55
|
+
/** A point-in-time health measurement or measurement-status observation. */
|
|
12
56
|
export type HealthPointV1 = {
|
|
57
|
+
/** Canonical metric identifier. */
|
|
13
58
|
metric: HealthMetricCode;
|
|
59
|
+
/** Absolute observation instant. Serialized as an ISO 8601 UTC timestamp. */
|
|
14
60
|
timestamp: Date;
|
|
61
|
+
/**
|
|
62
|
+
* Local wall-clock timestamp without a zone suffix.
|
|
63
|
+
*
|
|
64
|
+
* Interpret it together with `offsetSeconds`; it is not another instant.
|
|
65
|
+
*/
|
|
15
66
|
localTimestamp?: string;
|
|
67
|
+
/** UTC offset at `timestamp`, in seconds (for example `28800` is UTC+08:00). */
|
|
16
68
|
offsetSeconds?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Normalized numeric value in `unit`.
|
|
71
|
+
*
|
|
72
|
+
* Usually absent when `status !== 'valid'`; never interpret an absent value
|
|
73
|
+
* or `attributes.rawValue` as a physiological measurement.
|
|
74
|
+
*/
|
|
17
75
|
value?: number;
|
|
76
|
+
/** Unit of `value`, such as `bpm`, `breaths/min`, `percent`, or `score`. */
|
|
18
77
|
unit: string;
|
|
78
|
+
/** Measurement usability and, for non-valid samples, the missing-data reason. */
|
|
19
79
|
status: HealthValueStatus;
|
|
80
|
+
/** Source-provided confidence when available; its scale is metric-specific. */
|
|
20
81
|
quality?: number;
|
|
82
|
+
/** Statistical meaning of this point in the source file. */
|
|
21
83
|
aggregation?: 'instant' | 'mean' | 'min' | 'max' | 'sum' | 'latest';
|
|
84
|
+
/** FIT source location for audit and deterministic identity. */
|
|
22
85
|
source: HealthMessagePointerV1;
|
|
86
|
+
/**
|
|
87
|
+
* Additional source metadata. For non-valid samples, `rawValue` may contain
|
|
88
|
+
* the original FIT sentinel solely for diagnostics and round-trip audit.
|
|
89
|
+
*/
|
|
23
90
|
attributes?: Record<string, string | number | boolean | null>;
|
|
24
91
|
};
|
|
92
|
+
/** A health value or state covering the half-open range `[startTime, endTime)`. */
|
|
25
93
|
export type HealthIntervalV1 = {
|
|
94
|
+
/** Canonical metric identifier. */
|
|
26
95
|
metric: HealthMetricCode;
|
|
96
|
+
/** Absolute inclusive start instant. */
|
|
27
97
|
startTime: Date;
|
|
98
|
+
/** Absolute exclusive end instant. */
|
|
28
99
|
endTime: Date;
|
|
100
|
+
/** Local wall-clock start without a zone suffix; pair with `offsetSeconds`. */
|
|
29
101
|
localStartTime?: string;
|
|
102
|
+
/** UTC offset at `startTime`, in seconds. */
|
|
30
103
|
offsetSeconds?: number;
|
|
104
|
+
/** Normalized interval value; absent when no usable numeric value exists. */
|
|
31
105
|
value?: number;
|
|
106
|
+
/** Unit of `value`. */
|
|
32
107
|
unit: string;
|
|
108
|
+
/** Measurement usability for the interval. */
|
|
33
109
|
status: HealthValueStatus;
|
|
110
|
+
/** Source activity classification when the FIT message provides one. */
|
|
34
111
|
activityType?: string;
|
|
112
|
+
/** Source intensity classification when the FIT message provides one. */
|
|
35
113
|
intensity?: string;
|
|
114
|
+
/** FIT source location for audit and deterministic event identity. */
|
|
36
115
|
source: HealthMessagePointerV1;
|
|
116
|
+
/** Additional normalized or source-specific metadata. */
|
|
37
117
|
attributes?: Record<string, string | number | boolean | null>;
|
|
38
118
|
};
|
|
119
|
+
/** A non-sampled aggregate or device/window summary from the FIT file. */
|
|
39
120
|
export type HealthSummaryV1 = {
|
|
121
|
+
/** Semantic category of the summary. */
|
|
40
122
|
summaryType: 'daily' | 'sleep' | 'hrv_status' | 'monitoring_window' | 'device';
|
|
123
|
+
/** Stable source-derived identifier suitable for idempotent upsert. */
|
|
41
124
|
externalId: string;
|
|
125
|
+
/** Source-local calendar date in `YYYY-MM-DD` form, when defined. */
|
|
42
126
|
calendarDate?: string;
|
|
127
|
+
/** Absolute start instant of the summarized range, when defined. */
|
|
43
128
|
startTime?: Date;
|
|
129
|
+
/** Absolute end instant of the summarized range, when defined. */
|
|
44
130
|
endTime?: Date;
|
|
131
|
+
/** UTC offset associated with the summary, in seconds. */
|
|
45
132
|
offsetSeconds?: number;
|
|
133
|
+
/** Named summary values; keys are summary-type specific. */
|
|
46
134
|
metrics: Record<string, number | string | boolean | null>;
|
|
135
|
+
/** FIT source location. */
|
|
47
136
|
source: HealthMessagePointerV1;
|
|
48
137
|
};
|
|
138
|
+
/** One staged portion of a sleep or other health session. */
|
|
49
139
|
export type HealthSessionSegmentV1 = {
|
|
140
|
+
/** Normalized segment stage or a vendor-namespaced extension. */
|
|
50
141
|
segmentType: 'awake' | 'light' | 'deep' | 'rem' | 'unmeasurable' | 'sleeping' | `vendor:${string}`;
|
|
142
|
+
/** Absolute inclusive start instant. */
|
|
51
143
|
startTime: Date;
|
|
144
|
+
/** Absolute exclusive end instant. */
|
|
52
145
|
endTime: Date;
|
|
146
|
+
/** Segment usability. */
|
|
53
147
|
status: HealthValueStatus;
|
|
148
|
+
/** FIT source location. */
|
|
54
149
|
source: HealthMessagePointerV1;
|
|
55
150
|
};
|
|
151
|
+
/** A bounded health session such as sleep, a nap, or a health snapshot. */
|
|
56
152
|
export type HealthSessionV1 = {
|
|
153
|
+
/** Normalized session category or a vendor-namespaced extension. */
|
|
57
154
|
sessionType: 'sleep' | 'nap' | 'health_snapshot' | `vendor:${string}`;
|
|
155
|
+
/** Stable source-derived identifier suitable for idempotent upsert. */
|
|
58
156
|
externalId: string;
|
|
157
|
+
/** Absolute inclusive session start instant. */
|
|
59
158
|
startTime: Date;
|
|
159
|
+
/** Absolute exclusive session end instant. */
|
|
60
160
|
endTime: Date;
|
|
161
|
+
/** UTC offset at `startTime`, in seconds; this is not a duration. */
|
|
61
162
|
startOffsetSeconds?: number;
|
|
163
|
+
/** UTC offset at `endTime`, in seconds; may differ across a DST transition. */
|
|
62
164
|
endOffsetSeconds?: number;
|
|
165
|
+
/** Source-local session date in `YYYY-MM-DD` form. */
|
|
63
166
|
calendarDate?: string;
|
|
167
|
+
/** Source tombstone indicating that a previously emitted session was deleted. */
|
|
64
168
|
deleted?: boolean;
|
|
169
|
+
/** Ordered session stages; may be empty when the source only supplies bounds. */
|
|
65
170
|
segments: HealthSessionSegmentV1[];
|
|
171
|
+
/** Session-level values whose keys depend on `sessionType`. */
|
|
66
172
|
metrics: Record<string, number | string | boolean | null>;
|
|
173
|
+
/** FIT source location. */
|
|
67
174
|
source: HealthMessagePointerV1;
|
|
175
|
+
/** Additional source metadata, such as automatic/manual origin or update time. */
|
|
68
176
|
attributes?: Record<string, string | number | boolean | null>;
|
|
69
177
|
};
|
|
178
|
+
/** A recoverable parser warning with an optional FIT source pointer. */
|
|
70
179
|
export type FITDiagnosticWarningV1 = {
|
|
180
|
+
/** Stable machine-readable warning code. */
|
|
71
181
|
code: string;
|
|
182
|
+
/** Human-readable diagnostic message. */
|
|
72
183
|
message: string;
|
|
184
|
+
/** FIT source location when the warning belongs to one message or field. */
|
|
73
185
|
source?: HealthMessagePointerV1;
|
|
74
186
|
};
|
|
187
|
+
/** Parse coverage, invalid-value counts, and bounded warning diagnostics. */
|
|
75
188
|
export type FITDiagnosticsV1 = {
|
|
189
|
+
/** Garmin FIT SDK profile version used for decoding. */
|
|
76
190
|
sdkProfileVersion?: string;
|
|
191
|
+
/** TrackSwap Health IR parser version that produced this document. */
|
|
77
192
|
parserVersion: string;
|
|
193
|
+
/** Total decoded message count keyed by Garmin SDK message collection name. */
|
|
78
194
|
messageCounts: Record<string, number>;
|
|
195
|
+
/** Counts for message collections recognized by the Health IR parser. */
|
|
79
196
|
recognizedMessageCounts: Record<string, number>;
|
|
197
|
+
/** Counts for decoded collections not recognized by the Health IR parser. */
|
|
80
198
|
unknownMessageCounts: Record<string, number>;
|
|
199
|
+
/** Non-valid sample counts keyed as `<metric>:<status>`. */
|
|
81
200
|
invalidValueCounts: Record<string, number>;
|
|
201
|
+
/** Complete warning count by code, including warnings omitted from `warnings`. */
|
|
82
202
|
warningCounts: Record<string, number>;
|
|
203
|
+
/**
|
|
204
|
+
* Bounded warning examples. Repeated warnings are sampled to avoid unbounded
|
|
205
|
+
* diagnostic payloads; use `warningCounts` for their full cardinality.
|
|
206
|
+
*/
|
|
83
207
|
warnings: FITDiagnosticWarningV1[];
|
|
208
|
+
/** Raw unknown messages, present only when explicitly requested. */
|
|
84
209
|
unknownMessages?: Record<string, unknown[]>;
|
|
85
210
|
};
|
|
211
|
+
/** Canonical, provider-neutral Health Intermediate Representation (Health IR). */
|
|
86
212
|
export type HealthDocumentV1 = {
|
|
213
|
+
/** Health IR schema version. */
|
|
87
214
|
schemaVersion: '1';
|
|
215
|
+
/** Earliest absolute instant observed in the health content. */
|
|
88
216
|
observedStart?: Date;
|
|
217
|
+
/** Latest absolute instant observed in the health content. */
|
|
89
218
|
observedEnd?: Date;
|
|
219
|
+
/** Timezone evidence used to derive local wall-clock fields and dates. */
|
|
90
220
|
timezone: {
|
|
221
|
+
/**
|
|
222
|
+
* Provenance of the selected offsets: explicit FIT offset, timestamp
|
|
223
|
+
* correlation, conservative inference, or no usable timezone evidence.
|
|
224
|
+
*/
|
|
91
225
|
strategy: 'explicit_offset' | 'timestamp_correlation' | 'inferred' | 'unknown';
|
|
226
|
+
/**
|
|
227
|
+
* Chronological UTC-offset anchors. Each offset applies from `at` until the
|
|
228
|
+
* next anchor; `offsetSeconds` is seconds east of UTC.
|
|
229
|
+
*/
|
|
92
230
|
offsets: Array<{
|
|
93
231
|
at: Date;
|
|
94
232
|
offsetSeconds: number;
|
|
95
233
|
}>;
|
|
96
234
|
};
|
|
235
|
+
/** Point-in-time measurements and non-valid measurement-status observations. */
|
|
97
236
|
points: HealthPointV1[];
|
|
237
|
+
/** Duration-based values and states. */
|
|
98
238
|
intervals: HealthIntervalV1[];
|
|
239
|
+
/** Aggregate source summaries that should not be treated as sampled series. */
|
|
99
240
|
summaries: HealthSummaryV1[];
|
|
241
|
+
/** Bounded sessions such as sleep, naps, and health snapshots. */
|
|
100
242
|
sessions: HealthSessionV1[];
|
|
243
|
+
/** Parser version, coverage, invalid values, and warning diagnostics. */
|
|
101
244
|
diagnostics: FITDiagnosticsV1;
|
|
102
245
|
};
|
|
246
|
+
/** Options controlling FIT document normalization and diagnostic retention. */
|
|
103
247
|
export type FITDocumentParseOptions = {
|
|
248
|
+
/** Retain decoded message collections not recognized by the Health parser. */
|
|
104
249
|
includeUnknownMessages?: boolean;
|
|
250
|
+
/** Retain FIT developer fields when supported by the decoder. */
|
|
105
251
|
includeDeveloperFields?: boolean;
|
|
252
|
+
/** Fail on recoverable parse problems instead of returning diagnostics. */
|
|
106
253
|
strict?: boolean;
|
|
254
|
+
/** Health-specific normalization options. */
|
|
107
255
|
health?: {
|
|
256
|
+
/**
|
|
257
|
+
* Reconstruct intervals/deltas from cumulative monitoring counters.
|
|
258
|
+
* Defaults to enabled.
|
|
259
|
+
*/
|
|
108
260
|
reconstructIntervals?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Also retain raw cumulative counter points when interval reconstruction is
|
|
263
|
+
* enabled. Defaults to disabled to prevent accidental double counting.
|
|
264
|
+
*/
|
|
109
265
|
retainCumulativeValues?: boolean;
|
|
110
266
|
};
|
|
111
267
|
};
|
|
268
|
+
/** Garmin FIT SDK message collections keyed by their plural message name. */
|
|
112
269
|
export type FITMessages = Record<string, unknown[] | undefined>;
|
|
113
|
-
|
|
114
|
-
export
|
|
115
|
-
|
|
270
|
+
/** Decoder environment metadata recorded in Health IR diagnostics. */
|
|
271
|
+
export type FITHealthBuildEnvironment = {
|
|
272
|
+
/** Garmin FIT SDK profile version used to decode `messages`. */
|
|
116
273
|
sdkProfileVersion?: string;
|
|
117
|
-
}
|
|
274
|
+
};
|
|
275
|
+
/** Parser revision embedded in `HealthDocumentV1.diagnostics.parserVersion`. */
|
|
276
|
+
export declare const TRACKSWAP_HEALTH_PARSER_VERSION = "trackswap-health-ir-v1";
|
|
277
|
+
/**
|
|
278
|
+
* Detects every high-level content kind represented by decoded FIT messages.
|
|
279
|
+
*
|
|
280
|
+
* The result may contain more than one kind for mixed-content files. It falls
|
|
281
|
+
* back to `unknown` when no supported evidence is present.
|
|
282
|
+
*/
|
|
283
|
+
export declare function detectFITKinds(messages: FITMessages): FITPrimaryKind[];
|
|
284
|
+
/**
|
|
285
|
+
* Normalizes Garmin FIT SDK message collections into Health IR schema v1.
|
|
286
|
+
*
|
|
287
|
+
* Absolute timestamps are represented as `Date` values. Local wall-clock
|
|
288
|
+
* fields never replace those instants and must be interpreted with their UTC
|
|
289
|
+
* offset. Garmin sentinel values are mapped to `HealthValueStatus`; non-valid
|
|
290
|
+
* sentinels are not emitted as physiological numeric values.
|
|
291
|
+
*
|
|
292
|
+
* @param messages Decoded Garmin FIT SDK message collections.
|
|
293
|
+
* @param options Normalization and diagnostic-retention options.
|
|
294
|
+
* @param environment Decoder metadata that affects diagnostics, not values.
|
|
295
|
+
* @returns A deterministic, chronologically ordered Health IR document.
|
|
296
|
+
*/
|
|
297
|
+
export declare function buildHealthDocumentFromMessages(messages: FITMessages, options?: FITDocumentParseOptions, environment?: FITHealthBuildEnvironment): HealthDocumentV1;
|
|
298
|
+
/**
|
|
299
|
+
* FIT structure plugin that attaches detected content kinds and a normalized
|
|
300
|
+
* Health IR facet to TrackSwap's decoded FIT document.
|
|
301
|
+
*/
|
|
118
302
|
export declare class HealthStructurePlugin extends BaseFITStructurePlugin {
|
|
303
|
+
/** Stable plugin identifier. */
|
|
119
304
|
name: string;
|
|
305
|
+
/** Structure-plugin execution priority. */
|
|
120
306
|
priority: number;
|
|
307
|
+
/** Builds the health facet and FIT document metadata for decoded messages. */
|
|
121
308
|
structureData(messages: FITMessages, context: FITContext): Partial<import('./types.js').FITFileType>;
|
|
122
309
|
}
|
package/dist/FIT/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { FITEncoder } from "./encoder.js";
|
|
|
3
3
|
export { IFITMessageConverter, IFITStructurePlugin, IFITMiddlewarePlugin, BaseFITMessageConverter, BaseFITStructurePlugin, BaseFITMiddleware, } from "./base.js";
|
|
4
4
|
export { SessionStructurePlugin, CourseStructurePlugin, FileHeaderPlugin, } from "./plugins.js";
|
|
5
5
|
export { HealthStructurePlugin, buildHealthDocumentFromMessages, detectFITKinds, TRACKSWAP_HEALTH_PARSER_VERSION, } from "./health.js";
|
|
6
|
-
export type { FITDocumentParseOptions, FITPrimaryKind, FITDiagnosticsV1, HealthDocumentV1, HealthIntervalV1, HealthMetricCode, HealthPointV1, HealthSessionSegmentV1, HealthSessionV1, HealthSummaryV1, HealthValueStatus, } from "./health.js";
|
|
6
|
+
export type { FITDocumentParseOptions, FITHealthBuildEnvironment, FITPrimaryKind, FITDiagnosticsV1, HealthDocumentV1, HealthIntervalV1, HealthMetricCode, HealthPointV1, HealthSessionSegmentV1, HealthSessionV1, HealthSummaryV1, HealthValueStatus, } from "./health.js";
|
|
7
7
|
export * from "./types.js";
|
|
8
8
|
export { encodeCourse, buildCourseMesgs, type CoursePlan, type CourseRecordPoint, type CourseCuePoint, type FitMesg as CourseFitMesg, } from "./encoderCourse.js";
|
|
9
9
|
import { FITDecoder } from "./decoder.js";
|
package/dist/FIT/mesg.d.ts
CHANGED
|
@@ -29,6 +29,9 @@ export declare class Mesg {
|
|
|
29
29
|
constructor(localNum: number, mesgName: string, values: {
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
});
|
|
32
|
+
/**
|
|
33
|
+
* Get defns and obtain the size
|
|
34
|
+
*/
|
|
32
35
|
get mesgDefn(): ProcessedMesgDefn;
|
|
33
36
|
isSameDefn(mesgDefn: ProcessedMesgDefn): boolean;
|
|
34
37
|
get defnRecord(): ArrayBuffer;
|
package/dist/FIT/middleware.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { BaseFITMiddleware } from "./base.js";
|
|
2
2
|
import { FITDecoderMesgs, FITFileType, FITContext } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Performance monitoring middleware
|
|
5
|
+
*/
|
|
3
6
|
export declare class PerformanceMiddleware extends BaseFITMiddleware {
|
|
4
7
|
name: string;
|
|
5
8
|
description: string;
|
|
@@ -12,22 +15,34 @@ export declare class PerformanceMiddleware extends BaseFITMiddleware {
|
|
|
12
15
|
private analyzeStructure;
|
|
13
16
|
private getSummary;
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Data validation middleware
|
|
20
|
+
*/
|
|
15
21
|
export declare class ValidationMiddleware extends BaseFITMiddleware {
|
|
16
22
|
name: string;
|
|
17
23
|
description: string;
|
|
18
24
|
onComplete(result: FITFileType, context: FITContext): Promise<FITFileType>;
|
|
19
25
|
private validateFIT;
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Data cleanup middleware
|
|
29
|
+
*/
|
|
21
30
|
export declare class DataCleanupMiddleware extends BaseFITMiddleware {
|
|
22
31
|
name: string;
|
|
23
32
|
description: string;
|
|
24
33
|
onStructure(result: Partial<FITFileType>, context: FITContext): Promise<Partial<FITFileType>>;
|
|
25
34
|
private cleanupData;
|
|
26
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* File information extraction middleware
|
|
38
|
+
*/
|
|
27
39
|
export declare class FileInfoMiddleware extends BaseFITMiddleware {
|
|
28
40
|
name: string;
|
|
29
41
|
description: string;
|
|
30
42
|
onExtractMessages(messages: FITDecoderMesgs, context: FITContext): Promise<FITDecoderMesgs>;
|
|
31
43
|
private extractFileInfo;
|
|
32
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Register all default middlewares
|
|
47
|
+
*/
|
|
33
48
|
export declare function registerDefaultMiddlewares(decoder: any): Promise<void>;
|
package/dist/FIT/plugins.d.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { BaseFITStructurePlugin } from "./base.js";
|
|
2
2
|
import { FITDecoderMesgs, FITFileType, FITContext } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Session data structuring plugin
|
|
5
|
+
*/
|
|
3
6
|
export declare class SessionStructurePlugin extends BaseFITStructurePlugin {
|
|
4
7
|
name: string;
|
|
5
8
|
priority: number;
|
|
6
9
|
structureData(messages: FITDecoderMesgs, context: FITContext): Partial<FITFileType>;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Course data structuring plugin
|
|
13
|
+
*/
|
|
8
14
|
export declare class CourseStructurePlugin extends BaseFITStructurePlugin {
|
|
9
15
|
name: string;
|
|
10
16
|
priority: number;
|
|
11
17
|
structureData(messages: FITDecoderMesgs, context: FITContext): Partial<FITFileType>;
|
|
12
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* File header information extraction plugin
|
|
21
|
+
*/
|
|
13
22
|
export declare class FileHeaderPlugin extends BaseFITStructurePlugin {
|
|
14
23
|
name: string;
|
|
15
24
|
priority: number;
|
package/dist/FIT/processor.d.ts
CHANGED
|
@@ -1,34 +1,58 @@
|
|
|
1
1
|
import { IFITMessageConverter, IFITStructurePlugin } from "./base.js";
|
|
2
2
|
import { FITContext } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* FIT pipeline stages
|
|
5
|
+
*/
|
|
3
6
|
export declare enum FITPipelineStage {
|
|
4
7
|
PARSE = "parse",
|
|
5
8
|
EXTRACT = "extract",
|
|
6
9
|
STRUCTURE = "structure",
|
|
7
10
|
COMPLETE = "complete"
|
|
8
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* FIT pipeline processor interface
|
|
14
|
+
*/
|
|
9
15
|
export interface IFITPipelineProcessor {
|
|
10
16
|
stage: FITPipelineStage;
|
|
11
17
|
process(context: FITContext): Promise<FITContext>;
|
|
12
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse processor - parses binary FIT data to messages
|
|
21
|
+
*/
|
|
13
22
|
export declare class ParseProcessor implements IFITPipelineProcessor {
|
|
14
23
|
stage: FITPipelineStage;
|
|
15
24
|
process(context: FITContext): Promise<FITContext>;
|
|
25
|
+
/**
|
|
26
|
+
* Parse binary data using FIT SDK
|
|
27
|
+
*/
|
|
16
28
|
private parseWithFitSDK;
|
|
17
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Extract processor - extracts and converts messages
|
|
32
|
+
*/
|
|
18
33
|
export declare class ExtractProcessor implements IFITPipelineProcessor {
|
|
19
34
|
private getConverters;
|
|
20
35
|
stage: FITPipelineStage;
|
|
21
36
|
constructor(getConverters: (messageType: string) => IFITMessageConverter[]);
|
|
22
37
|
process(context: FITContext): Promise<FITContext>;
|
|
23
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Structure processor - data structuring
|
|
41
|
+
*/
|
|
24
42
|
export declare class StructureProcessor implements IFITPipelineProcessor {
|
|
25
43
|
private getStructurePlugins;
|
|
26
44
|
stage: FITPipelineStage;
|
|
27
45
|
constructor(getStructurePlugins: () => IFITStructurePlugin[]);
|
|
28
46
|
process(context: FITContext): Promise<FITContext>;
|
|
29
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Complete processor - final processing and cleanup
|
|
50
|
+
*/
|
|
30
51
|
export declare class CompleteProcessor implements IFITPipelineProcessor {
|
|
31
52
|
stage: FITPipelineStage;
|
|
32
53
|
process(context: FITContext): Promise<FITContext>;
|
|
54
|
+
/**
|
|
55
|
+
* Count total messages
|
|
56
|
+
*/
|
|
33
57
|
private countTotalMessages;
|
|
34
58
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export declare enum ChecksumType {
|
|
2
|
+
/**
|
|
3
|
+
* Allows clear of checksum for flash memory where can only write 1 to 0 without erasing sector.
|
|
4
|
+
*/
|
|
2
5
|
CLEAR = 0,
|
|
6
|
+
/**
|
|
7
|
+
* Set to mark checksum as valid if computes to invalid values 0 or 0xFF. Checksum can also be set to ok to save encoding computation time.
|
|
8
|
+
*/
|
|
3
9
|
OK = 1
|
|
4
10
|
}
|
package/dist/FIT/types/file.d.ts
CHANGED
|
@@ -1,23 +1,86 @@
|
|
|
1
1
|
export declare enum FITFile {
|
|
2
|
+
/**
|
|
3
|
+
* device(只读、单文件、必须在根目录)
|
|
4
|
+
*/
|
|
2
5
|
DEVICE = 1,
|
|
6
|
+
/**
|
|
7
|
+
* settings(读写、单文件、Directory=Settings)
|
|
8
|
+
*/
|
|
3
9
|
SETTINGS = 2,
|
|
10
|
+
/**
|
|
11
|
+
* sport(读写、多文件、file number = sport type、Directory=Sports)
|
|
12
|
+
*/
|
|
4
13
|
SPORT = 3,
|
|
14
|
+
/**
|
|
15
|
+
* activity(读/擦除、多文件、Directory=Activities)
|
|
16
|
+
*/
|
|
5
17
|
ACTIVITY = 4,
|
|
18
|
+
/**
|
|
19
|
+
* workout(读写/擦除、多文件、Directory=Workouts)
|
|
20
|
+
*/
|
|
6
21
|
WORKOUT = 5,
|
|
22
|
+
/**
|
|
23
|
+
* course(读写/擦除、多文件、Directory=Courses)
|
|
24
|
+
*/
|
|
7
25
|
COURSE = 6,
|
|
26
|
+
/**
|
|
27
|
+
* schedules(读写、单文件、Directory=Schedules)
|
|
28
|
+
*/
|
|
8
29
|
SCHEDULES = 7,
|
|
30
|
+
/**
|
|
31
|
+
* weight(只读、单文件、环形缓冲、所有消息定义在文件开头、Directory=Weight)
|
|
32
|
+
*/
|
|
9
33
|
WEIGHT = 9,
|
|
34
|
+
/**
|
|
35
|
+
* totals(只读、单文件、Directory=Totals)
|
|
36
|
+
*/
|
|
10
37
|
TOTALS = 10,
|
|
38
|
+
/**
|
|
39
|
+
* goals(读写、单文件、Directory=Goals)
|
|
40
|
+
*/
|
|
11
41
|
GOALS = 11,
|
|
42
|
+
/**
|
|
43
|
+
* bloodPressure(只读、Directory=Blood Pressure)
|
|
44
|
+
*/
|
|
12
45
|
BLOOD_PRESSURE = 14,
|
|
46
|
+
/**
|
|
47
|
+
* monitoringA(只读、Directory=Monitoring、file number=sub type)
|
|
48
|
+
*/
|
|
13
49
|
MONITORING_A = 15,
|
|
50
|
+
/**
|
|
51
|
+
* activitySummary(读/擦除、多文件、Directory=Activities)
|
|
52
|
+
*/
|
|
14
53
|
ACTIVITY_SUMMARY = 20,
|
|
54
|
+
/**
|
|
55
|
+
* monitoringDaily
|
|
56
|
+
*/
|
|
15
57
|
MONITORING_DAILY = 28,
|
|
58
|
+
/**
|
|
59
|
+
* monitoringB(只读、Directory=Monitoring、file number=identifier)
|
|
60
|
+
*/
|
|
16
61
|
MONITORING_B = 32,
|
|
62
|
+
/**
|
|
63
|
+
* segment(读写/擦除、多文件、Directory=Segments)
|
|
64
|
+
*/
|
|
17
65
|
SEGMENT = 34,
|
|
66
|
+
/**
|
|
67
|
+
* segmentList(读写/擦除、单文件、Directory=Segments)
|
|
68
|
+
*/
|
|
18
69
|
SEGMENT_LIST = 35,
|
|
70
|
+
/**
|
|
71
|
+
* exdConfiguration(读写/擦除、单文件、Directory=Settings)
|
|
72
|
+
*/
|
|
19
73
|
EXD_CONFIGURATION = 40,
|
|
74
|
+
/**
|
|
75
|
+
* mfgRangeMin(0xF7 - 0xFE 保留给厂商自定义 file types)
|
|
76
|
+
*/
|
|
20
77
|
MFG_RANGE_MIN = 247,
|
|
78
|
+
/**
|
|
79
|
+
* mfgRangeMax(0xF7 - 0xFE 保留给厂商自定义 file types)
|
|
80
|
+
*/
|
|
21
81
|
MFG_RANGE_MAX = 254,
|
|
82
|
+
/**
|
|
83
|
+
* invalid
|
|
84
|
+
*/
|
|
22
85
|
INVALID = 255
|
|
23
86
|
}
|