@asiriindatissa/capacitor-health 8.4.3 → 8.4.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 +49 -1
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthManager.kt +99 -2
- package/android/src/main/java/app/capgo/plugin/health/HealthPlugin.kt +98 -22
- package/dist/docs.json +145 -1
- package/dist/esm/definitions.d.ts +37 -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
|
@@ -222,6 +222,7 @@ const { sleepSessions } = await Health.querySleep({
|
|
|
222
222
|
* [`showPrivacyPolicy()`](#showprivacypolicy)
|
|
223
223
|
* [`queryWorkouts(...)`](#queryworkouts)
|
|
224
224
|
* [`querySleep(...)`](#querysleep)
|
|
225
|
+
* [`queryHydration(...)`](#queryhydration)
|
|
225
226
|
* [Interfaces](#interfaces)
|
|
226
227
|
* [Type Aliases](#type-aliases)
|
|
227
228
|
|
|
@@ -388,6 +389,23 @@ Queries sleep sessions from the native health store on Android (Health Connect).
|
|
|
388
389
|
--------------------
|
|
389
390
|
|
|
390
391
|
|
|
392
|
+
### queryHydration(...)
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
queryHydration(options: QueryHydrationOptions) => Promise<QueryHydrationResult>
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Queries hydration records from the native health store on Android (Health Connect).
|
|
399
|
+
|
|
400
|
+
| Param | Type | Description |
|
|
401
|
+
| ------------- | ----------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
402
|
+
| **`options`** | <code><a href="#queryhydrationoptions">QueryHydrationOptions</a></code> | Query options including date range, limit, and sort order |
|
|
403
|
+
|
|
404
|
+
**Returns:** <code>Promise<<a href="#queryhydrationresult">QueryHydrationResult</a>></code>
|
|
405
|
+
|
|
406
|
+
--------------------
|
|
407
|
+
|
|
408
|
+
|
|
391
409
|
### Interfaces
|
|
392
410
|
|
|
393
411
|
|
|
@@ -534,6 +552,35 @@ Queries sleep sessions from the native health store on Android (Health Connect).
|
|
|
534
552
|
| **`ascending`** | <code>boolean</code> | Return results sorted ascending by start date (defaults to false). |
|
|
535
553
|
|
|
536
554
|
|
|
555
|
+
#### QueryHydrationResult
|
|
556
|
+
|
|
557
|
+
| Prop | Type |
|
|
558
|
+
| ---------------------- | ------------------------------ |
|
|
559
|
+
| **`hydrationRecords`** | <code>HydrationRecord[]</code> |
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
#### HydrationRecord
|
|
563
|
+
|
|
564
|
+
| Prop | Type | Description |
|
|
565
|
+
| ---------------- | --------------------------------------------------------------- | -------------------------------------------- |
|
|
566
|
+
| **`volume`** | <code>number</code> | Volume of water consumed in liters. |
|
|
567
|
+
| **`startDate`** | <code>string</code> | ISO 8601 start date of the hydration record. |
|
|
568
|
+
| **`endDate`** | <code>string</code> | ISO 8601 end date of the hydration record. |
|
|
569
|
+
| **`sourceName`** | <code>string</code> | Source name that recorded the hydration. |
|
|
570
|
+
| **`sourceId`** | <code>string</code> | Source bundle identifier. |
|
|
571
|
+
| **`metadata`** | <code><a href="#record">Record</a><string, string></code> | Additional metadata (if available). |
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
#### QueryHydrationOptions
|
|
575
|
+
|
|
576
|
+
| Prop | Type | Description |
|
|
577
|
+
| --------------- | -------------------- | ------------------------------------------------------------------ |
|
|
578
|
+
| **`startDate`** | <code>string</code> | Inclusive ISO 8601 start date (defaults to now - 1 day). |
|
|
579
|
+
| **`endDate`** | <code>string</code> | Exclusive ISO 8601 end date (defaults to now). |
|
|
580
|
+
| **`limit`** | <code>number</code> | Maximum number of hydration records to return (defaults to 100). |
|
|
581
|
+
| **`ascending`** | <code>boolean</code> | Return results sorted ascending by start date (defaults to false). |
|
|
582
|
+
|
|
583
|
+
|
|
537
584
|
### Type Aliases
|
|
538
585
|
|
|
539
586
|
|
|
@@ -542,8 +589,9 @@ Queries sleep sessions from the native health store on Android (Health Connect).
|
|
|
542
589
|
Data types that can be requested for read authorization.
|
|
543
590
|
Includes 'workouts' for querying workout sessions via queryWorkouts().
|
|
544
591
|
Includes 'sleep' for querying sleep sessions via querySleep().
|
|
592
|
+
Includes 'hydration' for querying hydration records via queryHydration().
|
|
545
593
|
|
|
546
|
-
<code><a href="#healthdatatype">HealthDataType</a> | 'workouts' | 'sleep'</code>
|
|
594
|
+
<code><a href="#healthdatatype">HealthDataType</a> | 'workouts' | 'sleep' | 'hydration'</code>
|
|
547
595
|
|
|
548
596
|
|
|
549
597
|
#### HealthDataType
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
<uses-permission android:name="android.permission.health.READ_EXERCISE" />
|
|
16
16
|
<uses-permission android:name="android.permission.health.READ_SLEEP" />
|
|
17
17
|
<uses-permission android:name="android.permission.health.WRITE_SLEEP" />
|
|
18
|
+
<uses-permission android:name="android.permission.health.READ_HYDRATION" />
|
|
19
|
+
<uses-permission android:name="android.permission.health.WRITE_HYDRATION" />
|
|
18
20
|
|
|
19
21
|
<!-- Query for Health Connect availability -->
|
|
20
22
|
<queries>
|
|
@@ -8,6 +8,7 @@ import androidx.health.connect.client.records.DistanceRecord
|
|
|
8
8
|
import androidx.health.connect.client.records.ExerciseSessionRecord
|
|
9
9
|
import androidx.health.connect.client.records.HeartRateRecord
|
|
10
10
|
import androidx.health.connect.client.records.HeightRecord
|
|
11
|
+
import androidx.health.connect.client.records.HydrationRecord
|
|
11
12
|
import androidx.health.connect.client.records.Record
|
|
12
13
|
import androidx.health.connect.client.records.SleepSessionRecord
|
|
13
14
|
import androidx.health.connect.client.records.StepsRecord
|
|
@@ -18,6 +19,7 @@ import androidx.health.connect.client.time.TimeRangeFilter
|
|
|
18
19
|
import androidx.health.connect.client.units.Energy
|
|
19
20
|
import androidx.health.connect.client.units.Length
|
|
20
21
|
import androidx.health.connect.client.units.Mass
|
|
22
|
+
import androidx.health.connect.client.units.Volume
|
|
21
23
|
import androidx.health.connect.client.records.metadata.Metadata
|
|
22
24
|
import java.time.Duration
|
|
23
25
|
import com.getcapacitor.JSArray
|
|
@@ -33,7 +35,7 @@ class HealthManager {
|
|
|
33
35
|
|
|
34
36
|
private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_INSTANT
|
|
35
37
|
|
|
36
|
-
fun permissionsFor(readTypes: Collection<HealthDataType>, writeTypes: Collection<HealthDataType>, includeWorkouts: Boolean = false, includeSleep: Boolean = false): Set<String> = buildSet {
|
|
38
|
+
fun permissionsFor(readTypes: Collection<HealthDataType>, writeTypes: Collection<HealthDataType>, includeWorkouts: Boolean = false, includeSleep: Boolean = false, includeHydration: Boolean = false): Set<String> = buildSet {
|
|
37
39
|
readTypes.forEach { add(it.readPermission) }
|
|
38
40
|
writeTypes.forEach { add(it.writePermission) }
|
|
39
41
|
// Include workout read permission if explicitly requested
|
|
@@ -44,6 +46,10 @@ class HealthManager {
|
|
|
44
46
|
if (includeSleep) {
|
|
45
47
|
add(HealthPermission.getReadPermission(SleepSessionRecord::class))
|
|
46
48
|
}
|
|
49
|
+
// Include hydration read permission if explicitly requested
|
|
50
|
+
if (includeHydration) {
|
|
51
|
+
add(HealthPermission.getReadPermission(HydrationRecord::class))
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
suspend fun authorizationStatus(
|
|
@@ -51,7 +57,8 @@ class HealthManager {
|
|
|
51
57
|
readTypes: Collection<HealthDataType>,
|
|
52
58
|
writeTypes: Collection<HealthDataType>,
|
|
53
59
|
includeWorkouts: Boolean = false,
|
|
54
|
-
includeSleep: Boolean = false
|
|
60
|
+
includeSleep: Boolean = false,
|
|
61
|
+
includeHydration: Boolean = false
|
|
55
62
|
): JSObject {
|
|
56
63
|
val granted = client.permissionController.getGrantedPermissions()
|
|
57
64
|
|
|
@@ -85,6 +92,16 @@ class HealthManager {
|
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
94
|
|
|
95
|
+
// Check hydration permission if requested
|
|
96
|
+
if (includeHydration) {
|
|
97
|
+
val hydrationPermission = HealthPermission.getReadPermission(HydrationRecord::class)
|
|
98
|
+
if (granted.contains(hydrationPermission)) {
|
|
99
|
+
readAuthorized.put("hydration")
|
|
100
|
+
} else {
|
|
101
|
+
readDenied.put("hydration")
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
val writeAuthorized = JSArray()
|
|
89
106
|
val writeDenied = JSArray()
|
|
90
107
|
writeTypes.forEach { type ->
|
|
@@ -619,6 +636,86 @@ class HealthManager {
|
|
|
619
636
|
}
|
|
620
637
|
}
|
|
621
638
|
|
|
639
|
+
suspend fun queryHydration(
|
|
640
|
+
client: HealthConnectClient,
|
|
641
|
+
startTime: Instant,
|
|
642
|
+
endTime: Instant,
|
|
643
|
+
limit: Int,
|
|
644
|
+
ascending: Boolean
|
|
645
|
+
): JSArray {
|
|
646
|
+
val hydrationRecords = mutableListOf<Pair<Instant, JSObject>>()
|
|
647
|
+
|
|
648
|
+
var pageToken: String? = null
|
|
649
|
+
val pageSize = if (limit > 0) min(limit, MAX_PAGE_SIZE) else DEFAULT_PAGE_SIZE
|
|
650
|
+
var fetched = 0
|
|
651
|
+
|
|
652
|
+
do {
|
|
653
|
+
val request = ReadRecordsRequest(
|
|
654
|
+
recordType = HydrationRecord::class,
|
|
655
|
+
timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
|
|
656
|
+
pageSize = pageSize,
|
|
657
|
+
pageToken = pageToken
|
|
658
|
+
)
|
|
659
|
+
val response = client.readRecords(request)
|
|
660
|
+
|
|
661
|
+
response.records.forEach { record ->
|
|
662
|
+
val hydration = record as HydrationRecord
|
|
663
|
+
val payload = createHydrationPayload(hydration)
|
|
664
|
+
hydrationRecords.add(hydration.startTime to payload)
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
fetched += response.records.size
|
|
668
|
+
pageToken = response.pageToken
|
|
669
|
+
} while (pageToken != null && (limit <= 0 || fetched < limit))
|
|
670
|
+
|
|
671
|
+
val sorted = hydrationRecords.sortedBy { it.first }
|
|
672
|
+
val ordered = if (ascending) sorted else sorted.asReversed()
|
|
673
|
+
val limited = if (limit > 0) ordered.take(limit) else ordered
|
|
674
|
+
|
|
675
|
+
val array = JSArray()
|
|
676
|
+
limited.forEach { array.put(it.second) }
|
|
677
|
+
return array
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
private fun createHydrationPayload(hydration: HydrationRecord): JSObject {
|
|
681
|
+
val payload = JSObject()
|
|
682
|
+
|
|
683
|
+
// Volume in liters
|
|
684
|
+
val volumeLiters = hydration.volume.inLiters
|
|
685
|
+
payload.put("volume", volumeLiters)
|
|
686
|
+
|
|
687
|
+
// Start and end dates
|
|
688
|
+
payload.put("startDate", formatter.format(hydration.startTime))
|
|
689
|
+
payload.put("endDate", formatter.format(hydration.endTime))
|
|
690
|
+
|
|
691
|
+
// Source information
|
|
692
|
+
val dataOrigin = hydration.metadata.dataOrigin
|
|
693
|
+
payload.put("sourceId", dataOrigin.packageName)
|
|
694
|
+
payload.put("sourceName", dataOrigin.packageName)
|
|
695
|
+
hydration.metadata.device?.let { device ->
|
|
696
|
+
val manufacturer = device.manufacturer?.takeIf { it.isNotBlank() }
|
|
697
|
+
val model = device.model?.takeIf { it.isNotBlank() }
|
|
698
|
+
val label = listOfNotNull(manufacturer, model).joinToString(" ").trim()
|
|
699
|
+
if (label.isNotEmpty()) {
|
|
700
|
+
payload.put("sourceName", label)
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// Metadata if available
|
|
705
|
+
if (hydration.metadata.clientRecordId != null || hydration.metadata.clientRecordVersion > 0) {
|
|
706
|
+
val metadataObj = JSObject()
|
|
707
|
+
hydration.metadata.clientRecordId?.let { metadataObj.put("clientRecordId", it) }
|
|
708
|
+
if (hydration.metadata.clientRecordVersion > 0) {
|
|
709
|
+
metadataObj.put("clientRecordVersion", hydration.metadata.clientRecordVersion)
|
|
710
|
+
}
|
|
711
|
+
if (metadataObj.length() > 0) {
|
|
712
|
+
payload.put("metadata", metadataObj)
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
return payload
|
|
717
|
+
}
|
|
718
|
+
|
|
622
719
|
companion object {
|
|
623
720
|
private const val DEFAULT_PAGE_SIZE = 100
|
|
624
721
|
private const val MAX_PAGE_SIZE = 500
|
|
@@ -22,6 +22,13 @@ import kotlinx.coroutines.SupervisorJob
|
|
|
22
22
|
import kotlinx.coroutines.cancel
|
|
23
23
|
import kotlinx.coroutines.launch
|
|
24
24
|
|
|
25
|
+
data class ReadAuthorizationTypes(
|
|
26
|
+
val dataTypes: List<HealthDataType>,
|
|
27
|
+
val includeWorkouts: Boolean,
|
|
28
|
+
val includeSleep: Boolean,
|
|
29
|
+
val includeHydration: Boolean
|
|
30
|
+
)
|
|
31
|
+
|
|
25
32
|
@CapacitorPlugin(name = "Health")
|
|
26
33
|
class HealthPlugin : Plugin() {
|
|
27
34
|
private val pluginVersion = "7.2.14"
|
|
@@ -34,6 +41,7 @@ class HealthPlugin : Plugin() {
|
|
|
34
41
|
private var pendingWriteTypes: List<HealthDataType> = emptyList()
|
|
35
42
|
private var pendingIncludeWorkouts: Boolean = false
|
|
36
43
|
private var pendingIncludeSleep: Boolean = false
|
|
44
|
+
private var pendingIncludeHydration: Boolean = false
|
|
37
45
|
|
|
38
46
|
override fun handleOnDestroy() {
|
|
39
47
|
super.handleOnDestroy()
|
|
@@ -48,8 +56,8 @@ class HealthPlugin : Plugin() {
|
|
|
48
56
|
|
|
49
57
|
@PluginMethod
|
|
50
58
|
fun requestAuthorization(call: PluginCall) {
|
|
51
|
-
val
|
|
52
|
-
|
|
59
|
+
val readAuth = try {
|
|
60
|
+
parseReadAuthorizationTypes(call, "read")
|
|
53
61
|
} catch (e: IllegalArgumentException) {
|
|
54
62
|
call.reject(e.message, null, e)
|
|
55
63
|
return
|
|
@@ -64,26 +72,47 @@ class HealthPlugin : Plugin() {
|
|
|
64
72
|
|
|
65
73
|
pluginScope.launch {
|
|
66
74
|
val client = getClientOrReject(call) ?: return@launch
|
|
67
|
-
val permissions = manager.permissionsFor(
|
|
75
|
+
val permissions = manager.permissionsFor(
|
|
76
|
+
readAuth.dataTypes,
|
|
77
|
+
writeTypes,
|
|
78
|
+
readAuth.includeWorkouts,
|
|
79
|
+
readAuth.includeSleep,
|
|
80
|
+
readAuth.includeHydration
|
|
81
|
+
)
|
|
68
82
|
|
|
69
83
|
if (permissions.isEmpty()) {
|
|
70
|
-
val status = manager.authorizationStatus(
|
|
84
|
+
val status = manager.authorizationStatus(
|
|
85
|
+
client,
|
|
86
|
+
readAuth.dataTypes,
|
|
87
|
+
writeTypes,
|
|
88
|
+
readAuth.includeWorkouts,
|
|
89
|
+
readAuth.includeSleep,
|
|
90
|
+
readAuth.includeHydration
|
|
91
|
+
)
|
|
71
92
|
call.resolve(status)
|
|
72
93
|
return@launch
|
|
73
94
|
}
|
|
74
95
|
|
|
75
96
|
val granted = client.permissionController.getGrantedPermissions()
|
|
76
97
|
if (granted.containsAll(permissions)) {
|
|
77
|
-
val status = manager.authorizationStatus(
|
|
98
|
+
val status = manager.authorizationStatus(
|
|
99
|
+
client,
|
|
100
|
+
readAuth.dataTypes,
|
|
101
|
+
writeTypes,
|
|
102
|
+
readAuth.includeWorkouts,
|
|
103
|
+
readAuth.includeSleep,
|
|
104
|
+
readAuth.includeHydration
|
|
105
|
+
)
|
|
78
106
|
call.resolve(status)
|
|
79
107
|
return@launch
|
|
80
108
|
}
|
|
81
109
|
|
|
82
110
|
// Store types for callback
|
|
83
|
-
pendingReadTypes =
|
|
111
|
+
pendingReadTypes = readAuth.dataTypes
|
|
84
112
|
pendingWriteTypes = writeTypes
|
|
85
|
-
pendingIncludeWorkouts = includeWorkouts
|
|
86
|
-
pendingIncludeSleep = includeSleep
|
|
113
|
+
pendingIncludeWorkouts = readAuth.includeWorkouts
|
|
114
|
+
pendingIncludeSleep = readAuth.includeSleep
|
|
115
|
+
pendingIncludeHydration = readAuth.includeHydration
|
|
87
116
|
|
|
88
117
|
// Create intent using the Health Connect permission contract
|
|
89
118
|
val intent = permissionContract.createIntent(context, permissions)
|
|
@@ -108,22 +137,24 @@ class HealthPlugin : Plugin() {
|
|
|
108
137
|
val writeTypes = pendingWriteTypes
|
|
109
138
|
val includeWorkouts = pendingIncludeWorkouts
|
|
110
139
|
val includeSleep = pendingIncludeSleep
|
|
140
|
+
val includeHydration = pendingIncludeHydration
|
|
111
141
|
pendingReadTypes = emptyList()
|
|
112
142
|
pendingWriteTypes = emptyList()
|
|
113
143
|
pendingIncludeWorkouts = false
|
|
114
144
|
pendingIncludeSleep = false
|
|
145
|
+
pendingIncludeHydration = false
|
|
115
146
|
|
|
116
147
|
pluginScope.launch {
|
|
117
148
|
val client = getClientOrReject(call) ?: return@launch
|
|
118
|
-
val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts, includeSleep)
|
|
149
|
+
val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts, includeSleep, includeHydration)
|
|
119
150
|
call.resolve(status)
|
|
120
151
|
}
|
|
121
152
|
}
|
|
122
153
|
|
|
123
154
|
@PluginMethod
|
|
124
155
|
fun checkAuthorization(call: PluginCall) {
|
|
125
|
-
val
|
|
126
|
-
|
|
156
|
+
val readAuth = try {
|
|
157
|
+
parseReadAuthorizationTypes(call, "read")
|
|
127
158
|
} catch (e: IllegalArgumentException) {
|
|
128
159
|
call.reject(e.message, null, e)
|
|
129
160
|
return
|
|
@@ -138,7 +169,14 @@ class HealthPlugin : Plugin() {
|
|
|
138
169
|
|
|
139
170
|
pluginScope.launch {
|
|
140
171
|
val client = getClientOrReject(call) ?: return@launch
|
|
141
|
-
val status = manager.authorizationStatus(
|
|
172
|
+
val status = manager.authorizationStatus(
|
|
173
|
+
client,
|
|
174
|
+
readAuth.dataTypes,
|
|
175
|
+
writeTypes,
|
|
176
|
+
readAuth.includeWorkouts,
|
|
177
|
+
readAuth.includeSleep,
|
|
178
|
+
readAuth.includeHydration
|
|
179
|
+
)
|
|
142
180
|
call.resolve(status)
|
|
143
181
|
}
|
|
144
182
|
}
|
|
@@ -273,24 +311,26 @@ class HealthPlugin : Plugin() {
|
|
|
273
311
|
return result
|
|
274
312
|
}
|
|
275
313
|
|
|
276
|
-
private fun
|
|
314
|
+
private fun parseReadAuthorizationTypes(call: PluginCall, key: String): ReadAuthorizationTypes {
|
|
277
315
|
val array = call.getArray(key) ?: JSArray()
|
|
278
316
|
val result = mutableListOf<HealthDataType>()
|
|
279
317
|
var includeWorkouts = false
|
|
280
318
|
var includeSleep = false
|
|
319
|
+
var includeHydration = false
|
|
281
320
|
for (i in 0 until array.length()) {
|
|
282
321
|
val identifier = array.optString(i, null) ?: continue
|
|
283
|
-
|
|
284
|
-
includeWorkouts = true
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
322
|
+
when (identifier) {
|
|
323
|
+
"workouts" -> includeWorkouts = true
|
|
324
|
+
"sleep" -> includeSleep = true
|
|
325
|
+
"hydration" -> includeHydration = true
|
|
326
|
+
else -> {
|
|
327
|
+
val dataType = HealthDataType.from(identifier)
|
|
328
|
+
?: throw IllegalArgumentException("Unsupported data type: $identifier")
|
|
329
|
+
result.add(dataType)
|
|
330
|
+
}
|
|
291
331
|
}
|
|
292
332
|
}
|
|
293
|
-
return
|
|
333
|
+
return ReadAuthorizationTypes(result, includeWorkouts, includeSleep, includeHydration)
|
|
294
334
|
}
|
|
295
335
|
|
|
296
336
|
private fun getClientOrReject(call: PluginCall): HealthConnectClient? {
|
|
@@ -428,6 +468,42 @@ class HealthPlugin : Plugin() {
|
|
|
428
468
|
}
|
|
429
469
|
}
|
|
430
470
|
|
|
471
|
+
@PluginMethod
|
|
472
|
+
fun queryHydration(call: PluginCall) {
|
|
473
|
+
val limit = (call.getInt("limit") ?: DEFAULT_LIMIT).coerceAtLeast(0)
|
|
474
|
+
val ascending = call.getBoolean("ascending") ?: false
|
|
475
|
+
|
|
476
|
+
val startInstant = try {
|
|
477
|
+
manager.parseInstant(call.getString("startDate"), Instant.now().minus(DEFAULT_PAST_DURATION))
|
|
478
|
+
} catch (e: DateTimeParseException) {
|
|
479
|
+
call.reject(e.message, null, e)
|
|
480
|
+
return
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
val endInstant = try {
|
|
484
|
+
manager.parseInstant(call.getString("endDate"), Instant.now())
|
|
485
|
+
} catch (e: DateTimeParseException) {
|
|
486
|
+
call.reject(e.message, null, e)
|
|
487
|
+
return
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (endInstant.isBefore(startInstant)) {
|
|
491
|
+
call.reject("endDate must be greater than or equal to startDate")
|
|
492
|
+
return
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
pluginScope.launch {
|
|
496
|
+
val client = getClientOrReject(call) ?: return@launch
|
|
497
|
+
try {
|
|
498
|
+
val hydrationRecords = manager.queryHydration(client, startInstant, endInstant, limit, ascending)
|
|
499
|
+
val result = JSObject().apply { put("hydrationRecords", hydrationRecords) }
|
|
500
|
+
call.resolve(result)
|
|
501
|
+
} catch (e: Exception) {
|
|
502
|
+
call.reject(e.message ?: "Failed to query hydration records.", null, e)
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
431
507
|
companion object {
|
|
432
508
|
private const val DEFAULT_LIMIT = 100
|
|
433
509
|
private val DEFAULT_PAST_DURATION: Duration = Duration.ofDays(1)
|
package/dist/docs.json
CHANGED
|
@@ -204,6 +204,38 @@
|
|
|
204
204
|
"QuerySleepOptions"
|
|
205
205
|
],
|
|
206
206
|
"slug": "querysleep"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "queryHydration",
|
|
210
|
+
"signature": "(options: QueryHydrationOptions) => Promise<QueryHydrationResult>",
|
|
211
|
+
"parameters": [
|
|
212
|
+
{
|
|
213
|
+
"name": "options",
|
|
214
|
+
"docs": "Query options including date range, limit, and sort order",
|
|
215
|
+
"type": "QueryHydrationOptions"
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
"returns": "Promise<QueryHydrationResult>",
|
|
219
|
+
"tags": [
|
|
220
|
+
{
|
|
221
|
+
"name": "param",
|
|
222
|
+
"text": "options Query options including date range, limit, and sort order"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"name": "returns",
|
|
226
|
+
"text": "A promise that resolves with the hydration records"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"name": "throws",
|
|
230
|
+
"text": "An error if something went wrong"
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"docs": "Queries hydration records from the native health store on Android (Health Connect).",
|
|
234
|
+
"complexTypes": [
|
|
235
|
+
"QueryHydrationResult",
|
|
236
|
+
"QueryHydrationOptions"
|
|
237
|
+
],
|
|
238
|
+
"slug": "queryhydration"
|
|
207
239
|
}
|
|
208
240
|
],
|
|
209
241
|
"properties": []
|
|
@@ -789,6 +821,114 @@
|
|
|
789
821
|
"type": "boolean | undefined"
|
|
790
822
|
}
|
|
791
823
|
]
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"name": "QueryHydrationResult",
|
|
827
|
+
"slug": "queryhydrationresult",
|
|
828
|
+
"docs": "",
|
|
829
|
+
"tags": [],
|
|
830
|
+
"methods": [],
|
|
831
|
+
"properties": [
|
|
832
|
+
{
|
|
833
|
+
"name": "hydrationRecords",
|
|
834
|
+
"tags": [],
|
|
835
|
+
"docs": "",
|
|
836
|
+
"complexTypes": [
|
|
837
|
+
"HydrationRecord"
|
|
838
|
+
],
|
|
839
|
+
"type": "HydrationRecord[]"
|
|
840
|
+
}
|
|
841
|
+
]
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
"name": "HydrationRecord",
|
|
845
|
+
"slug": "hydrationrecord",
|
|
846
|
+
"docs": "",
|
|
847
|
+
"tags": [],
|
|
848
|
+
"methods": [],
|
|
849
|
+
"properties": [
|
|
850
|
+
{
|
|
851
|
+
"name": "volume",
|
|
852
|
+
"tags": [],
|
|
853
|
+
"docs": "Volume of water consumed in liters.",
|
|
854
|
+
"complexTypes": [],
|
|
855
|
+
"type": "number"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"name": "startDate",
|
|
859
|
+
"tags": [],
|
|
860
|
+
"docs": "ISO 8601 start date of the hydration record.",
|
|
861
|
+
"complexTypes": [],
|
|
862
|
+
"type": "string"
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
"name": "endDate",
|
|
866
|
+
"tags": [],
|
|
867
|
+
"docs": "ISO 8601 end date of the hydration record.",
|
|
868
|
+
"complexTypes": [],
|
|
869
|
+
"type": "string"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"name": "sourceName",
|
|
873
|
+
"tags": [],
|
|
874
|
+
"docs": "Source name that recorded the hydration.",
|
|
875
|
+
"complexTypes": [],
|
|
876
|
+
"type": "string | undefined"
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
"name": "sourceId",
|
|
880
|
+
"tags": [],
|
|
881
|
+
"docs": "Source bundle identifier.",
|
|
882
|
+
"complexTypes": [],
|
|
883
|
+
"type": "string | undefined"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
"name": "metadata",
|
|
887
|
+
"tags": [],
|
|
888
|
+
"docs": "Additional metadata (if available).",
|
|
889
|
+
"complexTypes": [
|
|
890
|
+
"Record"
|
|
891
|
+
],
|
|
892
|
+
"type": "Record<string, string>"
|
|
893
|
+
}
|
|
894
|
+
]
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"name": "QueryHydrationOptions",
|
|
898
|
+
"slug": "queryhydrationoptions",
|
|
899
|
+
"docs": "",
|
|
900
|
+
"tags": [],
|
|
901
|
+
"methods": [],
|
|
902
|
+
"properties": [
|
|
903
|
+
{
|
|
904
|
+
"name": "startDate",
|
|
905
|
+
"tags": [],
|
|
906
|
+
"docs": "Inclusive ISO 8601 start date (defaults to now - 1 day).",
|
|
907
|
+
"complexTypes": [],
|
|
908
|
+
"type": "string | undefined"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"name": "endDate",
|
|
912
|
+
"tags": [],
|
|
913
|
+
"docs": "Exclusive ISO 8601 end date (defaults to now).",
|
|
914
|
+
"complexTypes": [],
|
|
915
|
+
"type": "string | undefined"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"name": "limit",
|
|
919
|
+
"tags": [],
|
|
920
|
+
"docs": "Maximum number of hydration records to return (defaults to 100).",
|
|
921
|
+
"complexTypes": [],
|
|
922
|
+
"type": "number | undefined"
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"name": "ascending",
|
|
926
|
+
"tags": [],
|
|
927
|
+
"docs": "Return results sorted ascending by start date (defaults to false).",
|
|
928
|
+
"complexTypes": [],
|
|
929
|
+
"type": "boolean | undefined"
|
|
930
|
+
}
|
|
931
|
+
]
|
|
792
932
|
}
|
|
793
933
|
],
|
|
794
934
|
"enums": [],
|
|
@@ -796,7 +936,7 @@
|
|
|
796
936
|
{
|
|
797
937
|
"name": "ReadAuthorizationType",
|
|
798
938
|
"slug": "readauthorizationtype",
|
|
799
|
-
"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().",
|
|
939
|
+
"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().",
|
|
800
940
|
"types": [
|
|
801
941
|
{
|
|
802
942
|
"text": "HealthDataType",
|
|
@@ -811,6 +951,10 @@
|
|
|
811
951
|
{
|
|
812
952
|
"text": "'sleep'",
|
|
813
953
|
"complexTypes": []
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"text": "'hydration'",
|
|
957
|
+
"complexTypes": []
|
|
814
958
|
}
|
|
815
959
|
]
|
|
816
960
|
},
|
|
@@ -4,8 +4,9 @@ export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';
|
|
|
4
4
|
* Data types that can be requested for read authorization.
|
|
5
5
|
* Includes 'workouts' for querying workout sessions via queryWorkouts().
|
|
6
6
|
* Includes 'sleep' for querying sleep sessions via querySleep().
|
|
7
|
+
* Includes 'hydration' for querying hydration records via queryHydration().
|
|
7
8
|
*/
|
|
8
|
-
export type ReadAuthorizationType = HealthDataType | 'workouts' | 'sleep';
|
|
9
|
+
export type ReadAuthorizationType = HealthDataType | 'workouts' | 'sleep' | 'hydration';
|
|
9
10
|
export interface AuthorizationOptions {
|
|
10
11
|
/**
|
|
11
12
|
* Data types that should be readable after authorization.
|
|
@@ -131,6 +132,33 @@ export interface SleepSession {
|
|
|
131
132
|
export interface QuerySleepResult {
|
|
132
133
|
sleepSessions: SleepSession[];
|
|
133
134
|
}
|
|
135
|
+
export interface QueryHydrationOptions {
|
|
136
|
+
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
|
|
137
|
+
startDate?: string;
|
|
138
|
+
/** Exclusive ISO 8601 end date (defaults to now). */
|
|
139
|
+
endDate?: string;
|
|
140
|
+
/** Maximum number of hydration records to return (defaults to 100). */
|
|
141
|
+
limit?: number;
|
|
142
|
+
/** Return results sorted ascending by start date (defaults to false). */
|
|
143
|
+
ascending?: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface HydrationRecord {
|
|
146
|
+
/** Volume of water consumed in liters. */
|
|
147
|
+
volume: number;
|
|
148
|
+
/** ISO 8601 start date of the hydration record. */
|
|
149
|
+
startDate: string;
|
|
150
|
+
/** ISO 8601 end date of the hydration record. */
|
|
151
|
+
endDate: string;
|
|
152
|
+
/** Source name that recorded the hydration. */
|
|
153
|
+
sourceName?: string;
|
|
154
|
+
/** Source bundle identifier. */
|
|
155
|
+
sourceId?: string;
|
|
156
|
+
/** Additional metadata (if available). */
|
|
157
|
+
metadata?: Record<string, string>;
|
|
158
|
+
}
|
|
159
|
+
export interface QueryHydrationResult {
|
|
160
|
+
hydrationRecords: HydrationRecord[];
|
|
161
|
+
}
|
|
134
162
|
export interface WriteSampleOptions {
|
|
135
163
|
dataType: HealthDataType;
|
|
136
164
|
value: number;
|
|
@@ -204,4 +232,12 @@ export interface HealthPlugin {
|
|
|
204
232
|
* @throws An error if something went wrong
|
|
205
233
|
*/
|
|
206
234
|
querySleep(options: QuerySleepOptions): Promise<QuerySleepResult>;
|
|
235
|
+
/**
|
|
236
|
+
* Queries hydration records from the native health store on Android (Health Connect).
|
|
237
|
+
*
|
|
238
|
+
* @param options Query options including date range, limit, and sort order
|
|
239
|
+
* @returns A promise that resolves with the hydration records
|
|
240
|
+
* @throws An error if something went wrong
|
|
241
|
+
*/
|
|
242
|
+
queryHydration(options: QueryHydrationOptions): Promise<QueryHydrationResult>;
|
|
207
243
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'totalCalories' | 'heartRate' | 'weight' | 'height';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';\n\n/**\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 */\nexport type ReadAuthorizationType = HealthDataType | 'workouts' | 'sleep';\n\nexport interface AuthorizationOptions {\n /**\n * Data types that should be readable after authorization.\n * Include 'workouts' to enable queryWorkouts() method.\n */\n read?: ReadAuthorizationType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n /** Data types (and 'workouts') that are authorized for reading */\n readAuthorized: ReadAuthorizationType[];\n /** Data types (and 'workouts') that are denied for reading */\n readDenied: ReadAuthorizationType[];\n /** Data types that are authorized for writing */\n writeAuthorized: HealthDataType[];\n /** Data types that are denied for writing */\n writeDenied: HealthDataType[];\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 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 interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\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 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 /** 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\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 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` and `totalCalories`, bpm for `heartRate`, kilogram for `weight`, meter for `height`).\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}\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.\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"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'totalCalories' | 'heartRate' | 'weight' | 'height';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';\n\n/**\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 = HealthDataType | 'workouts' | 'sleep' | 'hydration';\n\nexport interface AuthorizationOptions {\n /**\n * Data types that should be readable after authorization.\n * Include 'workouts' to enable queryWorkouts() method.\n */\n read?: ReadAuthorizationType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n /** Data types (and 'workouts') that are authorized for reading */\n readAuthorized: ReadAuthorizationType[];\n /** Data types (and 'workouts') that are denied for reading */\n readDenied: ReadAuthorizationType[];\n /** Data types that are authorized for writing */\n writeAuthorized: HealthDataType[];\n /** Data types that are denied for writing */\n writeDenied: HealthDataType[];\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 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 interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\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 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 /** 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\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 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` and `totalCalories`, bpm for `heartRate`, kilogram for `weight`, meter for `height`).\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}\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.\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, QueryOptions, QuerySleepOptions, QuerySleepResult, QueryWorkoutsOptions, QueryWorkoutsResult, ReadSamplesResult, WriteSampleOptions } from './definitions';
|
|
2
|
+
import type { AuthorizationOptions, AuthorizationStatus, AvailabilityResult, HealthPlugin, QueryHydrationOptions, QueryHydrationResult, QueryOptions, QuerySleepOptions, QuerySleepResult, QueryWorkoutsOptions, QueryWorkoutsResult, ReadSamplesResult, WriteSampleOptions } from './definitions';
|
|
3
3
|
export declare class HealthWeb extends WebPlugin implements HealthPlugin {
|
|
4
4
|
isAvailable(): Promise<AvailabilityResult>;
|
|
5
5
|
requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
@@ -13,4 +13,5 @@ export declare class HealthWeb extends WebPlugin implements HealthPlugin {
|
|
|
13
13
|
showPrivacyPolicy(): Promise<void>;
|
|
14
14
|
queryWorkouts(_options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
|
|
15
15
|
querySleep(_options: QuerySleepOptions): Promise<QuerySleepResult>;
|
|
16
|
+
queryHydration(_options: QueryHydrationOptions): Promise<QueryHydrationResult>;
|
|
16
17
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -34,5 +34,8 @@ export class HealthWeb extends WebPlugin {
|
|
|
34
34
|
async querySleep(_options) {
|
|
35
35
|
throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
|
|
36
36
|
}
|
|
37
|
+
async queryHydration(_options) {
|
|
38
|
+
throw this.unimplemented('Querying hydration records is only available on native platforms.');
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
//# sourceMappingURL=web.js.map
|
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;AAkB5C,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,WAAW,CAAC,QAAsB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA4B;QAC3C,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 QueryOptions,\n QuerySleepOptions,\n QuerySleepResult,\n QueryWorkoutsOptions,\n QueryWorkoutsResult,\n ReadSamplesResult,\n WriteSampleOptions,\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 readSamples(_options: QueryOptions): Promise<ReadSamplesResult> {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n\n async saveSample(_options: WriteSampleOptions): Promise<void> {\n throw this.unimplemented('Writing health data is 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
|
@@ -41,6 +41,9 @@ class HealthWeb extends core.WebPlugin {
|
|
|
41
41
|
async querySleep(_options) {
|
|
42
42
|
throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
|
|
43
43
|
}
|
|
44
|
+
async queryHydration(_options) {
|
|
45
|
+
throw this.unimplemented('Querying hydration records is only available on native platforms.');
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
var web = /*#__PURE__*/Object.freeze({
|
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 readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is 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}\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,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,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;;;;;;;;;"}
|
|
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 readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is 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,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,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
|
@@ -40,6 +40,9 @@ var capacitorHealth = (function (exports, core) {
|
|
|
40
40
|
async querySleep(_options) {
|
|
41
41
|
throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
|
|
42
42
|
}
|
|
43
|
+
async queryHydration(_options) {
|
|
44
|
+
throw this.unimplemented('Querying hydration records is only available on native platforms.');
|
|
45
|
+
}
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
var web = /*#__PURE__*/Object.freeze({
|
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 readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is 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}\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,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,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;;;;;;;;;;;;;;;"}
|
|
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 readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is 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,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,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