@solutionforest/android-health-connect 0.0.0-stage → 0.3.14
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/AndroidHealthConnect.podspec +20 -0
- package/CHANGELOG.md +211 -0
- package/LICENSE +20 -0
- package/README.md +849 -2
- package/SECURITY.md +99 -0
- package/android/build.gradle +104 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/androidhealthconnect/AggregateMapper.kt +521 -0
- package/android/src/main/java/com/androidhealthconnect/AndroidHealthConnectModule.kt +637 -0
- package/android/src/main/java/com/androidhealthconnect/AndroidHealthConnectPackage.kt +31 -0
- package/android/src/main/java/com/androidhealthconnect/AvailabilitySupport.kt +149 -0
- package/android/src/main/java/com/androidhealthconnect/ChangesMapper.kt +105 -0
- package/android/src/main/java/com/androidhealthconnect/ExtendedRecordMapper.kt +665 -0
- package/android/src/main/java/com/androidhealthconnect/FeatureSupport.kt +88 -0
- package/android/src/main/java/com/androidhealthconnect/PhrMapper.kt +187 -0
- package/android/src/main/java/com/androidhealthconnect/PlannedExerciseMapper.kt +242 -0
- package/android/src/main/java/com/androidhealthconnect/RecordMapper.kt +1222 -0
- package/app.plugin.js +1 -0
- package/docs/assets/logo.jpg +0 -0
- package/ios/AndroidHealthConnect.h +5 -0
- package/ios/AndroidHealthConnect.mm +21 -0
- package/lib/module/NativeAndroidHealthConnect.js +5 -0
- package/lib/module/NativeAndroidHealthConnect.js.map +1 -0
- package/lib/module/foreground.js +117 -0
- package/lib/module/foreground.js.map +1 -0
- package/lib/module/helpers.js +280 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/index.js +354 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +392 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/upgrade.js +101 -0
- package/lib/module/upgrade.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/plugin/src/index.d.ts +14 -0
- package/lib/typescript/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/src/NativeAndroidHealthConnect.d.ts +95 -0
- package/lib/typescript/src/NativeAndroidHealthConnect.d.ts.map +1 -0
- package/lib/typescript/src/foreground.d.ts +43 -0
- package/lib/typescript/src/foreground.d.ts.map +1 -0
- package/lib/typescript/src/helpers.d.ts +108 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +208 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +1209 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/upgrade.d.ts +26 -0
- package/lib/typescript/src/upgrade.d.ts.map +1 -0
- package/package.json +255 -4
- package/plugin/build/index.d.ts +13 -0
- package/plugin/build/index.js +57 -0
- package/plugin/src/index.ts +105 -0
- package/src/NativeAndroidHealthConnect.ts +133 -0
- package/src/foreground.ts +167 -0
- package/src/helpers.ts +373 -0
- package/src/index.tsx +623 -0
- package/src/types.ts +1525 -0
- package/src/upgrade.ts +155 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,1525 @@
|
|
|
1
|
+
// ─── Availability ────────────────────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
/** Result of checking whether Health Connect is usable on the current device. */
|
|
4
|
+
export type HealthConnectAvailability =
|
|
5
|
+
| 'available' // HC is installed and ready (sdkStatus = 3 SDK_AVAILABLE)
|
|
6
|
+
| 'notInstalled' // HC app needs to be installed / updated (sdkStatus = 2)
|
|
7
|
+
| 'notSupported'; // OS too old, no GMS, or otherwise unusable (sdkStatus = 1)
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* How Health Connect is delivered on this device.
|
|
11
|
+
* - `framework` — Android 14+ system Health Connect
|
|
12
|
+
* - `apk` — Play Store APK (Android 9–13)
|
|
13
|
+
* - `none` — below API 28 / no provider path
|
|
14
|
+
*/
|
|
15
|
+
export type HealthConnectProviderKind = 'framework' | 'apk' | 'none';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Detailed availability for UX (China / HMS / install vs built-in).
|
|
19
|
+
* Raw `sdkStatus`: 1 = SDK_UNAVAILABLE, 2 = PROVIDER_UPDATE_REQUIRED, 3 = SDK_AVAILABLE.
|
|
20
|
+
* Note: `3` is available — not “version too old”.
|
|
21
|
+
*/
|
|
22
|
+
export type HealthConnectAvailabilityInfo = {
|
|
23
|
+
status: HealthConnectAvailability;
|
|
24
|
+
sdkStatus: number;
|
|
25
|
+
sdkStatusName: string;
|
|
26
|
+
provider: HealthConnectProviderKind;
|
|
27
|
+
androidSdkInt: number;
|
|
28
|
+
googlePlayServicesAvailable: boolean;
|
|
29
|
+
playStoreAvailable: boolean;
|
|
30
|
+
advice: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// ─── Permissions ─────────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
export type HealthPermission =
|
|
36
|
+
| 'android.permission.health.READ_STEPS'
|
|
37
|
+
| 'android.permission.health.WRITE_STEPS'
|
|
38
|
+
| 'android.permission.health.READ_HEART_RATE'
|
|
39
|
+
| 'android.permission.health.WRITE_HEART_RATE'
|
|
40
|
+
| 'android.permission.health.READ_SLEEP'
|
|
41
|
+
| 'android.permission.health.WRITE_SLEEP'
|
|
42
|
+
| 'android.permission.health.READ_ACTIVE_CALORIES_BURNED'
|
|
43
|
+
| 'android.permission.health.WRITE_ACTIVE_CALORIES_BURNED'
|
|
44
|
+
| 'android.permission.health.READ_TOTAL_CALORIES_BURNED'
|
|
45
|
+
| 'android.permission.health.WRITE_TOTAL_CALORIES_BURNED'
|
|
46
|
+
| 'android.permission.health.READ_DISTANCE'
|
|
47
|
+
| 'android.permission.health.WRITE_DISTANCE'
|
|
48
|
+
| 'android.permission.health.READ_WEIGHT'
|
|
49
|
+
| 'android.permission.health.WRITE_WEIGHT'
|
|
50
|
+
| 'android.permission.health.READ_HEIGHT'
|
|
51
|
+
| 'android.permission.health.WRITE_HEIGHT'
|
|
52
|
+
| 'android.permission.health.READ_BLOOD_PRESSURE'
|
|
53
|
+
| 'android.permission.health.WRITE_BLOOD_PRESSURE'
|
|
54
|
+
| 'android.permission.health.READ_BLOOD_GLUCOSE'
|
|
55
|
+
| 'android.permission.health.WRITE_BLOOD_GLUCOSE'
|
|
56
|
+
| 'android.permission.health.READ_OXYGEN_SATURATION'
|
|
57
|
+
| 'android.permission.health.WRITE_OXYGEN_SATURATION'
|
|
58
|
+
| 'android.permission.health.READ_BODY_TEMPERATURE'
|
|
59
|
+
| 'android.permission.health.WRITE_BODY_TEMPERATURE'
|
|
60
|
+
| 'android.permission.health.READ_BODY_FAT'
|
|
61
|
+
| 'android.permission.health.WRITE_BODY_FAT'
|
|
62
|
+
| 'android.permission.health.READ_HYDRATION'
|
|
63
|
+
| 'android.permission.health.WRITE_HYDRATION'
|
|
64
|
+
| 'android.permission.health.READ_EXERCISE'
|
|
65
|
+
| 'android.permission.health.WRITE_EXERCISE'
|
|
66
|
+
/** Plural — required to read routes on sessions you did not write. */
|
|
67
|
+
| 'android.permission.health.READ_EXERCISE_ROUTES'
|
|
68
|
+
/** Singular — required to insert/update a session with `exerciseRoute`. */
|
|
69
|
+
| 'android.permission.health.WRITE_EXERCISE_ROUTE'
|
|
70
|
+
/** Requires `getFeatureStatus('plannedExercise') === 'available'`. */
|
|
71
|
+
| 'android.permission.health.READ_PLANNED_EXERCISE'
|
|
72
|
+
| 'android.permission.health.WRITE_PLANNED_EXERCISE'
|
|
73
|
+
| 'android.permission.health.READ_RESTING_HEART_RATE'
|
|
74
|
+
| 'android.permission.health.WRITE_RESTING_HEART_RATE'
|
|
75
|
+
| 'android.permission.health.READ_RESPIRATORY_RATE'
|
|
76
|
+
| 'android.permission.health.WRITE_RESPIRATORY_RATE'
|
|
77
|
+
| 'android.permission.health.READ_FLOORS_CLIMBED'
|
|
78
|
+
| 'android.permission.health.WRITE_FLOORS_CLIMBED'
|
|
79
|
+
| 'android.permission.health.READ_ELEVATION_GAINED'
|
|
80
|
+
| 'android.permission.health.WRITE_ELEVATION_GAINED'
|
|
81
|
+
| 'android.permission.health.READ_MINDFULNESS'
|
|
82
|
+
| 'android.permission.health.WRITE_MINDFULNESS'
|
|
83
|
+
| 'android.permission.health.READ_SKIN_TEMPERATURE'
|
|
84
|
+
| 'android.permission.health.WRITE_SKIN_TEMPERATURE'
|
|
85
|
+
| 'android.permission.health.READ_ACTIVITY_INTENSITY'
|
|
86
|
+
| 'android.permission.health.WRITE_ACTIVITY_INTENSITY'
|
|
87
|
+
| 'android.permission.health.READ_NUTRITION'
|
|
88
|
+
| 'android.permission.health.WRITE_NUTRITION'
|
|
89
|
+
| 'android.permission.health.READ_VO2_MAX'
|
|
90
|
+
| 'android.permission.health.WRITE_VO2_MAX'
|
|
91
|
+
| 'android.permission.health.READ_SPEED'
|
|
92
|
+
| 'android.permission.health.WRITE_SPEED'
|
|
93
|
+
| 'android.permission.health.READ_POWER'
|
|
94
|
+
| 'android.permission.health.WRITE_POWER'
|
|
95
|
+
| 'android.permission.health.READ_WHEELCHAIR_PUSHES'
|
|
96
|
+
| 'android.permission.health.WRITE_WHEELCHAIR_PUSHES'
|
|
97
|
+
| 'android.permission.health.READ_MENSTRUATION'
|
|
98
|
+
| 'android.permission.health.WRITE_MENSTRUATION'
|
|
99
|
+
| 'android.permission.health.READ_OVULATION_TEST'
|
|
100
|
+
| 'android.permission.health.WRITE_OVULATION_TEST'
|
|
101
|
+
| 'android.permission.health.READ_CERVICAL_MUCUS'
|
|
102
|
+
| 'android.permission.health.WRITE_CERVICAL_MUCUS'
|
|
103
|
+
| 'android.permission.health.READ_INTERMENSTRUAL_BLEEDING'
|
|
104
|
+
| 'android.permission.health.WRITE_INTERMENSTRUAL_BLEEDING'
|
|
105
|
+
| 'android.permission.health.READ_SEXUAL_ACTIVITY'
|
|
106
|
+
| 'android.permission.health.WRITE_SEXUAL_ACTIVITY'
|
|
107
|
+
| 'android.permission.health.READ_BASAL_BODY_TEMPERATURE'
|
|
108
|
+
| 'android.permission.health.WRITE_BASAL_BODY_TEMPERATURE'
|
|
109
|
+
| 'android.permission.health.READ_LEAN_BODY_MASS'
|
|
110
|
+
| 'android.permission.health.WRITE_LEAN_BODY_MASS'
|
|
111
|
+
| 'android.permission.health.READ_BONE_MASS'
|
|
112
|
+
| 'android.permission.health.WRITE_BONE_MASS'
|
|
113
|
+
| 'android.permission.health.READ_BODY_WATER_MASS'
|
|
114
|
+
| 'android.permission.health.WRITE_BODY_WATER_MASS'
|
|
115
|
+
| 'android.permission.health.READ_BASAL_METABOLIC_RATE'
|
|
116
|
+
| 'android.permission.health.WRITE_BASAL_METABOLIC_RATE'
|
|
117
|
+
| 'android.permission.health.READ_HEART_RATE_VARIABILITY'
|
|
118
|
+
| 'android.permission.health.WRITE_HEART_RATE_VARIABILITY'
|
|
119
|
+
/**
|
|
120
|
+
* Read data older than ~30 days before first grant.
|
|
121
|
+
* Check `getFeatureStatus('readHealthDataHistory')` first.
|
|
122
|
+
*/
|
|
123
|
+
| 'android.permission.health.READ_HEALTH_DATA_HISTORY'
|
|
124
|
+
/**
|
|
125
|
+
* Read while the app is in the background.
|
|
126
|
+
* Check `getFeatureStatus('readHealthDataInBackground')` first.
|
|
127
|
+
*/
|
|
128
|
+
| 'android.permission.health.READ_HEALTH_DATA_IN_BACKGROUND'
|
|
129
|
+
| 'android.permission.health.WRITE_MEDICAL_DATA'
|
|
130
|
+
| 'android.permission.health.READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES'
|
|
131
|
+
| 'android.permission.health.READ_MEDICAL_DATA_CONDITIONS'
|
|
132
|
+
| 'android.permission.health.READ_MEDICAL_DATA_LABORATORY_RESULTS'
|
|
133
|
+
| 'android.permission.health.READ_MEDICAL_DATA_MEDICATIONS'
|
|
134
|
+
| 'android.permission.health.READ_MEDICAL_DATA_PERSONAL_DETAILS'
|
|
135
|
+
| 'android.permission.health.READ_MEDICAL_DATA_PRACTITIONER_DETAILS'
|
|
136
|
+
| 'android.permission.health.READ_MEDICAL_DATA_PREGNANCY'
|
|
137
|
+
| 'android.permission.health.READ_MEDICAL_DATA_PROCEDURES'
|
|
138
|
+
| 'android.permission.health.READ_MEDICAL_DATA_SOCIAL_HISTORY'
|
|
139
|
+
| 'android.permission.health.READ_MEDICAL_DATA_VACCINES'
|
|
140
|
+
| 'android.permission.health.READ_MEDICAL_DATA_VISITS'
|
|
141
|
+
| 'android.permission.health.READ_MEDICAL_DATA_VITAL_SIGNS'
|
|
142
|
+
| (string & {}); // allow custom / future permissions
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Typed Health Connect permission strings for autocomplete.
|
|
146
|
+
* Prefer these over hand-typed `android.permission.health.*` literals.
|
|
147
|
+
*/
|
|
148
|
+
export const Permission = {
|
|
149
|
+
READ_STEPS: 'android.permission.health.READ_STEPS',
|
|
150
|
+
WRITE_STEPS: 'android.permission.health.WRITE_STEPS',
|
|
151
|
+
READ_HEART_RATE: 'android.permission.health.READ_HEART_RATE',
|
|
152
|
+
WRITE_HEART_RATE: 'android.permission.health.WRITE_HEART_RATE',
|
|
153
|
+
READ_SLEEP: 'android.permission.health.READ_SLEEP',
|
|
154
|
+
WRITE_SLEEP: 'android.permission.health.WRITE_SLEEP',
|
|
155
|
+
READ_ACTIVE_CALORIES_BURNED:
|
|
156
|
+
'android.permission.health.READ_ACTIVE_CALORIES_BURNED',
|
|
157
|
+
WRITE_ACTIVE_CALORIES_BURNED:
|
|
158
|
+
'android.permission.health.WRITE_ACTIVE_CALORIES_BURNED',
|
|
159
|
+
READ_TOTAL_CALORIES_BURNED:
|
|
160
|
+
'android.permission.health.READ_TOTAL_CALORIES_BURNED',
|
|
161
|
+
WRITE_TOTAL_CALORIES_BURNED:
|
|
162
|
+
'android.permission.health.WRITE_TOTAL_CALORIES_BURNED',
|
|
163
|
+
READ_DISTANCE: 'android.permission.health.READ_DISTANCE',
|
|
164
|
+
WRITE_DISTANCE: 'android.permission.health.WRITE_DISTANCE',
|
|
165
|
+
READ_WEIGHT: 'android.permission.health.READ_WEIGHT',
|
|
166
|
+
WRITE_WEIGHT: 'android.permission.health.WRITE_WEIGHT',
|
|
167
|
+
READ_HEIGHT: 'android.permission.health.READ_HEIGHT',
|
|
168
|
+
WRITE_HEIGHT: 'android.permission.health.WRITE_HEIGHT',
|
|
169
|
+
READ_BLOOD_PRESSURE: 'android.permission.health.READ_BLOOD_PRESSURE',
|
|
170
|
+
WRITE_BLOOD_PRESSURE: 'android.permission.health.WRITE_BLOOD_PRESSURE',
|
|
171
|
+
READ_BLOOD_GLUCOSE: 'android.permission.health.READ_BLOOD_GLUCOSE',
|
|
172
|
+
WRITE_BLOOD_GLUCOSE: 'android.permission.health.WRITE_BLOOD_GLUCOSE',
|
|
173
|
+
READ_OXYGEN_SATURATION: 'android.permission.health.READ_OXYGEN_SATURATION',
|
|
174
|
+
WRITE_OXYGEN_SATURATION: 'android.permission.health.WRITE_OXYGEN_SATURATION',
|
|
175
|
+
READ_BODY_TEMPERATURE: 'android.permission.health.READ_BODY_TEMPERATURE',
|
|
176
|
+
WRITE_BODY_TEMPERATURE: 'android.permission.health.WRITE_BODY_TEMPERATURE',
|
|
177
|
+
READ_BODY_FAT: 'android.permission.health.READ_BODY_FAT',
|
|
178
|
+
WRITE_BODY_FAT: 'android.permission.health.WRITE_BODY_FAT',
|
|
179
|
+
READ_HYDRATION: 'android.permission.health.READ_HYDRATION',
|
|
180
|
+
WRITE_HYDRATION: 'android.permission.health.WRITE_HYDRATION',
|
|
181
|
+
READ_EXERCISE: 'android.permission.health.READ_EXERCISE',
|
|
182
|
+
WRITE_EXERCISE: 'android.permission.health.WRITE_EXERCISE',
|
|
183
|
+
READ_EXERCISE_ROUTES: 'android.permission.health.READ_EXERCISE_ROUTES',
|
|
184
|
+
WRITE_EXERCISE_ROUTE: 'android.permission.health.WRITE_EXERCISE_ROUTE',
|
|
185
|
+
READ_PLANNED_EXERCISE: 'android.permission.health.READ_PLANNED_EXERCISE',
|
|
186
|
+
WRITE_PLANNED_EXERCISE: 'android.permission.health.WRITE_PLANNED_EXERCISE',
|
|
187
|
+
READ_RESTING_HEART_RATE: 'android.permission.health.READ_RESTING_HEART_RATE',
|
|
188
|
+
WRITE_RESTING_HEART_RATE:
|
|
189
|
+
'android.permission.health.WRITE_RESTING_HEART_RATE',
|
|
190
|
+
READ_RESPIRATORY_RATE: 'android.permission.health.READ_RESPIRATORY_RATE',
|
|
191
|
+
WRITE_RESPIRATORY_RATE: 'android.permission.health.WRITE_RESPIRATORY_RATE',
|
|
192
|
+
READ_FLOORS_CLIMBED: 'android.permission.health.READ_FLOORS_CLIMBED',
|
|
193
|
+
WRITE_FLOORS_CLIMBED: 'android.permission.health.WRITE_FLOORS_CLIMBED',
|
|
194
|
+
READ_ELEVATION_GAINED: 'android.permission.health.READ_ELEVATION_GAINED',
|
|
195
|
+
WRITE_ELEVATION_GAINED: 'android.permission.health.WRITE_ELEVATION_GAINED',
|
|
196
|
+
READ_MINDFULNESS: 'android.permission.health.READ_MINDFULNESS',
|
|
197
|
+
WRITE_MINDFULNESS: 'android.permission.health.WRITE_MINDFULNESS',
|
|
198
|
+
READ_SKIN_TEMPERATURE: 'android.permission.health.READ_SKIN_TEMPERATURE',
|
|
199
|
+
WRITE_SKIN_TEMPERATURE: 'android.permission.health.WRITE_SKIN_TEMPERATURE',
|
|
200
|
+
READ_ACTIVITY_INTENSITY: 'android.permission.health.READ_ACTIVITY_INTENSITY',
|
|
201
|
+
WRITE_ACTIVITY_INTENSITY:
|
|
202
|
+
'android.permission.health.WRITE_ACTIVITY_INTENSITY',
|
|
203
|
+
READ_NUTRITION: 'android.permission.health.READ_NUTRITION',
|
|
204
|
+
WRITE_NUTRITION: 'android.permission.health.WRITE_NUTRITION',
|
|
205
|
+
READ_VO2_MAX: 'android.permission.health.READ_VO2_MAX',
|
|
206
|
+
WRITE_VO2_MAX: 'android.permission.health.WRITE_VO2_MAX',
|
|
207
|
+
READ_SPEED: 'android.permission.health.READ_SPEED',
|
|
208
|
+
WRITE_SPEED: 'android.permission.health.WRITE_SPEED',
|
|
209
|
+
READ_POWER: 'android.permission.health.READ_POWER',
|
|
210
|
+
WRITE_POWER: 'android.permission.health.WRITE_POWER',
|
|
211
|
+
READ_WHEELCHAIR_PUSHES: 'android.permission.health.READ_WHEELCHAIR_PUSHES',
|
|
212
|
+
WRITE_WHEELCHAIR_PUSHES: 'android.permission.health.WRITE_WHEELCHAIR_PUSHES',
|
|
213
|
+
READ_MENSTRUATION: 'android.permission.health.READ_MENSTRUATION',
|
|
214
|
+
WRITE_MENSTRUATION: 'android.permission.health.WRITE_MENSTRUATION',
|
|
215
|
+
READ_OVULATION_TEST: 'android.permission.health.READ_OVULATION_TEST',
|
|
216
|
+
WRITE_OVULATION_TEST: 'android.permission.health.WRITE_OVULATION_TEST',
|
|
217
|
+
READ_CERVICAL_MUCUS: 'android.permission.health.READ_CERVICAL_MUCUS',
|
|
218
|
+
WRITE_CERVICAL_MUCUS: 'android.permission.health.WRITE_CERVICAL_MUCUS',
|
|
219
|
+
READ_INTERMENSTRUAL_BLEEDING:
|
|
220
|
+
'android.permission.health.READ_INTERMENSTRUAL_BLEEDING',
|
|
221
|
+
WRITE_INTERMENSTRUAL_BLEEDING:
|
|
222
|
+
'android.permission.health.WRITE_INTERMENSTRUAL_BLEEDING',
|
|
223
|
+
READ_SEXUAL_ACTIVITY: 'android.permission.health.READ_SEXUAL_ACTIVITY',
|
|
224
|
+
WRITE_SEXUAL_ACTIVITY: 'android.permission.health.WRITE_SEXUAL_ACTIVITY',
|
|
225
|
+
READ_BASAL_BODY_TEMPERATURE:
|
|
226
|
+
'android.permission.health.READ_BASAL_BODY_TEMPERATURE',
|
|
227
|
+
WRITE_BASAL_BODY_TEMPERATURE:
|
|
228
|
+
'android.permission.health.WRITE_BASAL_BODY_TEMPERATURE',
|
|
229
|
+
READ_LEAN_BODY_MASS: 'android.permission.health.READ_LEAN_BODY_MASS',
|
|
230
|
+
WRITE_LEAN_BODY_MASS: 'android.permission.health.WRITE_LEAN_BODY_MASS',
|
|
231
|
+
READ_BONE_MASS: 'android.permission.health.READ_BONE_MASS',
|
|
232
|
+
WRITE_BONE_MASS: 'android.permission.health.WRITE_BONE_MASS',
|
|
233
|
+
READ_BODY_WATER_MASS: 'android.permission.health.READ_BODY_WATER_MASS',
|
|
234
|
+
WRITE_BODY_WATER_MASS: 'android.permission.health.WRITE_BODY_WATER_MASS',
|
|
235
|
+
READ_BASAL_METABOLIC_RATE:
|
|
236
|
+
'android.permission.health.READ_BASAL_METABOLIC_RATE',
|
|
237
|
+
WRITE_BASAL_METABOLIC_RATE:
|
|
238
|
+
'android.permission.health.WRITE_BASAL_METABOLIC_RATE',
|
|
239
|
+
READ_HEART_RATE_VARIABILITY:
|
|
240
|
+
'android.permission.health.READ_HEART_RATE_VARIABILITY',
|
|
241
|
+
WRITE_HEART_RATE_VARIABILITY:
|
|
242
|
+
'android.permission.health.WRITE_HEART_RATE_VARIABILITY',
|
|
243
|
+
READ_HEALTH_DATA_HISTORY:
|
|
244
|
+
'android.permission.health.READ_HEALTH_DATA_HISTORY',
|
|
245
|
+
READ_HEALTH_DATA_IN_BACKGROUND:
|
|
246
|
+
'android.permission.health.READ_HEALTH_DATA_IN_BACKGROUND',
|
|
247
|
+
WRITE_MEDICAL_DATA: 'android.permission.health.WRITE_MEDICAL_DATA',
|
|
248
|
+
READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES:
|
|
249
|
+
'android.permission.health.READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES',
|
|
250
|
+
READ_MEDICAL_DATA_CONDITIONS:
|
|
251
|
+
'android.permission.health.READ_MEDICAL_DATA_CONDITIONS',
|
|
252
|
+
READ_MEDICAL_DATA_LABORATORY_RESULTS:
|
|
253
|
+
'android.permission.health.READ_MEDICAL_DATA_LABORATORY_RESULTS',
|
|
254
|
+
READ_MEDICAL_DATA_MEDICATIONS:
|
|
255
|
+
'android.permission.health.READ_MEDICAL_DATA_MEDICATIONS',
|
|
256
|
+
READ_MEDICAL_DATA_PERSONAL_DETAILS:
|
|
257
|
+
'android.permission.health.READ_MEDICAL_DATA_PERSONAL_DETAILS',
|
|
258
|
+
READ_MEDICAL_DATA_PRACTITIONER_DETAILS:
|
|
259
|
+
'android.permission.health.READ_MEDICAL_DATA_PRACTITIONER_DETAILS',
|
|
260
|
+
READ_MEDICAL_DATA_PREGNANCY:
|
|
261
|
+
'android.permission.health.READ_MEDICAL_DATA_PREGNANCY',
|
|
262
|
+
READ_MEDICAL_DATA_PROCEDURES:
|
|
263
|
+
'android.permission.health.READ_MEDICAL_DATA_PROCEDURES',
|
|
264
|
+
READ_MEDICAL_DATA_SOCIAL_HISTORY:
|
|
265
|
+
'android.permission.health.READ_MEDICAL_DATA_SOCIAL_HISTORY',
|
|
266
|
+
READ_MEDICAL_DATA_VACCINES:
|
|
267
|
+
'android.permission.health.READ_MEDICAL_DATA_VACCINES',
|
|
268
|
+
READ_MEDICAL_DATA_VISITS:
|
|
269
|
+
'android.permission.health.READ_MEDICAL_DATA_VISITS',
|
|
270
|
+
READ_MEDICAL_DATA_VITAL_SIGNS:
|
|
271
|
+
'android.permission.health.READ_MEDICAL_DATA_VITAL_SIGNS',
|
|
272
|
+
} as const satisfies Record<string, HealthPermission>;
|
|
273
|
+
|
|
274
|
+
export type PermissionKey = keyof typeof Permission;
|
|
275
|
+
|
|
276
|
+
// ─── Common ───────────────────────────────────────────────────────────────────
|
|
277
|
+
|
|
278
|
+
export type DeviceInfo = {
|
|
279
|
+
/** Device.TYPE_* constant (0 = unknown, 1 = watch, 2 = phone, …). */
|
|
280
|
+
type: number;
|
|
281
|
+
manufacturer?: string | null;
|
|
282
|
+
model?: string | null;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export type RecordMetadata = {
|
|
286
|
+
/** Unique identifier assigned by Health Connect. Empty string for new records. */
|
|
287
|
+
id: string;
|
|
288
|
+
/** Optional caller-provided identifier; enables idempotent inserts. */
|
|
289
|
+
clientRecordId?: string | null;
|
|
290
|
+
clientRecordVersion?: number;
|
|
291
|
+
lastModifiedTime?: string; // ISO 8601
|
|
292
|
+
dataOrigin?: string; // package name of the writing app
|
|
293
|
+
/**
|
|
294
|
+
* How the record was recorded. Compare against `RecordingMethod` constants.
|
|
295
|
+
* Use `RecordingMethod.MANUAL_ENTRY` to detect user-typed data regardless
|
|
296
|
+
* of which app (Health Connect, Google Fit, Samsung Health, etc.) wrote it.
|
|
297
|
+
*/
|
|
298
|
+
recordingMethod?: number;
|
|
299
|
+
/** Present on read when the writer set a device; optional on write. */
|
|
300
|
+
device?: DeviceInfo | null;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export type TimeRangeFilter = {
|
|
304
|
+
/** ISO 8601 start time (inclusive). */
|
|
305
|
+
startTime: string;
|
|
306
|
+
/** ISO 8601 end time (exclusive). */
|
|
307
|
+
endTime: string;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export type ReadRecordsOptions = {
|
|
311
|
+
timeRangeFilter?: TimeRangeFilter;
|
|
312
|
+
/** Filter by package names that wrote the records. */
|
|
313
|
+
dataOriginFilter?: string[];
|
|
314
|
+
/** Default: true (oldest first). */
|
|
315
|
+
ascendingOrder?: boolean;
|
|
316
|
+
/** Maximum number of records per page. Default: 1000. */
|
|
317
|
+
pageSize?: number;
|
|
318
|
+
/** Opaque token returned from a previous read; used for pagination. */
|
|
319
|
+
pageToken?: string;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export type ReadRecordsResponse<T> = {
|
|
323
|
+
records: T[];
|
|
324
|
+
/** Present when more pages are available. */
|
|
325
|
+
pageToken?: string | null;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/** Record types that support Health Connect aggregation in this library. */
|
|
329
|
+
export type AggregateRecordType =
|
|
330
|
+
| 'Steps'
|
|
331
|
+
| 'Distance'
|
|
332
|
+
| 'ActiveCaloriesBurned'
|
|
333
|
+
| 'TotalCaloriesBurned'
|
|
334
|
+
| 'HeartRate'
|
|
335
|
+
| 'RestingHeartRate'
|
|
336
|
+
| 'Weight'
|
|
337
|
+
| 'Height'
|
|
338
|
+
| 'Hydration'
|
|
339
|
+
| 'FloorsClimbed'
|
|
340
|
+
| 'ElevationGained'
|
|
341
|
+
| 'ExerciseSession'
|
|
342
|
+
| 'SleepSession'
|
|
343
|
+
| 'BloodPressure'
|
|
344
|
+
| 'MindfulnessSession'
|
|
345
|
+
| 'ActivityIntensity'
|
|
346
|
+
| 'Nutrition'
|
|
347
|
+
| 'Speed'
|
|
348
|
+
| 'Power'
|
|
349
|
+
| 'StepsCadence'
|
|
350
|
+
| 'CyclingPedalingCadence'
|
|
351
|
+
| 'WheelchairPushes'
|
|
352
|
+
| 'BasalMetabolicRate';
|
|
353
|
+
|
|
354
|
+
export type EnergyResult = {
|
|
355
|
+
inKilocalories: number;
|
|
356
|
+
inCalories: number;
|
|
357
|
+
inJoules: number;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
export type LengthResult = {
|
|
361
|
+
inMeters: number;
|
|
362
|
+
inKilometers: number;
|
|
363
|
+
inMiles: number;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export type MassResult = {
|
|
367
|
+
inKilograms: number;
|
|
368
|
+
inGrams: number;
|
|
369
|
+
inPounds: number;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export type VolumeResult = {
|
|
373
|
+
inLiters: number;
|
|
374
|
+
inMilliliters: number;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export type PressureResult = {
|
|
378
|
+
inMillimetersOfMercury: number;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export type DurationResult = {
|
|
382
|
+
inSeconds: number;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export type VelocityResult = {
|
|
386
|
+
inMetersPerSecond: number;
|
|
387
|
+
inKilometersPerHour: number;
|
|
388
|
+
inMilesPerHour: number;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
export type PowerResult = {
|
|
392
|
+
inWatts: number;
|
|
393
|
+
inKilocaloriesPerDay: number;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
export type AggregateRequest = {
|
|
397
|
+
recordType: AggregateRecordType;
|
|
398
|
+
timeRangeFilter: TimeRangeFilter;
|
|
399
|
+
dataOriginFilter?: string[];
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
export type DurationRangeSlicer = {
|
|
403
|
+
unit: 'millis' | 'seconds' | 'minutes' | 'hours' | 'days';
|
|
404
|
+
value: number;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
export type PeriodRangeSlicer = {
|
|
408
|
+
unit: 'days' | 'weeks' | 'months' | 'years';
|
|
409
|
+
value: number;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export type AggregateGroupByDurationRequest = AggregateRequest & {
|
|
413
|
+
timeRangeSlicer: DurationRangeSlicer;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
export type AggregateGroupByPeriodRequest = AggregateRequest & {
|
|
417
|
+
timeRangeSlicer: PeriodRangeSlicer;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Aggregated metrics for a record type. Metric keys match Health Connect
|
|
422
|
+
* (e.g. `COUNT_TOTAL`, `BPM_AVG`). Missing data is `null`.
|
|
423
|
+
*/
|
|
424
|
+
export type AggregateMetricValue =
|
|
425
|
+
| number
|
|
426
|
+
| EnergyResult
|
|
427
|
+
| LengthResult
|
|
428
|
+
| MassResult
|
|
429
|
+
| VolumeResult
|
|
430
|
+
| PressureResult
|
|
431
|
+
| DurationResult
|
|
432
|
+
| VelocityResult
|
|
433
|
+
| PowerResult
|
|
434
|
+
| null;
|
|
435
|
+
|
|
436
|
+
export type AggregateResult = {
|
|
437
|
+
recordType: AggregateRecordType;
|
|
438
|
+
dataOrigins: string[];
|
|
439
|
+
metrics: Record<string, AggregateMetricValue>;
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
export type AggregationResultGroupedByDuration = {
|
|
443
|
+
startTime: string;
|
|
444
|
+
endTime: string;
|
|
445
|
+
zoneOffset: string | null;
|
|
446
|
+
result: AggregateResult;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
export type AggregationResultGroupedByPeriod = {
|
|
450
|
+
startTime: string;
|
|
451
|
+
endTime: string;
|
|
452
|
+
result: AggregateResult;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
export type InsertRecordsResponse = {
|
|
456
|
+
recordIdsList: string[];
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// ─── Record types ─────────────────────────────────────────────────────────────
|
|
460
|
+
|
|
461
|
+
export type StepsRecord = {
|
|
462
|
+
recordType: 'Steps';
|
|
463
|
+
/** Number of steps. */
|
|
464
|
+
count: number;
|
|
465
|
+
startTime: string; // ISO 8601
|
|
466
|
+
endTime: string;
|
|
467
|
+
startZoneOffset?: string; // e.g. "+05:30"
|
|
468
|
+
endZoneOffset?: string;
|
|
469
|
+
metadata?: RecordMetadata;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
export type HeartRateSample = {
|
|
473
|
+
time: string; // ISO 8601
|
|
474
|
+
beatsPerMinute: number;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
export type HeartRateRecord = {
|
|
478
|
+
recordType: 'HeartRate';
|
|
479
|
+
samples: HeartRateSample[];
|
|
480
|
+
startTime: string;
|
|
481
|
+
endTime: string;
|
|
482
|
+
startZoneOffset?: string;
|
|
483
|
+
endZoneOffset?: string;
|
|
484
|
+
metadata?: RecordMetadata;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
export type SleepStage = {
|
|
488
|
+
startTime: string;
|
|
489
|
+
endTime: string;
|
|
490
|
+
/** See SleepStageType constants (0–7). */
|
|
491
|
+
stage: number;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
export type SleepSessionRecord = {
|
|
495
|
+
recordType: 'SleepSession';
|
|
496
|
+
startTime: string;
|
|
497
|
+
endTime: string;
|
|
498
|
+
title?: string | null;
|
|
499
|
+
notes?: string | null;
|
|
500
|
+
stages?: SleepStage[];
|
|
501
|
+
startZoneOffset?: string;
|
|
502
|
+
endZoneOffset?: string;
|
|
503
|
+
metadata?: RecordMetadata;
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
export type ActiveCaloriesBurnedRecord = {
|
|
507
|
+
recordType: 'ActiveCaloriesBurned';
|
|
508
|
+
/** Energy in kilocalories. */
|
|
509
|
+
energy: number;
|
|
510
|
+
startTime: string;
|
|
511
|
+
endTime: string;
|
|
512
|
+
startZoneOffset?: string;
|
|
513
|
+
endZoneOffset?: string;
|
|
514
|
+
metadata?: RecordMetadata;
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export type TotalCaloriesBurnedRecord = {
|
|
518
|
+
recordType: 'TotalCaloriesBurned';
|
|
519
|
+
/** Energy in kilocalories. */
|
|
520
|
+
energy: number;
|
|
521
|
+
startTime: string;
|
|
522
|
+
endTime: string;
|
|
523
|
+
startZoneOffset?: string;
|
|
524
|
+
endZoneOffset?: string;
|
|
525
|
+
metadata?: RecordMetadata;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export type DistanceRecord = {
|
|
529
|
+
recordType: 'Distance';
|
|
530
|
+
/** Distance in meters. */
|
|
531
|
+
distance: number;
|
|
532
|
+
startTime: string;
|
|
533
|
+
endTime: string;
|
|
534
|
+
startZoneOffset?: string;
|
|
535
|
+
endZoneOffset?: string;
|
|
536
|
+
metadata?: RecordMetadata;
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
export type WeightRecord = {
|
|
540
|
+
recordType: 'Weight';
|
|
541
|
+
/** Weight in kilograms. */
|
|
542
|
+
weight: number;
|
|
543
|
+
time: string;
|
|
544
|
+
zoneOffset?: string;
|
|
545
|
+
metadata?: RecordMetadata;
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
export type HeightRecord = {
|
|
549
|
+
recordType: 'Height';
|
|
550
|
+
/** Height in meters. */
|
|
551
|
+
height: number;
|
|
552
|
+
time: string;
|
|
553
|
+
zoneOffset?: string;
|
|
554
|
+
metadata?: RecordMetadata;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
export type BloodPressureRecord = {
|
|
558
|
+
recordType: 'BloodPressure';
|
|
559
|
+
/** Systolic pressure in mmHg. */
|
|
560
|
+
systolic: number;
|
|
561
|
+
/** Diastolic pressure in mmHg. */
|
|
562
|
+
diastolic: number;
|
|
563
|
+
/** BloodPressureRecord.BODY_POSITION_* constant (0 = unknown). */
|
|
564
|
+
bodyPosition?: number;
|
|
565
|
+
/** BloodPressureRecord.MEASUREMENT_LOCATION_* constant (0 = unknown). */
|
|
566
|
+
measurementLocation?: number;
|
|
567
|
+
time: string;
|
|
568
|
+
zoneOffset?: string;
|
|
569
|
+
metadata?: RecordMetadata;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export type BloodGlucoseRecord = {
|
|
573
|
+
recordType: 'BloodGlucose';
|
|
574
|
+
/** Blood glucose level in mmol/L. */
|
|
575
|
+
level: number;
|
|
576
|
+
/** BloodGlucoseRecord.SPECIMEN_SOURCE_* (0 = unknown). */
|
|
577
|
+
specimenSource?: number;
|
|
578
|
+
/** MealType.MEAL_TYPE_* (0 = unknown). */
|
|
579
|
+
mealType?: number;
|
|
580
|
+
/** BloodGlucoseRecord.RELATION_TO_MEAL_* (0 = unknown). */
|
|
581
|
+
relationToMeal?: number;
|
|
582
|
+
time: string;
|
|
583
|
+
zoneOffset?: string;
|
|
584
|
+
metadata?: RecordMetadata;
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
export type OxygenSaturationRecord = {
|
|
588
|
+
recordType: 'OxygenSaturation';
|
|
589
|
+
/** Percentage value between 0 and 100. */
|
|
590
|
+
percentage: number;
|
|
591
|
+
time: string;
|
|
592
|
+
zoneOffset?: string;
|
|
593
|
+
metadata?: RecordMetadata;
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
export type BodyTemperatureRecord = {
|
|
597
|
+
recordType: 'BodyTemperature';
|
|
598
|
+
/** Temperature in Celsius. */
|
|
599
|
+
temperature: number;
|
|
600
|
+
/** BodyTemperatureRecord.MEASUREMENT_LOCATION_* (0 = unknown). */
|
|
601
|
+
measurementLocation?: number;
|
|
602
|
+
time: string;
|
|
603
|
+
zoneOffset?: string;
|
|
604
|
+
metadata?: RecordMetadata;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
export type BodyFatRecord = {
|
|
608
|
+
recordType: 'BodyFat';
|
|
609
|
+
/** Body fat percentage between 0 and 100. */
|
|
610
|
+
percentage: number;
|
|
611
|
+
time: string;
|
|
612
|
+
zoneOffset?: string;
|
|
613
|
+
metadata?: RecordMetadata;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
export type HydrationRecord = {
|
|
617
|
+
recordType: 'Hydration';
|
|
618
|
+
/** Volume of water consumed in liters. */
|
|
619
|
+
volume: number;
|
|
620
|
+
startTime: string;
|
|
621
|
+
endTime: string;
|
|
622
|
+
startZoneOffset?: string;
|
|
623
|
+
endZoneOffset?: string;
|
|
624
|
+
metadata?: RecordMetadata;
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
export type ExerciseSegment = {
|
|
628
|
+
startTime: string;
|
|
629
|
+
endTime: string;
|
|
630
|
+
/** {@link ExerciseSegmentType} constant. */
|
|
631
|
+
segmentType: number;
|
|
632
|
+
repetitions?: number;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
export type ExerciseLap = {
|
|
636
|
+
startTime: string;
|
|
637
|
+
endTime: string;
|
|
638
|
+
/** Lap length in meters. */
|
|
639
|
+
length?: number;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Write-side route point. Optional accuracy/altitude are meters.
|
|
644
|
+
* Omit optional fields instead of sending empty objects.
|
|
645
|
+
*/
|
|
646
|
+
export type ExerciseRouteLocation = {
|
|
647
|
+
time: string;
|
|
648
|
+
latitude: number;
|
|
649
|
+
longitude: number;
|
|
650
|
+
/** Meters above WGS84 ellipsoid. */
|
|
651
|
+
altitude?: number;
|
|
652
|
+
horizontalAccuracy?: number;
|
|
653
|
+
verticalAccuracy?: number;
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
/** Read-side length fields use multi-unit result objects. */
|
|
657
|
+
export type ExerciseRouteLocationResult = {
|
|
658
|
+
time: string;
|
|
659
|
+
latitude: number;
|
|
660
|
+
longitude: number;
|
|
661
|
+
altitude?: LengthResult | null;
|
|
662
|
+
horizontalAccuracy?: LengthResult | null;
|
|
663
|
+
verticalAccuracy?: LengthResult | null;
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
export type ExerciseRouteWrite = {
|
|
667
|
+
route: ExerciseRouteLocation[];
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
export type ExerciseRouteRead = {
|
|
671
|
+
type: 'DATA' | 'NO_DATA' | 'CONSENT_REQUIRED';
|
|
672
|
+
route: ExerciseRouteLocationResult[];
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
export type ExerciseSessionRecord = {
|
|
676
|
+
recordType: 'ExerciseSession';
|
|
677
|
+
/** ExerciseSessionRecord.EXERCISE_TYPE_* constant — use {@link ExerciseType}. */
|
|
678
|
+
exerciseType: number;
|
|
679
|
+
startTime: string;
|
|
680
|
+
endTime: string;
|
|
681
|
+
title?: string | null;
|
|
682
|
+
notes?: string | null;
|
|
683
|
+
segments?: ExerciseSegment[];
|
|
684
|
+
laps?: ExerciseLap[];
|
|
685
|
+
/** Write: pass `{ route: [...] }`. Read: `{ type, route }` with LengthResult fields. */
|
|
686
|
+
exerciseRoute?: ExerciseRouteWrite | ExerciseRouteRead;
|
|
687
|
+
/**
|
|
688
|
+
* Link to a planned exercise session id.
|
|
689
|
+
* Requires `getFeatureStatus('exerciseSessionImprovements') === 'available'`.
|
|
690
|
+
*/
|
|
691
|
+
plannedExerciseSessionId?: string | null;
|
|
692
|
+
/**
|
|
693
|
+
* Rate of perceived exertion (typically 0–10).
|
|
694
|
+
* Requires `getFeatureStatus('exerciseSessionImprovements') === 'available'`.
|
|
695
|
+
*/
|
|
696
|
+
rateOfPerceivedExertion?: number | null;
|
|
697
|
+
startZoneOffset?: string;
|
|
698
|
+
endZoneOffset?: string;
|
|
699
|
+
metadata?: RecordMetadata;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
export type RestingHeartRateRecord = {
|
|
703
|
+
recordType: 'RestingHeartRate';
|
|
704
|
+
beatsPerMinute: number;
|
|
705
|
+
time: string;
|
|
706
|
+
zoneOffset?: string;
|
|
707
|
+
metadata?: RecordMetadata;
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
export type RespiratoryRateRecord = {
|
|
711
|
+
recordType: 'RespiratoryRate';
|
|
712
|
+
/** Breaths per minute. */
|
|
713
|
+
rate: number;
|
|
714
|
+
time: string;
|
|
715
|
+
zoneOffset?: string;
|
|
716
|
+
metadata?: RecordMetadata;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
export type FloorsClimbedRecord = {
|
|
720
|
+
recordType: 'FloorsClimbed';
|
|
721
|
+
floors: number;
|
|
722
|
+
startTime: string;
|
|
723
|
+
endTime: string;
|
|
724
|
+
startZoneOffset?: string;
|
|
725
|
+
endZoneOffset?: string;
|
|
726
|
+
metadata?: RecordMetadata;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
export type ElevationGainedRecord = {
|
|
730
|
+
recordType: 'ElevationGained';
|
|
731
|
+
/** Elevation gained in meters. */
|
|
732
|
+
elevation: number;
|
|
733
|
+
startTime: string;
|
|
734
|
+
endTime: string;
|
|
735
|
+
startZoneOffset?: string;
|
|
736
|
+
endZoneOffset?: string;
|
|
737
|
+
metadata?: RecordMetadata;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
/** Requires FEATURE_MINDFULNESS_SESSION on the device. */
|
|
741
|
+
export type MindfulnessSessionRecord = {
|
|
742
|
+
recordType: 'MindfulnessSession';
|
|
743
|
+
/** MindfulnessSessionType constant (0–5). */
|
|
744
|
+
mindfulnessSessionType: number;
|
|
745
|
+
startTime: string;
|
|
746
|
+
endTime: string;
|
|
747
|
+
title?: string | null;
|
|
748
|
+
notes?: string | null;
|
|
749
|
+
startZoneOffset?: string;
|
|
750
|
+
endZoneOffset?: string;
|
|
751
|
+
metadata?: RecordMetadata;
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
export type SkinTemperatureDelta = {
|
|
755
|
+
time: string; // ISO 8601
|
|
756
|
+
/** Delta in Celsius degrees (−30 to 30). */
|
|
757
|
+
delta: number;
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
/** Requires FEATURE_SKIN_TEMPERATURE on the device. */
|
|
761
|
+
export type SkinTemperatureRecord = {
|
|
762
|
+
recordType: 'SkinTemperature';
|
|
763
|
+
deltas: SkinTemperatureDelta[];
|
|
764
|
+
/** Optional baseline in Celsius. */
|
|
765
|
+
baseline?: number | null;
|
|
766
|
+
/** SkinTemperatureMeasurementLocation (0–3). */
|
|
767
|
+
measurementLocation?: number;
|
|
768
|
+
startTime: string;
|
|
769
|
+
endTime: string;
|
|
770
|
+
startZoneOffset?: string;
|
|
771
|
+
endZoneOffset?: string;
|
|
772
|
+
metadata?: RecordMetadata;
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
/** Requires FEATURE_ACTIVITY_INTENSITY on the device. */
|
|
776
|
+
export type ActivityIntensityRecord = {
|
|
777
|
+
recordType: 'ActivityIntensity';
|
|
778
|
+
/** ActivityIntensityType: 0 = moderate, 1 = vigorous. */
|
|
779
|
+
activityIntensityType: number;
|
|
780
|
+
startTime: string;
|
|
781
|
+
endTime: string;
|
|
782
|
+
startZoneOffset?: string;
|
|
783
|
+
endZoneOffset?: string;
|
|
784
|
+
metadata?: RecordMetadata;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Nutrient masses are grams; `energy` and `energyFromFat` are kilocalories.
|
|
789
|
+
*/
|
|
790
|
+
export type NutritionRecord = {
|
|
791
|
+
recordType: 'Nutrition';
|
|
792
|
+
biotin?: number | null;
|
|
793
|
+
caffeine?: number | null;
|
|
794
|
+
calcium?: number | null;
|
|
795
|
+
energy?: number | null;
|
|
796
|
+
energyFromFat?: number | null;
|
|
797
|
+
chloride?: number | null;
|
|
798
|
+
cholesterol?: number | null;
|
|
799
|
+
chromium?: number | null;
|
|
800
|
+
copper?: number | null;
|
|
801
|
+
dietaryFiber?: number | null;
|
|
802
|
+
folate?: number | null;
|
|
803
|
+
folicAcid?: number | null;
|
|
804
|
+
iodine?: number | null;
|
|
805
|
+
iron?: number | null;
|
|
806
|
+
magnesium?: number | null;
|
|
807
|
+
manganese?: number | null;
|
|
808
|
+
molybdenum?: number | null;
|
|
809
|
+
monounsaturatedFat?: number | null;
|
|
810
|
+
niacin?: number | null;
|
|
811
|
+
pantothenicAcid?: number | null;
|
|
812
|
+
phosphorus?: number | null;
|
|
813
|
+
polyunsaturatedFat?: number | null;
|
|
814
|
+
potassium?: number | null;
|
|
815
|
+
protein?: number | null;
|
|
816
|
+
riboflavin?: number | null;
|
|
817
|
+
saturatedFat?: number | null;
|
|
818
|
+
selenium?: number | null;
|
|
819
|
+
sodium?: number | null;
|
|
820
|
+
sugar?: number | null;
|
|
821
|
+
thiamin?: number | null;
|
|
822
|
+
totalCarbohydrate?: number | null;
|
|
823
|
+
totalFat?: number | null;
|
|
824
|
+
transFat?: number | null;
|
|
825
|
+
unsaturatedFat?: number | null;
|
|
826
|
+
vitaminA?: number | null;
|
|
827
|
+
vitaminB12?: number | null;
|
|
828
|
+
vitaminB6?: number | null;
|
|
829
|
+
vitaminC?: number | null;
|
|
830
|
+
vitaminD?: number | null;
|
|
831
|
+
vitaminE?: number | null;
|
|
832
|
+
vitaminK?: number | null;
|
|
833
|
+
zinc?: number | null;
|
|
834
|
+
name?: string | null;
|
|
835
|
+
/** MealType.MEAL_TYPE_* constant. */
|
|
836
|
+
mealType?: number;
|
|
837
|
+
startTime: string;
|
|
838
|
+
endTime: string;
|
|
839
|
+
startZoneOffset?: string;
|
|
840
|
+
endZoneOffset?: string;
|
|
841
|
+
metadata?: RecordMetadata;
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
export type Vo2MaxRecord = {
|
|
845
|
+
recordType: 'Vo2Max';
|
|
846
|
+
vo2MillilitersPerMinuteKilogram: number;
|
|
847
|
+
/** Vo2MaxRecord.MEASUREMENT_METHOD_* constant (0–5). */
|
|
848
|
+
measurementMethod?: number;
|
|
849
|
+
time: string;
|
|
850
|
+
zoneOffset?: string;
|
|
851
|
+
metadata?: RecordMetadata;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
export type SpeedSample = {
|
|
855
|
+
time: string;
|
|
856
|
+
metersPerSecond: number;
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
export type SpeedRecord = {
|
|
860
|
+
recordType: 'Speed';
|
|
861
|
+
samples: SpeedSample[];
|
|
862
|
+
startTime: string;
|
|
863
|
+
endTime: string;
|
|
864
|
+
startZoneOffset?: string;
|
|
865
|
+
endZoneOffset?: string;
|
|
866
|
+
metadata?: RecordMetadata;
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
export type PowerSample = {
|
|
870
|
+
time: string;
|
|
871
|
+
watts: number;
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
export type PowerRecord = {
|
|
875
|
+
recordType: 'Power';
|
|
876
|
+
samples: PowerSample[];
|
|
877
|
+
startTime: string;
|
|
878
|
+
endTime: string;
|
|
879
|
+
startZoneOffset?: string;
|
|
880
|
+
endZoneOffset?: string;
|
|
881
|
+
metadata?: RecordMetadata;
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
export type StepsCadenceSample = {
|
|
885
|
+
time: string;
|
|
886
|
+
/** Steps per minute. */
|
|
887
|
+
rate: number;
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
export type StepsCadenceRecord = {
|
|
891
|
+
recordType: 'StepsCadence';
|
|
892
|
+
samples: StepsCadenceSample[];
|
|
893
|
+
startTime: string;
|
|
894
|
+
endTime: string;
|
|
895
|
+
startZoneOffset?: string;
|
|
896
|
+
endZoneOffset?: string;
|
|
897
|
+
metadata?: RecordMetadata;
|
|
898
|
+
};
|
|
899
|
+
|
|
900
|
+
export type CyclingPedalingCadenceSample = {
|
|
901
|
+
time: string;
|
|
902
|
+
revolutionsPerMinute: number;
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
export type CyclingPedalingCadenceRecord = {
|
|
906
|
+
recordType: 'CyclingPedalingCadence';
|
|
907
|
+
samples: CyclingPedalingCadenceSample[];
|
|
908
|
+
startTime: string;
|
|
909
|
+
endTime: string;
|
|
910
|
+
startZoneOffset?: string;
|
|
911
|
+
endZoneOffset?: string;
|
|
912
|
+
metadata?: RecordMetadata;
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
export type WheelchairPushesRecord = {
|
|
916
|
+
recordType: 'WheelchairPushes';
|
|
917
|
+
count: number;
|
|
918
|
+
startTime: string;
|
|
919
|
+
endTime: string;
|
|
920
|
+
startZoneOffset?: string;
|
|
921
|
+
endZoneOffset?: string;
|
|
922
|
+
metadata?: RecordMetadata;
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
export type MenstruationFlowRecord = {
|
|
926
|
+
recordType: 'MenstruationFlow';
|
|
927
|
+
/** MenstruationFlowRecord.FLOW_* constant (0–3). */
|
|
928
|
+
flow?: number;
|
|
929
|
+
time: string;
|
|
930
|
+
zoneOffset?: string;
|
|
931
|
+
metadata?: RecordMetadata;
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
export type MenstruationPeriodRecord = {
|
|
935
|
+
recordType: 'MenstruationPeriod';
|
|
936
|
+
startTime: string;
|
|
937
|
+
endTime: string;
|
|
938
|
+
startZoneOffset?: string;
|
|
939
|
+
endZoneOffset?: string;
|
|
940
|
+
metadata?: RecordMetadata;
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
export type OvulationTestRecord = {
|
|
944
|
+
recordType: 'OvulationTest';
|
|
945
|
+
/** OvulationTestRecord.RESULT_* constant (0–3). */
|
|
946
|
+
result: number;
|
|
947
|
+
time: string;
|
|
948
|
+
zoneOffset?: string;
|
|
949
|
+
metadata?: RecordMetadata;
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
export type CervicalMucusRecord = {
|
|
953
|
+
recordType: 'CervicalMucus';
|
|
954
|
+
/** CervicalMucusRecord.APPEARANCE_* constant (0–6). */
|
|
955
|
+
appearance?: number;
|
|
956
|
+
/** CervicalMucusRecord.SENSATION_* constant (0–3). */
|
|
957
|
+
sensation?: number;
|
|
958
|
+
time: string;
|
|
959
|
+
zoneOffset?: string;
|
|
960
|
+
metadata?: RecordMetadata;
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
export type IntermenstrualBleedingRecord = {
|
|
964
|
+
recordType: 'IntermenstrualBleeding';
|
|
965
|
+
time: string;
|
|
966
|
+
zoneOffset?: string;
|
|
967
|
+
metadata?: RecordMetadata;
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
export type SexualActivityRecord = {
|
|
971
|
+
recordType: 'SexualActivity';
|
|
972
|
+
/** SexualActivityRecord.PROTECTION_USED_* constant (0–2). */
|
|
973
|
+
protectionUsed?: number;
|
|
974
|
+
time: string;
|
|
975
|
+
zoneOffset?: string;
|
|
976
|
+
metadata?: RecordMetadata;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
export type BasalBodyTemperatureRecord = {
|
|
980
|
+
recordType: 'BasalBodyTemperature';
|
|
981
|
+
/** Celsius. */
|
|
982
|
+
temperature: number;
|
|
983
|
+
/** BodyTemperatureMeasurementLocation constant. */
|
|
984
|
+
measurementLocation?: number;
|
|
985
|
+
time: string;
|
|
986
|
+
zoneOffset?: string;
|
|
987
|
+
metadata?: RecordMetadata;
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
export type LeanBodyMassRecord = {
|
|
991
|
+
recordType: 'LeanBodyMass';
|
|
992
|
+
/** Kilograms. */
|
|
993
|
+
mass: number;
|
|
994
|
+
time: string;
|
|
995
|
+
zoneOffset?: string;
|
|
996
|
+
metadata?: RecordMetadata;
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
export type BoneMassRecord = {
|
|
1000
|
+
recordType: 'BoneMass';
|
|
1001
|
+
/** Kilograms. */
|
|
1002
|
+
mass: number;
|
|
1003
|
+
time: string;
|
|
1004
|
+
zoneOffset?: string;
|
|
1005
|
+
metadata?: RecordMetadata;
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
export type BodyWaterMassRecord = {
|
|
1009
|
+
recordType: 'BodyWaterMass';
|
|
1010
|
+
/** Kilograms. */
|
|
1011
|
+
mass: number;
|
|
1012
|
+
time: string;
|
|
1013
|
+
zoneOffset?: string;
|
|
1014
|
+
metadata?: RecordMetadata;
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
export type BasalMetabolicRateRecord = {
|
|
1018
|
+
recordType: 'BasalMetabolicRate';
|
|
1019
|
+
/** Kilocalories per day. */
|
|
1020
|
+
basalMetabolicRate: number;
|
|
1021
|
+
time: string;
|
|
1022
|
+
zoneOffset?: string;
|
|
1023
|
+
metadata?: RecordMetadata;
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
export type HeartRateVariabilityRmssdRecord = {
|
|
1027
|
+
recordType: 'HeartRateVariabilityRmssd';
|
|
1028
|
+
/** RMSSD in milliseconds. */
|
|
1029
|
+
heartRateVariabilityMillis: number;
|
|
1030
|
+
time: string;
|
|
1031
|
+
zoneOffset?: string;
|
|
1032
|
+
metadata?: RecordMetadata;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
/** Requires `getFeatureStatus('plannedExercise') === 'available'`. */
|
|
1036
|
+
export type ExerciseCompletionGoal =
|
|
1037
|
+
| { type: 'Distance'; distance: number }
|
|
1038
|
+
| { type: 'Duration'; durationMillis: number }
|
|
1039
|
+
| { type: 'Repetitions'; repetitions: number }
|
|
1040
|
+
| { type: 'Steps'; steps: number }
|
|
1041
|
+
| { type: 'ActiveCaloriesBurned'; energy: number }
|
|
1042
|
+
| { type: 'TotalCaloriesBurned'; energy: number }
|
|
1043
|
+
| { type: 'DistanceAndDuration'; distance: number; durationMillis: number }
|
|
1044
|
+
| { type: 'ManualCompletion' }
|
|
1045
|
+
| { type: 'Unknown' };
|
|
1046
|
+
|
|
1047
|
+
export type ExercisePerformanceTarget =
|
|
1048
|
+
| { type: 'HeartRate'; minHeartRate: number; maxHeartRate: number }
|
|
1049
|
+
| {
|
|
1050
|
+
type: 'Speed';
|
|
1051
|
+
minMetersPerSecond: number;
|
|
1052
|
+
maxMetersPerSecond: number;
|
|
1053
|
+
}
|
|
1054
|
+
| { type: 'Power'; minWatts: number; maxWatts: number }
|
|
1055
|
+
| { type: 'Cadence'; minRpm: number; maxRpm: number }
|
|
1056
|
+
| { type: 'Weight'; mass: number }
|
|
1057
|
+
| { type: 'RateOfPerceivedExertion'; rpe: number }
|
|
1058
|
+
| { type: 'Amrap' }
|
|
1059
|
+
| { type: 'Unknown' };
|
|
1060
|
+
|
|
1061
|
+
export type PlannedExerciseStep = {
|
|
1062
|
+
/** Prefer {@link ExerciseSegmentType} (segment ids, not session ExerciseType). */
|
|
1063
|
+
exerciseType: number;
|
|
1064
|
+
/** {@link ExercisePhase} constant. */
|
|
1065
|
+
exercisePhase: number;
|
|
1066
|
+
completionGoal: ExerciseCompletionGoal;
|
|
1067
|
+
performanceTargets?: ExercisePerformanceTarget[];
|
|
1068
|
+
description?: string | null;
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
export type PlannedExerciseBlock = {
|
|
1072
|
+
repetitions: number;
|
|
1073
|
+
steps: PlannedExerciseStep[];
|
|
1074
|
+
description?: string | null;
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
/** Requires FEATURE_PLANNED_EXERCISE on the device. */
|
|
1078
|
+
export type PlannedExerciseSessionRecord = {
|
|
1079
|
+
recordType: 'PlannedExerciseSession';
|
|
1080
|
+
/** Session-level {@link ExerciseType}. */
|
|
1081
|
+
exerciseType: number;
|
|
1082
|
+
startTime: string;
|
|
1083
|
+
endTime: string;
|
|
1084
|
+
title?: string | null;
|
|
1085
|
+
notes?: string | null;
|
|
1086
|
+
blocks?: PlannedExerciseBlock[];
|
|
1087
|
+
/** Read-only link filled when a related ExerciseSession completes. */
|
|
1088
|
+
completedExerciseSessionId?: string | null;
|
|
1089
|
+
hasExplicitTime?: boolean;
|
|
1090
|
+
startZoneOffset?: string;
|
|
1091
|
+
endZoneOffset?: string;
|
|
1092
|
+
metadata?: RecordMetadata;
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
// ─── Union & discriminant helpers ─────────────────────────────────────────────
|
|
1096
|
+
|
|
1097
|
+
export type HealthRecord =
|
|
1098
|
+
| StepsRecord
|
|
1099
|
+
| HeartRateRecord
|
|
1100
|
+
| SleepSessionRecord
|
|
1101
|
+
| ActiveCaloriesBurnedRecord
|
|
1102
|
+
| TotalCaloriesBurnedRecord
|
|
1103
|
+
| DistanceRecord
|
|
1104
|
+
| WeightRecord
|
|
1105
|
+
| HeightRecord
|
|
1106
|
+
| BloodPressureRecord
|
|
1107
|
+
| BloodGlucoseRecord
|
|
1108
|
+
| OxygenSaturationRecord
|
|
1109
|
+
| BodyTemperatureRecord
|
|
1110
|
+
| BodyFatRecord
|
|
1111
|
+
| HydrationRecord
|
|
1112
|
+
| ExerciseSessionRecord
|
|
1113
|
+
| RestingHeartRateRecord
|
|
1114
|
+
| RespiratoryRateRecord
|
|
1115
|
+
| FloorsClimbedRecord
|
|
1116
|
+
| ElevationGainedRecord
|
|
1117
|
+
| MindfulnessSessionRecord
|
|
1118
|
+
| SkinTemperatureRecord
|
|
1119
|
+
| ActivityIntensityRecord
|
|
1120
|
+
| NutritionRecord
|
|
1121
|
+
| Vo2MaxRecord
|
|
1122
|
+
| SpeedRecord
|
|
1123
|
+
| PowerRecord
|
|
1124
|
+
| StepsCadenceRecord
|
|
1125
|
+
| CyclingPedalingCadenceRecord
|
|
1126
|
+
| WheelchairPushesRecord
|
|
1127
|
+
| MenstruationFlowRecord
|
|
1128
|
+
| MenstruationPeriodRecord
|
|
1129
|
+
| OvulationTestRecord
|
|
1130
|
+
| CervicalMucusRecord
|
|
1131
|
+
| IntermenstrualBleedingRecord
|
|
1132
|
+
| SexualActivityRecord
|
|
1133
|
+
| BasalBodyTemperatureRecord
|
|
1134
|
+
| LeanBodyMassRecord
|
|
1135
|
+
| BoneMassRecord
|
|
1136
|
+
| BodyWaterMassRecord
|
|
1137
|
+
| BasalMetabolicRateRecord
|
|
1138
|
+
| HeartRateVariabilityRmssdRecord
|
|
1139
|
+
| PlannedExerciseSessionRecord;
|
|
1140
|
+
|
|
1141
|
+
export type RecordType = HealthRecord['recordType'];
|
|
1142
|
+
|
|
1143
|
+
// ─── Changelog / changes token ────────────────────────────────────────────────
|
|
1144
|
+
|
|
1145
|
+
export type GetChangesTokenRequest = {
|
|
1146
|
+
/** Prefer one type per token so a revoked permission cannot invalidate others. */
|
|
1147
|
+
recordTypes: RecordType[];
|
|
1148
|
+
/** Optional package-name filters (data origins). */
|
|
1149
|
+
dataOriginFilters?: string[];
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
export type UpsertionChange = {
|
|
1153
|
+
record: HealthRecord;
|
|
1154
|
+
};
|
|
1155
|
+
|
|
1156
|
+
export type DeletionChange = {
|
|
1157
|
+
recordId: string;
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
export type GetChangesOptions = {
|
|
1161
|
+
/** Soft page size hint (1–5000). Omit for platform default. */
|
|
1162
|
+
pageSize?: number;
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
export type GetChangesResponse = {
|
|
1166
|
+
upsertionChanges: UpsertionChange[];
|
|
1167
|
+
deletionChanges: DeletionChange[];
|
|
1168
|
+
/** Persist and pass to the next {@link getChanges} call. */
|
|
1169
|
+
nextChangesToken: string;
|
|
1170
|
+
/** Call {@link getChanges} again with `nextChangesToken` until false. */
|
|
1171
|
+
hasMore: boolean;
|
|
1172
|
+
/**
|
|
1173
|
+
* Token older than ~30 days. Re-sync with `readRecords` then call
|
|
1174
|
+
* {@link getChangesToken} for a fresh token.
|
|
1175
|
+
*/
|
|
1176
|
+
changesTokenExpired: boolean;
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
// ─── SleepStageType constants ─────────────────────────────────────────────────
|
|
1180
|
+
|
|
1181
|
+
export const SleepStageType = {
|
|
1182
|
+
UNKNOWN: 0,
|
|
1183
|
+
AWAKE: 1,
|
|
1184
|
+
SLEEPING: 2,
|
|
1185
|
+
OUT_OF_BED: 3,
|
|
1186
|
+
LIGHT: 4,
|
|
1187
|
+
DEEP: 5,
|
|
1188
|
+
REM: 6,
|
|
1189
|
+
AWAKE_IN_BED: 7,
|
|
1190
|
+
} as const;
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* `ExerciseSessionRecord.EXERCISE_TYPE_*` — values match connect-client 1.2.
|
|
1194
|
+
* Gaps in numbering are intentional (removed / reserved platform ids).
|
|
1195
|
+
* Segment-level types belong in {@link ExerciseSegmentType}, not here.
|
|
1196
|
+
*/
|
|
1197
|
+
export const ExerciseType = {
|
|
1198
|
+
OTHER_WORKOUT: 0,
|
|
1199
|
+
BADMINTON: 2,
|
|
1200
|
+
BASEBALL: 4,
|
|
1201
|
+
BASKETBALL: 5,
|
|
1202
|
+
BIKING: 8,
|
|
1203
|
+
BIKING_STATIONARY: 9,
|
|
1204
|
+
BOOT_CAMP: 10,
|
|
1205
|
+
BOXING: 11,
|
|
1206
|
+
CALISTHENICS: 13,
|
|
1207
|
+
CRICKET: 14,
|
|
1208
|
+
DANCING: 16,
|
|
1209
|
+
ELLIPTICAL: 25,
|
|
1210
|
+
EXERCISE_CLASS: 26,
|
|
1211
|
+
FENCING: 27,
|
|
1212
|
+
FOOTBALL_AMERICAN: 28,
|
|
1213
|
+
FOOTBALL_AUSTRALIAN: 29,
|
|
1214
|
+
FRISBEE_DISC: 31,
|
|
1215
|
+
GOLF: 32,
|
|
1216
|
+
GUIDED_BREATHING: 33,
|
|
1217
|
+
GYMNASTICS: 34,
|
|
1218
|
+
HANDBALL: 35,
|
|
1219
|
+
HIGH_INTENSITY_INTERVAL_TRAINING: 36,
|
|
1220
|
+
HIKING: 37,
|
|
1221
|
+
ICE_HOCKEY: 38,
|
|
1222
|
+
ICE_SKATING: 39,
|
|
1223
|
+
MARTIAL_ARTS: 44,
|
|
1224
|
+
PADDLING: 46,
|
|
1225
|
+
PARAGLIDING: 47,
|
|
1226
|
+
PILATES: 48,
|
|
1227
|
+
RACQUETBALL: 50,
|
|
1228
|
+
ROCK_CLIMBING: 51,
|
|
1229
|
+
ROLLER_HOCKEY: 52,
|
|
1230
|
+
ROWING: 53,
|
|
1231
|
+
ROWING_MACHINE: 54,
|
|
1232
|
+
RUGBY: 55,
|
|
1233
|
+
RUNNING: 56,
|
|
1234
|
+
RUNNING_TREADMILL: 57,
|
|
1235
|
+
SAILING: 58,
|
|
1236
|
+
SCUBA_DIVING: 59,
|
|
1237
|
+
SKATING: 60,
|
|
1238
|
+
SKIING: 61,
|
|
1239
|
+
SNOWBOARDING: 62,
|
|
1240
|
+
SNOWSHOEING: 63,
|
|
1241
|
+
SOCCER: 64,
|
|
1242
|
+
SOFTBALL: 65,
|
|
1243
|
+
SQUASH: 66,
|
|
1244
|
+
STAIR_CLIMBING: 68,
|
|
1245
|
+
STAIR_CLIMBING_MACHINE: 69,
|
|
1246
|
+
STRENGTH_TRAINING: 70,
|
|
1247
|
+
STRETCHING: 71,
|
|
1248
|
+
SURFING: 72,
|
|
1249
|
+
SWIMMING_OPEN_WATER: 73,
|
|
1250
|
+
SWIMMING_POOL: 74,
|
|
1251
|
+
TABLE_TENNIS: 75,
|
|
1252
|
+
TENNIS: 76,
|
|
1253
|
+
VOLLEYBALL: 78,
|
|
1254
|
+
WALKING: 79,
|
|
1255
|
+
WATER_POLO: 80,
|
|
1256
|
+
WEIGHTLIFTING: 81,
|
|
1257
|
+
WHEELCHAIR: 82,
|
|
1258
|
+
/** @deprecated Use {@link ExerciseType.WHEELCHAIR}. */
|
|
1259
|
+
WHEEL_CHAIR: 82,
|
|
1260
|
+
YOGA: 83,
|
|
1261
|
+
} as const;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* `ExerciseSegment.EXERCISE_SEGMENT_TYPE_*` — values match connect-client 1.2.
|
|
1265
|
+
* Use on `ExerciseSession.segments[].segmentType`, not `exerciseType`.
|
|
1266
|
+
*/
|
|
1267
|
+
/** `PlannedExerciseStep.EXERCISE_PHASE_*` */
|
|
1268
|
+
export const ExercisePhase = {
|
|
1269
|
+
UNKNOWN: 0,
|
|
1270
|
+
WARMUP: 1,
|
|
1271
|
+
REST: 2,
|
|
1272
|
+
ACTIVE: 3,
|
|
1273
|
+
COOLDOWN: 4,
|
|
1274
|
+
RECOVERY: 5,
|
|
1275
|
+
} as const;
|
|
1276
|
+
|
|
1277
|
+
export const ExerciseSegmentType = {
|
|
1278
|
+
UNKNOWN: 0,
|
|
1279
|
+
ARM_CURL: 1,
|
|
1280
|
+
BACK_EXTENSION: 2,
|
|
1281
|
+
BALL_SLAM: 3,
|
|
1282
|
+
BARBELL_SHOULDER_PRESS: 4,
|
|
1283
|
+
BENCH_PRESS: 5,
|
|
1284
|
+
BENCH_SIT_UP: 6,
|
|
1285
|
+
BIKING: 7,
|
|
1286
|
+
BIKING_STATIONARY: 8,
|
|
1287
|
+
BURPEE: 9,
|
|
1288
|
+
CRUNCH: 10,
|
|
1289
|
+
DEADLIFT: 11,
|
|
1290
|
+
DOUBLE_ARM_TRICEPS_EXTENSION: 12,
|
|
1291
|
+
DUMBBELL_CURL_LEFT_ARM: 13,
|
|
1292
|
+
DUMBBELL_CURL_RIGHT_ARM: 14,
|
|
1293
|
+
DUMBBELL_FRONT_RAISE: 15,
|
|
1294
|
+
DUMBBELL_LATERAL_RAISE: 16,
|
|
1295
|
+
DUMBBELL_ROW: 17,
|
|
1296
|
+
DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM: 18,
|
|
1297
|
+
DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM: 19,
|
|
1298
|
+
DUMBBELL_TRICEPS_EXTENSION_TWO_ARM: 20,
|
|
1299
|
+
ELLIPTICAL: 21,
|
|
1300
|
+
FORWARD_TWIST: 22,
|
|
1301
|
+
FRONT_RAISE: 23,
|
|
1302
|
+
HIGH_INTENSITY_INTERVAL_TRAINING: 24,
|
|
1303
|
+
HIP_THRUST: 25,
|
|
1304
|
+
HULA_HOOP: 26,
|
|
1305
|
+
JUMPING_JACK: 27,
|
|
1306
|
+
JUMP_ROPE: 28,
|
|
1307
|
+
KETTLEBELL_SWING: 29,
|
|
1308
|
+
LATERAL_RAISE: 30,
|
|
1309
|
+
LAT_PULL_DOWN: 31,
|
|
1310
|
+
LEG_CURL: 32,
|
|
1311
|
+
LEG_EXTENSION: 33,
|
|
1312
|
+
LEG_PRESS: 34,
|
|
1313
|
+
LEG_RAISE: 35,
|
|
1314
|
+
LUNGE: 36,
|
|
1315
|
+
MOUNTAIN_CLIMBER: 37,
|
|
1316
|
+
OTHER_WORKOUT: 38,
|
|
1317
|
+
PAUSE: 39,
|
|
1318
|
+
PILATES: 40,
|
|
1319
|
+
PLANK: 41,
|
|
1320
|
+
PULL_UP: 42,
|
|
1321
|
+
PUNCH: 43,
|
|
1322
|
+
REST: 44,
|
|
1323
|
+
ROWING_MACHINE: 45,
|
|
1324
|
+
RUNNING: 46,
|
|
1325
|
+
RUNNING_TREADMILL: 47,
|
|
1326
|
+
SHOULDER_PRESS: 48,
|
|
1327
|
+
SINGLE_ARM_TRICEPS_EXTENSION: 49,
|
|
1328
|
+
SIT_UP: 50,
|
|
1329
|
+
SQUAT: 51,
|
|
1330
|
+
STAIR_CLIMBING: 52,
|
|
1331
|
+
STAIR_CLIMBING_MACHINE: 53,
|
|
1332
|
+
STRETCHING: 54,
|
|
1333
|
+
SWIMMING_BACKSTROKE: 55,
|
|
1334
|
+
SWIMMING_BREASTSTROKE: 56,
|
|
1335
|
+
SWIMMING_BUTTERFLY: 57,
|
|
1336
|
+
SWIMMING_FREESTYLE: 58,
|
|
1337
|
+
SWIMMING_MIXED: 59,
|
|
1338
|
+
SWIMMING_OPEN_WATER: 60,
|
|
1339
|
+
SWIMMING_OTHER: 61,
|
|
1340
|
+
SWIMMING_POOL: 62,
|
|
1341
|
+
UPPER_TWIST: 63,
|
|
1342
|
+
WALKING: 64,
|
|
1343
|
+
WEIGHTLIFTING: 65,
|
|
1344
|
+
WHEELCHAIR: 66,
|
|
1345
|
+
YOGA: 67,
|
|
1346
|
+
} as const;
|
|
1347
|
+
|
|
1348
|
+
// ─── RecordingMethod constants ────────────────────────────────────────────────
|
|
1349
|
+
|
|
1350
|
+
export const RecordingMethod = {
|
|
1351
|
+
UNKNOWN: 0,
|
|
1352
|
+
/** Data was actively recorded by a sensor or wearable device. */
|
|
1353
|
+
ACTIVELY_RECORDED: 1,
|
|
1354
|
+
/** Data was inferred or recorded automatically in the background. */
|
|
1355
|
+
AUTOMATICALLY_RECORDED: 2,
|
|
1356
|
+
/**
|
|
1357
|
+
* Data was manually entered by the user.
|
|
1358
|
+
* This is true regardless of which app was used (Health Connect, Google Fit,
|
|
1359
|
+
* Samsung Health, etc.).
|
|
1360
|
+
*/
|
|
1361
|
+
MANUAL_ENTRY: 3,
|
|
1362
|
+
} as const;
|
|
1363
|
+
|
|
1364
|
+
// ─── Feature availability (connect-client 1.1+ / 1.2 alpha) ───────────────────
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Feature names accepted by {@link getFeatureStatus}.
|
|
1368
|
+
* Maps to `HealthConnectFeatures.FEATURE_*` on Android.
|
|
1369
|
+
*/
|
|
1370
|
+
export type HealthConnectFeature =
|
|
1371
|
+
| 'activityIntensity'
|
|
1372
|
+
| 'matchmaking'
|
|
1373
|
+
| 'mindfulnessSession'
|
|
1374
|
+
| 'personalHealthRecord'
|
|
1375
|
+
| 'plannedExercise'
|
|
1376
|
+
| 'readHealthDataHistory'
|
|
1377
|
+
| 'readHealthDataInBackground'
|
|
1378
|
+
| 'skinTemperature'
|
|
1379
|
+
| 'extendedDeviceTypes'
|
|
1380
|
+
| 'exerciseSessionImprovements';
|
|
1381
|
+
|
|
1382
|
+
export type FeatureStatus = 'available' | 'unavailable';
|
|
1383
|
+
|
|
1384
|
+
export const MindfulnessSessionType = {
|
|
1385
|
+
UNKNOWN: 0,
|
|
1386
|
+
MEDITATION: 1,
|
|
1387
|
+
BREATHING: 2,
|
|
1388
|
+
MUSIC: 3,
|
|
1389
|
+
MOVEMENT: 4,
|
|
1390
|
+
UNGUIDED: 5,
|
|
1391
|
+
} as const;
|
|
1392
|
+
|
|
1393
|
+
export const SkinTemperatureMeasurementLocation = {
|
|
1394
|
+
UNKNOWN: 0,
|
|
1395
|
+
FINGER: 1,
|
|
1396
|
+
TOE: 2,
|
|
1397
|
+
WRIST: 3,
|
|
1398
|
+
} as const;
|
|
1399
|
+
|
|
1400
|
+
export const ActivityIntensityType = {
|
|
1401
|
+
MODERATE: 0,
|
|
1402
|
+
VIGOROUS: 1,
|
|
1403
|
+
} as const;
|
|
1404
|
+
|
|
1405
|
+
// ─── Matchmaking (experimental) ───────────────────────────────────────────────
|
|
1406
|
+
|
|
1407
|
+
export type MatchmakingRequest = {
|
|
1408
|
+
/**
|
|
1409
|
+
* Record type names the app can read (e.g. `'Steps'`).
|
|
1410
|
+
* Empty / omitted → all record types the app has read permission for.
|
|
1411
|
+
*/
|
|
1412
|
+
recordTypes?: RecordType[];
|
|
1413
|
+
/** Package names to exclusively include as data sources. */
|
|
1414
|
+
includedDataSources?: string[];
|
|
1415
|
+
/** Package names to exclude as data sources. */
|
|
1416
|
+
excludedDataSources?: string[];
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
export type MatchmakingPossibleResponse = {
|
|
1420
|
+
isMatchmakingPossible: boolean;
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
// ─── Personal Health Record / medical (experimental) ──────────────────────────
|
|
1424
|
+
|
|
1425
|
+
export const MedicalResourceType = {
|
|
1426
|
+
VACCINES: 1,
|
|
1427
|
+
ALLERGIES_INTOLERANCES: 2,
|
|
1428
|
+
PREGNANCY: 3,
|
|
1429
|
+
SOCIAL_HISTORY: 4,
|
|
1430
|
+
VITAL_SIGNS: 5,
|
|
1431
|
+
LABORATORY_RESULTS: 6,
|
|
1432
|
+
CONDITIONS: 7,
|
|
1433
|
+
PROCEDURES: 8,
|
|
1434
|
+
MEDICATIONS: 9,
|
|
1435
|
+
PERSONAL_DETAILS: 10,
|
|
1436
|
+
PRACTITIONER_DETAILS: 11,
|
|
1437
|
+
VISITS: 12,
|
|
1438
|
+
} as const;
|
|
1439
|
+
|
|
1440
|
+
export type FhirVersion = {
|
|
1441
|
+
major: number;
|
|
1442
|
+
minor: number;
|
|
1443
|
+
patch: number;
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
export type MedicalDataSource = {
|
|
1447
|
+
id: string;
|
|
1448
|
+
displayName: string;
|
|
1449
|
+
fhirBaseUri: string;
|
|
1450
|
+
fhirVersion: FhirVersion;
|
|
1451
|
+
packageName?: string;
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
export type CreateMedicalDataSourceRequest = {
|
|
1455
|
+
displayName: string;
|
|
1456
|
+
/** e.g. `https://example.com/fhir/` or `myapp://source`. */
|
|
1457
|
+
fhirBaseUri: string;
|
|
1458
|
+
fhirVersion: FhirVersion;
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
export type UpsertMedicalResourceRequest = {
|
|
1462
|
+
dataSourceId: string;
|
|
1463
|
+
fhirVersion: FhirVersion;
|
|
1464
|
+
/** Valid FHIR resource JSON string. */
|
|
1465
|
+
data: string;
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1468
|
+
export type MedicalResourceId = {
|
|
1469
|
+
dataSourceId: string;
|
|
1470
|
+
/** `FhirResource` type constant (int). */
|
|
1471
|
+
fhirResourceType: number;
|
|
1472
|
+
fhirResourceId: string;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
export type FhirResource = {
|
|
1476
|
+
/** `FhirResource` type constant (int). */
|
|
1477
|
+
type: number;
|
|
1478
|
+
id: string;
|
|
1479
|
+
/** FHIR resource JSON string. */
|
|
1480
|
+
data: string;
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
export type MedicalResource = {
|
|
1484
|
+
type: number;
|
|
1485
|
+
id: MedicalResourceId;
|
|
1486
|
+
dataSourceId: string;
|
|
1487
|
+
fhirVersion: FhirVersion;
|
|
1488
|
+
fhirResource: FhirResource;
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
export type ReadMedicalResourcesRequest = {
|
|
1492
|
+
/**
|
|
1493
|
+
* Initial page: set `medicalResourceType`.
|
|
1494
|
+
* Subsequent pages: set `pageToken` from the previous response.
|
|
1495
|
+
*/
|
|
1496
|
+
medicalResourceType?: number;
|
|
1497
|
+
medicalDataSourceIds?: string[];
|
|
1498
|
+
pageSize?: number;
|
|
1499
|
+
pageToken?: string | null;
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
export type ReadMedicalResourcesResponse = {
|
|
1503
|
+
medicalResources: MedicalResource[];
|
|
1504
|
+
nextPageToken?: string | null;
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
export type DeleteMedicalResourcesRequest = {
|
|
1508
|
+
/** Delete by IDs (takes precedence when non-empty). */
|
|
1509
|
+
ids?: MedicalResourceId[];
|
|
1510
|
+
dataSourceIds?: string[];
|
|
1511
|
+
medicalResourceTypes?: number[];
|
|
1512
|
+
};
|
|
1513
|
+
|
|
1514
|
+
export type GetMedicalDataSourcesRequest = {
|
|
1515
|
+
/**
|
|
1516
|
+
* When set, fetch these data sources by ID
|
|
1517
|
+
* (`HealthConnectClient.getMedicalDataSources(ids)`).
|
|
1518
|
+
*/
|
|
1519
|
+
medicalDataSourceIds?: string[];
|
|
1520
|
+
/**
|
|
1521
|
+
* When IDs are omitted, filter by writing-app package names
|
|
1522
|
+
* (`GetMedicalDataSourcesRequest`). Empty / omitted → all visible sources.
|
|
1523
|
+
*/
|
|
1524
|
+
packageNames?: string[];
|
|
1525
|
+
};
|