expo-healthkit-module
Version:
Expo module providing Apple HealthKit / Android Health Connect integration for RN / expo apps.
147 lines • 5.15 kB
TypeScript
import type { StyleProp, ViewStyle } from "react-native";
export type OnLoadEventPayload = {
url: string;
};
export type ExpoHealthkitModuleEvents = {
onChange: (params: ChangeEventPayload) => void;
onHealthDataChange?: (params: HealthDataChangePayload) => void;
onBackgroundSyncComplete?: (params: BackgroundSyncCompletePayload) => void;
};
export type ChangeEventPayload = {
value: string;
};
export type HealthDataChangePayload = {
dataType: string;
samplesAdded: number;
timestamp: string;
};
export type BackgroundSyncCompletePayload = {
success: boolean;
syncedDataTypes: string[];
timestamp: string;
error?: string;
};
export type ExpoHealthkitModuleViewProps = {
url: string;
onLoad: (event: {
nativeEvent: OnLoadEventPayload;
}) => void;
style?: StyleProp<ViewStyle>;
};
export interface AuthorizeResult {
success: boolean;
granted: string[];
denied: string[];
error?: string;
}
export interface HealthDataError {
code: "missing_arguments" | "invalid_date" | "internal_error" | "query_error" | "unsupported_identifier" | "unsupported_platform" | "exception" | "permission_denied" | "network_error" | "timeout_error";
message: string;
}
export interface GetHealthDataOptions {
identifier: string;
startDate: string;
endDate: string;
aggregation?: "raw" | "hourly" | "daily" | "weekly" | "monthly";
limit?: number;
ascending?: boolean;
}
export interface HealthDataSample {
type: string;
sourceName: string;
sourceVersion?: string;
device?: string;
creationDate: string;
startDate: string;
endDate: string;
metadata?: Record<string, any>;
unit?: string;
value?: number;
categoryValue?: string | number;
workoutActivityType?: string;
duration?: number;
durationUnit?: string;
totalEnergyBurned?: number;
totalEnergyBurnedUnit?: string;
totalDistance?: number;
totalDistanceUnit?: string;
}
export interface GetHealthDataResult {
success: boolean;
data: HealthDataSample[];
error?: HealthDataError;
}
export interface BackgroundSyncOptions {
enabled: boolean;
syncInterval: number;
dataTypes: string[];
preferredSyncTime?: string;
wifiOnly?: boolean;
minimumBatteryLevel?: number;
}
export interface BackgroundSyncStatus {
enabled: boolean;
lastSync: string | null;
nextScheduledSync?: string | null;
syncedDataTypes?: string[];
failedDataTypes?: string[];
error?: string;
}
export interface BackgroundSyncResult {
success: boolean;
error?: string;
scheduledNextSync?: string;
}
export interface ExportHealthDataOptions {
startDate: string;
endDate: string;
}
export interface ExportedRecordData {
rawRecord: string;
recordClass: string;
metadata: {
dataOrigin: string;
id: string;
clientRecordId: string;
lastModifiedTime: string;
clientRecordVersion: number;
device: {
manufacturer: string;
model: string;
type: number;
};
};
formattedRecord: HealthDataSample;
}
export interface ExportedDataType {
count: number;
records: ExportedRecordData[];
error?: string;
}
export interface ExportHealthDataResult {
success: boolean;
data: Record<string, ExportedDataType>;
exportInfo?: {
startDate: string;
endDate: string;
exportTime: string;
totalTypes: number;
availableTypes: string[];
};
error?: {
code: string;
message: string;
};
}
export type HealthDataType = "HKQuantityTypeIdentifierActiveEnergyBurned" | "HKQuantityTypeIdentifierAppleExerciseTime" | "HKQuantityTypeIdentifierAppleStandTime" | "HKQuantityTypeIdentifierBasalEnergyBurned" | "HKQuantityTypeIdentifierDistanceCycling" | "HKQuantityTypeIdentifierDistanceWalkingRunning" | "HKQuantityTypeIdentifierFlightsClimbed" | "HKQuantityTypeIdentifierHeartRate" | "HKQuantityTypeIdentifierHeartRateRecoveryOneMinute" | "HKQuantityTypeIdentifierHeartRateVariabilitySDNN" | "HKQuantityTypeIdentifierRespiratoryRate" | "HKQuantityTypeIdentifierRestingHeartRate" | "HKQuantityTypeIdentifierStepCount" | "HKQuantityTypeIdentifierVO2Max" | "HKCategoryTypeIdentifierSleepAnalysis" | "HKWorkoutTypeIdentifier" | "stepCount" | "heartRate" | "activeEnergyBurned" | "totalEnergyBurned" | "distanceWalkingRunning" | "flightsClimbed" | "restingHeartRate" | "respiratoryRate" | "vo2Max" | "sleepAnalysis" | "workout" | "heartRateVariabilitySDNN";
export type HealthUnit = "count" | "count/min" | "kcal" | "km" | "min" | "ms" | "ml/(kg*min)" | "s";
export interface HealthDataQuery extends GetHealthDataOptions {
identifier: HealthDataType;
}
export interface TypedHealthDataResult<T extends HealthDataType> extends Omit<GetHealthDataResult, "data"> {
data: Array<HealthDataSample & {
type: T;
}>;
}
export type HealthKitEventListener<T extends keyof ExpoHealthkitModuleEvents> = ExpoHealthkitModuleEvents[T] extends (params: infer P) => void ? P : never;
//# sourceMappingURL=ExpoHealthkitModule.types.d.ts.map