@interval-health/capacitor-health 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ package app.capgo.plugin.health
3
3
  import androidx.health.connect.client.permission.HealthPermission
4
4
  import androidx.health.connect.client.records.ActiveCaloriesBurnedRecord
5
5
  import androidx.health.connect.client.records.DistanceRecord
6
+ import androidx.health.connect.client.records.ExerciseSessionRecord
6
7
  import androidx.health.connect.client.records.HeartRateRecord
7
8
  import androidx.health.connect.client.records.Record
8
9
  import androidx.health.connect.client.records.SleepSessionRecord
@@ -20,7 +21,9 @@ enum class HealthDataType(
20
21
  CALORIES("calories", ActiveCaloriesBurnedRecord::class, "kilocalorie"),
21
22
  HEART_RATE("heartRate", HeartRateRecord::class, "bpm"),
22
23
  WEIGHT("weight", WeightRecord::class, "kilogram"),
23
- SLEEP("sleep", SleepSessionRecord::class, "minute");
24
+ SLEEP("sleep", SleepSessionRecord::class, "minute"),
25
+ MOBILITY("mobility", StepsRecord::class, "mixed"), // Using StepsRecord as placeholder
26
+ WORKOUT("workout", ExerciseSessionRecord::class, "minute");
24
27
 
25
28
  val readPermission: String
26
29
  get() = HealthPermission.getReadPermission(recordClass)
package/dist/docs.json CHANGED
@@ -440,6 +440,26 @@
440
440
  {
441
441
  "text": "'sleep'",
442
442
  "complexTypes": []
443
+ },
444
+ {
445
+ "text": "'mobility'",
446
+ "complexTypes": []
447
+ },
448
+ {
449
+ "text": "'activity'",
450
+ "complexTypes": []
451
+ },
452
+ {
453
+ "text": "'heart'",
454
+ "complexTypes": []
455
+ },
456
+ {
457
+ "text": "'body'",
458
+ "complexTypes": []
459
+ },
460
+ {
461
+ "text": "'workout'",
462
+ "complexTypes": []
443
463
  }
444
464
  ]
445
465
  },
@@ -471,6 +491,10 @@
471
491
  {
472
492
  "text": "'minute'",
473
493
  "complexTypes": []
494
+ },
495
+ {
496
+ "text": "'mixed'",
497
+ "complexTypes": []
474
498
  }
475
499
  ]
476
500
  },
@@ -1,6 +1,24 @@
1
- export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep';
2
- export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute';
1
+ export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep' | 'mobility' | 'activity' | 'heart' | 'body' | 'workout';
2
+ export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute' | 'mixed';
3
3
  export type SleepState = 'inBed' | 'asleep' | 'awake' | 'asleepCore' | 'asleepDeep' | 'asleepREM' | 'unknown';
4
+ export interface WorkoutHeartRateZones {
5
+ zone1?: number;
6
+ zone2?: number;
7
+ zone3?: number;
8
+ zone4?: number;
9
+ zone5?: number;
10
+ }
11
+ export interface WorkoutData {
12
+ date: string;
13
+ type: string;
14
+ duration: number;
15
+ distance?: number;
16
+ calories?: number;
17
+ source?: string;
18
+ avgHeartRate?: number;
19
+ maxHeartRate?: number;
20
+ zones?: WorkoutHeartRateZones;
21
+ }
4
22
  export interface AuthorizationOptions {
5
23
  /** Data types that should be readable after authorization. */
6
24
  read?: HealthDataType[];
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute';\nexport type SleepState = 'inBed' | 'asleep' | 'awake' | 'asleepCore' | 'asleepDeep' | 'asleepREM' | 'unknown';\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n /** Sleep state (only present when dataType is 'sleep') */\n sleepState?: SleepState;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`, minute for `sleep`).\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<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":[" export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep' | 'mobility' | 'activity' | 'heart' | 'body' | 'workout';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute' | 'mixed';\nexport type SleepState = 'inBed' | 'asleep' | 'awake' | 'asleepCore' | 'asleepDeep' | 'asleepREM' | 'unknown';\n\nexport interface WorkoutHeartRateZones {\n zone1?: number; // 50-60% max HR, in minutes\n zone2?: number; // 60-70% max HR, in minutes\n zone3?: number; // 70-80% max HR, in minutes\n zone4?: number; // 80-90% max HR, in minutes\n zone5?: number; // 90-100% max HR, in minutes\n}\n\nexport interface WorkoutData {\n date: string; // ISO date (YYYY-MM-DD)\n type: string; // Activity type (e.g., \"Running\", \"Cycling\")\n duration: number; // Duration in minutes\n distance?: number; // Distance in miles\n calories?: number; // Calories burned\n source?: string; // Source app name\n avgHeartRate?: number; // Average heart rate in BPM\n maxHeartRate?: number; // Maximum heart rate in BPM\n zones?: WorkoutHeartRateZones; // Heart rate zones\n}\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n /** Sleep state (only present when dataType is 'sleep') */\n sleepState?: SleepState;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`, minute for `sleep`).\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<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}