@tryterra/react-native 2.1.0 → 2.2.1
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 +31 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Conversions.kt +103 -14
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/ReadConversions.kt +250 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeOpsImpl.kt +47 -5
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeStreamsImpl.kt +1 -3
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeOps.kt +89 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeTypes.kt +672 -0
- package/docs/availability.md +154 -4
- package/frameworks/TerraSDK.xcframework/Info.plist +5 -5
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Info.plist +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.abi.json +1385 -226
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.package.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +2 -2
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/DWARF/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/TerraSDK.yml +6589 -6468
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Info.plist +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1385 -226
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1385 -226
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +37 -1
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/_CodeSignature/CodeResources +21 -21
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +2 -2
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/DWARF/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/TerraSDK.yml +6590 -6469
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/TerraSDK.yml +6508 -6387
- package/ios/TerraBridgeCore/Conversions+Reads.swift +259 -0
- package/ios/TerraBridgeCore/Conversions.swift +129 -2
- package/ios/TerraBridgeCore/Generated/BridgeOps.swift +172 -0
- package/ios/TerraBridgeCore/Generated/BridgeTypes.swift +734 -1
- package/ios/TerraBridgeCore/TerraBridgeOpsImpl.swift +64 -0
- package/lib/Terra.d.ts +74 -5
- package/lib/Terra.js +69 -13
- package/lib/generated/client.d.ts +37 -1
- package/lib/generated/client.js +60 -0
- package/lib/generated/codecs.d.ts +85 -1
- package/lib/generated/codecs.js +710 -2
- package/lib/generated/ops.d.ts +1 -1
- package/lib/generated/ops.js +24 -0
- package/lib/generated/types.d.ts +314 -1
- package/lib/generated/types.js +133 -1
- package/lib/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/Terra.ts +146 -16
- package/src/generated/client.ts +74 -2
- package/src/generated/codecs.ts +705 -3
- package/src/generated/ops.ts +36 -0
- package/src/generated/types.ts +556 -1
- package/src/index.ts +2 -0
package/lib/generated/codecs.js
CHANGED
|
@@ -6,11 +6,27 @@ exports.asSource = asSource;
|
|
|
6
6
|
exports.asDataCategory = asDataCategory;
|
|
7
7
|
exports.asPermissionStatus = asPermissionStatus;
|
|
8
8
|
exports.asMotionContext = asMotionContext;
|
|
9
|
+
exports.asNutrient = asNutrient;
|
|
10
|
+
exports.asMealType = asMealType;
|
|
11
|
+
exports.asMenstruationFlow = asMenstruationFlow;
|
|
12
|
+
exports.asBiologicalSex = asBiologicalSex;
|
|
13
|
+
exports.asActivityMoveMode = asActivityMoveMode;
|
|
9
14
|
exports.asBackgroundRestrictionReason = asBackgroundRestrictionReason;
|
|
10
15
|
exports.asDiagnosticsReason = asDiagnosticsReason;
|
|
11
16
|
exports.asDeviceKeyRevokeOutcome = asDeviceKeyRevokeOutcome;
|
|
12
17
|
exports.asFailureCode = asFailureCode;
|
|
13
18
|
exports.asWorkoutSchedulingStatus = asWorkoutSchedulingStatus;
|
|
19
|
+
exports.asDayTotalMetric = asDayTotalMetric;
|
|
20
|
+
exports.asIntradayMetric = asIntradayMetric;
|
|
21
|
+
exports.asWorkoutIntensityMetric = asWorkoutIntensityMetric;
|
|
22
|
+
exports.asBodyMetric = asBodyMetric;
|
|
23
|
+
exports.asBloodGlucoseUnit = asBloodGlucoseUnit;
|
|
24
|
+
exports.asGlucoseMealTime = asGlucoseMealTime;
|
|
25
|
+
exports.asGlucoseSpecimen = asGlucoseSpecimen;
|
|
26
|
+
exports.asBodyTemperatureMetric = asBodyTemperatureMetric;
|
|
27
|
+
exports.asHeartRateVariabilityMetric = asHeartRateVariabilityMetric;
|
|
28
|
+
exports.asVO2MaxTestType = asVO2MaxTestType;
|
|
29
|
+
exports.asMenstrualEventKind = asMenstrualEventKind;
|
|
14
30
|
exports.encodeSampleSource = encodeSampleSource;
|
|
15
31
|
exports.decodeSampleSource = decodeSampleSource;
|
|
16
32
|
exports.encodeConnection = encodeConnection;
|
|
@@ -23,6 +39,12 @@ exports.encodeSleepSegment = encodeSleepSegment;
|
|
|
23
39
|
exports.decodeSleepSegment = decodeSleepSegment;
|
|
24
40
|
exports.encodeWorkout = encodeWorkout;
|
|
25
41
|
exports.decodeWorkout = decodeWorkout;
|
|
42
|
+
exports.encodeDietaryQuantity = encodeDietaryQuantity;
|
|
43
|
+
exports.decodeDietaryQuantity = decodeDietaryQuantity;
|
|
44
|
+
exports.encodeMenstruationFlowDay = encodeMenstruationFlowDay;
|
|
45
|
+
exports.decodeMenstruationFlowDay = decodeMenstruationFlowDay;
|
|
46
|
+
exports.encodeAthleteProfile = encodeAthleteProfile;
|
|
47
|
+
exports.decodeAthleteProfile = decodeAthleteProfile;
|
|
26
48
|
exports.encodeHealthChange = encodeHealthChange;
|
|
27
49
|
exports.decodeHealthChange = decodeHealthChange;
|
|
28
50
|
exports.encodeWorkoutScope = encodeWorkoutScope;
|
|
@@ -97,6 +119,16 @@ exports.encodeSleepSegmentList = encodeSleepSegmentList;
|
|
|
97
119
|
exports.decodeSleepSegmentList = decodeSleepSegmentList;
|
|
98
120
|
exports.encodeWorkoutList = encodeWorkoutList;
|
|
99
121
|
exports.decodeWorkoutList = decodeWorkoutList;
|
|
122
|
+
exports.encodeDietaryQuantityList = encodeDietaryQuantityList;
|
|
123
|
+
exports.decodeDietaryQuantityList = decodeDietaryQuantityList;
|
|
124
|
+
exports.encodeMenstruationFlowDayList = encodeMenstruationFlowDayList;
|
|
125
|
+
exports.decodeMenstruationFlowDayList = decodeMenstruationFlowDayList;
|
|
126
|
+
exports.encodeMenstrualEvent = encodeMenstrualEvent;
|
|
127
|
+
exports.decodeMenstrualEvent = decodeMenstrualEvent;
|
|
128
|
+
exports.encodeMenstrualEventList = encodeMenstrualEventList;
|
|
129
|
+
exports.decodeMenstrualEventList = decodeMenstrualEventList;
|
|
130
|
+
exports.encodeAthleteProfileResult = encodeAthleteProfileResult;
|
|
131
|
+
exports.decodeAthleteProfileResult = decodeAthleteProfileResult;
|
|
100
132
|
exports.encodePlannedWorkoutList = encodePlannedWorkoutList;
|
|
101
133
|
exports.decodePlannedWorkoutList = decodePlannedWorkoutList;
|
|
102
134
|
exports.encodeWorkoutScheduling = encodeWorkoutScheduling;
|
|
@@ -115,6 +147,38 @@ exports.encodeWorkoutEntryList = encodeWorkoutEntryList;
|
|
|
115
147
|
exports.decodeWorkoutEntryList = decodeWorkoutEntryList;
|
|
116
148
|
exports.encodeNutritionEntryList = encodeNutritionEntryList;
|
|
117
149
|
exports.decodeNutritionEntryList = decodeNutritionEntryList;
|
|
150
|
+
exports.encodeDayTotal = encodeDayTotal;
|
|
151
|
+
exports.decodeDayTotal = decodeDayTotal;
|
|
152
|
+
exports.encodeIntradaySample = encodeIntradaySample;
|
|
153
|
+
exports.decodeIntradaySample = decodeIntradaySample;
|
|
154
|
+
exports.encodeRestingHeartRateSample = encodeRestingHeartRateSample;
|
|
155
|
+
exports.decodeRestingHeartRateSample = decodeRestingHeartRateSample;
|
|
156
|
+
exports.encodeBodyReading = encodeBodyReading;
|
|
157
|
+
exports.decodeBodyReading = decodeBodyReading;
|
|
158
|
+
exports.encodeRoutePoint = encodeRoutePoint;
|
|
159
|
+
exports.decodeRoutePoint = decodeRoutePoint;
|
|
160
|
+
exports.encodeWorkoutRoute = encodeWorkoutRoute;
|
|
161
|
+
exports.decodeWorkoutRoute = decodeWorkoutRoute;
|
|
162
|
+
exports.encodeWorkoutIntensitySample = encodeWorkoutIntensitySample;
|
|
163
|
+
exports.decodeWorkoutIntensitySample = decodeWorkoutIntensitySample;
|
|
164
|
+
exports.encodeHydrationSample = encodeHydrationSample;
|
|
165
|
+
exports.decodeHydrationSample = decodeHydrationSample;
|
|
166
|
+
exports.encodeDayTotalList = encodeDayTotalList;
|
|
167
|
+
exports.decodeDayTotalList = decodeDayTotalList;
|
|
168
|
+
exports.encodeIntradaySampleList = encodeIntradaySampleList;
|
|
169
|
+
exports.decodeIntradaySampleList = decodeIntradaySampleList;
|
|
170
|
+
exports.encodeRestingHeartRateList = encodeRestingHeartRateList;
|
|
171
|
+
exports.decodeRestingHeartRateList = decodeRestingHeartRateList;
|
|
172
|
+
exports.encodeBodyReadingList = encodeBodyReadingList;
|
|
173
|
+
exports.decodeBodyReadingList = decodeBodyReadingList;
|
|
174
|
+
exports.encodeWorkoutRouteList = encodeWorkoutRouteList;
|
|
175
|
+
exports.decodeWorkoutRouteList = decodeWorkoutRouteList;
|
|
176
|
+
exports.encodeWorkoutIntensityList = encodeWorkoutIntensityList;
|
|
177
|
+
exports.decodeWorkoutIntensityList = decodeWorkoutIntensityList;
|
|
178
|
+
exports.encodeHydrationList = encodeHydrationList;
|
|
179
|
+
exports.decodeHydrationList = decodeHydrationList;
|
|
180
|
+
exports.encodeAvailabilityResult = encodeAvailabilityResult;
|
|
181
|
+
exports.decodeAvailabilityResult = decodeAvailabilityResult;
|
|
118
182
|
exports.encodeEndUser = encodeEndUser;
|
|
119
183
|
exports.decodeEndUser = decodeEndUser;
|
|
120
184
|
exports.encodeTimeRange = encodeTimeRange;
|
|
@@ -127,6 +191,10 @@ exports.encodeDiagnosticsState = encodeDiagnosticsState;
|
|
|
127
191
|
exports.decodeDiagnosticsState = decodeDiagnosticsState;
|
|
128
192
|
exports.encodeStreamMessage = encodeStreamMessage;
|
|
129
193
|
exports.decodeStreamMessage = decodeStreamMessage;
|
|
194
|
+
exports.encodeBodyReadingKind = encodeBodyReadingKind;
|
|
195
|
+
exports.decodeBodyReadingKind = decodeBodyReadingKind;
|
|
196
|
+
exports.encodeStoreAvailability = encodeStoreAvailability;
|
|
197
|
+
exports.decodeStoreAvailability = decodeStoreAvailability;
|
|
130
198
|
function encodeInstant(value) {
|
|
131
199
|
return value.toISOString();
|
|
132
200
|
}
|
|
@@ -197,7 +265,7 @@ function asSource(value, at = "Source") {
|
|
|
197
265
|
}
|
|
198
266
|
return value;
|
|
199
267
|
}
|
|
200
|
-
const DataCategoryCases = new Set(["activity", "body", "daily", "sleep", "nutrition"]);
|
|
268
|
+
const DataCategoryCases = new Set(["activity", "body", "daily", "sleep", "nutrition", "menstruation", "athlete"]);
|
|
201
269
|
/** Narrows an untyped value to DataCategory, or throws naming the field. */
|
|
202
270
|
function asDataCategory(value, at = "DataCategory") {
|
|
203
271
|
if (typeof value !== "string" || !DataCategoryCases.has(value)) {
|
|
@@ -223,6 +291,48 @@ function asMotionContext(value, at = "MotionContext") {
|
|
|
223
291
|
return "unknown";
|
|
224
292
|
return value;
|
|
225
293
|
}
|
|
294
|
+
const NutrientCases = new Set(["energyConsumed", "protein", "carbohydrates", "fatTotal", "fatSaturated", "fatMonounsaturated", "fatPolyunsaturated", "sugar", "fiber", "cholesterol", "sodium", "potassium", "calcium", "iron", "magnesium", "zinc", "phosphorus", "iodine", "manganese", "molybdenum", "selenium", "copper", "chromium", "chloride", "caffeine", "vitaminA", "vitaminC", "vitaminD", "vitaminE", "vitaminK", "vitaminB6", "vitaminB12", "thiamin", "riboflavin", "niacin", "folate", "biotin", "pantothenicAcid"]);
|
|
295
|
+
/** Narrows an untyped value to Nutrient, or throws naming the field. */
|
|
296
|
+
function asNutrient(value, at = "Nutrient") {
|
|
297
|
+
if (typeof value !== "string" || !NutrientCases.has(value)) {
|
|
298
|
+
throw new TypeError(`${at}: ${String(value)} is not a Nutrient`);
|
|
299
|
+
}
|
|
300
|
+
return value;
|
|
301
|
+
}
|
|
302
|
+
const MealTypeCases = new Set(["breakfast", "lunch", "dinner", "snack", "unknown"]);
|
|
303
|
+
/** Narrows an untyped value to MealType. A string it does not name is `unknown`; anything else throws. */
|
|
304
|
+
function asMealType(value, at = "MealType") {
|
|
305
|
+
if (typeof value !== "string") {
|
|
306
|
+
throw new TypeError(`${at}: ${String(value)} is not a MealType`);
|
|
307
|
+
}
|
|
308
|
+
if (!MealTypeCases.has(value))
|
|
309
|
+
return "unknown";
|
|
310
|
+
return value;
|
|
311
|
+
}
|
|
312
|
+
const MenstruationFlowCases = new Set(["unspecified", "light", "medium", "heavy", "none"]);
|
|
313
|
+
/** Narrows an untyped value to MenstruationFlow, or throws naming the field. */
|
|
314
|
+
function asMenstruationFlow(value, at = "MenstruationFlow") {
|
|
315
|
+
if (typeof value !== "string" || !MenstruationFlowCases.has(value)) {
|
|
316
|
+
throw new TypeError(`${at}: ${String(value)} is not a MenstruationFlow`);
|
|
317
|
+
}
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
const BiologicalSexCases = new Set(["female", "male", "other", "notSet"]);
|
|
321
|
+
/** Narrows an untyped value to BiologicalSex, or throws naming the field. */
|
|
322
|
+
function asBiologicalSex(value, at = "BiologicalSex") {
|
|
323
|
+
if (typeof value !== "string" || !BiologicalSexCases.has(value)) {
|
|
324
|
+
throw new TypeError(`${at}: ${String(value)} is not a BiologicalSex`);
|
|
325
|
+
}
|
|
326
|
+
return value;
|
|
327
|
+
}
|
|
328
|
+
const ActivityMoveModeCases = new Set(["activeEnergy", "appleMoveTime"]);
|
|
329
|
+
/** Narrows an untyped value to ActivityMoveMode, or throws naming the field. */
|
|
330
|
+
function asActivityMoveMode(value, at = "ActivityMoveMode") {
|
|
331
|
+
if (typeof value !== "string" || !ActivityMoveModeCases.has(value)) {
|
|
332
|
+
throw new TypeError(`${at}: ${String(value)} is not a ActivityMoveMode`);
|
|
333
|
+
}
|
|
334
|
+
return value;
|
|
335
|
+
}
|
|
226
336
|
const BackgroundRestrictionReasonCases = new Set(["oemRestricted", "backgroundReadDenied", "healthConnectFeatureUnavailable", "storeFeatureUnavailable", "ticksNotRunning"]);
|
|
227
337
|
/** Narrows an untyped value to BackgroundRestrictionReason, or throws naming the field. */
|
|
228
338
|
function asBackgroundRestrictionReason(value, at = "BackgroundRestrictionReason") {
|
|
@@ -263,6 +373,98 @@ function asWorkoutSchedulingStatus(value, at = "WorkoutSchedulingStatus") {
|
|
|
263
373
|
}
|
|
264
374
|
return value;
|
|
265
375
|
}
|
|
376
|
+
const DayTotalMetricCases = new Set(["distanceWalkingRunning", "distanceCycling", "distanceSwimming", "distanceWheelchair", "activeEnergyBurned", "basalEnergyBurned", "flightsClimbed", "appleExerciseTime"]);
|
|
377
|
+
/** Narrows an untyped value to DayTotalMetric, or throws naming the field. */
|
|
378
|
+
function asDayTotalMetric(value, at = "DayTotalMetric") {
|
|
379
|
+
if (typeof value !== "string" || !DayTotalMetricCases.has(value)) {
|
|
380
|
+
throw new TypeError(`${at}: ${String(value)} is not a DayTotalMetric`);
|
|
381
|
+
}
|
|
382
|
+
return value;
|
|
383
|
+
}
|
|
384
|
+
const IntradayMetricCases = new Set(["activeEnergy", "basalEnergy", "distance", "floorsClimbed"]);
|
|
385
|
+
/** Narrows an untyped value to IntradayMetric, or throws naming the field. */
|
|
386
|
+
function asIntradayMetric(value, at = "IntradayMetric") {
|
|
387
|
+
if (typeof value !== "string" || !IntradayMetricCases.has(value)) {
|
|
388
|
+
throw new TypeError(`${at}: ${String(value)} is not a IntradayMetric`);
|
|
389
|
+
}
|
|
390
|
+
return value;
|
|
391
|
+
}
|
|
392
|
+
const WorkoutIntensityMetricCases = new Set(["speed", "power", "cadence"]);
|
|
393
|
+
/** Narrows an untyped value to WorkoutIntensityMetric, or throws naming the field. */
|
|
394
|
+
function asWorkoutIntensityMetric(value, at = "WorkoutIntensityMetric") {
|
|
395
|
+
if (typeof value !== "string" || !WorkoutIntensityMetricCases.has(value)) {
|
|
396
|
+
throw new TypeError(`${at}: ${String(value)} is not a WorkoutIntensityMetric`);
|
|
397
|
+
}
|
|
398
|
+
return value;
|
|
399
|
+
}
|
|
400
|
+
const BodyMetricCases = new Set(["weight", "height", "bodyFatPercentage", "leanBodyMass", "bmi"]);
|
|
401
|
+
/** Narrows an untyped value to BodyMetric, or throws naming the field. */
|
|
402
|
+
function asBodyMetric(value, at = "BodyMetric") {
|
|
403
|
+
if (typeof value !== "string" || !BodyMetricCases.has(value)) {
|
|
404
|
+
throw new TypeError(`${at}: ${String(value)} is not a BodyMetric`);
|
|
405
|
+
}
|
|
406
|
+
return value;
|
|
407
|
+
}
|
|
408
|
+
const BloodGlucoseUnitCases = new Set(["mg/dL", "mmol/L"]);
|
|
409
|
+
/** Narrows an untyped value to BloodGlucoseUnit, or throws naming the field. */
|
|
410
|
+
function asBloodGlucoseUnit(value, at = "BloodGlucoseUnit") {
|
|
411
|
+
if (typeof value !== "string" || !BloodGlucoseUnitCases.has(value)) {
|
|
412
|
+
throw new TypeError(`${at}: ${String(value)} is not a BloodGlucoseUnit`);
|
|
413
|
+
}
|
|
414
|
+
return value;
|
|
415
|
+
}
|
|
416
|
+
const GlucoseMealTimeCases = new Set(["preprandial", "postprandial", "unknown"]);
|
|
417
|
+
/** Narrows an untyped value to GlucoseMealTime. A string it does not name is `unknown`; anything else throws. */
|
|
418
|
+
function asGlucoseMealTime(value, at = "GlucoseMealTime") {
|
|
419
|
+
if (typeof value !== "string") {
|
|
420
|
+
throw new TypeError(`${at}: ${String(value)} is not a GlucoseMealTime`);
|
|
421
|
+
}
|
|
422
|
+
if (!GlucoseMealTimeCases.has(value))
|
|
423
|
+
return "unknown";
|
|
424
|
+
return value;
|
|
425
|
+
}
|
|
426
|
+
const GlucoseSpecimenCases = new Set(["capillary", "interstitial", "plasma", "serum", "tears", "wholeBlood", "unknown"]);
|
|
427
|
+
/** Narrows an untyped value to GlucoseSpecimen. A string it does not name is `unknown`; anything else throws. */
|
|
428
|
+
function asGlucoseSpecimen(value, at = "GlucoseSpecimen") {
|
|
429
|
+
if (typeof value !== "string") {
|
|
430
|
+
throw new TypeError(`${at}: ${String(value)} is not a GlucoseSpecimen`);
|
|
431
|
+
}
|
|
432
|
+
if (!GlucoseSpecimenCases.has(value))
|
|
433
|
+
return "unknown";
|
|
434
|
+
return value;
|
|
435
|
+
}
|
|
436
|
+
const BodyTemperatureMetricCases = new Set(["body", "basal", "wrist", "skin"]);
|
|
437
|
+
/** Narrows an untyped value to BodyTemperatureMetric, or throws naming the field. */
|
|
438
|
+
function asBodyTemperatureMetric(value, at = "BodyTemperatureMetric") {
|
|
439
|
+
if (typeof value !== "string" || !BodyTemperatureMetricCases.has(value)) {
|
|
440
|
+
throw new TypeError(`${at}: ${String(value)} is not a BodyTemperatureMetric`);
|
|
441
|
+
}
|
|
442
|
+
return value;
|
|
443
|
+
}
|
|
444
|
+
const HeartRateVariabilityMetricCases = new Set(["sdnn", "rmssd"]);
|
|
445
|
+
/** Narrows an untyped value to HeartRateVariabilityMetric, or throws naming the field. */
|
|
446
|
+
function asHeartRateVariabilityMetric(value, at = "HeartRateVariabilityMetric") {
|
|
447
|
+
if (typeof value !== "string" || !HeartRateVariabilityMetricCases.has(value)) {
|
|
448
|
+
throw new TypeError(`${at}: ${String(value)} is not a HeartRateVariabilityMetric`);
|
|
449
|
+
}
|
|
450
|
+
return value;
|
|
451
|
+
}
|
|
452
|
+
const VO2MaxTestTypeCases = new Set(["maxExercise", "predictedSubMaxExercise", "predictedNonExercise"]);
|
|
453
|
+
/** Narrows an untyped value to VO2MaxTestType, or throws naming the field. */
|
|
454
|
+
function asVO2MaxTestType(value, at = "VO2MaxTestType") {
|
|
455
|
+
if (typeof value !== "string" || !VO2MaxTestTypeCases.has(value)) {
|
|
456
|
+
throw new TypeError(`${at}: ${String(value)} is not a VO2MaxTestType`);
|
|
457
|
+
}
|
|
458
|
+
return value;
|
|
459
|
+
}
|
|
460
|
+
const MenstrualEventKindCases = new Set(["intermenstrualBleeding", "ovulationTest", "cervicalMucus"]);
|
|
461
|
+
/** Narrows an untyped value to MenstrualEventKind, or throws naming the field. */
|
|
462
|
+
function asMenstrualEventKind(value, at = "MenstrualEventKind") {
|
|
463
|
+
if (typeof value !== "string" || !MenstrualEventKindCases.has(value)) {
|
|
464
|
+
throw new TypeError(`${at}: ${String(value)} is not a MenstrualEventKind`);
|
|
465
|
+
}
|
|
466
|
+
return value;
|
|
467
|
+
}
|
|
266
468
|
function encodeSampleSource(value) {
|
|
267
469
|
const out = {};
|
|
268
470
|
out.name = value.name;
|
|
@@ -384,6 +586,8 @@ function encodeWorkout(value) {
|
|
|
384
586
|
out.userEntered = value.userEntered;
|
|
385
587
|
if (value.timeZone !== undefined)
|
|
386
588
|
out.timeZone = value.timeZone;
|
|
589
|
+
if (value.title !== undefined)
|
|
590
|
+
out.title = value.title;
|
|
387
591
|
return out;
|
|
388
592
|
}
|
|
389
593
|
function decodeWorkout(raw, at$ = "Workout") {
|
|
@@ -399,7 +603,85 @@ function decodeWorkout(raw, at$ = "Workout") {
|
|
|
399
603
|
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
400
604
|
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
401
605
|
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
402
|
-
|
|
606
|
+
const title = optional(object.title, (value) => asString(value, `${at$}.title`));
|
|
607
|
+
return { id, start, end, activity, activityTypeCode, indoor, activeEnergyKilocalories, distanceMeters, source, userEntered, timeZone, title };
|
|
608
|
+
}
|
|
609
|
+
function encodeDietaryQuantity(value) {
|
|
610
|
+
const out = {};
|
|
611
|
+
out.id = value.id;
|
|
612
|
+
out.nutrient = value.nutrient;
|
|
613
|
+
out.value = value.value;
|
|
614
|
+
out.start = encodeInstant(value.start);
|
|
615
|
+
out.end = encodeInstant(value.end);
|
|
616
|
+
out.mealType = value.mealType;
|
|
617
|
+
if (value.name !== undefined)
|
|
618
|
+
out.name = value.name;
|
|
619
|
+
if (value.foodCorrelationId !== undefined)
|
|
620
|
+
out.foodCorrelationId = value.foodCorrelationId;
|
|
621
|
+
out.source = encodeSampleSource(value.source);
|
|
622
|
+
out.userEntered = value.userEntered;
|
|
623
|
+
if (value.timeZone !== undefined)
|
|
624
|
+
out.timeZone = value.timeZone;
|
|
625
|
+
return out;
|
|
626
|
+
}
|
|
627
|
+
function decodeDietaryQuantity(raw, at$ = "DietaryQuantity") {
|
|
628
|
+
const object = asObject(raw, at$);
|
|
629
|
+
const id = asString(object.id, `${at$}.id`);
|
|
630
|
+
const nutrient = asNutrient(object.nutrient, `${at$}.nutrient`);
|
|
631
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
632
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
633
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
634
|
+
const mealType = asMealType(object.mealType, `${at$}.mealType`);
|
|
635
|
+
const name = optional(object.name, (value) => asString(value, `${at$}.name`));
|
|
636
|
+
const foodCorrelationId = optional(object.foodCorrelationId, (value) => asString(value, `${at$}.foodCorrelationId`));
|
|
637
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
638
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
639
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
640
|
+
return { id, nutrient, value, start, end, mealType, name, foodCorrelationId, source, userEntered, timeZone };
|
|
641
|
+
}
|
|
642
|
+
function encodeMenstruationFlowDay(value) {
|
|
643
|
+
const out = {};
|
|
644
|
+
out.id = value.id;
|
|
645
|
+
out.start = encodeInstant(value.start);
|
|
646
|
+
out.end = encodeInstant(value.end);
|
|
647
|
+
out.flow = value.flow;
|
|
648
|
+
out.cycleStart = value.cycleStart;
|
|
649
|
+
out.source = encodeSampleSource(value.source);
|
|
650
|
+
out.userEntered = value.userEntered;
|
|
651
|
+
if (value.timeZone !== undefined)
|
|
652
|
+
out.timeZone = value.timeZone;
|
|
653
|
+
return out;
|
|
654
|
+
}
|
|
655
|
+
function decodeMenstruationFlowDay(raw, at$ = "MenstruationFlowDay") {
|
|
656
|
+
const object = asObject(raw, at$);
|
|
657
|
+
const id = asString(object.id, `${at$}.id`);
|
|
658
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
659
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
660
|
+
const flow = asMenstruationFlow(object.flow, `${at$}.flow`);
|
|
661
|
+
const cycleStart = asBoolean(object.cycleStart, `${at$}.cycleStart`);
|
|
662
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
663
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
664
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
665
|
+
return { id, start, end, flow, cycleStart, source, userEntered, timeZone };
|
|
666
|
+
}
|
|
667
|
+
function encodeAthleteProfile(value) {
|
|
668
|
+
const out = {};
|
|
669
|
+
out.biologicalSex = value.biologicalSex;
|
|
670
|
+
if (value.dateOfBirth !== undefined)
|
|
671
|
+
out.dateOfBirth = value.dateOfBirth;
|
|
672
|
+
if (value.wheelchairUse !== undefined)
|
|
673
|
+
out.wheelchairUse = value.wheelchairUse;
|
|
674
|
+
if (value.activityMoveMode !== undefined)
|
|
675
|
+
out.activityMoveMode = value.activityMoveMode;
|
|
676
|
+
return out;
|
|
677
|
+
}
|
|
678
|
+
function decodeAthleteProfile(raw, at$ = "AthleteProfile") {
|
|
679
|
+
const object = asObject(raw, at$);
|
|
680
|
+
const biologicalSex = asBiologicalSex(object.biologicalSex, `${at$}.biologicalSex`);
|
|
681
|
+
const dateOfBirth = optional(object.dateOfBirth, (value) => asString(value, `${at$}.dateOfBirth`));
|
|
682
|
+
const wheelchairUse = optional(object.wheelchairUse, (value) => asBoolean(value, `${at$}.wheelchairUse`));
|
|
683
|
+
const activityMoveMode = optional(object.activityMoveMode, (value) => asActivityMoveMode(value, `${at$}.activityMoveMode`));
|
|
684
|
+
return { biologicalSex, dateOfBirth, wheelchairUse, activityMoveMode };
|
|
403
685
|
}
|
|
404
686
|
function encodeHealthChange(value) {
|
|
405
687
|
const out = {};
|
|
@@ -1044,6 +1326,73 @@ function decodeWorkoutList(raw, at$ = "WorkoutList") {
|
|
|
1044
1326
|
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeWorkout(item, `${`${at$}.samples`}[${index}]`));
|
|
1045
1327
|
return { samples };
|
|
1046
1328
|
}
|
|
1329
|
+
function encodeDietaryQuantityList(value) {
|
|
1330
|
+
const out = {};
|
|
1331
|
+
out.samples = value.samples.map((item) => encodeDietaryQuantity(item));
|
|
1332
|
+
return out;
|
|
1333
|
+
}
|
|
1334
|
+
function decodeDietaryQuantityList(raw, at$ = "DietaryQuantityList") {
|
|
1335
|
+
const object = asObject(raw, at$);
|
|
1336
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeDietaryQuantity(item, `${`${at$}.samples`}[${index}]`));
|
|
1337
|
+
return { samples };
|
|
1338
|
+
}
|
|
1339
|
+
function encodeMenstruationFlowDayList(value) {
|
|
1340
|
+
const out = {};
|
|
1341
|
+
out.samples = value.samples.map((item) => encodeMenstruationFlowDay(item));
|
|
1342
|
+
return out;
|
|
1343
|
+
}
|
|
1344
|
+
function decodeMenstruationFlowDayList(raw, at$ = "MenstruationFlowDayList") {
|
|
1345
|
+
const object = asObject(raw, at$);
|
|
1346
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeMenstruationFlowDay(item, `${`${at$}.samples`}[${index}]`));
|
|
1347
|
+
return { samples };
|
|
1348
|
+
}
|
|
1349
|
+
function encodeMenstrualEvent(value) {
|
|
1350
|
+
const out = {};
|
|
1351
|
+
out.id = value.id;
|
|
1352
|
+
out.kind = value.kind;
|
|
1353
|
+
out.time = encodeInstant(value.time);
|
|
1354
|
+
if (value.value !== undefined)
|
|
1355
|
+
out.value = value.value;
|
|
1356
|
+
out.storeIdentifier = value.storeIdentifier;
|
|
1357
|
+
out.source = encodeSampleSource(value.source);
|
|
1358
|
+
out.userEntered = value.userEntered;
|
|
1359
|
+
if (value.timeZone !== undefined)
|
|
1360
|
+
out.timeZone = value.timeZone;
|
|
1361
|
+
return out;
|
|
1362
|
+
}
|
|
1363
|
+
function decodeMenstrualEvent(raw, at$ = "MenstrualEvent") {
|
|
1364
|
+
const object = asObject(raw, at$);
|
|
1365
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1366
|
+
const kind = asMenstrualEventKind(object.kind, `${at$}.kind`);
|
|
1367
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
1368
|
+
const value = optional(object.value, (value) => asString(value, `${at$}.value`));
|
|
1369
|
+
const storeIdentifier = asString(object.storeIdentifier, `${at$}.storeIdentifier`);
|
|
1370
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1371
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1372
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1373
|
+
return { id, kind, time, value, storeIdentifier, source, userEntered, timeZone };
|
|
1374
|
+
}
|
|
1375
|
+
function encodeMenstrualEventList(value) {
|
|
1376
|
+
const out = {};
|
|
1377
|
+
out.samples = value.samples.map((item) => encodeMenstrualEvent(item));
|
|
1378
|
+
return out;
|
|
1379
|
+
}
|
|
1380
|
+
function decodeMenstrualEventList(raw, at$ = "MenstrualEventList") {
|
|
1381
|
+
const object = asObject(raw, at$);
|
|
1382
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeMenstrualEvent(item, `${`${at$}.samples`}[${index}]`));
|
|
1383
|
+
return { samples };
|
|
1384
|
+
}
|
|
1385
|
+
function encodeAthleteProfileResult(value) {
|
|
1386
|
+
const out = {};
|
|
1387
|
+
if (value.profile !== undefined)
|
|
1388
|
+
out.profile = encodeAthleteProfile(value.profile);
|
|
1389
|
+
return out;
|
|
1390
|
+
}
|
|
1391
|
+
function decodeAthleteProfileResult(raw, at$ = "AthleteProfileResult") {
|
|
1392
|
+
const object = asObject(raw, at$);
|
|
1393
|
+
const profile = optional(object.profile, (value) => decodeAthleteProfile(value, `${at$}.profile`));
|
|
1394
|
+
return { profile };
|
|
1395
|
+
}
|
|
1047
1396
|
function encodePlannedWorkoutList(value) {
|
|
1048
1397
|
const out = {};
|
|
1049
1398
|
out.workouts = value.workouts.map((item) => encodePlannedWorkout(item));
|
|
@@ -1135,6 +1484,266 @@ function decodeNutritionEntryList(raw, at$ = "NutritionEntryList") {
|
|
|
1135
1484
|
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeNutritionEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1136
1485
|
return { entries };
|
|
1137
1486
|
}
|
|
1487
|
+
function encodeDayTotal(value) {
|
|
1488
|
+
const out = {};
|
|
1489
|
+
out.metric = value.metric;
|
|
1490
|
+
out.start = encodeInstant(value.start);
|
|
1491
|
+
out.end = encodeInstant(value.end);
|
|
1492
|
+
out.value = value.value;
|
|
1493
|
+
out.unit = value.unit;
|
|
1494
|
+
if (value.timeZone !== undefined)
|
|
1495
|
+
out.timeZone = value.timeZone;
|
|
1496
|
+
return out;
|
|
1497
|
+
}
|
|
1498
|
+
function decodeDayTotal(raw, at$ = "DayTotal") {
|
|
1499
|
+
const object = asObject(raw, at$);
|
|
1500
|
+
const metric = asDayTotalMetric(object.metric, `${at$}.metric`);
|
|
1501
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1502
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1503
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
1504
|
+
const unit = asString(object.unit, `${at$}.unit`);
|
|
1505
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1506
|
+
return { metric, start, end, value, unit, timeZone };
|
|
1507
|
+
}
|
|
1508
|
+
function encodeIntradaySample(value) {
|
|
1509
|
+
const out = {};
|
|
1510
|
+
out.id = value.id;
|
|
1511
|
+
out.metric = value.metric;
|
|
1512
|
+
out.start = encodeInstant(value.start);
|
|
1513
|
+
out.end = encodeInstant(value.end);
|
|
1514
|
+
out.value = value.value;
|
|
1515
|
+
out.source = encodeSampleSource(value.source);
|
|
1516
|
+
out.userEntered = value.userEntered;
|
|
1517
|
+
if (value.timeZone !== undefined)
|
|
1518
|
+
out.timeZone = value.timeZone;
|
|
1519
|
+
return out;
|
|
1520
|
+
}
|
|
1521
|
+
function decodeIntradaySample(raw, at$ = "IntradaySample") {
|
|
1522
|
+
const object = asObject(raw, at$);
|
|
1523
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1524
|
+
const metric = asIntradayMetric(object.metric, `${at$}.metric`);
|
|
1525
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1526
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1527
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
1528
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1529
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1530
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1531
|
+
return { id, metric, start, end, value, source, userEntered, timeZone };
|
|
1532
|
+
}
|
|
1533
|
+
function encodeRestingHeartRateSample(value) {
|
|
1534
|
+
const out = {};
|
|
1535
|
+
out.id = value.id;
|
|
1536
|
+
out.start = encodeInstant(value.start);
|
|
1537
|
+
out.end = encodeInstant(value.end);
|
|
1538
|
+
out.beatsPerMinute = value.beatsPerMinute;
|
|
1539
|
+
out.source = encodeSampleSource(value.source);
|
|
1540
|
+
out.userEntered = value.userEntered;
|
|
1541
|
+
if (value.timeZone !== undefined)
|
|
1542
|
+
out.timeZone = value.timeZone;
|
|
1543
|
+
return out;
|
|
1544
|
+
}
|
|
1545
|
+
function decodeRestingHeartRateSample(raw, at$ = "RestingHeartRateSample") {
|
|
1546
|
+
const object = asObject(raw, at$);
|
|
1547
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1548
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1549
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1550
|
+
const beatsPerMinute = asNumber(object.beatsPerMinute, `${at$}.beatsPerMinute`);
|
|
1551
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1552
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1553
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1554
|
+
return { id, start, end, beatsPerMinute, source, userEntered, timeZone };
|
|
1555
|
+
}
|
|
1556
|
+
function encodeBodyReading(value) {
|
|
1557
|
+
const out = {};
|
|
1558
|
+
out.id = value.id;
|
|
1559
|
+
out.kind = encodeBodyReadingKind(value.kind);
|
|
1560
|
+
out.start = encodeInstant(value.start);
|
|
1561
|
+
out.end = encodeInstant(value.end);
|
|
1562
|
+
out.source = encodeSampleSource(value.source);
|
|
1563
|
+
out.userEntered = value.userEntered;
|
|
1564
|
+
if (value.timeZone !== undefined)
|
|
1565
|
+
out.timeZone = value.timeZone;
|
|
1566
|
+
return out;
|
|
1567
|
+
}
|
|
1568
|
+
function decodeBodyReading(raw, at$ = "BodyReading") {
|
|
1569
|
+
const object = asObject(raw, at$);
|
|
1570
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1571
|
+
const kind = decodeBodyReadingKind(object.kind, `${at$}.kind`);
|
|
1572
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1573
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1574
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1575
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1576
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1577
|
+
return { id, kind, start, end, source, userEntered, timeZone };
|
|
1578
|
+
}
|
|
1579
|
+
function encodeRoutePoint(value) {
|
|
1580
|
+
const out = {};
|
|
1581
|
+
out.time = encodeInstant(value.time);
|
|
1582
|
+
out.latitude = value.latitude;
|
|
1583
|
+
out.longitude = value.longitude;
|
|
1584
|
+
return out;
|
|
1585
|
+
}
|
|
1586
|
+
function decodeRoutePoint(raw, at$ = "RoutePoint") {
|
|
1587
|
+
const object = asObject(raw, at$);
|
|
1588
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
1589
|
+
const latitude = asNumber(object.latitude, `${at$}.latitude`);
|
|
1590
|
+
const longitude = asNumber(object.longitude, `${at$}.longitude`);
|
|
1591
|
+
return { time, latitude, longitude };
|
|
1592
|
+
}
|
|
1593
|
+
function encodeWorkoutRoute(value) {
|
|
1594
|
+
const out = {};
|
|
1595
|
+
out.id = value.id;
|
|
1596
|
+
out.workoutId = value.workoutId;
|
|
1597
|
+
out.start = encodeInstant(value.start);
|
|
1598
|
+
out.end = encodeInstant(value.end);
|
|
1599
|
+
out.points = value.points.map((item) => encodeRoutePoint(item));
|
|
1600
|
+
out.source = encodeSampleSource(value.source);
|
|
1601
|
+
if (value.timeZone !== undefined)
|
|
1602
|
+
out.timeZone = value.timeZone;
|
|
1603
|
+
return out;
|
|
1604
|
+
}
|
|
1605
|
+
function decodeWorkoutRoute(raw, at$ = "WorkoutRoute") {
|
|
1606
|
+
const object = asObject(raw, at$);
|
|
1607
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1608
|
+
const workoutId = asString(object.workoutId, `${at$}.workoutId`);
|
|
1609
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1610
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1611
|
+
const points = asArray(object.points, `${at$}.points`).map((item, index) => decodeRoutePoint(item, `${`${at$}.points`}[${index}]`));
|
|
1612
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1613
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1614
|
+
return { id, workoutId, start, end, points, source, timeZone };
|
|
1615
|
+
}
|
|
1616
|
+
function encodeWorkoutIntensitySample(value) {
|
|
1617
|
+
const out = {};
|
|
1618
|
+
out.id = value.id;
|
|
1619
|
+
out.metric = value.metric;
|
|
1620
|
+
if (value.workoutId !== undefined)
|
|
1621
|
+
out.workoutId = value.workoutId;
|
|
1622
|
+
out.start = encodeInstant(value.start);
|
|
1623
|
+
out.end = encodeInstant(value.end);
|
|
1624
|
+
out.value = value.value;
|
|
1625
|
+
out.source = encodeSampleSource(value.source);
|
|
1626
|
+
out.userEntered = value.userEntered;
|
|
1627
|
+
if (value.timeZone !== undefined)
|
|
1628
|
+
out.timeZone = value.timeZone;
|
|
1629
|
+
return out;
|
|
1630
|
+
}
|
|
1631
|
+
function decodeWorkoutIntensitySample(raw, at$ = "WorkoutIntensitySample") {
|
|
1632
|
+
const object = asObject(raw, at$);
|
|
1633
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1634
|
+
const metric = asWorkoutIntensityMetric(object.metric, `${at$}.metric`);
|
|
1635
|
+
const workoutId = optional(object.workoutId, (value) => asString(value, `${at$}.workoutId`));
|
|
1636
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1637
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1638
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
1639
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1640
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1641
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1642
|
+
return { id, metric, workoutId, start, end, value, source, userEntered, timeZone };
|
|
1643
|
+
}
|
|
1644
|
+
function encodeHydrationSample(value) {
|
|
1645
|
+
const out = {};
|
|
1646
|
+
out.id = value.id;
|
|
1647
|
+
out.start = encodeInstant(value.start);
|
|
1648
|
+
out.end = encodeInstant(value.end);
|
|
1649
|
+
out.millilitres = value.millilitres;
|
|
1650
|
+
out.source = encodeSampleSource(value.source);
|
|
1651
|
+
out.userEntered = value.userEntered;
|
|
1652
|
+
if (value.timeZone !== undefined)
|
|
1653
|
+
out.timeZone = value.timeZone;
|
|
1654
|
+
return out;
|
|
1655
|
+
}
|
|
1656
|
+
function decodeHydrationSample(raw, at$ = "HydrationSample") {
|
|
1657
|
+
const object = asObject(raw, at$);
|
|
1658
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1659
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1660
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1661
|
+
const millilitres = asNumber(object.millilitres, `${at$}.millilitres`);
|
|
1662
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1663
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1664
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1665
|
+
return { id, start, end, millilitres, source, userEntered, timeZone };
|
|
1666
|
+
}
|
|
1667
|
+
function encodeDayTotalList(value) {
|
|
1668
|
+
const out = {};
|
|
1669
|
+
out.totals = value.totals.map((item) => encodeDayTotal(item));
|
|
1670
|
+
return out;
|
|
1671
|
+
}
|
|
1672
|
+
function decodeDayTotalList(raw, at$ = "DayTotalList") {
|
|
1673
|
+
const object = asObject(raw, at$);
|
|
1674
|
+
const totals = asArray(object.totals, `${at$}.totals`).map((item, index) => decodeDayTotal(item, `${`${at$}.totals`}[${index}]`));
|
|
1675
|
+
return { totals };
|
|
1676
|
+
}
|
|
1677
|
+
function encodeIntradaySampleList(value) {
|
|
1678
|
+
const out = {};
|
|
1679
|
+
out.samples = value.samples.map((item) => encodeIntradaySample(item));
|
|
1680
|
+
return out;
|
|
1681
|
+
}
|
|
1682
|
+
function decodeIntradaySampleList(raw, at$ = "IntradaySampleList") {
|
|
1683
|
+
const object = asObject(raw, at$);
|
|
1684
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeIntradaySample(item, `${`${at$}.samples`}[${index}]`));
|
|
1685
|
+
return { samples };
|
|
1686
|
+
}
|
|
1687
|
+
function encodeRestingHeartRateList(value) {
|
|
1688
|
+
const out = {};
|
|
1689
|
+
out.samples = value.samples.map((item) => encodeRestingHeartRateSample(item));
|
|
1690
|
+
return out;
|
|
1691
|
+
}
|
|
1692
|
+
function decodeRestingHeartRateList(raw, at$ = "RestingHeartRateList") {
|
|
1693
|
+
const object = asObject(raw, at$);
|
|
1694
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeRestingHeartRateSample(item, `${`${at$}.samples`}[${index}]`));
|
|
1695
|
+
return { samples };
|
|
1696
|
+
}
|
|
1697
|
+
function encodeBodyReadingList(value) {
|
|
1698
|
+
const out = {};
|
|
1699
|
+
out.samples = value.samples.map((item) => encodeBodyReading(item));
|
|
1700
|
+
return out;
|
|
1701
|
+
}
|
|
1702
|
+
function decodeBodyReadingList(raw, at$ = "BodyReadingList") {
|
|
1703
|
+
const object = asObject(raw, at$);
|
|
1704
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeBodyReading(item, `${`${at$}.samples`}[${index}]`));
|
|
1705
|
+
return { samples };
|
|
1706
|
+
}
|
|
1707
|
+
function encodeWorkoutRouteList(value) {
|
|
1708
|
+
const out = {};
|
|
1709
|
+
out.routes = value.routes.map((item) => encodeWorkoutRoute(item));
|
|
1710
|
+
return out;
|
|
1711
|
+
}
|
|
1712
|
+
function decodeWorkoutRouteList(raw, at$ = "WorkoutRouteList") {
|
|
1713
|
+
const object = asObject(raw, at$);
|
|
1714
|
+
const routes = asArray(object.routes, `${at$}.routes`).map((item, index) => decodeWorkoutRoute(item, `${`${at$}.routes`}[${index}]`));
|
|
1715
|
+
return { routes };
|
|
1716
|
+
}
|
|
1717
|
+
function encodeWorkoutIntensityList(value) {
|
|
1718
|
+
const out = {};
|
|
1719
|
+
out.samples = value.samples.map((item) => encodeWorkoutIntensitySample(item));
|
|
1720
|
+
return out;
|
|
1721
|
+
}
|
|
1722
|
+
function decodeWorkoutIntensityList(raw, at$ = "WorkoutIntensityList") {
|
|
1723
|
+
const object = asObject(raw, at$);
|
|
1724
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeWorkoutIntensitySample(item, `${`${at$}.samples`}[${index}]`));
|
|
1725
|
+
return { samples };
|
|
1726
|
+
}
|
|
1727
|
+
function encodeHydrationList(value) {
|
|
1728
|
+
const out = {};
|
|
1729
|
+
out.samples = value.samples.map((item) => encodeHydrationSample(item));
|
|
1730
|
+
return out;
|
|
1731
|
+
}
|
|
1732
|
+
function decodeHydrationList(raw, at$ = "HydrationList") {
|
|
1733
|
+
const object = asObject(raw, at$);
|
|
1734
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeHydrationSample(item, `${`${at$}.samples`}[${index}]`));
|
|
1735
|
+
return { samples };
|
|
1736
|
+
}
|
|
1737
|
+
function encodeAvailabilityResult(value) {
|
|
1738
|
+
const out = {};
|
|
1739
|
+
out.availability = encodeStoreAvailability(value.availability);
|
|
1740
|
+
return out;
|
|
1741
|
+
}
|
|
1742
|
+
function decodeAvailabilityResult(raw, at$ = "AvailabilityResult") {
|
|
1743
|
+
const object = asObject(raw, at$);
|
|
1744
|
+
const availability = decodeStoreAvailability(object.availability, `${at$}.availability`);
|
|
1745
|
+
return { availability };
|
|
1746
|
+
}
|
|
1138
1747
|
function encodeEndUser(value) {
|
|
1139
1748
|
switch (value.kind) {
|
|
1140
1749
|
case "reference":
|
|
@@ -1356,3 +1965,102 @@ function decodeStreamMessage(raw, at$ = "StreamMessage") {
|
|
|
1356
1965
|
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1357
1966
|
}
|
|
1358
1967
|
}
|
|
1968
|
+
function encodeBodyReadingKind(value) {
|
|
1969
|
+
switch (value.type) {
|
|
1970
|
+
case "measurement":
|
|
1971
|
+
return { type: "measurement", metric: value.metric, value: value.value };
|
|
1972
|
+
case "bloodPressure":
|
|
1973
|
+
return { type: "bloodPressure", systolic: value.systolic, diastolic: value.diastolic };
|
|
1974
|
+
case "bloodGlucose":
|
|
1975
|
+
return { type: "bloodGlucose", value: value.value, unit: value.unit, mealTime: value.mealTime, specimen: value.specimen };
|
|
1976
|
+
case "oxygenSaturation":
|
|
1977
|
+
return { type: "oxygenSaturation", fraction: value.fraction };
|
|
1978
|
+
case "temperature":
|
|
1979
|
+
return { type: "temperature", metric: value.metric, celsius: value.celsius };
|
|
1980
|
+
case "heartRateVariability":
|
|
1981
|
+
return { type: "heartRateVariability", metric: value.metric, milliseconds: value.milliseconds };
|
|
1982
|
+
case "respiratoryRate":
|
|
1983
|
+
return { type: "respiratoryRate", breathsPerMinute: value.breathsPerMinute };
|
|
1984
|
+
case "vo2Max":
|
|
1985
|
+
return { type: "vo2Max", millilitresPerKilogramMinute: value.millilitresPerKilogramMinute, testType: value.testType };
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
function decodeBodyReadingKind(raw, at$ = "BodyReadingKind") {
|
|
1989
|
+
const object = asObject(raw, at$);
|
|
1990
|
+
const tag = object.type;
|
|
1991
|
+
switch (tag) {
|
|
1992
|
+
case "measurement": {
|
|
1993
|
+
return { type: "measurement", metric: asBodyMetric(object.metric, `${at$}.metric`), value: asNumber(object.value, `${at$}.value`) };
|
|
1994
|
+
}
|
|
1995
|
+
case "bloodPressure": {
|
|
1996
|
+
return { type: "bloodPressure", systolic: asNumber(object.systolic, `${at$}.systolic`), diastolic: asNumber(object.diastolic, `${at$}.diastolic`) };
|
|
1997
|
+
}
|
|
1998
|
+
case "bloodGlucose": {
|
|
1999
|
+
return { type: "bloodGlucose", value: asNumber(object.value, `${at$}.value`), unit: asBloodGlucoseUnit(object.unit, `${at$}.unit`), mealTime: optional(object.mealTime, (value) => asGlucoseMealTime(value, `${at$}.mealTime`)), specimen: optional(object.specimen, (value) => asGlucoseSpecimen(value, `${at$}.specimen`)) };
|
|
2000
|
+
}
|
|
2001
|
+
case "oxygenSaturation": {
|
|
2002
|
+
return { type: "oxygenSaturation", fraction: asNumber(object.fraction, `${at$}.fraction`) };
|
|
2003
|
+
}
|
|
2004
|
+
case "temperature": {
|
|
2005
|
+
return { type: "temperature", metric: asBodyTemperatureMetric(object.metric, `${at$}.metric`), celsius: asNumber(object.celsius, `${at$}.celsius`) };
|
|
2006
|
+
}
|
|
2007
|
+
case "heartRateVariability": {
|
|
2008
|
+
return { type: "heartRateVariability", metric: asHeartRateVariabilityMetric(object.metric, `${at$}.metric`), milliseconds: asNumber(object.milliseconds, `${at$}.milliseconds`) };
|
|
2009
|
+
}
|
|
2010
|
+
case "respiratoryRate": {
|
|
2011
|
+
return { type: "respiratoryRate", breathsPerMinute: asNumber(object.breathsPerMinute, `${at$}.breathsPerMinute`) };
|
|
2012
|
+
}
|
|
2013
|
+
case "vo2Max": {
|
|
2014
|
+
return { type: "vo2Max", millilitresPerKilogramMinute: asNumber(object.millilitresPerKilogramMinute, `${at$}.millilitresPerKilogramMinute`), testType: optional(object.testType, (value) => asVO2MaxTestType(value, `${at$}.testType`)) };
|
|
2015
|
+
}
|
|
2016
|
+
default:
|
|
2017
|
+
throw new TypeError(`${at$}: unknown type ${String(tag)}`);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
function encodeStoreAvailability(value) {
|
|
2021
|
+
switch (value.kind) {
|
|
2022
|
+
case "available":
|
|
2023
|
+
return { kind: "available" };
|
|
2024
|
+
case "unsupportedDevice":
|
|
2025
|
+
return { kind: "unsupportedDevice" };
|
|
2026
|
+
case "providerAppMissing":
|
|
2027
|
+
return { kind: "providerAppMissing" };
|
|
2028
|
+
case "providerAppTooOld":
|
|
2029
|
+
return { kind: "providerAppTooOld", installed: value.installed };
|
|
2030
|
+
case "moduleMissing":
|
|
2031
|
+
return { kind: "moduleMissing" };
|
|
2032
|
+
case "partnerPolicyMissing":
|
|
2033
|
+
return { kind: "partnerPolicyMissing" };
|
|
2034
|
+
case "featureUnavailable":
|
|
2035
|
+
return { kind: "featureUnavailable" };
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
function decodeStoreAvailability(raw, at$ = "StoreAvailability") {
|
|
2039
|
+
const object = asObject(raw, at$);
|
|
2040
|
+
const tag = object.kind;
|
|
2041
|
+
switch (tag) {
|
|
2042
|
+
case "available": {
|
|
2043
|
+
return { kind: "available" };
|
|
2044
|
+
}
|
|
2045
|
+
case "unsupportedDevice": {
|
|
2046
|
+
return { kind: "unsupportedDevice" };
|
|
2047
|
+
}
|
|
2048
|
+
case "providerAppMissing": {
|
|
2049
|
+
return { kind: "providerAppMissing" };
|
|
2050
|
+
}
|
|
2051
|
+
case "providerAppTooOld": {
|
|
2052
|
+
return { kind: "providerAppTooOld", installed: asString(object.installed, `${at$}.installed`) };
|
|
2053
|
+
}
|
|
2054
|
+
case "moduleMissing": {
|
|
2055
|
+
return { kind: "moduleMissing" };
|
|
2056
|
+
}
|
|
2057
|
+
case "partnerPolicyMissing": {
|
|
2058
|
+
return { kind: "partnerPolicyMissing" };
|
|
2059
|
+
}
|
|
2060
|
+
case "featureUnavailable": {
|
|
2061
|
+
return { kind: "featureUnavailable" };
|
|
2062
|
+
}
|
|
2063
|
+
default:
|
|
2064
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
2065
|
+
}
|
|
2066
|
+
}
|