react-native-health-connect 0.0.1 → 0.1.0-alpha.2
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/LICENSE +20 -0
- package/README.md +35 -0
- package/android/build.gradle +106 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/dev/matinzd/healthconnect/HealthConnectManager.kt +174 -0
- package/android/src/main/java/dev/matinzd/healthconnect/HealthConnectModule.kt +73 -0
- package/android/src/main/java/dev/matinzd/healthconnect/HealthConnectPackage.kt +35 -0
- package/android/src/main/java/dev/matinzd/healthconnect/permissions/HCPermissionManager.kt +74 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactActiveCaloriesBurnedRecord.kt +103 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBasalBodyTemperatureRecord.kt +77 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBasalMetabolicRateRecord.kt +96 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBloodGlucoseRecord.kt +84 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBloodPressureRecord.kt +115 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBodyFatRecord.kt +54 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBodyTemperatureRecord.kt +77 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBodyWaterMassRecord.kt +50 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactBoneMassRecord.kt +50 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactCervicalMucusRecord.kt +52 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactCyclingPedalingCadenceRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactDistanceRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactElevationGainedRecord.kt +53 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactExerciseSessionRecord.kt +72 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactFloorsClimbedRecord.kt +60 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactHealthRecord.kt +67 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactHealthRecordImpl.kt +19 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactHeartRateRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactHeartRateVariabilityRmssdRecord.kt +34 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactHeightRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactHydrationRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactIntermenstrualBleedingRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactLeanBodyMassRecord.kt +35 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactMenstruationFlowRecord.kt +34 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactMenstruationPeriodRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactNutritionRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactOvulationTestRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactOxygenSaturationRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactPowerRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactRespiratoryRateRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactRestingHeartRateRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactSexualActivityRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactSleepSessionRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactSleepStageRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactSpeedRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactStepsCadenceRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactStepsRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactTotalCaloriesBurnedRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactVo2MaxRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactWeightRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/records/ReactWheelchairPushesRecord.kt +33 -0
- package/android/src/main/java/dev/matinzd/healthconnect/utils/ExceptionsUtils.kt +39 -0
- package/android/src/main/java/dev/matinzd/healthconnect/utils/HealthConnectUtils.kt +255 -0
- package/android/src/newarch/HealthConnectSpec.kt +7 -0
- package/android/src/oldarch/HealthConnectSpec.kt +34 -0
- package/lib/commonjs/NativeHealthConnect.js +10 -0
- package/lib/commonjs/NativeHealthConnect.js.map +1 -0
- package/lib/commonjs/constants.js +165 -0
- package/lib/commonjs/constants.js.map +1 -0
- package/lib/commonjs/errors.js +13 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/index.js +104 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types/aggregate.types.js +6 -0
- package/lib/commonjs/types/aggregate.types.js.map +1 -0
- package/lib/commonjs/types/base.types.js +2 -0
- package/lib/commonjs/types/base.types.js.map +1 -0
- package/lib/commonjs/types/index.js +39 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/records.types.js +6 -0
- package/lib/commonjs/types/records.types.js.map +1 -0
- package/lib/commonjs/types/results.types.js +6 -0
- package/lib/commonjs/types/results.types.js.map +1 -0
- package/lib/module/NativeHealthConnect.js +3 -0
- package/lib/module/NativeHealthConnect.js.map +1 -0
- package/lib/module/constants.js +150 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/errors.js +6 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +68 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types/aggregate.types.js +2 -0
- package/lib/module/types/aggregate.types.js.map +1 -0
- package/lib/module/types/base.types.js +2 -0
- package/lib/module/types/base.types.js.map +1 -0
- package/lib/module/types/index.js +5 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/records.types.js +2 -0
- package/lib/module/types/records.types.js.map +1 -0
- package/lib/module/types/results.types.js +2 -0
- package/lib/module/types/results.types.js.map +1 -0
- package/lib/typescript/NativeHealthConnect.d.ts +28 -0
- package/lib/typescript/NativeHealthConnect.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +150 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/errors.d.ts +4 -0
- package/lib/typescript/errors.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types/aggregate.types.d.ts +42 -0
- package/lib/typescript/types/aggregate.types.d.ts.map +1 -0
- package/lib/typescript/types/base.types.d.ts +85 -0
- package/lib/typescript/types/base.types.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +9 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/records.types.d.ts +74 -0
- package/lib/typescript/types/records.types.d.ts.map +1 -0
- package/lib/typescript/types/results.types.d.ts +56 -0
- package/lib/typescript/types/results.types.d.ts.map +1 -0
- package/package.json +158 -6
- package/src/NativeHealthConnect.ts +44 -0
- package/src/constants.ts +157 -0
- package/src/errors.ts +5 -0
- package/src/index.tsx +132 -0
- package/src/types/aggregate.types.ts +60 -0
- package/src/types/base.types.ts +110 -0
- package/src/types/index.ts +10 -0
- package/src/types/records.types.ts +113 -0
- package/src/types/results.types.ts +105 -0
package/src/index.tsx
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { HealthConnectError } from './errors';
|
|
3
|
+
import type {
|
|
4
|
+
AggregateRequest,
|
|
5
|
+
AggregateResult,
|
|
6
|
+
AggregateResultRecordType,
|
|
7
|
+
HealthConnectRecord,
|
|
8
|
+
Permission,
|
|
9
|
+
ReadRecordsOptions,
|
|
10
|
+
RecordResult,
|
|
11
|
+
RecordType,
|
|
12
|
+
} from './types';
|
|
13
|
+
import type { TimeRangeFilter } from './types/base.types';
|
|
14
|
+
|
|
15
|
+
const LINKING_ERROR =
|
|
16
|
+
`The package 'react-native-health-connect' doesn't seem to be linked. Make sure: \n\n` +
|
|
17
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
18
|
+
'- You rebuilt the app after installing the package\n' +
|
|
19
|
+
'- You are not using Expo Go\n';
|
|
20
|
+
|
|
21
|
+
const PLATFORM_NOT_SUPPORTED_ERROR = `Platform not supported. This package only supports Android.`;
|
|
22
|
+
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
25
|
+
|
|
26
|
+
const moduleProxy = (message: string) =>
|
|
27
|
+
new Proxy(
|
|
28
|
+
{},
|
|
29
|
+
{
|
|
30
|
+
get() {
|
|
31
|
+
throw new Error(message);
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const HealthConnectModule = Platform.select({
|
|
37
|
+
android: isTurboModuleEnabled
|
|
38
|
+
? require('./NativeHealthConnect').default
|
|
39
|
+
: NativeModules.HealthConnect,
|
|
40
|
+
ios: moduleProxy(PLATFORM_NOT_SUPPORTED_ERROR),
|
|
41
|
+
default: moduleProxy(PLATFORM_NOT_SUPPORTED_ERROR),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const HealthConnect = HealthConnectModule
|
|
45
|
+
? HealthConnectModule
|
|
46
|
+
: moduleProxy(LINKING_ERROR);
|
|
47
|
+
|
|
48
|
+
const DEFAULT_PROVIDER_PACKAGE_NAME = 'com.google.android.apps.healthdata';
|
|
49
|
+
|
|
50
|
+
export function isAvailable(
|
|
51
|
+
providerPackageNames: string[] = [DEFAULT_PROVIDER_PACKAGE_NAME]
|
|
52
|
+
): Promise<boolean> {
|
|
53
|
+
return HealthConnect.isAvailable(providerPackageNames);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function initialize(
|
|
57
|
+
providerPackageNames: string[] = [DEFAULT_PROVIDER_PACKAGE_NAME]
|
|
58
|
+
): Promise<boolean> {
|
|
59
|
+
return HealthConnect.initialize(providerPackageNames);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Request permissions to access Health Connect data
|
|
64
|
+
* @param permissions list of permissions to request
|
|
65
|
+
* @returns granted permissions
|
|
66
|
+
*/
|
|
67
|
+
export function requestPermission(
|
|
68
|
+
permissions: Permission[],
|
|
69
|
+
providerPackageName = DEFAULT_PROVIDER_PACKAGE_NAME
|
|
70
|
+
): Promise<Permission> {
|
|
71
|
+
return HealthConnect.requestPermission(permissions, providerPackageName);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function revokeAllPermissions(): void {
|
|
75
|
+
return HealthConnect.revokeAllPermissions();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function readRecords<T extends RecordType>(
|
|
79
|
+
recordType: T,
|
|
80
|
+
options: ReadRecordsOptions
|
|
81
|
+
): Promise<RecordResult<T>[]> {
|
|
82
|
+
return HealthConnect.readRecords(recordType, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function insertRecords(
|
|
86
|
+
records: HealthConnectRecord[]
|
|
87
|
+
): Promise<string[]> {
|
|
88
|
+
if (records.length === 0) {
|
|
89
|
+
throw new HealthConnectError(
|
|
90
|
+
'You must provide at least one record',
|
|
91
|
+
'insertRecords'
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const recordTypes = records.map((record) => record.recordType);
|
|
96
|
+
const uniqueRecordTypes = new Set(recordTypes);
|
|
97
|
+
if (uniqueRecordTypes.size > 1) {
|
|
98
|
+
throw new HealthConnectError(
|
|
99
|
+
'All records must have the same type',
|
|
100
|
+
'insertRecords'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return HealthConnect.insertRecords(records);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function aggregateRecord<T extends AggregateResultRecordType>(
|
|
108
|
+
request: AggregateRequest<T>
|
|
109
|
+
): Promise<AggregateResult<T>> {
|
|
110
|
+
return HealthConnect.aggregateRecord(request);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function deleteRecordsByUuids(
|
|
114
|
+
recordType: RecordType,
|
|
115
|
+
recordIdsList: string[],
|
|
116
|
+
clientRecordIdsList: string[]
|
|
117
|
+
): Promise<void> {
|
|
118
|
+
return HealthConnect.deleteRecordsByUuids(
|
|
119
|
+
recordType,
|
|
120
|
+
recordIdsList,
|
|
121
|
+
clientRecordIdsList
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function deleteRecordsByTimeRange(
|
|
126
|
+
recordType: RecordType,
|
|
127
|
+
timeRangeFilter: TimeRangeFilter
|
|
128
|
+
): Promise<void> {
|
|
129
|
+
return HealthConnect.deleteRecordsByTimeRange(recordType, timeRangeFilter);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export * from './constants';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EnergyResult,
|
|
3
|
+
PressureResult,
|
|
4
|
+
TimeRangeFilter,
|
|
5
|
+
} from './base.types';
|
|
6
|
+
|
|
7
|
+
interface BaseAggregate {
|
|
8
|
+
dataOrigins: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ActiveCaloriesBurnedAggregateResult extends BaseAggregate {
|
|
12
|
+
recordType: 'ActiveCaloriesBurned';
|
|
13
|
+
ACTIVE_CALORIES_TOTAL: EnergyResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface BasalMetabolicRateAggregateResult extends BaseAggregate {
|
|
17
|
+
recordType: 'BasalMetabolicRate';
|
|
18
|
+
BASAL_CALORIES_TOTAL: EnergyResult;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface BloodPressureAggregateResult extends BaseAggregate {
|
|
22
|
+
recordType: 'BloodPressure';
|
|
23
|
+
SYSTOLIC_AVG: PressureResult;
|
|
24
|
+
SYSTOLIC_MIN: PressureResult;
|
|
25
|
+
DIASTOLIC_AVG: PressureResult;
|
|
26
|
+
DIASTOLIC_MIN: PressureResult;
|
|
27
|
+
DIASTOLIC_MAX: PressureResult;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface ExerciseSessionAggregateResult extends BaseAggregate {
|
|
31
|
+
recordType: 'ExerciseSession';
|
|
32
|
+
EXERCISE_DURATION_TOTAL: {
|
|
33
|
+
inSeconds: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface FloorsClimbedAggregateResult extends BaseAggregate {
|
|
38
|
+
recordType: 'FloorsClimbed';
|
|
39
|
+
FLOORS_CLIMBED_TOTAL: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type AggregateRecordResult =
|
|
43
|
+
| ActiveCaloriesBurnedAggregateResult
|
|
44
|
+
| BasalMetabolicRateAggregateResult
|
|
45
|
+
| BloodPressureAggregateResult
|
|
46
|
+
| ExerciseSessionAggregateResult
|
|
47
|
+
| FloorsClimbedAggregateResult;
|
|
48
|
+
|
|
49
|
+
export type AggregateResultRecordType = AggregateRecordResult['recordType'];
|
|
50
|
+
|
|
51
|
+
export type AggregateResult<T extends AggregateResultRecordType> = Omit<
|
|
52
|
+
Extract<AggregateRecordResult, { recordType: T }>,
|
|
53
|
+
'recordType'
|
|
54
|
+
>;
|
|
55
|
+
|
|
56
|
+
export interface AggregateRequest<T extends AggregateResultRecordType> {
|
|
57
|
+
recordType: T;
|
|
58
|
+
timeRangeFilter: TimeRangeFilter;
|
|
59
|
+
dataOriginFilter?: string[];
|
|
60
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
export interface BaseRecord {
|
|
2
|
+
metadata?: Metadata;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface InstantaneousRecord extends BaseRecord {
|
|
6
|
+
time: string;
|
|
7
|
+
zoneOffset?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IntervalRecord extends BaseRecord {
|
|
11
|
+
startTime: string;
|
|
12
|
+
startZoneOffset?: string;
|
|
13
|
+
endTime: string;
|
|
14
|
+
endZoneOffset?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Metadata {
|
|
18
|
+
id: string;
|
|
19
|
+
// package name of the app that created the record
|
|
20
|
+
dataOrigin: string;
|
|
21
|
+
lastModifiedTime: string;
|
|
22
|
+
clientRecordId?: string;
|
|
23
|
+
clientRecordVersion: number;
|
|
24
|
+
// see: https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/metadata/Device
|
|
25
|
+
device: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type TimeRangeFilter =
|
|
29
|
+
| {
|
|
30
|
+
operator: 'between';
|
|
31
|
+
startTime: string;
|
|
32
|
+
endTime: string;
|
|
33
|
+
}
|
|
34
|
+
| {
|
|
35
|
+
operator: 'after';
|
|
36
|
+
startTime: string;
|
|
37
|
+
}
|
|
38
|
+
| {
|
|
39
|
+
operator: 'before';
|
|
40
|
+
endTime: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export interface Energy {
|
|
44
|
+
value: number;
|
|
45
|
+
unit: 'calories' | 'joules' | 'kilocalories' | 'kilojoules';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface EnergyResult {
|
|
49
|
+
inCalories: number;
|
|
50
|
+
inJoules: number;
|
|
51
|
+
inKilocalories: number;
|
|
52
|
+
inKilojoules: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BloodGlucose {
|
|
56
|
+
value: number;
|
|
57
|
+
unit: 'milligramsPerDeciliter' | 'millimolesPerLiter';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface Power {
|
|
61
|
+
value: number;
|
|
62
|
+
unit: 'watts' | 'kilocaloriesPerDay';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface Temperature {
|
|
66
|
+
value: number;
|
|
67
|
+
unit: 'celsius' | 'fahrenheit';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface Pressure {
|
|
71
|
+
value: number;
|
|
72
|
+
unit: 'millimetersOfMercury';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface PressureResult {
|
|
76
|
+
inMillimetersOfMercury: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface Mass {
|
|
80
|
+
value: number;
|
|
81
|
+
unit:
|
|
82
|
+
| 'grams'
|
|
83
|
+
| 'kilograms'
|
|
84
|
+
| 'milligrams'
|
|
85
|
+
| 'micrograms'
|
|
86
|
+
| 'ounces'
|
|
87
|
+
| 'pounds';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface MassResult {
|
|
91
|
+
inGrams: number;
|
|
92
|
+
inKilograms: number;
|
|
93
|
+
inMilligrams: number;
|
|
94
|
+
inMicrograms: number;
|
|
95
|
+
inOunces: number;
|
|
96
|
+
inPounds: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface Length {
|
|
100
|
+
value: number;
|
|
101
|
+
unit: 'meters' | 'kilometers' | 'miles' | 'inches' | 'feet';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface LengthResult {
|
|
105
|
+
inMeters: number;
|
|
106
|
+
inKilometers: number;
|
|
107
|
+
inMiles: number;
|
|
108
|
+
inInches: number;
|
|
109
|
+
inFeet: number;
|
|
110
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Energy,
|
|
3
|
+
InstantaneousRecord,
|
|
4
|
+
IntervalRecord,
|
|
5
|
+
BloodGlucose,
|
|
6
|
+
Power,
|
|
7
|
+
Pressure,
|
|
8
|
+
Temperature,
|
|
9
|
+
TimeRangeFilter,
|
|
10
|
+
Mass,
|
|
11
|
+
Length,
|
|
12
|
+
} from './base.types';
|
|
13
|
+
|
|
14
|
+
export interface ActiveCaloriesBurnedRecord extends IntervalRecord {
|
|
15
|
+
recordType: 'ActiveCaloriesBurned';
|
|
16
|
+
energy: Energy;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BasalBodyTemperatureRecord extends InstantaneousRecord {
|
|
20
|
+
recordType: 'BasalBodyTemperature';
|
|
21
|
+
temperature: Temperature;
|
|
22
|
+
measurementLocation?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BasalMetabolicRateRecord extends InstantaneousRecord {
|
|
26
|
+
recordType: 'BasalMetabolicRate';
|
|
27
|
+
basalMetabolicRate: Power;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BloodGlucoseRecord extends InstantaneousRecord {
|
|
31
|
+
recordType: 'BloodGlucose';
|
|
32
|
+
level: BloodGlucose;
|
|
33
|
+
specimenSource: number;
|
|
34
|
+
mealType: number;
|
|
35
|
+
relationToMeal: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface BloodPressureRecord extends InstantaneousRecord {
|
|
39
|
+
recordType: 'BloodPressure';
|
|
40
|
+
systolic: Pressure;
|
|
41
|
+
diastolic: Pressure;
|
|
42
|
+
bodyPosition: number;
|
|
43
|
+
measurementLocation: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface BodyFatRecord extends InstantaneousRecord {
|
|
47
|
+
recordType: 'BodyFat';
|
|
48
|
+
percentage: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BodyTemperatureRecord extends InstantaneousRecord {
|
|
52
|
+
recordType: 'BodyTemperature';
|
|
53
|
+
temperature: Temperature;
|
|
54
|
+
measurementLocation?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface BodyWaterMassRecord extends InstantaneousRecord {
|
|
58
|
+
recordType: 'BodyWaterMass';
|
|
59
|
+
mass: Mass;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface BoneMassRecord extends InstantaneousRecord {
|
|
63
|
+
recordType: 'BoneMass';
|
|
64
|
+
mass: Mass;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface CervicalMucusRecord extends InstantaneousRecord {
|
|
68
|
+
recordType: 'CervicalMucus';
|
|
69
|
+
appearance?: number;
|
|
70
|
+
sensation?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ElevationGainedRecord extends IntervalRecord {
|
|
74
|
+
recordType: 'ElevationGained';
|
|
75
|
+
elevation: Length;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ExerciseSessionRecord extends IntervalRecord {
|
|
79
|
+
recordType: 'ExerciseSession';
|
|
80
|
+
exerciseType: number;
|
|
81
|
+
title?: string;
|
|
82
|
+
notes?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface FloorsClimbedRecord extends IntervalRecord {
|
|
86
|
+
recordType: 'FloorsClimbed';
|
|
87
|
+
floors: number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type HealthConnectRecord =
|
|
91
|
+
| ActiveCaloriesBurnedRecord
|
|
92
|
+
| BasalBodyTemperatureRecord
|
|
93
|
+
| BasalMetabolicRateRecord
|
|
94
|
+
| BloodGlucoseRecord
|
|
95
|
+
| BloodPressureRecord
|
|
96
|
+
| BodyFatRecord
|
|
97
|
+
| BodyTemperatureRecord
|
|
98
|
+
| BodyWaterMassRecord
|
|
99
|
+
| BoneMassRecord
|
|
100
|
+
| CervicalMucusRecord
|
|
101
|
+
| ElevationGainedRecord
|
|
102
|
+
| ExerciseSessionRecord
|
|
103
|
+
| FloorsClimbedRecord;
|
|
104
|
+
|
|
105
|
+
export type RecordType = HealthConnectRecord['recordType'];
|
|
106
|
+
|
|
107
|
+
export interface ReadRecordsOptions {
|
|
108
|
+
timeRangeFilter: TimeRangeFilter;
|
|
109
|
+
dataOriginFilter?: string[];
|
|
110
|
+
ascendingOrder?: boolean;
|
|
111
|
+
pageSize?: number;
|
|
112
|
+
pageToken?: string;
|
|
113
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EnergyResult,
|
|
3
|
+
LengthResult,
|
|
4
|
+
MassResult,
|
|
5
|
+
PressureResult,
|
|
6
|
+
} from './base.types';
|
|
7
|
+
import type {
|
|
8
|
+
ActiveCaloriesBurnedRecord,
|
|
9
|
+
BasalBodyTemperatureRecord,
|
|
10
|
+
BasalMetabolicRateRecord,
|
|
11
|
+
BloodGlucoseRecord,
|
|
12
|
+
BloodPressureRecord,
|
|
13
|
+
BodyFatRecord,
|
|
14
|
+
BodyTemperatureRecord,
|
|
15
|
+
BodyWaterMassRecord,
|
|
16
|
+
BoneMassRecord,
|
|
17
|
+
CervicalMucusRecord,
|
|
18
|
+
ElevationGainedRecord,
|
|
19
|
+
ExerciseSessionRecord,
|
|
20
|
+
FloorsClimbedRecord,
|
|
21
|
+
RecordType,
|
|
22
|
+
} from './records.types';
|
|
23
|
+
|
|
24
|
+
interface ActiveCaloriesBurnedRecordResult
|
|
25
|
+
extends Omit<ActiveCaloriesBurnedRecord, 'energy'> {
|
|
26
|
+
energy: EnergyResult;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface BasalBodyTemperatureRecordResult
|
|
30
|
+
extends Omit<BasalBodyTemperatureRecord, 'temperature'> {
|
|
31
|
+
temperature: {
|
|
32
|
+
inFahrenheit: number;
|
|
33
|
+
inCelsius: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface BasalMetabolicRateRecordResult
|
|
38
|
+
extends Omit<BasalMetabolicRateRecord, 'basalMetabolicRate'> {
|
|
39
|
+
basalMetabolicRate: {
|
|
40
|
+
inKilocaloriesPerDay: number;
|
|
41
|
+
inWatts: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface BloodGlucoseRecordResult extends Omit<BloodGlucoseRecord, 'level'> {
|
|
46
|
+
level: {
|
|
47
|
+
inMillimolesPerLiter: number;
|
|
48
|
+
inMilligramsPerDeciliter: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface BloodPressureRecordResult
|
|
53
|
+
extends Omit<BloodPressureRecord, 'systolic' | 'diastolic'> {
|
|
54
|
+
systolic: PressureResult;
|
|
55
|
+
diastolic: PressureResult;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface BodyTemperatureRecordResult
|
|
59
|
+
extends Omit<BodyTemperatureRecord, 'temperature'> {
|
|
60
|
+
temperature: {
|
|
61
|
+
inFahrenheit: number;
|
|
62
|
+
inCelsius: number;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface BodyFatRecordResult extends BodyFatRecord {}
|
|
67
|
+
|
|
68
|
+
interface BodyWaterMassRecordResult extends Omit<BodyWaterMassRecord, 'mass'> {
|
|
69
|
+
mass: MassResult;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface BoneMassRecordResult extends Omit<BoneMassRecord, 'mass'> {
|
|
73
|
+
mass: MassResult;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface CervicalMucusRecordResult extends CervicalMucusRecord {}
|
|
77
|
+
|
|
78
|
+
interface ElevationGainedRecordResult
|
|
79
|
+
extends Omit<ElevationGainedRecord, 'elevation'> {
|
|
80
|
+
elevation: LengthResult;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ExerciseSessionRecordResult extends ExerciseSessionRecord {}
|
|
84
|
+
|
|
85
|
+
interface FloorsClimbedRecordResult extends FloorsClimbedRecord {}
|
|
86
|
+
|
|
87
|
+
type HealthConnectRecordResult =
|
|
88
|
+
| ActiveCaloriesBurnedRecordResult
|
|
89
|
+
| BasalBodyTemperatureRecordResult
|
|
90
|
+
| BasalMetabolicRateRecordResult
|
|
91
|
+
| BloodGlucoseRecordResult
|
|
92
|
+
| BloodPressureRecordResult
|
|
93
|
+
| BodyFatRecordResult
|
|
94
|
+
| BodyTemperatureRecordResult
|
|
95
|
+
| BodyWaterMassRecordResult
|
|
96
|
+
| BoneMassRecordResult
|
|
97
|
+
| CervicalMucusRecordResult
|
|
98
|
+
| ElevationGainedRecordResult
|
|
99
|
+
| ExerciseSessionRecordResult
|
|
100
|
+
| FloorsClimbedRecordResult;
|
|
101
|
+
|
|
102
|
+
export type RecordResult<T extends RecordType> = Omit<
|
|
103
|
+
Extract<HealthConnectRecordResult, { recordType: T }>,
|
|
104
|
+
'recordType'
|
|
105
|
+
>;
|