@asiriindatissa/capacitor-health 9.0.2 → 9.0.3
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 +60 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/app/capgo/plugin/health/HealthDataType.kt +24 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthManager.kt +101 -1
- package/android/src/main/java/app/capgo/plugin/health/HealthPlugin.kt +64 -3
- package/dist/docs.json +173 -0
- package/dist/esm/definitions.d.ts +29 -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
|
@@ -213,6 +213,7 @@ const { sleepSessions } = await Health.querySleep({
|
|
|
213
213
|
* [`isAvailable()`](#isavailable)
|
|
214
214
|
* [`requestAuthorization(...)`](#requestauthorization)
|
|
215
215
|
* [`checkAuthorization(...)`](#checkauthorization)
|
|
216
|
+
* [`readSamples(...)`](#readsamples)
|
|
216
217
|
* [`getPluginVersion()`](#getpluginversion)
|
|
217
218
|
* [`openHealthConnectSettings()`](#openhealthconnectsettings)
|
|
218
219
|
* [`showPrivacyPolicy()`](#showprivacypolicy)
|
|
@@ -273,6 +274,23 @@ Checks authorization status for the provided data types without prompting the us
|
|
|
273
274
|
--------------------
|
|
274
275
|
|
|
275
276
|
|
|
277
|
+
### readSamples(...)
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
readSamples(options: QueryOptions) => Promise<ReadSamplesResult>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Reads samples for the given data type within the specified time frame.
|
|
284
|
+
|
|
285
|
+
| Param | Type |
|
|
286
|
+
| ------------- | ----------------------------------------------------- |
|
|
287
|
+
| **`options`** | <code><a href="#queryoptions">QueryOptions</a></code> |
|
|
288
|
+
|
|
289
|
+
**Returns:** <code>Promise<<a href="#readsamplesresult">ReadSamplesResult</a>></code>
|
|
290
|
+
|
|
291
|
+
--------------------
|
|
292
|
+
|
|
293
|
+
|
|
276
294
|
### getPluginVersion()
|
|
277
295
|
|
|
278
296
|
```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
|
+
#### ReadSamplesResult
|
|
403
|
+
|
|
404
|
+
| Prop | Type |
|
|
405
|
+
| ------------- | --------------------------- |
|
|
406
|
+
| **`samples`** | <code>HealthSample[]</code> |
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
#### HealthSample
|
|
410
|
+
|
|
411
|
+
| Prop | Type |
|
|
412
|
+
| ---------------- | --------------------------------------------------------- |
|
|
413
|
+
| **`dataType`** | <code><a href="#healthdatatype">HealthDataType</a></code> |
|
|
414
|
+
| **`value`** | <code>number</code> |
|
|
415
|
+
| **`unit`** | <code><a href="#healthunit">HealthUnit</a></code> |
|
|
416
|
+
| **`startDate`** | <code>string</code> |
|
|
417
|
+
| **`endDate`** | <code>string</code> |
|
|
418
|
+
| **`sourceName`** | <code>string</code> |
|
|
419
|
+
| **`sourceId`** | <code>string</code> |
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
#### QueryOptions
|
|
423
|
+
|
|
424
|
+
| Prop | Type | Description |
|
|
425
|
+
| --------------- | --------------------------------------------------------- | ------------------------------------------------------------------ |
|
|
426
|
+
| **`dataType`** | <code><a href="#healthdatatype">HealthDataType</a></code> | The type of data to retrieve from the health store. |
|
|
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 samples 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 |
|
|
@@ -459,7 +508,17 @@ Data types that can be requested for read authorization.
|
|
|
459
508
|
Includes 'sleep' for querying sleep sessions via querySleep().
|
|
460
509
|
Includes 'hydration' for querying hydration records via queryHydration().
|
|
461
510
|
|
|
462
|
-
<code>'sleep' | 'hydration'</code>
|
|
511
|
+
<code><a href="#healthdatatype">HealthDataType</a> | 'sleep' | 'hydration'</code>
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
#### HealthDataType
|
|
515
|
+
|
|
516
|
+
<code>'steps'</code>
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
#### HealthUnit
|
|
520
|
+
|
|
521
|
+
<code>'count'</code>
|
|
463
522
|
|
|
464
523
|
|
|
465
524
|
#### SleepStage
|
|
@@ -1,7 +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
|
-
|
|
4
|
+
<uses-permission android:name="android.permission.health.READ_STEPS" />
|
|
5
5
|
<!-- Query for Health Connect availability -->
|
|
6
6
|
<queries>
|
|
7
7
|
<package android:name="com.google.android.apps.healthdata" />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package app.capgo.plugin.health
|
|
2
|
+
|
|
3
|
+
import androidx.health.connect.client.permission.HealthPermission
|
|
4
|
+
import androidx.health.connect.client.records.StepsRecord
|
|
5
|
+
|
|
6
|
+
enum class HealthDataType(
|
|
7
|
+
val identifier: String,
|
|
8
|
+
val unit: String,
|
|
9
|
+
val readPermission: String,
|
|
10
|
+
val writePermission: String
|
|
11
|
+
) {
|
|
12
|
+
STEPS(
|
|
13
|
+
identifier = "steps",
|
|
14
|
+
unit = "count",
|
|
15
|
+
readPermission = HealthPermission.getReadPermission(StepsRecord::class),
|
|
16
|
+
writePermission = HealthPermission.getWritePermission(StepsRecord::class)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
companion object {
|
|
20
|
+
fun from(identifier: String): HealthDataType? {
|
|
21
|
+
return entries.find { it.identifier == identifier }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -4,6 +4,8 @@ import androidx.health.connect.client.HealthConnectClient
|
|
|
4
4
|
import androidx.health.connect.client.permission.HealthPermission
|
|
5
5
|
import androidx.health.connect.client.records.HydrationRecord
|
|
6
6
|
import androidx.health.connect.client.records.SleepSessionRecord
|
|
7
|
+
import androidx.health.connect.client.records.StepsRecord
|
|
8
|
+
import androidx.health.connect.client.records.Record
|
|
7
9
|
import androidx.health.connect.client.request.ReadRecordsRequest
|
|
8
10
|
import androidx.health.connect.client.time.TimeRangeFilter
|
|
9
11
|
import androidx.health.connect.client.records.metadata.Metadata
|
|
@@ -21,7 +23,8 @@ class HealthManager {
|
|
|
21
23
|
|
|
22
24
|
private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_INSTANT
|
|
23
25
|
|
|
24
|
-
fun permissionsFor(includeSleep: Boolean = false, includeHydration: Boolean = false): Set<String> = buildSet {
|
|
26
|
+
fun permissionsFor(readTypes: Collection<HealthDataType>, includeSleep: Boolean = false, includeHydration: Boolean = false): Set<String> = buildSet {
|
|
27
|
+
readTypes.forEach { add(it.readPermission) }
|
|
25
28
|
// Include sleep read permission if explicitly requested
|
|
26
29
|
if (includeSleep) {
|
|
27
30
|
add(HealthPermission.getReadPermission(SleepSessionRecord::class))
|
|
@@ -34,6 +37,7 @@ class HealthManager {
|
|
|
34
37
|
|
|
35
38
|
suspend fun authorizationStatus(
|
|
36
39
|
client: HealthConnectClient,
|
|
40
|
+
readTypes: Collection<HealthDataType>,
|
|
37
41
|
includeSleep: Boolean = false,
|
|
38
42
|
includeHydration: Boolean = false
|
|
39
43
|
): JSObject {
|
|
@@ -42,6 +46,14 @@ class HealthManager {
|
|
|
42
46
|
val readAuthorized = JSArray()
|
|
43
47
|
val readDenied = JSArray()
|
|
44
48
|
|
|
49
|
+
readTypes.forEach { type ->
|
|
50
|
+
if (granted.contains(type.readPermission)) {
|
|
51
|
+
readAuthorized.put(type.identifier)
|
|
52
|
+
} else {
|
|
53
|
+
readDenied.put(type.identifier)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
// Check sleep permission if requested
|
|
46
58
|
if (includeSleep) {
|
|
47
59
|
val sleepPermission = HealthPermission.getReadPermission(SleepSessionRecord::class)
|
|
@@ -74,6 +86,94 @@ class HealthManager {
|
|
|
74
86
|
}
|
|
75
87
|
|
|
76
88
|
|
|
89
|
+
suspend fun readSamples(
|
|
90
|
+
client: HealthConnectClient,
|
|
91
|
+
dataType: HealthDataType,
|
|
92
|
+
startTime: Instant,
|
|
93
|
+
endTime: Instant,
|
|
94
|
+
limit: Int,
|
|
95
|
+
ascending: Boolean
|
|
96
|
+
): JSArray {
|
|
97
|
+
val samples = mutableListOf<Pair<Instant, JSObject>>()
|
|
98
|
+
when (dataType) {
|
|
99
|
+
HealthDataType.STEPS -> readRecords(client, StepsRecord::class, startTime, endTime, limit) { record ->
|
|
100
|
+
val payload = createSamplePayload(
|
|
101
|
+
dataType,
|
|
102
|
+
record.startTime,
|
|
103
|
+
record.endTime,
|
|
104
|
+
record.count.toDouble(),
|
|
105
|
+
record.metadata
|
|
106
|
+
)
|
|
107
|
+
samples.add(record.startTime to payload)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
val sorted = samples.sortedBy { it.first }
|
|
112
|
+
val ordered = if (ascending) sorted else sorted.asReversed()
|
|
113
|
+
val limited = if (limit > 0) ordered.take(limit) else ordered
|
|
114
|
+
|
|
115
|
+
val array = JSArray()
|
|
116
|
+
limited.forEach { array.put(it.second) }
|
|
117
|
+
return array
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private suspend fun <T : Record> readRecords(
|
|
121
|
+
client: HealthConnectClient,
|
|
122
|
+
recordClass: kotlin.reflect.KClass<T>,
|
|
123
|
+
startTime: Instant,
|
|
124
|
+
endTime: Instant,
|
|
125
|
+
limit: Int,
|
|
126
|
+
consumer: (record: T) -> Unit
|
|
127
|
+
) {
|
|
128
|
+
var pageToken: String? = null
|
|
129
|
+
val pageSize = if (limit > 0) min(limit, MAX_PAGE_SIZE) else DEFAULT_PAGE_SIZE
|
|
130
|
+
var fetched = 0
|
|
131
|
+
|
|
132
|
+
do {
|
|
133
|
+
val request = ReadRecordsRequest(
|
|
134
|
+
recordType = recordClass,
|
|
135
|
+
timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
|
|
136
|
+
pageSize = pageSize,
|
|
137
|
+
pageToken = pageToken
|
|
138
|
+
)
|
|
139
|
+
val response = client.readRecords(request)
|
|
140
|
+
response.records.forEach { record ->
|
|
141
|
+
consumer(record)
|
|
142
|
+
}
|
|
143
|
+
fetched += response.records.size
|
|
144
|
+
pageToken = response.pageToken
|
|
145
|
+
} while (pageToken != null && (limit <= 0 || fetched < limit))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private fun createSamplePayload(
|
|
149
|
+
dataType: HealthDataType,
|
|
150
|
+
startTime: Instant,
|
|
151
|
+
endTime: Instant,
|
|
152
|
+
value: Double,
|
|
153
|
+
metadata: Metadata
|
|
154
|
+
): JSObject {
|
|
155
|
+
val payload = JSObject()
|
|
156
|
+
payload.put("dataType", dataType.identifier)
|
|
157
|
+
payload.put("value", value)
|
|
158
|
+
payload.put("unit", dataType.unit)
|
|
159
|
+
payload.put("startDate", formatter.format(startTime))
|
|
160
|
+
payload.put("endDate", formatter.format(endTime))
|
|
161
|
+
|
|
162
|
+
val dataOrigin = metadata.dataOrigin
|
|
163
|
+
payload.put("sourceId", dataOrigin.packageName)
|
|
164
|
+
payload.put("sourceName", dataOrigin.packageName)
|
|
165
|
+
metadata.device?.let { device ->
|
|
166
|
+
val manufacturer = device.manufacturer?.takeIf { it.isNotBlank() }
|
|
167
|
+
val model = device.model?.takeIf { it.isNotBlank() }
|
|
168
|
+
val label = listOfNotNull(manufacturer, model).joinToString(" ").trim()
|
|
169
|
+
if (label.isNotEmpty()) {
|
|
170
|
+
payload.put("sourceName", label)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return payload
|
|
175
|
+
}
|
|
176
|
+
|
|
77
177
|
fun parseInstant(value: String?, defaultInstant: Instant): Instant {
|
|
78
178
|
if (value.isNullOrBlank()) {
|
|
79
179
|
return defaultInstant
|
|
@@ -23,6 +23,7 @@ import kotlinx.coroutines.cancel
|
|
|
23
23
|
import kotlinx.coroutines.launch
|
|
24
24
|
|
|
25
25
|
data class ReadAuthorizationTypes(
|
|
26
|
+
val dataTypes: List<HealthDataType>,
|
|
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 pendingReadTypes: List<HealthDataType> = emptyList()
|
|
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.dataTypes,
|
|
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.dataTypes,
|
|
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.dataTypes,
|
|
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
|
+
pendingReadTypes = readAuth.dataTypes
|
|
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 readTypes = pendingReadTypes
|
|
110
117
|
val includeSleep = pendingIncludeSleep
|
|
111
118
|
val includeHydration = pendingIncludeHydration
|
|
119
|
+
pendingReadTypes = emptyList()
|
|
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, readTypes, 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.dataTypes,
|
|
135
144
|
readAuth.includeSleep,
|
|
136
145
|
readAuth.includeHydration
|
|
137
146
|
)
|
|
@@ -139,9 +148,57 @@ class HealthPlugin : Plugin() {
|
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
|
|
151
|
+
@PluginMethod
|
|
152
|
+
fun readSamples(call: PluginCall) {
|
|
153
|
+
val identifier = call.getString("dataType")
|
|
154
|
+
if (identifier.isNullOrBlank()) {
|
|
155
|
+
call.reject("dataType is required")
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
val dataType = HealthDataType.from(identifier)
|
|
160
|
+
if (dataType == null) {
|
|
161
|
+
call.reject("Unsupported data type: $identifier")
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
val limit = (call.getInt("limit") ?: DEFAULT_LIMIT).coerceAtLeast(0)
|
|
166
|
+
val ascending = call.getBoolean("ascending") ?: false
|
|
167
|
+
|
|
168
|
+
val startInstant = try {
|
|
169
|
+
manager.parseInstant(call.getString("startDate"), Instant.now().minus(DEFAULT_PAST_DURATION))
|
|
170
|
+
} catch (e: DateTimeParseException) {
|
|
171
|
+
call.reject(e.message, null, e)
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
val endInstant = try {
|
|
176
|
+
manager.parseInstant(call.getString("endDate"), Instant.now())
|
|
177
|
+
} catch (e: DateTimeParseException) {
|
|
178
|
+
call.reject(e.message, null, e)
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (endInstant.isBefore(startInstant)) {
|
|
183
|
+
call.reject("endDate must be greater than or equal to startDate")
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
pluginScope.launch {
|
|
188
|
+
val client = getClientOrReject(call) ?: return@launch
|
|
189
|
+
try {
|
|
190
|
+
val samples = manager.readSamples(client, dataType, startInstant, endInstant, limit, ascending)
|
|
191
|
+
val result = JSObject().apply { put("samples", samples) }
|
|
192
|
+
call.resolve(result)
|
|
193
|
+
} catch (e: Exception) {
|
|
194
|
+
call.reject(e.message ?: "Failed to read samples.", null, e)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
142
198
|
|
|
143
199
|
private fun parseReadAuthorizationTypes(call: PluginCall, key: String): ReadAuthorizationTypes {
|
|
144
200
|
val array = call.getArray(key) ?: JSArray()
|
|
201
|
+
val result = mutableListOf<HealthDataType>()
|
|
145
202
|
var includeSleep = false
|
|
146
203
|
var includeHydration = false
|
|
147
204
|
for (i in 0 until array.length()) {
|
|
@@ -149,10 +206,14 @@ class HealthPlugin : Plugin() {
|
|
|
149
206
|
when (identifier) {
|
|
150
207
|
"sleep" -> includeSleep = true
|
|
151
208
|
"hydration" -> includeHydration = true
|
|
152
|
-
else ->
|
|
209
|
+
else -> {
|
|
210
|
+
val dataType = HealthDataType.from(identifier)
|
|
211
|
+
?: throw IllegalArgumentException("Unsupported data type: $identifier")
|
|
212
|
+
result.add(dataType)
|
|
213
|
+
}
|
|
153
214
|
}
|
|
154
215
|
}
|
|
155
|
-
return ReadAuthorizationTypes(includeSleep, includeHydration)
|
|
216
|
+
return ReadAuthorizationTypes(result, includeSleep, includeHydration)
|
|
156
217
|
}
|
|
157
218
|
|
|
158
219
|
private fun getClientOrReject(call: PluginCall): HealthConnectClient? {
|
package/dist/docs.json
CHANGED
|
@@ -55,6 +55,25 @@
|
|
|
55
55
|
],
|
|
56
56
|
"slug": "checkauthorization"
|
|
57
57
|
},
|
|
58
|
+
{
|
|
59
|
+
"name": "readSamples",
|
|
60
|
+
"signature": "(options: QueryOptions) => Promise<ReadSamplesResult>",
|
|
61
|
+
"parameters": [
|
|
62
|
+
{
|
|
63
|
+
"name": "options",
|
|
64
|
+
"docs": "",
|
|
65
|
+
"type": "QueryOptions"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"returns": "Promise<ReadSamplesResult>",
|
|
69
|
+
"tags": [],
|
|
70
|
+
"docs": "Reads samples for the given data type within the specified time frame.",
|
|
71
|
+
"complexTypes": [
|
|
72
|
+
"ReadSamplesResult",
|
|
73
|
+
"QueryOptions"
|
|
74
|
+
],
|
|
75
|
+
"slug": "readsamples"
|
|
76
|
+
},
|
|
58
77
|
{
|
|
59
78
|
"name": "getPluginVersion",
|
|
60
79
|
"signature": "() => Promise<{ version: string; }>",
|
|
@@ -261,6 +280,132 @@
|
|
|
261
280
|
}
|
|
262
281
|
]
|
|
263
282
|
},
|
|
283
|
+
{
|
|
284
|
+
"name": "ReadSamplesResult",
|
|
285
|
+
"slug": "readsamplesresult",
|
|
286
|
+
"docs": "",
|
|
287
|
+
"tags": [],
|
|
288
|
+
"methods": [],
|
|
289
|
+
"properties": [
|
|
290
|
+
{
|
|
291
|
+
"name": "samples",
|
|
292
|
+
"tags": [],
|
|
293
|
+
"docs": "",
|
|
294
|
+
"complexTypes": [
|
|
295
|
+
"HealthSample"
|
|
296
|
+
],
|
|
297
|
+
"type": "HealthSample[]"
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"name": "HealthSample",
|
|
303
|
+
"slug": "healthsample",
|
|
304
|
+
"docs": "",
|
|
305
|
+
"tags": [],
|
|
306
|
+
"methods": [],
|
|
307
|
+
"properties": [
|
|
308
|
+
{
|
|
309
|
+
"name": "dataType",
|
|
310
|
+
"tags": [],
|
|
311
|
+
"docs": "",
|
|
312
|
+
"complexTypes": [
|
|
313
|
+
"HealthDataType"
|
|
314
|
+
],
|
|
315
|
+
"type": "HealthDataType"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"name": "value",
|
|
319
|
+
"tags": [],
|
|
320
|
+
"docs": "",
|
|
321
|
+
"complexTypes": [],
|
|
322
|
+
"type": "number"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"name": "unit",
|
|
326
|
+
"tags": [],
|
|
327
|
+
"docs": "",
|
|
328
|
+
"complexTypes": [
|
|
329
|
+
"HealthUnit"
|
|
330
|
+
],
|
|
331
|
+
"type": "HealthUnit"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"name": "startDate",
|
|
335
|
+
"tags": [],
|
|
336
|
+
"docs": "",
|
|
337
|
+
"complexTypes": [],
|
|
338
|
+
"type": "string"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "endDate",
|
|
342
|
+
"tags": [],
|
|
343
|
+
"docs": "",
|
|
344
|
+
"complexTypes": [],
|
|
345
|
+
"type": "string"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"name": "sourceName",
|
|
349
|
+
"tags": [],
|
|
350
|
+
"docs": "",
|
|
351
|
+
"complexTypes": [],
|
|
352
|
+
"type": "string | undefined"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
"name": "sourceId",
|
|
356
|
+
"tags": [],
|
|
357
|
+
"docs": "",
|
|
358
|
+
"complexTypes": [],
|
|
359
|
+
"type": "string | undefined"
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"name": "QueryOptions",
|
|
365
|
+
"slug": "queryoptions",
|
|
366
|
+
"docs": "",
|
|
367
|
+
"tags": [],
|
|
368
|
+
"methods": [],
|
|
369
|
+
"properties": [
|
|
370
|
+
{
|
|
371
|
+
"name": "dataType",
|
|
372
|
+
"tags": [],
|
|
373
|
+
"docs": "The type of data to retrieve from the health store.",
|
|
374
|
+
"complexTypes": [
|
|
375
|
+
"HealthDataType"
|
|
376
|
+
],
|
|
377
|
+
"type": "HealthDataType"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"name": "startDate",
|
|
381
|
+
"tags": [],
|
|
382
|
+
"docs": "Inclusive ISO 8601 start date (defaults to now - 1 day).",
|
|
383
|
+
"complexTypes": [],
|
|
384
|
+
"type": "string | undefined"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"name": "endDate",
|
|
388
|
+
"tags": [],
|
|
389
|
+
"docs": "Exclusive ISO 8601 end date (defaults to now).",
|
|
390
|
+
"complexTypes": [],
|
|
391
|
+
"type": "string | undefined"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"name": "limit",
|
|
395
|
+
"tags": [],
|
|
396
|
+
"docs": "Maximum number of samples to return (defaults to 100).",
|
|
397
|
+
"complexTypes": [],
|
|
398
|
+
"type": "number | undefined"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"name": "ascending",
|
|
402
|
+
"tags": [],
|
|
403
|
+
"docs": "Return results sorted ascending by start date (defaults to false).",
|
|
404
|
+
"complexTypes": [],
|
|
405
|
+
"type": "boolean | undefined"
|
|
406
|
+
}
|
|
407
|
+
]
|
|
408
|
+
},
|
|
264
409
|
{
|
|
265
410
|
"name": "QuerySleepResult",
|
|
266
411
|
"slug": "querysleepresult",
|
|
@@ -533,6 +678,12 @@
|
|
|
533
678
|
"slug": "readauthorizationtype",
|
|
534
679
|
"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().",
|
|
535
680
|
"types": [
|
|
681
|
+
{
|
|
682
|
+
"text": "HealthDataType",
|
|
683
|
+
"complexTypes": [
|
|
684
|
+
"HealthDataType"
|
|
685
|
+
]
|
|
686
|
+
},
|
|
536
687
|
{
|
|
537
688
|
"text": "'sleep'",
|
|
538
689
|
"complexTypes": []
|
|
@@ -543,6 +694,28 @@
|
|
|
543
694
|
}
|
|
544
695
|
]
|
|
545
696
|
},
|
|
697
|
+
{
|
|
698
|
+
"name": "HealthDataType",
|
|
699
|
+
"slug": "healthdatatype",
|
|
700
|
+
"docs": "",
|
|
701
|
+
"types": [
|
|
702
|
+
{
|
|
703
|
+
"text": "'steps'",
|
|
704
|
+
"complexTypes": []
|
|
705
|
+
}
|
|
706
|
+
]
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
"name": "HealthUnit",
|
|
710
|
+
"slug": "healthunit",
|
|
711
|
+
"docs": "",
|
|
712
|
+
"types": [
|
|
713
|
+
{
|
|
714
|
+
"text": "'count'",
|
|
715
|
+
"complexTypes": []
|
|
716
|
+
}
|
|
717
|
+
]
|
|
718
|
+
},
|
|
546
719
|
{
|
|
547
720
|
"name": "SleepStage",
|
|
548
721
|
"slug": "sleepstage",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export type HealthDataType = 'steps';
|
|
2
|
+
export type HealthUnit = 'count';
|
|
1
3
|
/**
|
|
2
4
|
* Data types that can be requested for read authorization.
|
|
3
5
|
* Includes 'sleep' for querying sleep sessions via querySleep().
|
|
4
6
|
* Includes 'hydration' for querying hydration records via queryHydration().
|
|
5
7
|
*/
|
|
6
|
-
export type ReadAuthorizationType = 'sleep' | 'hydration';
|
|
8
|
+
export type ReadAuthorizationType = HealthDataType | 'sleep' | 'hydration';
|
|
7
9
|
export interface AuthorizationOptions {
|
|
8
10
|
/**
|
|
9
11
|
* Data types that should be readable after authorization.
|
|
@@ -26,6 +28,30 @@ export interface AvailabilityResult {
|
|
|
26
28
|
platform?: 'android' | 'web';
|
|
27
29
|
reason?: string;
|
|
28
30
|
}
|
|
31
|
+
export interface QueryOptions {
|
|
32
|
+
/** The type of data to retrieve from the health store. */
|
|
33
|
+
dataType: HealthDataType;
|
|
34
|
+
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
|
|
35
|
+
startDate?: string;
|
|
36
|
+
/** Exclusive ISO 8601 end date (defaults to now). */
|
|
37
|
+
endDate?: string;
|
|
38
|
+
/** Maximum number of samples to return (defaults to 100). */
|
|
39
|
+
limit?: number;
|
|
40
|
+
/** Return results sorted ascending by start date (defaults to false). */
|
|
41
|
+
ascending?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface HealthSample {
|
|
44
|
+
dataType: HealthDataType;
|
|
45
|
+
value: number;
|
|
46
|
+
unit: HealthUnit;
|
|
47
|
+
startDate: string;
|
|
48
|
+
endDate: string;
|
|
49
|
+
sourceName?: string;
|
|
50
|
+
sourceId?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ReadSamplesResult {
|
|
53
|
+
samples: HealthSample[];
|
|
54
|
+
}
|
|
29
55
|
export type SleepStage = 'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem';
|
|
30
56
|
export interface QuerySleepOptions {
|
|
31
57
|
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
|
|
@@ -100,6 +126,8 @@ export interface HealthPlugin {
|
|
|
100
126
|
requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
101
127
|
/** Checks authorization status for the provided data types without prompting the user. */
|
|
102
128
|
checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
129
|
+
/** Reads samples for the given data type within the specified time frame. */
|
|
130
|
+
readSamples(options: QueryOptions): Promise<ReadSamplesResult>;
|
|
103
131
|
/**
|
|
104
132
|
* Get the native Capacitor plugin version
|
|
105
133
|
*
|
|
@@ -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":["export type HealthDataType = 'steps';\n\nexport type HealthUnit = 'count';\n\n/**\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 = HealthDataType | '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 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 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 /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\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"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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, QueryOptions, QueryHydrationOptions, QueryHydrationResult, QuerySleepOptions, QuerySleepResult, ReadSamplesResult } from './definitions';
|
|
3
3
|
export declare class HealthWeb extends WebPlugin implements HealthPlugin {
|
|
4
4
|
isAvailable(): Promise<AvailabilityResult>;
|
|
5
5
|
requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
6
6
|
checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
7
|
+
readSamples(_options: QueryOptions): Promise<ReadSamplesResult>;
|
|
7
8
|
getPluginVersion(): Promise<{
|
|
8
9
|
version: string;
|
|
9
10
|
}>;
|
package/dist/esm/web.js
CHANGED
|
@@ -13,6 +13,9 @@ export class HealthWeb extends WebPlugin {
|
|
|
13
13
|
async checkAuthorization(_options) {
|
|
14
14
|
throw this.unimplemented('Health permissions are only available on native platforms.');
|
|
15
15
|
}
|
|
16
|
+
async readSamples(_options) {
|
|
17
|
+
throw this.unimplemented('Reading health data is only available on native platforms.');
|
|
18
|
+
}
|
|
16
19
|
async getPluginVersion() {
|
|
17
20
|
return { version: 'web' };
|
|
18
21
|
}
|
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,WAAW,CAAC,QAAsB;QACtC,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,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 QueryOptions,\n QueryHydrationOptions,\n QueryHydrationResult,\n QuerySleepOptions,\n QuerySleepResult,\n ReadSamplesResult,\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 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 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
|
@@ -20,6 +20,9 @@ class HealthWeb extends core.WebPlugin {
|
|
|
20
20
|
async checkAuthorization(_options) {
|
|
21
21
|
throw this.unimplemented('Health permissions are only available on native platforms.');
|
|
22
22
|
}
|
|
23
|
+
async readSamples(_options) {
|
|
24
|
+
throw this.unimplemented('Reading health data is only available on native platforms.');
|
|
25
|
+
}
|
|
23
26
|
async getPluginVersion() {
|
|
24
27
|
return { version: 'web' };
|
|
25
28
|
}
|
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 readSamples(_options) {\n throw this.unimplemented('Reading 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 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,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;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -19,6 +19,9 @@ var capacitorHealth = (function (exports, core) {
|
|
|
19
19
|
async checkAuthorization(_options) {
|
|
20
20
|
throw this.unimplemented('Health permissions are only available on native platforms.');
|
|
21
21
|
}
|
|
22
|
+
async readSamples(_options) {
|
|
23
|
+
throw this.unimplemented('Reading health data is only available on native platforms.');
|
|
24
|
+
}
|
|
22
25
|
async getPluginVersion() {
|
|
23
26
|
return { version: 'web' };
|
|
24
27
|
}
|
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 readSamples(_options) {\n throw this.unimplemented('Reading 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 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,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;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED