@kingstinct/react-native-healthkit 13.3.1 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReactNativeHealthkit.podspec +1 -0
- package/app.plugin.ts +40 -2
- package/ios/BackgroundDeliveryManager.swift +196 -0
- package/ios/CategoryTypeModule.swift +1 -1
- package/ios/CoreModule.swift +24 -0
- package/ios/CorrelationTypeModule.swift +2 -35
- package/ios/ElectrocardiogramModule.swift +2 -34
- package/ios/HeartbeatSeriesModule.swift +2 -34
- package/ios/MedicationModule.swift +3 -35
- package/ios/PredicateHelpers.swift +2 -2
- package/ios/QuantityTypeModule.swift +11 -11
- package/ios/Serializers.swift +58 -90
- package/ios/StateOfMindModule.swift +2 -34
- package/ios/WorkoutProxy.swift +4 -149
- package/ios/generated/HealthkitGenerated.swift +52 -0
- package/lib/commonjs/generated/healthkit.generated.js +745 -0
- package/lib/commonjs/healthkit.ios.js +51 -17
- package/lib/commonjs/healthkit.js +120 -34
- package/lib/commonjs/specs/QuantityTypeModule.nitro.js +1 -0
- package/lib/commonjs/type-tests/generated-typing.js +2 -0
- package/lib/commonjs/types/CategoryType.js +19 -99
- package/lib/commonjs/types/Medication.js +2 -0
- package/lib/commonjs/types/MetadataEnums.js +17 -0
- package/lib/commonjs/types/QuantityType.js +4 -15
- package/lib/commonjs/types/WeatherCondition.js +2 -32
- package/lib/commonjs/types/Workouts.js +3 -98
- package/lib/commonjs/types/index.js +2 -0
- package/lib/module/generated/healthkit.generated.js +742 -0
- package/lib/module/healthkit.ios.js +49 -15
- package/lib/module/healthkit.js +94 -20
- package/lib/module/specs/QuantityTypeModule.nitro.js +1 -0
- package/lib/module/type-tests/generated-typing.js +1 -0
- package/lib/module/types/CategoryType.js +2 -98
- package/lib/module/types/Medication.js +1 -0
- package/lib/module/types/MetadataEnums.js +1 -0
- package/lib/module/types/QuantityType.js +2 -14
- package/lib/module/types/WeatherCondition.js +1 -32
- package/lib/module/types/Workouts.js +2 -98
- package/lib/module/types/index.js +2 -0
- package/lib/typescript/generated/healthkit.generated.d.ts +1006 -0
- package/lib/typescript/healthkit.d.ts +39 -36
- package/lib/typescript/healthkit.ios.d.ts +64 -53
- package/lib/typescript/hooks/useMostRecentQuantitySample.d.ts +3 -2
- package/lib/typescript/hooks/useMostRecentWorkout.d.ts +2 -2
- package/lib/typescript/hooks/useQuantitySampleById.d.ts +5 -4
- package/lib/typescript/hooks/useStatisticsForQuantity.d.ts +2 -2
- package/lib/typescript/hooks/useSubscribeToQuantitySamples.d.ts +1 -1
- package/lib/typescript/modules.d.ts +2 -2
- package/lib/typescript/specs/CategoryTypeModule.nitro.d.ts +3 -3
- package/lib/typescript/specs/CoreModule.nitro.d.ts +15 -0
- package/lib/typescript/specs/QuantityTypeModule.nitro.d.ts +20 -9
- package/lib/typescript/type-tests/generated-typing.d.ts +1 -0
- package/lib/typescript/types/CategoryType.d.ts +10 -104
- package/lib/typescript/types/CategoryTypeIdentifier.d.ts +1 -61
- package/lib/typescript/types/CorrelationType.d.ts +8 -2
- package/lib/typescript/types/ElectrocardiogramSample.d.ts +8 -1
- package/lib/typescript/types/HeartbeatSeries.d.ts +8 -1
- package/lib/typescript/types/InterfaceVerification.d.ts +14 -1
- package/lib/typescript/types/Medication.d.ts +10 -0
- package/lib/typescript/types/MetadataEnums.d.ts +1 -0
- package/lib/typescript/types/QuantitySample.d.ts +9 -1
- package/lib/typescript/types/QuantityType.d.ts +14 -18
- package/lib/typescript/types/QuantityTypeIdentifier.d.ts +1 -671
- package/lib/typescript/types/QueryOptions.d.ts +8 -4
- package/lib/typescript/types/Shared.d.ts +12 -41
- package/lib/typescript/types/StateOfMind.d.ts +8 -1
- package/lib/typescript/types/Subscriptions.d.ts +11 -11
- package/lib/typescript/types/WeatherCondition.d.ts +1 -30
- package/lib/typescript/types/Workouts.d.ts +20 -104
- package/lib/typescript/types/index.d.ts +2 -0
- package/lib/typescript/utils/getMostRecentQuantitySample.d.ts +2 -1
- package/lib/typescript/utils/getMostRecentWorkout.d.ts +2 -1
- package/lib/typescript/utils/getPreferredUnit.d.ts +2 -1
- package/lib/typescript/utils/getQuantitySampleById.d.ts +2 -1
- package/lib/typescript/utils/subscribeToQuantitySamples.d.ts +1 -1
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +55 -109
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +12 -18
- package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +5 -14
- package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +18 -2
- package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +1 -13
- package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +1 -13
- package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +2 -14
- package/nitrogen/generated/ios/c++/HybridMedicationModuleSpecSwift.hpp +1 -13
- package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +19 -28
- package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +2 -14
- package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +3 -116
- package/nitrogen/generated/ios/swift/CategorySample.swift +4 -329
- package/nitrogen/generated/ios/swift/CategoryTypeIdentifier.swift +112 -108
- package/nitrogen/generated/ios/swift/CategoryTypeIdentifierWriteable.swift +292 -0
- package/nitrogen/generated/ios/swift/CorrelationSample.swift +4 -347
- package/nitrogen/generated/ios/swift/ElectrocardiogramSample.swift +4 -329
- package/nitrogen/generated/ios/swift/FilterForWorkouts.swift +30 -30
- package/nitrogen/generated/ios/swift/FilterForWorkoutsBase.swift +30 -30
- package/nitrogen/generated/ios/swift/GeneralForm.swift +4 -4
- package/nitrogen/generated/ios/swift/HeartbeatSeriesSample.swift +4 -329
- package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec_cxx.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +38 -0
- package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec_cxx.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec.swift +1 -27
- package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec_cxx.swift +2 -340
- package/nitrogen/generated/ios/swift/MedicationDoseEvent.swift +4 -329
- package/nitrogen/generated/ios/swift/ObjectTypeIdentifier.swift +492 -492
- package/nitrogen/generated/ios/swift/QuantitySample.swift +4 -329
- package/nitrogen/generated/ios/swift/QuantityTypeIdentifier.swift +380 -384
- package/nitrogen/generated/ios/swift/QuantityTypeIdentifierWriteable.swift +372 -376
- package/nitrogen/generated/ios/swift/{QueryOptionsWithAnchorAndUnit.swift → QueryOptionsWithAnchorAndStringUnit.swift} +5 -5
- package/nitrogen/generated/ios/swift/{QueryOptionsWithSortOrderAndUnit.swift → QueryOptionsWithSortOrderAndStringUnit.swift} +5 -5
- package/nitrogen/generated/ios/swift/QueryStatisticsResponseFromSingleSource.swift +37 -37
- package/nitrogen/generated/ios/swift/SampleTypeIdentifier.swift +492 -492
- package/nitrogen/generated/ios/swift/SampleTypeIdentifierWriteable.swift +482 -486
- package/nitrogen/generated/ios/swift/StateOfMindSample.swift +4 -329
- package/nitrogen/generated/ios/swift/{StatisticsQueryOptions.swift → StatisticsQueryOptionsWithStringUnit.swift} +5 -5
- package/nitrogen/generated/ios/swift/WorkoutEvent.swift +20 -2
- package/nitrogen/generated/ios/swift/WorkoutSample.swift +4 -402
- package/nitrogen/generated/shared/c++/CategorySample.hpp +8 -100
- package/nitrogen/generated/shared/c++/CategoryTypeIdentifier.hpp +153 -149
- package/nitrogen/generated/shared/c++/CategoryTypeIdentifierWriteable.hpp +328 -0
- package/nitrogen/generated/shared/c++/CorrelationSample.hpp +9 -105
- package/nitrogen/generated/shared/c++/ElectrocardiogramSample.hpp +7 -99
- package/nitrogen/generated/shared/c++/FilterForWorkouts.hpp +13 -13
- package/nitrogen/generated/shared/c++/FilterForWorkoutsBase.hpp +13 -13
- package/nitrogen/generated/shared/c++/GeneralForm.hpp +7 -7
- package/nitrogen/generated/shared/c++/HeartbeatSeriesSample.hpp +8 -100
- package/nitrogen/generated/shared/c++/HybridCategoryTypeModuleSpec.hpp +5 -2
- package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +4 -2
- package/nitrogen/generated/shared/c++/HybridQuantityTypeModuleSpec.hpp +15 -15
- package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.cpp +1 -27
- package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.hpp +2 -37
- package/nitrogen/generated/shared/c++/MedicationDoseEvent.hpp +7 -99
- package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +565 -565
- package/nitrogen/generated/shared/c++/QuantitySample.hpp +8 -100
- package/nitrogen/generated/shared/c++/QuantityTypeIdentifier.hpp +407 -411
- package/nitrogen/generated/shared/c++/QuantityTypeIdentifierWriteable.hpp +398 -402
- package/nitrogen/generated/shared/c++/{QueryOptionsWithAnchorAndUnit.hpp → QueryOptionsWithAnchorAndStringUnit.hpp} +11 -11
- package/nitrogen/generated/shared/c++/{QueryOptionsWithSortOrderAndUnit.hpp → QueryOptionsWithSortOrderAndStringUnit.hpp} +11 -11
- package/nitrogen/generated/shared/c++/QueryStatisticsResponseFromSingleSource.hpp +12 -12
- package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +559 -559
- package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +541 -545
- package/nitrogen/generated/shared/c++/StateOfMindSample.hpp +8 -100
- package/nitrogen/generated/shared/c++/{StatisticsQueryOptions.hpp → StatisticsQueryOptionsWithStringUnit.hpp} +11 -11
- package/nitrogen/generated/shared/c++/WorkoutEvent.hpp +8 -2
- package/nitrogen/generated/shared/c++/WorkoutSample.hpp +7 -120
- package/package.json +5 -2
- package/src/generated/healthkit-schema.json +3680 -0
- package/src/generated/healthkit.generated.ts +1307 -0
- package/src/healthkit.ios.ts +225 -19
- package/src/healthkit.ts +181 -55
- package/src/hooks/useMostRecentQuantitySample.ts +6 -5
- package/src/hooks/useMostRecentWorkout.ts +2 -2
- package/src/hooks/useQuantitySampleById.ts +6 -5
- package/src/hooks/useStatisticsForQuantity.ts +2 -1
- package/src/hooks/useSubscribeToQuantitySamples.ts +1 -1
- package/src/modules.ts +7 -2
- package/src/specs/CategoryTypeModule.nitro.ts +8 -5
- package/src/specs/CoreModule.nitro.ts +20 -0
- package/src/specs/QuantityTypeModule.nitro.ts +81 -7
- package/src/test-setup.ts +2 -0
- package/src/type-tests/generated-typing.ts +133 -0
- package/src/types/CategoryType.ts +52 -148
- package/src/types/CategoryTypeIdentifier.ts +5 -134
- package/src/types/CorrelationType.ts +13 -3
- package/src/types/ElectrocardiogramSample.ts +13 -1
- package/src/types/HeartbeatSeries.ts +13 -1
- package/src/types/InterfaceVerification.ts +38 -1
- package/src/types/Medication.ts +19 -0
- package/src/types/MetadataEnums.ts +15 -0
- package/src/types/QuantitySample.ts +14 -2
- package/src/types/QuantityType.ts +22 -122
- package/src/types/QuantityTypeIdentifier.ts +5 -772
- package/src/types/QueryOptions.ts +11 -4
- package/src/types/Shared.ts +22 -49
- package/src/types/StateOfMind.ts +13 -1
- package/src/types/Subscriptions.ts +19 -13
- package/src/types/WeatherCondition.ts +1 -31
- package/src/types/Workouts.ts +46 -108
- package/src/types/index.ts +2 -0
- package/src/utils/getMostRecentQuantitySample.ts +4 -3
- package/src/utils/getMostRecentWorkout.ts +5 -2
- package/src/utils/getPreferredUnit.ts +5 -4
- package/src/utils/getQuantitySampleById.ts +4 -3
- package/src/utils/subscribeToQuantitySamples.ts +5 -3
- package/nitrogen/generated/ios/swift/HeartRateMotionContext.swift +0 -44
- package/nitrogen/generated/ios/swift/InsulinDeliveryReason.swift +0 -40
- package/nitrogen/generated/ios/swift/WeatherCondition.swift +0 -144
- package/nitrogen/generated/shared/c++/HeartRateMotionContext.hpp +0 -67
- package/nitrogen/generated/shared/c++/InsulinDeliveryReason.hpp +0 -62
- package/nitrogen/generated/shared/c++/WeatherCondition.hpp +0 -88
package/src/healthkit.ios.ts
CHANGED
|
@@ -21,7 +21,31 @@ import {
|
|
|
21
21
|
StateOfMind,
|
|
22
22
|
Workouts,
|
|
23
23
|
} from './modules'
|
|
24
|
+
import type {
|
|
25
|
+
CorrelationSampleTyped,
|
|
26
|
+
QueryCorrelationSamplesWithAnchorResponseTyped,
|
|
27
|
+
} from './types/CorrelationType'
|
|
28
|
+
import type {
|
|
29
|
+
ElectrocardiogramSamplesWithAnchorResponseTyped,
|
|
30
|
+
ElectrocardiogramSampleTyped,
|
|
31
|
+
} from './types/ElectrocardiogramSample'
|
|
32
|
+
import type {
|
|
33
|
+
HeartbeatSeriesSamplesWithAnchorResponseTyped,
|
|
34
|
+
HeartbeatSeriesSampleTyped,
|
|
35
|
+
} from './types/HeartbeatSeries'
|
|
36
|
+
import type {
|
|
37
|
+
MedicationDoseEventsWithAnchorResponseTyped,
|
|
38
|
+
MedicationDoseEventTyped,
|
|
39
|
+
} from './types/Medication'
|
|
24
40
|
import type { QuantityTypeIdentifier } from './types/QuantityTypeIdentifier'
|
|
41
|
+
import type {
|
|
42
|
+
StateOfMindSamplesWithAnchorResponseTyped,
|
|
43
|
+
StateOfMindSampleTyped,
|
|
44
|
+
} from './types/StateOfMind'
|
|
45
|
+
import type {
|
|
46
|
+
QueryWorkoutSamplesWithAnchorResponseTyped,
|
|
47
|
+
WorkoutProxyTyped,
|
|
48
|
+
} from './types/Workouts'
|
|
25
49
|
import getMostRecentCategorySample from './utils/getMostRecentCategorySample'
|
|
26
50
|
import getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'
|
|
27
51
|
import getMostRecentWorkout from './utils/getMostRecentWorkout'
|
|
@@ -90,6 +114,188 @@ export type AvailableQuantityTypes<
|
|
|
90
114
|
? AvailableQuantityTypesIOS17Plus
|
|
91
115
|
: AvailableQuantityTypesBeforeIOS17
|
|
92
116
|
|
|
117
|
+
type BoundMethod<
|
|
118
|
+
TMethod,
|
|
119
|
+
TReturn = TMethod extends (...args: infer _Args) => infer TResult
|
|
120
|
+
? TResult
|
|
121
|
+
: never,
|
|
122
|
+
> = (
|
|
123
|
+
...args: TMethod extends (...args: infer TArgs) => unknown ? TArgs : never
|
|
124
|
+
) => TReturn
|
|
125
|
+
|
|
126
|
+
function bindRetypedMethod<TModule, TMethod, TReturn>(
|
|
127
|
+
module: TModule,
|
|
128
|
+
method: TMethod,
|
|
129
|
+
): BoundMethod<TMethod, TReturn> {
|
|
130
|
+
return (
|
|
131
|
+
method as TMethod extends (...args: infer TArgs) => infer TResult
|
|
132
|
+
? (...args: TArgs) => TResult
|
|
133
|
+
: never
|
|
134
|
+
).bind(module) as BoundMethod<TMethod, TReturn>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const CorrelationTypeBindings = {
|
|
138
|
+
queryCorrelationSamples: bindRetypedMethod<
|
|
139
|
+
typeof CorrelationTypes,
|
|
140
|
+
typeof CorrelationTypes.queryCorrelationSamples,
|
|
141
|
+
Promise<readonly CorrelationSampleTyped[]>
|
|
142
|
+
>(CorrelationTypes, CorrelationTypes.queryCorrelationSamples),
|
|
143
|
+
queryCorrelationSamplesWithAnchor: bindRetypedMethod<
|
|
144
|
+
typeof CorrelationTypes,
|
|
145
|
+
typeof CorrelationTypes.queryCorrelationSamplesWithAnchor,
|
|
146
|
+
Promise<QueryCorrelationSamplesWithAnchorResponseTyped>
|
|
147
|
+
>(CorrelationTypes, CorrelationTypes.queryCorrelationSamplesWithAnchor),
|
|
148
|
+
saveCorrelationSample: bindRetypedMethod<
|
|
149
|
+
typeof CorrelationTypes,
|
|
150
|
+
typeof CorrelationTypes.saveCorrelationSample,
|
|
151
|
+
Promise<CorrelationSampleTyped | undefined>
|
|
152
|
+
>(CorrelationTypes, CorrelationTypes.saveCorrelationSample),
|
|
153
|
+
} satisfies {
|
|
154
|
+
queryCorrelationSamples: BoundMethod<
|
|
155
|
+
typeof CorrelationTypes.queryCorrelationSamples,
|
|
156
|
+
Promise<readonly CorrelationSampleTyped[]>
|
|
157
|
+
>
|
|
158
|
+
queryCorrelationSamplesWithAnchor: BoundMethod<
|
|
159
|
+
typeof CorrelationTypes.queryCorrelationSamplesWithAnchor,
|
|
160
|
+
Promise<QueryCorrelationSamplesWithAnchorResponseTyped>
|
|
161
|
+
>
|
|
162
|
+
saveCorrelationSample: BoundMethod<
|
|
163
|
+
typeof CorrelationTypes.saveCorrelationSample,
|
|
164
|
+
Promise<CorrelationSampleTyped | undefined>
|
|
165
|
+
>
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const HeartbeatSeriesBindings = {
|
|
169
|
+
queryHeartbeatSeriesSamples: bindRetypedMethod<
|
|
170
|
+
typeof HeartbeatSeries,
|
|
171
|
+
typeof HeartbeatSeries.queryHeartbeatSeriesSamples,
|
|
172
|
+
Promise<readonly HeartbeatSeriesSampleTyped[]>
|
|
173
|
+
>(HeartbeatSeries, HeartbeatSeries.queryHeartbeatSeriesSamples),
|
|
174
|
+
queryHeartbeatSeriesSamplesWithAnchor: bindRetypedMethod<
|
|
175
|
+
typeof HeartbeatSeries,
|
|
176
|
+
typeof HeartbeatSeries.queryHeartbeatSeriesSamplesWithAnchor,
|
|
177
|
+
Promise<HeartbeatSeriesSamplesWithAnchorResponseTyped>
|
|
178
|
+
>(HeartbeatSeries, HeartbeatSeries.queryHeartbeatSeriesSamplesWithAnchor),
|
|
179
|
+
} satisfies {
|
|
180
|
+
queryHeartbeatSeriesSamples: BoundMethod<
|
|
181
|
+
typeof HeartbeatSeries.queryHeartbeatSeriesSamples,
|
|
182
|
+
Promise<readonly HeartbeatSeriesSampleTyped[]>
|
|
183
|
+
>
|
|
184
|
+
queryHeartbeatSeriesSamplesWithAnchor: BoundMethod<
|
|
185
|
+
typeof HeartbeatSeries.queryHeartbeatSeriesSamplesWithAnchor,
|
|
186
|
+
Promise<HeartbeatSeriesSamplesWithAnchorResponseTyped>
|
|
187
|
+
>
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const ElectrocardiogramBindings = {
|
|
191
|
+
queryElectrocardiogramSamples: bindRetypedMethod<
|
|
192
|
+
typeof Electrocardiograms,
|
|
193
|
+
typeof Electrocardiograms.queryElectrocardiogramSamples,
|
|
194
|
+
Promise<readonly ElectrocardiogramSampleTyped[]>
|
|
195
|
+
>(Electrocardiograms, Electrocardiograms.queryElectrocardiogramSamples),
|
|
196
|
+
queryElectrocardiogramSamplesWithAnchor: bindRetypedMethod<
|
|
197
|
+
typeof Electrocardiograms,
|
|
198
|
+
typeof Electrocardiograms.queryElectrocardiogramSamplesWithAnchor,
|
|
199
|
+
Promise<ElectrocardiogramSamplesWithAnchorResponseTyped>
|
|
200
|
+
>(
|
|
201
|
+
Electrocardiograms,
|
|
202
|
+
Electrocardiograms.queryElectrocardiogramSamplesWithAnchor,
|
|
203
|
+
),
|
|
204
|
+
} satisfies {
|
|
205
|
+
queryElectrocardiogramSamples: BoundMethod<
|
|
206
|
+
typeof Electrocardiograms.queryElectrocardiogramSamples,
|
|
207
|
+
Promise<readonly ElectrocardiogramSampleTyped[]>
|
|
208
|
+
>
|
|
209
|
+
queryElectrocardiogramSamplesWithAnchor: BoundMethod<
|
|
210
|
+
typeof Electrocardiograms.queryElectrocardiogramSamplesWithAnchor,
|
|
211
|
+
Promise<ElectrocardiogramSamplesWithAnchorResponseTyped>
|
|
212
|
+
>
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const WorkoutBindings = {
|
|
216
|
+
queryWorkoutSamples: bindRetypedMethod<
|
|
217
|
+
typeof Workouts,
|
|
218
|
+
typeof Workouts.queryWorkoutSamples,
|
|
219
|
+
Promise<readonly WorkoutProxyTyped[]>
|
|
220
|
+
>(Workouts, Workouts.queryWorkoutSamples),
|
|
221
|
+
queryWorkoutSamplesWithAnchor: bindRetypedMethod<
|
|
222
|
+
typeof Workouts,
|
|
223
|
+
typeof Workouts.queryWorkoutSamplesWithAnchor,
|
|
224
|
+
Promise<QueryWorkoutSamplesWithAnchorResponseTyped>
|
|
225
|
+
>(Workouts, Workouts.queryWorkoutSamplesWithAnchor),
|
|
226
|
+
saveWorkoutSample: bindRetypedMethod<
|
|
227
|
+
typeof Workouts,
|
|
228
|
+
typeof Workouts.saveWorkoutSample,
|
|
229
|
+
Promise<WorkoutProxyTyped>
|
|
230
|
+
>(Workouts, Workouts.saveWorkoutSample),
|
|
231
|
+
} satisfies {
|
|
232
|
+
queryWorkoutSamples: BoundMethod<
|
|
233
|
+
typeof Workouts.queryWorkoutSamples,
|
|
234
|
+
Promise<readonly WorkoutProxyTyped[]>
|
|
235
|
+
>
|
|
236
|
+
queryWorkoutSamplesWithAnchor: BoundMethod<
|
|
237
|
+
typeof Workouts.queryWorkoutSamplesWithAnchor,
|
|
238
|
+
Promise<QueryWorkoutSamplesWithAnchorResponseTyped>
|
|
239
|
+
>
|
|
240
|
+
saveWorkoutSample: BoundMethod<
|
|
241
|
+
typeof Workouts.saveWorkoutSample,
|
|
242
|
+
Promise<WorkoutProxyTyped>
|
|
243
|
+
>
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const StateOfMindBindings = {
|
|
247
|
+
queryStateOfMindSamples: bindRetypedMethod<
|
|
248
|
+
typeof StateOfMind,
|
|
249
|
+
typeof StateOfMind.queryStateOfMindSamples,
|
|
250
|
+
Promise<readonly StateOfMindSampleTyped[]>
|
|
251
|
+
>(StateOfMind, StateOfMind.queryStateOfMindSamples),
|
|
252
|
+
queryStateOfMindSamplesWithAnchor: bindRetypedMethod<
|
|
253
|
+
typeof StateOfMind,
|
|
254
|
+
typeof StateOfMind.queryStateOfMindSamplesWithAnchor,
|
|
255
|
+
Promise<StateOfMindSamplesWithAnchorResponseTyped>
|
|
256
|
+
>(StateOfMind, StateOfMind.queryStateOfMindSamplesWithAnchor),
|
|
257
|
+
saveStateOfMindSample: bindRetypedMethod<
|
|
258
|
+
typeof StateOfMind,
|
|
259
|
+
typeof StateOfMind.saveStateOfMindSample,
|
|
260
|
+
Promise<StateOfMindSampleTyped | undefined>
|
|
261
|
+
>(StateOfMind, StateOfMind.saveStateOfMindSample),
|
|
262
|
+
} satisfies {
|
|
263
|
+
queryStateOfMindSamples: BoundMethod<
|
|
264
|
+
typeof StateOfMind.queryStateOfMindSamples,
|
|
265
|
+
Promise<readonly StateOfMindSampleTyped[]>
|
|
266
|
+
>
|
|
267
|
+
queryStateOfMindSamplesWithAnchor: BoundMethod<
|
|
268
|
+
typeof StateOfMind.queryStateOfMindSamplesWithAnchor,
|
|
269
|
+
Promise<StateOfMindSamplesWithAnchorResponseTyped>
|
|
270
|
+
>
|
|
271
|
+
saveStateOfMindSample: BoundMethod<
|
|
272
|
+
typeof StateOfMind.saveStateOfMindSample,
|
|
273
|
+
Promise<StateOfMindSampleTyped | undefined>
|
|
274
|
+
>
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const MedicationBindings = {
|
|
278
|
+
queryMedicationEvents: bindRetypedMethod<
|
|
279
|
+
typeof Medication,
|
|
280
|
+
typeof Medication.queryMedicationEvents,
|
|
281
|
+
Promise<readonly MedicationDoseEventTyped[]>
|
|
282
|
+
>(Medication, Medication.queryMedicationEvents),
|
|
283
|
+
queryMedicationEventsWithAnchor: bindRetypedMethod<
|
|
284
|
+
typeof Medication,
|
|
285
|
+
typeof Medication.queryMedicationEventsWithAnchor,
|
|
286
|
+
Promise<MedicationDoseEventsWithAnchorResponseTyped>
|
|
287
|
+
>(Medication, Medication.queryMedicationEventsWithAnchor),
|
|
288
|
+
} satisfies {
|
|
289
|
+
queryMedicationEvents: BoundMethod<
|
|
290
|
+
typeof Medication.queryMedicationEvents,
|
|
291
|
+
Promise<readonly MedicationDoseEventTyped[]>
|
|
292
|
+
>
|
|
293
|
+
queryMedicationEventsWithAnchor: BoundMethod<
|
|
294
|
+
typeof Medication.queryMedicationEventsWithAnchor,
|
|
295
|
+
Promise<MedicationDoseEventsWithAnchorResponseTyped>
|
|
296
|
+
>
|
|
297
|
+
}
|
|
298
|
+
|
|
93
299
|
// Named exports - all functions bound to their respective modules
|
|
94
300
|
export const authorizationStatusFor = Core.authorizationStatusFor.bind(Core)
|
|
95
301
|
export const requestPerObjectReadAuthorization =
|
|
@@ -99,6 +305,8 @@ export const disableAllBackgroundDelivery =
|
|
|
99
305
|
export const disableBackgroundDelivery =
|
|
100
306
|
Core.disableBackgroundDelivery.bind(Core)
|
|
101
307
|
export const enableBackgroundDelivery = Core.enableBackgroundDelivery.bind(Core)
|
|
308
|
+
export const configureBackgroundTypes = Core.configureBackgroundTypes.bind(Core)
|
|
309
|
+
export const clearBackgroundTypes = Core.clearBackgroundTypes.bind(Core)
|
|
102
310
|
export const getBiologicalSex =
|
|
103
311
|
Characteristics.getBiologicalSex.bind(Characteristics)
|
|
104
312
|
export const getBloodType = Characteristics.getBloodType.bind(Characteristics)
|
|
@@ -119,19 +327,17 @@ export const queryCategorySamples =
|
|
|
119
327
|
export const queryCategorySamplesWithAnchor =
|
|
120
328
|
CategoryTypes.queryCategorySamplesWithAnchor.bind(CategoryTypes)
|
|
121
329
|
export const queryCorrelationSamples =
|
|
122
|
-
|
|
330
|
+
CorrelationTypeBindings.queryCorrelationSamples
|
|
123
331
|
export const queryCorrelationSamplesWithAnchor =
|
|
124
|
-
|
|
332
|
+
CorrelationTypeBindings.queryCorrelationSamplesWithAnchor
|
|
125
333
|
export const queryHeartbeatSeriesSamples =
|
|
126
|
-
|
|
334
|
+
HeartbeatSeriesBindings.queryHeartbeatSeriesSamples
|
|
127
335
|
export const queryHeartbeatSeriesSamplesWithAnchor =
|
|
128
|
-
|
|
336
|
+
HeartbeatSeriesBindings.queryHeartbeatSeriesSamplesWithAnchor
|
|
129
337
|
export const queryElectrocardiogramSamples =
|
|
130
|
-
|
|
338
|
+
ElectrocardiogramBindings.queryElectrocardiogramSamples
|
|
131
339
|
export const queryElectrocardiogramSamplesWithAnchor =
|
|
132
|
-
|
|
133
|
-
Electrocardiograms,
|
|
134
|
-
)
|
|
340
|
+
ElectrocardiogramBindings.queryElectrocardiogramSamplesWithAnchor
|
|
135
341
|
export const queryQuantitySamples =
|
|
136
342
|
QuantityTypes.queryQuantitySamples.bind(QuantityTypes)
|
|
137
343
|
export const queryQuantitySamplesWithAnchor =
|
|
@@ -146,28 +352,27 @@ export const queryStatisticsCollectionForQuantitySeparateBySource =
|
|
|
146
352
|
QuantityTypes.queryStatisticsCollectionForQuantitySeparateBySource.bind(
|
|
147
353
|
QuantityTypes,
|
|
148
354
|
)
|
|
149
|
-
export const queryWorkoutSamples =
|
|
355
|
+
export const queryWorkoutSamples = WorkoutBindings.queryWorkoutSamples
|
|
150
356
|
export const queryWorkoutSamplesWithAnchor =
|
|
151
|
-
|
|
357
|
+
WorkoutBindings.queryWorkoutSamplesWithAnchor
|
|
152
358
|
export const querySources = Core.querySources.bind(Core)
|
|
153
359
|
export const requestAuthorization = Core.requestAuthorization.bind(Core)
|
|
154
360
|
export const deleteObjects = Core.deleteObjects.bind(Core)
|
|
155
361
|
export const saveCategorySample =
|
|
156
362
|
CategoryTypes.saveCategorySample.bind(CategoryTypes)
|
|
157
363
|
export const saveCorrelationSample =
|
|
158
|
-
|
|
364
|
+
CorrelationTypeBindings.saveCorrelationSample
|
|
159
365
|
export const saveQuantitySample =
|
|
160
366
|
QuantityTypes.saveQuantitySample.bind(QuantityTypes)
|
|
161
|
-
export const saveWorkoutSample =
|
|
367
|
+
export const saveWorkoutSample = WorkoutBindings.saveWorkoutSample
|
|
162
368
|
export const startWatchApp =
|
|
163
369
|
Workouts.startWatchAppWithWorkoutConfiguration.bind(Workouts)
|
|
164
370
|
export const isProtectedDataAvailable = Core.isProtectedDataAvailable.bind(Core)
|
|
165
371
|
export const queryStateOfMindSamples =
|
|
166
|
-
|
|
372
|
+
StateOfMindBindings.queryStateOfMindSamples
|
|
167
373
|
export const queryStateOfMindSamplesWithAnchor =
|
|
168
|
-
|
|
169
|
-
export const saveStateOfMindSample =
|
|
170
|
-
StateOfMind.saveStateOfMindSample.bind(StateOfMind)
|
|
374
|
+
StateOfMindBindings.queryStateOfMindSamplesWithAnchor
|
|
375
|
+
export const saveStateOfMindSample = StateOfMindBindings.saveStateOfMindSample
|
|
171
376
|
export const isQuantityCompatibleWithUnit =
|
|
172
377
|
QuantityTypes.isQuantityCompatibleWithUnit.bind(QuantityTypes)
|
|
173
378
|
|
|
@@ -181,10 +386,9 @@ export const requestMedicationsAuthorization =
|
|
|
181
386
|
Medication.requestMedicationsAuthorization.bind(Medication)
|
|
182
387
|
|
|
183
388
|
export const queryMedications = Medication.queryMedications.bind(Medication)
|
|
184
|
-
export const queryMedicationEvents =
|
|
185
|
-
Medication.queryMedicationEvents.bind(Medication)
|
|
389
|
+
export const queryMedicationEvents = MedicationBindings.queryMedicationEvents
|
|
186
390
|
export const queryMedicationEventsWithAnchor =
|
|
187
|
-
|
|
391
|
+
MedicationBindings.queryMedicationEventsWithAnchor
|
|
188
392
|
|
|
189
393
|
export const currentAppSource = Core.currentAppSource.bind(Core)
|
|
190
394
|
|
|
@@ -206,6 +410,8 @@ export default {
|
|
|
206
410
|
areObjectTypesAvailable,
|
|
207
411
|
areObjectTypesAvailableAsync,
|
|
208
412
|
isQuantityCompatibleWithUnit,
|
|
413
|
+
configureBackgroundTypes,
|
|
414
|
+
clearBackgroundTypes,
|
|
209
415
|
disableAllBackgroundDelivery,
|
|
210
416
|
disableBackgroundDelivery,
|
|
211
417
|
enableBackgroundDelivery,
|
package/src/healthkit.ts
CHANGED
|
@@ -13,18 +13,41 @@ import { AuthorizationRequestStatus, AuthorizationStatus } from './types/Auth'
|
|
|
13
13
|
import type {
|
|
14
14
|
CategorySamplesWithAnchorResponseTyped,
|
|
15
15
|
CategorySampleTyped,
|
|
16
|
+
CategoryValueForIdentifier,
|
|
17
|
+
MetadataForCategoryIdentifier,
|
|
16
18
|
} from './types/CategoryType'
|
|
17
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
CategoryTypeIdentifier,
|
|
21
|
+
CategoryTypeIdentifierWriteable,
|
|
22
|
+
} from './types/CategoryTypeIdentifier'
|
|
18
23
|
import {
|
|
19
24
|
BiologicalSex,
|
|
20
25
|
BloodType,
|
|
21
26
|
FitzpatrickSkinType,
|
|
22
27
|
WheelchairUse,
|
|
23
28
|
} from './types/Characteristics'
|
|
24
|
-
import type {
|
|
29
|
+
import type {
|
|
30
|
+
MetadataForQuantityIdentifier,
|
|
31
|
+
QuantitySampleTyped,
|
|
32
|
+
} from './types/QuantitySample'
|
|
33
|
+
import type {
|
|
34
|
+
IntervalComponents,
|
|
35
|
+
QuantitySamplesWithAnchorResponseTyped,
|
|
36
|
+
QueryStatisticsResponse,
|
|
37
|
+
QueryStatisticsResponseFromSingleSource,
|
|
38
|
+
StatisticsOptions,
|
|
39
|
+
StatisticsQueryOptions,
|
|
40
|
+
UnitForIdentifier,
|
|
41
|
+
} from './types/QuantityType'
|
|
42
|
+
import type {
|
|
43
|
+
QuantityTypeIdentifier,
|
|
44
|
+
QuantityTypeIdentifierWriteable,
|
|
45
|
+
} from './types/QuantityTypeIdentifier'
|
|
25
46
|
import type {
|
|
26
47
|
QueryOptionsWithAnchor,
|
|
48
|
+
QueryOptionsWithAnchorAndUnit,
|
|
27
49
|
QueryOptionsWithSortOrder,
|
|
50
|
+
QueryOptionsWithSortOrderAndUnit,
|
|
28
51
|
} from './types/QueryOptions'
|
|
29
52
|
|
|
30
53
|
export * from './types'
|
|
@@ -68,6 +91,14 @@ export const enableBackgroundDelivery = UnavailableFnFromModule(
|
|
|
68
91
|
'enableBackgroundDelivery',
|
|
69
92
|
Promise.resolve(false),
|
|
70
93
|
)
|
|
94
|
+
export const configureBackgroundTypes = UnavailableFnFromModule(
|
|
95
|
+
'configureBackgroundTypes',
|
|
96
|
+
Promise.resolve(false),
|
|
97
|
+
)
|
|
98
|
+
export const clearBackgroundTypes = UnavailableFnFromModule(
|
|
99
|
+
'clearBackgroundTypes',
|
|
100
|
+
Promise.resolve(false),
|
|
101
|
+
)
|
|
71
102
|
export const getPreferredUnits = UnavailableFnFromModule(
|
|
72
103
|
'getPreferredUnits',
|
|
73
104
|
Promise.resolve([]),
|
|
@@ -146,47 +177,114 @@ export const getWheelchairUse = UnavailableFnFromModule(
|
|
|
146
177
|
)
|
|
147
178
|
|
|
148
179
|
// QuantityTypeModule functions
|
|
149
|
-
export
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
180
|
+
export function queryQuantitySamples<T extends QuantityTypeIdentifier>(
|
|
181
|
+
_identifier: T,
|
|
182
|
+
_options: QueryOptionsWithSortOrderAndUnit<UnitForIdentifier<T>>,
|
|
183
|
+
): Promise<readonly QuantitySampleTyped<T>[]> {
|
|
184
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
185
|
+
console.warn(notAvailableError)
|
|
186
|
+
hasWarned = true
|
|
187
|
+
}
|
|
188
|
+
return Promise.resolve([])
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function queryQuantitySamplesWithAnchor<
|
|
192
|
+
T extends QuantityTypeIdentifier,
|
|
193
|
+
>(
|
|
194
|
+
_identifier: T,
|
|
195
|
+
_options: QueryOptionsWithAnchorAndUnit<UnitForIdentifier<T>>,
|
|
196
|
+
): Promise<QuantitySamplesWithAnchorResponseTyped<T>> {
|
|
197
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
198
|
+
console.warn(notAvailableError)
|
|
199
|
+
hasWarned = true
|
|
200
|
+
}
|
|
201
|
+
return Promise.resolve({
|
|
156
202
|
samples: [],
|
|
157
203
|
deletedSamples: [],
|
|
158
204
|
newAnchor: '',
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
export
|
|
162
|
-
|
|
163
|
-
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
export function queryStatisticsForQuantity<T extends QuantityTypeIdentifier>(
|
|
208
|
+
_identifier: T,
|
|
209
|
+
_statistics: readonly StatisticsOptions[],
|
|
210
|
+
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
211
|
+
): Promise<QueryStatisticsResponse> {
|
|
212
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
213
|
+
console.warn(notAvailableError)
|
|
214
|
+
hasWarned = true
|
|
215
|
+
}
|
|
216
|
+
return Promise.resolve({
|
|
164
217
|
sources: [],
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
export
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
export function queryStatisticsCollectionForQuantity<
|
|
221
|
+
T extends QuantityTypeIdentifier,
|
|
222
|
+
>(
|
|
223
|
+
_identifier: T,
|
|
224
|
+
_statistics: readonly StatisticsOptions[],
|
|
225
|
+
_anchorDate: Date,
|
|
226
|
+
_intervalComponents: IntervalComponents,
|
|
227
|
+
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
228
|
+
): Promise<readonly QueryStatisticsResponse[]> {
|
|
229
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
230
|
+
console.warn(notAvailableError)
|
|
231
|
+
hasWarned = true
|
|
232
|
+
}
|
|
233
|
+
return Promise.resolve([])
|
|
234
|
+
}
|
|
171
235
|
|
|
172
|
-
export
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
236
|
+
export function queryStatisticsForQuantitySeparateBySource<
|
|
237
|
+
T extends QuantityTypeIdentifier,
|
|
238
|
+
>(
|
|
239
|
+
_identifier: T,
|
|
240
|
+
_statistics: readonly StatisticsOptions[],
|
|
241
|
+
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
242
|
+
): Promise<QueryStatisticsResponseFromSingleSource[]> {
|
|
243
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
244
|
+
console.warn(notAvailableError)
|
|
245
|
+
hasWarned = true
|
|
246
|
+
}
|
|
247
|
+
return Promise.resolve([])
|
|
248
|
+
}
|
|
249
|
+
export function queryStatisticsCollectionForQuantitySeparateBySource<
|
|
250
|
+
T extends QuantityTypeIdentifier,
|
|
251
|
+
>(
|
|
252
|
+
_identifier: T,
|
|
253
|
+
_statistics: readonly StatisticsOptions[],
|
|
254
|
+
_anchorDate: Date,
|
|
255
|
+
_intervalComponents: IntervalComponents,
|
|
256
|
+
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
257
|
+
): Promise<readonly QueryStatisticsResponseFromSingleSource[]> {
|
|
258
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
259
|
+
console.warn(notAvailableError)
|
|
260
|
+
hasWarned = true
|
|
261
|
+
}
|
|
262
|
+
return Promise.resolve([])
|
|
263
|
+
}
|
|
264
|
+
export function saveQuantitySample<T extends QuantityTypeIdentifierWriteable>(
|
|
265
|
+
_identifier: T,
|
|
266
|
+
_unit: UnitForIdentifier<T>,
|
|
267
|
+
_value: number,
|
|
268
|
+
_start: Date,
|
|
269
|
+
_end: Date,
|
|
270
|
+
_metadata?: MetadataForQuantityIdentifier<T>,
|
|
271
|
+
): Promise<QuantitySampleTyped<T> | undefined> {
|
|
272
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
273
|
+
console.warn(notAvailableError)
|
|
274
|
+
hasWarned = true
|
|
275
|
+
}
|
|
276
|
+
return Promise.resolve(undefined)
|
|
277
|
+
}
|
|
278
|
+
export function isQuantityCompatibleWithUnit<T extends QuantityTypeIdentifier>(
|
|
279
|
+
_identifier: T,
|
|
280
|
+
_unit: UnitForIdentifier<T>,
|
|
281
|
+
): boolean {
|
|
282
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
283
|
+
console.warn(notAvailableError)
|
|
284
|
+
hasWarned = true
|
|
285
|
+
}
|
|
286
|
+
return false
|
|
287
|
+
}
|
|
190
288
|
|
|
191
289
|
// CategoryTypeModule functions
|
|
192
290
|
export function queryCategorySamples<T extends CategoryTypeIdentifier>(
|
|
@@ -216,10 +314,20 @@ export function queryCategorySamplesWithAnchor<
|
|
|
216
314
|
newAnchor: '',
|
|
217
315
|
})
|
|
218
316
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
317
|
+
|
|
318
|
+
export function saveCategorySample<T extends CategoryTypeIdentifierWriteable>(
|
|
319
|
+
_identifier: T,
|
|
320
|
+
_value: CategoryValueForIdentifier<T>,
|
|
321
|
+
_startDate: Date,
|
|
322
|
+
_endDate: Date,
|
|
323
|
+
_metadata?: MetadataForCategoryIdentifier<T>,
|
|
324
|
+
): Promise<CategorySampleTyped<T> | undefined> {
|
|
325
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
326
|
+
console.warn(notAvailableError)
|
|
327
|
+
hasWarned = true
|
|
328
|
+
}
|
|
329
|
+
return Promise.resolve(undefined)
|
|
330
|
+
}
|
|
223
331
|
|
|
224
332
|
// CorrelationTypeModule functions
|
|
225
333
|
export const queryCorrelationSamples = UnavailableFnFromModule(
|
|
@@ -321,20 +429,30 @@ export function getMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
|
321
429
|
return Promise.resolve(undefined)
|
|
322
430
|
}
|
|
323
431
|
|
|
324
|
-
export
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
)
|
|
432
|
+
export function getMostRecentQuantitySample<T extends QuantityTypeIdentifier>(
|
|
433
|
+
_identifier: T,
|
|
434
|
+
_unit?: UnitForIdentifier<T>,
|
|
435
|
+
): Promise<QuantitySampleTyped<T> | undefined> {
|
|
436
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
437
|
+
console.warn(notAvailableError)
|
|
438
|
+
hasWarned = true
|
|
439
|
+
}
|
|
440
|
+
return Promise.resolve(undefined)
|
|
441
|
+
}
|
|
329
442
|
export const getMostRecentWorkout = UnavailableFnFromModule(
|
|
330
443
|
'getMostRecentWorkout',
|
|
331
444
|
// biome-ignore lint/suspicious/noExplicitAny: it works
|
|
332
445
|
Promise.resolve(undefined as any as WorkoutProxy),
|
|
333
446
|
)
|
|
334
|
-
export
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
447
|
+
export function getPreferredUnit<T extends QuantityTypeIdentifier>(
|
|
448
|
+
_quantityType: T,
|
|
449
|
+
): Promise<UnitForIdentifier<T>> {
|
|
450
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
451
|
+
console.warn(notAvailableError)
|
|
452
|
+
hasWarned = true
|
|
453
|
+
}
|
|
454
|
+
return Promise.resolve('count' as UnitForIdentifier<T>)
|
|
455
|
+
}
|
|
338
456
|
|
|
339
457
|
// Hooks (from original export list)
|
|
340
458
|
export function useMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
@@ -347,10 +465,16 @@ export function useMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
|
347
465
|
return undefined
|
|
348
466
|
}
|
|
349
467
|
|
|
350
|
-
export
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
)
|
|
468
|
+
export function useMostRecentQuantitySample<T extends QuantityTypeIdentifier>(
|
|
469
|
+
_identifier: T,
|
|
470
|
+
_unit?: UnitForIdentifier<T>,
|
|
471
|
+
): QuantitySampleTyped<T> | undefined {
|
|
472
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
473
|
+
console.warn(notAvailableError)
|
|
474
|
+
hasWarned = true
|
|
475
|
+
}
|
|
476
|
+
return undefined
|
|
477
|
+
}
|
|
354
478
|
export const useMostRecentWorkout = UnavailableFnFromModule(
|
|
355
479
|
'useMostRecentWorkout',
|
|
356
480
|
undefined,
|
|
@@ -463,6 +587,8 @@ const HealthkitModule = {
|
|
|
463
587
|
areObjectTypesAvailable,
|
|
464
588
|
areObjectTypesAvailableAsync,
|
|
465
589
|
isQuantityCompatibleWithUnit,
|
|
590
|
+
configureBackgroundTypes,
|
|
591
|
+
clearBackgroundTypes,
|
|
466
592
|
disableAllBackgroundDelivery,
|
|
467
593
|
disableBackgroundDelivery,
|
|
468
594
|
enableBackgroundDelivery,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { QuantitySampleTyped } from '../types/QuantitySample'
|
|
3
|
+
import type { UnitForIdentifier } from '../types/QuantityType'
|
|
3
4
|
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
4
5
|
import getMostRecentQuantitySample from '../utils/getMostRecentQuantitySample'
|
|
5
6
|
import useSubscribeToChanges from './useSubscribeToChanges'
|
|
@@ -7,11 +8,11 @@ import useSubscribeToChanges from './useSubscribeToChanges'
|
|
|
7
8
|
/**
|
|
8
9
|
* @returns the most recent sample for the given quantity type.
|
|
9
10
|
*/
|
|
10
|
-
export function useMostRecentQuantitySample(
|
|
11
|
-
identifier:
|
|
12
|
-
unit?:
|
|
11
|
+
export function useMostRecentQuantitySample<T extends QuantityTypeIdentifier>(
|
|
12
|
+
identifier: T,
|
|
13
|
+
unit?: UnitForIdentifier<T>,
|
|
13
14
|
) {
|
|
14
|
-
const [lastSample, setLastSample] = useState<
|
|
15
|
+
const [lastSample, setLastSample] = useState<QuantitySampleTyped<T>>()
|
|
15
16
|
|
|
16
17
|
const fetchMostRecentSample = useCallback(async () => {
|
|
17
18
|
const value = await getMostRecentQuantitySample(identifier, unit)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { WorkoutProxyTyped } from '../types/Workouts'
|
|
3
3
|
import getMostRecentWorkout from '../utils/getMostRecentWorkout'
|
|
4
4
|
import useSubscribeToChanges from './useSubscribeToChanges'
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import useSubscribeToChanges from './useSubscribeToChanges'
|
|
|
7
7
|
* @returns the most recent workout sample.
|
|
8
8
|
*/
|
|
9
9
|
export function useMostRecentWorkout() {
|
|
10
|
-
const [workout, setWorkout] = useState<
|
|
10
|
+
const [workout, setWorkout] = useState<WorkoutProxyTyped>()
|
|
11
11
|
|
|
12
12
|
const update = useCallback(async () => {
|
|
13
13
|
setWorkout(await getMostRecentWorkout())
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react'
|
|
2
|
-
import type {
|
|
2
|
+
import type { QuantitySampleTyped } from '../types/QuantitySample'
|
|
3
|
+
import type { UnitForIdentifier } from '../types/QuantityType'
|
|
3
4
|
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
4
5
|
import getQuantitySampleById from '../utils/getQuantitySampleById'
|
|
5
6
|
import useSubscribeToChanges from './useSubscribeToChanges'
|
|
@@ -7,15 +8,15 @@ import useSubscribeToChanges from './useSubscribeToChanges'
|
|
|
7
8
|
/**
|
|
8
9
|
* @returns the most recent sample for the given quantity type.
|
|
9
10
|
*/
|
|
10
|
-
export function useQuantitySampleById(
|
|
11
|
-
identifier:
|
|
11
|
+
export function useQuantitySampleById<T extends QuantityTypeIdentifier>(
|
|
12
|
+
identifier: T,
|
|
12
13
|
uuid: string,
|
|
13
14
|
options: {
|
|
14
15
|
/** The unit to use for the sample. */
|
|
15
|
-
unit?:
|
|
16
|
+
unit?: UnitForIdentifier<T>
|
|
16
17
|
} = {},
|
|
17
18
|
) {
|
|
18
|
-
const [sample, setSample] = useState<
|
|
19
|
+
const [sample, setSample] = useState<QuantitySampleTyped<T>>()
|
|
19
20
|
const [isLoading, setIsLoading] = useState(true)
|
|
20
21
|
const [error, setError] = useState<Error | null>(null)
|
|
21
22
|
|