@kingstinct/react-native-healthkit 4.2.0 → 4.4.1
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 +1 -1
- package/ios/ReactNativeHealthkit.m +6 -1
- package/ios/ReactNativeHealthkit.swift +365 -176
- package/lib/commonjs/index.ios.js +129 -105
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +58 -44
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +136 -106
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/example/App.js +197 -0
- package/lib/index.ios.js +310 -0
- package/lib/index.js +44 -0
- package/lib/module/index.ios.js +130 -106
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +52 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +127 -104
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/native-types.js +447 -0
- package/lib/src/index.ios.js +314 -0
- package/lib/src/index.js +45 -0
- package/lib/src/native-types.js +453 -0
- package/lib/src/types.js +1 -0
- package/lib/types.js +1 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.ios.d.ts +1 -1
- package/lib/typescript/src/native-types.d.ts +458 -205
- package/lib/typescript/src/types.d.ts +87 -81
- package/package.json +21 -35
- package/src/index.ios.tsx +303 -269
- package/src/index.tsx +63 -45
- package/src/native-types.ts +318 -290
- package/src/types.ts +120 -105
- package/.DS_Store +0 -0
- package/.circleci/config.yml +0 -98
- package/.editorconfig +0 -15
- package/.gitattributes +0 -3
- package/.github/workflows/main.yml +0 -32
- package/.gitignore +0 -60
- package/CONTRIBUTING.md +0 -184
- package/babel.config.js +0 -3
- package/example-expo/.expo/README.md +0 -15
- package/example-expo/.expo/devices.json +0 -8
- package/example-expo/.expo/packager-info.json +0 -5
- package/example-expo/.expo/settings.json +0 -9
- package/example-expo/.expo-shared/assets.json +0 -4
- package/example-expo/.gitignore +0 -14
- package/example-expo/App.tsx +0 -376
- package/example-expo/app.json +0 -43
- package/example-expo/assets/adaptive-icon.png +0 -0
- package/example-expo/assets/favicon.png +0 -0
- package/example-expo/assets/icon.png +0 -0
- package/example-expo/assets/splash.png +0 -0
- package/example-expo/babel.config.js +0 -8
- package/example-expo/build-1653040579600.ipa +0 -0
- package/example-expo/build-1653041063216.ipa +0 -0
- package/example-expo/eas.json +0 -18
- package/example-expo/package.json +0 -32
- package/example-expo/tsconfig.json +0 -6
- package/example-expo/yarn.lock +0 -6857
- package/lib/typescript/example-expo/App.d.ts +0 -3
- package/lib/typescript/src/__tests__/index.test.d.ts +0 -0
- package/src/__tests__/index.test.tsx +0 -1
- package/tsconfig.json +0 -27
- package/yarn.lock +0 -10241
package/src/native-types.ts
CHANGED
|
@@ -1,20 +1,126 @@
|
|
|
1
1
|
import {
|
|
2
|
-
NativeModules,
|
|
3
2
|
NativeEventEmitter,
|
|
4
|
-
|
|
5
|
-
} from 'react-native'
|
|
3
|
+
NativeModules,
|
|
4
|
+
} from 'react-native'
|
|
5
|
+
|
|
6
|
+
import type { EmitterSubscription } from 'react-native'
|
|
7
|
+
import type { ValueOf } from 'type-fest'
|
|
8
|
+
|
|
9
|
+
export const HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier' as const
|
|
10
|
+
export const HKAudiogramTypeIdentifier = 'HKAudiogramTypeIdentifier' as const
|
|
11
|
+
export const HKWorkoutRouteTypeIdentifier = 'HKWorkoutRouteTypeIdentifier' as const
|
|
12
|
+
export const HKDataTypeIdentifierHeartbeatSeries = 'HKDataTypeIdentifierHeartbeatSeries' as const
|
|
13
|
+
|
|
14
|
+
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier
|
|
15
|
+
export enum HKQuantityTypeIdentifier {
|
|
16
|
+
bodyMassIndex = 'HKQuantityTypeIdentifierBodyMassIndex',
|
|
17
|
+
bodyFatPercentage = 'HKQuantityTypeIdentifierBodyFatPercentage', // Scalar(Percent, 0.0 - 1.0), Discrete
|
|
18
|
+
height = 'HKQuantityTypeIdentifierHeight', // Length, Discrete
|
|
19
|
+
bodyMass = 'HKQuantityTypeIdentifierBodyMass', // Mass, Discrete
|
|
20
|
+
leanBodyMass = 'HKQuantityTypeIdentifierLeanBodyMass', // Mass, Discrete
|
|
21
|
+
|
|
22
|
+
waistCircumference = 'HKQuantityTypeIdentifierWaistCircumference', // Length, Discrete
|
|
23
|
+
// Fitness
|
|
24
|
+
stepCount = 'HKQuantityTypeIdentifierStepCount', // Scalar(Count), Cumulative
|
|
25
|
+
distanceWalkingRunning = 'HKQuantityTypeIdentifierDistanceWalkingRunning', // Length, Cumulative
|
|
26
|
+
distanceCycling = 'HKQuantityTypeIdentifierDistanceCycling', // Length, Cumulative
|
|
27
|
+
distanceWheelchair = 'HKQuantityTypeIdentifierDistanceWheelchair', // Length, Cumulative
|
|
28
|
+
basalEnergyBurned = 'HKQuantityTypeIdentifierBasalEnergyBurned', // Energy, Cumulative
|
|
29
|
+
activeEnergyBurned = 'HKQuantityTypeIdentifierActiveEnergyBurned', // Energy, Cumulative
|
|
30
|
+
flightsClimbed = 'HKQuantityTypeIdentifierFlightsClimbed', // Scalar(Count), Cumulative
|
|
31
|
+
nikeFuel = 'HKQuantityTypeIdentifierNikeFuel', // Scalar(Count), Cumulative
|
|
32
|
+
appleExerciseTime = 'HKQuantityTypeIdentifierAppleExerciseTime', // Time Cumulative
|
|
33
|
+
pushCount = 'HKQuantityTypeIdentifierPushCount', // Scalar(Count), Cumulative
|
|
34
|
+
distanceSwimming = 'HKQuantityTypeIdentifierDistanceSwimming', // Length, Cumulative
|
|
35
|
+
swimmingStrokeCount = 'HKQuantityTypeIdentifierSwimmingStrokeCount', // Scalar(Count), Cumulative
|
|
36
|
+
vo2Max = 'HKQuantityTypeIdentifierVo2Max', // ml/(kg*min) Discrete
|
|
37
|
+
distanceDownhillSnowSports = 'HKQuantityTypeIdentifierDistanceDownhillSnowSports', // Length, Cumulative
|
|
38
|
+
|
|
39
|
+
appleStandTime = 'HKQuantityTypeIdentifierAppleStandTime', // Time, Cumulative
|
|
40
|
+
// Vitals
|
|
41
|
+
heartRate = 'HKQuantityTypeIdentifierHeartRate', // Scalar(Count)/Time, Discrete
|
|
42
|
+
bodyTemperature = 'HKQuantityTypeIdentifierBodyTemperature', // Temperature, Discrete
|
|
43
|
+
basalBodyTemperature = 'HKQuantityTypeIdentifierBasalBodyTemperature', // Basal Body Temperature, Discrete
|
|
44
|
+
bloodPressureSystolic = 'HKQuantityTypeIdentifierBloodPressureSystolic', // Pressure, Discrete
|
|
45
|
+
bloodPressureDiastolic = 'HKQuantityTypeIdentifierBloodPressureDiastolic', // Pressure, Discrete
|
|
46
|
+
respiratoryRate = 'HKQuantityTypeIdentifierRespiratoryRate', // Scalar(Count)/Time, Discrete
|
|
47
|
+
// Beats per minute estimate of a user's lowest heart rate while at rest
|
|
48
|
+
restingHeartRate = 'HKQuantityTypeIdentifierRestingHeartRate', // Scalar(Count)/Time, Discrete
|
|
49
|
+
// Average heartbeats per minute captured by an Apple Watch while a user is walking
|
|
50
|
+
walkingHeartRateAverage = 'HKQuantityTypeIdentifierWalkingHeartRateAverage', // Scalar(Count)/Time, Discrete
|
|
51
|
+
// The standard deviation of heart beat-to-beat intevals (Standard Deviation of Normal to Normal)
|
|
52
|
+
|
|
53
|
+
heartRateVariabilitySDNN = 'HKQuantityTypeIdentifierHeartRateVariabilitySDNN', // Time (ms), Discrete
|
|
54
|
+
// Results
|
|
55
|
+
oxygenSaturation = 'HKQuantityTypeIdentifierOxygenSaturation', // Scalar (Percent, 0.0 - 1.0, Discrete
|
|
56
|
+
peripheralPerfusionIndex = 'HKQuantityTypeIdentifierPeripheralPerfusionIndex', // Scalar(Percent, 0.0 - 1.0), Discrete
|
|
57
|
+
bloodGlucose = 'HKQuantityTypeIdentifierBloodGlucose', // Mass/Volume, Discrete
|
|
58
|
+
numberOfTimesFallen = 'HKQuantityTypeIdentifierNumberOfTimesFallen', // Scalar(Count), Cumulative
|
|
59
|
+
electrodermalActivity = 'HKQuantityTypeIdentifierElectrodermalActivity', // Conductance, Discrete
|
|
60
|
+
inhalerUsage = 'HKQuantityTypeIdentifierInhalerUsage', // Scalar(Count), Cumulative
|
|
61
|
+
insulinDelivery = 'HKQuantityTypeIdentifierInsulinDelivery', // Pharmacology (IU) Cumulative
|
|
62
|
+
bloodAlcoholContent = 'HKQuantityTypeIdentifierBloodAlcoholContent', // Scalar(Percent, 0.0 - 1.0), Discrete
|
|
63
|
+
forcedVitalCapacity = 'HKQuantityTypeIdentifierForcedVitalCapacity', // Volume, Discrete
|
|
64
|
+
forcedExpiratoryVolume1 = 'HKQuantityTypeIdentifierForcedExpiratoryVolume1', // Volume, Discrete
|
|
65
|
+
peakExpiratoryFlowRate = 'HKQuantityTypeIdentifierPeakExpiratoryFlowRate', // Volume/Time, Discrete
|
|
66
|
+
environmentalAudioExposure = 'HKQuantityTypeIdentifierEnvironmentalAudioExposure', // Pressure, Cumulative
|
|
67
|
+
|
|
68
|
+
headphoneAudioExposure = 'HKQuantityTypeIdentifierHeadphoneAudioExposure', // Pressure, Cumulative
|
|
69
|
+
// Nutrition
|
|
70
|
+
dietaryFatTotal = 'HKQuantityTypeIdentifierDietaryFatTotal', // Mass, Cumulative
|
|
71
|
+
dietaryFatPolyunsaturated = 'HKQuantityTypeIdentifierDietaryFatPolyunsaturated', // Mass, Cumulative
|
|
72
|
+
dietaryFatMonounsaturated = 'HKQuantityTypeIdentifierDietaryFatMonounsaturated', // Mass, Cumulative
|
|
73
|
+
dietaryFatSaturated = 'HKQuantityTypeIdentifierDietaryFatSaturated', // Mass, Cumulative
|
|
74
|
+
dietaryCholesterol = 'HKQuantityTypeIdentifierDietaryCholesterol', // Mass, Cumulative
|
|
75
|
+
dietarySodium = 'HKQuantityTypeIdentifierDietarySodium', // Mass, Cumulative
|
|
76
|
+
dietaryCarbohydrates = 'HKQuantityTypeIdentifierDietaryCarbohydrates', // Mass, Cumulative
|
|
77
|
+
dietaryFiber = 'HKQuantityTypeIdentifierDietaryFiber', // Mass, Cumulative
|
|
78
|
+
dietarySugar = 'HKQuantityTypeIdentifierDietarySugar', // Mass, Cumulative
|
|
79
|
+
dietaryEnergyConsumed = 'HKQuantityTypeIdentifierDietaryEnergyConsumed', // Energy, Cumulative
|
|
80
|
+
dietaryProtein = 'HKQuantityTypeIdentifierDietaryProtein', // Mass, Cumulative
|
|
81
|
+
|
|
82
|
+
dietaryVitaminA = 'HKQuantityTypeIdentifierDietaryVitaminA', // Mass, Cumulative
|
|
83
|
+
dietaryVitaminB6 = 'HKQuantityTypeIdentifierDietaryVitaminB6', // Mass, Cumulative
|
|
84
|
+
dietaryVitaminB12 = 'HKQuantityTypeIdentifierDietaryVitaminB12', // Mass, Cumulative
|
|
85
|
+
dietaryVitaminC = 'HKQuantityTypeIdentifierDietaryVitaminC', // Mass, Cumulative
|
|
86
|
+
dietaryVitaminD = 'HKQuantityTypeIdentifierDietaryVitaminD', // Mass, Cumulative
|
|
87
|
+
dietaryVitaminE = 'HKQuantityTypeIdentifierDietaryVitaminE', // Mass, Cumulative
|
|
88
|
+
dietaryVitaminK = 'HKQuantityTypeIdentifierDietaryVitaminK', // Mass, Cumulative
|
|
89
|
+
dietaryCalcium = 'HKQuantityTypeIdentifierDietaryCalcium', // Mass, Cumulative
|
|
90
|
+
dietaryIron = 'HKQuantityTypeIdentifierDietaryIron', // Mass, Cumulative
|
|
91
|
+
dietaryThiamin = 'HKQuantityTypeIdentifierDietaryThiamin', // Mass, Cumulative
|
|
92
|
+
dietaryRiboflavin = 'HKQuantityTypeIdentifierDietaryRiboflavin', // Mass, Cumulative
|
|
93
|
+
dietaryNiacin = 'HKQuantityTypeIdentifierDietaryNiacin', // Mass, Cumulative
|
|
94
|
+
dietaryFolate = 'HKQuantityTypeIdentifierDietaryFolate', // Mass, Cumulative
|
|
95
|
+
dietaryBiotin = 'HKQuantityTypeIdentifierDietaryBiotin', // Mass, Cumulative
|
|
96
|
+
dietaryPantothenicAcid = 'HKQuantityTypeIdentifierDietaryPantothenicAcid', // Mass, Cumulative
|
|
97
|
+
dietaryPhosphorus = 'HKQuantityTypeIdentifierDietaryPhosphorus', // Mass, Cumulative
|
|
98
|
+
dietaryIodine = 'HKQuantityTypeIdentifierDietaryIodine', // Mass, Cumulative
|
|
99
|
+
dietaryMagnesium = 'HKQuantityTypeIdentifierDietaryMagnesium', // Mass, Cumulative
|
|
100
|
+
dietaryZinc = 'HKQuantityTypeIdentifierDietaryZinc', // Mass, Cumulative
|
|
101
|
+
dietarySelenium = 'HKQuantityTypeIdentifierDietarySelenium', // Mass, Cumulative
|
|
102
|
+
dietaryCopper = 'HKQuantityTypeIdentifierDietaryCopper', // Mass, Cumulative
|
|
103
|
+
dietaryManganese = 'HKQuantityTypeIdentifierDietaryManganese', // Mass, Cumulative
|
|
104
|
+
dietaryChromium = 'HKQuantityTypeIdentifierDietaryChromium', // Mass, Cumulative
|
|
105
|
+
dietaryMolybdenum = 'HKQuantityTypeIdentifierDietaryMolybdenum', // Mass, Cumulative
|
|
106
|
+
dietaryChloride = 'HKQuantityTypeIdentifierDietaryChloride', // Mass, Cumulative
|
|
107
|
+
dietaryPotassium = 'HKQuantityTypeIdentifierDietaryPotassium', // Mass, Cumulative
|
|
108
|
+
dietaryCaffeine = 'HKQuantityTypeIdentifierDietaryCaffeine', // Mass, Cumulative
|
|
109
|
+
dietaryWater = 'HKQuantityTypeIdentifierDietaryWater', // Volume, Cumulative
|
|
6
110
|
|
|
7
|
-
|
|
8
|
-
|
|
111
|
+
// Mobility
|
|
112
|
+
sixMinuteWalkTestDistance = 'HKQuantityTypeIdentifierSixMinuteWalkTestDistance',
|
|
113
|
+
walkingSpeed = 'HKQuantityTypeIdentifierWalkingSpeed',
|
|
114
|
+
walkingStepLength = 'HKQuantityTypeIdentifierWalkingStepLength',
|
|
115
|
+
walkingAsymmetryPercentage = 'HKQuantityTypeIdentifierWalkingAsymmetryPercentage',
|
|
116
|
+
walkingDoubleSupportPercentage = 'HKQuantityTypeIdentifierWalkingDoubleSupportPercentage',
|
|
117
|
+
stairAscentSpeed = 'HKQuantityTypeIdentifierStairAscentSpeed',
|
|
118
|
+
stairDescentSpeed = 'HKQuantityTypeIdentifierStairDescentSpeed',
|
|
9
119
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| HKQuantityTypeIdentifier
|
|
13
|
-
| HKCategoryTypeIdentifier
|
|
14
|
-
| HKAudiogramTypeIdentifier
|
|
15
|
-
| HKCorrelationTypeIdentifier;
|
|
120
|
+
uvExposure = 'HKQuantityTypeIdentifierUvExposure', // Scalar (Count), Discrete
|
|
121
|
+
}
|
|
16
122
|
|
|
17
|
-
export type TypeToUnitMapping = {
|
|
123
|
+
export type TypeToUnitMapping = { readonly
|
|
18
124
|
[key in HKQuantityTypeIdentifier]: HKUnit;
|
|
19
125
|
};
|
|
20
126
|
|
|
@@ -24,6 +130,11 @@ export enum HKHeartRateMotionContext {
|
|
|
24
130
|
sedentary = 1,
|
|
25
131
|
}
|
|
26
132
|
|
|
133
|
+
export enum HKCorrelationTypeIdentifier {
|
|
134
|
+
bloodPressure = 'HKCorrelationTypeIdentifierBloodPressure',
|
|
135
|
+
food = 'HKCorrelationTypeIdentifierFood',
|
|
136
|
+
}
|
|
137
|
+
|
|
27
138
|
export enum HKCategoryTypeIdentifier {
|
|
28
139
|
sleepAnalysis = 'HKCategoryTypeIdentifierSleepAnalysis',
|
|
29
140
|
appleStandHour = 'HKCategoryTypeIdentifierAppleStandHour',
|
|
@@ -40,6 +151,16 @@ export enum HKCategoryTypeIdentifier {
|
|
|
40
151
|
toothbrushingEvent = 'HKCategoryTypeIdentifierToothbrushingEvent',
|
|
41
152
|
}
|
|
42
153
|
|
|
154
|
+
export const HKSampleTypeIdentifier = {
|
|
155
|
+
...HKCategoryTypeIdentifier,
|
|
156
|
+
...HKCorrelationTypeIdentifier,
|
|
157
|
+
...HKQuantityTypeIdentifier,
|
|
158
|
+
audiogram: HKAudiogramTypeIdentifier,
|
|
159
|
+
heartbeatSeries: HKDataTypeIdentifierHeartbeatSeries,
|
|
160
|
+
workoutRoute: HKWorkoutRouteTypeIdentifier,
|
|
161
|
+
workoute: HKWorkoutTypeIdentifier,
|
|
162
|
+
}
|
|
163
|
+
|
|
43
164
|
export enum HKCategoryValueAppleStandHour {
|
|
44
165
|
stood = 0,
|
|
45
166
|
idle = 1,
|
|
@@ -126,21 +247,21 @@ export enum HKWorkoutActivityType {
|
|
|
126
247
|
}
|
|
127
248
|
|
|
128
249
|
export type HKGenericMetadata = {
|
|
129
|
-
[key: string]:
|
|
130
|
-
HKExternalUUID?: string;
|
|
131
|
-
HKTimeZone?: string;
|
|
132
|
-
HKWasUserEntered?: boolean;
|
|
133
|
-
HKDeviceSerialNumber?: string;
|
|
134
|
-
HKUDIDeviceIdentifier?: string;
|
|
135
|
-
HKUDIProductionIdentifier?: string;
|
|
136
|
-
HKDigitalSignature?: string;
|
|
137
|
-
HKDeviceName?: string;
|
|
138
|
-
HKDeviceManufacturerName?: string;
|
|
139
|
-
HKSyncIdentifier?: string;
|
|
140
|
-
HKSyncVersion?: number;
|
|
141
|
-
HKWasTakenInLab?: boolean;
|
|
142
|
-
HKReferenceRangeLowerLimit?: number;
|
|
143
|
-
HKReferenceRangeUpperLimit?: number;
|
|
250
|
+
readonly [key: string]: HKQuantity | boolean | number | string | undefined;
|
|
251
|
+
readonly HKExternalUUID?: string;
|
|
252
|
+
readonly HKTimeZone?: string;
|
|
253
|
+
readonly HKWasUserEntered?: boolean;
|
|
254
|
+
readonly HKDeviceSerialNumber?: string;
|
|
255
|
+
readonly HKUDIDeviceIdentifier?: string;
|
|
256
|
+
readonly HKUDIProductionIdentifier?: string;
|
|
257
|
+
readonly HKDigitalSignature?: string;
|
|
258
|
+
readonly HKDeviceName?: string;
|
|
259
|
+
readonly HKDeviceManufacturerName?: string;
|
|
260
|
+
readonly HKSyncIdentifier?: string;
|
|
261
|
+
readonly HKSyncVersion?: number;
|
|
262
|
+
readonly HKWasTakenInLab?: boolean;
|
|
263
|
+
readonly HKReferenceRangeLowerLimit?: number;
|
|
264
|
+
readonly HKReferenceRangeUpperLimit?: number;
|
|
144
265
|
};
|
|
145
266
|
|
|
146
267
|
// documented at https://developer.apple.com/documentation/healthkit/hkweathercondition
|
|
@@ -176,130 +297,27 @@ export enum HKWeatherCondition {
|
|
|
176
297
|
}
|
|
177
298
|
|
|
178
299
|
export interface HKWorkoutMetadata
|
|
179
|
-
extends HKGenericMetadata
|
|
180
|
-
HKWeatherCondition?: HKWeatherCondition;
|
|
181
|
-
HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
300
|
+
extends HKGenericMetadata /* <TTemperatureUnit extends HKUnit> */ {
|
|
301
|
+
readonly HKWeatherCondition?: HKWeatherCondition;
|
|
302
|
+
readonly HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
182
303
|
// HKWeatherTemperature: HKQuantity<TTemperatureUnit>
|
|
183
304
|
}
|
|
184
305
|
|
|
185
|
-
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier
|
|
186
|
-
export enum HKQuantityTypeIdentifier {
|
|
187
|
-
bodyMassIndex = 'HKQuantityTypeIdentifierBodyMassIndex',
|
|
188
|
-
bodyFatPercentage = 'HKQuantityTypeIdentifierBodyFatPercentage', // Scalar(Percent, 0.0 - 1.0), Discrete
|
|
189
|
-
height = 'HKQuantityTypeIdentifierHeight', // Length, Discrete
|
|
190
|
-
bodyMass = 'HKQuantityTypeIdentifierBodyMass', // Mass, Discrete
|
|
191
|
-
leanBodyMass = 'HKQuantityTypeIdentifierLeanBodyMass', // Mass, Discrete
|
|
192
|
-
|
|
193
|
-
waistCircumference = 'HKQuantityTypeIdentifierWaistCircumference', // Length, Discrete
|
|
194
|
-
// Fitness
|
|
195
|
-
stepCount = 'HKQuantityTypeIdentifierStepCount', // Scalar(Count), Cumulative
|
|
196
|
-
distanceWalkingRunning = 'HKQuantityTypeIdentifierDistanceWalkingRunning', // Length, Cumulative
|
|
197
|
-
distanceCycling = 'HKQuantityTypeIdentifierDistanceCycling', // Length, Cumulative
|
|
198
|
-
distanceWheelchair = 'HKQuantityTypeIdentifierDistanceWheelchair', // Length, Cumulative
|
|
199
|
-
basalEnergyBurned = 'HKQuantityTypeIdentifierBasalEnergyBurned', // Energy, Cumulative
|
|
200
|
-
activeEnergyBurned = 'HKQuantityTypeIdentifierActiveEnergyBurned', // Energy, Cumulative
|
|
201
|
-
flightsClimbed = 'HKQuantityTypeIdentifierFlightsClimbed', // Scalar(Count), Cumulative
|
|
202
|
-
nikeFuel = 'HKQuantityTypeIdentifierNikeFuel', // Scalar(Count), Cumulative
|
|
203
|
-
appleExerciseTime = 'HKQuantityTypeIdentifierAppleExerciseTime', // Time Cumulative
|
|
204
|
-
pushCount = 'HKQuantityTypeIdentifierPushCount', // Scalar(Count), Cumulative
|
|
205
|
-
distanceSwimming = 'HKQuantityTypeIdentifierDistanceSwimming', // Length, Cumulative
|
|
206
|
-
swimmingStrokeCount = 'HKQuantityTypeIdentifierSwimmingStrokeCount', // Scalar(Count), Cumulative
|
|
207
|
-
vo2Max = 'HKQuantityTypeIdentifierVo2Max', // ml/(kg*min) Discrete
|
|
208
|
-
distanceDownhillSnowSports = 'HKQuantityTypeIdentifierDistanceDownhillSnowSports', // Length, Cumulative
|
|
209
|
-
|
|
210
|
-
appleStandTime = 'HKQuantityTypeIdentifierAppleStandTime', // Time, Cumulative
|
|
211
|
-
// Vitals
|
|
212
|
-
heartRate = 'HKQuantityTypeIdentifierHeartRate', // Scalar(Count)/Time, Discrete
|
|
213
|
-
bodyTemperature = 'HKQuantityTypeIdentifierBodyTemperature', // Temperature, Discrete
|
|
214
|
-
basalBodyTemperature = 'HKQuantityTypeIdentifierBasalBodyTemperature', // Basal Body Temperature, Discrete
|
|
215
|
-
bloodPressureSystolic = 'HKQuantityTypeIdentifierBloodPressureSystolic', // Pressure, Discrete
|
|
216
|
-
bloodPressureDiastolic = 'HKQuantityTypeIdentifierBloodPressureDiastolic', // Pressure, Discrete
|
|
217
|
-
respiratoryRate = 'HKQuantityTypeIdentifierRespiratoryRate', // Scalar(Count)/Time, Discrete
|
|
218
|
-
// Beats per minute estimate of a user's lowest heart rate while at rest
|
|
219
|
-
restingHeartRate = 'HKQuantityTypeIdentifierRestingHeartRate', // Scalar(Count)/Time, Discrete
|
|
220
|
-
// Average heartbeats per minute captured by an Apple Watch while a user is walking
|
|
221
|
-
walkingHeartRateAverage = 'HKQuantityTypeIdentifierWalkingHeartRateAverage', // Scalar(Count)/Time, Discrete
|
|
222
|
-
// The standard deviation of heart beat-to-beat intevals (Standard Deviation of Normal to Normal)
|
|
223
|
-
|
|
224
|
-
heartRateVariabilitySDNN = 'HKQuantityTypeIdentifierHeartRateVariabilitySDNN', // Time (ms), Discrete
|
|
225
|
-
// Results
|
|
226
|
-
oxygenSaturation = 'HKQuantityTypeIdentifierOxygenSaturation', // Scalar (Percent, 0.0 - 1.0, Discrete
|
|
227
|
-
peripheralPerfusionIndex = 'HKQuantityTypeIdentifierPeripheralPerfusionIndex', // Scalar(Percent, 0.0 - 1.0), Discrete
|
|
228
|
-
bloodGlucose = 'HKQuantityTypeIdentifierBloodGlucose', // Mass/Volume, Discrete
|
|
229
|
-
numberOfTimesFallen = 'HKQuantityTypeIdentifierNumberOfTimesFallen', // Scalar(Count), Cumulative
|
|
230
|
-
electrodermalActivity = 'HKQuantityTypeIdentifierElectrodermalActivity', // Conductance, Discrete
|
|
231
|
-
inhalerUsage = 'HKQuantityTypeIdentifierInhalerUsage', // Scalar(Count), Cumulative
|
|
232
|
-
insulinDelivery = 'HKQuantityTypeIdentifierInsulinDelivery', // Pharmacology (IU) Cumulative
|
|
233
|
-
bloodAlcoholContent = 'HKQuantityTypeIdentifierBloodAlcoholContent', // Scalar(Percent, 0.0 - 1.0), Discrete
|
|
234
|
-
forcedVitalCapacity = 'HKQuantityTypeIdentifierForcedVitalCapacity', // Volume, Discrete
|
|
235
|
-
forcedExpiratoryVolume1 = 'HKQuantityTypeIdentifierForcedExpiratoryVolume1', // Volume, Discrete
|
|
236
|
-
peakExpiratoryFlowRate = 'HKQuantityTypeIdentifierPeakExpiratoryFlowRate', // Volume/Time, Discrete
|
|
237
|
-
environmentalAudioExposure = 'HKQuantityTypeIdentifierEnvironmentalAudioExposure', // Pressure, Cumulative
|
|
238
|
-
|
|
239
|
-
headphoneAudioExposure = 'HKQuantityTypeIdentifierHeadphoneAudioExposure', // Pressure, Cumulative
|
|
240
|
-
// Nutrition
|
|
241
|
-
dietaryFatTotal = 'HKQuantityTypeIdentifierDietaryFatTotal', // Mass, Cumulative
|
|
242
|
-
dietaryFatPolyunsaturated = 'HKQuantityTypeIdentifierDietaryFatPolyunsaturated', // Mass, Cumulative
|
|
243
|
-
dietaryFatMonounsaturated = 'HKQuantityTypeIdentifierDietaryFatMonounsaturated', // Mass, Cumulative
|
|
244
|
-
dietaryFatSaturated = 'HKQuantityTypeIdentifierDietaryFatSaturated', // Mass, Cumulative
|
|
245
|
-
dietaryCholesterol = 'HKQuantityTypeIdentifierDietaryCholesterol', // Mass, Cumulative
|
|
246
|
-
dietarySodium = 'HKQuantityTypeIdentifierDietarySodium', // Mass, Cumulative
|
|
247
|
-
dietaryCarbohydrates = 'HKQuantityTypeIdentifierDietaryCarbohydrates', // Mass, Cumulative
|
|
248
|
-
dietaryFiber = 'HKQuantityTypeIdentifierDietaryFiber', // Mass, Cumulative
|
|
249
|
-
dietarySugar = 'HKQuantityTypeIdentifierDietarySugar', // Mass, Cumulative
|
|
250
|
-
dietaryEnergyConsumed = 'HKQuantityTypeIdentifierDietaryEnergyConsumed', // Energy, Cumulative
|
|
251
|
-
dietaryProtein = 'HKQuantityTypeIdentifierDietaryProtein', // Mass, Cumulative
|
|
252
|
-
|
|
253
|
-
dietaryVitaminA = 'HKQuantityTypeIdentifierDietaryVitaminA', // Mass, Cumulative
|
|
254
|
-
dietaryVitaminB6 = 'HKQuantityTypeIdentifierDietaryVitaminB6', // Mass, Cumulative
|
|
255
|
-
dietaryVitaminB12 = 'HKQuantityTypeIdentifierDietaryVitaminB12', // Mass, Cumulative
|
|
256
|
-
dietaryVitaminC = 'HKQuantityTypeIdentifierDietaryVitaminC', // Mass, Cumulative
|
|
257
|
-
dietaryVitaminD = 'HKQuantityTypeIdentifierDietaryVitaminD', // Mass, Cumulative
|
|
258
|
-
dietaryVitaminE = 'HKQuantityTypeIdentifierDietaryVitaminE', // Mass, Cumulative
|
|
259
|
-
dietaryVitaminK = 'HKQuantityTypeIdentifierDietaryVitaminK', // Mass, Cumulative
|
|
260
|
-
dietaryCalcium = 'HKQuantityTypeIdentifierDietaryCalcium', // Mass, Cumulative
|
|
261
|
-
dietaryIron = 'HKQuantityTypeIdentifierDietaryIron', // Mass, Cumulative
|
|
262
|
-
dietaryThiamin = 'HKQuantityTypeIdentifierDietaryThiamin', // Mass, Cumulative
|
|
263
|
-
dietaryRiboflavin = 'HKQuantityTypeIdentifierDietaryRiboflavin', // Mass, Cumulative
|
|
264
|
-
dietaryNiacin = 'HKQuantityTypeIdentifierDietaryNiacin', // Mass, Cumulative
|
|
265
|
-
dietaryFolate = 'HKQuantityTypeIdentifierDietaryFolate', // Mass, Cumulative
|
|
266
|
-
dietaryBiotin = 'HKQuantityTypeIdentifierDietaryBiotin', // Mass, Cumulative
|
|
267
|
-
dietaryPantothenicAcid = 'HKQuantityTypeIdentifierDietaryPantothenicAcid', // Mass, Cumulative
|
|
268
|
-
dietaryPhosphorus = 'HKQuantityTypeIdentifierDietaryPhosphorus', // Mass, Cumulative
|
|
269
|
-
dietaryIodine = 'HKQuantityTypeIdentifierDietaryIodine', // Mass, Cumulative
|
|
270
|
-
dietaryMagnesium = 'HKQuantityTypeIdentifierDietaryMagnesium', // Mass, Cumulative
|
|
271
|
-
dietaryZinc = 'HKQuantityTypeIdentifierDietaryZinc', // Mass, Cumulative
|
|
272
|
-
dietarySelenium = 'HKQuantityTypeIdentifierDietarySelenium', // Mass, Cumulative
|
|
273
|
-
dietaryCopper = 'HKQuantityTypeIdentifierDietaryCopper', // Mass, Cumulative
|
|
274
|
-
dietaryManganese = 'HKQuantityTypeIdentifierDietaryManganese', // Mass, Cumulative
|
|
275
|
-
dietaryChromium = 'HKQuantityTypeIdentifierDietaryChromium', // Mass, Cumulative
|
|
276
|
-
dietaryMolybdenum = 'HKQuantityTypeIdentifierDietaryMolybdenum', // Mass, Cumulative
|
|
277
|
-
dietaryChloride = 'HKQuantityTypeIdentifierDietaryChloride', // Mass, Cumulative
|
|
278
|
-
dietaryPotassium = 'HKQuantityTypeIdentifierDietaryPotassium', // Mass, Cumulative
|
|
279
|
-
dietaryCaffeine = 'HKQuantityTypeIdentifierDietaryCaffeine', // Mass, Cumulative
|
|
280
|
-
dietaryWater = 'HKQuantityTypeIdentifierDietaryWater', // Volume, Cumulative
|
|
281
|
-
|
|
282
|
-
// Mobility
|
|
283
|
-
sixMinuteWalkTestDistance = 'HKQuantityTypeIdentifierSixMinuteWalkTestDistance',
|
|
284
|
-
walkingSpeed = 'HKQuantityTypeIdentifierWalkingSpeed',
|
|
285
|
-
walkingStepLength = 'HKQuantityTypeIdentifierWalkingStepLength',
|
|
286
|
-
walkingAsymmetryPercentage = 'HKQuantityTypeIdentifierWalkingAsymmetryPercentage',
|
|
287
|
-
walkingDoubleSupportPercentage = 'HKQuantityTypeIdentifierWalkingDoubleSupportPercentage',
|
|
288
|
-
stairAscentSpeed = 'HKQuantityTypeIdentifierStairAscentSpeed',
|
|
289
|
-
stairDescentSpeed = 'HKQuantityTypeIdentifierStairDescentSpeed',
|
|
290
|
-
|
|
291
|
-
uvExposure = 'HKQuantityTypeIdentifierUvExposure', // Scalar (Count), Discrete
|
|
292
|
-
}
|
|
293
|
-
|
|
294
306
|
export enum HKAuthorizationRequestStatus {
|
|
295
307
|
unknown = 0,
|
|
296
308
|
shouldRequest = 1,
|
|
297
309
|
unnecessary = 2,
|
|
298
310
|
}
|
|
299
311
|
|
|
312
|
+
export enum HKAuthorizationStatus {
|
|
313
|
+
notDetermined = 0,
|
|
314
|
+
sharingDenied = 1,
|
|
315
|
+
sharingAuthorized = 2,
|
|
316
|
+
}
|
|
317
|
+
|
|
300
318
|
export type HKQuantity<T extends HKUnit = HKUnit> = {
|
|
301
|
-
unit: T;
|
|
302
|
-
quantity: number;
|
|
319
|
+
readonly unit: T;
|
|
320
|
+
readonly quantity: number;
|
|
303
321
|
};
|
|
304
322
|
|
|
305
323
|
export enum HKBloodType {
|
|
@@ -343,13 +361,13 @@ export enum HKStatisticsOptions {
|
|
|
343
361
|
}
|
|
344
362
|
|
|
345
363
|
export type QueryStatisticsResponseRaw<TUnit extends HKUnit = HKUnit> = {
|
|
346
|
-
averageQuantity?: HKQuantity<TUnit>;
|
|
347
|
-
maximumQuantity?: HKQuantity<TUnit>;
|
|
348
|
-
minimumQuantity?: HKQuantity<TUnit>;
|
|
349
|
-
sumQuantity?: HKQuantity<TUnit>;
|
|
350
|
-
mostRecentQuantity?: HKQuantity<TUnit>;
|
|
351
|
-
mostRecentQuantityDateInterval?: { from: string; to: string };
|
|
352
|
-
duration?: HKQuantity<HKUnit.Seconds>;
|
|
364
|
+
readonly averageQuantity?: HKQuantity<TUnit>;
|
|
365
|
+
readonly maximumQuantity?: HKQuantity<TUnit>;
|
|
366
|
+
readonly minimumQuantity?: HKQuantity<TUnit>;
|
|
367
|
+
readonly sumQuantity?: HKQuantity<TUnit>;
|
|
368
|
+
readonly mostRecentQuantity?: HKQuantity<TUnit>;
|
|
369
|
+
readonly mostRecentQuantityDateInterval?: { readonly from: string; readonly to: string };
|
|
370
|
+
readonly duration?: HKQuantity<HKUnit.Seconds>;
|
|
353
371
|
};
|
|
354
372
|
|
|
355
373
|
export enum HKCategoryValueCervicalMucusQuality {
|
|
@@ -407,13 +425,13 @@ export enum HKCategoryValueNotApplicable {
|
|
|
407
425
|
|
|
408
426
|
export type HKCategoryValue =
|
|
409
427
|
| HKCategoryValueAppetiteChanges
|
|
428
|
+
| HKCategoryValueCervicalMucusQuality
|
|
429
|
+
| HKCategoryValueMenstrualFlow
|
|
430
|
+
| HKCategoryValueOvulationTestResult
|
|
410
431
|
| HKCategoryValuePresence
|
|
411
|
-
| HKCategoryValueSeverity
|
|
412
432
|
| HKCategoryValuePresence
|
|
413
|
-
|
|
|
433
|
+
| HKCategoryValueSeverity
|
|
414
434
|
| HKCategoryValueSleepAnalysis
|
|
415
|
-
| HKCategoryValueCervicalMucusQuality
|
|
416
|
-
| HKCategoryValueOvulationTestResult
|
|
417
435
|
| number;
|
|
418
436
|
|
|
419
437
|
export enum HKInsulinDeliveryReason {
|
|
@@ -425,58 +443,58 @@ export type MetadataMapperForQuantityIdentifier<
|
|
|
425
443
|
TQuantityTypeIdentifier = HKQuantityTypeIdentifier
|
|
426
444
|
> = TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.insulinDelivery
|
|
427
445
|
? HKGenericMetadata & {
|
|
428
|
-
|
|
429
|
-
|
|
446
|
+
readonly HKInsulinDeliveryReason: HKInsulinDeliveryReason;
|
|
447
|
+
}
|
|
430
448
|
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.bloodGlucose
|
|
431
|
-
|
|
432
|
-
HKBloodGlucoseMealTime?: number;
|
|
433
|
-
}
|
|
434
|
-
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.heartRate
|
|
435
|
-
? HKGenericMetadata & {
|
|
436
|
-
HKHeartRateMotionContext?: HKHeartRateMotionContext;
|
|
449
|
+
? HKGenericMetadata & {
|
|
450
|
+
readonly HKBloodGlucoseMealTime?: number;
|
|
437
451
|
}
|
|
438
|
-
|
|
452
|
+
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.heartRate
|
|
453
|
+
? HKGenericMetadata & {
|
|
454
|
+
readonly HKHeartRateMotionContext?: HKHeartRateMotionContext;
|
|
455
|
+
}
|
|
456
|
+
: HKGenericMetadata;
|
|
439
457
|
|
|
440
458
|
export type MetadataMapperForCorrelationIdentifier<
|
|
441
459
|
TCorrelationTypeIdentifier = HKCorrelationTypeIdentifier
|
|
442
460
|
> = TCorrelationTypeIdentifier extends HKCorrelationTypeIdentifier.food
|
|
443
461
|
? HKGenericMetadata & {
|
|
444
|
-
|
|
445
|
-
|
|
462
|
+
readonly HKFoodType?: string;
|
|
463
|
+
}
|
|
446
464
|
: HKGenericMetadata;
|
|
447
465
|
|
|
448
466
|
export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
|
|
449
467
|
T extends HKCategoryTypeIdentifier.cervicalMucusQuality
|
|
450
468
|
? HKCategoryValueCervicalMucusQuality
|
|
451
469
|
: T extends HKCategoryTypeIdentifier.menstrualFlow
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
? HKCategoryValueMenstrualFlow
|
|
471
|
+
: T extends HKCategoryTypeIdentifier.ovulationTestResult
|
|
472
|
+
? HKCategoryValueOvulationTestResult
|
|
473
|
+
: T extends HKCategoryTypeIdentifier.sleepAnalysis
|
|
474
|
+
? HKCategoryValueSleepAnalysis
|
|
475
|
+
: T extends HKCategoryTypeIdentifier.mindfulSession
|
|
476
|
+
? HKCategoryValueNotApplicable
|
|
477
|
+
: T extends HKCategoryTypeIdentifier.intermenstrualBleeding
|
|
478
|
+
? HKCategoryValueNotApplicable
|
|
479
|
+
: T extends HKCategoryTypeIdentifier.highHeartRateEvent
|
|
480
|
+
? HKCategoryValueNotApplicable
|
|
481
|
+
: T extends HKCategoryTypeIdentifier.sexualActivity
|
|
482
|
+
? HKCategoryValueNotApplicable
|
|
483
|
+
: T extends HKCategoryTypeIdentifier.appleStandHour
|
|
484
|
+
? HKCategoryValueAppleStandHour
|
|
485
|
+
: number;
|
|
468
486
|
|
|
469
487
|
export type MetadataMapperForCategoryIdentifier<
|
|
470
488
|
T extends HKCategoryTypeIdentifier
|
|
471
489
|
> = T extends HKCategoryTypeIdentifier.sexualActivity
|
|
472
490
|
? HKGenericMetadata & {
|
|
473
|
-
|
|
474
|
-
|
|
491
|
+
readonly HKSexualActivityProtectionUsed: boolean;
|
|
492
|
+
}
|
|
475
493
|
: T extends HKCategoryTypeIdentifier.menstrualFlow
|
|
476
|
-
|
|
477
|
-
HKMenstrualCycleStart: boolean;
|
|
494
|
+
? HKGenericMetadata & {
|
|
495
|
+
readonly HKMenstrualCycleStart: boolean;
|
|
478
496
|
}
|
|
479
|
-
|
|
497
|
+
: HKGenericMetadata;
|
|
480
498
|
|
|
481
499
|
// Maps directly to https://developer.apple.com/documentation/healthkit/hkwheelchairuse
|
|
482
500
|
export enum HKWheelchairUse {
|
|
@@ -558,53 +576,55 @@ export enum HKUnit {
|
|
|
558
576
|
}
|
|
559
577
|
|
|
560
578
|
export type HKDevice = {
|
|
561
|
-
name: string;
|
|
562
|
-
firmwareVersion: string;
|
|
563
|
-
hardwareVersion: string;
|
|
564
|
-
localIdentifier: string;
|
|
565
|
-
manufacturer: string;
|
|
566
|
-
model: string;
|
|
567
|
-
softwareVersion: string;
|
|
579
|
+
readonly name: string;
|
|
580
|
+
readonly firmwareVersion: string;
|
|
581
|
+
readonly hardwareVersion: string;
|
|
582
|
+
readonly localIdentifier: string;
|
|
583
|
+
readonly manufacturer: string;
|
|
584
|
+
readonly model: string;
|
|
585
|
+
readonly softwareVersion: string;
|
|
568
586
|
};
|
|
569
587
|
|
|
570
588
|
export type HKSource = {
|
|
571
|
-
name: string;
|
|
572
|
-
bundleIdentifier: string;
|
|
589
|
+
readonly name: string;
|
|
590
|
+
readonly bundleIdentifier: string;
|
|
573
591
|
};
|
|
574
592
|
|
|
575
593
|
export type HKSourceRevision = {
|
|
576
|
-
source: HKSource;
|
|
577
|
-
version: string;
|
|
578
|
-
operatingSystemVersion?: string;
|
|
579
|
-
productType?: string;
|
|
594
|
+
readonly source: HKSource;
|
|
595
|
+
readonly version: string;
|
|
596
|
+
readonly operatingSystemVersion?: string;
|
|
597
|
+
readonly productType?: string;
|
|
580
598
|
};
|
|
581
599
|
|
|
582
600
|
export type HKQuantitySampleRaw<
|
|
583
601
|
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
584
602
|
TUnit extends HKUnit = HKUnit
|
|
585
603
|
> = {
|
|
586
|
-
uuid: string;
|
|
587
|
-
device?: HKDevice;
|
|
588
|
-
quantityType: TQuantityIdentifier;
|
|
589
|
-
startDate: string;
|
|
590
|
-
endDate: string;
|
|
591
|
-
quantity: number;
|
|
592
|
-
unit: TUnit;
|
|
593
|
-
metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
|
|
594
|
-
sourceRevision?: HKSourceRevision;
|
|
604
|
+
readonly uuid: string;
|
|
605
|
+
readonly device?: HKDevice;
|
|
606
|
+
readonly quantityType: TQuantityIdentifier;
|
|
607
|
+
readonly startDate: string;
|
|
608
|
+
readonly endDate: string;
|
|
609
|
+
readonly quantity: number;
|
|
610
|
+
readonly unit: TUnit;
|
|
611
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
|
|
612
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
595
613
|
};
|
|
596
614
|
|
|
597
615
|
export type HKWorkoutRaw<TEnergy extends HKUnit, TDistance extends HKUnit> = {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
616
|
+
readonly uuid: string;
|
|
617
|
+
readonly device?: HKDevice;
|
|
618
|
+
readonly workoutActivityType: HKWorkoutActivityType;
|
|
619
|
+
readonly duration: number;
|
|
620
|
+
readonly totalDistance?: HKQuantity<TDistance>;
|
|
621
|
+
readonly totalEnergyBurned?: HKQuantity<TEnergy>;
|
|
622
|
+
readonly totalSwimmingStrokeCount?: HKQuantity<HKUnit.Count>;
|
|
623
|
+
readonly totalFlightsClimbed?: HKQuantity<HKUnit.Count>;
|
|
624
|
+
readonly startDate: string;
|
|
625
|
+
readonly endDate: string;
|
|
626
|
+
readonly metadata?: HKWorkoutMetadata;
|
|
627
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
608
628
|
};
|
|
609
629
|
|
|
610
630
|
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkcharacteristictypeidentifier
|
|
@@ -616,49 +636,38 @@ export enum HKCharacteristicTypeIdentifier {
|
|
|
616
636
|
wheelchairUse = 'HKCharacteristicTypeIdentifierWheelchairUse',
|
|
617
637
|
}
|
|
618
638
|
|
|
619
|
-
export type
|
|
620
|
-
[key in
|
|
621
|
-
| HKCharacteristicTypeIdentifier
|
|
622
|
-
| HKQuantityTypeIdentifier
|
|
623
|
-
| HKCategoryTypeIdentifier]: boolean;
|
|
639
|
+
export type WritePermissions = {
|
|
640
|
+
readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
|
|
624
641
|
};
|
|
625
642
|
|
|
626
|
-
export type
|
|
627
|
-
[key in
|
|
628
|
-
| HKQuantityTypeIdentifier
|
|
629
|
-
| HKCharacteristicTypeIdentifier
|
|
630
|
-
| HKCategoryTypeIdentifier]: boolean;
|
|
643
|
+
export type ReadPermissions = {
|
|
644
|
+
readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
|
|
631
645
|
};
|
|
632
646
|
|
|
633
647
|
export type HKCategorySampleRaw<
|
|
634
648
|
T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
635
649
|
> = {
|
|
636
|
-
uuid: string;
|
|
637
|
-
device?: HKDevice;
|
|
638
|
-
categoryType: T;
|
|
639
|
-
startDate: string;
|
|
640
|
-
endDate: string;
|
|
641
|
-
value: HKCategoryValueForIdentifier<T>;
|
|
642
|
-
metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
643
|
-
sourceRevision?: HKSourceRevision;
|
|
650
|
+
readonly uuid: string;
|
|
651
|
+
readonly device?: HKDevice;
|
|
652
|
+
readonly categoryType: T;
|
|
653
|
+
readonly startDate: string;
|
|
654
|
+
readonly endDate: string;
|
|
655
|
+
readonly value: HKCategoryValueForIdentifier<T>;
|
|
656
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
657
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
644
658
|
};
|
|
645
659
|
|
|
646
660
|
export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
647
661
|
{
|
|
648
|
-
correlationType: HKCorrelationTypeIdentifier;
|
|
649
|
-
objects: (
|
|
650
|
-
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
651
|
-
startDate: string;
|
|
652
|
-
endDate: string;
|
|
662
|
+
readonly correlationType: HKCorrelationTypeIdentifier;
|
|
663
|
+
readonly objects: readonly (HKCategorySampleRaw | HKQuantitySampleRaw)[];
|
|
664
|
+
readonly metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
665
|
+
readonly startDate: string;
|
|
666
|
+
readonly endDate: string;
|
|
653
667
|
};
|
|
654
668
|
|
|
655
669
|
type QueryId = string;
|
|
656
670
|
|
|
657
|
-
export enum HKCorrelationTypeIdentifier {
|
|
658
|
-
bloodPressure = 'HKCorrelationTypeIdentifierBloodPressure',
|
|
659
|
-
food = 'HKCorrelationTypeIdentifierFood',
|
|
660
|
-
}
|
|
661
|
-
|
|
662
671
|
export enum HKUpdateFrequency {
|
|
663
672
|
immediate = 1,
|
|
664
673
|
hourly = 2,
|
|
@@ -666,90 +675,109 @@ export enum HKUpdateFrequency {
|
|
|
666
675
|
weekly = 4,
|
|
667
676
|
}
|
|
668
677
|
|
|
678
|
+
export type WorkoutLocation = {
|
|
679
|
+
readonly longitude: number;
|
|
680
|
+
readonly latitude: number;
|
|
681
|
+
readonly altitude: number;
|
|
682
|
+
readonly speed: number;
|
|
683
|
+
readonly timestamp: number;
|
|
684
|
+
readonly horizontalAccuracy: number;
|
|
685
|
+
readonly speedAccuracy: number;
|
|
686
|
+
readonly verticalAccuracy: number;
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
export type WorkoutRoute = {
|
|
690
|
+
readonly locations: readonly WorkoutLocation[];
|
|
691
|
+
readonly HKMetadataKeySyncIdentifier?: string;
|
|
692
|
+
readonly HKMetadataKeySyncVersion?: number;
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
export const HealthkitAuthorization = { ...HKCharacteristicTypeIdentifier, ...HKSampleTypeIdentifier }
|
|
696
|
+
|
|
669
697
|
type ReactNativeHealthkitTypeNative = {
|
|
670
698
|
isHealthDataAvailable(): Promise<boolean>;
|
|
671
699
|
getBloodType(): Promise<HKBloodType>;
|
|
672
700
|
getDateOfBirth(): Promise<string>;
|
|
673
701
|
getBiologicalSex(): Promise<HKBiologicalSex>;
|
|
674
702
|
getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
|
|
675
|
-
getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
703
|
+
readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
676
704
|
|
|
677
|
-
enableBackgroundDelivery: (
|
|
678
|
-
typeIdentifier: HKSampleTypeIdentifier
|
|
705
|
+
readonly enableBackgroundDelivery: (
|
|
706
|
+
typeIdentifier: ValueOf<typeof HKSampleTypeIdentifier>,
|
|
679
707
|
updateFrequency: HKUpdateFrequency
|
|
680
708
|
) => Promise<boolean>;
|
|
681
|
-
disableBackgroundDelivery: (
|
|
682
|
-
typeIdentifier: HKSampleTypeIdentifier
|
|
709
|
+
readonly disableBackgroundDelivery: (
|
|
710
|
+
typeIdentifier: ValueOf<typeof HKSampleTypeIdentifier>,
|
|
683
711
|
) => Promise<boolean>;
|
|
684
|
-
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
712
|
+
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
685
713
|
|
|
686
|
-
saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
714
|
+
readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
687
715
|
typeIdentifier: TIdentifier,
|
|
688
|
-
samples: Omit<
|
|
689
|
-
|
|
690
|
-
|
|
716
|
+
samples: readonly Omit<
|
|
717
|
+
HKCategorySampleRaw | HKQuantitySampleRaw,
|
|
718
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
691
719
|
>[],
|
|
692
720
|
start: string,
|
|
693
721
|
end: string,
|
|
694
722
|
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>
|
|
695
723
|
) => Promise<boolean>;
|
|
696
724
|
|
|
697
|
-
saveWorkoutSample: (
|
|
725
|
+
readonly saveWorkoutSample: (
|
|
698
726
|
typeIdentifier: HKWorkoutActivityType,
|
|
699
|
-
quantities: Omit<
|
|
700
|
-
|
|
701
|
-
|
|
727
|
+
quantities: readonly Omit<
|
|
728
|
+
HKQuantitySampleRaw,
|
|
729
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
702
730
|
>[],
|
|
703
731
|
start: string,
|
|
704
732
|
end: string,
|
|
705
733
|
metadata: HKWorkoutMetadata
|
|
706
734
|
) => Promise<boolean>;
|
|
707
735
|
|
|
708
|
-
queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
736
|
+
readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
709
737
|
typeIdentifier: TIdentifier,
|
|
710
738
|
from: string,
|
|
711
739
|
to: string
|
|
712
|
-
) => Promise<HKCorrelationRaw<TIdentifier>[]>;
|
|
740
|
+
) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
|
|
713
741
|
|
|
714
742
|
subscribeToObserverQuery(
|
|
715
|
-
identifier: HKSampleTypeIdentifier
|
|
743
|
+
identifier: ValueOf<typeof HKSampleTypeIdentifier>
|
|
716
744
|
): Promise<QueryId>;
|
|
717
745
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
718
746
|
authorizationStatusFor(
|
|
719
|
-
type:
|
|
747
|
+
type: ValueOf<keyof typeof HealthkitAuthorization>
|
|
720
748
|
): Promise<boolean>;
|
|
721
749
|
getRequestStatusForAuthorization(
|
|
722
|
-
write:
|
|
723
|
-
read:
|
|
750
|
+
write: WritePermissions,
|
|
751
|
+
read: ReadPermissions
|
|
724
752
|
): Promise<HKAuthorizationRequestStatus>;
|
|
725
753
|
requestAuthorization(
|
|
726
|
-
write:
|
|
727
|
-
read:
|
|
754
|
+
write: WritePermissions,
|
|
755
|
+
read: ReadPermissions
|
|
728
756
|
): Promise<boolean>;
|
|
729
|
-
saveQuantitySample: (
|
|
757
|
+
readonly saveQuantitySample: (
|
|
730
758
|
identifier: HKQuantityTypeIdentifier,
|
|
731
759
|
unit: HKUnit,
|
|
732
760
|
value: number,
|
|
733
761
|
start: string,
|
|
734
762
|
end: string,
|
|
735
|
-
metadata:
|
|
763
|
+
metadata: unknown
|
|
736
764
|
) => Promise<boolean>;
|
|
737
|
-
queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
|
|
765
|
+
readonly queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
|
|
738
766
|
energyUnit: TEnergy,
|
|
739
767
|
distanceUnit: TDistance,
|
|
740
768
|
from: string,
|
|
741
769
|
to: string,
|
|
742
|
-
limit:
|
|
770
|
+
limit: number,
|
|
743
771
|
ascending: boolean
|
|
744
|
-
) => Promise<HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
745
|
-
queryCategorySamples: <T extends HKCategoryTypeIdentifier>(
|
|
772
|
+
) => Promise<readonly HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
773
|
+
readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(
|
|
746
774
|
identifier: T,
|
|
747
775
|
from: string,
|
|
748
776
|
to: string,
|
|
749
|
-
limit:
|
|
777
|
+
limit: number,
|
|
750
778
|
ascending: boolean
|
|
751
|
-
) => Promise<HKCategorySampleRaw<T>[]>;
|
|
752
|
-
queryQuantitySamples: <
|
|
779
|
+
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
780
|
+
readonly queryQuantitySamples: <
|
|
753
781
|
TUnit extends HKUnit,
|
|
754
782
|
TIdentifier extends HKQuantityTypeIdentifier
|
|
755
783
|
>(
|
|
@@ -757,46 +785,46 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
757
785
|
unit: TUnit,
|
|
758
786
|
from: string,
|
|
759
787
|
to: string,
|
|
760
|
-
limit:
|
|
788
|
+
limit: number,
|
|
761
789
|
ascending: boolean
|
|
762
|
-
) => Promise<HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
|
|
763
|
-
saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
790
|
+
) => Promise<readonly HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
|
|
791
|
+
readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
764
792
|
identifier: T,
|
|
765
793
|
value: HKCategoryValueForIdentifier<T>,
|
|
766
794
|
start: string,
|
|
767
795
|
end: string,
|
|
768
|
-
metadata:
|
|
796
|
+
metadata: unknown
|
|
769
797
|
) => Promise<boolean>;
|
|
770
|
-
queryStatisticsForQuantity: <TUnit extends HKUnit>(
|
|
798
|
+
readonly queryStatisticsForQuantity: <TUnit extends HKUnit>(
|
|
771
799
|
identifier: HKQuantityTypeIdentifier,
|
|
772
800
|
unit: TUnit,
|
|
773
801
|
from: string,
|
|
774
802
|
to: string,
|
|
775
|
-
options: HKStatisticsOptions[]
|
|
803
|
+
options: readonly HKStatisticsOptions[]
|
|
776
804
|
) => Promise<QueryStatisticsResponseRaw<TUnit>>;
|
|
777
|
-
getPreferredUnits: (
|
|
778
|
-
identifiers: HKQuantityTypeIdentifier[]
|
|
805
|
+
readonly getPreferredUnits: (
|
|
806
|
+
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
779
807
|
) => Promise<TypeToUnitMapping>;
|
|
808
|
+
readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
|
|
780
809
|
};
|
|
781
810
|
|
|
782
|
-
const Native =
|
|
783
|
-
NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative;
|
|
811
|
+
const Native = NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative
|
|
784
812
|
|
|
785
813
|
type OnChangeCallback = ({
|
|
786
814
|
typeIdentifier,
|
|
787
815
|
}: {
|
|
788
|
-
typeIdentifier: HKSampleTypeIdentifier
|
|
816
|
+
readonly typeIdentifier: ValueOf<typeof HKSampleTypeIdentifier>;
|
|
789
817
|
}) => void;
|
|
790
818
|
|
|
791
819
|
interface HealthkitEventEmitter extends NativeEventEmitter {
|
|
792
|
-
addListener: (
|
|
820
|
+
readonly addListener: (
|
|
793
821
|
eventType: 'onChange',
|
|
794
822
|
callback: OnChangeCallback
|
|
795
823
|
) => EmitterSubscription;
|
|
796
824
|
}
|
|
797
825
|
|
|
798
826
|
export const EventEmitter = new NativeEventEmitter(
|
|
799
|
-
NativeModules.ReactNativeHealthkit
|
|
800
|
-
) as HealthkitEventEmitter
|
|
827
|
+
NativeModules.ReactNativeHealthkit,
|
|
828
|
+
) as HealthkitEventEmitter
|
|
801
829
|
|
|
802
|
-
export default Native
|
|
830
|
+
export default Native
|