@tryterra/react-native 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +142 -2
- package/TerraReactNative.podspec +48 -0
- package/android/build.gradle +87 -0
- package/android/src/bridgeCore/kotlin/README.md +1 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/BridgeBootstrap.kt +133 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/BridgeHost.kt +32 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Conversions.kt +557 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/LauncherSlots.kt +41 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/ReadConversions.kt +250 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/Rejections.kt +150 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/StreamRegistry.kt +77 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridge.kt +86 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeOpsImpl.kt +300 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TerraBridgeStreamsImpl.kt +50 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/TokenBroker.kt +198 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeErrors.kt +217 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeOps.kt +582 -0
- package/android/src/bridgeCore/kotlin/co/tryterra/sdk/bridge/generated/BridgeTypes.kt +1569 -0
- package/android/src/healthConnectOnly/kotlin/co/tryterra/sdk/reactnative/TerraStores.kt +11 -0
- package/android/src/main/AndroidManifest.xml +24 -0
- package/android/src/main/java/co/tryterra/sdk/reactnative/TerraBridgeModule.kt +96 -0
- package/android/src/main/java/co/tryterra/sdk/reactnative/TerraReactNativePackage.kt +26 -0
- package/android/src/main/java/co/tryterra/sdk/reactnative/TerraStartup.kt +46 -0
- package/android/src/samsung/kotlin/co/tryterra/sdk/reactnative/TerraStores.kt +13 -0
- package/docs/availability.md +396 -0
- package/frameworks/TerraSDK.xcframework/Info.plist +48 -0
- 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 +82672 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.package.swiftinterface +2186 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +2186 -0
- 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 +2163 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/PrivacyInfo.xcprivacy +96 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/TerraSDK.framework/TerraSDK +0 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +20 -0
- 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 +6594 -0
- 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 +82672 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.package.swiftinterface +2186 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2186 -0
- 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 +2163 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +82672 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.package.swiftinterface +2186 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/Modules/TerraSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2186 -0
- 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 +2163 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/TerraSDK.framework/PrivacyInfo.xcprivacy +96 -0
- 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 +223 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Info.plist +20 -0
- 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 +6595 -0
- package/frameworks/TerraSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/TerraSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/TerraSDK.yml +6513 -0
- package/ios/TerraBridgeCore/BridgeBootstrap.swift +89 -0
- package/ios/TerraBridgeCore/BridgeHost.swift +13 -0
- package/ios/TerraBridgeCore/Conversions+Reads.swift +259 -0
- package/ios/TerraBridgeCore/Conversions.swift +594 -0
- package/ios/TerraBridgeCore/Generated/BridgeErrors.swift +179 -0
- package/ios/TerraBridgeCore/Generated/BridgeOps.swift +967 -0
- package/ios/TerraBridgeCore/Generated/BridgeTypes.swift +2050 -0
- package/ios/TerraBridgeCore/Locked.swift +15 -0
- package/ios/TerraBridgeCore/README.md +1 -0
- package/ios/TerraBridgeCore/Rejections.swift +130 -0
- package/ios/TerraBridgeCore/RuntimeAttachment.swift +60 -0
- package/ios/TerraBridgeCore/StreamRegistry.swift +59 -0
- package/ios/TerraBridgeCore/TerraBridge.swift +122 -0
- package/ios/TerraBridgeCore/TerraBridgeOpsImpl.swift +318 -0
- package/ios/TerraBridgeCore/TerraBridgeStreamsImpl.swift +60 -0
- package/ios/TerraBridgeCore/TokenBroker.swift +147 -0
- package/ios/TerraBridgeModule.mm +79 -0
- package/ios/TerraBridgeModuleImpl.swift +49 -0
- package/ios/TerraReactNative.swift +19 -0
- package/lib/EndUser.d.ts +12 -0
- package/lib/EndUser.js +13 -0
- package/lib/NativeTerraBridge.d.ts +23 -0
- package/lib/NativeTerraBridge.js +13 -0
- package/lib/Terra.d.ts +223 -0
- package/lib/Terra.js +336 -0
- package/lib/TerraError.d.ts +42 -0
- package/lib/TerraError.js +95 -0
- package/lib/createTerra.d.ts +8 -0
- package/lib/createTerra.js +19 -0
- package/lib/generated/client.d.ts +128 -0
- package/lib/generated/client.js +256 -0
- package/lib/generated/codecs.d.ts +219 -0
- package/lib/generated/codecs.js +2066 -0
- package/lib/generated/errors.d.ts +13 -0
- package/lib/generated/errors.js +68 -0
- package/lib/generated/ops.d.ts +13 -0
- package/lib/generated/ops.js +161 -0
- package/lib/generated/streams.d.ts +23 -0
- package/lib/generated/streams.js +58 -0
- package/lib/generated/types.d.ts +794 -0
- package/lib/generated/types.js +224 -0
- package/lib/index.d.ts +29 -0
- package/lib/index.js +55 -0
- package/package.json +71 -4
- package/src/EndUser.ts +15 -0
- package/src/NativeTerraBridge.ts +27 -0
- package/src/Terra.ts +592 -0
- package/src/TerraError.ts +116 -0
- package/src/createTerra.ts +18 -0
- package/src/generated/client.ts +315 -0
- package/src/generated/codecs.ts +1989 -0
- package/src/generated/errors.ts +113 -0
- package/src/generated/ops.ts +233 -0
- package/src/generated/streams.ts +74 -0
- package/src/generated/types.ts +1222 -0
- package/src/index.ts +54 -0
|
@@ -0,0 +1,2066 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Generated from surface/terra-surface.json by surface/gen. Do not edit by hand.
|
|
3
|
+
// Regenerate with: node surface/gen/src/cli.ts generate
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.asSource = asSource;
|
|
6
|
+
exports.asDataCategory = asDataCategory;
|
|
7
|
+
exports.asPermissionStatus = asPermissionStatus;
|
|
8
|
+
exports.asMotionContext = asMotionContext;
|
|
9
|
+
exports.asNutrient = asNutrient;
|
|
10
|
+
exports.asMealType = asMealType;
|
|
11
|
+
exports.asMenstruationFlow = asMenstruationFlow;
|
|
12
|
+
exports.asBiologicalSex = asBiologicalSex;
|
|
13
|
+
exports.asActivityMoveMode = asActivityMoveMode;
|
|
14
|
+
exports.asBackgroundRestrictionReason = asBackgroundRestrictionReason;
|
|
15
|
+
exports.asDiagnosticsReason = asDiagnosticsReason;
|
|
16
|
+
exports.asDeviceKeyRevokeOutcome = asDeviceKeyRevokeOutcome;
|
|
17
|
+
exports.asFailureCode = asFailureCode;
|
|
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;
|
|
30
|
+
exports.encodeSampleSource = encodeSampleSource;
|
|
31
|
+
exports.decodeSampleSource = decodeSampleSource;
|
|
32
|
+
exports.encodeConnection = encodeConnection;
|
|
33
|
+
exports.decodeConnection = decodeConnection;
|
|
34
|
+
exports.encodeHeartRateSample = encodeHeartRateSample;
|
|
35
|
+
exports.decodeHeartRateSample = decodeHeartRateSample;
|
|
36
|
+
exports.encodeStepCount = encodeStepCount;
|
|
37
|
+
exports.decodeStepCount = decodeStepCount;
|
|
38
|
+
exports.encodeSleepSegment = encodeSleepSegment;
|
|
39
|
+
exports.decodeSleepSegment = decodeSleepSegment;
|
|
40
|
+
exports.encodeWorkout = encodeWorkout;
|
|
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;
|
|
48
|
+
exports.encodeHealthChange = encodeHealthChange;
|
|
49
|
+
exports.decodeHealthChange = decodeHealthChange;
|
|
50
|
+
exports.encodeWorkoutScope = encodeWorkoutScope;
|
|
51
|
+
exports.decodeWorkoutScope = decodeWorkoutScope;
|
|
52
|
+
exports.encodeHealthAccess = encodeHealthAccess;
|
|
53
|
+
exports.decodeHealthAccess = decodeHealthAccess;
|
|
54
|
+
exports.encodeHeartRateEntry = encodeHeartRateEntry;
|
|
55
|
+
exports.decodeHeartRateEntry = decodeHeartRateEntry;
|
|
56
|
+
exports.encodeStepEntry = encodeStepEntry;
|
|
57
|
+
exports.decodeStepEntry = decodeStepEntry;
|
|
58
|
+
exports.encodeSleepEntry = encodeSleepEntry;
|
|
59
|
+
exports.decodeSleepEntry = decodeSleepEntry;
|
|
60
|
+
exports.encodeWorkoutEntry = encodeWorkoutEntry;
|
|
61
|
+
exports.decodeWorkoutEntry = decodeWorkoutEntry;
|
|
62
|
+
exports.encodeBodyEntry = encodeBodyEntry;
|
|
63
|
+
exports.decodeBodyEntry = decodeBodyEntry;
|
|
64
|
+
exports.encodeNutrients = encodeNutrients;
|
|
65
|
+
exports.decodeNutrients = decodeNutrients;
|
|
66
|
+
exports.encodeNutritionEntry = encodeNutritionEntry;
|
|
67
|
+
exports.decodeNutritionEntry = decodeNutritionEntry;
|
|
68
|
+
exports.encodeTerraErrorPayload = encodeTerraErrorPayload;
|
|
69
|
+
exports.decodeTerraErrorPayload = decodeTerraErrorPayload;
|
|
70
|
+
exports.encodePlannedWorkout = encodePlannedWorkout;
|
|
71
|
+
exports.decodePlannedWorkout = decodePlannedWorkout;
|
|
72
|
+
exports.encodeTerraEvent = encodeTerraEvent;
|
|
73
|
+
exports.decodeTerraEvent = decodeTerraEvent;
|
|
74
|
+
exports.encodeSupportReport = encodeSupportReport;
|
|
75
|
+
exports.decodeSupportReport = decodeSupportReport;
|
|
76
|
+
exports.encodeBootstrapState = encodeBootstrapState;
|
|
77
|
+
exports.decodeBootstrapState = decodeBootstrapState;
|
|
78
|
+
exports.encodeTokenRequest = encodeTokenRequest;
|
|
79
|
+
exports.decodeTokenRequest = decodeTokenRequest;
|
|
80
|
+
exports.encodeEmpty = encodeEmpty;
|
|
81
|
+
exports.decodeEmpty = decodeEmpty;
|
|
82
|
+
exports.encodeSourceRequest = encodeSourceRequest;
|
|
83
|
+
exports.decodeSourceRequest = decodeSourceRequest;
|
|
84
|
+
exports.encodeRangeRequest = encodeRangeRequest;
|
|
85
|
+
exports.decodeRangeRequest = decodeRangeRequest;
|
|
86
|
+
exports.encodeCategoryRequest = encodeCategoryRequest;
|
|
87
|
+
exports.decodeCategoryRequest = decodeCategoryRequest;
|
|
88
|
+
exports.encodeRecordIdRequest = encodeRecordIdRequest;
|
|
89
|
+
exports.decodeRecordIdRequest = decodeRecordIdRequest;
|
|
90
|
+
exports.encodeConnectRequest = encodeConnectRequest;
|
|
91
|
+
exports.decodeConnectRequest = decodeConnectRequest;
|
|
92
|
+
exports.encodePermissionRequest = encodePermissionRequest;
|
|
93
|
+
exports.decodePermissionRequest = decodePermissionRequest;
|
|
94
|
+
exports.encodePermissionGrant = encodePermissionGrant;
|
|
95
|
+
exports.decodePermissionGrant = decodePermissionGrant;
|
|
96
|
+
exports.encodeTokenResolveRequest = encodeTokenResolveRequest;
|
|
97
|
+
exports.decodeTokenResolveRequest = decodeTokenResolveRequest;
|
|
98
|
+
exports.encodeTokenRejectRequest = encodeTokenRejectRequest;
|
|
99
|
+
exports.decodeTokenRejectRequest = decodeTokenRejectRequest;
|
|
100
|
+
exports.encodeTokenProviderRequest = encodeTokenProviderRequest;
|
|
101
|
+
exports.decodeTokenProviderRequest = decodeTokenProviderRequest;
|
|
102
|
+
exports.encodeMarkCompleteRequest = encodeMarkCompleteRequest;
|
|
103
|
+
exports.decodeMarkCompleteRequest = decodeMarkCompleteRequest;
|
|
104
|
+
exports.encodeBoolResult = encodeBoolResult;
|
|
105
|
+
exports.decodeBoolResult = decodeBoolResult;
|
|
106
|
+
exports.encodeStatusResult = encodeStatusResult;
|
|
107
|
+
exports.decodeStatusResult = decodeStatusResult;
|
|
108
|
+
exports.encodeStatusesResult = encodeStatusesResult;
|
|
109
|
+
exports.decodeStatusesResult = decodeStatusesResult;
|
|
110
|
+
exports.encodeRecordIdList = encodeRecordIdList;
|
|
111
|
+
exports.decodeRecordIdList = decodeRecordIdList;
|
|
112
|
+
exports.encodeConnectionList = encodeConnectionList;
|
|
113
|
+
exports.decodeConnectionList = decodeConnectionList;
|
|
114
|
+
exports.encodeHeartRateList = encodeHeartRateList;
|
|
115
|
+
exports.decodeHeartRateList = decodeHeartRateList;
|
|
116
|
+
exports.encodeStepCountList = encodeStepCountList;
|
|
117
|
+
exports.decodeStepCountList = decodeStepCountList;
|
|
118
|
+
exports.encodeSleepSegmentList = encodeSleepSegmentList;
|
|
119
|
+
exports.decodeSleepSegmentList = decodeSleepSegmentList;
|
|
120
|
+
exports.encodeWorkoutList = encodeWorkoutList;
|
|
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;
|
|
132
|
+
exports.encodePlannedWorkoutList = encodePlannedWorkoutList;
|
|
133
|
+
exports.decodePlannedWorkoutList = decodePlannedWorkoutList;
|
|
134
|
+
exports.encodeWorkoutScheduling = encodeWorkoutScheduling;
|
|
135
|
+
exports.decodeWorkoutScheduling = decodeWorkoutScheduling;
|
|
136
|
+
exports.encodeLastDeliveryResult = encodeLastDeliveryResult;
|
|
137
|
+
exports.decodeLastDeliveryResult = decodeLastDeliveryResult;
|
|
138
|
+
exports.encodeHeartRateEntryList = encodeHeartRateEntryList;
|
|
139
|
+
exports.decodeHeartRateEntryList = decodeHeartRateEntryList;
|
|
140
|
+
exports.encodeBodyEntryList = encodeBodyEntryList;
|
|
141
|
+
exports.decodeBodyEntryList = decodeBodyEntryList;
|
|
142
|
+
exports.encodeStepEntryList = encodeStepEntryList;
|
|
143
|
+
exports.decodeStepEntryList = decodeStepEntryList;
|
|
144
|
+
exports.encodeSleepEntryList = encodeSleepEntryList;
|
|
145
|
+
exports.decodeSleepEntryList = decodeSleepEntryList;
|
|
146
|
+
exports.encodeWorkoutEntryList = encodeWorkoutEntryList;
|
|
147
|
+
exports.decodeWorkoutEntryList = decodeWorkoutEntryList;
|
|
148
|
+
exports.encodeNutritionEntryList = encodeNutritionEntryList;
|
|
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;
|
|
182
|
+
exports.encodeEndUser = encodeEndUser;
|
|
183
|
+
exports.decodeEndUser = decodeEndUser;
|
|
184
|
+
exports.encodeTimeRange = encodeTimeRange;
|
|
185
|
+
exports.decodeTimeRange = decodeTimeRange;
|
|
186
|
+
exports.encodeSleepStage = encodeSleepStage;
|
|
187
|
+
exports.decodeSleepStage = decodeSleepStage;
|
|
188
|
+
exports.encodeWorkoutActivity = encodeWorkoutActivity;
|
|
189
|
+
exports.decodeWorkoutActivity = decodeWorkoutActivity;
|
|
190
|
+
exports.encodeDiagnosticsState = encodeDiagnosticsState;
|
|
191
|
+
exports.decodeDiagnosticsState = decodeDiagnosticsState;
|
|
192
|
+
exports.encodeStreamMessage = encodeStreamMessage;
|
|
193
|
+
exports.decodeStreamMessage = decodeStreamMessage;
|
|
194
|
+
exports.encodeBodyReadingKind = encodeBodyReadingKind;
|
|
195
|
+
exports.decodeBodyReadingKind = decodeBodyReadingKind;
|
|
196
|
+
exports.encodeStoreAvailability = encodeStoreAvailability;
|
|
197
|
+
exports.decodeStoreAvailability = decodeStoreAvailability;
|
|
198
|
+
function encodeInstant(value) {
|
|
199
|
+
return value.toISOString();
|
|
200
|
+
}
|
|
201
|
+
function decodeInstant(value, at) {
|
|
202
|
+
if (typeof value !== 'string')
|
|
203
|
+
throw new TypeError(`${at}: expected an ISO 8601 string`);
|
|
204
|
+
// `new Date` reads a string with no offset as device-local time and shifts the instant.
|
|
205
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value)) {
|
|
206
|
+
throw new TypeError(`${at}: not a millisecond UTC instant`);
|
|
207
|
+
}
|
|
208
|
+
const parsed = new Date(value);
|
|
209
|
+
if (Number.isNaN(parsed.getTime()) || parsed.toISOString() !== value) {
|
|
210
|
+
throw new TypeError(`${at}: not a valid instant`);
|
|
211
|
+
}
|
|
212
|
+
return parsed;
|
|
213
|
+
}
|
|
214
|
+
function asObject(value, at) {
|
|
215
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
216
|
+
throw new TypeError(`${at}: expected an object`);
|
|
217
|
+
}
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
function asArray(value, at) {
|
|
221
|
+
if (!Array.isArray(value))
|
|
222
|
+
throw new TypeError(`${at}: expected an array`);
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Checked rather than cast.
|
|
227
|
+
*
|
|
228
|
+
* `value as number` on a string produces a `number`-typed value that is a string, and the
|
|
229
|
+
* failure then happens in the caller's arithmetic with no mention of the bridge. Rejecting at
|
|
230
|
+
* the boundary names the field that was wrong.
|
|
231
|
+
*/
|
|
232
|
+
function asNumber(value, at) {
|
|
233
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
234
|
+
throw new TypeError(`${at}: expected a number`);
|
|
235
|
+
}
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
function asInteger(value, at) {
|
|
239
|
+
if (typeof value !== 'number' || !Number.isInteger(value)) {
|
|
240
|
+
throw new TypeError(`${at}: expected an integer`);
|
|
241
|
+
}
|
|
242
|
+
return value;
|
|
243
|
+
}
|
|
244
|
+
function caseSet(items) {
|
|
245
|
+
return [...new Set(items)].sort();
|
|
246
|
+
}
|
|
247
|
+
function asBoolean(value, at) {
|
|
248
|
+
if (typeof value !== 'boolean')
|
|
249
|
+
throw new TypeError(`${at}: expected a boolean`);
|
|
250
|
+
return value;
|
|
251
|
+
}
|
|
252
|
+
function asString(value, at) {
|
|
253
|
+
if (typeof value !== 'string')
|
|
254
|
+
throw new TypeError(`${at}: expected a string`);
|
|
255
|
+
return value;
|
|
256
|
+
}
|
|
257
|
+
function optional(value, read) {
|
|
258
|
+
return value === undefined || value === null ? undefined : read(value);
|
|
259
|
+
}
|
|
260
|
+
const SourceCases = new Set(["health", "samsungHealth"]);
|
|
261
|
+
/** Narrows an untyped value to Source, or throws naming the field. */
|
|
262
|
+
function asSource(value, at = "Source") {
|
|
263
|
+
if (typeof value !== "string" || !SourceCases.has(value)) {
|
|
264
|
+
throw new TypeError(`${at}: ${String(value)} is not a Source`);
|
|
265
|
+
}
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
const DataCategoryCases = new Set(["activity", "body", "daily", "sleep", "nutrition", "menstruation", "athlete"]);
|
|
269
|
+
/** Narrows an untyped value to DataCategory, or throws naming the field. */
|
|
270
|
+
function asDataCategory(value, at = "DataCategory") {
|
|
271
|
+
if (typeof value !== "string" || !DataCategoryCases.has(value)) {
|
|
272
|
+
throw new TypeError(`${at}: ${String(value)} is not a DataCategory`);
|
|
273
|
+
}
|
|
274
|
+
return value;
|
|
275
|
+
}
|
|
276
|
+
const PermissionStatusCases = new Set(["granted", "denied", "notDetermined", "notDisclosed", "unsupported", "unavailable"]);
|
|
277
|
+
/** Narrows an untyped value to PermissionStatus, or throws naming the field. */
|
|
278
|
+
function asPermissionStatus(value, at = "PermissionStatus") {
|
|
279
|
+
if (typeof value !== "string" || !PermissionStatusCases.has(value)) {
|
|
280
|
+
throw new TypeError(`${at}: ${String(value)} is not a PermissionStatus`);
|
|
281
|
+
}
|
|
282
|
+
return value;
|
|
283
|
+
}
|
|
284
|
+
const MotionContextCases = new Set(["unknown", "sedentary", "active"]);
|
|
285
|
+
/** Narrows an untyped value to MotionContext. A string it does not name is `unknown`; anything else throws. */
|
|
286
|
+
function asMotionContext(value, at = "MotionContext") {
|
|
287
|
+
if (typeof value !== "string") {
|
|
288
|
+
throw new TypeError(`${at}: ${String(value)} is not a MotionContext`);
|
|
289
|
+
}
|
|
290
|
+
if (!MotionContextCases.has(value))
|
|
291
|
+
return "unknown";
|
|
292
|
+
return value;
|
|
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
|
+
}
|
|
336
|
+
const BackgroundRestrictionReasonCases = new Set(["oemRestricted", "backgroundReadDenied", "healthConnectFeatureUnavailable", "storeFeatureUnavailable", "ticksNotRunning"]);
|
|
337
|
+
/** Narrows an untyped value to BackgroundRestrictionReason, or throws naming the field. */
|
|
338
|
+
function asBackgroundRestrictionReason(value, at = "BackgroundRestrictionReason") {
|
|
339
|
+
if (typeof value !== "string" || !BackgroundRestrictionReasonCases.has(value)) {
|
|
340
|
+
throw new TypeError(`${at}: ${String(value)} is not a BackgroundRestrictionReason`);
|
|
341
|
+
}
|
|
342
|
+
return value;
|
|
343
|
+
}
|
|
344
|
+
const DiagnosticsReasonCases = new Set(["uploadFailed", "backfillAbandoned", "backgroundObservationUnavailable", "backgroundRestricted", "backgroundRefreshUnscheduled", "quiet", "requested"]);
|
|
345
|
+
/** Narrows an untyped value to DiagnosticsReason, or throws naming the field. */
|
|
346
|
+
function asDiagnosticsReason(value, at = "DiagnosticsReason") {
|
|
347
|
+
if (typeof value !== "string" || !DiagnosticsReasonCases.has(value)) {
|
|
348
|
+
throw new TypeError(`${at}: ${String(value)} is not a DiagnosticsReason`);
|
|
349
|
+
}
|
|
350
|
+
return value;
|
|
351
|
+
}
|
|
352
|
+
const DeviceKeyRevokeOutcomeCases = new Set(["revoked", "alreadyRevoked", "routeAbsent"]);
|
|
353
|
+
/** Narrows an untyped value to DeviceKeyRevokeOutcome, or throws naming the field. */
|
|
354
|
+
function asDeviceKeyRevokeOutcome(value, at = "DeviceKeyRevokeOutcome") {
|
|
355
|
+
if (typeof value !== "string" || !DeviceKeyRevokeOutcomeCases.has(value)) {
|
|
356
|
+
throw new TypeError(`${at}: ${String(value)} is not a DeviceKeyRevokeOutcome`);
|
|
357
|
+
}
|
|
358
|
+
return value;
|
|
359
|
+
}
|
|
360
|
+
const FailureCodeCases = new Set(["healthDataUnavailable", "notConnected", "tokenUnavailable", "tokenRejected", "tokenProviderFailed", "offline", "timedOut", "serverError", "transport", "malformedResponse", "userLimitReached", "upgradeRequired", "platform", "deviceKeyUnavailable", "signatureRejected", "linkRevoked", "linkConflict", "clockSkewed", "devIDMismatch", "syncAlreadyRunning", "linkAlreadyRunning", "storeLocked", "storeUnreadable", "deadlineExceeded", "permissionDenied", "authorizationNotDetermined", "sampleNotFound", "rollbackIncomplete", "distanceNotAttributable", "bloodPressureIncomplete", "authorizationUnavailableInExtension", "routeAwaitingConverter", "readQuotaExceeded", "plannedWorkoutUnnamed"]);
|
|
361
|
+
/** Narrows an untyped value to FailureCode, or throws naming the field. */
|
|
362
|
+
function asFailureCode(value, at = "FailureCode") {
|
|
363
|
+
if (typeof value !== "string" || !FailureCodeCases.has(value)) {
|
|
364
|
+
throw new TypeError(`${at}: ${String(value)} is not a FailureCode`);
|
|
365
|
+
}
|
|
366
|
+
return value;
|
|
367
|
+
}
|
|
368
|
+
const WorkoutSchedulingStatusCases = new Set(["unsupported", "notDetermined", "denied", "authorized"]);
|
|
369
|
+
/** Narrows an untyped value to WorkoutSchedulingStatus, or throws naming the field. */
|
|
370
|
+
function asWorkoutSchedulingStatus(value, at = "WorkoutSchedulingStatus") {
|
|
371
|
+
if (typeof value !== "string" || !WorkoutSchedulingStatusCases.has(value)) {
|
|
372
|
+
throw new TypeError(`${at}: ${String(value)} is not a WorkoutSchedulingStatus`);
|
|
373
|
+
}
|
|
374
|
+
return value;
|
|
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
|
+
}
|
|
468
|
+
function encodeSampleSource(value) {
|
|
469
|
+
const out = {};
|
|
470
|
+
out.name = value.name;
|
|
471
|
+
out.bundleId = value.bundleId;
|
|
472
|
+
if (value.productType !== undefined)
|
|
473
|
+
out.productType = value.productType;
|
|
474
|
+
if (value.deviceType !== undefined)
|
|
475
|
+
out.deviceType = value.deviceType;
|
|
476
|
+
return out;
|
|
477
|
+
}
|
|
478
|
+
function decodeSampleSource(raw, at$ = "SampleSource") {
|
|
479
|
+
const object = asObject(raw, at$);
|
|
480
|
+
const name = asString(object.name, `${at$}.name`);
|
|
481
|
+
const bundleId = asString(object.bundleId, `${at$}.bundleId`);
|
|
482
|
+
const productType = optional(object.productType, (value) => asString(value, `${at$}.productType`));
|
|
483
|
+
const deviceType = optional(object.deviceType, (value) => asString(value, `${at$}.deviceType`));
|
|
484
|
+
return { name, bundleId, productType, deviceType };
|
|
485
|
+
}
|
|
486
|
+
function encodeConnection(value) {
|
|
487
|
+
const out = {};
|
|
488
|
+
out.source = value.source;
|
|
489
|
+
out.userId = value.userId;
|
|
490
|
+
if (value.providerUserId !== undefined)
|
|
491
|
+
out.providerUserId = value.providerUserId;
|
|
492
|
+
return out;
|
|
493
|
+
}
|
|
494
|
+
function decodeConnection(raw, at$ = "Connection") {
|
|
495
|
+
const object = asObject(raw, at$);
|
|
496
|
+
const source = asSource(object.source, `${at$}.source`);
|
|
497
|
+
const userId = asString(object.userId, `${at$}.userId`);
|
|
498
|
+
const providerUserId = optional(object.providerUserId, (value) => asString(value, `${at$}.providerUserId`));
|
|
499
|
+
return { source, userId, providerUserId };
|
|
500
|
+
}
|
|
501
|
+
function encodeHeartRateSample(value) {
|
|
502
|
+
const out = {};
|
|
503
|
+
out.id = value.id;
|
|
504
|
+
out.time = encodeInstant(value.time);
|
|
505
|
+
out.beatsPerMinute = value.beatsPerMinute;
|
|
506
|
+
out.source = encodeSampleSource(value.source);
|
|
507
|
+
if (value.motionContext !== undefined)
|
|
508
|
+
out.motionContext = value.motionContext;
|
|
509
|
+
out.userEntered = value.userEntered;
|
|
510
|
+
if (value.timeZone !== undefined)
|
|
511
|
+
out.timeZone = value.timeZone;
|
|
512
|
+
return out;
|
|
513
|
+
}
|
|
514
|
+
function decodeHeartRateSample(raw, at$ = "HeartRateSample") {
|
|
515
|
+
const object = asObject(raw, at$);
|
|
516
|
+
const id = asString(object.id, `${at$}.id`);
|
|
517
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
518
|
+
const beatsPerMinute = asNumber(object.beatsPerMinute, `${at$}.beatsPerMinute`);
|
|
519
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
520
|
+
const motionContext = optional(object.motionContext, (value) => asMotionContext(value, `${at$}.motionContext`));
|
|
521
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
522
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
523
|
+
return { id, time, beatsPerMinute, source, motionContext, userEntered, timeZone };
|
|
524
|
+
}
|
|
525
|
+
function encodeStepCount(value) {
|
|
526
|
+
const out = {};
|
|
527
|
+
if (value.id !== undefined)
|
|
528
|
+
out.id = value.id;
|
|
529
|
+
out.start = encodeInstant(value.start);
|
|
530
|
+
out.end = encodeInstant(value.end);
|
|
531
|
+
out.steps = value.steps;
|
|
532
|
+
out.source = encodeSampleSource(value.source);
|
|
533
|
+
out.userEntered = value.userEntered;
|
|
534
|
+
if (value.timeZone !== undefined)
|
|
535
|
+
out.timeZone = value.timeZone;
|
|
536
|
+
return out;
|
|
537
|
+
}
|
|
538
|
+
function decodeStepCount(raw, at$ = "StepCount") {
|
|
539
|
+
const object = asObject(raw, at$);
|
|
540
|
+
const id = optional(object.id, (value) => asString(value, `${at$}.id`));
|
|
541
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
542
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
543
|
+
const steps = asInteger(object.steps, `${at$}.steps`);
|
|
544
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
545
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
546
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
547
|
+
return { id, start, end, steps, source, userEntered, timeZone };
|
|
548
|
+
}
|
|
549
|
+
function encodeSleepSegment(value) {
|
|
550
|
+
const out = {};
|
|
551
|
+
out.id = value.id;
|
|
552
|
+
out.start = encodeInstant(value.start);
|
|
553
|
+
out.end = encodeInstant(value.end);
|
|
554
|
+
out.stage = encodeSleepStage(value.stage);
|
|
555
|
+
out.source = encodeSampleSource(value.source);
|
|
556
|
+
out.userEntered = value.userEntered;
|
|
557
|
+
if (value.timeZone !== undefined)
|
|
558
|
+
out.timeZone = value.timeZone;
|
|
559
|
+
return out;
|
|
560
|
+
}
|
|
561
|
+
function decodeSleepSegment(raw, at$ = "SleepSegment") {
|
|
562
|
+
const object = asObject(raw, at$);
|
|
563
|
+
const id = asString(object.id, `${at$}.id`);
|
|
564
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
565
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
566
|
+
const stage = decodeSleepStage(object.stage, `${at$}.stage`);
|
|
567
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
568
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
569
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
570
|
+
return { id, start, end, stage, source, userEntered, timeZone };
|
|
571
|
+
}
|
|
572
|
+
function encodeWorkout(value) {
|
|
573
|
+
const out = {};
|
|
574
|
+
out.id = value.id;
|
|
575
|
+
out.start = encodeInstant(value.start);
|
|
576
|
+
out.end = encodeInstant(value.end);
|
|
577
|
+
out.activity = encodeWorkoutActivity(value.activity);
|
|
578
|
+
out.activityTypeCode = value.activityTypeCode;
|
|
579
|
+
if (value.indoor !== undefined)
|
|
580
|
+
out.indoor = value.indoor;
|
|
581
|
+
if (value.activeEnergyKilocalories !== undefined)
|
|
582
|
+
out.activeEnergyKilocalories = value.activeEnergyKilocalories;
|
|
583
|
+
if (value.distanceMeters !== undefined)
|
|
584
|
+
out.distanceMeters = value.distanceMeters;
|
|
585
|
+
out.source = encodeSampleSource(value.source);
|
|
586
|
+
out.userEntered = value.userEntered;
|
|
587
|
+
if (value.timeZone !== undefined)
|
|
588
|
+
out.timeZone = value.timeZone;
|
|
589
|
+
if (value.title !== undefined)
|
|
590
|
+
out.title = value.title;
|
|
591
|
+
return out;
|
|
592
|
+
}
|
|
593
|
+
function decodeWorkout(raw, at$ = "Workout") {
|
|
594
|
+
const object = asObject(raw, at$);
|
|
595
|
+
const id = asString(object.id, `${at$}.id`);
|
|
596
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
597
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
598
|
+
const activity = decodeWorkoutActivity(object.activity, `${at$}.activity`);
|
|
599
|
+
const activityTypeCode = asInteger(object.activityTypeCode, `${at$}.activityTypeCode`);
|
|
600
|
+
const indoor = optional(object.indoor, (value) => asBoolean(value, `${at$}.indoor`));
|
|
601
|
+
const activeEnergyKilocalories = optional(object.activeEnergyKilocalories, (value) => asNumber(value, `${at$}.activeEnergyKilocalories`));
|
|
602
|
+
const distanceMeters = optional(object.distanceMeters, (value) => asNumber(value, `${at$}.distanceMeters`));
|
|
603
|
+
const source = decodeSampleSource(object.source, `${at$}.source`);
|
|
604
|
+
const userEntered = asBoolean(object.userEntered, `${at$}.userEntered`);
|
|
605
|
+
const timeZone = optional(object.timeZone, (value) => asString(value, `${at$}.timeZone`));
|
|
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 };
|
|
685
|
+
}
|
|
686
|
+
function encodeHealthChange(value) {
|
|
687
|
+
const out = {};
|
|
688
|
+
out.category = value.category;
|
|
689
|
+
out.day = value.day;
|
|
690
|
+
return out;
|
|
691
|
+
}
|
|
692
|
+
function decodeHealthChange(raw, at$ = "HealthChange") {
|
|
693
|
+
const object = asObject(raw, at$);
|
|
694
|
+
const category = asDataCategory(object.category, `${at$}.category`);
|
|
695
|
+
const day = asString(object.day, `${at$}.day`);
|
|
696
|
+
return { category, day };
|
|
697
|
+
}
|
|
698
|
+
function encodeWorkoutScope(value) {
|
|
699
|
+
const out = {};
|
|
700
|
+
out.activity = encodeWorkoutActivity(value.activity);
|
|
701
|
+
out.energy = value.energy;
|
|
702
|
+
out.distance = value.distance;
|
|
703
|
+
return out;
|
|
704
|
+
}
|
|
705
|
+
function decodeWorkoutScope(raw, at$ = "WorkoutScope") {
|
|
706
|
+
const object = asObject(raw, at$);
|
|
707
|
+
const activity = decodeWorkoutActivity(object.activity, `${at$}.activity`);
|
|
708
|
+
const energy = asBoolean(object.energy, `${at$}.energy`);
|
|
709
|
+
const distance = asBoolean(object.distance, `${at$}.distance`);
|
|
710
|
+
return { activity, energy, distance };
|
|
711
|
+
}
|
|
712
|
+
function encodeHealthAccess(value) {
|
|
713
|
+
const out = {};
|
|
714
|
+
out.read = caseSet(value.read);
|
|
715
|
+
out.write = caseSet(value.write);
|
|
716
|
+
out.workouts = value.workouts.map((item) => encodeWorkoutScope(item));
|
|
717
|
+
return out;
|
|
718
|
+
}
|
|
719
|
+
function decodeHealthAccess(raw, at$ = "HealthAccess") {
|
|
720
|
+
const object = asObject(raw, at$);
|
|
721
|
+
const read = caseSet(asArray(object.read, `${at$}.read`).map((item, index) => asDataCategory(item, `${`${at$}.read`}[${index}]`)));
|
|
722
|
+
const write = caseSet(asArray(object.write, `${at$}.write`).map((item, index) => asDataCategory(item, `${`${at$}.write`}[${index}]`)));
|
|
723
|
+
const workouts = asArray(object.workouts, `${at$}.workouts`).map((item, index) => decodeWorkoutScope(item, `${`${at$}.workouts`}[${index}]`));
|
|
724
|
+
return { read, write, workouts };
|
|
725
|
+
}
|
|
726
|
+
function encodeHeartRateEntry(value) {
|
|
727
|
+
const out = {};
|
|
728
|
+
out.time = encodeInstant(value.time);
|
|
729
|
+
out.beatsPerMinute = value.beatsPerMinute;
|
|
730
|
+
if (value.recordId !== undefined)
|
|
731
|
+
out.recordId = value.recordId;
|
|
732
|
+
return out;
|
|
733
|
+
}
|
|
734
|
+
function decodeHeartRateEntry(raw, at$ = "HeartRateEntry") {
|
|
735
|
+
const object = asObject(raw, at$);
|
|
736
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
737
|
+
const beatsPerMinute = asNumber(object.beatsPerMinute, `${at$}.beatsPerMinute`);
|
|
738
|
+
const recordId = optional(object.recordId, (value) => asString(value, `${at$}.recordId`));
|
|
739
|
+
return { time, beatsPerMinute, recordId };
|
|
740
|
+
}
|
|
741
|
+
function encodeStepEntry(value) {
|
|
742
|
+
const out = {};
|
|
743
|
+
out.start = encodeInstant(value.start);
|
|
744
|
+
out.end = encodeInstant(value.end);
|
|
745
|
+
out.steps = value.steps;
|
|
746
|
+
if (value.recordId !== undefined)
|
|
747
|
+
out.recordId = value.recordId;
|
|
748
|
+
return out;
|
|
749
|
+
}
|
|
750
|
+
function decodeStepEntry(raw, at$ = "StepEntry") {
|
|
751
|
+
const object = asObject(raw, at$);
|
|
752
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
753
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
754
|
+
const steps = asInteger(object.steps, `${at$}.steps`);
|
|
755
|
+
const recordId = optional(object.recordId, (value) => asString(value, `${at$}.recordId`));
|
|
756
|
+
return { start, end, steps, recordId };
|
|
757
|
+
}
|
|
758
|
+
function encodeSleepEntry(value) {
|
|
759
|
+
const out = {};
|
|
760
|
+
out.start = encodeInstant(value.start);
|
|
761
|
+
out.end = encodeInstant(value.end);
|
|
762
|
+
out.stage = encodeSleepStage(value.stage);
|
|
763
|
+
if (value.recordId !== undefined)
|
|
764
|
+
out.recordId = value.recordId;
|
|
765
|
+
return out;
|
|
766
|
+
}
|
|
767
|
+
function decodeSleepEntry(raw, at$ = "SleepEntry") {
|
|
768
|
+
const object = asObject(raw, at$);
|
|
769
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
770
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
771
|
+
const stage = decodeSleepStage(object.stage, `${at$}.stage`);
|
|
772
|
+
const recordId = optional(object.recordId, (value) => asString(value, `${at$}.recordId`));
|
|
773
|
+
return { start, end, stage, recordId };
|
|
774
|
+
}
|
|
775
|
+
function encodeWorkoutEntry(value) {
|
|
776
|
+
const out = {};
|
|
777
|
+
out.start = encodeInstant(value.start);
|
|
778
|
+
out.end = encodeInstant(value.end);
|
|
779
|
+
out.activity = encodeWorkoutActivity(value.activity);
|
|
780
|
+
if (value.totalEnergyKilocalories !== undefined)
|
|
781
|
+
out.totalEnergyKilocalories = value.totalEnergyKilocalories;
|
|
782
|
+
if (value.totalDistanceMeters !== undefined)
|
|
783
|
+
out.totalDistanceMeters = value.totalDistanceMeters;
|
|
784
|
+
if (value.recordId !== undefined)
|
|
785
|
+
out.recordId = value.recordId;
|
|
786
|
+
return out;
|
|
787
|
+
}
|
|
788
|
+
function decodeWorkoutEntry(raw, at$ = "WorkoutEntry") {
|
|
789
|
+
const object = asObject(raw, at$);
|
|
790
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
791
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
792
|
+
const activity = decodeWorkoutActivity(object.activity, `${at$}.activity`);
|
|
793
|
+
const totalEnergyKilocalories = optional(object.totalEnergyKilocalories, (value) => asNumber(value, `${at$}.totalEnergyKilocalories`));
|
|
794
|
+
const totalDistanceMeters = optional(object.totalDistanceMeters, (value) => asNumber(value, `${at$}.totalDistanceMeters`));
|
|
795
|
+
const recordId = optional(object.recordId, (value) => asString(value, `${at$}.recordId`));
|
|
796
|
+
return { start, end, activity, totalEnergyKilocalories, totalDistanceMeters, recordId };
|
|
797
|
+
}
|
|
798
|
+
function encodeBodyEntry(value) {
|
|
799
|
+
const out = {};
|
|
800
|
+
out.time = encodeInstant(value.time);
|
|
801
|
+
if (value.bodyMassKilograms !== undefined)
|
|
802
|
+
out.bodyMassKilograms = value.bodyMassKilograms;
|
|
803
|
+
if (value.bodyFatPercent !== undefined)
|
|
804
|
+
out.bodyFatPercent = value.bodyFatPercent;
|
|
805
|
+
if (value.bodyMassIndex !== undefined)
|
|
806
|
+
out.bodyMassIndex = value.bodyMassIndex;
|
|
807
|
+
if (value.heightMeters !== undefined)
|
|
808
|
+
out.heightMeters = value.heightMeters;
|
|
809
|
+
if (value.leanBodyMassKilograms !== undefined)
|
|
810
|
+
out.leanBodyMassKilograms = value.leanBodyMassKilograms;
|
|
811
|
+
if (value.bodyTemperatureCelsius !== undefined)
|
|
812
|
+
out.bodyTemperatureCelsius = value.bodyTemperatureCelsius;
|
|
813
|
+
if (value.oxygenSaturationPercent !== undefined)
|
|
814
|
+
out.oxygenSaturationPercent = value.oxygenSaturationPercent;
|
|
815
|
+
if (value.bloodGlucoseMilligramsPerDeciliter !== undefined)
|
|
816
|
+
out.bloodGlucoseMilligramsPerDeciliter = value.bloodGlucoseMilligramsPerDeciliter;
|
|
817
|
+
if (value.bloodPressureSystolicMillimetersOfMercury !== undefined)
|
|
818
|
+
out.bloodPressureSystolicMillimetersOfMercury = value.bloodPressureSystolicMillimetersOfMercury;
|
|
819
|
+
if (value.bloodPressureDiastolicMillimetersOfMercury !== undefined)
|
|
820
|
+
out.bloodPressureDiastolicMillimetersOfMercury = value.bloodPressureDiastolicMillimetersOfMercury;
|
|
821
|
+
if (value.recordId !== undefined)
|
|
822
|
+
out.recordId = value.recordId;
|
|
823
|
+
return out;
|
|
824
|
+
}
|
|
825
|
+
function decodeBodyEntry(raw, at$ = "BodyEntry") {
|
|
826
|
+
const object = asObject(raw, at$);
|
|
827
|
+
const time = decodeInstant(object.time, `${at$}.time`);
|
|
828
|
+
const bodyMassKilograms = optional(object.bodyMassKilograms, (value) => asNumber(value, `${at$}.bodyMassKilograms`));
|
|
829
|
+
const bodyFatPercent = optional(object.bodyFatPercent, (value) => asNumber(value, `${at$}.bodyFatPercent`));
|
|
830
|
+
const bodyMassIndex = optional(object.bodyMassIndex, (value) => asNumber(value, `${at$}.bodyMassIndex`));
|
|
831
|
+
const heightMeters = optional(object.heightMeters, (value) => asNumber(value, `${at$}.heightMeters`));
|
|
832
|
+
const leanBodyMassKilograms = optional(object.leanBodyMassKilograms, (value) => asNumber(value, `${at$}.leanBodyMassKilograms`));
|
|
833
|
+
const bodyTemperatureCelsius = optional(object.bodyTemperatureCelsius, (value) => asNumber(value, `${at$}.bodyTemperatureCelsius`));
|
|
834
|
+
const oxygenSaturationPercent = optional(object.oxygenSaturationPercent, (value) => asNumber(value, `${at$}.oxygenSaturationPercent`));
|
|
835
|
+
const bloodGlucoseMilligramsPerDeciliter = optional(object.bloodGlucoseMilligramsPerDeciliter, (value) => asNumber(value, `${at$}.bloodGlucoseMilligramsPerDeciliter`));
|
|
836
|
+
const bloodPressureSystolicMillimetersOfMercury = optional(object.bloodPressureSystolicMillimetersOfMercury, (value) => asNumber(value, `${at$}.bloodPressureSystolicMillimetersOfMercury`));
|
|
837
|
+
const bloodPressureDiastolicMillimetersOfMercury = optional(object.bloodPressureDiastolicMillimetersOfMercury, (value) => asNumber(value, `${at$}.bloodPressureDiastolicMillimetersOfMercury`));
|
|
838
|
+
const recordId = optional(object.recordId, (value) => asString(value, `${at$}.recordId`));
|
|
839
|
+
return { time, bodyMassKilograms, bodyFatPercent, bodyMassIndex, heightMeters, leanBodyMassKilograms, bodyTemperatureCelsius, oxygenSaturationPercent, bloodGlucoseMilligramsPerDeciliter, bloodPressureSystolicMillimetersOfMercury, bloodPressureDiastolicMillimetersOfMercury, recordId };
|
|
840
|
+
}
|
|
841
|
+
function encodeNutrients(value) {
|
|
842
|
+
const out = {};
|
|
843
|
+
if (value.energyKilocalories !== undefined)
|
|
844
|
+
out.energyKilocalories = value.energyKilocalories;
|
|
845
|
+
if (value.proteinGrams !== undefined)
|
|
846
|
+
out.proteinGrams = value.proteinGrams;
|
|
847
|
+
if (value.carbohydratesGrams !== undefined)
|
|
848
|
+
out.carbohydratesGrams = value.carbohydratesGrams;
|
|
849
|
+
if (value.fiberGrams !== undefined)
|
|
850
|
+
out.fiberGrams = value.fiberGrams;
|
|
851
|
+
if (value.sugarGrams !== undefined)
|
|
852
|
+
out.sugarGrams = value.sugarGrams;
|
|
853
|
+
if (value.fatTotalGrams !== undefined)
|
|
854
|
+
out.fatTotalGrams = value.fatTotalGrams;
|
|
855
|
+
if (value.fatSaturatedGrams !== undefined)
|
|
856
|
+
out.fatSaturatedGrams = value.fatSaturatedGrams;
|
|
857
|
+
if (value.fatMonounsaturatedGrams !== undefined)
|
|
858
|
+
out.fatMonounsaturatedGrams = value.fatMonounsaturatedGrams;
|
|
859
|
+
if (value.fatPolyunsaturatedGrams !== undefined)
|
|
860
|
+
out.fatPolyunsaturatedGrams = value.fatPolyunsaturatedGrams;
|
|
861
|
+
if (value.cholesterolMilligrams !== undefined)
|
|
862
|
+
out.cholesterolMilligrams = value.cholesterolMilligrams;
|
|
863
|
+
if (value.sodiumMilligrams !== undefined)
|
|
864
|
+
out.sodiumMilligrams = value.sodiumMilligrams;
|
|
865
|
+
if (value.potassiumMilligrams !== undefined)
|
|
866
|
+
out.potassiumMilligrams = value.potassiumMilligrams;
|
|
867
|
+
if (value.calciumMilligrams !== undefined)
|
|
868
|
+
out.calciumMilligrams = value.calciumMilligrams;
|
|
869
|
+
if (value.ironMilligrams !== undefined)
|
|
870
|
+
out.ironMilligrams = value.ironMilligrams;
|
|
871
|
+
if (value.magnesiumMilligrams !== undefined)
|
|
872
|
+
out.magnesiumMilligrams = value.magnesiumMilligrams;
|
|
873
|
+
if (value.zincMilligrams !== undefined)
|
|
874
|
+
out.zincMilligrams = value.zincMilligrams;
|
|
875
|
+
if (value.waterLiters !== undefined)
|
|
876
|
+
out.waterLiters = value.waterLiters;
|
|
877
|
+
if (value.caffeineMilligrams !== undefined)
|
|
878
|
+
out.caffeineMilligrams = value.caffeineMilligrams;
|
|
879
|
+
if (value.vitaminAMicrograms !== undefined)
|
|
880
|
+
out.vitaminAMicrograms = value.vitaminAMicrograms;
|
|
881
|
+
if (value.vitaminCMilligrams !== undefined)
|
|
882
|
+
out.vitaminCMilligrams = value.vitaminCMilligrams;
|
|
883
|
+
if (value.vitaminDMicrograms !== undefined)
|
|
884
|
+
out.vitaminDMicrograms = value.vitaminDMicrograms;
|
|
885
|
+
if (value.vitaminEMilligrams !== undefined)
|
|
886
|
+
out.vitaminEMilligrams = value.vitaminEMilligrams;
|
|
887
|
+
if (value.vitaminKMicrograms !== undefined)
|
|
888
|
+
out.vitaminKMicrograms = value.vitaminKMicrograms;
|
|
889
|
+
if (value.vitaminB6Milligrams !== undefined)
|
|
890
|
+
out.vitaminB6Milligrams = value.vitaminB6Milligrams;
|
|
891
|
+
if (value.vitaminB12Micrograms !== undefined)
|
|
892
|
+
out.vitaminB12Micrograms = value.vitaminB12Micrograms;
|
|
893
|
+
if (value.folateMicrograms !== undefined)
|
|
894
|
+
out.folateMicrograms = value.folateMicrograms;
|
|
895
|
+
if (value.thiaminMilligrams !== undefined)
|
|
896
|
+
out.thiaminMilligrams = value.thiaminMilligrams;
|
|
897
|
+
if (value.riboflavinMilligrams !== undefined)
|
|
898
|
+
out.riboflavinMilligrams = value.riboflavinMilligrams;
|
|
899
|
+
if (value.niacinMilligrams !== undefined)
|
|
900
|
+
out.niacinMilligrams = value.niacinMilligrams;
|
|
901
|
+
if (value.biotinMicrograms !== undefined)
|
|
902
|
+
out.biotinMicrograms = value.biotinMicrograms;
|
|
903
|
+
if (value.pantothenicAcidMilligrams !== undefined)
|
|
904
|
+
out.pantothenicAcidMilligrams = value.pantothenicAcidMilligrams;
|
|
905
|
+
if (value.phosphorusMilligrams !== undefined)
|
|
906
|
+
out.phosphorusMilligrams = value.phosphorusMilligrams;
|
|
907
|
+
if (value.iodineMicrograms !== undefined)
|
|
908
|
+
out.iodineMicrograms = value.iodineMicrograms;
|
|
909
|
+
if (value.chromiumMicrograms !== undefined)
|
|
910
|
+
out.chromiumMicrograms = value.chromiumMicrograms;
|
|
911
|
+
if (value.copperMilligrams !== undefined)
|
|
912
|
+
out.copperMilligrams = value.copperMilligrams;
|
|
913
|
+
if (value.manganeseMilligrams !== undefined)
|
|
914
|
+
out.manganeseMilligrams = value.manganeseMilligrams;
|
|
915
|
+
if (value.molybdenumMicrograms !== undefined)
|
|
916
|
+
out.molybdenumMicrograms = value.molybdenumMicrograms;
|
|
917
|
+
if (value.seleniumMicrograms !== undefined)
|
|
918
|
+
out.seleniumMicrograms = value.seleniumMicrograms;
|
|
919
|
+
if (value.chlorideMilligrams !== undefined)
|
|
920
|
+
out.chlorideMilligrams = value.chlorideMilligrams;
|
|
921
|
+
return out;
|
|
922
|
+
}
|
|
923
|
+
function decodeNutrients(raw, at$ = "Nutrients") {
|
|
924
|
+
const object = asObject(raw, at$);
|
|
925
|
+
const energyKilocalories = optional(object.energyKilocalories, (value) => asNumber(value, `${at$}.energyKilocalories`));
|
|
926
|
+
const proteinGrams = optional(object.proteinGrams, (value) => asNumber(value, `${at$}.proteinGrams`));
|
|
927
|
+
const carbohydratesGrams = optional(object.carbohydratesGrams, (value) => asNumber(value, `${at$}.carbohydratesGrams`));
|
|
928
|
+
const fiberGrams = optional(object.fiberGrams, (value) => asNumber(value, `${at$}.fiberGrams`));
|
|
929
|
+
const sugarGrams = optional(object.sugarGrams, (value) => asNumber(value, `${at$}.sugarGrams`));
|
|
930
|
+
const fatTotalGrams = optional(object.fatTotalGrams, (value) => asNumber(value, `${at$}.fatTotalGrams`));
|
|
931
|
+
const fatSaturatedGrams = optional(object.fatSaturatedGrams, (value) => asNumber(value, `${at$}.fatSaturatedGrams`));
|
|
932
|
+
const fatMonounsaturatedGrams = optional(object.fatMonounsaturatedGrams, (value) => asNumber(value, `${at$}.fatMonounsaturatedGrams`));
|
|
933
|
+
const fatPolyunsaturatedGrams = optional(object.fatPolyunsaturatedGrams, (value) => asNumber(value, `${at$}.fatPolyunsaturatedGrams`));
|
|
934
|
+
const cholesterolMilligrams = optional(object.cholesterolMilligrams, (value) => asNumber(value, `${at$}.cholesterolMilligrams`));
|
|
935
|
+
const sodiumMilligrams = optional(object.sodiumMilligrams, (value) => asNumber(value, `${at$}.sodiumMilligrams`));
|
|
936
|
+
const potassiumMilligrams = optional(object.potassiumMilligrams, (value) => asNumber(value, `${at$}.potassiumMilligrams`));
|
|
937
|
+
const calciumMilligrams = optional(object.calciumMilligrams, (value) => asNumber(value, `${at$}.calciumMilligrams`));
|
|
938
|
+
const ironMilligrams = optional(object.ironMilligrams, (value) => asNumber(value, `${at$}.ironMilligrams`));
|
|
939
|
+
const magnesiumMilligrams = optional(object.magnesiumMilligrams, (value) => asNumber(value, `${at$}.magnesiumMilligrams`));
|
|
940
|
+
const zincMilligrams = optional(object.zincMilligrams, (value) => asNumber(value, `${at$}.zincMilligrams`));
|
|
941
|
+
const waterLiters = optional(object.waterLiters, (value) => asNumber(value, `${at$}.waterLiters`));
|
|
942
|
+
const caffeineMilligrams = optional(object.caffeineMilligrams, (value) => asNumber(value, `${at$}.caffeineMilligrams`));
|
|
943
|
+
const vitaminAMicrograms = optional(object.vitaminAMicrograms, (value) => asNumber(value, `${at$}.vitaminAMicrograms`));
|
|
944
|
+
const vitaminCMilligrams = optional(object.vitaminCMilligrams, (value) => asNumber(value, `${at$}.vitaminCMilligrams`));
|
|
945
|
+
const vitaminDMicrograms = optional(object.vitaminDMicrograms, (value) => asNumber(value, `${at$}.vitaminDMicrograms`));
|
|
946
|
+
const vitaminEMilligrams = optional(object.vitaminEMilligrams, (value) => asNumber(value, `${at$}.vitaminEMilligrams`));
|
|
947
|
+
const vitaminKMicrograms = optional(object.vitaminKMicrograms, (value) => asNumber(value, `${at$}.vitaminKMicrograms`));
|
|
948
|
+
const vitaminB6Milligrams = optional(object.vitaminB6Milligrams, (value) => asNumber(value, `${at$}.vitaminB6Milligrams`));
|
|
949
|
+
const vitaminB12Micrograms = optional(object.vitaminB12Micrograms, (value) => asNumber(value, `${at$}.vitaminB12Micrograms`));
|
|
950
|
+
const folateMicrograms = optional(object.folateMicrograms, (value) => asNumber(value, `${at$}.folateMicrograms`));
|
|
951
|
+
const thiaminMilligrams = optional(object.thiaminMilligrams, (value) => asNumber(value, `${at$}.thiaminMilligrams`));
|
|
952
|
+
const riboflavinMilligrams = optional(object.riboflavinMilligrams, (value) => asNumber(value, `${at$}.riboflavinMilligrams`));
|
|
953
|
+
const niacinMilligrams = optional(object.niacinMilligrams, (value) => asNumber(value, `${at$}.niacinMilligrams`));
|
|
954
|
+
const biotinMicrograms = optional(object.biotinMicrograms, (value) => asNumber(value, `${at$}.biotinMicrograms`));
|
|
955
|
+
const pantothenicAcidMilligrams = optional(object.pantothenicAcidMilligrams, (value) => asNumber(value, `${at$}.pantothenicAcidMilligrams`));
|
|
956
|
+
const phosphorusMilligrams = optional(object.phosphorusMilligrams, (value) => asNumber(value, `${at$}.phosphorusMilligrams`));
|
|
957
|
+
const iodineMicrograms = optional(object.iodineMicrograms, (value) => asNumber(value, `${at$}.iodineMicrograms`));
|
|
958
|
+
const chromiumMicrograms = optional(object.chromiumMicrograms, (value) => asNumber(value, `${at$}.chromiumMicrograms`));
|
|
959
|
+
const copperMilligrams = optional(object.copperMilligrams, (value) => asNumber(value, `${at$}.copperMilligrams`));
|
|
960
|
+
const manganeseMilligrams = optional(object.manganeseMilligrams, (value) => asNumber(value, `${at$}.manganeseMilligrams`));
|
|
961
|
+
const molybdenumMicrograms = optional(object.molybdenumMicrograms, (value) => asNumber(value, `${at$}.molybdenumMicrograms`));
|
|
962
|
+
const seleniumMicrograms = optional(object.seleniumMicrograms, (value) => asNumber(value, `${at$}.seleniumMicrograms`));
|
|
963
|
+
const chlorideMilligrams = optional(object.chlorideMilligrams, (value) => asNumber(value, `${at$}.chlorideMilligrams`));
|
|
964
|
+
return { energyKilocalories, proteinGrams, carbohydratesGrams, fiberGrams, sugarGrams, fatTotalGrams, fatSaturatedGrams, fatMonounsaturatedGrams, fatPolyunsaturatedGrams, cholesterolMilligrams, sodiumMilligrams, potassiumMilligrams, calciumMilligrams, ironMilligrams, magnesiumMilligrams, zincMilligrams, waterLiters, caffeineMilligrams, vitaminAMicrograms, vitaminCMilligrams, vitaminDMicrograms, vitaminEMilligrams, vitaminKMicrograms, vitaminB6Milligrams, vitaminB12Micrograms, folateMicrograms, thiaminMilligrams, riboflavinMilligrams, niacinMilligrams, biotinMicrograms, pantothenicAcidMilligrams, phosphorusMilligrams, iodineMicrograms, chromiumMicrograms, copperMilligrams, manganeseMilligrams, molybdenumMicrograms, seleniumMicrograms, chlorideMilligrams };
|
|
965
|
+
}
|
|
966
|
+
function encodeNutritionEntry(value) {
|
|
967
|
+
const out = {};
|
|
968
|
+
out.start = encodeInstant(value.start);
|
|
969
|
+
out.end = encodeInstant(value.end);
|
|
970
|
+
if (value.name !== undefined)
|
|
971
|
+
out.name = value.name;
|
|
972
|
+
out.nutrients = encodeNutrients(value.nutrients);
|
|
973
|
+
if (value.recordId !== undefined)
|
|
974
|
+
out.recordId = value.recordId;
|
|
975
|
+
return out;
|
|
976
|
+
}
|
|
977
|
+
function decodeNutritionEntry(raw, at$ = "NutritionEntry") {
|
|
978
|
+
const object = asObject(raw, at$);
|
|
979
|
+
const start = decodeInstant(object.start, `${at$}.start`);
|
|
980
|
+
const end = decodeInstant(object.end, `${at$}.end`);
|
|
981
|
+
const name = optional(object.name, (value) => asString(value, `${at$}.name`));
|
|
982
|
+
const nutrients = decodeNutrients(object.nutrients, `${at$}.nutrients`);
|
|
983
|
+
const recordId = optional(object.recordId, (value) => asString(value, `${at$}.recordId`));
|
|
984
|
+
return { start, end, name, nutrients, recordId };
|
|
985
|
+
}
|
|
986
|
+
function encodeTerraErrorPayload(value) {
|
|
987
|
+
const out = {};
|
|
988
|
+
out.code = value.code;
|
|
989
|
+
out.retryable = value.retryable;
|
|
990
|
+
out.message = value.message;
|
|
991
|
+
if (value.source !== undefined)
|
|
992
|
+
out.source = value.source;
|
|
993
|
+
if (value.details !== undefined)
|
|
994
|
+
out.details = value.details;
|
|
995
|
+
return out;
|
|
996
|
+
}
|
|
997
|
+
function decodeTerraErrorPayload(raw, at$ = "TerraErrorPayload") {
|
|
998
|
+
const object = asObject(raw, at$);
|
|
999
|
+
const code = asString(object.code, `${at$}.code`);
|
|
1000
|
+
const retryable = asBoolean(object.retryable, `${at$}.retryable`);
|
|
1001
|
+
const message = asString(object.message, `${at$}.message`);
|
|
1002
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1003
|
+
const details = optional(object.details, (value) => asObject(value, `${at$}.details`));
|
|
1004
|
+
return { code, retryable, message, source, details };
|
|
1005
|
+
}
|
|
1006
|
+
function encodePlannedWorkout(value) {
|
|
1007
|
+
const out = {};
|
|
1008
|
+
out.id = value.id;
|
|
1009
|
+
out.plannedOn = value.plannedOn;
|
|
1010
|
+
out.activity = encodeWorkoutActivity(value.activity);
|
|
1011
|
+
if (value.title !== undefined)
|
|
1012
|
+
out.title = value.title;
|
|
1013
|
+
if (value.completedAt !== undefined)
|
|
1014
|
+
out.completedAt = encodeInstant(value.completedAt);
|
|
1015
|
+
return out;
|
|
1016
|
+
}
|
|
1017
|
+
function decodePlannedWorkout(raw, at$ = "PlannedWorkout") {
|
|
1018
|
+
const object = asObject(raw, at$);
|
|
1019
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1020
|
+
const plannedOn = asString(object.plannedOn, `${at$}.plannedOn`);
|
|
1021
|
+
const activity = decodeWorkoutActivity(object.activity, `${at$}.activity`);
|
|
1022
|
+
const title = optional(object.title, (value) => asString(value, `${at$}.title`));
|
|
1023
|
+
const completedAt = optional(object.completedAt, (value) => decodeInstant(value, `${at$}.completedAt`));
|
|
1024
|
+
return { id, plannedOn, activity, title, completedAt };
|
|
1025
|
+
}
|
|
1026
|
+
function encodeTerraEvent(value) {
|
|
1027
|
+
return value;
|
|
1028
|
+
}
|
|
1029
|
+
function decodeTerraEvent(raw, at$ = "TerraEvent") {
|
|
1030
|
+
const object = asObject(raw, at$);
|
|
1031
|
+
if (!(typeof object["at"] === "string")) {
|
|
1032
|
+
throw new TypeError(`${at$}: at is not a string`);
|
|
1033
|
+
}
|
|
1034
|
+
if (!(typeof object["event"] === "string")) {
|
|
1035
|
+
throw new TypeError(`${at$}: event is not a string`);
|
|
1036
|
+
}
|
|
1037
|
+
return object;
|
|
1038
|
+
}
|
|
1039
|
+
function encodeSupportReport(value) {
|
|
1040
|
+
const out = {};
|
|
1041
|
+
out.sdkVersion = value.sdkVersion;
|
|
1042
|
+
out.generatedAt = encodeInstant(value.generatedAt);
|
|
1043
|
+
out.state = encodeDiagnosticsState(value.state);
|
|
1044
|
+
if (value.lastDelivery !== undefined)
|
|
1045
|
+
out.lastDelivery = encodeInstant(value.lastDelivery);
|
|
1046
|
+
out.isConnected = value.isConnected;
|
|
1047
|
+
out.requestedCategories = value.requestedCategories;
|
|
1048
|
+
out.requestedWrites = value.requestedWrites;
|
|
1049
|
+
out.requestedWorkouts = value.requestedWorkouts;
|
|
1050
|
+
out.recentEvents = value.recentEvents.map((item) => encodeTerraEvent(item));
|
|
1051
|
+
return out;
|
|
1052
|
+
}
|
|
1053
|
+
function decodeSupportReport(raw, at$ = "SupportReport") {
|
|
1054
|
+
const object = asObject(raw, at$);
|
|
1055
|
+
const sdkVersion = asString(object.sdkVersion, `${at$}.sdkVersion`);
|
|
1056
|
+
const generatedAt = decodeInstant(object.generatedAt, `${at$}.generatedAt`);
|
|
1057
|
+
const state = decodeDiagnosticsState(object.state, `${at$}.state`);
|
|
1058
|
+
const lastDelivery = optional(object.lastDelivery, (value) => decodeInstant(value, `${at$}.lastDelivery`));
|
|
1059
|
+
const isConnected = asBoolean(object.isConnected, `${at$}.isConnected`);
|
|
1060
|
+
const requestedCategories = asArray(object.requestedCategories, `${at$}.requestedCategories`).map((item, index) => asString(item, `${`${at$}.requestedCategories`}[${index}]`));
|
|
1061
|
+
const requestedWrites = asArray(object.requestedWrites, `${at$}.requestedWrites`).map((item, index) => asString(item, `${`${at$}.requestedWrites`}[${index}]`));
|
|
1062
|
+
const requestedWorkouts = asArray(object.requestedWorkouts, `${at$}.requestedWorkouts`).map((item, index) => asString(item, `${`${at$}.requestedWorkouts`}[${index}]`));
|
|
1063
|
+
const recentEvents = asArray(object.recentEvents, `${at$}.recentEvents`).map((item, index) => decodeTerraEvent(item, `${`${at$}.recentEvents`}[${index}]`));
|
|
1064
|
+
return { sdkVersion, generatedAt, state, lastDelivery, isConnected, requestedCategories, requestedWrites, requestedWorkouts, recentEvents };
|
|
1065
|
+
}
|
|
1066
|
+
function encodeBootstrapState(value) {
|
|
1067
|
+
const out = {};
|
|
1068
|
+
out.bootstrapped = value.bootstrapped;
|
|
1069
|
+
if (value.devId !== undefined)
|
|
1070
|
+
out.devId = value.devId;
|
|
1071
|
+
out.platform = value.platform;
|
|
1072
|
+
out.sdkVersion = value.sdkVersion;
|
|
1073
|
+
out.backgroundRegistered = value.backgroundRegistered;
|
|
1074
|
+
return out;
|
|
1075
|
+
}
|
|
1076
|
+
function decodeBootstrapState(raw, at$ = "BootstrapState") {
|
|
1077
|
+
const object = asObject(raw, at$);
|
|
1078
|
+
const bootstrapped = asBoolean(object.bootstrapped, `${at$}.bootstrapped`);
|
|
1079
|
+
const devId = optional(object.devId, (value) => asString(value, `${at$}.devId`));
|
|
1080
|
+
const platform = asString(object.platform, `${at$}.platform`);
|
|
1081
|
+
const sdkVersion = asString(object.sdkVersion, `${at$}.sdkVersion`);
|
|
1082
|
+
const backgroundRegistered = asBoolean(object.backgroundRegistered, `${at$}.backgroundRegistered`);
|
|
1083
|
+
return { bootstrapped, devId, platform, sdkVersion, backgroundRegistered };
|
|
1084
|
+
}
|
|
1085
|
+
function encodeTokenRequest(value) {
|
|
1086
|
+
const out = {};
|
|
1087
|
+
out.requestId = value.requestId;
|
|
1088
|
+
return out;
|
|
1089
|
+
}
|
|
1090
|
+
function decodeTokenRequest(raw, at$ = "TokenRequest") {
|
|
1091
|
+
const object = asObject(raw, at$);
|
|
1092
|
+
const requestId = asString(object.requestId, `${at$}.requestId`);
|
|
1093
|
+
return { requestId };
|
|
1094
|
+
}
|
|
1095
|
+
function encodeEmpty(_value) {
|
|
1096
|
+
return {};
|
|
1097
|
+
}
|
|
1098
|
+
function decodeEmpty(raw, at$ = "Empty") {
|
|
1099
|
+
asObject(raw, at$);
|
|
1100
|
+
return {};
|
|
1101
|
+
}
|
|
1102
|
+
function encodeSourceRequest(value) {
|
|
1103
|
+
const out = {};
|
|
1104
|
+
if (value.source !== undefined)
|
|
1105
|
+
out.source = value.source;
|
|
1106
|
+
return out;
|
|
1107
|
+
}
|
|
1108
|
+
function decodeSourceRequest(raw, at$ = "SourceRequest") {
|
|
1109
|
+
const object = asObject(raw, at$);
|
|
1110
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1111
|
+
return { source };
|
|
1112
|
+
}
|
|
1113
|
+
function encodeRangeRequest(value) {
|
|
1114
|
+
const out = {};
|
|
1115
|
+
out.range = encodeTimeRange(value.range);
|
|
1116
|
+
return out;
|
|
1117
|
+
}
|
|
1118
|
+
function decodeRangeRequest(raw, at$ = "RangeRequest") {
|
|
1119
|
+
const object = asObject(raw, at$);
|
|
1120
|
+
const range = decodeTimeRange(object.range, `${at$}.range`);
|
|
1121
|
+
return { range };
|
|
1122
|
+
}
|
|
1123
|
+
function encodeCategoryRequest(value) {
|
|
1124
|
+
const out = {};
|
|
1125
|
+
out.category = value.category;
|
|
1126
|
+
if (value.source !== undefined)
|
|
1127
|
+
out.source = value.source;
|
|
1128
|
+
return out;
|
|
1129
|
+
}
|
|
1130
|
+
function decodeCategoryRequest(raw, at$ = "CategoryRequest") {
|
|
1131
|
+
const object = asObject(raw, at$);
|
|
1132
|
+
const category = asDataCategory(object.category, `${at$}.category`);
|
|
1133
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1134
|
+
return { category, source };
|
|
1135
|
+
}
|
|
1136
|
+
function encodeRecordIdRequest(value) {
|
|
1137
|
+
const out = {};
|
|
1138
|
+
out.id = value.id;
|
|
1139
|
+
return out;
|
|
1140
|
+
}
|
|
1141
|
+
function decodeRecordIdRequest(raw, at$ = "RecordIdRequest") {
|
|
1142
|
+
const object = asObject(raw, at$);
|
|
1143
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1144
|
+
return { id };
|
|
1145
|
+
}
|
|
1146
|
+
function encodeConnectRequest(value) {
|
|
1147
|
+
const out = {};
|
|
1148
|
+
if (value.source !== undefined)
|
|
1149
|
+
out.source = value.source;
|
|
1150
|
+
out.endUser = encodeEndUser(value.endUser);
|
|
1151
|
+
if (value.token !== undefined)
|
|
1152
|
+
out.token = value.token;
|
|
1153
|
+
return out;
|
|
1154
|
+
}
|
|
1155
|
+
function decodeConnectRequest(raw, at$ = "ConnectRequest") {
|
|
1156
|
+
const object = asObject(raw, at$);
|
|
1157
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1158
|
+
const endUser = decodeEndUser(object.endUser, `${at$}.endUser`);
|
|
1159
|
+
const token = optional(object.token, (value) => asString(value, `${at$}.token`));
|
|
1160
|
+
return { source, endUser, token };
|
|
1161
|
+
}
|
|
1162
|
+
function encodePermissionRequest(value) {
|
|
1163
|
+
const out = {};
|
|
1164
|
+
out.read = caseSet(value.read);
|
|
1165
|
+
out.write = caseSet(value.write);
|
|
1166
|
+
out.workouts = value.workouts.map((item) => encodeWorkoutScope(item));
|
|
1167
|
+
if (value.source !== undefined)
|
|
1168
|
+
out.source = value.source;
|
|
1169
|
+
return out;
|
|
1170
|
+
}
|
|
1171
|
+
function decodePermissionRequest(raw, at$ = "PermissionRequest") {
|
|
1172
|
+
const object = asObject(raw, at$);
|
|
1173
|
+
const read = caseSet(asArray(object.read, `${at$}.read`).map((item, index) => asDataCategory(item, `${`${at$}.read`}[${index}]`)));
|
|
1174
|
+
const write = caseSet(asArray(object.write, `${at$}.write`).map((item, index) => asDataCategory(item, `${`${at$}.write`}[${index}]`)));
|
|
1175
|
+
const workouts = asArray(object.workouts, `${at$}.workouts`).map((item, index) => decodeWorkoutScope(item, `${`${at$}.workouts`}[${index}]`));
|
|
1176
|
+
const source = optional(object.source, (value) => asSource(value, `${at$}.source`));
|
|
1177
|
+
return { read, write, workouts, source };
|
|
1178
|
+
}
|
|
1179
|
+
function encodePermissionGrant(value) {
|
|
1180
|
+
const out = {};
|
|
1181
|
+
if (value.granted !== undefined)
|
|
1182
|
+
out.granted = encodeHealthAccess(value.granted);
|
|
1183
|
+
return out;
|
|
1184
|
+
}
|
|
1185
|
+
function decodePermissionGrant(raw, at$ = "PermissionGrant") {
|
|
1186
|
+
const object = asObject(raw, at$);
|
|
1187
|
+
const granted = optional(object.granted, (value) => decodeHealthAccess(value, `${at$}.granted`));
|
|
1188
|
+
return { granted };
|
|
1189
|
+
}
|
|
1190
|
+
function encodeTokenResolveRequest(value) {
|
|
1191
|
+
const out = {};
|
|
1192
|
+
out.requestId = value.requestId;
|
|
1193
|
+
out.token = value.token;
|
|
1194
|
+
return out;
|
|
1195
|
+
}
|
|
1196
|
+
function decodeTokenResolveRequest(raw, at$ = "TokenResolveRequest") {
|
|
1197
|
+
const object = asObject(raw, at$);
|
|
1198
|
+
const requestId = asString(object.requestId, `${at$}.requestId`);
|
|
1199
|
+
const token = asString(object.token, `${at$}.token`);
|
|
1200
|
+
return { requestId, token };
|
|
1201
|
+
}
|
|
1202
|
+
function encodeTokenRejectRequest(value) {
|
|
1203
|
+
const out = {};
|
|
1204
|
+
out.requestId = value.requestId;
|
|
1205
|
+
out.message = value.message;
|
|
1206
|
+
return out;
|
|
1207
|
+
}
|
|
1208
|
+
function decodeTokenRejectRequest(raw, at$ = "TokenRejectRequest") {
|
|
1209
|
+
const object = asObject(raw, at$);
|
|
1210
|
+
const requestId = asString(object.requestId, `${at$}.requestId`);
|
|
1211
|
+
const message = asString(object.message, `${at$}.message`);
|
|
1212
|
+
return { requestId, message };
|
|
1213
|
+
}
|
|
1214
|
+
function encodeTokenProviderRequest(value) {
|
|
1215
|
+
const out = {};
|
|
1216
|
+
out.present = value.present;
|
|
1217
|
+
out.timeoutMs = value.timeoutMs;
|
|
1218
|
+
return out;
|
|
1219
|
+
}
|
|
1220
|
+
function decodeTokenProviderRequest(raw, at$ = "TokenProviderRequest") {
|
|
1221
|
+
const object = asObject(raw, at$);
|
|
1222
|
+
const present = asBoolean(object.present, `${at$}.present`);
|
|
1223
|
+
const timeoutMs = asInteger(object.timeoutMs, `${at$}.timeoutMs`);
|
|
1224
|
+
return { present, timeoutMs };
|
|
1225
|
+
}
|
|
1226
|
+
function encodeMarkCompleteRequest(value) {
|
|
1227
|
+
const out = {};
|
|
1228
|
+
out.id = value.id;
|
|
1229
|
+
if (value.at !== undefined)
|
|
1230
|
+
out.at = encodeInstant(value.at);
|
|
1231
|
+
return out;
|
|
1232
|
+
}
|
|
1233
|
+
function decodeMarkCompleteRequest(raw, at$ = "MarkCompleteRequest") {
|
|
1234
|
+
const object = asObject(raw, at$);
|
|
1235
|
+
const id = asString(object.id, `${at$}.id`);
|
|
1236
|
+
const at = optional(object.at, (value) => decodeInstant(value, `${at$}.at`));
|
|
1237
|
+
return { id, at };
|
|
1238
|
+
}
|
|
1239
|
+
function encodeBoolResult(value) {
|
|
1240
|
+
const out = {};
|
|
1241
|
+
out.value = value.value;
|
|
1242
|
+
return out;
|
|
1243
|
+
}
|
|
1244
|
+
function decodeBoolResult(raw, at$ = "BoolResult") {
|
|
1245
|
+
const object = asObject(raw, at$);
|
|
1246
|
+
const value = asBoolean(object.value, `${at$}.value`);
|
|
1247
|
+
return { value };
|
|
1248
|
+
}
|
|
1249
|
+
function encodeStatusResult(value) {
|
|
1250
|
+
const out = {};
|
|
1251
|
+
out.status = value.status;
|
|
1252
|
+
return out;
|
|
1253
|
+
}
|
|
1254
|
+
function decodeStatusResult(raw, at$ = "StatusResult") {
|
|
1255
|
+
const object = asObject(raw, at$);
|
|
1256
|
+
const status = asPermissionStatus(object.status, `${at$}.status`);
|
|
1257
|
+
return { status };
|
|
1258
|
+
}
|
|
1259
|
+
function encodeStatusesResult(value) {
|
|
1260
|
+
const out = {};
|
|
1261
|
+
out.statuses = value.statuses;
|
|
1262
|
+
return out;
|
|
1263
|
+
}
|
|
1264
|
+
function decodeStatusesResult(raw, at$ = "StatusesResult") {
|
|
1265
|
+
const object = asObject(raw, at$);
|
|
1266
|
+
const statuses = Object.fromEntries(Object.entries(asObject(object.statuses, `${at$}.statuses`)).map(([key, item]) => [asDataCategory(key, `${at$}.statuses`), asPermissionStatus(item, `${at$}.statuses`)]));
|
|
1267
|
+
return { statuses };
|
|
1268
|
+
}
|
|
1269
|
+
function encodeRecordIdList(value) {
|
|
1270
|
+
const out = {};
|
|
1271
|
+
out.ids = value.ids;
|
|
1272
|
+
return out;
|
|
1273
|
+
}
|
|
1274
|
+
function decodeRecordIdList(raw, at$ = "RecordIdList") {
|
|
1275
|
+
const object = asObject(raw, at$);
|
|
1276
|
+
const ids = asArray(object.ids, `${at$}.ids`).map((item, index) => asString(item, `${`${at$}.ids`}[${index}]`));
|
|
1277
|
+
return { ids };
|
|
1278
|
+
}
|
|
1279
|
+
function encodeConnectionList(value) {
|
|
1280
|
+
const out = {};
|
|
1281
|
+
out.connections = value.connections.map((item) => encodeConnection(item));
|
|
1282
|
+
return out;
|
|
1283
|
+
}
|
|
1284
|
+
function decodeConnectionList(raw, at$ = "ConnectionList") {
|
|
1285
|
+
const object = asObject(raw, at$);
|
|
1286
|
+
const connections = asArray(object.connections, `${at$}.connections`).map((item, index) => decodeConnection(item, `${`${at$}.connections`}[${index}]`));
|
|
1287
|
+
return { connections };
|
|
1288
|
+
}
|
|
1289
|
+
function encodeHeartRateList(value) {
|
|
1290
|
+
const out = {};
|
|
1291
|
+
out.samples = value.samples.map((item) => encodeHeartRateSample(item));
|
|
1292
|
+
return out;
|
|
1293
|
+
}
|
|
1294
|
+
function decodeHeartRateList(raw, at$ = "HeartRateList") {
|
|
1295
|
+
const object = asObject(raw, at$);
|
|
1296
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeHeartRateSample(item, `${`${at$}.samples`}[${index}]`));
|
|
1297
|
+
return { samples };
|
|
1298
|
+
}
|
|
1299
|
+
function encodeStepCountList(value) {
|
|
1300
|
+
const out = {};
|
|
1301
|
+
out.samples = value.samples.map((item) => encodeStepCount(item));
|
|
1302
|
+
return out;
|
|
1303
|
+
}
|
|
1304
|
+
function decodeStepCountList(raw, at$ = "StepCountList") {
|
|
1305
|
+
const object = asObject(raw, at$);
|
|
1306
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeStepCount(item, `${`${at$}.samples`}[${index}]`));
|
|
1307
|
+
return { samples };
|
|
1308
|
+
}
|
|
1309
|
+
function encodeSleepSegmentList(value) {
|
|
1310
|
+
const out = {};
|
|
1311
|
+
out.samples = value.samples.map((item) => encodeSleepSegment(item));
|
|
1312
|
+
return out;
|
|
1313
|
+
}
|
|
1314
|
+
function decodeSleepSegmentList(raw, at$ = "SleepSegmentList") {
|
|
1315
|
+
const object = asObject(raw, at$);
|
|
1316
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeSleepSegment(item, `${`${at$}.samples`}[${index}]`));
|
|
1317
|
+
return { samples };
|
|
1318
|
+
}
|
|
1319
|
+
function encodeWorkoutList(value) {
|
|
1320
|
+
const out = {};
|
|
1321
|
+
out.samples = value.samples.map((item) => encodeWorkout(item));
|
|
1322
|
+
return out;
|
|
1323
|
+
}
|
|
1324
|
+
function decodeWorkoutList(raw, at$ = "WorkoutList") {
|
|
1325
|
+
const object = asObject(raw, at$);
|
|
1326
|
+
const samples = asArray(object.samples, `${at$}.samples`).map((item, index) => decodeWorkout(item, `${`${at$}.samples`}[${index}]`));
|
|
1327
|
+
return { samples };
|
|
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
|
+
}
|
|
1396
|
+
function encodePlannedWorkoutList(value) {
|
|
1397
|
+
const out = {};
|
|
1398
|
+
out.workouts = value.workouts.map((item) => encodePlannedWorkout(item));
|
|
1399
|
+
return out;
|
|
1400
|
+
}
|
|
1401
|
+
function decodePlannedWorkoutList(raw, at$ = "PlannedWorkoutList") {
|
|
1402
|
+
const object = asObject(raw, at$);
|
|
1403
|
+
const workouts = asArray(object.workouts, `${at$}.workouts`).map((item, index) => decodePlannedWorkout(item, `${`${at$}.workouts`}[${index}]`));
|
|
1404
|
+
return { workouts };
|
|
1405
|
+
}
|
|
1406
|
+
function encodeWorkoutScheduling(value) {
|
|
1407
|
+
const out = {};
|
|
1408
|
+
out.status = value.status;
|
|
1409
|
+
return out;
|
|
1410
|
+
}
|
|
1411
|
+
function decodeWorkoutScheduling(raw, at$ = "WorkoutScheduling") {
|
|
1412
|
+
const object = asObject(raw, at$);
|
|
1413
|
+
const status = asWorkoutSchedulingStatus(object.status, `${at$}.status`);
|
|
1414
|
+
return { status };
|
|
1415
|
+
}
|
|
1416
|
+
function encodeLastDeliveryResult(value) {
|
|
1417
|
+
const out = {};
|
|
1418
|
+
if (value.at !== undefined)
|
|
1419
|
+
out.at = encodeInstant(value.at);
|
|
1420
|
+
return out;
|
|
1421
|
+
}
|
|
1422
|
+
function decodeLastDeliveryResult(raw, at$ = "LastDeliveryResult") {
|
|
1423
|
+
const object = asObject(raw, at$);
|
|
1424
|
+
const at = optional(object.at, (value) => decodeInstant(value, `${at$}.at`));
|
|
1425
|
+
return { at };
|
|
1426
|
+
}
|
|
1427
|
+
function encodeHeartRateEntryList(value) {
|
|
1428
|
+
const out = {};
|
|
1429
|
+
out.entries = value.entries.map((item) => encodeHeartRateEntry(item));
|
|
1430
|
+
return out;
|
|
1431
|
+
}
|
|
1432
|
+
function decodeHeartRateEntryList(raw, at$ = "HeartRateEntryList") {
|
|
1433
|
+
const object = asObject(raw, at$);
|
|
1434
|
+
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeHeartRateEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1435
|
+
return { entries };
|
|
1436
|
+
}
|
|
1437
|
+
function encodeBodyEntryList(value) {
|
|
1438
|
+
const out = {};
|
|
1439
|
+
out.entries = value.entries.map((item) => encodeBodyEntry(item));
|
|
1440
|
+
return out;
|
|
1441
|
+
}
|
|
1442
|
+
function decodeBodyEntryList(raw, at$ = "BodyEntryList") {
|
|
1443
|
+
const object = asObject(raw, at$);
|
|
1444
|
+
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeBodyEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1445
|
+
return { entries };
|
|
1446
|
+
}
|
|
1447
|
+
function encodeStepEntryList(value) {
|
|
1448
|
+
const out = {};
|
|
1449
|
+
out.entries = value.entries.map((item) => encodeStepEntry(item));
|
|
1450
|
+
return out;
|
|
1451
|
+
}
|
|
1452
|
+
function decodeStepEntryList(raw, at$ = "StepEntryList") {
|
|
1453
|
+
const object = asObject(raw, at$);
|
|
1454
|
+
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeStepEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1455
|
+
return { entries };
|
|
1456
|
+
}
|
|
1457
|
+
function encodeSleepEntryList(value) {
|
|
1458
|
+
const out = {};
|
|
1459
|
+
out.entries = value.entries.map((item) => encodeSleepEntry(item));
|
|
1460
|
+
return out;
|
|
1461
|
+
}
|
|
1462
|
+
function decodeSleepEntryList(raw, at$ = "SleepEntryList") {
|
|
1463
|
+
const object = asObject(raw, at$);
|
|
1464
|
+
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeSleepEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1465
|
+
return { entries };
|
|
1466
|
+
}
|
|
1467
|
+
function encodeWorkoutEntryList(value) {
|
|
1468
|
+
const out = {};
|
|
1469
|
+
out.entries = value.entries.map((item) => encodeWorkoutEntry(item));
|
|
1470
|
+
return out;
|
|
1471
|
+
}
|
|
1472
|
+
function decodeWorkoutEntryList(raw, at$ = "WorkoutEntryList") {
|
|
1473
|
+
const object = asObject(raw, at$);
|
|
1474
|
+
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeWorkoutEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1475
|
+
return { entries };
|
|
1476
|
+
}
|
|
1477
|
+
function encodeNutritionEntryList(value) {
|
|
1478
|
+
const out = {};
|
|
1479
|
+
out.entries = value.entries.map((item) => encodeNutritionEntry(item));
|
|
1480
|
+
return out;
|
|
1481
|
+
}
|
|
1482
|
+
function decodeNutritionEntryList(raw, at$ = "NutritionEntryList") {
|
|
1483
|
+
const object = asObject(raw, at$);
|
|
1484
|
+
const entries = asArray(object.entries, `${at$}.entries`).map((item, index) => decodeNutritionEntry(item, `${`${at$}.entries`}[${index}]`));
|
|
1485
|
+
return { entries };
|
|
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
|
+
}
|
|
1747
|
+
function encodeEndUser(value) {
|
|
1748
|
+
switch (value.kind) {
|
|
1749
|
+
case "reference":
|
|
1750
|
+
return { kind: "reference", id: value.id };
|
|
1751
|
+
case "anonymous":
|
|
1752
|
+
return { kind: "anonymous" };
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
function decodeEndUser(raw, at$ = "EndUser") {
|
|
1756
|
+
const object = asObject(raw, at$);
|
|
1757
|
+
const tag = object.kind;
|
|
1758
|
+
switch (tag) {
|
|
1759
|
+
case "reference": {
|
|
1760
|
+
return { kind: "reference", id: asString(object.id, `${at$}.id`) };
|
|
1761
|
+
}
|
|
1762
|
+
case "anonymous": {
|
|
1763
|
+
return { kind: "anonymous" };
|
|
1764
|
+
}
|
|
1765
|
+
default:
|
|
1766
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
function encodeTimeRange(value) {
|
|
1770
|
+
switch (value.kind) {
|
|
1771
|
+
case "lastHours":
|
|
1772
|
+
return { kind: "lastHours", hours: value.hours };
|
|
1773
|
+
case "lastDays":
|
|
1774
|
+
return { kind: "lastDays", days: value.days };
|
|
1775
|
+
case "today":
|
|
1776
|
+
return { kind: "today" };
|
|
1777
|
+
case "between":
|
|
1778
|
+
return { kind: "between", start: encodeInstant(value.start), end: encodeInstant(value.end) };
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
function decodeTimeRange(raw, at$ = "TimeRange") {
|
|
1782
|
+
const object = asObject(raw, at$);
|
|
1783
|
+
const tag = object.kind;
|
|
1784
|
+
switch (tag) {
|
|
1785
|
+
case "lastHours": {
|
|
1786
|
+
return { kind: "lastHours", hours: asInteger(object.hours, `${at$}.hours`) };
|
|
1787
|
+
}
|
|
1788
|
+
case "lastDays": {
|
|
1789
|
+
return { kind: "lastDays", days: asInteger(object.days, `${at$}.days`) };
|
|
1790
|
+
}
|
|
1791
|
+
case "today": {
|
|
1792
|
+
return { kind: "today" };
|
|
1793
|
+
}
|
|
1794
|
+
case "between": {
|
|
1795
|
+
return { kind: "between", start: decodeInstant(object.start, `${at$}.start`), end: decodeInstant(object.end, `${at$}.end`) };
|
|
1796
|
+
}
|
|
1797
|
+
default:
|
|
1798
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
function encodeSleepStage(value) {
|
|
1802
|
+
switch (value.kind) {
|
|
1803
|
+
case "inBed":
|
|
1804
|
+
return { kind: "inBed" };
|
|
1805
|
+
case "awake":
|
|
1806
|
+
return { kind: "awake" };
|
|
1807
|
+
case "asleep":
|
|
1808
|
+
return { kind: "asleep" };
|
|
1809
|
+
case "light":
|
|
1810
|
+
return { kind: "light" };
|
|
1811
|
+
case "deep":
|
|
1812
|
+
return { kind: "deep" };
|
|
1813
|
+
case "rem":
|
|
1814
|
+
return { kind: "rem" };
|
|
1815
|
+
case "unknown":
|
|
1816
|
+
return { kind: "unknown", raw: value.raw };
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
function decodeSleepStage(raw, at$ = "SleepStage") {
|
|
1820
|
+
const object = asObject(raw, at$);
|
|
1821
|
+
const tag = object.kind;
|
|
1822
|
+
switch (tag) {
|
|
1823
|
+
case "inBed": {
|
|
1824
|
+
return { kind: "inBed" };
|
|
1825
|
+
}
|
|
1826
|
+
case "awake": {
|
|
1827
|
+
return { kind: "awake" };
|
|
1828
|
+
}
|
|
1829
|
+
case "asleep": {
|
|
1830
|
+
return { kind: "asleep" };
|
|
1831
|
+
}
|
|
1832
|
+
case "light": {
|
|
1833
|
+
return { kind: "light" };
|
|
1834
|
+
}
|
|
1835
|
+
case "deep": {
|
|
1836
|
+
return { kind: "deep" };
|
|
1837
|
+
}
|
|
1838
|
+
case "rem": {
|
|
1839
|
+
return { kind: "rem" };
|
|
1840
|
+
}
|
|
1841
|
+
case "unknown": {
|
|
1842
|
+
return { kind: "unknown", raw: asString(object.raw, `${at$}.raw`) };
|
|
1843
|
+
}
|
|
1844
|
+
default:
|
|
1845
|
+
if (typeof tag === "string")
|
|
1846
|
+
return { kind: "unknown", raw: tag };
|
|
1847
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
function encodeWorkoutActivity(value) {
|
|
1851
|
+
switch (value.kind) {
|
|
1852
|
+
case "running":
|
|
1853
|
+
return { kind: "running" };
|
|
1854
|
+
case "walking":
|
|
1855
|
+
return { kind: "walking" };
|
|
1856
|
+
case "cycling":
|
|
1857
|
+
return { kind: "cycling" };
|
|
1858
|
+
case "swimming":
|
|
1859
|
+
return { kind: "swimming" };
|
|
1860
|
+
case "strengthTraining":
|
|
1861
|
+
return { kind: "strengthTraining" };
|
|
1862
|
+
case "other":
|
|
1863
|
+
return { kind: "other", label: value.label };
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
function decodeWorkoutActivity(raw, at$ = "WorkoutActivity") {
|
|
1867
|
+
const object = asObject(raw, at$);
|
|
1868
|
+
const tag = object.kind;
|
|
1869
|
+
switch (tag) {
|
|
1870
|
+
case "running": {
|
|
1871
|
+
return { kind: "running" };
|
|
1872
|
+
}
|
|
1873
|
+
case "walking": {
|
|
1874
|
+
return { kind: "walking" };
|
|
1875
|
+
}
|
|
1876
|
+
case "cycling": {
|
|
1877
|
+
return { kind: "cycling" };
|
|
1878
|
+
}
|
|
1879
|
+
case "swimming": {
|
|
1880
|
+
return { kind: "swimming" };
|
|
1881
|
+
}
|
|
1882
|
+
case "strengthTraining": {
|
|
1883
|
+
return { kind: "strengthTraining" };
|
|
1884
|
+
}
|
|
1885
|
+
case "other": {
|
|
1886
|
+
return { kind: "other", label: asString(object.label, `${at$}.label`) };
|
|
1887
|
+
}
|
|
1888
|
+
default:
|
|
1889
|
+
if (typeof tag === "string")
|
|
1890
|
+
return { kind: "other", label: tag };
|
|
1891
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
function encodeDiagnosticsState(value) {
|
|
1895
|
+
switch (value.state) {
|
|
1896
|
+
case "healthy":
|
|
1897
|
+
return { state: "healthy" };
|
|
1898
|
+
case "quiet":
|
|
1899
|
+
return { state: "quiet", since: encodeInstant(value.since) };
|
|
1900
|
+
case "backgroundRestricted":
|
|
1901
|
+
return { state: "backgroundRestricted", reason: value.reason };
|
|
1902
|
+
case "backgroundRefreshUnscheduled":
|
|
1903
|
+
return { state: "backgroundRefreshUnscheduled" };
|
|
1904
|
+
case "pendingRetry":
|
|
1905
|
+
return { state: "pendingRetry" };
|
|
1906
|
+
case "linkRevoked":
|
|
1907
|
+
return { state: "linkRevoked" };
|
|
1908
|
+
case "devIDMismatch":
|
|
1909
|
+
return { state: "devIDMismatch" };
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
function decodeDiagnosticsState(raw, at$ = "DiagnosticsState") {
|
|
1913
|
+
const object = asObject(raw, at$);
|
|
1914
|
+
const tag = object.state;
|
|
1915
|
+
switch (tag) {
|
|
1916
|
+
case "healthy": {
|
|
1917
|
+
return { state: "healthy" };
|
|
1918
|
+
}
|
|
1919
|
+
case "quiet": {
|
|
1920
|
+
return { state: "quiet", since: decodeInstant(object.since, `${at$}.since`) };
|
|
1921
|
+
}
|
|
1922
|
+
case "backgroundRestricted": {
|
|
1923
|
+
return { state: "backgroundRestricted", reason: optional(object.reason, (value) => asBackgroundRestrictionReason(value, `${at$}.reason`)) };
|
|
1924
|
+
}
|
|
1925
|
+
case "backgroundRefreshUnscheduled": {
|
|
1926
|
+
return { state: "backgroundRefreshUnscheduled" };
|
|
1927
|
+
}
|
|
1928
|
+
case "pendingRetry": {
|
|
1929
|
+
return { state: "pendingRetry" };
|
|
1930
|
+
}
|
|
1931
|
+
case "linkRevoked": {
|
|
1932
|
+
return { state: "linkRevoked" };
|
|
1933
|
+
}
|
|
1934
|
+
case "devIDMismatch": {
|
|
1935
|
+
return { state: "devIDMismatch" };
|
|
1936
|
+
}
|
|
1937
|
+
default:
|
|
1938
|
+
throw new TypeError(`${at$}: unknown state ${String(tag)}`);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
function encodeStreamMessage(value) {
|
|
1942
|
+
switch (value.kind) {
|
|
1943
|
+
case "data":
|
|
1944
|
+
return { kind: "data", element: value.element };
|
|
1945
|
+
case "error":
|
|
1946
|
+
return { kind: "error", error: encodeTerraErrorPayload(value.error) };
|
|
1947
|
+
case "complete":
|
|
1948
|
+
return { kind: "complete" };
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
function decodeStreamMessage(raw, at$ = "StreamMessage") {
|
|
1952
|
+
const object = asObject(raw, at$);
|
|
1953
|
+
const tag = object.kind;
|
|
1954
|
+
switch (tag) {
|
|
1955
|
+
case "data": {
|
|
1956
|
+
return { kind: "data", element: asObject(object.element, `${at$}.element`) };
|
|
1957
|
+
}
|
|
1958
|
+
case "error": {
|
|
1959
|
+
return { kind: "error", error: decodeTerraErrorPayload(object.error, `${at$}.error`) };
|
|
1960
|
+
}
|
|
1961
|
+
case "complete": {
|
|
1962
|
+
return { kind: "complete" };
|
|
1963
|
+
}
|
|
1964
|
+
default:
|
|
1965
|
+
throw new TypeError(`${at$}: unknown kind ${String(tag)}`);
|
|
1966
|
+
}
|
|
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
|
+
}
|