@kingstinct/react-native-healthkit 4.3.0 → 4.4.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/ios/ReactNativeHealthkit.swift +2 -2
- package/lib/commonjs/index.ios.js +123 -104
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +50 -37
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +127 -106
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.ios.js +124 -105
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +51 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +118 -103
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/native-types.d.ts +452 -217
- package/lib/typescript/src/types.d.ts +85 -83
- package/package.json +21 -35
- package/src/index.ios.tsx +299 -273
- package/src/index.tsx +63 -46
- package/src/native-types.ts +310 -301
- package/src/types.ts +113 -107
package/src/native-types.ts
CHANGED
|
@@ -1,20 +1,126 @@
|
|
|
1
1
|
import {
|
|
2
|
-
EmitterSubscription,
|
|
3
2
|
NativeEventEmitter,
|
|
4
3
|
NativeModules,
|
|
5
|
-
} from 'react-native'
|
|
4
|
+
} from 'react-native'
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import type { EmitterSubscription } from 'react-native'
|
|
7
|
+
import type { ValueOf } from 'type-fest'
|
|
9
8
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
| HKAudiogramTypeIdentifier
|
|
15
|
-
| HKCorrelationTypeIdentifier;
|
|
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
|
|
16
13
|
|
|
17
|
-
|
|
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
|
|
110
|
+
|
|
111
|
+
// Mobility
|
|
112
|
+
sixMinuteWalkTestDistance = 'HKQuantityTypeIdentifierSixMinuteWalkTestDistance',
|
|
113
|
+
walkingSpeed = 'HKQuantityTypeIdentifierWalkingSpeed',
|
|
114
|
+
walkingStepLength = 'HKQuantityTypeIdentifierWalkingStepLength',
|
|
115
|
+
walkingAsymmetryPercentage = 'HKQuantityTypeIdentifierWalkingAsymmetryPercentage',
|
|
116
|
+
walkingDoubleSupportPercentage = 'HKQuantityTypeIdentifierWalkingDoubleSupportPercentage',
|
|
117
|
+
stairAscentSpeed = 'HKQuantityTypeIdentifierStairAscentSpeed',
|
|
118
|
+
stairDescentSpeed = 'HKQuantityTypeIdentifierStairDescentSpeed',
|
|
119
|
+
|
|
120
|
+
uvExposure = 'HKQuantityTypeIdentifierUvExposure', // Scalar (Count), Discrete
|
|
121
|
+
}
|
|
122
|
+
|
|
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,21 @@ 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
|
+
|
|
164
|
+
export type SampleTypeIdentifier = ValueOf<typeof HKSampleTypeIdentifier>;
|
|
165
|
+
|
|
166
|
+
export type HealthkitReadAuthorization = ValueOf<typeof HealthkitAuthorization>
|
|
167
|
+
export type HealthkitWriteAuthorization = ValueOf<typeof HealthkitAuthorization>
|
|
168
|
+
|
|
43
169
|
export enum HKCategoryValueAppleStandHour {
|
|
44
170
|
stood = 0,
|
|
45
171
|
idle = 1,
|
|
@@ -126,21 +252,21 @@ export enum HKWorkoutActivityType {
|
|
|
126
252
|
}
|
|
127
253
|
|
|
128
254
|
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;
|
|
255
|
+
readonly [key: string]: HKQuantity | boolean | number | string | undefined;
|
|
256
|
+
readonly HKExternalUUID?: string;
|
|
257
|
+
readonly HKTimeZone?: string;
|
|
258
|
+
readonly HKWasUserEntered?: boolean;
|
|
259
|
+
readonly HKDeviceSerialNumber?: string;
|
|
260
|
+
readonly HKUDIDeviceIdentifier?: string;
|
|
261
|
+
readonly HKUDIProductionIdentifier?: string;
|
|
262
|
+
readonly HKDigitalSignature?: string;
|
|
263
|
+
readonly HKDeviceName?: string;
|
|
264
|
+
readonly HKDeviceManufacturerName?: string;
|
|
265
|
+
readonly HKSyncIdentifier?: string;
|
|
266
|
+
readonly HKSyncVersion?: number;
|
|
267
|
+
readonly HKWasTakenInLab?: boolean;
|
|
268
|
+
readonly HKReferenceRangeLowerLimit?: number;
|
|
269
|
+
readonly HKReferenceRangeUpperLimit?: number;
|
|
144
270
|
};
|
|
145
271
|
|
|
146
272
|
// documented at https://developer.apple.com/documentation/healthkit/hkweathercondition
|
|
@@ -176,121 +302,12 @@ export enum HKWeatherCondition {
|
|
|
176
302
|
}
|
|
177
303
|
|
|
178
304
|
export interface HKWorkoutMetadata
|
|
179
|
-
extends HKGenericMetadata
|
|
180
|
-
HKWeatherCondition?: HKWeatherCondition;
|
|
181
|
-
HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
305
|
+
extends HKGenericMetadata /* <TTemperatureUnit extends HKUnit> */ {
|
|
306
|
+
readonly HKWeatherCondition?: HKWeatherCondition;
|
|
307
|
+
readonly HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
182
308
|
// HKWeatherTemperature: HKQuantity<TTemperatureUnit>
|
|
183
309
|
}
|
|
184
310
|
|
|
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
311
|
export enum HKAuthorizationRequestStatus {
|
|
295
312
|
unknown = 0,
|
|
296
313
|
shouldRequest = 1,
|
|
@@ -304,8 +321,8 @@ export enum HKAuthorizationStatus {
|
|
|
304
321
|
}
|
|
305
322
|
|
|
306
323
|
export type HKQuantity<T extends HKUnit = HKUnit> = {
|
|
307
|
-
unit: T;
|
|
308
|
-
quantity: number;
|
|
324
|
+
readonly unit: T;
|
|
325
|
+
readonly quantity: number;
|
|
309
326
|
};
|
|
310
327
|
|
|
311
328
|
export enum HKBloodType {
|
|
@@ -349,13 +366,13 @@ export enum HKStatisticsOptions {
|
|
|
349
366
|
}
|
|
350
367
|
|
|
351
368
|
export type QueryStatisticsResponseRaw<TUnit extends HKUnit = HKUnit> = {
|
|
352
|
-
averageQuantity?: HKQuantity<TUnit>;
|
|
353
|
-
maximumQuantity?: HKQuantity<TUnit>;
|
|
354
|
-
minimumQuantity?: HKQuantity<TUnit>;
|
|
355
|
-
sumQuantity?: HKQuantity<TUnit>;
|
|
356
|
-
mostRecentQuantity?: HKQuantity<TUnit>;
|
|
357
|
-
mostRecentQuantityDateInterval?: { from: string; to: string };
|
|
358
|
-
duration?: HKQuantity<HKUnit.Seconds>;
|
|
369
|
+
readonly averageQuantity?: HKQuantity<TUnit>;
|
|
370
|
+
readonly maximumQuantity?: HKQuantity<TUnit>;
|
|
371
|
+
readonly minimumQuantity?: HKQuantity<TUnit>;
|
|
372
|
+
readonly sumQuantity?: HKQuantity<TUnit>;
|
|
373
|
+
readonly mostRecentQuantity?: HKQuantity<TUnit>;
|
|
374
|
+
readonly mostRecentQuantityDateInterval?: { readonly from: string; readonly to: string };
|
|
375
|
+
readonly duration?: HKQuantity<HKUnit.Seconds>;
|
|
359
376
|
};
|
|
360
377
|
|
|
361
378
|
export enum HKCategoryValueCervicalMucusQuality {
|
|
@@ -413,13 +430,13 @@ export enum HKCategoryValueNotApplicable {
|
|
|
413
430
|
|
|
414
431
|
export type HKCategoryValue =
|
|
415
432
|
| HKCategoryValueAppetiteChanges
|
|
433
|
+
| HKCategoryValueCervicalMucusQuality
|
|
434
|
+
| HKCategoryValueMenstrualFlow
|
|
435
|
+
| HKCategoryValueOvulationTestResult
|
|
416
436
|
| HKCategoryValuePresence
|
|
417
|
-
| HKCategoryValueSeverity
|
|
418
437
|
| HKCategoryValuePresence
|
|
419
|
-
|
|
|
438
|
+
| HKCategoryValueSeverity
|
|
420
439
|
| HKCategoryValueSleepAnalysis
|
|
421
|
-
| HKCategoryValueCervicalMucusQuality
|
|
422
|
-
| HKCategoryValueOvulationTestResult
|
|
423
440
|
| number;
|
|
424
441
|
|
|
425
442
|
export enum HKInsulinDeliveryReason {
|
|
@@ -431,58 +448,58 @@ export type MetadataMapperForQuantityIdentifier<
|
|
|
431
448
|
TQuantityTypeIdentifier = HKQuantityTypeIdentifier
|
|
432
449
|
> = TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.insulinDelivery
|
|
433
450
|
? HKGenericMetadata & {
|
|
434
|
-
|
|
435
|
-
|
|
451
|
+
readonly HKInsulinDeliveryReason: HKInsulinDeliveryReason;
|
|
452
|
+
}
|
|
436
453
|
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.bloodGlucose
|
|
437
|
-
|
|
438
|
-
HKBloodGlucoseMealTime?: number;
|
|
439
|
-
}
|
|
440
|
-
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.heartRate
|
|
441
|
-
? HKGenericMetadata & {
|
|
442
|
-
HKHeartRateMotionContext?: HKHeartRateMotionContext;
|
|
454
|
+
? HKGenericMetadata & {
|
|
455
|
+
readonly HKBloodGlucoseMealTime?: number;
|
|
443
456
|
}
|
|
444
|
-
|
|
457
|
+
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.heartRate
|
|
458
|
+
? HKGenericMetadata & {
|
|
459
|
+
readonly HKHeartRateMotionContext?: HKHeartRateMotionContext;
|
|
460
|
+
}
|
|
461
|
+
: HKGenericMetadata;
|
|
445
462
|
|
|
446
463
|
export type MetadataMapperForCorrelationIdentifier<
|
|
447
464
|
TCorrelationTypeIdentifier = HKCorrelationTypeIdentifier
|
|
448
465
|
> = TCorrelationTypeIdentifier extends HKCorrelationTypeIdentifier.food
|
|
449
466
|
? HKGenericMetadata & {
|
|
450
|
-
|
|
451
|
-
|
|
467
|
+
readonly HKFoodType?: string;
|
|
468
|
+
}
|
|
452
469
|
: HKGenericMetadata;
|
|
453
470
|
|
|
454
471
|
export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
|
|
455
472
|
T extends HKCategoryTypeIdentifier.cervicalMucusQuality
|
|
456
473
|
? HKCategoryValueCervicalMucusQuality
|
|
457
474
|
: T extends HKCategoryTypeIdentifier.menstrualFlow
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
475
|
+
? HKCategoryValueMenstrualFlow
|
|
476
|
+
: T extends HKCategoryTypeIdentifier.ovulationTestResult
|
|
477
|
+
? HKCategoryValueOvulationTestResult
|
|
478
|
+
: T extends HKCategoryTypeIdentifier.sleepAnalysis
|
|
479
|
+
? HKCategoryValueSleepAnalysis
|
|
480
|
+
: T extends HKCategoryTypeIdentifier.mindfulSession
|
|
481
|
+
? HKCategoryValueNotApplicable
|
|
482
|
+
: T extends HKCategoryTypeIdentifier.intermenstrualBleeding
|
|
483
|
+
? HKCategoryValueNotApplicable
|
|
484
|
+
: T extends HKCategoryTypeIdentifier.highHeartRateEvent
|
|
485
|
+
? HKCategoryValueNotApplicable
|
|
486
|
+
: T extends HKCategoryTypeIdentifier.sexualActivity
|
|
487
|
+
? HKCategoryValueNotApplicable
|
|
488
|
+
: T extends HKCategoryTypeIdentifier.appleStandHour
|
|
489
|
+
? HKCategoryValueAppleStandHour
|
|
490
|
+
: number;
|
|
474
491
|
|
|
475
492
|
export type MetadataMapperForCategoryIdentifier<
|
|
476
493
|
T extends HKCategoryTypeIdentifier
|
|
477
494
|
> = T extends HKCategoryTypeIdentifier.sexualActivity
|
|
478
495
|
? HKGenericMetadata & {
|
|
479
|
-
|
|
480
|
-
|
|
496
|
+
readonly HKSexualActivityProtectionUsed: boolean;
|
|
497
|
+
}
|
|
481
498
|
: T extends HKCategoryTypeIdentifier.menstrualFlow
|
|
482
|
-
|
|
483
|
-
HKMenstrualCycleStart: boolean;
|
|
499
|
+
? HKGenericMetadata & {
|
|
500
|
+
readonly HKMenstrualCycleStart: boolean;
|
|
484
501
|
}
|
|
485
|
-
|
|
502
|
+
: HKGenericMetadata;
|
|
486
503
|
|
|
487
504
|
// Maps directly to https://developer.apple.com/documentation/healthkit/hkwheelchairuse
|
|
488
505
|
export enum HKWheelchairUse {
|
|
@@ -564,53 +581,55 @@ export enum HKUnit {
|
|
|
564
581
|
}
|
|
565
582
|
|
|
566
583
|
export type HKDevice = {
|
|
567
|
-
name: string;
|
|
568
|
-
firmwareVersion: string;
|
|
569
|
-
hardwareVersion: string;
|
|
570
|
-
localIdentifier: string;
|
|
571
|
-
manufacturer: string;
|
|
572
|
-
model: string;
|
|
573
|
-
softwareVersion: string;
|
|
584
|
+
readonly name: string;
|
|
585
|
+
readonly firmwareVersion: string;
|
|
586
|
+
readonly hardwareVersion: string;
|
|
587
|
+
readonly localIdentifier: string;
|
|
588
|
+
readonly manufacturer: string;
|
|
589
|
+
readonly model: string;
|
|
590
|
+
readonly softwareVersion: string;
|
|
574
591
|
};
|
|
575
592
|
|
|
576
593
|
export type HKSource = {
|
|
577
|
-
name: string;
|
|
578
|
-
bundleIdentifier: string;
|
|
594
|
+
readonly name: string;
|
|
595
|
+
readonly bundleIdentifier: string;
|
|
579
596
|
};
|
|
580
597
|
|
|
581
598
|
export type HKSourceRevision = {
|
|
582
|
-
source: HKSource;
|
|
583
|
-
version: string;
|
|
584
|
-
operatingSystemVersion?: string;
|
|
585
|
-
productType?: string;
|
|
599
|
+
readonly source: HKSource;
|
|
600
|
+
readonly version: string;
|
|
601
|
+
readonly operatingSystemVersion?: string;
|
|
602
|
+
readonly productType?: string;
|
|
586
603
|
};
|
|
587
604
|
|
|
588
605
|
export type HKQuantitySampleRaw<
|
|
589
606
|
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
590
607
|
TUnit extends HKUnit = HKUnit
|
|
591
608
|
> = {
|
|
592
|
-
uuid: string;
|
|
593
|
-
device?: HKDevice;
|
|
594
|
-
quantityType: TQuantityIdentifier;
|
|
595
|
-
startDate: string;
|
|
596
|
-
endDate: string;
|
|
597
|
-
quantity: number;
|
|
598
|
-
unit: TUnit;
|
|
599
|
-
metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
|
|
600
|
-
sourceRevision?: HKSourceRevision;
|
|
609
|
+
readonly uuid: string;
|
|
610
|
+
readonly device?: HKDevice;
|
|
611
|
+
readonly quantityType: TQuantityIdentifier;
|
|
612
|
+
readonly startDate: string;
|
|
613
|
+
readonly endDate: string;
|
|
614
|
+
readonly quantity: number;
|
|
615
|
+
readonly unit: TUnit;
|
|
616
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
|
|
617
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
601
618
|
};
|
|
602
619
|
|
|
603
620
|
export type HKWorkoutRaw<TEnergy extends HKUnit, TDistance extends HKUnit> = {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
621
|
+
readonly uuid: string;
|
|
622
|
+
readonly device?: HKDevice;
|
|
623
|
+
readonly workoutActivityType: HKWorkoutActivityType;
|
|
624
|
+
readonly duration: number;
|
|
625
|
+
readonly totalDistance?: HKQuantity<TDistance>;
|
|
626
|
+
readonly totalEnergyBurned?: HKQuantity<TEnergy>;
|
|
627
|
+
readonly totalSwimmingStrokeCount?: HKQuantity<HKUnit.Count>;
|
|
628
|
+
readonly totalFlightsClimbed?: HKQuantity<HKUnit.Count>;
|
|
629
|
+
readonly startDate: string;
|
|
630
|
+
readonly endDate: string;
|
|
631
|
+
readonly metadata?: HKWorkoutMetadata;
|
|
632
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
614
633
|
};
|
|
615
634
|
|
|
616
635
|
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkcharacteristictypeidentifier
|
|
@@ -622,49 +641,38 @@ export enum HKCharacteristicTypeIdentifier {
|
|
|
622
641
|
wheelchairUse = 'HKCharacteristicTypeIdentifierWheelchairUse',
|
|
623
642
|
}
|
|
624
643
|
|
|
625
|
-
export type
|
|
626
|
-
[key in
|
|
627
|
-
| HKCharacteristicTypeIdentifier
|
|
628
|
-
| HKQuantityTypeIdentifier
|
|
629
|
-
| HKCategoryTypeIdentifier]: boolean;
|
|
644
|
+
export type WritePermissions = {
|
|
645
|
+
readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
|
|
630
646
|
};
|
|
631
647
|
|
|
632
|
-
export type
|
|
633
|
-
[key in
|
|
634
|
-
| HKQuantityTypeIdentifier
|
|
635
|
-
| HKCharacteristicTypeIdentifier
|
|
636
|
-
| HKCategoryTypeIdentifier]: boolean;
|
|
648
|
+
export type ReadPermissions = {
|
|
649
|
+
readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
|
|
637
650
|
};
|
|
638
651
|
|
|
639
652
|
export type HKCategorySampleRaw<
|
|
640
653
|
T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
641
654
|
> = {
|
|
642
|
-
uuid: string;
|
|
643
|
-
device?: HKDevice;
|
|
644
|
-
categoryType: T;
|
|
645
|
-
startDate: string;
|
|
646
|
-
endDate: string;
|
|
647
|
-
value: HKCategoryValueForIdentifier<T>;
|
|
648
|
-
metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
649
|
-
sourceRevision?: HKSourceRevision;
|
|
655
|
+
readonly uuid: string;
|
|
656
|
+
readonly device?: HKDevice;
|
|
657
|
+
readonly categoryType: T;
|
|
658
|
+
readonly startDate: string;
|
|
659
|
+
readonly endDate: string;
|
|
660
|
+
readonly value: HKCategoryValueForIdentifier<T>;
|
|
661
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
662
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
650
663
|
};
|
|
651
664
|
|
|
652
665
|
export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
653
666
|
{
|
|
654
|
-
correlationType: HKCorrelationTypeIdentifier;
|
|
655
|
-
objects: (
|
|
656
|
-
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
657
|
-
startDate: string;
|
|
658
|
-
endDate: string;
|
|
667
|
+
readonly correlationType: HKCorrelationTypeIdentifier;
|
|
668
|
+
readonly objects: readonly (HKCategorySampleRaw | HKQuantitySampleRaw)[];
|
|
669
|
+
readonly metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
670
|
+
readonly startDate: string;
|
|
671
|
+
readonly endDate: string;
|
|
659
672
|
};
|
|
660
673
|
|
|
661
674
|
type QueryId = string;
|
|
662
675
|
|
|
663
|
-
export enum HKCorrelationTypeIdentifier {
|
|
664
|
-
bloodPressure = 'HKCorrelationTypeIdentifierBloodPressure',
|
|
665
|
-
food = 'HKCorrelationTypeIdentifierFood',
|
|
666
|
-
}
|
|
667
|
-
|
|
668
676
|
export enum HKUpdateFrequency {
|
|
669
677
|
immediate = 1,
|
|
670
678
|
hourly = 2,
|
|
@@ -673,106 +681,108 @@ export enum HKUpdateFrequency {
|
|
|
673
681
|
}
|
|
674
682
|
|
|
675
683
|
export type WorkoutLocation = {
|
|
676
|
-
longitude: number;
|
|
677
|
-
latitude: number;
|
|
678
|
-
altitude: number;
|
|
679
|
-
speed: number;
|
|
680
|
-
timestamp: number;
|
|
681
|
-
horizontalAccuracy: number;
|
|
682
|
-
speedAccuracy: number;
|
|
683
|
-
verticalAccuracy: number;
|
|
684
|
+
readonly longitude: number;
|
|
685
|
+
readonly latitude: number;
|
|
686
|
+
readonly altitude: number;
|
|
687
|
+
readonly speed: number;
|
|
688
|
+
readonly timestamp: number;
|
|
689
|
+
readonly horizontalAccuracy: number;
|
|
690
|
+
readonly speedAccuracy: number;
|
|
691
|
+
readonly verticalAccuracy: number;
|
|
684
692
|
};
|
|
685
693
|
|
|
686
694
|
export type WorkoutRoute = {
|
|
687
|
-
locations: WorkoutLocation[];
|
|
688
|
-
HKMetadataKeySyncIdentifier?: string;
|
|
689
|
-
HKMetadataKeySyncVersion?: number;
|
|
695
|
+
readonly locations: readonly WorkoutLocation[];
|
|
696
|
+
readonly HKMetadataKeySyncIdentifier?: string;
|
|
697
|
+
readonly HKMetadataKeySyncVersion?: number;
|
|
690
698
|
};
|
|
691
699
|
|
|
700
|
+
export const HealthkitAuthorization = { ...HKCharacteristicTypeIdentifier, ...HKSampleTypeIdentifier }
|
|
701
|
+
|
|
692
702
|
type ReactNativeHealthkitTypeNative = {
|
|
693
703
|
isHealthDataAvailable(): Promise<boolean>;
|
|
694
704
|
getBloodType(): Promise<HKBloodType>;
|
|
695
705
|
getDateOfBirth(): Promise<string>;
|
|
696
706
|
getBiologicalSex(): Promise<HKBiologicalSex>;
|
|
697
707
|
getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
|
|
698
|
-
getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
708
|
+
readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
699
709
|
|
|
700
|
-
enableBackgroundDelivery: (
|
|
701
|
-
typeIdentifier: HKSampleTypeIdentifier
|
|
710
|
+
readonly enableBackgroundDelivery: (
|
|
711
|
+
typeIdentifier: ValueOf<typeof HKSampleTypeIdentifier>,
|
|
702
712
|
updateFrequency: HKUpdateFrequency
|
|
703
713
|
) => Promise<boolean>;
|
|
704
|
-
disableBackgroundDelivery: (
|
|
705
|
-
typeIdentifier: HKSampleTypeIdentifier
|
|
714
|
+
readonly disableBackgroundDelivery: (
|
|
715
|
+
typeIdentifier: ValueOf<typeof HKSampleTypeIdentifier>,
|
|
706
716
|
) => Promise<boolean>;
|
|
707
|
-
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
717
|
+
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
708
718
|
|
|
709
|
-
saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
719
|
+
readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
710
720
|
typeIdentifier: TIdentifier,
|
|
711
|
-
samples: Omit<
|
|
712
|
-
|
|
713
|
-
|
|
721
|
+
samples: readonly Omit<
|
|
722
|
+
HKCategorySampleRaw | HKQuantitySampleRaw,
|
|
723
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
714
724
|
>[],
|
|
715
725
|
start: string,
|
|
716
726
|
end: string,
|
|
717
727
|
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>
|
|
718
728
|
) => Promise<boolean>;
|
|
719
729
|
|
|
720
|
-
saveWorkoutSample: (
|
|
730
|
+
readonly saveWorkoutSample: (
|
|
721
731
|
typeIdentifier: HKWorkoutActivityType,
|
|
722
|
-
quantities: Omit<
|
|
723
|
-
|
|
724
|
-
|
|
732
|
+
quantities: readonly Omit<
|
|
733
|
+
HKQuantitySampleRaw,
|
|
734
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
725
735
|
>[],
|
|
726
736
|
start: string,
|
|
727
737
|
end: string,
|
|
728
738
|
metadata: HKWorkoutMetadata
|
|
729
739
|
) => Promise<boolean>;
|
|
730
740
|
|
|
731
|
-
queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
741
|
+
readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
732
742
|
typeIdentifier: TIdentifier,
|
|
733
743
|
from: string,
|
|
734
744
|
to: string
|
|
735
|
-
) => Promise<HKCorrelationRaw<TIdentifier>[]>;
|
|
745
|
+
) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
|
|
736
746
|
|
|
737
747
|
subscribeToObserverQuery(
|
|
738
|
-
identifier: HKSampleTypeIdentifier
|
|
748
|
+
identifier: ValueOf<typeof HKSampleTypeIdentifier>
|
|
739
749
|
): Promise<QueryId>;
|
|
740
750
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
741
751
|
authorizationStatusFor(
|
|
742
|
-
type:
|
|
752
|
+
type: ValueOf<keyof typeof HealthkitAuthorization>
|
|
743
753
|
): Promise<boolean>;
|
|
744
754
|
getRequestStatusForAuthorization(
|
|
745
|
-
write:
|
|
746
|
-
read:
|
|
755
|
+
write: WritePermissions,
|
|
756
|
+
read: ReadPermissions
|
|
747
757
|
): Promise<HKAuthorizationRequestStatus>;
|
|
748
758
|
requestAuthorization(
|
|
749
|
-
write:
|
|
750
|
-
read:
|
|
759
|
+
write: WritePermissions,
|
|
760
|
+
read: ReadPermissions
|
|
751
761
|
): Promise<boolean>;
|
|
752
|
-
saveQuantitySample: (
|
|
762
|
+
readonly saveQuantitySample: (
|
|
753
763
|
identifier: HKQuantityTypeIdentifier,
|
|
754
764
|
unit: HKUnit,
|
|
755
765
|
value: number,
|
|
756
766
|
start: string,
|
|
757
767
|
end: string,
|
|
758
|
-
metadata:
|
|
768
|
+
metadata: unknown
|
|
759
769
|
) => Promise<boolean>;
|
|
760
|
-
queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
|
|
770
|
+
readonly queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
|
|
761
771
|
energyUnit: TEnergy,
|
|
762
772
|
distanceUnit: TDistance,
|
|
763
773
|
from: string,
|
|
764
774
|
to: string,
|
|
765
|
-
limit:
|
|
775
|
+
limit: number,
|
|
766
776
|
ascending: boolean
|
|
767
|
-
) => Promise<HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
768
|
-
queryCategorySamples: <T extends HKCategoryTypeIdentifier>(
|
|
777
|
+
) => Promise<readonly HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
778
|
+
readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(
|
|
769
779
|
identifier: T,
|
|
770
780
|
from: string,
|
|
771
781
|
to: string,
|
|
772
|
-
limit:
|
|
782
|
+
limit: number,
|
|
773
783
|
ascending: boolean
|
|
774
|
-
) => Promise<HKCategorySampleRaw<T>[]>;
|
|
775
|
-
queryQuantitySamples: <
|
|
784
|
+
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
785
|
+
readonly queryQuantitySamples: <
|
|
776
786
|
TUnit extends HKUnit,
|
|
777
787
|
TIdentifier extends HKQuantityTypeIdentifier
|
|
778
788
|
>(
|
|
@@ -780,47 +790,46 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
780
790
|
unit: TUnit,
|
|
781
791
|
from: string,
|
|
782
792
|
to: string,
|
|
783
|
-
limit:
|
|
793
|
+
limit: number,
|
|
784
794
|
ascending: boolean
|
|
785
|
-
) => Promise<HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
|
|
786
|
-
saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
795
|
+
) => Promise<readonly HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
|
|
796
|
+
readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
787
797
|
identifier: T,
|
|
788
798
|
value: HKCategoryValueForIdentifier<T>,
|
|
789
799
|
start: string,
|
|
790
800
|
end: string,
|
|
791
|
-
metadata:
|
|
801
|
+
metadata: unknown
|
|
792
802
|
) => Promise<boolean>;
|
|
793
|
-
queryStatisticsForQuantity: <TUnit extends HKUnit>(
|
|
803
|
+
readonly queryStatisticsForQuantity: <TUnit extends HKUnit>(
|
|
794
804
|
identifier: HKQuantityTypeIdentifier,
|
|
795
805
|
unit: TUnit,
|
|
796
806
|
from: string,
|
|
797
807
|
to: string,
|
|
798
|
-
options: HKStatisticsOptions[]
|
|
808
|
+
options: readonly HKStatisticsOptions[]
|
|
799
809
|
) => Promise<QueryStatisticsResponseRaw<TUnit>>;
|
|
800
|
-
getPreferredUnits: (
|
|
801
|
-
identifiers: HKQuantityTypeIdentifier[]
|
|
810
|
+
readonly getPreferredUnits: (
|
|
811
|
+
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
802
812
|
) => Promise<TypeToUnitMapping>;
|
|
803
|
-
getWorkoutRoutes: (workoutUUID: string) => Promise<WorkoutRoute[]>;
|
|
813
|
+
readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
|
|
804
814
|
};
|
|
805
815
|
|
|
806
|
-
const Native =
|
|
807
|
-
NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative;
|
|
816
|
+
const Native = NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative
|
|
808
817
|
|
|
809
818
|
type OnChangeCallback = ({
|
|
810
819
|
typeIdentifier,
|
|
811
820
|
}: {
|
|
812
|
-
typeIdentifier: HKSampleTypeIdentifier
|
|
821
|
+
readonly typeIdentifier: ValueOf<typeof HKSampleTypeIdentifier>;
|
|
813
822
|
}) => void;
|
|
814
823
|
|
|
815
824
|
interface HealthkitEventEmitter extends NativeEventEmitter {
|
|
816
|
-
addListener: (
|
|
825
|
+
readonly addListener: (
|
|
817
826
|
eventType: 'onChange',
|
|
818
827
|
callback: OnChangeCallback
|
|
819
828
|
) => EmitterSubscription;
|
|
820
829
|
}
|
|
821
830
|
|
|
822
831
|
export const EventEmitter = new NativeEventEmitter(
|
|
823
|
-
NativeModules.ReactNativeHealthkit
|
|
824
|
-
) as HealthkitEventEmitter
|
|
832
|
+
NativeModules.ReactNativeHealthkit,
|
|
833
|
+
) as HealthkitEventEmitter
|
|
825
834
|
|
|
826
|
-
export default Native
|
|
835
|
+
export default Native
|