@asiriindatissa/capacitor-health 8.4.2 → 8.4.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 CHANGED
@@ -162,6 +162,52 @@ const { workouts } = await Health.queryWorkouts({
162
162
  - Workout energy and distance data are aggregated from separate Health Connect records during the workout time period. If you don't request permissions for `calories`/`totalCalories` and `distance`, these fields will be missing from workout results.
163
163
  - If `totalEnergyBurned` or `totalDistance` are missing despite having permissions, it means no calorie or distance data was recorded during that workout period in Health Connect.
164
164
 
165
+ ### Sleep
166
+
167
+ To query sleep sessions, you need to request read permission for `'sleep'`:
168
+
169
+ ```ts
170
+ // Request permission to read sleep data
171
+ await Health.requestAuthorization({
172
+ read: ['sleep'],
173
+ write: [],
174
+ });
175
+
176
+ // Query recent sleep sessions
177
+ const { sleepSessions } = await Health.querySleep({
178
+ startDate: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString(),
179
+ endDate: new Date().toISOString(),
180
+ limit: 10,
181
+ });
182
+
183
+ // Each sleep session includes:
184
+ // - duration (in seconds), startDate, endDate (always present)
185
+ // - title (optional, if provided by the source app)
186
+ // - stages (optional array of sleep stage records if available)
187
+ // - sourceName, sourceId (source app information)
188
+
189
+ // Sleep stages can be: 'unknown', 'awake', 'sleeping', 'outOfBed',
190
+ // 'awakeInBed', 'light', 'deep', 'rem'
191
+ ```
192
+
193
+ **Supported Sleep Stages:**
194
+
195
+ | Stage | Description |
196
+ | ------------ | ---------------------------------------------- |
197
+ | `unknown` | Unspecified or unknown if the user is sleeping |
198
+ | `awake` | The user is awake within a sleep cycle |
199
+ | `sleeping` | Generic or non-granular sleep description |
200
+ | `outOfBed` | The user gets out of bed during sleep session |
201
+ | `awakeInBed` | The user is awake in bed |
202
+ | `light` | Light sleep cycle |
203
+ | `deep` | Deep sleep cycle |
204
+ | `rem` | REM sleep cycle |
205
+
206
+ **Note:**
207
+
208
+ - `'sleep'` is a special read-only permission type. You cannot write sleep data with this plugin.
209
+ - Not all sleep sessions include detailed sleep stages. Some apps may only record the overall sleep duration.
210
+
165
211
  ## API
166
212
 
167
213
  <docgen-index>
@@ -175,6 +221,7 @@ const { workouts } = await Health.queryWorkouts({
175
221
  * [`openHealthConnectSettings()`](#openhealthconnectsettings)
176
222
  * [`showPrivacyPolicy()`](#showprivacypolicy)
177
223
  * [`queryWorkouts(...)`](#queryworkouts)
224
+ * [`querySleep(...)`](#querysleep)
178
225
  * [Interfaces](#interfaces)
179
226
  * [Type Aliases](#type-aliases)
180
227
 
@@ -324,6 +371,23 @@ Queries workout sessions from the native health store on Android (Health Connect
324
371
  --------------------
325
372
 
326
373
 
374
+ ### querySleep(...)
375
+
376
+ ```typescript
377
+ querySleep(options: QuerySleepOptions) => Promise<QuerySleepResult>
378
+ ```
379
+
380
+ Queries sleep sessions from the native health store on Android (Health Connect).
381
+
382
+ | Param | Type | Description |
383
+ | ------------- | --------------------------------------------------------------- | --------------------------------------------------------- |
384
+ | **`options`** | <code><a href="#querysleepoptions">QuerySleepOptions</a></code> | Query options including date range, limit, and sort order |
385
+
386
+ **Returns:** <code>Promise&lt;<a href="#querysleepresult">QuerySleepResult</a>&gt;</code>
387
+
388
+ --------------------
389
+
390
+
327
391
  ### Interfaces
328
392
 
329
393
 
@@ -430,6 +494,46 @@ Queries workout sessions from the native health store on Android (Health Connect
430
494
  | **`ascending`** | <code>boolean</code> | Return results sorted ascending by start date (defaults to false). |
431
495
 
432
496
 
497
+ #### QuerySleepResult
498
+
499
+ | Prop | Type |
500
+ | ------------------- | --------------------------- |
501
+ | **`sleepSessions`** | <code>SleepSession[]</code> |
502
+
503
+
504
+ #### SleepSession
505
+
506
+ | Prop | Type | Description |
507
+ | ---------------- | --------------------------------------------------------------- | -------------------------------------------------------- |
508
+ | **`title`** | <code>string</code> | Title/name of the sleep session (if available). |
509
+ | **`duration`** | <code>number</code> | Duration of the sleep session in seconds. |
510
+ | **`startDate`** | <code>string</code> | ISO 8601 start date of the sleep session. |
511
+ | **`endDate`** | <code>string</code> | ISO 8601 end date of the sleep session. |
512
+ | **`stages`** | <code>SleepStageRecord[]</code> | Array of sleep stages during the session (if available). |
513
+ | **`sourceName`** | <code>string</code> | Source name that recorded the sleep session. |
514
+ | **`sourceId`** | <code>string</code> | Source bundle identifier. |
515
+ | **`metadata`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> | Additional metadata (if available). |
516
+
517
+
518
+ #### SleepStageRecord
519
+
520
+ | Prop | Type | Description |
521
+ | --------------- | ------------------------------------------------- | ---------------------------------------- |
522
+ | **`stage`** | <code><a href="#sleepstage">SleepStage</a></code> | The sleep stage type. |
523
+ | **`startDate`** | <code>string</code> | ISO 8601 start date of this sleep stage. |
524
+ | **`endDate`** | <code>string</code> | ISO 8601 end date of this sleep stage. |
525
+
526
+
527
+ #### QuerySleepOptions
528
+
529
+ | Prop | Type | Description |
530
+ | --------------- | -------------------- | ------------------------------------------------------------------ |
531
+ | **`startDate`** | <code>string</code> | Inclusive ISO 8601 start date (defaults to now - 1 day). |
532
+ | **`endDate`** | <code>string</code> | Exclusive ISO 8601 end date (defaults to now). |
533
+ | **`limit`** | <code>number</code> | Maximum number of sleep sessions to return (defaults to 100). |
534
+ | **`ascending`** | <code>boolean</code> | Return results sorted ascending by start date (defaults to false). |
535
+
536
+
433
537
  ### Type Aliases
434
538
 
435
539
 
@@ -437,8 +541,9 @@ Queries workout sessions from the native health store on Android (Health Connect
437
541
 
438
542
  Data types that can be requested for read authorization.
439
543
  Includes 'workouts' for querying workout sessions via queryWorkouts().
544
+ Includes 'sleep' for querying sleep sessions via querySleep().
440
545
 
441
- <code><a href="#healthdatatype">HealthDataType</a> | 'workouts'</code>
546
+ <code><a href="#healthdatatype">HealthDataType</a> | 'workouts' | 'sleep'</code>
442
547
 
443
548
 
444
549
  #### HealthDataType
@@ -462,6 +567,11 @@ Construct a type with a set of properties K of type T
462
567
 
463
568
  <code>'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'other'</code>
464
569
 
570
+
571
+ #### SleepStage
572
+
573
+ <code>'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem'</code>
574
+
465
575
  </docgen-api>
466
576
 
467
577
  ### Credits:
@@ -13,6 +13,8 @@
13
13
  <uses-permission android:name="android.permission.health.READ_HEIGHT" />
14
14
  <uses-permission android:name="android.permission.health.WRITE_HEIGHT" />
15
15
  <uses-permission android:name="android.permission.health.READ_EXERCISE" />
16
+ <uses-permission android:name="android.permission.health.READ_SLEEP" />
17
+ <uses-permission android:name="android.permission.health.WRITE_SLEEP" />
16
18
 
17
19
  <!-- Query for Health Connect availability -->
18
20
  <queries>
@@ -9,6 +9,7 @@ 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
11
  import androidx.health.connect.client.records.Record
12
+ import androidx.health.connect.client.records.SleepSessionRecord
12
13
  import androidx.health.connect.client.records.StepsRecord
13
14
  import androidx.health.connect.client.records.TotalCaloriesBurnedRecord
14
15
  import androidx.health.connect.client.records.WeightRecord
@@ -32,20 +33,25 @@ class HealthManager {
32
33
 
33
34
  private val formatter: DateTimeFormatter = DateTimeFormatter.ISO_INSTANT
34
35
 
35
- fun permissionsFor(readTypes: Collection<HealthDataType>, writeTypes: Collection<HealthDataType>, includeWorkouts: Boolean = false): Set<String> = buildSet {
36
+ fun permissionsFor(readTypes: Collection<HealthDataType>, writeTypes: Collection<HealthDataType>, includeWorkouts: Boolean = false, includeSleep: Boolean = false): Set<String> = buildSet {
36
37
  readTypes.forEach { add(it.readPermission) }
37
38
  writeTypes.forEach { add(it.writePermission) }
38
39
  // Include workout read permission if explicitly requested
39
40
  if (includeWorkouts) {
40
41
  add(HealthPermission.getReadPermission(ExerciseSessionRecord::class))
41
42
  }
43
+ // Include sleep read permission if explicitly requested
44
+ if (includeSleep) {
45
+ add(HealthPermission.getReadPermission(SleepSessionRecord::class))
46
+ }
42
47
  }
43
48
 
44
49
  suspend fun authorizationStatus(
45
50
  client: HealthConnectClient,
46
51
  readTypes: Collection<HealthDataType>,
47
52
  writeTypes: Collection<HealthDataType>,
48
- includeWorkouts: Boolean = false
53
+ includeWorkouts: Boolean = false,
54
+ includeSleep: Boolean = false
49
55
  ): JSObject {
50
56
  val granted = client.permissionController.getGrantedPermissions()
51
57
 
@@ -69,6 +75,16 @@ class HealthManager {
69
75
  }
70
76
  }
71
77
 
78
+ // Check sleep permission if requested
79
+ if (includeSleep) {
80
+ val sleepPermission = HealthPermission.getReadPermission(SleepSessionRecord::class)
81
+ if (granted.contains(sleepPermission)) {
82
+ readAuthorized.put("sleep")
83
+ } else {
84
+ readDenied.put("sleep")
85
+ }
86
+ }
87
+
72
88
  val writeAuthorized = JSArray()
73
89
  val writeDenied = JSArray()
74
90
  writeTypes.forEach { type ->
@@ -501,6 +517,108 @@ class HealthManager {
501
517
  return payload
502
518
  }
503
519
 
520
+ suspend fun querySleep(
521
+ client: HealthConnectClient,
522
+ startTime: Instant,
523
+ endTime: Instant,
524
+ limit: Int,
525
+ ascending: Boolean
526
+ ): JSArray {
527
+ val sleepSessions = mutableListOf<Pair<Instant, JSObject>>()
528
+
529
+ var pageToken: String? = null
530
+ val pageSize = if (limit > 0) min(limit, MAX_PAGE_SIZE) else DEFAULT_PAGE_SIZE
531
+ var fetched = 0
532
+
533
+ do {
534
+ val request = ReadRecordsRequest(
535
+ recordType = SleepSessionRecord::class,
536
+ timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
537
+ pageSize = pageSize,
538
+ pageToken = pageToken
539
+ )
540
+ val response = client.readRecords(request)
541
+
542
+ response.records.forEach { record ->
543
+ val session = record as SleepSessionRecord
544
+ val payload = createSleepPayload(session)
545
+ sleepSessions.add(session.startTime to payload)
546
+ }
547
+
548
+ fetched += response.records.size
549
+ pageToken = response.pageToken
550
+ } while (pageToken != null && (limit <= 0 || fetched < limit))
551
+
552
+ val sorted = sleepSessions.sortedBy { it.first }
553
+ val ordered = if (ascending) sorted else sorted.asReversed()
554
+ val limited = if (limit > 0) ordered.take(limit) else ordered
555
+
556
+ val array = JSArray()
557
+ limited.forEach { array.put(it.second) }
558
+ return array
559
+ }
560
+
561
+ private fun createSleepPayload(session: SleepSessionRecord): JSObject {
562
+ val payload = JSObject()
563
+
564
+ // Title if available
565
+ session.title?.let { title ->
566
+ if (title.isNotBlank()) {
567
+ payload.put("title", title)
568
+ }
569
+ }
570
+
571
+ // Duration in seconds
572
+ val durationSeconds = Duration.between(session.startTime, session.endTime).seconds.toInt()
573
+ payload.put("duration", durationSeconds)
574
+
575
+ // Start and end dates
576
+ payload.put("startDate", formatter.format(session.startTime))
577
+ payload.put("endDate", formatter.format(session.endTime))
578
+
579
+ // Sleep stages if available
580
+ if (session.stages.isNotEmpty()) {
581
+ val stagesArray = JSArray()
582
+ session.stages.forEach { stage ->
583
+ val stageObject = JSObject()
584
+ stageObject.put("stage", sleepStageToString(stage.stage))
585
+ stageObject.put("startDate", formatter.format(stage.startTime))
586
+ stageObject.put("endDate", formatter.format(stage.endTime))
587
+ stagesArray.put(stageObject)
588
+ }
589
+ payload.put("stages", stagesArray)
590
+ }
591
+
592
+ // Source information
593
+ val dataOrigin = session.metadata.dataOrigin
594
+ payload.put("sourceId", dataOrigin.packageName)
595
+ payload.put("sourceName", dataOrigin.packageName)
596
+ session.metadata.device?.let { device ->
597
+ val manufacturer = device.manufacturer?.takeIf { it.isNotBlank() }
598
+ val model = device.model?.takeIf { it.isNotBlank() }
599
+ val label = listOfNotNull(manufacturer, model).joinToString(" ").trim()
600
+ if (label.isNotEmpty()) {
601
+ payload.put("sourceName", label)
602
+ }
603
+ }
604
+
605
+ return payload
606
+ }
607
+
608
+ private fun sleepStageToString(stage: Int): String {
609
+ return when (stage) {
610
+ SleepSessionRecord.STAGE_TYPE_UNKNOWN -> "unknown"
611
+ SleepSessionRecord.STAGE_TYPE_AWAKE -> "awake"
612
+ SleepSessionRecord.STAGE_TYPE_SLEEPING -> "sleeping"
613
+ SleepSessionRecord.STAGE_TYPE_OUT_OF_BED -> "outOfBed"
614
+ SleepSessionRecord.STAGE_TYPE_LIGHT -> "light"
615
+ SleepSessionRecord.STAGE_TYPE_DEEP -> "deep"
616
+ SleepSessionRecord.STAGE_TYPE_REM -> "rem"
617
+ SleepSessionRecord.STAGE_TYPE_AWAKE_IN_BED -> "awakeInBed"
618
+ else -> "unknown"
619
+ }
620
+ }
621
+
504
622
  companion object {
505
623
  private const val DEFAULT_PAGE_SIZE = 100
506
624
  private const val MAX_PAGE_SIZE = 500
@@ -33,6 +33,7 @@ class HealthPlugin : Plugin() {
33
33
  private var pendingReadTypes: List<HealthDataType> = emptyList()
34
34
  private var pendingWriteTypes: List<HealthDataType> = emptyList()
35
35
  private var pendingIncludeWorkouts: Boolean = false
36
+ private var pendingIncludeSleep: Boolean = false
36
37
 
37
38
  override fun handleOnDestroy() {
38
39
  super.handleOnDestroy()
@@ -47,8 +48,8 @@ class HealthPlugin : Plugin() {
47
48
 
48
49
  @PluginMethod
49
50
  fun requestAuthorization(call: PluginCall) {
50
- val (readTypes, includeWorkouts) = try {
51
- parseTypeListWithWorkouts(call, "read")
51
+ val (readTypes, includeWorkouts, includeSleep) = try {
52
+ parseTypeListWithWorkoutsAndSleep(call, "read")
52
53
  } catch (e: IllegalArgumentException) {
53
54
  call.reject(e.message, null, e)
54
55
  return
@@ -63,17 +64,17 @@ class HealthPlugin : Plugin() {
63
64
 
64
65
  pluginScope.launch {
65
66
  val client = getClientOrReject(call) ?: return@launch
66
- val permissions = manager.permissionsFor(readTypes, writeTypes, includeWorkouts)
67
+ val permissions = manager.permissionsFor(readTypes, writeTypes, includeWorkouts, includeSleep)
67
68
 
68
69
  if (permissions.isEmpty()) {
69
- val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts)
70
+ val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts, includeSleep)
70
71
  call.resolve(status)
71
72
  return@launch
72
73
  }
73
74
 
74
75
  val granted = client.permissionController.getGrantedPermissions()
75
76
  if (granted.containsAll(permissions)) {
76
- val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts)
77
+ val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts, includeSleep)
77
78
  call.resolve(status)
78
79
  return@launch
79
80
  }
@@ -82,6 +83,7 @@ class HealthPlugin : Plugin() {
82
83
  pendingReadTypes = readTypes
83
84
  pendingWriteTypes = writeTypes
84
85
  pendingIncludeWorkouts = includeWorkouts
86
+ pendingIncludeSleep = includeSleep
85
87
 
86
88
  // Create intent using the Health Connect permission contract
87
89
  val intent = permissionContract.createIntent(context, permissions)
@@ -105,21 +107,23 @@ class HealthPlugin : Plugin() {
105
107
  val readTypes = pendingReadTypes
106
108
  val writeTypes = pendingWriteTypes
107
109
  val includeWorkouts = pendingIncludeWorkouts
110
+ val includeSleep = pendingIncludeSleep
108
111
  pendingReadTypes = emptyList()
109
112
  pendingWriteTypes = emptyList()
110
113
  pendingIncludeWorkouts = false
114
+ pendingIncludeSleep = false
111
115
 
112
116
  pluginScope.launch {
113
117
  val client = getClientOrReject(call) ?: return@launch
114
- val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts)
118
+ val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts, includeSleep)
115
119
  call.resolve(status)
116
120
  }
117
121
  }
118
122
 
119
123
  @PluginMethod
120
124
  fun checkAuthorization(call: PluginCall) {
121
- val (readTypes, includeWorkouts) = try {
122
- parseTypeListWithWorkouts(call, "read")
125
+ val (readTypes, includeWorkouts, includeSleep) = try {
126
+ parseTypeListWithWorkoutsAndSleep(call, "read")
123
127
  } catch (e: IllegalArgumentException) {
124
128
  call.reject(e.message, null, e)
125
129
  return
@@ -134,7 +138,7 @@ class HealthPlugin : Plugin() {
134
138
 
135
139
  pluginScope.launch {
136
140
  val client = getClientOrReject(call) ?: return@launch
137
- val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts)
141
+ val status = manager.authorizationStatus(client, readTypes, writeTypes, includeWorkouts, includeSleep)
138
142
  call.resolve(status)
139
143
  }
140
144
  }
@@ -269,21 +273,24 @@ class HealthPlugin : Plugin() {
269
273
  return result
270
274
  }
271
275
 
272
- private fun parseTypeListWithWorkouts(call: PluginCall, key: String): Pair<List<HealthDataType>, Boolean> {
276
+ private fun parseTypeListWithWorkoutsAndSleep(call: PluginCall, key: String): Triple<List<HealthDataType>, Boolean, Boolean> {
273
277
  val array = call.getArray(key) ?: JSArray()
274
278
  val result = mutableListOf<HealthDataType>()
275
279
  var includeWorkouts = false
280
+ var includeSleep = false
276
281
  for (i in 0 until array.length()) {
277
282
  val identifier = array.optString(i, null) ?: continue
278
283
  if (identifier == "workouts") {
279
284
  includeWorkouts = true
285
+ } else if (identifier == "sleep") {
286
+ includeSleep = true
280
287
  } else {
281
288
  val dataType = HealthDataType.from(identifier)
282
289
  ?: throw IllegalArgumentException("Unsupported data type: $identifier")
283
290
  result.add(dataType)
284
291
  }
285
292
  }
286
- return Pair(result, includeWorkouts)
293
+ return Triple(result, includeWorkouts, includeSleep)
287
294
  }
288
295
 
289
296
  private fun getClientOrReject(call: PluginCall): HealthConnectClient? {
@@ -385,6 +392,42 @@ class HealthPlugin : Plugin() {
385
392
  }
386
393
  }
387
394
 
395
+ @PluginMethod
396
+ fun querySleep(call: PluginCall) {
397
+ val limit = (call.getInt("limit") ?: DEFAULT_LIMIT).coerceAtLeast(0)
398
+ val ascending = call.getBoolean("ascending") ?: false
399
+
400
+ val startInstant = try {
401
+ manager.parseInstant(call.getString("startDate"), Instant.now().minus(DEFAULT_PAST_DURATION))
402
+ } catch (e: DateTimeParseException) {
403
+ call.reject(e.message, null, e)
404
+ return
405
+ }
406
+
407
+ val endInstant = try {
408
+ manager.parseInstant(call.getString("endDate"), Instant.now())
409
+ } catch (e: DateTimeParseException) {
410
+ call.reject(e.message, null, e)
411
+ return
412
+ }
413
+
414
+ if (endInstant.isBefore(startInstant)) {
415
+ call.reject("endDate must be greater than or equal to startDate")
416
+ return
417
+ }
418
+
419
+ pluginScope.launch {
420
+ val client = getClientOrReject(call) ?: return@launch
421
+ try {
422
+ val sleepSessions = manager.querySleep(client, startInstant, endInstant, limit, ascending)
423
+ val result = JSObject().apply { put("sleepSessions", sleepSessions) }
424
+ call.resolve(result)
425
+ } catch (e: Exception) {
426
+ call.reject(e.message ?: "Failed to query sleep sessions.", null, e)
427
+ }
428
+ }
429
+ }
430
+
388
431
  companion object {
389
432
  private const val DEFAULT_LIMIT = 100
390
433
  private val DEFAULT_PAST_DURATION: Duration = Duration.ofDays(1)
package/dist/docs.json CHANGED
@@ -172,6 +172,38 @@
172
172
  "QueryWorkoutsOptions"
173
173
  ],
174
174
  "slug": "queryworkouts"
175
+ },
176
+ {
177
+ "name": "querySleep",
178
+ "signature": "(options: QuerySleepOptions) => Promise<QuerySleepResult>",
179
+ "parameters": [
180
+ {
181
+ "name": "options",
182
+ "docs": "Query options including date range, limit, and sort order",
183
+ "type": "QuerySleepOptions"
184
+ }
185
+ ],
186
+ "returns": "Promise<QuerySleepResult>",
187
+ "tags": [
188
+ {
189
+ "name": "param",
190
+ "text": "options Query options including date range, limit, and sort order"
191
+ },
192
+ {
193
+ "name": "returns",
194
+ "text": "A promise that resolves with the sleep sessions"
195
+ },
196
+ {
197
+ "name": "throws",
198
+ "text": "An error if something went wrong"
199
+ }
200
+ ],
201
+ "docs": "Queries sleep sessions from the native health store on Android (Health Connect).",
202
+ "complexTypes": [
203
+ "QuerySleepResult",
204
+ "QuerySleepOptions"
205
+ ],
206
+ "slug": "querysleep"
175
207
  }
176
208
  ],
177
209
  "properties": []
@@ -601,6 +633,162 @@
601
633
  "type": "boolean | undefined"
602
634
  }
603
635
  ]
636
+ },
637
+ {
638
+ "name": "QuerySleepResult",
639
+ "slug": "querysleepresult",
640
+ "docs": "",
641
+ "tags": [],
642
+ "methods": [],
643
+ "properties": [
644
+ {
645
+ "name": "sleepSessions",
646
+ "tags": [],
647
+ "docs": "",
648
+ "complexTypes": [
649
+ "SleepSession"
650
+ ],
651
+ "type": "SleepSession[]"
652
+ }
653
+ ]
654
+ },
655
+ {
656
+ "name": "SleepSession",
657
+ "slug": "sleepsession",
658
+ "docs": "",
659
+ "tags": [],
660
+ "methods": [],
661
+ "properties": [
662
+ {
663
+ "name": "title",
664
+ "tags": [],
665
+ "docs": "Title/name of the sleep session (if available).",
666
+ "complexTypes": [],
667
+ "type": "string | undefined"
668
+ },
669
+ {
670
+ "name": "duration",
671
+ "tags": [],
672
+ "docs": "Duration of the sleep session in seconds.",
673
+ "complexTypes": [],
674
+ "type": "number"
675
+ },
676
+ {
677
+ "name": "startDate",
678
+ "tags": [],
679
+ "docs": "ISO 8601 start date of the sleep session.",
680
+ "complexTypes": [],
681
+ "type": "string"
682
+ },
683
+ {
684
+ "name": "endDate",
685
+ "tags": [],
686
+ "docs": "ISO 8601 end date of the sleep session.",
687
+ "complexTypes": [],
688
+ "type": "string"
689
+ },
690
+ {
691
+ "name": "stages",
692
+ "tags": [],
693
+ "docs": "Array of sleep stages during the session (if available).",
694
+ "complexTypes": [
695
+ "SleepStageRecord"
696
+ ],
697
+ "type": "SleepStageRecord[] | undefined"
698
+ },
699
+ {
700
+ "name": "sourceName",
701
+ "tags": [],
702
+ "docs": "Source name that recorded the sleep session.",
703
+ "complexTypes": [],
704
+ "type": "string | undefined"
705
+ },
706
+ {
707
+ "name": "sourceId",
708
+ "tags": [],
709
+ "docs": "Source bundle identifier.",
710
+ "complexTypes": [],
711
+ "type": "string | undefined"
712
+ },
713
+ {
714
+ "name": "metadata",
715
+ "tags": [],
716
+ "docs": "Additional metadata (if available).",
717
+ "complexTypes": [
718
+ "Record"
719
+ ],
720
+ "type": "Record<string, string>"
721
+ }
722
+ ]
723
+ },
724
+ {
725
+ "name": "SleepStageRecord",
726
+ "slug": "sleepstagerecord",
727
+ "docs": "",
728
+ "tags": [],
729
+ "methods": [],
730
+ "properties": [
731
+ {
732
+ "name": "stage",
733
+ "tags": [],
734
+ "docs": "The sleep stage type.",
735
+ "complexTypes": [
736
+ "SleepStage"
737
+ ],
738
+ "type": "SleepStage"
739
+ },
740
+ {
741
+ "name": "startDate",
742
+ "tags": [],
743
+ "docs": "ISO 8601 start date of this sleep stage.",
744
+ "complexTypes": [],
745
+ "type": "string"
746
+ },
747
+ {
748
+ "name": "endDate",
749
+ "tags": [],
750
+ "docs": "ISO 8601 end date of this sleep stage.",
751
+ "complexTypes": [],
752
+ "type": "string"
753
+ }
754
+ ]
755
+ },
756
+ {
757
+ "name": "QuerySleepOptions",
758
+ "slug": "querysleepoptions",
759
+ "docs": "",
760
+ "tags": [],
761
+ "methods": [],
762
+ "properties": [
763
+ {
764
+ "name": "startDate",
765
+ "tags": [],
766
+ "docs": "Inclusive ISO 8601 start date (defaults to now - 1 day).",
767
+ "complexTypes": [],
768
+ "type": "string | undefined"
769
+ },
770
+ {
771
+ "name": "endDate",
772
+ "tags": [],
773
+ "docs": "Exclusive ISO 8601 end date (defaults to now).",
774
+ "complexTypes": [],
775
+ "type": "string | undefined"
776
+ },
777
+ {
778
+ "name": "limit",
779
+ "tags": [],
780
+ "docs": "Maximum number of sleep sessions to return (defaults to 100).",
781
+ "complexTypes": [],
782
+ "type": "number | undefined"
783
+ },
784
+ {
785
+ "name": "ascending",
786
+ "tags": [],
787
+ "docs": "Return results sorted ascending by start date (defaults to false).",
788
+ "complexTypes": [],
789
+ "type": "boolean | undefined"
790
+ }
791
+ ]
604
792
  }
605
793
  ],
606
794
  "enums": [],
@@ -608,7 +796,7 @@
608
796
  {
609
797
  "name": "ReadAuthorizationType",
610
798
  "slug": "readauthorizationtype",
611
- "docs": "Data types that can be requested for read authorization.\nIncludes 'workouts' for querying workout sessions via queryWorkouts().",
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().",
612
800
  "types": [
613
801
  {
614
802
  "text": "HealthDataType",
@@ -619,6 +807,10 @@
619
807
  {
620
808
  "text": "'workouts'",
621
809
  "complexTypes": []
810
+ },
811
+ {
812
+ "text": "'sleep'",
813
+ "complexTypes": []
622
814
  }
623
815
  ]
624
816
  },
@@ -792,6 +984,45 @@
792
984
  "complexTypes": []
793
985
  }
794
986
  ]
987
+ },
988
+ {
989
+ "name": "SleepStage",
990
+ "slug": "sleepstage",
991
+ "docs": "",
992
+ "types": [
993
+ {
994
+ "text": "'unknown'",
995
+ "complexTypes": []
996
+ },
997
+ {
998
+ "text": "'awake'",
999
+ "complexTypes": []
1000
+ },
1001
+ {
1002
+ "text": "'sleeping'",
1003
+ "complexTypes": []
1004
+ },
1005
+ {
1006
+ "text": "'outOfBed'",
1007
+ "complexTypes": []
1008
+ },
1009
+ {
1010
+ "text": "'awakeInBed'",
1011
+ "complexTypes": []
1012
+ },
1013
+ {
1014
+ "text": "'light'",
1015
+ "complexTypes": []
1016
+ },
1017
+ {
1018
+ "text": "'deep'",
1019
+ "complexTypes": []
1020
+ },
1021
+ {
1022
+ "text": "'rem'",
1023
+ "complexTypes": []
1024
+ }
1025
+ ]
795
1026
  }
796
1027
  ],
797
1028
  "pluginConfigs": []
@@ -3,8 +3,9 @@ export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';
3
3
  /**
4
4
  * Data types that can be requested for read authorization.
5
5
  * Includes 'workouts' for querying workout sessions via queryWorkouts().
6
+ * Includes 'sleep' for querying sleep sessions via querySleep().
6
7
  */
7
- export type ReadAuthorizationType = HealthDataType | 'workouts';
8
+ export type ReadAuthorizationType = HealthDataType | 'workouts' | 'sleep';
8
9
  export interface AuthorizationOptions {
9
10
  /**
10
11
  * Data types that should be readable after authorization.
@@ -55,6 +56,7 @@ export interface ReadSamplesResult {
55
56
  samples: HealthSample[];
56
57
  }
57
58
  export type WorkoutType = 'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'other';
59
+ export type SleepStage = 'unknown' | 'awake' | 'sleeping' | 'outOfBed' | 'awakeInBed' | 'light' | 'deep' | 'rem';
58
60
  export interface QueryWorkoutsOptions {
59
61
  /** Optional workout type filter. If omitted, all workout types are returned. */
60
62
  workoutType?: WorkoutType;
@@ -90,6 +92,45 @@ export interface Workout {
90
92
  export interface QueryWorkoutsResult {
91
93
  workouts: Workout[];
92
94
  }
95
+ export interface QuerySleepOptions {
96
+ /** Inclusive ISO 8601 start date (defaults to now - 1 day). */
97
+ startDate?: string;
98
+ /** Exclusive ISO 8601 end date (defaults to now). */
99
+ endDate?: string;
100
+ /** Maximum number of sleep sessions to return (defaults to 100). */
101
+ limit?: number;
102
+ /** Return results sorted ascending by start date (defaults to false). */
103
+ ascending?: boolean;
104
+ }
105
+ export interface SleepStageRecord {
106
+ /** The sleep stage type. */
107
+ stage: SleepStage;
108
+ /** ISO 8601 start date of this sleep stage. */
109
+ startDate: string;
110
+ /** ISO 8601 end date of this sleep stage. */
111
+ endDate: string;
112
+ }
113
+ export interface SleepSession {
114
+ /** Title/name of the sleep session (if available). */
115
+ title?: string;
116
+ /** Duration of the sleep session in seconds. */
117
+ duration: number;
118
+ /** ISO 8601 start date of the sleep session. */
119
+ startDate: string;
120
+ /** ISO 8601 end date of the sleep session. */
121
+ endDate: string;
122
+ /** Array of sleep stages during the session (if available). */
123
+ stages?: SleepStageRecord[];
124
+ /** Source name that recorded the sleep session. */
125
+ sourceName?: string;
126
+ /** Source bundle identifier. */
127
+ sourceId?: string;
128
+ /** Additional metadata (if available). */
129
+ metadata?: Record<string, string>;
130
+ }
131
+ export interface QuerySleepResult {
132
+ sleepSessions: SleepSession[];
133
+ }
93
134
  export interface WriteSampleOptions {
94
135
  dataType: HealthDataType;
95
136
  value: number;
@@ -155,4 +196,12 @@ export interface HealthPlugin {
155
196
  * @throws An error if something went wrong
156
197
  */
157
198
  queryWorkouts(options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
199
+ /**
200
+ * Queries sleep sessions from the native health store on Android (Health Connect).
201
+ *
202
+ * @param options Query options including date range, limit, and sort order
203
+ * @returns A promise that resolves with the sleep sessions
204
+ * @throws An error if something went wrong
205
+ */
206
+ querySleep(options: QuerySleepOptions): Promise<QuerySleepResult>;
158
207
  }
@@ -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 */\nexport type ReadAuthorizationType = HealthDataType | 'workouts';\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 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 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"]}
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"]}
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, QueryWorkoutsOptions, QueryWorkoutsResult, ReadSamplesResult, WriteSampleOptions } from './definitions';
2
+ import type { AuthorizationOptions, AuthorizationStatus, AvailabilityResult, HealthPlugin, 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>;
@@ -12,4 +12,5 @@ export declare class HealthWeb extends WebPlugin implements HealthPlugin {
12
12
  openHealthConnectSettings(): Promise<void>;
13
13
  showPrivacyPolicy(): Promise<void>;
14
14
  queryWorkouts(_options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
15
+ querySleep(_options: QuerySleepOptions): Promise<QuerySleepResult>;
15
16
  }
package/dist/esm/web.js CHANGED
@@ -31,5 +31,8 @@ export class HealthWeb extends WebPlugin {
31
31
  async queryWorkouts(_options) {
32
32
  throw this.unimplemented('Querying workouts is only available on native platforms.');
33
33
  }
34
+ async querySleep(_options) {
35
+ throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
36
+ }
34
37
  }
35
38
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc5C,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;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\n QueryOptions,\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"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgB5C,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;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\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"]}
@@ -38,6 +38,9 @@ class HealthWeb extends core.WebPlugin {
38
38
  async queryWorkouts(_options) {
39
39
  throw this.unimplemented('Querying workouts is only available on native platforms.');
40
40
  }
41
+ async querySleep(_options) {
42
+ throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
43
+ }
41
44
  }
42
45
 
43
46
  var web = /*#__PURE__*/Object.freeze({
@@ -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}\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;;;;;;;;;"}
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;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -37,6 +37,9 @@ var capacitorHealth = (function (exports, core) {
37
37
  async queryWorkouts(_options) {
38
38
  throw this.unimplemented('Querying workouts is only available on native platforms.');
39
39
  }
40
+ async querySleep(_options) {
41
+ throw this.unimplemented('Querying sleep sessions is only available on native platforms.');
42
+ }
40
43
  }
41
44
 
42
45
  var web = /*#__PURE__*/Object.freeze({
@@ -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}\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;;;;;;;;;;;;;;;"}
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;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asiriindatissa/capacitor-health",
3
- "version": "8.4.2",
3
+ "version": "8.4.3",
4
4
  "description": "Capacitor plugin to interact with data from Health Connect on Android",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",