@capgo/capacitor-health 8.2.18 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/src/main/java/app/capgo/plugin/health/WorkoutType.kt +117 -1
- package/dist/docs.json +240 -0
- package/dist/esm/definitions.d.ts +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/HealthPlugin/Health.swift +346 -1
- package/ios/Sources/HealthPlugin/HealthPlugin.swift +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -675,7 +675,7 @@ Construct a type with a set of properties K of type T
|
|
|
675
675
|
|
|
676
676
|
#### WorkoutType
|
|
677
677
|
|
|
678
|
-
<code>'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'other'</code>
|
|
678
|
+
<code>'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'archery' | 'australianFootball' | 'badminton' | 'barre' | 'bowling' | 'boxing' | 'climbing' | 'cooldown' | 'coreTraining' | 'cricket' | 'crossCountrySkiing' | 'curling' | 'dance' | 'discSports' | 'downhillSkiing' | 'equestrianSports' | 'fencing' | 'fishing' | 'fitnessGaming' | 'flexibility' | 'functionalStrengthTraining' | 'golf' | 'gymnastics' | 'handball' | 'handCycling' | 'highIntensityIntervalTraining' | 'hockey' | 'hunting' | 'jumpRope' | 'kickboxing' | 'lacrosse' | 'martialArts' | 'mindAndBody' | 'mixedCardio' | 'paddleSports' | 'pickleball' | 'pilates' | 'play' | 'preparationAndRecovery' | 'racquetball' | 'rugby' | 'sailing' | 'skatingSports' | 'snowboarding' | 'snowSports' | 'softball' | 'squash' | 'stairs' | 'stepTraining' | 'surfingSports' | 'tableTennis' | 'taiChi' | 'trackAndField' | 'transition' | 'underwaterDiving' | 'volleyball' | 'wheelchairRunPace' | 'wheelchairWalkPace' | 'cardioDance' | 'socialDance' | 'other'</code>
|
|
679
679
|
|
|
680
680
|
|
|
681
681
|
#### BucketType
|
|
@@ -2,6 +2,28 @@ package app.capgo.plugin.health
|
|
|
2
2
|
|
|
3
3
|
import androidx.health.connect.client.records.ExerciseSessionRecord
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* WorkoutType mapper between TypeScript workout types and Android Health Connect exercise types.
|
|
7
|
+
*
|
|
8
|
+
* Note: Due to platform limitations, some TypeScript workout types map to the same Android
|
|
9
|
+
* exercise type. When reading workouts from Android, these will return the primary/legacy
|
|
10
|
+
* workout type to maintain backward compatibility:
|
|
11
|
+
*
|
|
12
|
+
* - highIntensityIntervalTraining, mixedCardio, crossTraining → reads as "crossTraining"
|
|
13
|
+
* - kickboxing, martialArts, wrestling → reads as "wrestling"
|
|
14
|
+
* - wheelchairRunPace, wheelchairWalkPace → reads as "wheelchairWalkPace"
|
|
15
|
+
* - stairs, stairClimbing → reads as "stairClimbing"
|
|
16
|
+
* - barre, pilates → reads as "pilates"
|
|
17
|
+
* - cooldown, flexibility, preparationAndRecovery → reads as "flexibility"
|
|
18
|
+
* - coreTraining, functionalStrengthTraining, strengthTraining, traditionalStrengthTraining → reads as "strengthTraining"
|
|
19
|
+
* - mindAndBody, taiChi, yoga → reads as "yoga"
|
|
20
|
+
* - trackAndField, running → reads as "running"
|
|
21
|
+
* - cardioDance, socialDance, dance → reads as "dance"
|
|
22
|
+
* - crossCountrySkiing, downhillSkiing → reads as "downhillSkiing"
|
|
23
|
+
*
|
|
24
|
+
* This asymmetric mapping is intentional to support the full iOS workout type set while
|
|
25
|
+
* maintaining compatibility with Android's more limited exercise type taxonomy.
|
|
26
|
+
*/
|
|
5
27
|
object WorkoutType {
|
|
6
28
|
fun fromString(type: String?): Int? {
|
|
7
29
|
if (type.isNullOrBlank()) return null
|
|
@@ -28,6 +50,67 @@ object WorkoutType {
|
|
|
28
50
|
"waterPolo" -> ExerciseSessionRecord.EXERCISE_TYPE_WATER_POLO
|
|
29
51
|
"waterSports" -> ExerciseSessionRecord.EXERCISE_TYPE_SWIMMING_OPEN_WATER
|
|
30
52
|
"wrestling" -> ExerciseSessionRecord.EXERCISE_TYPE_MARTIAL_ARTS
|
|
53
|
+
// New comprehensive workout type mappings
|
|
54
|
+
"archery" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
55
|
+
"australianFootball" -> ExerciseSessionRecord.EXERCISE_TYPE_FOOTBALL_AUSTRALIAN
|
|
56
|
+
"badminton" -> ExerciseSessionRecord.EXERCISE_TYPE_BADMINTON
|
|
57
|
+
"barre" -> ExerciseSessionRecord.EXERCISE_TYPE_PILATES
|
|
58
|
+
"bowling" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
59
|
+
"boxing" -> ExerciseSessionRecord.EXERCISE_TYPE_BOXING
|
|
60
|
+
"climbing" -> ExerciseSessionRecord.EXERCISE_TYPE_ROCK_CLIMBING
|
|
61
|
+
"cooldown" -> ExerciseSessionRecord.EXERCISE_TYPE_STRETCHING
|
|
62
|
+
"coreTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING
|
|
63
|
+
"cricket" -> ExerciseSessionRecord.EXERCISE_TYPE_CRICKET
|
|
64
|
+
"crossCountrySkiing" -> ExerciseSessionRecord.EXERCISE_TYPE_SKIING
|
|
65
|
+
"curling" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
66
|
+
"dance" -> ExerciseSessionRecord.EXERCISE_TYPE_DANCING
|
|
67
|
+
"discSports" -> ExerciseSessionRecord.EXERCISE_TYPE_FRISBEE_DISC
|
|
68
|
+
"downhillSkiing" -> ExerciseSessionRecord.EXERCISE_TYPE_SKIING
|
|
69
|
+
"equestrianSports" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
70
|
+
"fencing" -> ExerciseSessionRecord.EXERCISE_TYPE_FENCING
|
|
71
|
+
"fishing" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
72
|
+
"fitnessGaming" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
73
|
+
"flexibility" -> ExerciseSessionRecord.EXERCISE_TYPE_STRETCHING
|
|
74
|
+
"functionalStrengthTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING
|
|
75
|
+
"golf" -> ExerciseSessionRecord.EXERCISE_TYPE_GOLF
|
|
76
|
+
"gymnastics" -> ExerciseSessionRecord.EXERCISE_TYPE_GYMNASTICS
|
|
77
|
+
"handball" -> ExerciseSessionRecord.EXERCISE_TYPE_HANDBALL
|
|
78
|
+
"handCycling" -> ExerciseSessionRecord.EXERCISE_TYPE_WHEELCHAIR
|
|
79
|
+
"highIntensityIntervalTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING
|
|
80
|
+
"hockey" -> ExerciseSessionRecord.EXERCISE_TYPE_ICE_HOCKEY
|
|
81
|
+
"hunting" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
82
|
+
"jumpRope" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
83
|
+
"kickboxing" -> ExerciseSessionRecord.EXERCISE_TYPE_MARTIAL_ARTS
|
|
84
|
+
"lacrosse" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
85
|
+
"martialArts" -> ExerciseSessionRecord.EXERCISE_TYPE_MARTIAL_ARTS
|
|
86
|
+
"mindAndBody" -> ExerciseSessionRecord.EXERCISE_TYPE_YOGA
|
|
87
|
+
"mixedCardio" -> ExerciseSessionRecord.EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING
|
|
88
|
+
"paddleSports" -> ExerciseSessionRecord.EXERCISE_TYPE_PADDLING
|
|
89
|
+
"pickleball" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
90
|
+
"pilates" -> ExerciseSessionRecord.EXERCISE_TYPE_PILATES
|
|
91
|
+
"play" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
92
|
+
"preparationAndRecovery" -> ExerciseSessionRecord.EXERCISE_TYPE_STRETCHING
|
|
93
|
+
"racquetball" -> ExerciseSessionRecord.EXERCISE_TYPE_RACQUETBALL
|
|
94
|
+
"rugby" -> ExerciseSessionRecord.EXERCISE_TYPE_RUGBY
|
|
95
|
+
"sailing" -> ExerciseSessionRecord.EXERCISE_TYPE_SAILING
|
|
96
|
+
"skatingSports" -> ExerciseSessionRecord.EXERCISE_TYPE_SKATING
|
|
97
|
+
"snowboarding" -> ExerciseSessionRecord.EXERCISE_TYPE_SNOWBOARDING
|
|
98
|
+
"snowSports" -> ExerciseSessionRecord.EXERCISE_TYPE_SNOWSHOEING
|
|
99
|
+
"softball" -> ExerciseSessionRecord.EXERCISE_TYPE_SOFTBALL
|
|
100
|
+
"squash" -> ExerciseSessionRecord.EXERCISE_TYPE_SQUASH
|
|
101
|
+
"stairs" -> ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING
|
|
102
|
+
"stepTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING_MACHINE
|
|
103
|
+
"surfingSports" -> ExerciseSessionRecord.EXERCISE_TYPE_SURFING
|
|
104
|
+
"tableTennis" -> ExerciseSessionRecord.EXERCISE_TYPE_TABLE_TENNIS
|
|
105
|
+
"taiChi" -> ExerciseSessionRecord.EXERCISE_TYPE_YOGA
|
|
106
|
+
"trackAndField" -> ExerciseSessionRecord.EXERCISE_TYPE_RUNNING
|
|
107
|
+
"transition" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
108
|
+
"underwaterDiving" -> ExerciseSessionRecord.EXERCISE_TYPE_SCUBA_DIVING
|
|
109
|
+
"volleyball" -> ExerciseSessionRecord.EXERCISE_TYPE_VOLLEYBALL
|
|
110
|
+
"wheelchairRunPace" -> ExerciseSessionRecord.EXERCISE_TYPE_WHEELCHAIR
|
|
111
|
+
"wheelchairWalkPace" -> ExerciseSessionRecord.EXERCISE_TYPE_WHEELCHAIR
|
|
112
|
+
"cardioDance" -> ExerciseSessionRecord.EXERCISE_TYPE_DANCING
|
|
113
|
+
"socialDance" -> ExerciseSessionRecord.EXERCISE_TYPE_DANCING
|
|
31
114
|
"other" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
32
115
|
else -> null
|
|
33
116
|
}
|
|
@@ -49,14 +132,47 @@ object WorkoutType {
|
|
|
49
132
|
ExerciseSessionRecord.EXERCISE_TYPE_SOCCER -> "soccer"
|
|
50
133
|
ExerciseSessionRecord.EXERCISE_TYPE_FOOTBALL_AMERICAN -> "americanFootball"
|
|
51
134
|
ExerciseSessionRecord.EXERCISE_TYPE_BASEBALL -> "baseball"
|
|
135
|
+
// Keep backward compatible mapping for existing types
|
|
52
136
|
ExerciseSessionRecord.EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING -> "crossTraining"
|
|
53
137
|
ExerciseSessionRecord.EXERCISE_TYPE_ELLIPTICAL -> "elliptical"
|
|
54
138
|
ExerciseSessionRecord.EXERCISE_TYPE_ROWING -> "rowing"
|
|
55
139
|
ExerciseSessionRecord.EXERCISE_TYPE_ROWING_MACHINE -> "rowing"
|
|
140
|
+
// Keep stairClimbing as primary mapping for backward compatibility
|
|
56
141
|
ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING -> "stairClimbing"
|
|
57
|
-
ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING_MACHINE -> "
|
|
142
|
+
ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING_MACHINE -> "stepTraining"
|
|
58
143
|
ExerciseSessionRecord.EXERCISE_TYPE_WATER_POLO -> "waterPolo"
|
|
144
|
+
// Keep wrestling as primary mapping for backward compatibility
|
|
59
145
|
ExerciseSessionRecord.EXERCISE_TYPE_MARTIAL_ARTS -> "wrestling"
|
|
146
|
+
// Comprehensive Android to TypeScript workout type mappings
|
|
147
|
+
ExerciseSessionRecord.EXERCISE_TYPE_FOOTBALL_AUSTRALIAN -> "australianFootball"
|
|
148
|
+
ExerciseSessionRecord.EXERCISE_TYPE_BADMINTON -> "badminton"
|
|
149
|
+
ExerciseSessionRecord.EXERCISE_TYPE_PILATES -> "pilates"
|
|
150
|
+
ExerciseSessionRecord.EXERCISE_TYPE_BOXING -> "boxing"
|
|
151
|
+
ExerciseSessionRecord.EXERCISE_TYPE_ROCK_CLIMBING -> "climbing"
|
|
152
|
+
ExerciseSessionRecord.EXERCISE_TYPE_STRETCHING -> "flexibility"
|
|
153
|
+
ExerciseSessionRecord.EXERCISE_TYPE_CRICKET -> "cricket"
|
|
154
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SKIING -> "downhillSkiing"
|
|
155
|
+
ExerciseSessionRecord.EXERCISE_TYPE_DANCING -> "dance"
|
|
156
|
+
ExerciseSessionRecord.EXERCISE_TYPE_FRISBEE_DISC -> "discSports"
|
|
157
|
+
ExerciseSessionRecord.EXERCISE_TYPE_FENCING -> "fencing"
|
|
158
|
+
ExerciseSessionRecord.EXERCISE_TYPE_GOLF -> "golf"
|
|
159
|
+
ExerciseSessionRecord.EXERCISE_TYPE_GYMNASTICS -> "gymnastics"
|
|
160
|
+
ExerciseSessionRecord.EXERCISE_TYPE_HANDBALL -> "handball"
|
|
161
|
+
ExerciseSessionRecord.EXERCISE_TYPE_WHEELCHAIR -> "wheelchairWalkPace"
|
|
162
|
+
ExerciseSessionRecord.EXERCISE_TYPE_ICE_HOCKEY -> "hockey"
|
|
163
|
+
ExerciseSessionRecord.EXERCISE_TYPE_PADDLING -> "paddleSports"
|
|
164
|
+
ExerciseSessionRecord.EXERCISE_TYPE_RACQUETBALL -> "racquetball"
|
|
165
|
+
ExerciseSessionRecord.EXERCISE_TYPE_RUGBY -> "rugby"
|
|
166
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SAILING -> "sailing"
|
|
167
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SKATING -> "skatingSports"
|
|
168
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SNOWBOARDING -> "snowboarding"
|
|
169
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SNOWSHOEING -> "snowSports"
|
|
170
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SOFTBALL -> "softball"
|
|
171
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SQUASH -> "squash"
|
|
172
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SURFING -> "surfingSports"
|
|
173
|
+
ExerciseSessionRecord.EXERCISE_TYPE_TABLE_TENNIS -> "tableTennis"
|
|
174
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SCUBA_DIVING -> "underwaterDiving"
|
|
175
|
+
ExerciseSessionRecord.EXERCISE_TYPE_VOLLEYBALL -> "volleyball"
|
|
60
176
|
ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT -> "other"
|
|
61
177
|
else -> "other"
|
|
62
178
|
}
|
package/dist/docs.json
CHANGED
|
@@ -1083,6 +1083,246 @@
|
|
|
1083
1083
|
"text": "'wrestling'",
|
|
1084
1084
|
"complexTypes": []
|
|
1085
1085
|
},
|
|
1086
|
+
{
|
|
1087
|
+
"text": "'archery'",
|
|
1088
|
+
"complexTypes": []
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
"text": "'australianFootball'",
|
|
1092
|
+
"complexTypes": []
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
"text": "'badminton'",
|
|
1096
|
+
"complexTypes": []
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
"text": "'barre'",
|
|
1100
|
+
"complexTypes": []
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"text": "'bowling'",
|
|
1104
|
+
"complexTypes": []
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
"text": "'boxing'",
|
|
1108
|
+
"complexTypes": []
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
"text": "'climbing'",
|
|
1112
|
+
"complexTypes": []
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
"text": "'cooldown'",
|
|
1116
|
+
"complexTypes": []
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
"text": "'coreTraining'",
|
|
1120
|
+
"complexTypes": []
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
"text": "'cricket'",
|
|
1124
|
+
"complexTypes": []
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
"text": "'crossCountrySkiing'",
|
|
1128
|
+
"complexTypes": []
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
"text": "'curling'",
|
|
1132
|
+
"complexTypes": []
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
"text": "'dance'",
|
|
1136
|
+
"complexTypes": []
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
"text": "'discSports'",
|
|
1140
|
+
"complexTypes": []
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
"text": "'downhillSkiing'",
|
|
1144
|
+
"complexTypes": []
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
"text": "'equestrianSports'",
|
|
1148
|
+
"complexTypes": []
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
"text": "'fencing'",
|
|
1152
|
+
"complexTypes": []
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
"text": "'fishing'",
|
|
1156
|
+
"complexTypes": []
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
"text": "'fitnessGaming'",
|
|
1160
|
+
"complexTypes": []
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
"text": "'flexibility'",
|
|
1164
|
+
"complexTypes": []
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
"text": "'functionalStrengthTraining'",
|
|
1168
|
+
"complexTypes": []
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
"text": "'golf'",
|
|
1172
|
+
"complexTypes": []
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"text": "'gymnastics'",
|
|
1176
|
+
"complexTypes": []
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
"text": "'handball'",
|
|
1180
|
+
"complexTypes": []
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
"text": "'handCycling'",
|
|
1184
|
+
"complexTypes": []
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
"text": "'highIntensityIntervalTraining'",
|
|
1188
|
+
"complexTypes": []
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
"text": "'hockey'",
|
|
1192
|
+
"complexTypes": []
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
"text": "'hunting'",
|
|
1196
|
+
"complexTypes": []
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
"text": "'jumpRope'",
|
|
1200
|
+
"complexTypes": []
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
"text": "'kickboxing'",
|
|
1204
|
+
"complexTypes": []
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
"text": "'lacrosse'",
|
|
1208
|
+
"complexTypes": []
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
"text": "'martialArts'",
|
|
1212
|
+
"complexTypes": []
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
"text": "'mindAndBody'",
|
|
1216
|
+
"complexTypes": []
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
"text": "'mixedCardio'",
|
|
1220
|
+
"complexTypes": []
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
"text": "'paddleSports'",
|
|
1224
|
+
"complexTypes": []
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
"text": "'pickleball'",
|
|
1228
|
+
"complexTypes": []
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
"text": "'pilates'",
|
|
1232
|
+
"complexTypes": []
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
"text": "'play'",
|
|
1236
|
+
"complexTypes": []
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
"text": "'preparationAndRecovery'",
|
|
1240
|
+
"complexTypes": []
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
"text": "'racquetball'",
|
|
1244
|
+
"complexTypes": []
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
"text": "'rugby'",
|
|
1248
|
+
"complexTypes": []
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
"text": "'sailing'",
|
|
1252
|
+
"complexTypes": []
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
"text": "'skatingSports'",
|
|
1256
|
+
"complexTypes": []
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
"text": "'snowboarding'",
|
|
1260
|
+
"complexTypes": []
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
"text": "'snowSports'",
|
|
1264
|
+
"complexTypes": []
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
"text": "'softball'",
|
|
1268
|
+
"complexTypes": []
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
"text": "'squash'",
|
|
1272
|
+
"complexTypes": []
|
|
1273
|
+
},
|
|
1274
|
+
{
|
|
1275
|
+
"text": "'stairs'",
|
|
1276
|
+
"complexTypes": []
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
"text": "'stepTraining'",
|
|
1280
|
+
"complexTypes": []
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
"text": "'surfingSports'",
|
|
1284
|
+
"complexTypes": []
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
"text": "'tableTennis'",
|
|
1288
|
+
"complexTypes": []
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
"text": "'taiChi'",
|
|
1292
|
+
"complexTypes": []
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
"text": "'trackAndField'",
|
|
1296
|
+
"complexTypes": []
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
"text": "'transition'",
|
|
1300
|
+
"complexTypes": []
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
"text": "'underwaterDiving'",
|
|
1304
|
+
"complexTypes": []
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
"text": "'volleyball'",
|
|
1308
|
+
"complexTypes": []
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
"text": "'wheelchairRunPace'",
|
|
1312
|
+
"complexTypes": []
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
"text": "'wheelchairWalkPace'",
|
|
1316
|
+
"complexTypes": []
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
"text": "'cardioDance'",
|
|
1320
|
+
"complexTypes": []
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
"text": "'socialDance'",
|
|
1324
|
+
"complexTypes": []
|
|
1325
|
+
},
|
|
1086
1326
|
{
|
|
1087
1327
|
"text": "'other'",
|
|
1088
1328
|
"complexTypes": []
|
|
@@ -49,7 +49,7 @@ export interface HealthSample {
|
|
|
49
49
|
export interface ReadSamplesResult {
|
|
50
50
|
samples: HealthSample[];
|
|
51
51
|
}
|
|
52
|
-
export type WorkoutType = 'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'other';
|
|
52
|
+
export type WorkoutType = 'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'archery' | 'australianFootball' | 'badminton' | 'barre' | 'bowling' | 'boxing' | 'climbing' | 'cooldown' | 'coreTraining' | 'cricket' | 'crossCountrySkiing' | 'curling' | 'dance' | 'discSports' | 'downhillSkiing' | 'equestrianSports' | 'fencing' | 'fishing' | 'fitnessGaming' | 'flexibility' | 'functionalStrengthTraining' | 'golf' | 'gymnastics' | 'handball' | 'handCycling' | 'highIntensityIntervalTraining' | 'hockey' | 'hunting' | 'jumpRope' | 'kickboxing' | 'lacrosse' | 'martialArts' | 'mindAndBody' | 'mixedCardio' | 'paddleSports' | 'pickleball' | 'pilates' | 'play' | 'preparationAndRecovery' | 'racquetball' | 'rugby' | 'sailing' | 'skatingSports' | 'snowboarding' | 'snowSports' | 'softball' | 'squash' | 'stairs' | 'stepTraining' | 'surfingSports' | 'tableTennis' | 'taiChi' | 'trackAndField' | 'transition' | 'underwaterDiving' | 'volleyball' | 'wheelchairRunPace' | 'wheelchairWalkPace' | 'cardioDance' | 'socialDance' | 'other';
|
|
53
53
|
export interface QueryWorkoutsOptions {
|
|
54
54
|
/** Optional workout type filter. If omitted, all workout types are returned. */
|
|
55
55
|
workoutType?: WorkoutType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType =\n | 'steps'\n | 'distance'\n | 'calories'\n | 'heartRate'\n | 'weight'\n | 'sleep'\n | 'respiratoryRate'\n | 'oxygenSaturation'\n | 'restingHeartRate'\n | 'heartRateVariability'\n | 'bloodPressure'\n | 'bloodGlucose'\n | 'bodyTemperature'\n | 'height'\n | 'flightsClimbed'\n | 'exerciseTime'\n | 'distanceCycling'\n | 'bodyFat'\n | 'basalBodyTemperature'\n | 'basalCalories'\n | 'totalCalories'\n | 'mindfulness';\n\nexport type HealthUnit =\n | 'count'\n | 'meter'\n | 'kilocalorie'\n | 'bpm'\n | 'kilogram'\n | 'minute'\n | 'percent'\n | 'millisecond'\n | 'mmHg'\n | 'mg/dL'\n | 'celsius'\n | 'fahrenheit'\n | 'centimeter';\n\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport type SleepState = 'inBed' | 'asleep' | 'awake' | 'rem' | 'deep' | 'light';\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n /** For sleep data, indicates the sleep state (e.g., 'asleep', 'awake', 'rem', 'deep', 'light'). */\n sleepState?: SleepState;\n /** For blood pressure data, the systolic value in mmHg. */\n systolic?: number;\n /** For blood pressure data, the diastolic value in mmHg. */\n diastolic?: number;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport type WorkoutType =\n | 'running'\n | 'cycling'\n | 'walking'\n | 'swimming'\n | 'yoga'\n | 'strengthTraining'\n | 'hiking'\n | 'tennis'\n | 'basketball'\n | 'soccer'\n | 'americanFootball'\n | 'baseball'\n | 'crossTraining'\n | 'elliptical'\n | 'rowing'\n | 'stairClimbing'\n | 'traditionalStrengthTraining'\n | 'waterFitness'\n | 'waterPolo'\n | 'waterSports'\n | 'wrestling'\n | 'other';\n\nexport interface QueryWorkoutsOptions {\n /** Optional workout type filter. If omitted, all workout types are returned. */\n workoutType?: WorkoutType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of workouts to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n /**\n * Anchor for pagination. Use the anchor returned from a previous query to continue from that point.\n * On iOS, this uses HKQueryAnchor. On Android, this uses Health Connect's pageToken.\n * Omit this parameter to start from the beginning.\n */\n anchor?: string;\n}\n\nexport interface Workout {\n /** The type of workout. */\n workoutType: WorkoutType;\n /** Duration of the workout in seconds. */\n duration: number;\n /** Total energy burned in kilocalories (if available). */\n totalEnergyBurned?: number;\n /** Total distance in meters (if available). */\n totalDistance?: number;\n /** ISO 8601 start date of the workout. */\n startDate: string;\n /** ISO 8601 end date of the workout. */\n endDate: string;\n /** Source name that recorded the workout. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QueryWorkoutsResult {\n workouts: Workout[];\n /**\n * Anchor for the next page of results. Pass this value as the anchor parameter in the next query\n * to continue pagination. If undefined or null, there are no more results.\n */\n anchor?: string;\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).\n */\n unit?: HealthUnit;\n /** ISO 8601 start date for the sample. Defaults to now. */\n startDate?: string;\n /** ISO 8601 end date for the sample. Defaults to startDate. */\n endDate?: string;\n /** Metadata key-value pairs forwarded to the native APIs where supported. */\n metadata?: Record<string, string>;\n /** For blood pressure data, the systolic value in mmHg. Required when dataType is 'bloodPressure'. */\n systolic?: number;\n /** For blood pressure data, the diastolic value in mmHg. Required when dataType is 'bloodPressure'. */\n diastolic?: number;\n}\n\nexport type BucketType = 'hour' | 'day' | 'week' | 'month';\n\nexport type AggregationType = 'sum' | 'average' | 'min' | 'max';\n\nexport interface QueryAggregatedOptions {\n /** The type of data to aggregate from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Time bucket for aggregation (defaults to 'day'). */\n bucket?: BucketType;\n /** Aggregation operation to perform (defaults to 'sum'). */\n aggregation?: AggregationType;\n}\n\nexport interface AggregatedSample {\n /** ISO 8601 start date of the bucket. */\n startDate: string;\n /** ISO 8601 end date of the bucket. */\n endDate: string;\n /** Aggregated value for the bucket. */\n value: number;\n /** Unit of the aggregated value. */\n unit: HealthUnit;\n}\n\nexport interface QueryAggregatedResult {\n samples: AggregatedSample[];\n}\n\nexport interface HealthPlugin {\n /** Returns whether the current platform supports the native health SDK. */\n isAvailable(): Promise<AvailabilityResult>;\n /** Requests read/write access to the provided data types. */\n requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Checks authorization status for the provided data types without prompting the user. */\n checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\n /** Writes a single sample to the native health store. */\n saveSample(options: WriteSampleOptions): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ version: string }>} a Promise with version for this device\n * @throws An error if something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Opens the Health Connect settings screen (Android only).\n * On iOS, this method does nothing.\n *\n * Use this to direct users to manage their Health Connect permissions\n * or to install Health Connect if not available.\n *\n * @throws An error if Health Connect settings cannot be opened\n */\n openHealthConnectSettings(): Promise<void>;\n\n /**\n * Shows the app's privacy policy for Health Connect (Android only).\n * On iOS, this method does nothing.\n *\n * This displays the same privacy policy screen that Health Connect shows\n * when the user taps \"Privacy policy\" in the permissions dialog.\n *\n * The privacy policy URL can be configured by adding a string resource\n * named \"health_connect_privacy_policy_url\" in your app's strings.xml,\n * or by placing an HTML file at www/privacypolicy.html in your assets.\n *\n * @throws An error if the privacy policy cannot be displayed\n */\n showPrivacyPolicy(): Promise<void>;\n\n /**\n * Queries workout sessions from the native health store.\n * Supported on iOS (HealthKit) and Android (Health Connect).\n *\n * @param options Query options including optional workout type filter, date range, limit, and sort order\n * @returns A promise that resolves with the workout sessions\n * @throws An error if something went wrong\n */\n queryWorkouts(options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;\n\n /**\n * Queries aggregated health data from the native health store.\n * Aggregates data into time buckets (hour, day, week, month) with operations like sum, average, min, or max.\n * This is more efficient than fetching individual samples for large date ranges.\n *\n * Supported on iOS (HealthKit) and Android (Health Connect).\n *\n * @param options Query options including data type, date range, bucket size, and aggregation type\n * @returns A promise that resolves with the aggregated samples\n * @throws An error if something went wrong\n */\n queryAggregated(options: QueryAggregatedOptions): Promise<QueryAggregatedResult>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType =\n | 'steps'\n | 'distance'\n | 'calories'\n | 'heartRate'\n | 'weight'\n | 'sleep'\n | 'respiratoryRate'\n | 'oxygenSaturation'\n | 'restingHeartRate'\n | 'heartRateVariability'\n | 'bloodPressure'\n | 'bloodGlucose'\n | 'bodyTemperature'\n | 'height'\n | 'flightsClimbed'\n | 'exerciseTime'\n | 'distanceCycling'\n | 'bodyFat'\n | 'basalBodyTemperature'\n | 'basalCalories'\n | 'totalCalories'\n | 'mindfulness';\n\nexport type HealthUnit =\n | 'count'\n | 'meter'\n | 'kilocalorie'\n | 'bpm'\n | 'kilogram'\n | 'minute'\n | 'percent'\n | 'millisecond'\n | 'mmHg'\n | 'mg/dL'\n | 'celsius'\n | 'fahrenheit'\n | 'centimeter';\n\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport type SleepState = 'inBed' | 'asleep' | 'awake' | 'rem' | 'deep' | 'light';\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n /** For sleep data, indicates the sleep state (e.g., 'asleep', 'awake', 'rem', 'deep', 'light'). */\n sleepState?: SleepState;\n /** For blood pressure data, the systolic value in mmHg. */\n systolic?: number;\n /** For blood pressure data, the diastolic value in mmHg. */\n diastolic?: number;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport type WorkoutType =\n | 'running'\n | 'cycling'\n | 'walking'\n | 'swimming'\n | 'yoga'\n | 'strengthTraining'\n | 'hiking'\n | 'tennis'\n | 'basketball'\n | 'soccer'\n | 'americanFootball'\n | 'baseball'\n | 'crossTraining'\n | 'elliptical'\n | 'rowing'\n | 'stairClimbing'\n | 'traditionalStrengthTraining'\n | 'waterFitness'\n | 'waterPolo'\n | 'waterSports'\n | 'wrestling'\n | 'archery'\n | 'australianFootball'\n | 'badminton'\n | 'barre'\n | 'bowling'\n | 'boxing'\n | 'climbing'\n | 'cooldown'\n | 'coreTraining'\n | 'cricket'\n | 'crossCountrySkiing'\n | 'curling'\n | 'dance'\n | 'discSports'\n | 'downhillSkiing'\n | 'equestrianSports'\n | 'fencing'\n | 'fishing'\n | 'fitnessGaming'\n | 'flexibility'\n | 'functionalStrengthTraining'\n | 'golf'\n | 'gymnastics'\n | 'handball'\n | 'handCycling'\n | 'highIntensityIntervalTraining'\n | 'hockey'\n | 'hunting'\n | 'jumpRope'\n | 'kickboxing'\n | 'lacrosse'\n | 'martialArts'\n | 'mindAndBody'\n | 'mixedCardio'\n | 'paddleSports'\n | 'pickleball'\n | 'pilates'\n | 'play'\n | 'preparationAndRecovery'\n | 'racquetball'\n | 'rugby'\n | 'sailing'\n | 'skatingSports'\n | 'snowboarding'\n | 'snowSports'\n | 'softball'\n | 'squash'\n | 'stairs'\n | 'stepTraining'\n | 'surfingSports'\n | 'tableTennis'\n | 'taiChi'\n | 'trackAndField'\n | 'transition'\n | 'underwaterDiving'\n | 'volleyball'\n | 'wheelchairRunPace'\n | 'wheelchairWalkPace'\n | 'cardioDance'\n | 'socialDance'\n | 'other';\n\nexport interface QueryWorkoutsOptions {\n /** Optional workout type filter. If omitted, all workout types are returned. */\n workoutType?: WorkoutType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of workouts to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n /**\n * Anchor for pagination. Use the anchor returned from a previous query to continue from that point.\n * On iOS, this uses HKQueryAnchor. On Android, this uses Health Connect's pageToken.\n * Omit this parameter to start from the beginning.\n */\n anchor?: string;\n}\n\nexport interface Workout {\n /** The type of workout. */\n workoutType: WorkoutType;\n /** Duration of the workout in seconds. */\n duration: number;\n /** Total energy burned in kilocalories (if available). */\n totalEnergyBurned?: number;\n /** Total distance in meters (if available). */\n totalDistance?: number;\n /** ISO 8601 start date of the workout. */\n startDate: string;\n /** ISO 8601 end date of the workout. */\n endDate: string;\n /** Source name that recorded the workout. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QueryWorkoutsResult {\n workouts: Workout[];\n /**\n * Anchor for the next page of results. Pass this value as the anchor parameter in the next query\n * to continue pagination. If undefined or null, there are no more results.\n */\n anchor?: string;\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).\n */\n unit?: HealthUnit;\n /** ISO 8601 start date for the sample. Defaults to now. */\n startDate?: string;\n /** ISO 8601 end date for the sample. Defaults to startDate. */\n endDate?: string;\n /** Metadata key-value pairs forwarded to the native APIs where supported. */\n metadata?: Record<string, string>;\n /** For blood pressure data, the systolic value in mmHg. Required when dataType is 'bloodPressure'. */\n systolic?: number;\n /** For blood pressure data, the diastolic value in mmHg. Required when dataType is 'bloodPressure'. */\n diastolic?: number;\n}\n\nexport type BucketType = 'hour' | 'day' | 'week' | 'month';\n\nexport type AggregationType = 'sum' | 'average' | 'min' | 'max';\n\nexport interface QueryAggregatedOptions {\n /** The type of data to aggregate from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Time bucket for aggregation (defaults to 'day'). */\n bucket?: BucketType;\n /** Aggregation operation to perform (defaults to 'sum'). */\n aggregation?: AggregationType;\n}\n\nexport interface AggregatedSample {\n /** ISO 8601 start date of the bucket. */\n startDate: string;\n /** ISO 8601 end date of the bucket. */\n endDate: string;\n /** Aggregated value for the bucket. */\n value: number;\n /** Unit of the aggregated value. */\n unit: HealthUnit;\n}\n\nexport interface QueryAggregatedResult {\n samples: AggregatedSample[];\n}\n\nexport interface HealthPlugin {\n /** Returns whether the current platform supports the native health SDK. */\n isAvailable(): Promise<AvailabilityResult>;\n /** Requests read/write access to the provided data types. */\n requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Checks authorization status for the provided data types without prompting the user. */\n checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\n /** Writes a single sample to the native health store. */\n saveSample(options: WriteSampleOptions): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ version: string }>} a Promise with version for this device\n * @throws An error if something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Opens the Health Connect settings screen (Android only).\n * On iOS, this method does nothing.\n *\n * Use this to direct users to manage their Health Connect permissions\n * or to install Health Connect if not available.\n *\n * @throws An error if Health Connect settings cannot be opened\n */\n openHealthConnectSettings(): Promise<void>;\n\n /**\n * Shows the app's privacy policy for Health Connect (Android only).\n * On iOS, this method does nothing.\n *\n * This displays the same privacy policy screen that Health Connect shows\n * when the user taps \"Privacy policy\" in the permissions dialog.\n *\n * The privacy policy URL can be configured by adding a string resource\n * named \"health_connect_privacy_policy_url\" in your app's strings.xml,\n * or by placing an HTML file at www/privacypolicy.html in your assets.\n *\n * @throws An error if the privacy policy cannot be displayed\n */\n showPrivacyPolicy(): Promise<void>;\n\n /**\n * Queries workout sessions from the native health store.\n * Supported on iOS (HealthKit) and Android (Health Connect).\n *\n * @param options Query options including optional workout type filter, date range, limit, and sort order\n * @returns A promise that resolves with the workout sessions\n * @throws An error if something went wrong\n */\n queryWorkouts(options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;\n\n /**\n * Queries aggregated health data from the native health store.\n * Aggregates data into time buckets (hour, day, week, month) with operations like sum, average, min, or max.\n * This is more efficient than fetching individual samples for large date ranges.\n *\n * Supported on iOS (HealthKit) and Android (Health Connect).\n *\n * @param options Query options including data type, date range, bucket size, and aggregation type\n * @returns A promise that resolves with the aggregated samples\n * @throws An error if something went wrong\n */\n queryAggregated(options: QueryAggregatedOptions): Promise<QueryAggregatedResult>;\n}\n"]}
|
|
@@ -27,6 +27,19 @@ enum HealthManagerError: LocalizedError {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/// WorkoutType enum that maps TypeScript workout types to iOS HealthKit HKWorkoutActivityType values.
|
|
31
|
+
///
|
|
32
|
+
/// This enum provides bidirectional mapping between the plugin's TypeScript workout types and
|
|
33
|
+
/// native iOS HealthKit workout activity types. The mapping is designed to provide maximum
|
|
34
|
+
/// compatibility across all iOS versions.
|
|
35
|
+
///
|
|
36
|
+
/// iOS Version Compatibility:
|
|
37
|
+
/// - Most workout types are available on all supported iOS versions
|
|
38
|
+
/// - cardioDance and socialDance require iOS 14.0+ and fallback to .dance on older versions
|
|
39
|
+
/// - transition requires iOS 16.0+ and falls back to .other on older versions
|
|
40
|
+
/// - underwaterDiving requires iOS 17.0+ and falls back to .swimming on older versions
|
|
41
|
+
///
|
|
42
|
+
/// Note: The enum case names match the TypeScript WorkoutType union type for consistency.
|
|
30
43
|
enum WorkoutType: String, CaseIterable {
|
|
31
44
|
case running
|
|
32
45
|
case cycling
|
|
@@ -49,6 +62,66 @@ enum WorkoutType: String, CaseIterable {
|
|
|
49
62
|
case waterPolo
|
|
50
63
|
case waterSports
|
|
51
64
|
case wrestling
|
|
65
|
+
case archery
|
|
66
|
+
case australianFootball
|
|
67
|
+
case badminton
|
|
68
|
+
case barre
|
|
69
|
+
case bowling
|
|
70
|
+
case boxing
|
|
71
|
+
case climbing
|
|
72
|
+
case cooldown
|
|
73
|
+
case coreTraining
|
|
74
|
+
case cricket
|
|
75
|
+
case crossCountrySkiing
|
|
76
|
+
case curling
|
|
77
|
+
case dance
|
|
78
|
+
case discSports
|
|
79
|
+
case downhillSkiing
|
|
80
|
+
case equestrianSports
|
|
81
|
+
case fencing
|
|
82
|
+
case fishing
|
|
83
|
+
case fitnessGaming
|
|
84
|
+
case flexibility
|
|
85
|
+
case functionalStrengthTraining
|
|
86
|
+
case golf
|
|
87
|
+
case gymnastics
|
|
88
|
+
case handball
|
|
89
|
+
case handCycling
|
|
90
|
+
case highIntensityIntervalTraining
|
|
91
|
+
case hockey
|
|
92
|
+
case hunting
|
|
93
|
+
case jumpRope
|
|
94
|
+
case kickboxing
|
|
95
|
+
case lacrosse
|
|
96
|
+
case martialArts
|
|
97
|
+
case mindAndBody
|
|
98
|
+
case mixedCardio
|
|
99
|
+
case paddleSports
|
|
100
|
+
case pickleball
|
|
101
|
+
case pilates
|
|
102
|
+
case play
|
|
103
|
+
case preparationAndRecovery
|
|
104
|
+
case racquetball
|
|
105
|
+
case rugby
|
|
106
|
+
case sailing
|
|
107
|
+
case skatingSports
|
|
108
|
+
case snowboarding
|
|
109
|
+
case snowSports
|
|
110
|
+
case softball
|
|
111
|
+
case squash
|
|
112
|
+
case stairs
|
|
113
|
+
case stepTraining
|
|
114
|
+
case surfingSports
|
|
115
|
+
case tableTennis
|
|
116
|
+
case taiChi
|
|
117
|
+
case trackAndField
|
|
118
|
+
case transition
|
|
119
|
+
case underwaterDiving
|
|
120
|
+
case volleyball
|
|
121
|
+
case wheelchairRunPace
|
|
122
|
+
case wheelchairWalkPace
|
|
123
|
+
case cardioDance
|
|
124
|
+
case socialDance
|
|
52
125
|
case other
|
|
53
126
|
|
|
54
127
|
func hkWorkoutActivityType() -> HKWorkoutActivityType {
|
|
@@ -95,6 +168,142 @@ enum WorkoutType: String, CaseIterable {
|
|
|
95
168
|
return .waterSports
|
|
96
169
|
case .wrestling:
|
|
97
170
|
return .wrestling
|
|
171
|
+
case .archery:
|
|
172
|
+
return .archery
|
|
173
|
+
case .australianFootball:
|
|
174
|
+
return .australianFootball
|
|
175
|
+
case .badminton:
|
|
176
|
+
return .badminton
|
|
177
|
+
case .barre:
|
|
178
|
+
return .barre
|
|
179
|
+
case .bowling:
|
|
180
|
+
return .bowling
|
|
181
|
+
case .boxing:
|
|
182
|
+
return .boxing
|
|
183
|
+
case .climbing:
|
|
184
|
+
return .climbing
|
|
185
|
+
case .cooldown:
|
|
186
|
+
return .cooldown
|
|
187
|
+
case .coreTraining:
|
|
188
|
+
return .coreTraining
|
|
189
|
+
case .cricket:
|
|
190
|
+
return .cricket
|
|
191
|
+
case .crossCountrySkiing:
|
|
192
|
+
return .crossCountrySkiing
|
|
193
|
+
case .curling:
|
|
194
|
+
return .curling
|
|
195
|
+
case .dance:
|
|
196
|
+
return .dance
|
|
197
|
+
case .discSports:
|
|
198
|
+
return .discSports
|
|
199
|
+
case .downhillSkiing:
|
|
200
|
+
return .downhillSkiing
|
|
201
|
+
case .equestrianSports:
|
|
202
|
+
return .equestrianSports
|
|
203
|
+
case .fencing:
|
|
204
|
+
return .fencing
|
|
205
|
+
case .fishing:
|
|
206
|
+
return .fishing
|
|
207
|
+
case .fitnessGaming:
|
|
208
|
+
return .fitnessGaming
|
|
209
|
+
case .flexibility:
|
|
210
|
+
return .flexibility
|
|
211
|
+
case .functionalStrengthTraining:
|
|
212
|
+
return .functionalStrengthTraining
|
|
213
|
+
case .golf:
|
|
214
|
+
return .golf
|
|
215
|
+
case .gymnastics:
|
|
216
|
+
return .gymnastics
|
|
217
|
+
case .handball:
|
|
218
|
+
return .handball
|
|
219
|
+
case .handCycling:
|
|
220
|
+
return .handCycling
|
|
221
|
+
case .highIntensityIntervalTraining:
|
|
222
|
+
return .highIntensityIntervalTraining
|
|
223
|
+
case .hockey:
|
|
224
|
+
return .hockey
|
|
225
|
+
case .hunting:
|
|
226
|
+
return .hunting
|
|
227
|
+
case .jumpRope:
|
|
228
|
+
return .jumpRope
|
|
229
|
+
case .kickboxing:
|
|
230
|
+
return .kickboxing
|
|
231
|
+
case .lacrosse:
|
|
232
|
+
return .lacrosse
|
|
233
|
+
case .martialArts:
|
|
234
|
+
return .martialArts
|
|
235
|
+
case .mindAndBody:
|
|
236
|
+
return .mindAndBody
|
|
237
|
+
case .mixedCardio:
|
|
238
|
+
return .mixedCardio
|
|
239
|
+
case .paddleSports:
|
|
240
|
+
return .paddleSports
|
|
241
|
+
case .pickleball:
|
|
242
|
+
return .pickleball
|
|
243
|
+
case .pilates:
|
|
244
|
+
return .pilates
|
|
245
|
+
case .play:
|
|
246
|
+
return .play
|
|
247
|
+
case .preparationAndRecovery:
|
|
248
|
+
return .preparationAndRecovery
|
|
249
|
+
case .racquetball:
|
|
250
|
+
return .racquetball
|
|
251
|
+
case .rugby:
|
|
252
|
+
return .rugby
|
|
253
|
+
case .sailing:
|
|
254
|
+
return .sailing
|
|
255
|
+
case .skatingSports:
|
|
256
|
+
return .skatingSports
|
|
257
|
+
case .snowboarding:
|
|
258
|
+
return .snowboarding
|
|
259
|
+
case .snowSports:
|
|
260
|
+
return .snowSports
|
|
261
|
+
case .softball:
|
|
262
|
+
return .softball
|
|
263
|
+
case .squash:
|
|
264
|
+
return .squash
|
|
265
|
+
case .stairs:
|
|
266
|
+
return .stairs
|
|
267
|
+
case .stepTraining:
|
|
268
|
+
return .stepTraining
|
|
269
|
+
case .surfingSports:
|
|
270
|
+
return .surfingSports
|
|
271
|
+
case .tableTennis:
|
|
272
|
+
return .tableTennis
|
|
273
|
+
case .taiChi:
|
|
274
|
+
return .taiChi
|
|
275
|
+
case .trackAndField:
|
|
276
|
+
return .trackAndField
|
|
277
|
+
case .transition:
|
|
278
|
+
// transition requires iOS 16.0+, fallback to other for older versions
|
|
279
|
+
if #available(iOS 16.0, *) {
|
|
280
|
+
return .transition
|
|
281
|
+
}
|
|
282
|
+
return .other
|
|
283
|
+
case .underwaterDiving:
|
|
284
|
+
// underwaterDiving requires iOS 17.0+, fallback to swimming for older versions
|
|
285
|
+
if #available(iOS 17.0, *) {
|
|
286
|
+
return .underwaterDiving
|
|
287
|
+
}
|
|
288
|
+
return .swimming
|
|
289
|
+
case .volleyball:
|
|
290
|
+
return .volleyball
|
|
291
|
+
case .wheelchairRunPace:
|
|
292
|
+
return .wheelchairRunPace
|
|
293
|
+
case .wheelchairWalkPace:
|
|
294
|
+
return .wheelchairWalkPace
|
|
295
|
+
case .cardioDance:
|
|
296
|
+
// cardioDance requires iOS 14.0+, fallback to dance for older versions
|
|
297
|
+
if #available(iOS 14.0, *) {
|
|
298
|
+
return .cardioDance
|
|
299
|
+
}
|
|
300
|
+
return .dance
|
|
301
|
+
case .socialDance:
|
|
302
|
+
// socialDance requires iOS 14.0+, fallback to dance for older versions
|
|
303
|
+
if #available(iOS 14.0, *) {
|
|
304
|
+
return .socialDance
|
|
305
|
+
}
|
|
306
|
+
return .dance
|
|
98
307
|
case .other:
|
|
99
308
|
return .other
|
|
100
309
|
}
|
|
@@ -112,8 +321,11 @@ enum WorkoutType: String, CaseIterable {
|
|
|
112
321
|
return .swimming
|
|
113
322
|
case .yoga:
|
|
114
323
|
return .yoga
|
|
324
|
+
// Note: Both plugin workout types "strengthTraining" and "traditionalStrengthTraining"
|
|
325
|
+
// are written to HealthKit as HKWorkoutActivityType.traditionalStrengthTraining.
|
|
326
|
+
// When reading from HealthKit we always normalize back to .strengthTraining to keep
|
|
327
|
+
// a single canonical plugin type and maintain backward compatibility.
|
|
115
328
|
case .traditionalStrengthTraining:
|
|
116
|
-
// Map back to strengthTraining for consistency (both map to the same HK type)
|
|
117
329
|
return .strengthTraining
|
|
118
330
|
case .hiking:
|
|
119
331
|
return .hiking
|
|
@@ -143,7 +355,140 @@ enum WorkoutType: String, CaseIterable {
|
|
|
143
355
|
return .waterSports
|
|
144
356
|
case .wrestling:
|
|
145
357
|
return .wrestling
|
|
358
|
+
case .archery:
|
|
359
|
+
return .archery
|
|
360
|
+
case .australianFootball:
|
|
361
|
+
return .australianFootball
|
|
362
|
+
case .badminton:
|
|
363
|
+
return .badminton
|
|
364
|
+
case .barre:
|
|
365
|
+
return .barre
|
|
366
|
+
case .bowling:
|
|
367
|
+
return .bowling
|
|
368
|
+
case .boxing:
|
|
369
|
+
return .boxing
|
|
370
|
+
case .climbing:
|
|
371
|
+
return .climbing
|
|
372
|
+
case .cooldown:
|
|
373
|
+
return .cooldown
|
|
374
|
+
case .coreTraining:
|
|
375
|
+
return .coreTraining
|
|
376
|
+
case .cricket:
|
|
377
|
+
return .cricket
|
|
378
|
+
case .crossCountrySkiing:
|
|
379
|
+
return .crossCountrySkiing
|
|
380
|
+
case .curling:
|
|
381
|
+
return .curling
|
|
382
|
+
case .dance:
|
|
383
|
+
return .dance
|
|
384
|
+
case .discSports:
|
|
385
|
+
return .discSports
|
|
386
|
+
case .downhillSkiing:
|
|
387
|
+
return .downhillSkiing
|
|
388
|
+
case .equestrianSports:
|
|
389
|
+
return .equestrianSports
|
|
390
|
+
case .fencing:
|
|
391
|
+
return .fencing
|
|
392
|
+
case .fishing:
|
|
393
|
+
return .fishing
|
|
394
|
+
case .fitnessGaming:
|
|
395
|
+
return .fitnessGaming
|
|
396
|
+
case .flexibility:
|
|
397
|
+
return .flexibility
|
|
398
|
+
case .functionalStrengthTraining:
|
|
399
|
+
return .functionalStrengthTraining
|
|
400
|
+
case .golf:
|
|
401
|
+
return .golf
|
|
402
|
+
case .gymnastics:
|
|
403
|
+
return .gymnastics
|
|
404
|
+
case .handball:
|
|
405
|
+
return .handball
|
|
406
|
+
case .handCycling:
|
|
407
|
+
return .handCycling
|
|
408
|
+
case .highIntensityIntervalTraining:
|
|
409
|
+
return .highIntensityIntervalTraining
|
|
410
|
+
case .hockey:
|
|
411
|
+
return .hockey
|
|
412
|
+
case .hunting:
|
|
413
|
+
return .hunting
|
|
414
|
+
case .jumpRope:
|
|
415
|
+
return .jumpRope
|
|
416
|
+
case .kickboxing:
|
|
417
|
+
return .kickboxing
|
|
418
|
+
case .lacrosse:
|
|
419
|
+
return .lacrosse
|
|
420
|
+
case .martialArts:
|
|
421
|
+
return .martialArts
|
|
422
|
+
case .mindAndBody:
|
|
423
|
+
return .mindAndBody
|
|
424
|
+
case .mixedCardio:
|
|
425
|
+
return .mixedCardio
|
|
426
|
+
case .paddleSports:
|
|
427
|
+
return .paddleSports
|
|
428
|
+
case .pickleball:
|
|
429
|
+
return .pickleball
|
|
430
|
+
case .pilates:
|
|
431
|
+
return .pilates
|
|
432
|
+
case .play:
|
|
433
|
+
return .play
|
|
434
|
+
case .preparationAndRecovery:
|
|
435
|
+
return .preparationAndRecovery
|
|
436
|
+
case .racquetball:
|
|
437
|
+
return .racquetball
|
|
438
|
+
case .rugby:
|
|
439
|
+
return .rugby
|
|
440
|
+
case .sailing:
|
|
441
|
+
return .sailing
|
|
442
|
+
case .skatingSports:
|
|
443
|
+
return .skatingSports
|
|
444
|
+
case .snowboarding:
|
|
445
|
+
return .snowboarding
|
|
446
|
+
case .snowSports:
|
|
447
|
+
return .snowSports
|
|
448
|
+
case .softball:
|
|
449
|
+
return .softball
|
|
450
|
+
case .squash:
|
|
451
|
+
return .squash
|
|
452
|
+
case .stairs:
|
|
453
|
+
return .stairs
|
|
454
|
+
case .stepTraining:
|
|
455
|
+
return .stepTraining
|
|
456
|
+
case .surfingSports:
|
|
457
|
+
return .surfingSports
|
|
458
|
+
case .tableTennis:
|
|
459
|
+
return .tableTennis
|
|
460
|
+
case .taiChi:
|
|
461
|
+
return .taiChi
|
|
462
|
+
case .trackAndField:
|
|
463
|
+
return .trackAndField
|
|
464
|
+
case .volleyball:
|
|
465
|
+
return .volleyball
|
|
466
|
+
case .wheelchairRunPace:
|
|
467
|
+
return .wheelchairRunPace
|
|
468
|
+
case .wheelchairWalkPace:
|
|
469
|
+
return .wheelchairWalkPace
|
|
146
470
|
default:
|
|
471
|
+
// Handle iOS 14+ types
|
|
472
|
+
if #available(iOS 14.0, *) {
|
|
473
|
+
if hkType == .cardioDance {
|
|
474
|
+
return .cardioDance
|
|
475
|
+
}
|
|
476
|
+
if hkType == .socialDance {
|
|
477
|
+
return .socialDance
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
// Handle iOS 16+ types
|
|
481
|
+
if #available(iOS 16.0, *) {
|
|
482
|
+
if hkType == .transition {
|
|
483
|
+
return .transition
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
// Handle iOS 17+ types
|
|
487
|
+
if #available(iOS 17.0, *) {
|
|
488
|
+
if hkType == .underwaterDiving {
|
|
489
|
+
return .underwaterDiving
|
|
490
|
+
}
|
|
491
|
+
}
|
|
147
492
|
return .other
|
|
148
493
|
}
|
|
149
494
|
}
|
|
@@ -3,7 +3,7 @@ import Capacitor
|
|
|
3
3
|
|
|
4
4
|
@objc(HealthPlugin)
|
|
5
5
|
public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
-
private let pluginVersion: String = "8.
|
|
6
|
+
private let pluginVersion: String = "8.3.0"
|
|
7
7
|
public let identifier = "HealthPlugin"
|
|
8
8
|
public let jsName = "Health"
|
|
9
9
|
public let pluginMethods: [CAPPluginMethod] = [
|
package/package.json
CHANGED