@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/src/generated/codecs.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated from surface/terra-surface.json by surface/gen. Do not edit by hand.
|
|
2
2
|
// Regenerate with: node surface/gen/src/cli.ts generate
|
|
3
3
|
|
|
4
|
-
import type { Source, DataCategory, PermissionStatus, MotionContext, BackgroundRestrictionReason, DiagnosticsReason, DeviceKeyRevokeOutcome, FailureCode, WorkoutSchedulingStatus, EndUser, TimeRange, SleepStage, WorkoutActivity, DiagnosticsState, StreamMessage, SampleSource, Connection, HeartRateSample, StepCount, SleepSegment, Workout, HealthChange, WorkoutScope, HealthAccess, HeartRateEntry, StepEntry, SleepEntry, WorkoutEntry, BodyEntry, Nutrients, NutritionEntry, TerraErrorPayload, PlannedWorkout, TerraEvent, SupportReport, BootstrapState, TokenRequest, Empty, SourceRequest, RangeRequest, CategoryRequest, RecordIdRequest, ConnectRequest, PermissionRequest, PermissionGrant, TokenResolveRequest, TokenRejectRequest, TokenProviderRequest, MarkCompleteRequest, BoolResult, StatusResult, StatusesResult, RecordIdList, ConnectionList, HeartRateList, StepCountList, SleepSegmentList, WorkoutList, PlannedWorkoutList, WorkoutScheduling, LastDeliveryResult, HeartRateEntryList, BodyEntryList, StepEntryList, SleepEntryList, WorkoutEntryList, NutritionEntryList } from "./types";
|
|
4
|
+
import type { Source, DataCategory, PermissionStatus, MotionContext, Nutrient, MealType, MenstruationFlow, BiologicalSex, ActivityMoveMode, BackgroundRestrictionReason, DiagnosticsReason, DeviceKeyRevokeOutcome, FailureCode, WorkoutSchedulingStatus, DayTotalMetric, IntradayMetric, WorkoutIntensityMetric, BodyMetric, BloodGlucoseUnit, GlucoseMealTime, GlucoseSpecimen, BodyTemperatureMetric, HeartRateVariabilityMetric, VO2MaxTestType, MenstrualEventKind, EndUser, TimeRange, SleepStage, WorkoutActivity, DiagnosticsState, StreamMessage, BodyReadingKind, StoreAvailability, SampleSource, Connection, HeartRateSample, StepCount, SleepSegment, Workout, DietaryQuantity, MenstruationFlowDay, AthleteProfile, HealthChange, WorkoutScope, HealthAccess, HeartRateEntry, StepEntry, SleepEntry, WorkoutEntry, BodyEntry, Nutrients, NutritionEntry, TerraErrorPayload, PlannedWorkout, TerraEvent, SupportReport, BootstrapState, TokenRequest, Empty, SourceRequest, RangeRequest, CategoryRequest, RecordIdRequest, ConnectRequest, PermissionRequest, PermissionGrant, TokenResolveRequest, TokenRejectRequest, TokenProviderRequest, MarkCompleteRequest, BoolResult, StatusResult, StatusesResult, RecordIdList, ConnectionList, HeartRateList, StepCountList, SleepSegmentList, WorkoutList, DietaryQuantityList, MenstruationFlowDayList, MenstrualEvent, MenstrualEventList, AthleteProfileResult, PlannedWorkoutList, WorkoutScheduling, LastDeliveryResult, HeartRateEntryList, BodyEntryList, StepEntryList, SleepEntryList, WorkoutEntryList, NutritionEntryList, DayTotal, IntradaySample, RestingHeartRateSample, BodyReading, RoutePoint, WorkoutRoute, WorkoutIntensitySample, HydrationSample, DayTotalList, IntradaySampleList, RestingHeartRateList, BodyReadingList, WorkoutRouteList, WorkoutIntensityList, HydrationList, AvailabilityResult } from "./types";
|
|
5
5
|
|
|
6
6
|
function encodeInstant(value: Date): string {
|
|
7
7
|
return value.toISOString();
|
|
@@ -81,7 +81,7 @@ export function asSource(value: unknown, at = "Source"): Source {
|
|
|
81
81
|
return value as Source;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
const DataCategoryCases: ReadonlySet<string> = new Set(["activity", "body", "daily", "sleep", "nutrition"]);
|
|
84
|
+
const DataCategoryCases: ReadonlySet<string> = new Set(["activity", "body", "daily", "sleep", "nutrition", "menstruation", "athlete"]);
|
|
85
85
|
|
|
86
86
|
/** Narrows an untyped value to DataCategory, or throws naming the field. */
|
|
87
87
|
export function asDataCategory(value: unknown, at = "DataCategory"): DataCategory {
|
|
@@ -112,6 +112,57 @@ export function asMotionContext(value: unknown, at = "MotionContext"): MotionCon
|
|
|
112
112
|
return value as MotionContext;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
const NutrientCases: ReadonlySet<string> = 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"]);
|
|
116
|
+
|
|
117
|
+
/** Narrows an untyped value to Nutrient, or throws naming the field. */
|
|
118
|
+
export function asNutrient(value: unknown, at = "Nutrient"): Nutrient {
|
|
119
|
+
if (typeof value !== "string" || !NutrientCases.has(value)) {
|
|
120
|
+
throw new TypeError(`${at}: ${String(value)} is not a Nutrient`);
|
|
121
|
+
}
|
|
122
|
+
return value as Nutrient;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const MealTypeCases: ReadonlySet<string> = new Set(["breakfast", "lunch", "dinner", "snack", "unknown"]);
|
|
126
|
+
|
|
127
|
+
/** Narrows an untyped value to MealType. A string it does not name is `unknown`; anything else throws. */
|
|
128
|
+
export function asMealType(value: unknown, at = "MealType"): MealType {
|
|
129
|
+
if (typeof value !== "string") {
|
|
130
|
+
throw new TypeError(`${at}: ${String(value)} is not a MealType`);
|
|
131
|
+
}
|
|
132
|
+
if (!MealTypeCases.has(value)) return "unknown";
|
|
133
|
+
return value as MealType;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const MenstruationFlowCases: ReadonlySet<string> = new Set(["unspecified", "light", "medium", "heavy", "none"]);
|
|
137
|
+
|
|
138
|
+
/** Narrows an untyped value to MenstruationFlow, or throws naming the field. */
|
|
139
|
+
export function asMenstruationFlow(value: unknown, at = "MenstruationFlow"): MenstruationFlow {
|
|
140
|
+
if (typeof value !== "string" || !MenstruationFlowCases.has(value)) {
|
|
141
|
+
throw new TypeError(`${at}: ${String(value)} is not a MenstruationFlow`);
|
|
142
|
+
}
|
|
143
|
+
return value as MenstruationFlow;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const BiologicalSexCases: ReadonlySet<string> = new Set(["female", "male", "other", "notSet"]);
|
|
147
|
+
|
|
148
|
+
/** Narrows an untyped value to BiologicalSex, or throws naming the field. */
|
|
149
|
+
export function asBiologicalSex(value: unknown, at = "BiologicalSex"): BiologicalSex {
|
|
150
|
+
if (typeof value !== "string" || !BiologicalSexCases.has(value)) {
|
|
151
|
+
throw new TypeError(`${at}: ${String(value)} is not a BiologicalSex`);
|
|
152
|
+
}
|
|
153
|
+
return value as BiologicalSex;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const ActivityMoveModeCases: ReadonlySet<string> = new Set(["activeEnergy", "appleMoveTime"]);
|
|
157
|
+
|
|
158
|
+
/** Narrows an untyped value to ActivityMoveMode, or throws naming the field. */
|
|
159
|
+
export function asActivityMoveMode(value: unknown, at = "ActivityMoveMode"): ActivityMoveMode {
|
|
160
|
+
if (typeof value !== "string" || !ActivityMoveModeCases.has(value)) {
|
|
161
|
+
throw new TypeError(`${at}: ${String(value)} is not a ActivityMoveMode`);
|
|
162
|
+
}
|
|
163
|
+
return value as ActivityMoveMode;
|
|
164
|
+
}
|
|
165
|
+
|
|
115
166
|
const BackgroundRestrictionReasonCases: ReadonlySet<string> = new Set(["oemRestricted", "backgroundReadDenied", "healthConnectFeatureUnavailable", "storeFeatureUnavailable", "ticksNotRunning"]);
|
|
116
167
|
|
|
117
168
|
/** Narrows an untyped value to BackgroundRestrictionReason, or throws naming the field. */
|
|
@@ -162,6 +213,118 @@ export function asWorkoutSchedulingStatus(value: unknown, at = "WorkoutSchedulin
|
|
|
162
213
|
return value as WorkoutSchedulingStatus;
|
|
163
214
|
}
|
|
164
215
|
|
|
216
|
+
const DayTotalMetricCases: ReadonlySet<string> = new Set(["distanceWalkingRunning", "distanceCycling", "distanceSwimming", "distanceWheelchair", "activeEnergyBurned", "basalEnergyBurned", "flightsClimbed", "appleExerciseTime"]);
|
|
217
|
+
|
|
218
|
+
/** Narrows an untyped value to DayTotalMetric, or throws naming the field. */
|
|
219
|
+
export function asDayTotalMetric(value: unknown, at = "DayTotalMetric"): DayTotalMetric {
|
|
220
|
+
if (typeof value !== "string" || !DayTotalMetricCases.has(value)) {
|
|
221
|
+
throw new TypeError(`${at}: ${String(value)} is not a DayTotalMetric`);
|
|
222
|
+
}
|
|
223
|
+
return value as DayTotalMetric;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const IntradayMetricCases: ReadonlySet<string> = new Set(["activeEnergy", "basalEnergy", "distance", "floorsClimbed"]);
|
|
227
|
+
|
|
228
|
+
/** Narrows an untyped value to IntradayMetric, or throws naming the field. */
|
|
229
|
+
export function asIntradayMetric(value: unknown, at = "IntradayMetric"): IntradayMetric {
|
|
230
|
+
if (typeof value !== "string" || !IntradayMetricCases.has(value)) {
|
|
231
|
+
throw new TypeError(`${at}: ${String(value)} is not a IntradayMetric`);
|
|
232
|
+
}
|
|
233
|
+
return value as IntradayMetric;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const WorkoutIntensityMetricCases: ReadonlySet<string> = new Set(["speed", "power", "cadence"]);
|
|
237
|
+
|
|
238
|
+
/** Narrows an untyped value to WorkoutIntensityMetric, or throws naming the field. */
|
|
239
|
+
export function asWorkoutIntensityMetric(value: unknown, at = "WorkoutIntensityMetric"): WorkoutIntensityMetric {
|
|
240
|
+
if (typeof value !== "string" || !WorkoutIntensityMetricCases.has(value)) {
|
|
241
|
+
throw new TypeError(`${at}: ${String(value)} is not a WorkoutIntensityMetric`);
|
|
242
|
+
}
|
|
243
|
+
return value as WorkoutIntensityMetric;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const BodyMetricCases: ReadonlySet<string> = new Set(["weight", "height", "bodyFatPercentage", "leanBodyMass", "bmi"]);
|
|
247
|
+
|
|
248
|
+
/** Narrows an untyped value to BodyMetric, or throws naming the field. */
|
|
249
|
+
export function asBodyMetric(value: unknown, at = "BodyMetric"): BodyMetric {
|
|
250
|
+
if (typeof value !== "string" || !BodyMetricCases.has(value)) {
|
|
251
|
+
throw new TypeError(`${at}: ${String(value)} is not a BodyMetric`);
|
|
252
|
+
}
|
|
253
|
+
return value as BodyMetric;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const BloodGlucoseUnitCases: ReadonlySet<string> = new Set(["mg/dL", "mmol/L"]);
|
|
257
|
+
|
|
258
|
+
/** Narrows an untyped value to BloodGlucoseUnit, or throws naming the field. */
|
|
259
|
+
export function asBloodGlucoseUnit(value: unknown, at = "BloodGlucoseUnit"): BloodGlucoseUnit {
|
|
260
|
+
if (typeof value !== "string" || !BloodGlucoseUnitCases.has(value)) {
|
|
261
|
+
throw new TypeError(`${at}: ${String(value)} is not a BloodGlucoseUnit`);
|
|
262
|
+
}
|
|
263
|
+
return value as BloodGlucoseUnit;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const GlucoseMealTimeCases: ReadonlySet<string> = new Set(["preprandial", "postprandial", "unknown"]);
|
|
267
|
+
|
|
268
|
+
/** Narrows an untyped value to GlucoseMealTime. A string it does not name is `unknown`; anything else throws. */
|
|
269
|
+
export function asGlucoseMealTime(value: unknown, at = "GlucoseMealTime"): GlucoseMealTime {
|
|
270
|
+
if (typeof value !== "string") {
|
|
271
|
+
throw new TypeError(`${at}: ${String(value)} is not a GlucoseMealTime`);
|
|
272
|
+
}
|
|
273
|
+
if (!GlucoseMealTimeCases.has(value)) return "unknown";
|
|
274
|
+
return value as GlucoseMealTime;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const GlucoseSpecimenCases: ReadonlySet<string> = new Set(["capillary", "interstitial", "plasma", "serum", "tears", "wholeBlood", "unknown"]);
|
|
278
|
+
|
|
279
|
+
/** Narrows an untyped value to GlucoseSpecimen. A string it does not name is `unknown`; anything else throws. */
|
|
280
|
+
export function asGlucoseSpecimen(value: unknown, at = "GlucoseSpecimen"): GlucoseSpecimen {
|
|
281
|
+
if (typeof value !== "string") {
|
|
282
|
+
throw new TypeError(`${at}: ${String(value)} is not a GlucoseSpecimen`);
|
|
283
|
+
}
|
|
284
|
+
if (!GlucoseSpecimenCases.has(value)) return "unknown";
|
|
285
|
+
return value as GlucoseSpecimen;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const BodyTemperatureMetricCases: ReadonlySet<string> = new Set(["body", "basal", "wrist", "skin"]);
|
|
289
|
+
|
|
290
|
+
/** Narrows an untyped value to BodyTemperatureMetric, or throws naming the field. */
|
|
291
|
+
export function asBodyTemperatureMetric(value: unknown, at = "BodyTemperatureMetric"): BodyTemperatureMetric {
|
|
292
|
+
if (typeof value !== "string" || !BodyTemperatureMetricCases.has(value)) {
|
|
293
|
+
throw new TypeError(`${at}: ${String(value)} is not a BodyTemperatureMetric`);
|
|
294
|
+
}
|
|
295
|
+
return value as BodyTemperatureMetric;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const HeartRateVariabilityMetricCases: ReadonlySet<string> = new Set(["sdnn", "rmssd"]);
|
|
299
|
+
|
|
300
|
+
/** Narrows an untyped value to HeartRateVariabilityMetric, or throws naming the field. */
|
|
301
|
+
export function asHeartRateVariabilityMetric(value: unknown, at = "HeartRateVariabilityMetric"): HeartRateVariabilityMetric {
|
|
302
|
+
if (typeof value !== "string" || !HeartRateVariabilityMetricCases.has(value)) {
|
|
303
|
+
throw new TypeError(`${at}: ${String(value)} is not a HeartRateVariabilityMetric`);
|
|
304
|
+
}
|
|
305
|
+
return value as HeartRateVariabilityMetric;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const VO2MaxTestTypeCases: ReadonlySet<string> = new Set(["maxExercise", "predictedSubMaxExercise", "predictedNonExercise"]);
|
|
309
|
+
|
|
310
|
+
/** Narrows an untyped value to VO2MaxTestType, or throws naming the field. */
|
|
311
|
+
export function asVO2MaxTestType(value: unknown, at = "VO2MaxTestType"): VO2MaxTestType {
|
|
312
|
+
if (typeof value !== "string" || !VO2MaxTestTypeCases.has(value)) {
|
|
313
|
+
throw new TypeError(`${at}: ${String(value)} is not a VO2MaxTestType`);
|
|
314
|
+
}
|
|
315
|
+
return value as VO2MaxTestType;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const MenstrualEventKindCases: ReadonlySet<string> = new Set(["intermenstrualBleeding", "ovulationTest", "cervicalMucus"]);
|
|
319
|
+
|
|
320
|
+
/** Narrows an untyped value to MenstrualEventKind, or throws naming the field. */
|
|
321
|
+
export function asMenstrualEventKind(value: unknown, at = "MenstrualEventKind"): MenstrualEventKind {
|
|
322
|
+
if (typeof value !== "string" || !MenstrualEventKindCases.has(value)) {
|
|
323
|
+
throw new TypeError(`${at}: ${String(value)} is not a MenstrualEventKind`);
|
|
324
|
+
}
|
|
325
|
+
return value as MenstrualEventKind;
|
|
326
|
+
}
|
|
327
|
+
|
|
165
328
|
export function encodeSampleSource(value: SampleSource): Record<string, unknown> {
|
|
166
329
|
const out: Record<string, unknown> = {};
|
|
167
330
|
out.name = value.name;
|
|
@@ -281,6 +444,7 @@ export function encodeWorkout(value: Workout): Record<string, unknown> {
|
|
|
281
444
|
out.source = encodeSampleSource(value.source);
|
|
282
445
|
out.userEntered = value.userEntered;
|
|
283
446
|
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
447
|
+
if (value.title !== undefined) out.title = value.title;
|
|
284
448
|
return out;
|
|
285
449
|
}
|
|
286
450
|
|
|
@@ -297,7 +461,84 @@ export function decodeWorkout(raw: unknown, at$ = "Workout"): Workout {
|
|
|
297
461
|
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
298
462
|
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
299
463
|
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
300
|
-
|
|
464
|
+
const title = optional(object.title, (value) => asString(value, `${at$}.title`));
|
|
465
|
+
return { id, start, end, activity, activityTypeCode, indoor, activeEnergyKilocalories, distanceMeters, source, userEntered, timeZone, title };
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
export function encodeDietaryQuantity(value: DietaryQuantity): Record<string, unknown> {
|
|
469
|
+
const out: Record<string, unknown> = {};
|
|
470
|
+
out.id = value.id;
|
|
471
|
+
out.nutrient = value.nutrient;
|
|
472
|
+
out.value = value.value;
|
|
473
|
+
out.start = encodeInstant(value.start);
|
|
474
|
+
out.end = encodeInstant(value.end);
|
|
475
|
+
out.mealType = value.mealType;
|
|
476
|
+
if (value.name !== undefined) out.name = value.name;
|
|
477
|
+
if (value.foodCorrelationId !== undefined) out.foodCorrelationId = value.foodCorrelationId;
|
|
478
|
+
out.source = encodeSampleSource(value.source);
|
|
479
|
+
out.userEntered = value.userEntered;
|
|
480
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
481
|
+
return out;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export function decodeDietaryQuantity(raw: unknown, at$ = "DietaryQuantity"): DietaryQuantity {
|
|
485
|
+
const object = asObject(raw, at$);
|
|
486
|
+
const id = asString(object.id, `${at$}.id`);
|
|
487
|
+
const nutrient = asNutrient(object.nutrient, `${at$}.nutrient`);
|
|
488
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
489
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
490
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
491
|
+
const mealType = asMealType(object.mealType, `${at$}.mealType`);
|
|
492
|
+
const name = optional(object.name, (value) => asString(value, `${at$}.name`));
|
|
493
|
+
const foodCorrelationId = optional(object.foodCorrelationId, (value) => asString(value, `${at$}.foodCorrelationId`));
|
|
494
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
495
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
496
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
497
|
+
return { id, nutrient, value, start, end, mealType, name, foodCorrelationId, source, userEntered, timeZone };
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export function encodeMenstruationFlowDay(value: MenstruationFlowDay): Record<string, unknown> {
|
|
501
|
+
const out: Record<string, unknown> = {};
|
|
502
|
+
out.id = value.id;
|
|
503
|
+
out.start = encodeInstant(value.start);
|
|
504
|
+
out.end = encodeInstant(value.end);
|
|
505
|
+
out.flow = value.flow;
|
|
506
|
+
out.cycleStart = value.cycleStart;
|
|
507
|
+
out.source = encodeSampleSource(value.source);
|
|
508
|
+
out.userEntered = value.userEntered;
|
|
509
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
510
|
+
return out;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export function decodeMenstruationFlowDay(raw: unknown, at$ = "MenstruationFlowDay"): MenstruationFlowDay {
|
|
514
|
+
const object = asObject(raw, at$);
|
|
515
|
+
const id = asString(object.id, `${at$}.id`);
|
|
516
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
517
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
518
|
+
const flow = asMenstruationFlow(object.flow, `${at$}.flow`);
|
|
519
|
+
const cycleStart = asBoolean(object.cycleStart, `${at$}.cycleStart`);
|
|
520
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
521
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
522
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
523
|
+
return { id, start, end, flow, cycleStart, source, userEntered, timeZone };
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export function encodeAthleteProfile(value: AthleteProfile): Record<string, unknown> {
|
|
527
|
+
const out: Record<string, unknown> = {};
|
|
528
|
+
out.biologicalSex = value.biologicalSex;
|
|
529
|
+
if (value.dateOfBirth !== undefined) out.dateOfBirth = value.dateOfBirth;
|
|
530
|
+
if (value.wheelchairUse !== undefined) out.wheelchairUse = value.wheelchairUse;
|
|
531
|
+
if (value.activityMoveMode !== undefined) out.activityMoveMode = value.activityMoveMode;
|
|
532
|
+
return out;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export function decodeAthleteProfile(raw: unknown, at$ = "AthleteProfile"): AthleteProfile {
|
|
536
|
+
const object = asObject(raw, at$);
|
|
537
|
+
const biologicalSex = asBiologicalSex(object.biologicalSex, `${at$}.biologicalSex`);
|
|
538
|
+
const dateOfBirth = optional(object.dateOfBirth, (value) => asString(value, `${at$}.dateOfBirth`));
|
|
539
|
+
const wheelchairUse = optional(object.wheelchairUse, (value) => asBoolean(value, `${at$}.wheelchairUse`));
|
|
540
|
+
const activityMoveMode = optional(object.activityMoveMode, (value) => asActivityMoveMode(value, `${at$}.activityMoveMode`));
|
|
541
|
+
return { biologicalSex, dateOfBirth, wheelchairUse, activityMoveMode };
|
|
301
542
|
}
|
|
302
543
|
|
|
303
544
|
export function encodeHealthChange(value: HealthChange): Record<string, unknown> {
|
|
@@ -946,6 +1187,80 @@ export function decodeWorkoutList(raw: unknown, at$ = "WorkoutList"): WorkoutLis
|
|
|
946
1187
|
return { samples };
|
|
947
1188
|
}
|
|
948
1189
|
|
|
1190
|
+
export function encodeDietaryQuantityList(value: DietaryQuantityList): Record<string, unknown> {
|
|
1191
|
+
const out: Record<string, unknown> = {};
|
|
1192
|
+
out.samples = value.samples.map((item) => encodeDietaryQuantity(item));
|
|
1193
|
+
return out;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
export function decodeDietaryQuantityList(raw: unknown, at$ = "DietaryQuantityList"): DietaryQuantityList {
|
|
1197
|
+
const object = asObject(raw, at$);
|
|
1198
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeDietaryQuantity(item, `${`${at$}.samples`}[${index}]`));
|
|
1199
|
+
return { samples };
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
export function encodeMenstruationFlowDayList(value: MenstruationFlowDayList): Record<string, unknown> {
|
|
1203
|
+
const out: Record<string, unknown> = {};
|
|
1204
|
+
out.samples = value.samples.map((item) => encodeMenstruationFlowDay(item));
|
|
1205
|
+
return out;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
export function decodeMenstruationFlowDayList(raw: unknown, at$ = "MenstruationFlowDayList"): MenstruationFlowDayList {
|
|
1209
|
+
const object = asObject(raw, at$);
|
|
1210
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeMenstruationFlowDay(item, `${`${at$}.samples`}[${index}]`));
|
|
1211
|
+
return { samples };
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
export function encodeMenstrualEvent(value: MenstrualEvent): Record<string, unknown> {
|
|
1215
|
+
const out: Record<string, unknown> = {};
|
|
1216
|
+
out.id = value.id;
|
|
1217
|
+
out.kind = value.kind;
|
|
1218
|
+
out.time = encodeInstant(value.time);
|
|
1219
|
+
if (value.value !== undefined) out.value = value.value;
|
|
1220
|
+
out.storeIdentifier = value.storeIdentifier;
|
|
1221
|
+
out.source = encodeSampleSource(value.source);
|
|
1222
|
+
out.userEntered = value.userEntered;
|
|
1223
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1224
|
+
return out;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
export function decodeMenstrualEvent(raw: unknown, at$ = "MenstrualEvent"): MenstrualEvent {
|
|
1228
|
+
const object = asObject(raw, at$);
|
|
1229
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1230
|
+
const kind = asMenstrualEventKind(object.kind, `${at$}.kind`);
|
|
1231
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
1232
|
+
const value = optional(object.value, (value) => asString(value, `${at$}.value`));
|
|
1233
|
+
const storeIdentifier = asString(object.storeIdentifier, `${at$}.storeIdentifier`);
|
|
1234
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1235
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1236
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1237
|
+
return { id, kind, time, value, storeIdentifier, source, userEntered, timeZone };
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
export function encodeMenstrualEventList(value: MenstrualEventList): Record<string, unknown> {
|
|
1241
|
+
const out: Record<string, unknown> = {};
|
|
1242
|
+
out.samples = value.samples.map((item) => encodeMenstrualEvent(item));
|
|
1243
|
+
return out;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
export function decodeMenstrualEventList(raw: unknown, at$ = "MenstrualEventList"): MenstrualEventList {
|
|
1247
|
+
const object = asObject(raw, at$);
|
|
1248
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeMenstrualEvent(item, `${`${at$}.samples`}[${index}]`));
|
|
1249
|
+
return { samples };
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
export function encodeAthleteProfileResult(value: AthleteProfileResult): Record<string, unknown> {
|
|
1253
|
+
const out: Record<string, unknown> = {};
|
|
1254
|
+
if (value.profile !== undefined) out.profile = encodeAthleteProfile(value.profile);
|
|
1255
|
+
return out;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
export function decodeAthleteProfileResult(raw: unknown, at$ = "AthleteProfileResult"): AthleteProfileResult {
|
|
1259
|
+
const object = asObject(raw, at$);
|
|
1260
|
+
const profile = optional(object.profile, (value) => decodeAthleteProfile(value, `${at$}.profile`));
|
|
1261
|
+
return { profile };
|
|
1262
|
+
}
|
|
1263
|
+
|
|
949
1264
|
export function encodePlannedWorkoutList(value: PlannedWorkoutList): Record<string, unknown> {
|
|
950
1265
|
const out: Record<string, unknown> = {};
|
|
951
1266
|
out.workouts = value.workouts.map((item) => encodePlannedWorkout(item));
|
|
@@ -1054,6 +1369,290 @@ export function decodeNutritionEntryList(raw: unknown, at$ = "NutritionEntryList
|
|
|
1054
1369
|
return { entries };
|
|
1055
1370
|
}
|
|
1056
1371
|
|
|
1372
|
+
export function encodeDayTotal(value: DayTotal): Record<string, unknown> {
|
|
1373
|
+
const out: Record<string, unknown> = {};
|
|
1374
|
+
out.metric = value.metric;
|
|
1375
|
+
out.start = encodeInstant(value.start);
|
|
1376
|
+
out.end = encodeInstant(value.end);
|
|
1377
|
+
out.value = value.value;
|
|
1378
|
+
out.unit = value.unit;
|
|
1379
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1380
|
+
return out;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
export function decodeDayTotal(raw: unknown, at$ = "DayTotal"): DayTotal {
|
|
1384
|
+
const object = asObject(raw, at$);
|
|
1385
|
+
const metric = asDayTotalMetric(object.metric, `${at$}.metric`);
|
|
1386
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1387
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1388
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
1389
|
+
const unit = asString(object.unit, `${at$}.unit`);
|
|
1390
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1391
|
+
return { metric, start, end, value, unit, timeZone };
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
export function encodeIntradaySample(value: IntradaySample): Record<string, unknown> {
|
|
1395
|
+
const out: Record<string, unknown> = {};
|
|
1396
|
+
out.id = value.id;
|
|
1397
|
+
out.metric = value.metric;
|
|
1398
|
+
out.start = encodeInstant(value.start);
|
|
1399
|
+
out.end = encodeInstant(value.end);
|
|
1400
|
+
out.value = value.value;
|
|
1401
|
+
out.source = encodeSampleSource(value.source);
|
|
1402
|
+
out.userEntered = value.userEntered;
|
|
1403
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1404
|
+
return out;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
export function decodeIntradaySample(raw: unknown, at$ = "IntradaySample"): IntradaySample {
|
|
1408
|
+
const object = asObject(raw, at$);
|
|
1409
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1410
|
+
const metric = asIntradayMetric(object.metric, `${at$}.metric`);
|
|
1411
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1412
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1413
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
1414
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1415
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1416
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1417
|
+
return { id, metric, start, end, value, source, userEntered, timeZone };
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
export function encodeRestingHeartRateSample(value: RestingHeartRateSample): Record<string, unknown> {
|
|
1421
|
+
const out: Record<string, unknown> = {};
|
|
1422
|
+
out.id = value.id;
|
|
1423
|
+
out.start = encodeInstant(value.start);
|
|
1424
|
+
out.end = encodeInstant(value.end);
|
|
1425
|
+
out.beatsPerMinute = value.beatsPerMinute;
|
|
1426
|
+
out.source = encodeSampleSource(value.source);
|
|
1427
|
+
out.userEntered = value.userEntered;
|
|
1428
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1429
|
+
return out;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
export function decodeRestingHeartRateSample(raw: unknown, at$ = "RestingHeartRateSample"): RestingHeartRateSample {
|
|
1433
|
+
const object = asObject(raw, at$);
|
|
1434
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1435
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1436
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1437
|
+
const beatsPerMinute = asNumber(object.beatsPerMinute, `${at$}.beatsPerMinute`);
|
|
1438
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1439
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1440
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1441
|
+
return { id, start, end, beatsPerMinute, source, userEntered, timeZone };
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
export function encodeBodyReading(value: BodyReading): Record<string, unknown> {
|
|
1445
|
+
const out: Record<string, unknown> = {};
|
|
1446
|
+
out.id = value.id;
|
|
1447
|
+
out.kind = encodeBodyReadingKind(value.kind);
|
|
1448
|
+
out.start = encodeInstant(value.start);
|
|
1449
|
+
out.end = encodeInstant(value.end);
|
|
1450
|
+
out.source = encodeSampleSource(value.source);
|
|
1451
|
+
out.userEntered = value.userEntered;
|
|
1452
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1453
|
+
return out;
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
export function decodeBodyReading(raw: unknown, at$ = "BodyReading"): BodyReading {
|
|
1457
|
+
const object = asObject(raw, at$);
|
|
1458
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1459
|
+
const kind = decodeBodyReadingKind(object.kind, `${at$}.kind`);
|
|
1460
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1461
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1462
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1463
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1464
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1465
|
+
return { id, kind, start, end, source, userEntered, timeZone };
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
export function encodeRoutePoint(value: RoutePoint): Record<string, unknown> {
|
|
1469
|
+
const out: Record<string, unknown> = {};
|
|
1470
|
+
out.time = encodeInstant(value.time);
|
|
1471
|
+
out.latitude = value.latitude;
|
|
1472
|
+
out.longitude = value.longitude;
|
|
1473
|
+
return out;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
export function decodeRoutePoint(raw: unknown, at$ = "RoutePoint"): RoutePoint {
|
|
1477
|
+
const object = asObject(raw, at$);
|
|
1478
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
1479
|
+
const latitude = asNumber(object.latitude, `${at$}.latitude`);
|
|
1480
|
+
const longitude = asNumber(object.longitude, `${at$}.longitude`);
|
|
1481
|
+
return { time, latitude, longitude };
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
export function encodeWorkoutRoute(value: WorkoutRoute): Record<string, unknown> {
|
|
1485
|
+
const out: Record<string, unknown> = {};
|
|
1486
|
+
out.id = value.id;
|
|
1487
|
+
out.workoutId = value.workoutId;
|
|
1488
|
+
out.start = encodeInstant(value.start);
|
|
1489
|
+
out.end = encodeInstant(value.end);
|
|
1490
|
+
out.points = value.points.map((item) => encodeRoutePoint(item));
|
|
1491
|
+
out.source = encodeSampleSource(value.source);
|
|
1492
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1493
|
+
return out;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
export function decodeWorkoutRoute(raw: unknown, at$ = "WorkoutRoute"): WorkoutRoute {
|
|
1497
|
+
const object = asObject(raw, at$);
|
|
1498
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1499
|
+
const workoutId = asString(object.workoutId, `${at$}.workoutId`);
|
|
1500
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1501
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1502
|
+
const points = asArray(object.points, `${at$}.points`).map((item, index) => decodeRoutePoint(item, `${`${at$}.points`}[${index}]`));
|
|
1503
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1504
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1505
|
+
return { id, workoutId, start, end, points, source, timeZone };
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
export function encodeWorkoutIntensitySample(value: WorkoutIntensitySample): Record<string, unknown> {
|
|
1509
|
+
const out: Record<string, unknown> = {};
|
|
1510
|
+
out.id = value.id;
|
|
1511
|
+
out.metric = value.metric;
|
|
1512
|
+
if (value.workoutId !== undefined) out.workoutId = value.workoutId;
|
|
1513
|
+
out.start = encodeInstant(value.start);
|
|
1514
|
+
out.end = encodeInstant(value.end);
|
|
1515
|
+
out.value = value.value;
|
|
1516
|
+
out.source = encodeSampleSource(value.source);
|
|
1517
|
+
out.userEntered = value.userEntered;
|
|
1518
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1519
|
+
return out;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
export function decodeWorkoutIntensitySample(raw: unknown, at$ = "WorkoutIntensitySample"): WorkoutIntensitySample {
|
|
1523
|
+
const object = asObject(raw, at$);
|
|
1524
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1525
|
+
const metric = asWorkoutIntensityMetric(object.metric, `${at$}.metric`);
|
|
1526
|
+
const workoutId = optional(object.workoutId, (value) => asString(value, `${at$}.workoutId`));
|
|
1527
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1528
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1529
|
+
const value = asNumber(object.value, `${at$}.value`);
|
|
1530
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1531
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1532
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1533
|
+
return { id, metric, workoutId, start, end, value, source, userEntered, timeZone };
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
export function encodeHydrationSample(value: HydrationSample): Record<string, unknown> {
|
|
1537
|
+
const out: Record<string, unknown> = {};
|
|
1538
|
+
out.id = value.id;
|
|
1539
|
+
out.start = encodeInstant(value.start);
|
|
1540
|
+
out.end = encodeInstant(value.end);
|
|
1541
|
+
out.millilitres = value.millilitres;
|
|
1542
|
+
out.source = encodeSampleSource(value.source);
|
|
1543
|
+
out.userEntered = value.userEntered;
|
|
1544
|
+
if (value.timeZone !== undefined) out.timeZone = value.timeZone;
|
|
1545
|
+
return out;
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
export function decodeHydrationSample(raw: unknown, at$ = "HydrationSample"): HydrationSample {
|
|
1549
|
+
const object = asObject(raw, at$);
|
|
1550
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1551
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
1552
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
1553
|
+
const millilitres = asNumber(object.millilitres, `${at$}.millilitres`);
|
|
1554
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
1555
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
1556
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
1557
|
+
return { id, start, end, millilitres, source, userEntered, timeZone };
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
export function encodeDayTotalList(value: DayTotalList): Record<string, unknown> {
|
|
1561
|
+
const out: Record<string, unknown> = {};
|
|
1562
|
+
out.totals = value.totals.map((item) => encodeDayTotal(item));
|
|
1563
|
+
return out;
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
export function decodeDayTotalList(raw: unknown, at$ = "DayTotalList"): DayTotalList {
|
|
1567
|
+
const object = asObject(raw, at$);
|
|
1568
|
+
const totals = asArray(object.totals, `${at$}.totals`).map((item, index) => decodeDayTotal(item, `${`${at$}.totals`}[${index}]`));
|
|
1569
|
+
return { totals };
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
export function encodeIntradaySampleList(value: IntradaySampleList): Record<string, unknown> {
|
|
1573
|
+
const out: Record<string, unknown> = {};
|
|
1574
|
+
out.samples = value.samples.map((item) => encodeIntradaySample(item));
|
|
1575
|
+
return out;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
export function decodeIntradaySampleList(raw: unknown, at$ = "IntradaySampleList"): IntradaySampleList {
|
|
1579
|
+
const object = asObject(raw, at$);
|
|
1580
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeIntradaySample(item, `${`${at$}.samples`}[${index}]`));
|
|
1581
|
+
return { samples };
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
export function encodeRestingHeartRateList(value: RestingHeartRateList): Record<string, unknown> {
|
|
1585
|
+
const out: Record<string, unknown> = {};
|
|
1586
|
+
out.samples = value.samples.map((item) => encodeRestingHeartRateSample(item));
|
|
1587
|
+
return out;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
export function decodeRestingHeartRateList(raw: unknown, at$ = "RestingHeartRateList"): RestingHeartRateList {
|
|
1591
|
+
const object = asObject(raw, at$);
|
|
1592
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeRestingHeartRateSample(item, `${`${at$}.samples`}[${index}]`));
|
|
1593
|
+
return { samples };
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
export function encodeBodyReadingList(value: BodyReadingList): Record<string, unknown> {
|
|
1597
|
+
const out: Record<string, unknown> = {};
|
|
1598
|
+
out.samples = value.samples.map((item) => encodeBodyReading(item));
|
|
1599
|
+
return out;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
export function decodeBodyReadingList(raw: unknown, at$ = "BodyReadingList"): BodyReadingList {
|
|
1603
|
+
const object = asObject(raw, at$);
|
|
1604
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeBodyReading(item, `${`${at$}.samples`}[${index}]`));
|
|
1605
|
+
return { samples };
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
export function encodeWorkoutRouteList(value: WorkoutRouteList): Record<string, unknown> {
|
|
1609
|
+
const out: Record<string, unknown> = {};
|
|
1610
|
+
out.routes = value.routes.map((item) => encodeWorkoutRoute(item));
|
|
1611
|
+
return out;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
export function decodeWorkoutRouteList(raw: unknown, at$ = "WorkoutRouteList"): WorkoutRouteList {
|
|
1615
|
+
const object = asObject(raw, at$);
|
|
1616
|
+
const routes = asArray(object.routes, `${at$}.routes`).map((item, index) => decodeWorkoutRoute(item, `${`${at$}.routes`}[${index}]`));
|
|
1617
|
+
return { routes };
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
export function encodeWorkoutIntensityList(value: WorkoutIntensityList): Record<string, unknown> {
|
|
1621
|
+
const out: Record<string, unknown> = {};
|
|
1622
|
+
out.samples = value.samples.map((item) => encodeWorkoutIntensitySample(item));
|
|
1623
|
+
return out;
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
export function decodeWorkoutIntensityList(raw: unknown, at$ = "WorkoutIntensityList"): WorkoutIntensityList {
|
|
1627
|
+
const object = asObject(raw, at$);
|
|
1628
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeWorkoutIntensitySample(item, `${`${at$}.samples`}[${index}]`));
|
|
1629
|
+
return { samples };
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
export function encodeHydrationList(value: HydrationList): Record<string, unknown> {
|
|
1633
|
+
const out: Record<string, unknown> = {};
|
|
1634
|
+
out.samples = value.samples.map((item) => encodeHydrationSample(item));
|
|
1635
|
+
return out;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
export function decodeHydrationList(raw: unknown, at$ = "HydrationList"): HydrationList {
|
|
1639
|
+
const object = asObject(raw, at$);
|
|
1640
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeHydrationSample(item, `${`${at$}.samples`}[${index}]`));
|
|
1641
|
+
return { samples };
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
export function encodeAvailabilityResult(value: AvailabilityResult): Record<string, unknown> {
|
|
1645
|
+
const out: Record<string, unknown> = {};
|
|
1646
|
+
out.availability = encodeStoreAvailability(value.availability);
|
|
1647
|
+
return out;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
export function decodeAvailabilityResult(raw: unknown, at$ = "AvailabilityResult"): AvailabilityResult {
|
|
1651
|
+
const object = asObject(raw, at$);
|
|
1652
|
+
const availability = decodeStoreAvailability(object.availability, `${at$}.availability`);
|
|
1653
|
+
return { availability };
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1057
1656
|
export function encodeEndUser(value: EndUser): Record<string, unknown> {
|
|
1058
1657
|
switch (value.kind) {
|
|
1059
1658
|
case "reference":
|
|
@@ -1285,3 +1884,106 @@ export function decodeStreamMessage(raw: unknown, at$ = "StreamMessage"): Stream
|
|
|
1285
1884
|
}
|
|
1286
1885
|
}
|
|
1287
1886
|
|
|
1887
|
+
export function encodeBodyReadingKind(value: BodyReadingKind): Record<string, unknown> {
|
|
1888
|
+
switch (value.type) {
|
|
1889
|
+
case "measurement":
|
|
1890
|
+
return { type: "measurement", metric: value.metric, value: value.value };
|
|
1891
|
+
case "bloodPressure":
|
|
1892
|
+
return { type: "bloodPressure", systolic: value.systolic, diastolic: value.diastolic };
|
|
1893
|
+
case "bloodGlucose":
|
|
1894
|
+
return { type: "bloodGlucose", value: value.value, unit: value.unit, mealTime: value.mealTime, specimen: value.specimen };
|
|
1895
|
+
case "oxygenSaturation":
|
|
1896
|
+
return { type: "oxygenSaturation", fraction: value.fraction };
|
|
1897
|
+
case "temperature":
|
|
1898
|
+
return { type: "temperature", metric: value.metric, celsius: value.celsius };
|
|
1899
|
+
case "heartRateVariability":
|
|
1900
|
+
return { type: "heartRateVariability", metric: value.metric, milliseconds: value.milliseconds };
|
|
1901
|
+
case "respiratoryRate":
|
|
1902
|
+
return { type: "respiratoryRate", breathsPerMinute: value.breathsPerMinute };
|
|
1903
|
+
case "vo2Max":
|
|
1904
|
+
return { type: "vo2Max", millilitresPerKilogramMinute: value.millilitresPerKilogramMinute, testType: value.testType };
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
export function decodeBodyReadingKind(raw: unknown, at$ = "BodyReadingKind"): BodyReadingKind {
|
|
1909
|
+
const object = asObject(raw, at$);
|
|
1910
|
+
const tag = object.type;
|
|
1911
|
+
switch (tag) {
|
|
1912
|
+
case "measurement": {
|
|
1913
|
+
return { type: "measurement", metric: asBodyMetric(object.metric, `${at$}.metric`), value: asNumber(object.value, `${at$}.value`) };
|
|
1914
|
+
}
|
|
1915
|
+
case "bloodPressure": {
|
|
1916
|
+
return { type: "bloodPressure", systolic: asNumber(object.systolic, `${at$}.systolic`), diastolic: asNumber(object.diastolic, `${at$}.diastolic`) };
|
|
1917
|
+
}
|
|
1918
|
+
case "bloodGlucose": {
|
|
1919
|
+
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`)) };
|
|
1920
|
+
}
|
|
1921
|
+
case "oxygenSaturation": {
|
|
1922
|
+
return { type: "oxygenSaturation", fraction: asNumber(object.fraction, `${at$}.fraction`) };
|
|
1923
|
+
}
|
|
1924
|
+
case "temperature": {
|
|
1925
|
+
return { type: "temperature", metric: asBodyTemperatureMetric(object.metric, `${at$}.metric`), celsius: asNumber(object.celsius, `${at$}.celsius`) };
|
|
1926
|
+
}
|
|
1927
|
+
case "heartRateVariability": {
|
|
1928
|
+
return { type: "heartRateVariability", metric: asHeartRateVariabilityMetric(object.metric, `${at$}.metric`), milliseconds: asNumber(object.milliseconds, `${at$}.milliseconds`) };
|
|
1929
|
+
}
|
|
1930
|
+
case "respiratoryRate": {
|
|
1931
|
+
return { type: "respiratoryRate", breathsPerMinute: asNumber(object.breathsPerMinute, `${at$}.breathsPerMinute`) };
|
|
1932
|
+
}
|
|
1933
|
+
case "vo2Max": {
|
|
1934
|
+
return { type: "vo2Max", millilitresPerKilogramMinute: asNumber(object.millilitresPerKilogramMinute, `${at$}.millilitresPerKilogramMinute`), testType: optional(object.testType, (value) => asVO2MaxTestType(value, `${at$}.testType`)) };
|
|
1935
|
+
}
|
|
1936
|
+
default:
|
|
1937
|
+
throw new TypeError(`${at$}: unknown type ${String(tag)}`);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
export function encodeStoreAvailability(value: StoreAvailability): Record<string, unknown> {
|
|
1942
|
+
switch (value.kind) {
|
|
1943
|
+
case "available":
|
|
1944
|
+
return { kind: "available" };
|
|
1945
|
+
case "unsupportedDevice":
|
|
1946
|
+
return { kind: "unsupportedDevice" };
|
|
1947
|
+
case "providerAppMissing":
|
|
1948
|
+
return { kind: "providerAppMissing" };
|
|
1949
|
+
case "providerAppTooOld":
|
|
1950
|
+
return { kind: "providerAppTooOld", installed: value.installed };
|
|
1951
|
+
case "moduleMissing":
|
|
1952
|
+
return { kind: "moduleMissing" };
|
|
1953
|
+
case "partnerPolicyMissing":
|
|
1954
|
+
return { kind: "partnerPolicyMissing" };
|
|
1955
|
+
case "featureUnavailable":
|
|
1956
|
+
return { kind: "featureUnavailable" };
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
export function decodeStoreAvailability(raw: unknown, at$ = "StoreAvailability"): StoreAvailability {
|
|
1961
|
+
const object = asObject(raw, at$);
|
|
1962
|
+
const tag = object.kind;
|
|
1963
|
+
switch (tag) {
|
|
1964
|
+
case "available": {
|
|
1965
|
+
return { kind: "available" };
|
|
1966
|
+
}
|
|
1967
|
+
case "unsupportedDevice": {
|
|
1968
|
+
return { kind: "unsupportedDevice" };
|
|
1969
|
+
}
|
|
1970
|
+
case "providerAppMissing": {
|
|
1971
|
+
return { kind: "providerAppMissing" };
|
|
1972
|
+
}
|
|
1973
|
+
case "providerAppTooOld": {
|
|
1974
|
+
return { kind: "providerAppTooOld", installed: asString(object.installed, `${at$}.installed`) };
|
|
1975
|
+
}
|
|
1976
|
+
case "moduleMissing": {
|
|
1977
|
+
return { kind: "moduleMissing" };
|
|
1978
|
+
}
|
|
1979
|
+
case "partnerPolicyMissing": {
|
|
1980
|
+
return { kind: "partnerPolicyMissing" };
|
|
1981
|
+
}
|
|
1982
|
+
case "featureUnavailable": {
|
|
1983
|
+
return { kind: "featureUnavailable" };
|
|
1984
|
+
}
|
|
1985
|
+
default:
|
|
1986
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|