@asiriindatissa/capacitor-health 9.0.2 → 9.0.4
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 +58 -3
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthManager.kt +96 -4
- package/android/src/main/java/app/capgo/plugin/health/HealthPlugin.kt +50 -2
- package/android/src/main/java/app/capgo/plugin/health/WorkoutType.kt +64 -0
- package/dist/docs.json +268 -11
- package/dist/esm/definitions.d.ts +42 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -216,6 +216,7 @@ const { sleepSessions } = await Health.querySleep({
|
|
|
216
216
|
* [`getPluginVersion()`](#getpluginversion)
|
|
217
217
|
* [`openHealthConnectSettings()`](#openhealthconnectsettings)
|
|
218
218
|
* [`showPrivacyPolicy()`](#showprivacypolicy)
|
|
219
|
+
* [`queryWorkouts(...)`](#queryworkouts)
|
|
219
220
|
* [`querySleep(...)`](#querysleep)
|
|
220
221
|
* [`queryHydration(...)`](#queryhydration)
|
|
221
222
|
* [Interfaces](#interfaces)
|
|
@@ -318,6 +319,23 @@ or by placing an HTML file at www/privacypolicy.html in your assets.
|
|
|
318
319
|
--------------------
|
|
319
320
|
|
|
320
321
|
|
|
322
|
+
### queryWorkouts(...)
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
queryWorkouts(options: QueryWorkoutsOptions) => Promise<QueryWorkoutsResult>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Queries workout sessions from the native health store on Android (Health Connect).
|
|
329
|
+
|
|
330
|
+
| Param | Type | Description |
|
|
331
|
+
| ------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
332
|
+
| **`options`** | <code><a href="#queryworkoutsoptions">QueryWorkoutsOptions</a></code> | Query options including optional workout type filter, date range, limit, and sort order |
|
|
333
|
+
|
|
334
|
+
**Returns:** <code>Promise<<a href="#queryworkoutsresult">QueryWorkoutsResult</a>></code>
|
|
335
|
+
|
|
336
|
+
--------------------
|
|
337
|
+
|
|
338
|
+
|
|
321
339
|
### querySleep(...)
|
|
322
340
|
|
|
323
341
|
```typescript
|
|
@@ -381,6 +399,37 @@ Queries hydration records from the native health store on Android (Health Connec
|
|
|
381
399
|
| **`read`** | <code>ReadAuthorizationType[]</code> | Data types that should be readable after authorization. |
|
|
382
400
|
|
|
383
401
|
|
|
402
|
+
#### QueryWorkoutsResult
|
|
403
|
+
|
|
404
|
+
| Prop | Type |
|
|
405
|
+
| -------------- | ---------------------- |
|
|
406
|
+
| **`workouts`** | <code>Workout[]</code> |
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
#### Workout
|
|
410
|
+
|
|
411
|
+
| Prop | Type | Description |
|
|
412
|
+
| ----------------- | --------------------------------------------------------------- | -------------------------------------- |
|
|
413
|
+
| **`workoutType`** | <code><a href="#workouttype">WorkoutType</a></code> | The type of workout. |
|
|
414
|
+
| **`duration`** | <code>number</code> | Duration of the workout in seconds. |
|
|
415
|
+
| **`startDate`** | <code>string</code> | ISO 8601 start date of the workout. |
|
|
416
|
+
| **`endDate`** | <code>string</code> | ISO 8601 end date of the workout. |
|
|
417
|
+
| **`sourceName`** | <code>string</code> | Source name that recorded the workout. |
|
|
418
|
+
| **`sourceId`** | <code>string</code> | Source bundle identifier. |
|
|
419
|
+
| **`metadata`** | <code><a href="#record">Record</a><string, string></code> | Additional metadata (if available). |
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
#### QueryWorkoutsOptions
|
|
423
|
+
|
|
424
|
+
| Prop | Type | Description |
|
|
425
|
+
| ----------------- | --------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
426
|
+
| **`workoutType`** | <code><a href="#workouttype">WorkoutType</a></code> | Optional workout type filter. If omitted, all workout types are returned. |
|
|
427
|
+
| **`startDate`** | <code>string</code> | Inclusive ISO 8601 start date (defaults to now - 1 day). |
|
|
428
|
+
| **`endDate`** | <code>string</code> | Exclusive ISO 8601 end date (defaults to now). |
|
|
429
|
+
| **`limit`** | <code>number</code> | Maximum number of workouts to return (defaults to 100). |
|
|
430
|
+
| **`ascending`** | <code>boolean</code> | Return results sorted ascending by start date (defaults to false). |
|
|
431
|
+
|
|
432
|
+
|
|
384
433
|
#### QuerySleepResult
|
|
385
434
|
|
|
386
435
|
| Prop | Type |
|
|
@@ -456,15 +505,16 @@ Queries hydration records from the native health store on Android (Health Connec
|
|
|
456
505
|
#### ReadAuthorizationType
|
|
457
506
|
|
|
458
507
|
Data types that can be requested for read authorization.
|
|
508
|
+
Includes 'workouts' for querying workout sessions via queryWorkouts().
|
|
459
509
|
Includes 'sleep' for querying sleep sessions via querySleep().
|
|
460
510
|
Includes 'hydration' for querying hydration records via queryHydration().
|
|
461
511
|
|
|
462
|
-
<code>'sleep' | 'hydration'</code>
|
|
512
|
+
<code>'workouts' | 'sleep' | 'hydration'</code>
|
|
463
513
|
|
|
464
514
|
|
|
465
|
-
####
|
|
515
|
+
#### WorkoutType
|
|
466
516
|
|
|
467
|
-
<code>'
|
|
517
|
+
<code>'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'other'</code>
|
|
468
518
|
|
|
469
519
|
|
|
470
520
|
#### Record
|
|
@@ -473,6 +523,11 @@ Construct a type with a set of properties K of type T
|
|
|
473
523
|
|
|
474
524
|
<code>{
|
|
475
525
|
[P in K]: T;
|
|
476
526
|
}</code>
|
|
477
527
|
|
|
528
|
+
|
|
529
|
+
#### SleepStage
|
|
530
|
+
|
|
531
|
+
<code>'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem'</code>
|
|
532
|
+
|
|
478
533
|
</docgen-api>
|
|
479
534
|
|
|
480
535
|
### Credits:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
2
|
<uses-permission android:name="android.permission.health.READ_SLEEP" />
|
|
3
3
|
<uses-permission android:name="android.permission.health.READ_HYDRATION" />
|
|
4
|
+
<uses-permission android:name="android.permission.health.READ_EXERCISE" />
|
|
4
5
|
|
|
5
6
|
<!-- Query for Health Connect availability -->
|
|
6
7
|
<queries>
|
|
@@ -2,17 +2,15 @@ package app.capgo.plugin.health
|
|
|
2
2
|
|
|
3
3
|
import androidx.health.connect.client.HealthConnectClient
|
|
4
4
|
import androidx.health.connect.client.permission.HealthPermission
|
|
5
|
+
import androidx.health.connect.client.records.ExerciseSessionRecord
|
|
5
6
|
import androidx.health.connect.client.records.HydrationRecord
|
|
6
7
|
import androidx.health.connect.client.records.SleepSessionRecord
|
|
7
8
|
import androidx.health.connect.client.request.ReadRecordsRequest
|
|
8
9
|
import androidx.health.connect.client.time.TimeRangeFilter
|
|
9
|
-
import androidx.health.connect.client.records.metadata.Metadata
|
|
10
10
|
import java.time.Duration
|
|
11
11
|
import com.getcapacitor.JSArray
|
|
12
12
|
import com.getcapacitor.JSObject
|
|
13
13
|
import java.time.Instant
|
|
14
|
-
import java.time.ZoneId
|
|
15
|
-
import java.time.ZoneOffset
|
|
16
14
|
import java.time.format.DateTimeFormatter
|
|
17
15
|
import kotlin.math.min
|
|
18
16
|
import kotlin.collections.buildSet
|
|
@@ -21,7 +19,11 @@ class HealthManager {
|
|
|
21
19
|
|
|
22
20
|
private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_INSTANT
|
|
23
21
|
|
|
24
|
-
fun permissionsFor(includeSleep: Boolean = false, includeHydration: Boolean = false): Set<String> = buildSet {
|
|
22
|
+
fun permissionsFor(includeWorkouts: Boolean = false, includeSleep: Boolean = false, includeHydration: Boolean = false): Set<String> = buildSet {
|
|
23
|
+
// Include workout read permission if explicitly requested
|
|
24
|
+
if (includeWorkouts) {
|
|
25
|
+
add(HealthPermission.getReadPermission(ExerciseSessionRecord::class))
|
|
26
|
+
}
|
|
25
27
|
// Include sleep read permission if explicitly requested
|
|
26
28
|
if (includeSleep) {
|
|
27
29
|
add(HealthPermission.getReadPermission(SleepSessionRecord::class))
|
|
@@ -34,6 +36,7 @@ class HealthManager {
|
|
|
34
36
|
|
|
35
37
|
suspend fun authorizationStatus(
|
|
36
38
|
client: HealthConnectClient,
|
|
39
|
+
includeWorkouts: Boolean = false,
|
|
37
40
|
includeSleep: Boolean = false,
|
|
38
41
|
includeHydration: Boolean = false
|
|
39
42
|
): JSObject {
|
|
@@ -42,6 +45,16 @@ class HealthManager {
|
|
|
42
45
|
val readAuthorized = JSArray()
|
|
43
46
|
val readDenied = JSArray()
|
|
44
47
|
|
|
48
|
+
// Check workout permission if requested
|
|
49
|
+
if (includeWorkouts) {
|
|
50
|
+
val workoutPermission = HealthPermission.getReadPermission(ExerciseSessionRecord::class)
|
|
51
|
+
if (granted.contains(workoutPermission)) {
|
|
52
|
+
readAuthorized.put("workouts")
|
|
53
|
+
} else {
|
|
54
|
+
readDenied.put("workouts")
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
45
58
|
// Check sleep permission if requested
|
|
46
59
|
if (includeSleep) {
|
|
47
60
|
val sleepPermission = HealthPermission.getReadPermission(SleepSessionRecord::class)
|
|
@@ -86,6 +99,85 @@ class HealthManager {
|
|
|
86
99
|
return ZoneId.systemDefault().rules.getOffset(instant)
|
|
87
100
|
}
|
|
88
101
|
|
|
102
|
+
suspend fun queryWorkouts(
|
|
103
|
+
client: HealthConnectClient,
|
|
104
|
+
workoutType: String?,
|
|
105
|
+
startTime: Instant,
|
|
106
|
+
endTime: Instant,
|
|
107
|
+
limit: Int,
|
|
108
|
+
ascending: Boolean
|
|
109
|
+
): JSArray {
|
|
110
|
+
val workouts = mutableListOf<Pair<Instant, JSObject>>()
|
|
111
|
+
|
|
112
|
+
var pageToken: String? = null
|
|
113
|
+
val pageSize = if (limit > 0) min(limit, MAX_PAGE_SIZE) else DEFAULT_PAGE_SIZE
|
|
114
|
+
var fetched = 0
|
|
115
|
+
|
|
116
|
+
val exerciseTypeFilter = WorkoutType.fromString(workoutType)
|
|
117
|
+
|
|
118
|
+
do {
|
|
119
|
+
val request = ReadRecordsRequest(
|
|
120
|
+
recordType = ExerciseSessionRecord::class,
|
|
121
|
+
timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
|
|
122
|
+
pageSize = pageSize,
|
|
123
|
+
pageToken = pageToken
|
|
124
|
+
)
|
|
125
|
+
val response = client.readRecords(request)
|
|
126
|
+
|
|
127
|
+
response.records.forEach { record ->
|
|
128
|
+
val session = record as ExerciseSessionRecord
|
|
129
|
+
|
|
130
|
+
// Filter by exercise type if specified
|
|
131
|
+
if (exerciseTypeFilter != null && session.exerciseType != exerciseTypeFilter) {
|
|
132
|
+
return@forEach
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
val payload = createWorkoutPayload(session)
|
|
136
|
+
workouts.add(session.startTime to payload)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
fetched += response.records.size
|
|
140
|
+
pageToken = response.pageToken
|
|
141
|
+
} while (pageToken != null && (limit <= 0 || fetched < limit))
|
|
142
|
+
|
|
143
|
+
val sorted = workouts.sortedBy { it.first }
|
|
144
|
+
val ordered = if (ascending) sorted else sorted.asReversed()
|
|
145
|
+
val limited = if (limit > 0) ordered.take(limit) else ordered
|
|
146
|
+
|
|
147
|
+
val array = JSArray()
|
|
148
|
+
limited.forEach { array.put(it.second) }
|
|
149
|
+
return array
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private fun createWorkoutPayload(session: ExerciseSessionRecord): JSObject {
|
|
153
|
+
val payload = JSObject()
|
|
154
|
+
|
|
155
|
+
// Workout type
|
|
156
|
+
payload.put("workoutType", WorkoutType.toWorkoutTypeString(session.exerciseType))
|
|
157
|
+
|
|
158
|
+
// Duration in seconds
|
|
159
|
+
val durationSeconds = Duration.between(session.startTime, session.endTime).seconds.toInt()
|
|
160
|
+
payload.put("duration", durationSeconds)
|
|
161
|
+
|
|
162
|
+
// Start and end dates
|
|
163
|
+
payload.put("startDate", formatter.format(session.startTime))
|
|
164
|
+
payload.put("endDate", formatter.format(session.endTime))
|
|
165
|
+
|
|
166
|
+
// Source information
|
|
167
|
+
val dataOrigin = session.metadata.dataOrigin
|
|
168
|
+
payload.put("sourceId", dataOrigin.packageName)
|
|
169
|
+
payload.put("sourceName", dataOrigin.packageName)
|
|
170
|
+
session.metadata.device?.let { device ->
|
|
171
|
+
val manufacturer = device.manufacturer?.takeIf { it.isNotBlank() }
|
|
172
|
+
val model = device.model?.takeIf { it.isNotBlank() }
|
|
173
|
+
val label = listOfNotNull(manufacturer, model).joinToString(" ").trim()
|
|
174
|
+
if (label.isNotEmpty()) {
|
|
175
|
+
payload.put("sourceName", label)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return payload
|
|
180
|
+
}
|
|
89
181
|
|
|
90
182
|
suspend fun querySleep(
|
|
91
183
|
client: HealthConnectClient,
|
|
@@ -23,6 +23,7 @@ import kotlinx.coroutines.cancel
|
|
|
23
23
|
import kotlinx.coroutines.launch
|
|
24
24
|
|
|
25
25
|
data class ReadAuthorizationTypes(
|
|
26
|
+
val includeWorkouts: Boolean,
|
|
26
27
|
val includeSleep: Boolean,
|
|
27
28
|
val includeHydration: Boolean
|
|
28
29
|
)
|
|
@@ -35,6 +36,7 @@ class HealthPlugin : Plugin() {
|
|
|
35
36
|
private val permissionContract = PermissionController.createRequestPermissionResultContract()
|
|
36
37
|
|
|
37
38
|
// Store pending request data for callback
|
|
39
|
+
private var pendingIncludeWorkouts: Boolean = false
|
|
38
40
|
private var pendingIncludeSleep: Boolean = false
|
|
39
41
|
private var pendingIncludeHydration: Boolean = false
|
|
40
42
|
|
|
@@ -61,6 +63,7 @@ class HealthPlugin : Plugin() {
|
|
|
61
63
|
pluginScope.launch {
|
|
62
64
|
val client = getClientOrReject(call) ?: return@launch
|
|
63
65
|
val permissions = manager.permissionsFor(
|
|
66
|
+
readAuth.includeWorkouts,
|
|
64
67
|
readAuth.includeSleep,
|
|
65
68
|
readAuth.includeHydration
|
|
66
69
|
)
|
|
@@ -68,6 +71,7 @@ class HealthPlugin : Plugin() {
|
|
|
68
71
|
if (permissions.isEmpty()) {
|
|
69
72
|
val status = manager.authorizationStatus(
|
|
70
73
|
client,
|
|
74
|
+
readAuth.includeWorkouts,
|
|
71
75
|
readAuth.includeSleep,
|
|
72
76
|
readAuth.includeHydration
|
|
73
77
|
)
|
|
@@ -79,6 +83,7 @@ class HealthPlugin : Plugin() {
|
|
|
79
83
|
if (granted.containsAll(permissions)) {
|
|
80
84
|
val status = manager.authorizationStatus(
|
|
81
85
|
client,
|
|
86
|
+
readAuth.includeWorkouts,
|
|
82
87
|
readAuth.includeSleep,
|
|
83
88
|
readAuth.includeHydration
|
|
84
89
|
)
|
|
@@ -87,6 +92,7 @@ class HealthPlugin : Plugin() {
|
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
// Store types for callback
|
|
95
|
+
pendingIncludeWorkouts = readAuth.includeWorkouts
|
|
90
96
|
pendingIncludeSleep = readAuth.includeSleep
|
|
91
97
|
pendingIncludeHydration = readAuth.includeHydration
|
|
92
98
|
|
|
@@ -107,14 +113,16 @@ class HealthPlugin : Plugin() {
|
|
|
107
113
|
return
|
|
108
114
|
}
|
|
109
115
|
|
|
116
|
+
val includeWorkouts = pendingIncludeWorkouts
|
|
110
117
|
val includeSleep = pendingIncludeSleep
|
|
111
118
|
val includeHydration = pendingIncludeHydration
|
|
119
|
+
pendingIncludeWorkouts = false
|
|
112
120
|
pendingIncludeSleep = false
|
|
113
121
|
pendingIncludeHydration = false
|
|
114
122
|
|
|
115
123
|
pluginScope.launch {
|
|
116
124
|
val client = getClientOrReject(call) ?: return@launch
|
|
117
|
-
val status = manager.authorizationStatus(client, includeSleep, includeHydration)
|
|
125
|
+
val status = manager.authorizationStatus(client, includeWorkouts, includeSleep, includeHydration)
|
|
118
126
|
call.resolve(status)
|
|
119
127
|
}
|
|
120
128
|
}
|
|
@@ -132,6 +140,7 @@ class HealthPlugin : Plugin() {
|
|
|
132
140
|
val client = getClientOrReject(call) ?: return@launch
|
|
133
141
|
val status = manager.authorizationStatus(
|
|
134
142
|
client,
|
|
143
|
+
readAuth.includeWorkouts,
|
|
135
144
|
readAuth.includeSleep,
|
|
136
145
|
readAuth.includeHydration
|
|
137
146
|
)
|
|
@@ -142,17 +151,19 @@ class HealthPlugin : Plugin() {
|
|
|
142
151
|
|
|
143
152
|
private fun parseReadAuthorizationTypes(call: PluginCall, key: String): ReadAuthorizationTypes {
|
|
144
153
|
val array = call.getArray(key) ?: JSArray()
|
|
154
|
+
var includeWorkouts = false
|
|
145
155
|
var includeSleep = false
|
|
146
156
|
var includeHydration = false
|
|
147
157
|
for (i in 0 until array.length()) {
|
|
148
158
|
val identifier = array.optString(i, null) ?: continue
|
|
149
159
|
when (identifier) {
|
|
160
|
+
"workouts" -> includeWorkouts = true
|
|
150
161
|
"sleep" -> includeSleep = true
|
|
151
162
|
"hydration" -> includeHydration = true
|
|
152
163
|
else -> throw IllegalArgumentException("Unsupported data type: $identifier")
|
|
153
164
|
}
|
|
154
165
|
}
|
|
155
|
-
return ReadAuthorizationTypes(includeSleep, includeHydration)
|
|
166
|
+
return ReadAuthorizationTypes(includeWorkouts, includeSleep, includeHydration)
|
|
156
167
|
}
|
|
157
168
|
|
|
158
169
|
private fun getClientOrReject(call: PluginCall): HealthConnectClient? {
|
|
@@ -217,6 +228,43 @@ class HealthPlugin : Plugin() {
|
|
|
217
228
|
}
|
|
218
229
|
}
|
|
219
230
|
|
|
231
|
+
@PluginMethod
|
|
232
|
+
fun queryWorkouts(call: PluginCall) {
|
|
233
|
+
val workoutType = call.getString("workoutType")
|
|
234
|
+
val limit = (call.getInt("limit") ?: DEFAULT_LIMIT).coerceAtLeast(0)
|
|
235
|
+
val ascending = call.getBoolean("ascending") ?: false
|
|
236
|
+
|
|
237
|
+
val startInstant = try {
|
|
238
|
+
manager.parseInstant(call.getString("startDate"), Instant.now().minus(DEFAULT_PAST_DURATION))
|
|
239
|
+
} catch (e: DateTimeParseException) {
|
|
240
|
+
call.reject(e.message, null, e)
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
val endInstant = try {
|
|
245
|
+
manager.parseInstant(call.getString("endDate"), Instant.now())
|
|
246
|
+
} catch (e: DateTimeParseException) {
|
|
247
|
+
call.reject(e.message, null, e)
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (endInstant.isBefore(startInstant)) {
|
|
252
|
+
call.reject("endDate must be greater than or equal to startDate")
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
pluginScope.launch {
|
|
257
|
+
val client = getClientOrReject(call) ?: return@launch
|
|
258
|
+
try {
|
|
259
|
+
val workouts = manager.queryWorkouts(client, workoutType, startInstant, endInstant, limit, ascending)
|
|
260
|
+
val result = JSObject().apply { put("workouts", workouts) }
|
|
261
|
+
call.resolve(result)
|
|
262
|
+
} catch (e: Exception) {
|
|
263
|
+
call.reject(e.message ?: "Failed to query workouts.", null, e)
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
220
268
|
@PluginMethod
|
|
221
269
|
fun querySleep(call: PluginCall) {
|
|
222
270
|
val limit = (call.getInt("limit") ?: DEFAULT_LIMIT).coerceAtLeast(0)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package app.capgo.plugin.health
|
|
2
|
+
|
|
3
|
+
import androidx.health.connect.client.records.ExerciseSessionRecord
|
|
4
|
+
|
|
5
|
+
object WorkoutType {
|
|
6
|
+
fun fromString(type: String?): Int? {
|
|
7
|
+
if (type.isNullOrBlank()) return null
|
|
8
|
+
|
|
9
|
+
return when (type) {
|
|
10
|
+
"running" -> ExerciseSessionRecord.EXERCISE_TYPE_RUNNING
|
|
11
|
+
"cycling" -> ExerciseSessionRecord.EXERCISE_TYPE_BIKING
|
|
12
|
+
"walking" -> ExerciseSessionRecord.EXERCISE_TYPE_WALKING
|
|
13
|
+
"swimming" -> ExerciseSessionRecord.EXERCISE_TYPE_SWIMMING_POOL
|
|
14
|
+
"yoga" -> ExerciseSessionRecord.EXERCISE_TYPE_YOGA
|
|
15
|
+
"strengthTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING
|
|
16
|
+
"hiking" -> ExerciseSessionRecord.EXERCISE_TYPE_HIKING
|
|
17
|
+
"tennis" -> ExerciseSessionRecord.EXERCISE_TYPE_TENNIS
|
|
18
|
+
"basketball" -> ExerciseSessionRecord.EXERCISE_TYPE_BASKETBALL
|
|
19
|
+
"soccer" -> ExerciseSessionRecord.EXERCISE_TYPE_SOCCER
|
|
20
|
+
"americanFootball" -> ExerciseSessionRecord.EXERCISE_TYPE_FOOTBALL_AMERICAN
|
|
21
|
+
"baseball" -> ExerciseSessionRecord.EXERCISE_TYPE_BASEBALL
|
|
22
|
+
"crossTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING
|
|
23
|
+
"elliptical" -> ExerciseSessionRecord.EXERCISE_TYPE_ELLIPTICAL
|
|
24
|
+
"rowing" -> ExerciseSessionRecord.EXERCISE_TYPE_ROWING
|
|
25
|
+
"stairClimbing" -> ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING
|
|
26
|
+
"traditionalStrengthTraining" -> ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING
|
|
27
|
+
"waterFitness" -> ExerciseSessionRecord.EXERCISE_TYPE_SWIMMING_POOL
|
|
28
|
+
"waterPolo" -> ExerciseSessionRecord.EXERCISE_TYPE_WATER_POLO
|
|
29
|
+
"waterSports" -> ExerciseSessionRecord.EXERCISE_TYPE_SWIMMING_OPEN_WATER
|
|
30
|
+
"wrestling" -> ExerciseSessionRecord.EXERCISE_TYPE_MARTIAL_ARTS
|
|
31
|
+
"other" -> ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT
|
|
32
|
+
else -> null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun toWorkoutTypeString(exerciseType: Int): String {
|
|
37
|
+
return when (exerciseType) {
|
|
38
|
+
ExerciseSessionRecord.EXERCISE_TYPE_RUNNING -> "running"
|
|
39
|
+
ExerciseSessionRecord.EXERCISE_TYPE_BIKING -> "cycling"
|
|
40
|
+
ExerciseSessionRecord.EXERCISE_TYPE_BIKING_STATIONARY -> "cycling"
|
|
41
|
+
ExerciseSessionRecord.EXERCISE_TYPE_WALKING -> "walking"
|
|
42
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SWIMMING_POOL -> "swimming"
|
|
43
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SWIMMING_OPEN_WATER -> "swimming"
|
|
44
|
+
ExerciseSessionRecord.EXERCISE_TYPE_YOGA -> "yoga"
|
|
45
|
+
ExerciseSessionRecord.EXERCISE_TYPE_STRENGTH_TRAINING -> "strengthTraining"
|
|
46
|
+
ExerciseSessionRecord.EXERCISE_TYPE_HIKING -> "hiking"
|
|
47
|
+
ExerciseSessionRecord.EXERCISE_TYPE_TENNIS -> "tennis"
|
|
48
|
+
ExerciseSessionRecord.EXERCISE_TYPE_BASKETBALL -> "basketball"
|
|
49
|
+
ExerciseSessionRecord.EXERCISE_TYPE_SOCCER -> "soccer"
|
|
50
|
+
ExerciseSessionRecord.EXERCISE_TYPE_FOOTBALL_AMERICAN -> "americanFootball"
|
|
51
|
+
ExerciseSessionRecord.EXERCISE_TYPE_BASEBALL -> "baseball"
|
|
52
|
+
ExerciseSessionRecord.EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING -> "crossTraining"
|
|
53
|
+
ExerciseSessionRecord.EXERCISE_TYPE_ELLIPTICAL -> "elliptical"
|
|
54
|
+
ExerciseSessionRecord.EXERCISE_TYPE_ROWING -> "rowing"
|
|
55
|
+
ExerciseSessionRecord.EXERCISE_TYPE_ROWING_MACHINE -> "rowing"
|
|
56
|
+
ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING -> "stairClimbing"
|
|
57
|
+
ExerciseSessionRecord.EXERCISE_TYPE_STAIR_CLIMBING_MACHINE -> "stairClimbing"
|
|
58
|
+
ExerciseSessionRecord.EXERCISE_TYPE_WATER_POLO -> "waterPolo"
|
|
59
|
+
ExerciseSessionRecord.EXERCISE_TYPE_MARTIAL_ARTS -> "wrestling"
|
|
60
|
+
ExerciseSessionRecord.EXERCISE_TYPE_OTHER_WORKOUT -> "other"
|
|
61
|
+
else -> "other"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -104,6 +104,38 @@
|
|
|
104
104
|
"complexTypes": [],
|
|
105
105
|
"slug": "showprivacypolicy"
|
|
106
106
|
},
|
|
107
|
+
{
|
|
108
|
+
"name": "queryWorkouts",
|
|
109
|
+
"signature": "(options: QueryWorkoutsOptions) => Promise<QueryWorkoutsResult>",
|
|
110
|
+
"parameters": [
|
|
111
|
+
{
|
|
112
|
+
"name": "options",
|
|
113
|
+
"docs": "Query options including optional workout type filter, date range, limit, and sort order",
|
|
114
|
+
"type": "QueryWorkoutsOptions"
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"returns": "Promise<QueryWorkoutsResult>",
|
|
118
|
+
"tags": [
|
|
119
|
+
{
|
|
120
|
+
"name": "param",
|
|
121
|
+
"text": "options Query options including optional workout type filter, date range, limit, and sort order"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "returns",
|
|
125
|
+
"text": "A promise that resolves with the workout sessions"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "throws",
|
|
129
|
+
"text": "An error if something went wrong"
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"docs": "Queries workout sessions from the native health store on Android (Health Connect).",
|
|
133
|
+
"complexTypes": [
|
|
134
|
+
"QueryWorkoutsResult",
|
|
135
|
+
"QueryWorkoutsOptions"
|
|
136
|
+
],
|
|
137
|
+
"slug": "queryworkouts"
|
|
138
|
+
},
|
|
107
139
|
{
|
|
108
140
|
"name": "querySleep",
|
|
109
141
|
"signature": "(options: QuerySleepOptions) => Promise<QuerySleepResult>",
|
|
@@ -261,6 +293,132 @@
|
|
|
261
293
|
}
|
|
262
294
|
]
|
|
263
295
|
},
|
|
296
|
+
{
|
|
297
|
+
"name": "QueryWorkoutsResult",
|
|
298
|
+
"slug": "queryworkoutsresult",
|
|
299
|
+
"docs": "",
|
|
300
|
+
"tags": [],
|
|
301
|
+
"methods": [],
|
|
302
|
+
"properties": [
|
|
303
|
+
{
|
|
304
|
+
"name": "workouts",
|
|
305
|
+
"tags": [],
|
|
306
|
+
"docs": "",
|
|
307
|
+
"complexTypes": [
|
|
308
|
+
"Workout"
|
|
309
|
+
],
|
|
310
|
+
"type": "Workout[]"
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"name": "Workout",
|
|
316
|
+
"slug": "workout",
|
|
317
|
+
"docs": "",
|
|
318
|
+
"tags": [],
|
|
319
|
+
"methods": [],
|
|
320
|
+
"properties": [
|
|
321
|
+
{
|
|
322
|
+
"name": "workoutType",
|
|
323
|
+
"tags": [],
|
|
324
|
+
"docs": "The type of workout.",
|
|
325
|
+
"complexTypes": [
|
|
326
|
+
"WorkoutType"
|
|
327
|
+
],
|
|
328
|
+
"type": "WorkoutType"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "duration",
|
|
332
|
+
"tags": [],
|
|
333
|
+
"docs": "Duration of the workout in seconds.",
|
|
334
|
+
"complexTypes": [],
|
|
335
|
+
"type": "number"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"name": "startDate",
|
|
339
|
+
"tags": [],
|
|
340
|
+
"docs": "ISO 8601 start date of the workout.",
|
|
341
|
+
"complexTypes": [],
|
|
342
|
+
"type": "string"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
"name": "endDate",
|
|
346
|
+
"tags": [],
|
|
347
|
+
"docs": "ISO 8601 end date of the workout.",
|
|
348
|
+
"complexTypes": [],
|
|
349
|
+
"type": "string"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"name": "sourceName",
|
|
353
|
+
"tags": [],
|
|
354
|
+
"docs": "Source name that recorded the workout.",
|
|
355
|
+
"complexTypes": [],
|
|
356
|
+
"type": "string | undefined"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"name": "sourceId",
|
|
360
|
+
"tags": [],
|
|
361
|
+
"docs": "Source bundle identifier.",
|
|
362
|
+
"complexTypes": [],
|
|
363
|
+
"type": "string | undefined"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"name": "metadata",
|
|
367
|
+
"tags": [],
|
|
368
|
+
"docs": "Additional metadata (if available).",
|
|
369
|
+
"complexTypes": [
|
|
370
|
+
"Record"
|
|
371
|
+
],
|
|
372
|
+
"type": "Record<string, string>"
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "QueryWorkoutsOptions",
|
|
378
|
+
"slug": "queryworkoutsoptions",
|
|
379
|
+
"docs": "",
|
|
380
|
+
"tags": [],
|
|
381
|
+
"methods": [],
|
|
382
|
+
"properties": [
|
|
383
|
+
{
|
|
384
|
+
"name": "workoutType",
|
|
385
|
+
"tags": [],
|
|
386
|
+
"docs": "Optional workout type filter. If omitted, all workout types are returned.",
|
|
387
|
+
"complexTypes": [
|
|
388
|
+
"WorkoutType"
|
|
389
|
+
],
|
|
390
|
+
"type": "WorkoutType"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "startDate",
|
|
394
|
+
"tags": [],
|
|
395
|
+
"docs": "Inclusive ISO 8601 start date (defaults to now - 1 day).",
|
|
396
|
+
"complexTypes": [],
|
|
397
|
+
"type": "string | undefined"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"name": "endDate",
|
|
401
|
+
"tags": [],
|
|
402
|
+
"docs": "Exclusive ISO 8601 end date (defaults to now).",
|
|
403
|
+
"complexTypes": [],
|
|
404
|
+
"type": "string | undefined"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"name": "limit",
|
|
408
|
+
"tags": [],
|
|
409
|
+
"docs": "Maximum number of workouts to return (defaults to 100).",
|
|
410
|
+
"complexTypes": [],
|
|
411
|
+
"type": "number | undefined"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"name": "ascending",
|
|
415
|
+
"tags": [],
|
|
416
|
+
"docs": "Return results sorted ascending by start date (defaults to false).",
|
|
417
|
+
"complexTypes": [],
|
|
418
|
+
"type": "boolean | undefined"
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
},
|
|
264
422
|
{
|
|
265
423
|
"name": "QuerySleepResult",
|
|
266
424
|
"slug": "querysleepresult",
|
|
@@ -531,8 +689,12 @@
|
|
|
531
689
|
{
|
|
532
690
|
"name": "ReadAuthorizationType",
|
|
533
691
|
"slug": "readauthorizationtype",
|
|
534
|
-
"docs": "Data types that can be requested for read authorization.\nIncludes 'sleep' for querying sleep sessions via querySleep().\nIncludes 'hydration' for querying hydration records via queryHydration().",
|
|
692
|
+
"docs": "Data types that can be requested for read authorization.\nIncludes 'workouts' for querying workout sessions via queryWorkouts().\nIncludes 'sleep' for querying sleep sessions via querySleep().\nIncludes 'hydration' for querying hydration records via queryHydration().",
|
|
535
693
|
"types": [
|
|
694
|
+
{
|
|
695
|
+
"text": "'workouts'",
|
|
696
|
+
"complexTypes": []
|
|
697
|
+
},
|
|
536
698
|
{
|
|
537
699
|
"text": "'sleep'",
|
|
538
700
|
"complexTypes": []
|
|
@@ -544,40 +706,96 @@
|
|
|
544
706
|
]
|
|
545
707
|
},
|
|
546
708
|
{
|
|
547
|
-
"name": "
|
|
548
|
-
"slug": "
|
|
709
|
+
"name": "WorkoutType",
|
|
710
|
+
"slug": "workouttype",
|
|
549
711
|
"docs": "",
|
|
550
712
|
"types": [
|
|
551
713
|
{
|
|
552
|
-
"text": "'
|
|
714
|
+
"text": "'running'",
|
|
553
715
|
"complexTypes": []
|
|
554
716
|
},
|
|
555
717
|
{
|
|
556
|
-
"text": "'
|
|
718
|
+
"text": "'cycling'",
|
|
557
719
|
"complexTypes": []
|
|
558
720
|
},
|
|
559
721
|
{
|
|
560
|
-
"text": "'
|
|
722
|
+
"text": "'walking'",
|
|
561
723
|
"complexTypes": []
|
|
562
724
|
},
|
|
563
725
|
{
|
|
564
|
-
"text": "'
|
|
726
|
+
"text": "'swimming'",
|
|
565
727
|
"complexTypes": []
|
|
566
728
|
},
|
|
567
729
|
{
|
|
568
|
-
"text": "'
|
|
730
|
+
"text": "'yoga'",
|
|
569
731
|
"complexTypes": []
|
|
570
732
|
},
|
|
571
733
|
{
|
|
572
|
-
"text": "'
|
|
734
|
+
"text": "'strengthTraining'",
|
|
573
735
|
"complexTypes": []
|
|
574
736
|
},
|
|
575
737
|
{
|
|
576
|
-
"text": "'
|
|
738
|
+
"text": "'hiking'",
|
|
577
739
|
"complexTypes": []
|
|
578
740
|
},
|
|
579
741
|
{
|
|
580
|
-
"text": "'
|
|
742
|
+
"text": "'tennis'",
|
|
743
|
+
"complexTypes": []
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
"text": "'basketball'",
|
|
747
|
+
"complexTypes": []
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
"text": "'soccer'",
|
|
751
|
+
"complexTypes": []
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
"text": "'americanFootball'",
|
|
755
|
+
"complexTypes": []
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"text": "'baseball'",
|
|
759
|
+
"complexTypes": []
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
"text": "'crossTraining'",
|
|
763
|
+
"complexTypes": []
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"text": "'elliptical'",
|
|
767
|
+
"complexTypes": []
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
"text": "'rowing'",
|
|
771
|
+
"complexTypes": []
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
"text": "'stairClimbing'",
|
|
775
|
+
"complexTypes": []
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
"text": "'traditionalStrengthTraining'",
|
|
779
|
+
"complexTypes": []
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"text": "'waterFitness'",
|
|
783
|
+
"complexTypes": []
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"text": "'waterPolo'",
|
|
787
|
+
"complexTypes": []
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
"text": "'waterSports'",
|
|
791
|
+
"complexTypes": []
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
"text": "'wrestling'",
|
|
795
|
+
"complexTypes": []
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
"text": "'other'",
|
|
581
799
|
"complexTypes": []
|
|
582
800
|
}
|
|
583
801
|
]
|
|
@@ -595,6 +813,45 @@
|
|
|
595
813
|
]
|
|
596
814
|
}
|
|
597
815
|
]
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"name": "SleepStage",
|
|
819
|
+
"slug": "sleepstage",
|
|
820
|
+
"docs": "",
|
|
821
|
+
"types": [
|
|
822
|
+
{
|
|
823
|
+
"text": "'unknown'",
|
|
824
|
+
"complexTypes": []
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
"text": "'awake'",
|
|
828
|
+
"complexTypes": []
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
"text": "'sleeping'",
|
|
832
|
+
"complexTypes": []
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
"text": "'outOfBed'",
|
|
836
|
+
"complexTypes": []
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
"text": "'awakeInBed'",
|
|
840
|
+
"complexTypes": []
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
"text": "'light'",
|
|
844
|
+
"complexTypes": []
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
"text": "'deep'",
|
|
848
|
+
"complexTypes": []
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"text": "'rem'",
|
|
852
|
+
"complexTypes": []
|
|
853
|
+
}
|
|
854
|
+
]
|
|
598
855
|
}
|
|
599
856
|
],
|
|
600
857
|
"pluginConfigs": []
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Data types that can be requested for read authorization.
|
|
3
|
+
* Includes 'workouts' for querying workout sessions via queryWorkouts().
|
|
3
4
|
* Includes 'sleep' for querying sleep sessions via querySleep().
|
|
4
5
|
* Includes 'hydration' for querying hydration records via queryHydration().
|
|
5
6
|
*/
|
|
6
|
-
export type ReadAuthorizationType = 'sleep' | 'hydration';
|
|
7
|
+
export type ReadAuthorizationType = 'workouts' | 'sleep' | 'hydration';
|
|
8
|
+
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';
|
|
7
9
|
export interface AuthorizationOptions {
|
|
8
10
|
/**
|
|
9
11
|
* Data types that should be readable after authorization.
|
|
@@ -27,6 +29,37 @@ export interface AvailabilityResult {
|
|
|
27
29
|
reason?: string;
|
|
28
30
|
}
|
|
29
31
|
export type SleepStage = 'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem';
|
|
32
|
+
export interface QueryWorkoutsOptions {
|
|
33
|
+
/** Optional workout type filter. If omitted, all workout types are returned. */
|
|
34
|
+
workoutType?: WorkoutType;
|
|
35
|
+
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
|
|
36
|
+
startDate?: string;
|
|
37
|
+
/** Exclusive ISO 8601 end date (defaults to now). */
|
|
38
|
+
endDate?: string;
|
|
39
|
+
/** Maximum number of workouts to return (defaults to 100). */
|
|
40
|
+
limit?: number;
|
|
41
|
+
/** Return results sorted ascending by start date (defaults to false). */
|
|
42
|
+
ascending?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface Workout {
|
|
45
|
+
/** The type of workout. */
|
|
46
|
+
workoutType: WorkoutType;
|
|
47
|
+
/** Duration of the workout in seconds. */
|
|
48
|
+
duration: number;
|
|
49
|
+
/** ISO 8601 start date of the workout. */
|
|
50
|
+
startDate: string;
|
|
51
|
+
/** ISO 8601 end date of the workout. */
|
|
52
|
+
endDate: string;
|
|
53
|
+
/** Source name that recorded the workout. */
|
|
54
|
+
sourceName?: string;
|
|
55
|
+
/** Source bundle identifier. */
|
|
56
|
+
sourceId?: string;
|
|
57
|
+
/** Additional metadata (if available). */
|
|
58
|
+
metadata?: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
export interface QueryWorkoutsResult {
|
|
61
|
+
workouts: Workout[];
|
|
62
|
+
}
|
|
30
63
|
export interface QuerySleepOptions {
|
|
31
64
|
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
|
|
32
65
|
startDate?: string;
|
|
@@ -131,6 +164,14 @@ export interface HealthPlugin {
|
|
|
131
164
|
* @throws An error if the privacy policy cannot be displayed
|
|
132
165
|
*/
|
|
133
166
|
showPrivacyPolicy(): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Queries workout sessions from the native health store on Android (Health Connect).
|
|
169
|
+
*
|
|
170
|
+
* @param options Query options including optional workout type filter, date range, limit, and sort order
|
|
171
|
+
* @returns A promise that resolves with the workout sessions
|
|
172
|
+
* @throws An error if something went wrong
|
|
173
|
+
*/
|
|
174
|
+
queryWorkouts(options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
|
|
134
175
|
/**
|
|
135
176
|
* Queries sleep sessions from the native health store on Android (Health Connect).
|
|
136
177
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Data types that can be requested for read authorization.\n * Includes 'sleep' for querying sleep sessions via querySleep().\n * Includes 'hydration' for querying hydration records via queryHydration().\n */\nexport type ReadAuthorizationType = 'sleep' | 'hydration';\n\nexport interface AuthorizationOptions {\n /**\n * Data types that should be readable after authorization.\n */\n read?: ReadAuthorizationType[];\n}\n\nexport interface AuthorizationStatus {\n /** Data types that are authorized for reading */\n readAuthorized: ReadAuthorizationType[];\n /** Data types that are denied for reading */\n readDenied: ReadAuthorizationType[];\n /** Data types that are authorized for writing (always empty) */\n writeAuthorized: [];\n /** Data types that are denied for writing (always empty) */\n writeDenied: [];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'android' | 'web';\n reason?: string;\n}\n\nexport type SleepStage = 'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem';\n\nexport interface QuerySleepOptions {\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 sleep sessions 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 interface SleepStageRecord {\n /** The sleep stage type. */\n stage: SleepStage;\n /** ISO 8601 start date of this sleep stage. */\n startDate: string;\n /** ISO 8601 end date of this sleep stage. */\n endDate: string;\n}\n\nexport interface SleepSession {\n /** Title/name of the sleep session (if available). */\n title?: string;\n /** Duration of the sleep session in seconds. */\n duration: number;\n /** ISO 8601 start date of the sleep session. */\n startDate: string;\n /** ISO 8601 end date of the sleep session. */\n endDate: string;\n /** Array of sleep stages during the session (if available). */\n stages?: SleepStageRecord[];\n /** Source name that recorded the sleep session. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QuerySleepResult {\n sleepSessions: SleepSession[];\n}\n\nexport interface QueryHydrationOptions {\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 hydration records 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 interface HydrationRecord {\n /** Volume of water consumed in liters. */\n volume: number;\n /** ISO 8601 start date of the hydration record. */\n startDate: string;\n /** ISO 8601 end date of the hydration record. */\n endDate: string;\n /** Source name that recorded the hydration. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QueryHydrationResult {\n hydrationRecords: HydrationRecord[];\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\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.\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.\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 sleep sessions from the native health store on Android (Health Connect).\n *\n * @param options Query options including date range, limit, and sort order\n * @returns A promise that resolves with the sleep sessions\n * @throws An error if something went wrong\n */\n querySleep(options: QuerySleepOptions): Promise<QuerySleepResult>;\n\n /**\n * Queries hydration records from the native health store on Android (Health Connect).\n *\n * @param options Query options including date range, limit, and sort order\n * @returns A promise that resolves with the hydration records\n * @throws An error if something went wrong\n */\n queryHydration(options: QueryHydrationOptions): Promise<QueryHydrationResult>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Data types that can be requested for read authorization.\n * Includes 'workouts' for querying workout sessions via queryWorkouts().\n * Includes 'sleep' for querying sleep sessions via querySleep().\n * Includes 'hydration' for querying hydration records via queryHydration().\n */\nexport type ReadAuthorizationType = 'workouts' | 'sleep' | 'hydration';\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 AuthorizationOptions {\n /**\n * Data types that should be readable after authorization.\n */\n read?: ReadAuthorizationType[];\n}\n\nexport interface AuthorizationStatus {\n /** Data types that are authorized for reading */\n readAuthorized: ReadAuthorizationType[];\n /** Data types that are denied for reading */\n readDenied: ReadAuthorizationType[];\n /** Data types that are authorized for writing (always empty) */\n writeAuthorized: [];\n /** Data types that are denied for writing (always empty) */\n writeDenied: [];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'android' | 'web';\n reason?: string;\n}\n\nexport type SleepStage = 'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem';\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\nexport interface Workout {\n /** The type of workout. */\n workoutType: WorkoutType;\n /** Duration of the workout in seconds. */\n duration: 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\nexport interface QuerySleepOptions {\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 sleep sessions 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 interface SleepStageRecord {\n /** The sleep stage type. */\n stage: SleepStage;\n /** ISO 8601 start date of this sleep stage. */\n startDate: string;\n /** ISO 8601 end date of this sleep stage. */\n endDate: string;\n}\n\nexport interface SleepSession {\n /** Title/name of the sleep session (if available). */\n title?: string;\n /** Duration of the sleep session in seconds. */\n duration: number;\n /** ISO 8601 start date of the sleep session. */\n startDate: string;\n /** ISO 8601 end date of the sleep session. */\n endDate: string;\n /** Array of sleep stages during the session (if available). */\n stages?: SleepStageRecord[];\n /** Source name that recorded the sleep session. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QuerySleepResult {\n sleepSessions: SleepSession[];\n}\n\nexport interface QueryHydrationOptions {\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 hydration records 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 interface HydrationRecord {\n /** Volume of water consumed in liters. */\n volume: number;\n /** ISO 8601 start date of the hydration record. */\n startDate: string;\n /** ISO 8601 end date of the hydration record. */\n endDate: string;\n /** Source name that recorded the hydration. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QueryHydrationResult {\n hydrationRecords: HydrationRecord[];\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\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.\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.\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 on 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 sleep sessions from the native health store on Android (Health Connect).\n *\n * @param options Query options including date range, limit, and sort order\n * @returns A promise that resolves with the sleep sessions\n * @throws An error if something went wrong\n */\n querySleep(options: QuerySleepOptions): Promise<QuerySleepResult>;\n\n /**\n * Queries hydration records from the native health store on Android (Health Connect).\n *\n * @param options Query options including date range, limit, and sort order\n * @returns A promise that resolves with the hydration records\n * @throws An error if something went wrong\n */\n queryHydration(options: QueryHydrationOptions): Promise<QueryHydrationResult>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { AuthorizationOptions, AuthorizationStatus, AvailabilityResult, HealthPlugin, QueryHydrationOptions, QueryHydrationResult, QuerySleepOptions, QuerySleepResult } from './definitions';
|
|
2
|
+
import type { AuthorizationOptions, AuthorizationStatus, AvailabilityResult, HealthPlugin, QueryHydrationOptions, QueryHydrationResult, QuerySleepOptions, QuerySleepResult, QueryWorkoutsOptions, QueryWorkoutsResult } from './definitions';
|
|
3
3
|
export declare class HealthWeb extends WebPlugin implements HealthPlugin {
|
|
4
4
|
isAvailable(): Promise<AvailabilityResult>;
|
|
5
5
|
requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
@@ -9,6 +9,7 @@ export declare class HealthWeb extends WebPlugin implements HealthPlugin {
|
|
|
9
9
|
}>;
|
|
10
10
|
openHealthConnectSettings(): Promise<void>;
|
|
11
11
|
showPrivacyPolicy(): Promise<void>;
|
|
12
|
+
queryWorkouts(_options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
|
|
12
13
|
querySleep(_options: QuerySleepOptions): Promise<QuerySleepResult>;
|
|
13
14
|
queryHydration(_options: QueryHydrationOptions): Promise<QueryHydrationResult>;
|
|
14
15
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -22,6 +22,9 @@ export class HealthWeb extends WebPlugin {
|
|
|
22
22
|
async showPrivacyPolicy() {
|
|
23
23
|
// No-op on web - Health Connect privacy policy is Android only
|
|
24
24
|
}
|
|
25
|
+
async queryWorkouts(_options) {
|
|
26
|
+
throw this.unimplemented('Querying workouts is only available on native platforms.');
|
|
27
|
+
}
|
|
25
28
|
async querySleep(_options) {
|
|
26
29
|
throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
|
|
27
30
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,WAAW;QACf,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iEAAiE;SAC1E,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAA8B;QACvD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA8B;QACrD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,yBAAyB;QAC7B,gDAAgD;IAClD,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,+DAA+D;IACjE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,QAA8B;QAChD,MAAM,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAAC;IACvF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA2B;QAC1C,MAAM,IAAI,CAAC,aAAa,CAAC,gEAAgE,CAAC,CAAC;IAC7F,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAA+B;QAClD,MAAM,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\n QueryHydrationOptions,\n QueryHydrationResult,\n QuerySleepOptions,\n QuerySleepResult,\n QueryWorkoutsOptions,\n QueryWorkoutsResult,\n} from './definitions';\n\nexport class HealthWeb extends WebPlugin implements HealthPlugin {\n async isAvailable(): Promise<AvailabilityResult> {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n\n async requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openHealthConnectSettings(): Promise<void> {\n // No-op on web - Health Connect is Android only\n }\n\n async showPrivacyPolicy(): Promise<void> {\n // No-op on web - Health Connect privacy policy is Android only\n }\n\n async queryWorkouts(_options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult> {\n throw this.unimplemented('Querying workouts is only available on native platforms.');\n }\n\n async querySleep(_options: QuerySleepOptions): Promise<QuerySleepResult> {\n throw this.unimplemented('Querying sleep sessions is only available on native platforms.');\n }\n\n async queryHydration(_options: QueryHydrationOptions): Promise<QueryHydrationResult> {\n throw this.unimplemented('Querying hydration records is only available on native platforms.');\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -29,6 +29,9 @@ class HealthWeb extends core.WebPlugin {
|
|
|
29
29
|
async showPrivacyPolicy() {
|
|
30
30
|
// No-op on web - Health Connect privacy policy is Android only
|
|
31
31
|
}
|
|
32
|
+
async queryWorkouts(_options) {
|
|
33
|
+
throw this.unimplemented('Querying workouts is only available on native platforms.');
|
|
34
|
+
}
|
|
32
35
|
async querySleep(_options) {
|
|
33
36
|
throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
|
|
34
37
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n async querySleep(_options) {\n throw this.unimplemented('Querying sleep sessions is only available on native platforms.');\n }\n async queryHydration(_options) {\n throw this.unimplemented('Querying hydration records is only available on native platforms.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,KAAK;AAC5B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,MAAM,EAAE,iEAAiE;AACrF,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;AACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,yBAAyB,GAAG;AACtC;AACA,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B;AACA,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gEAAgE,CAAC;AAClG,IAAI;AACJ,IAAI,MAAM,cAAc,CAAC,QAAQ,EAAE;AACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC;AACrG,IAAI;AACJ;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n async queryWorkouts(_options) {\n throw this.unimplemented('Querying workouts is only available on native platforms.');\n }\n async querySleep(_options) {\n throw this.unimplemented('Querying sleep sessions is only available on native platforms.');\n }\n async queryHydration(_options) {\n throw this.unimplemented('Querying hydration records is only available on native platforms.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,KAAK;AAC5B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,MAAM,EAAE,iEAAiE;AACrF,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;AACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,yBAAyB,GAAG;AACtC;AACA,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B;AACA,IAAI;AACJ,IAAI,MAAM,aAAa,CAAC,QAAQ,EAAE;AAClC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC;AAC5F,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gEAAgE,CAAC;AAClG,IAAI;AACJ,IAAI,MAAM,cAAc,CAAC,QAAQ,EAAE;AACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC;AACrG,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -28,6 +28,9 @@ var capacitorHealth = (function (exports, core) {
|
|
|
28
28
|
async showPrivacyPolicy() {
|
|
29
29
|
// No-op on web - Health Connect privacy policy is Android only
|
|
30
30
|
}
|
|
31
|
+
async queryWorkouts(_options) {
|
|
32
|
+
throw this.unimplemented('Querying workouts is only available on native platforms.');
|
|
33
|
+
}
|
|
31
34
|
async querySleep(_options) {
|
|
32
35
|
throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
|
|
33
36
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n async querySleep(_options) {\n throw this.unimplemented('Querying sleep sessions is only available on native platforms.');\n }\n async queryHydration(_options) {\n throw this.unimplemented('Querying hydration records is only available on native platforms.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO;IACf,YAAY,SAAS,EAAE,KAAK;IAC5B,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,MAAM,EAAE,iEAAiE;IACrF,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;IACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,yBAAyB,GAAG;IACtC;IACA,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B;IACA,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gEAAgE,CAAC;IAClG,IAAI;IACJ,IAAI,MAAM,cAAc,CAAC,QAAQ,EAAE;IACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC;IACrG,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n async queryWorkouts(_options) {\n throw this.unimplemented('Querying workouts is only available on native platforms.');\n }\n async querySleep(_options) {\n throw this.unimplemented('Querying sleep sessions is only available on native platforms.');\n }\n async queryHydration(_options) {\n throw this.unimplemented('Querying hydration records is only available on native platforms.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO;IACf,YAAY,SAAS,EAAE,KAAK;IAC5B,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,MAAM,EAAE,iEAAiE;IACrF,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;IACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,yBAAyB,GAAG;IACtC;IACA,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B;IACA,IAAI;IACJ,IAAI,MAAM,aAAa,CAAC,QAAQ,EAAE;IAClC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC;IAC5F,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gEAAgE,CAAC;IAClG,IAAI;IACJ,IAAI,MAAM,cAAc,CAAC,QAAQ,EAAE;IACnC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC;IACrG,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED