@kingstinct/react-native-healthkit 15.1.0 → 16.1.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/README.md +22 -3
- package/ReactNativeHealthkit.podspec +17 -6
- package/app.plugin.js +18 -34
- package/app.plugin.ts +25 -50
- package/ios/CategoryTypeModule.swift +1 -0
- package/ios/CharacteristicTypeModule.swift +7 -6
- package/ios/Constants.swift +9 -34
- package/ios/CoreModule.swift +72 -41
- package/ios/CorrelationTypeModule.swift +3 -2
- package/ios/ElectrocardiogramModule.swift +4 -3
- package/ios/HeartbeatSeriesModule.swift +4 -3
- package/ios/Helpers.swift +10 -243
- package/ios/MedicationModule.swift +9 -8
- package/ios/MemoryEstimation.swift +1 -0
- package/ios/PredicateHelpers.swift +16 -86
- package/ios/QuantityTypeModule.swift +3 -2
- package/ios/Serializers.swift +16 -67
- package/ios/SourceProxy.swift +1 -0
- package/ios/StateOfMindModule.swift +3 -2
- package/ios/WorkoutProxy.swift +3 -2
- package/ios/WorkoutsModule.swift +4 -3
- package/lib/commonjs/generated/healthkit.generated.js +3 -0
- package/lib/commonjs/healthkit.ios.js +4 -2
- package/lib/commonjs/healthkit.js +21 -78
- package/lib/commonjs/types/Auth.js +3 -18
- package/lib/commonjs/types/Background.js +2 -10
- package/lib/commonjs/types/QueryOptions.js +2 -17
- package/lib/module/generated/healthkit.generated.js +3 -0
- package/lib/module/healthkit.ios.js +2 -0
- package/lib/module/healthkit.js +20 -77
- package/lib/module/types/Auth.js +1 -18
- package/lib/module/types/Background.js +1 -10
- package/lib/module/types/QueryOptions.js +1 -17
- package/lib/typescript/generated/healthkit.generated.d.ts +6 -2
- package/lib/typescript/healthkit.d.ts +3 -2
- package/lib/typescript/healthkit.ios.d.ts +11 -9
- package/lib/typescript/specs/CoreModule.nitro.d.ts +16 -0
- package/lib/typescript/specs/SourceProxy.nitro.d.ts +2 -4
- package/lib/typescript/types/Auth.d.ts +1 -16
- package/lib/typescript/types/Background.d.ts +1 -9
- package/lib/typescript/types/Device.d.ts +1 -13
- package/lib/typescript/types/QuantityType.d.ts +1 -1
- package/lib/typescript/types/QueryOptions.d.ts +3 -37
- package/lib/typescript/types/Shared.d.ts +2 -25
- package/lib/typescript/types/Source.d.ts +1 -10
- package/lib/typescript/types/Subscriptions.d.ts +2 -3
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +68 -0
- package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +8 -0
- package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridMedicationModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/CategorySample.swift +8 -8
- package/nitrogen/generated/ios/swift/CorrelationSample.swift +8 -8
- package/nitrogen/generated/ios/swift/ElectrocardiogramSample.swift +8 -8
- package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__std__chrono__system_clock__time_point_.swift +54 -0
- package/nitrogen/generated/ios/swift/HeartbeatSeriesSample.swift +8 -8
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +25 -0
- package/nitrogen/generated/ios/swift/MedicationDoseEvent.swift +8 -8
- package/nitrogen/generated/ios/swift/ObjectTypeIdentifier.swift +4 -0
- package/nitrogen/generated/ios/swift/QuantitySample.swift +8 -8
- package/nitrogen/generated/ios/swift/QuantityTypeIdentifier.swift +4 -0
- package/nitrogen/generated/ios/swift/QuantityTypeIdentifierWriteable.swift +4 -0
- package/nitrogen/generated/ios/swift/SampleTypeIdentifier.swift +4 -0
- package/nitrogen/generated/ios/swift/SampleTypeIdentifierWriteable.swift +4 -0
- package/nitrogen/generated/ios/swift/StateOfMindSample.swift +8 -8
- package/nitrogen/generated/shared/c++/CategorySample.hpp +7 -7
- package/nitrogen/generated/shared/c++/CorrelationSample.hpp +7 -7
- package/nitrogen/generated/shared/c++/ElectrocardiogramSample.hpp +7 -7
- package/nitrogen/generated/shared/c++/HeartbeatSeriesSample.hpp +7 -7
- package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +3 -1
- package/nitrogen/generated/shared/c++/MedicationDoseEvent.hpp +7 -7
- package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +49 -45
- package/nitrogen/generated/shared/c++/QuantitySample.hpp +7 -7
- package/nitrogen/generated/shared/c++/QuantityTypeIdentifier.hpp +42 -38
- package/nitrogen/generated/shared/c++/QuantityTypeIdentifierWriteable.hpp +42 -38
- package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +48 -44
- package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +47 -43
- package/nitrogen/generated/shared/c++/StateOfMindSample.hpp +7 -7
- package/package.json +4 -1
- package/src/generated/healthkit-schema.json +13 -0
- package/src/generated/healthkit.generated.ts +5 -0
- package/src/healthkit.ios.ts +3 -0
- package/src/healthkit.ts +27 -84
- package/src/specs/CoreModule.nitro.ts +19 -0
- package/src/specs/SourceProxy.nitro.ts +2 -4
- package/src/test-setup.ts +1 -0
- package/src/types/Auth.ts +4 -17
- package/src/types/Background.ts +1 -9
- package/src/types/Device.ts +1 -13
- package/src/types/QuantityType.ts +1 -1
- package/src/types/QueryOptions.ts +7 -65
- package/src/types/Shared.ts +7 -28
- package/src/types/Source.ts +1 -11
- package/src/types/Subscriptions.ts +2 -3
- package/ios/BackgroundDeliveryManager.swift +0 -284
- package/ios/BackgroundLaunchHook.mm +0 -41
- package/ios/Bridge.h +0 -10
- package/ios/ExceptionCatcher.h +0 -5
- package/ios/ExceptionCatcher.mm +0 -32
- package/ios/module.modulemap +0 -5
|
@@ -648,6 +648,14 @@
|
|
|
648
648
|
"writeable": true,
|
|
649
649
|
"legacy": false
|
|
650
650
|
},
|
|
651
|
+
{
|
|
652
|
+
"name": "HKQuantityTypeIdentifierHeartRateVariabilityRMSSD",
|
|
653
|
+
"ios": "27.0",
|
|
654
|
+
"canonicalUnit": "ms",
|
|
655
|
+
"aggregationStyle": "Discrete (Arithmetic)",
|
|
656
|
+
"writeable": true,
|
|
657
|
+
"legacy": false
|
|
658
|
+
},
|
|
651
659
|
{
|
|
652
660
|
"name": "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
|
|
653
661
|
"ios": "11.0",
|
|
@@ -2096,6 +2104,11 @@
|
|
|
2096
2104
|
"name": "predictionNonExercise",
|
|
2097
2105
|
"swiftName": "HKHeartRateRecoveryTestTypePredictionNonExercise",
|
|
2098
2106
|
"rawValue": 3
|
|
2107
|
+
},
|
|
2108
|
+
{
|
|
2109
|
+
"name": "stepTest",
|
|
2110
|
+
"swiftName": "HKHeartRateRecoveryTestTypeStepTest",
|
|
2111
|
+
"rawValue": 4
|
|
2099
2112
|
}
|
|
2100
2113
|
]
|
|
2101
2114
|
},
|
|
@@ -99,6 +99,7 @@ export type QuantityTypeIdentifierWriteable =
|
|
|
99
99
|
| 'HKQuantityTypeIdentifierHeadphoneAudioExposure'
|
|
100
100
|
| 'HKQuantityTypeIdentifierHeartRate'
|
|
101
101
|
| 'HKQuantityTypeIdentifierHeartRateRecoveryOneMinute'
|
|
102
|
+
| 'HKQuantityTypeIdentifierHeartRateVariabilityRMSSD'
|
|
102
103
|
| 'HKQuantityTypeIdentifierHeartRateVariabilitySDNN'
|
|
103
104
|
| 'HKQuantityTypeIdentifierHeight'
|
|
104
105
|
| 'HKQuantityTypeIdentifierInhalerUsage'
|
|
@@ -299,6 +300,7 @@ export const QUANTITY_IDENTIFIER_IOS_AVAILABILITY = {
|
|
|
299
300
|
HKQuantityTypeIdentifierHeadphoneAudioExposure: '13.0',
|
|
300
301
|
HKQuantityTypeIdentifierHeartRate: '8.0',
|
|
301
302
|
HKQuantityTypeIdentifierHeartRateRecoveryOneMinute: '16.0',
|
|
303
|
+
HKQuantityTypeIdentifierHeartRateVariabilityRMSSD: '27.0',
|
|
302
304
|
HKQuantityTypeIdentifierHeartRateVariabilitySDNN: '11.0',
|
|
303
305
|
HKQuantityTypeIdentifierHeight: '8.0',
|
|
304
306
|
HKQuantityTypeIdentifierInhalerUsage: '8.0',
|
|
@@ -495,6 +497,7 @@ export const QUANTITY_IDENTIFIER_CANONICAL_UNITS = {
|
|
|
495
497
|
HKQuantityTypeIdentifierHeadphoneAudioExposure: 'dBASPL',
|
|
496
498
|
HKQuantityTypeIdentifierHeartRate: 'count/s',
|
|
497
499
|
HKQuantityTypeIdentifierHeartRateRecoveryOneMinute: 'count/min',
|
|
500
|
+
HKQuantityTypeIdentifierHeartRateVariabilityRMSSD: 'ms',
|
|
498
501
|
HKQuantityTypeIdentifierHeartRateVariabilitySDNN: 'ms',
|
|
499
502
|
HKQuantityTypeIdentifierHeight: 'm',
|
|
500
503
|
HKQuantityTypeIdentifierInhalerUsage: 'count',
|
|
@@ -767,6 +770,7 @@ export enum HeartRateRecoveryTestType {
|
|
|
767
770
|
maxExercise = 1,
|
|
768
771
|
predictionSubMaxExercise = 2,
|
|
769
772
|
predictionNonExercise = 3,
|
|
773
|
+
stepTest = 4,
|
|
770
774
|
}
|
|
771
775
|
export enum HeartRateSensorLocation {
|
|
772
776
|
other = 0,
|
|
@@ -1267,6 +1271,7 @@ export interface QuantityUnitByIdentifierMap {
|
|
|
1267
1271
|
readonly HKQuantityTypeIdentifierHeadphoneAudioExposure: PressureUnit
|
|
1268
1272
|
readonly HKQuantityTypeIdentifierHeartRate: CountPerTime<TimeUnit>
|
|
1269
1273
|
readonly HKQuantityTypeIdentifierHeartRateRecoveryOneMinute: CountPerTime<TimeUnit>
|
|
1274
|
+
readonly HKQuantityTypeIdentifierHeartRateVariabilityRMSSD: string
|
|
1270
1275
|
readonly HKQuantityTypeIdentifierHeartRateVariabilitySDNN: string
|
|
1271
1276
|
readonly HKQuantityTypeIdentifierHeight: LengthUnit
|
|
1272
1277
|
readonly HKQuantityTypeIdentifierInhalerUsage: 'count'
|
package/src/healthkit.ios.ts
CHANGED
|
@@ -300,6 +300,8 @@ const MedicationBindings = {
|
|
|
300
300
|
export const authorizationStatusFor = Core.authorizationStatusFor.bind(Core)
|
|
301
301
|
export const requestPerObjectReadAuthorization =
|
|
302
302
|
Core.requestPerObjectReadAuthorization.bind(Core)
|
|
303
|
+
export const getEarliestAuthorizedSampleDates =
|
|
304
|
+
Core.getEarliestAuthorizedSampleDates.bind(Core)
|
|
303
305
|
export const disableAllBackgroundDelivery =
|
|
304
306
|
Core.disableAllBackgroundDelivery.bind(Core)
|
|
305
307
|
export const disableBackgroundDelivery =
|
|
@@ -454,6 +456,7 @@ export default {
|
|
|
454
456
|
querySources,
|
|
455
457
|
requestAuthorization,
|
|
456
458
|
requestPerObjectReadAuthorization,
|
|
459
|
+
getEarliestAuthorizedSampleDates,
|
|
457
460
|
deleteObjects,
|
|
458
461
|
saveCategorySample,
|
|
459
462
|
saveCorrelationSample,
|
package/src/healthkit.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createUnavailableHelpers } from '@react-native-healthkit/core'
|
|
2
2
|
|
|
3
3
|
// Import types for default values and function signatures.
|
|
4
4
|
// These types are expected to be available via the './types' export.
|
|
@@ -52,25 +52,10 @@ import type {
|
|
|
52
52
|
|
|
53
53
|
export * from './types'
|
|
54
54
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
function UnavailableFnFromModule<
|
|
60
|
-
TKey extends keyof typeof ReactNativeHealthkit,
|
|
61
|
-
// biome-ignore lint/complexity/noBannedTypes: it works
|
|
62
|
-
T extends Function = (typeof ReactNativeHealthkit)[TKey],
|
|
63
|
-
// @ts-expect-error
|
|
64
|
-
>(_fn: TKey, defaultValue: ReturnType<T>): T {
|
|
65
|
-
// @ts-expect-error
|
|
66
|
-
return () => {
|
|
67
|
-
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
68
|
-
console.warn(notAvailableError)
|
|
69
|
-
hasWarned = true
|
|
70
|
-
}
|
|
71
|
-
return defaultValue
|
|
72
|
-
}
|
|
73
|
-
}
|
|
55
|
+
const { unavailableFn: UnavailableFnFromModule, warnIfUnavailable } =
|
|
56
|
+
createUnavailableHelpers<typeof ReactNativeHealthkit>(
|
|
57
|
+
'@kingstinct/react-native-healthkit',
|
|
58
|
+
)
|
|
74
59
|
|
|
75
60
|
// --- Mock Implementations for exported functions ---
|
|
76
61
|
|
|
@@ -185,10 +170,7 @@ export function queryQuantitySamples<T extends QuantityTypeIdentifier>(
|
|
|
185
170
|
_identifier: T,
|
|
186
171
|
_options: QueryOptionsWithSortOrderAndUnit<UnitForIdentifier<T>>,
|
|
187
172
|
): Promise<readonly QuantitySampleTyped<T>[]> {
|
|
188
|
-
|
|
189
|
-
console.warn(notAvailableError)
|
|
190
|
-
hasWarned = true
|
|
191
|
-
}
|
|
173
|
+
warnIfUnavailable()
|
|
192
174
|
return Promise.resolve([])
|
|
193
175
|
}
|
|
194
176
|
|
|
@@ -198,10 +180,7 @@ export function queryQuantitySamplesWithAnchor<
|
|
|
198
180
|
_identifier: T,
|
|
199
181
|
_options: QueryOptionsWithAnchorAndUnit<UnitForIdentifier<T>>,
|
|
200
182
|
): Promise<QuantitySamplesWithAnchorResponseTyped<T>> {
|
|
201
|
-
|
|
202
|
-
console.warn(notAvailableError)
|
|
203
|
-
hasWarned = true
|
|
204
|
-
}
|
|
183
|
+
warnIfUnavailable()
|
|
205
184
|
return Promise.resolve({
|
|
206
185
|
samples: [],
|
|
207
186
|
deletedSamples: [],
|
|
@@ -213,10 +192,7 @@ export function queryStatisticsForQuantity<T extends QuantityTypeIdentifier>(
|
|
|
213
192
|
_statistics: readonly StatisticsOptions[],
|
|
214
193
|
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
215
194
|
): Promise<QueryStatisticsResponse> {
|
|
216
|
-
|
|
217
|
-
console.warn(notAvailableError)
|
|
218
|
-
hasWarned = true
|
|
219
|
-
}
|
|
195
|
+
warnIfUnavailable()
|
|
220
196
|
return Promise.resolve({
|
|
221
197
|
sources: [],
|
|
222
198
|
})
|
|
@@ -230,10 +206,7 @@ export function queryStatisticsCollectionForQuantity<
|
|
|
230
206
|
_intervalComponents: IntervalComponents,
|
|
231
207
|
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
232
208
|
): Promise<readonly QueryStatisticsResponse[]> {
|
|
233
|
-
|
|
234
|
-
console.warn(notAvailableError)
|
|
235
|
-
hasWarned = true
|
|
236
|
-
}
|
|
209
|
+
warnIfUnavailable()
|
|
237
210
|
return Promise.resolve([])
|
|
238
211
|
}
|
|
239
212
|
|
|
@@ -244,10 +217,7 @@ export function queryStatisticsForQuantitySeparateBySource<
|
|
|
244
217
|
_statistics: readonly StatisticsOptions[],
|
|
245
218
|
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
246
219
|
): Promise<QueryStatisticsResponseFromSingleSource[]> {
|
|
247
|
-
|
|
248
|
-
console.warn(notAvailableError)
|
|
249
|
-
hasWarned = true
|
|
250
|
-
}
|
|
220
|
+
warnIfUnavailable()
|
|
251
221
|
return Promise.resolve([])
|
|
252
222
|
}
|
|
253
223
|
export function queryStatisticsCollectionForQuantitySeparateBySource<
|
|
@@ -259,10 +229,7 @@ export function queryStatisticsCollectionForQuantitySeparateBySource<
|
|
|
259
229
|
_intervalComponents: IntervalComponents,
|
|
260
230
|
_options?: StatisticsQueryOptions<UnitForIdentifier<T>>,
|
|
261
231
|
): Promise<readonly QueryStatisticsResponseFromSingleSource[]> {
|
|
262
|
-
|
|
263
|
-
console.warn(notAvailableError)
|
|
264
|
-
hasWarned = true
|
|
265
|
-
}
|
|
232
|
+
warnIfUnavailable()
|
|
266
233
|
return Promise.resolve([])
|
|
267
234
|
}
|
|
268
235
|
export function saveQuantitySample<T extends QuantityTypeIdentifierWriteable>(
|
|
@@ -273,20 +240,14 @@ export function saveQuantitySample<T extends QuantityTypeIdentifierWriteable>(
|
|
|
273
240
|
_end: Date,
|
|
274
241
|
_metadata?: MetadataForQuantityIdentifier<T>,
|
|
275
242
|
): Promise<QuantitySampleTyped<T> | undefined> {
|
|
276
|
-
|
|
277
|
-
console.warn(notAvailableError)
|
|
278
|
-
hasWarned = true
|
|
279
|
-
}
|
|
243
|
+
warnIfUnavailable()
|
|
280
244
|
return Promise.resolve(undefined)
|
|
281
245
|
}
|
|
282
246
|
export function isQuantityCompatibleWithUnit<T extends QuantityTypeIdentifier>(
|
|
283
247
|
_identifier: T,
|
|
284
248
|
_unit: UnitForIdentifier<T>,
|
|
285
249
|
): boolean {
|
|
286
|
-
|
|
287
|
-
console.warn(notAvailableError)
|
|
288
|
-
hasWarned = true
|
|
289
|
-
}
|
|
250
|
+
warnIfUnavailable()
|
|
290
251
|
return false
|
|
291
252
|
}
|
|
292
253
|
|
|
@@ -295,10 +256,7 @@ export function queryCategorySamples<T extends CategoryTypeIdentifier>(
|
|
|
295
256
|
_categoryTypeIdentifier: T,
|
|
296
257
|
_options: QueryOptionsWithSortOrder,
|
|
297
258
|
): Promise<CategorySampleTyped<T>[]> {
|
|
298
|
-
|
|
299
|
-
console.warn(notAvailableError)
|
|
300
|
-
hasWarned = true
|
|
301
|
-
}
|
|
259
|
+
warnIfUnavailable()
|
|
302
260
|
return Promise.resolve([])
|
|
303
261
|
}
|
|
304
262
|
|
|
@@ -308,10 +266,7 @@ export function queryCategorySamplesWithAnchor<
|
|
|
308
266
|
_categoryTypeIdentifier: T,
|
|
309
267
|
_options: QueryOptionsWithAnchor,
|
|
310
268
|
): Promise<CategorySamplesWithAnchorResponseTyped<T>> {
|
|
311
|
-
|
|
312
|
-
console.warn(notAvailableError)
|
|
313
|
-
hasWarned = true
|
|
314
|
-
}
|
|
269
|
+
warnIfUnavailable()
|
|
315
270
|
return Promise.resolve({
|
|
316
271
|
samples: [],
|
|
317
272
|
deletedSamples: [],
|
|
@@ -326,10 +281,7 @@ export function saveCategorySample<T extends CategoryTypeIdentifierWriteable>(
|
|
|
326
281
|
_endDate: Date,
|
|
327
282
|
_metadata?: MetadataForCategoryIdentifier<T>,
|
|
328
283
|
): Promise<CategorySampleTyped<T> | undefined> {
|
|
329
|
-
|
|
330
|
-
console.warn(notAvailableError)
|
|
331
|
-
hasWarned = true
|
|
332
|
-
}
|
|
284
|
+
warnIfUnavailable()
|
|
333
285
|
return Promise.resolve(undefined)
|
|
334
286
|
}
|
|
335
287
|
|
|
@@ -426,10 +378,7 @@ export const saveStateOfMindSample = UnavailableFnFromModule(
|
|
|
426
378
|
export function getMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
427
379
|
_identifier: T,
|
|
428
380
|
): Promise<CategorySampleTyped<T> | undefined> {
|
|
429
|
-
|
|
430
|
-
console.warn(notAvailableError)
|
|
431
|
-
hasWarned = true
|
|
432
|
-
}
|
|
381
|
+
warnIfUnavailable()
|
|
433
382
|
return Promise.resolve(undefined)
|
|
434
383
|
}
|
|
435
384
|
|
|
@@ -437,10 +386,7 @@ export function getMostRecentQuantitySample<T extends QuantityTypeIdentifier>(
|
|
|
437
386
|
_identifier: T,
|
|
438
387
|
_unit?: UnitForIdentifier<T>,
|
|
439
388
|
): Promise<QuantitySampleTyped<T> | undefined> {
|
|
440
|
-
|
|
441
|
-
console.warn(notAvailableError)
|
|
442
|
-
hasWarned = true
|
|
443
|
-
}
|
|
389
|
+
warnIfUnavailable()
|
|
444
390
|
return Promise.resolve(undefined)
|
|
445
391
|
}
|
|
446
392
|
export const getMostRecentWorkout = UnavailableFnFromModule(
|
|
@@ -451,10 +397,7 @@ export const getMostRecentWorkout = UnavailableFnFromModule(
|
|
|
451
397
|
export function getPreferredUnit<T extends QuantityTypeIdentifier>(
|
|
452
398
|
_quantityType: T,
|
|
453
399
|
): Promise<UnitForIdentifier<T>> {
|
|
454
|
-
|
|
455
|
-
console.warn(notAvailableError)
|
|
456
|
-
hasWarned = true
|
|
457
|
-
}
|
|
400
|
+
warnIfUnavailable()
|
|
458
401
|
return Promise.resolve('count' as UnitForIdentifier<T>)
|
|
459
402
|
}
|
|
460
403
|
|
|
@@ -462,10 +405,7 @@ export function getPreferredUnit<T extends QuantityTypeIdentifier>(
|
|
|
462
405
|
export function useMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
463
406
|
_categoryTypeIdentifier: T,
|
|
464
407
|
): CategorySampleTyped<T> | undefined {
|
|
465
|
-
|
|
466
|
-
console.warn(notAvailableError)
|
|
467
|
-
hasWarned = true
|
|
468
|
-
}
|
|
408
|
+
warnIfUnavailable()
|
|
469
409
|
return undefined
|
|
470
410
|
}
|
|
471
411
|
|
|
@@ -473,10 +413,7 @@ export function useMostRecentQuantitySample<T extends QuantityTypeIdentifier>(
|
|
|
473
413
|
_identifier: T,
|
|
474
414
|
_unit?: UnitForIdentifier<T>,
|
|
475
415
|
): QuantitySampleTyped<T> | undefined {
|
|
476
|
-
|
|
477
|
-
console.warn(notAvailableError)
|
|
478
|
-
hasWarned = true
|
|
479
|
-
}
|
|
416
|
+
warnIfUnavailable()
|
|
480
417
|
return undefined
|
|
481
418
|
}
|
|
482
419
|
export const useMostRecentWorkout = UnavailableFnFromModule(
|
|
@@ -569,6 +506,11 @@ export const requestPerObjectReadAuthorization = UnavailableFnFromModule(
|
|
|
569
506
|
Promise.resolve(undefined),
|
|
570
507
|
) // Mocking callback structure
|
|
571
508
|
|
|
509
|
+
export const getEarliestAuthorizedSampleDates = UnavailableFnFromModule(
|
|
510
|
+
'getEarliestAuthorizedSampleDates',
|
|
511
|
+
Promise.resolve({}),
|
|
512
|
+
)
|
|
513
|
+
|
|
572
514
|
export const subscribeToCategorySamples = UnavailableFnFromModule(
|
|
573
515
|
'subscribeToCategorySamples',
|
|
574
516
|
{
|
|
@@ -646,6 +588,7 @@ const HealthkitModule = {
|
|
|
646
588
|
queryMedicationEventsWithAnchor,
|
|
647
589
|
requestMedicationsAuthorization,
|
|
648
590
|
requestPerObjectReadAuthorization,
|
|
591
|
+
getEarliestAuthorizedSampleDates,
|
|
649
592
|
|
|
650
593
|
subscribeToCategorySamples,
|
|
651
594
|
currentAppSource,
|
|
@@ -118,6 +118,25 @@ export interface CoreModule extends HybridObject<{ ios: 'swift' }> {
|
|
|
118
118
|
typeIdentifier: PerObjectTypeIdentifier,
|
|
119
119
|
): Promise<void>
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Reports, for each of the given object types, the earliest date from which the app is
|
|
123
|
+
* authorized to read samples when the user has granted only limited access.
|
|
124
|
+
*
|
|
125
|
+
* A type is only present in the result when the user has imposed a lower time bound on
|
|
126
|
+
* the app's read access for it - types without such a bound are omitted. Use it to clamp
|
|
127
|
+
* the `startDate` of a query filter so you don't request data you can't read.
|
|
128
|
+
*
|
|
129
|
+
* Requires iOS 27. On earlier versions there is no limited-access lower bound, so this
|
|
130
|
+
* resolves to an empty object. It also resolves to an empty object - and logs a warning -
|
|
131
|
+
* when running on iOS 27 in an app built with an SDK older than iOS 27, since the
|
|
132
|
+
* underlying API cannot be called from such a binary.
|
|
133
|
+
*
|
|
134
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/earliestauthorizedsampledate(for:) Apple Docs }
|
|
135
|
+
*/
|
|
136
|
+
getEarliestAuthorizedSampleDates(
|
|
137
|
+
objectTypeIdentifiers: readonly ObjectTypeIdentifier[],
|
|
138
|
+
): Promise<Record<string, Date>>
|
|
139
|
+
|
|
121
140
|
deleteObjects(
|
|
122
141
|
objectTypeIdentifier: SampleTypeIdentifierWriteable,
|
|
123
142
|
filter: FilterForSamples,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import type { Source } from '@react-native-healthkit/core'
|
|
1
2
|
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
readonly name: string
|
|
5
|
-
readonly bundleIdentifier: string
|
|
6
|
-
}
|
|
4
|
+
export type { Source }
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkobject/1615781-source Apple Docs }
|
package/src/test-setup.ts
CHANGED
|
@@ -50,6 +50,7 @@ const mockModule = {
|
|
|
50
50
|
isObjectTypeAvailableAsync: jest.fn(),
|
|
51
51
|
areObjectTypesAvailable: jest.fn(),
|
|
52
52
|
areObjectTypesAvailableAsync: jest.fn(),
|
|
53
|
+
getEarliestAuthorizedSampleDates: jest.fn(),
|
|
53
54
|
queryStateOfMindSamples: jest.fn(),
|
|
54
55
|
workoutSessionMirroringStartHandler: jest.fn(),
|
|
55
56
|
}
|
package/src/types/Auth.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
unknown = 0,
|
|
6
|
-
shouldRequest = 1,
|
|
7
|
-
unnecessary = 2,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkauthorizationstatus Apple Docs }
|
|
12
|
-
*/
|
|
13
|
-
export enum AuthorizationStatus {
|
|
14
|
-
notDetermined = 0,
|
|
15
|
-
sharingDenied = 1,
|
|
16
|
-
sharingAuthorized = 2,
|
|
17
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
AuthorizationRequestStatus,
|
|
3
|
+
AuthorizationStatus,
|
|
4
|
+
} from '@react-native-healthkit/core'
|
package/src/types/Background.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
3
|
-
*/
|
|
4
|
-
export enum UpdateFrequency {
|
|
5
|
-
immediate = 1,
|
|
6
|
-
hourly = 2,
|
|
7
|
-
daily = 3,
|
|
8
|
-
weekly = 4,
|
|
9
|
-
}
|
|
1
|
+
export { UpdateFrequency } from '@react-native-healthkit/core'
|
package/src/types/Device.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkdevice Apple Docs }
|
|
3
|
-
*/
|
|
4
|
-
export interface Device {
|
|
5
|
-
readonly name?: string // ex: "Apple Watch"
|
|
6
|
-
readonly firmwareVersion?: string
|
|
7
|
-
readonly hardwareVersion?: string // ex: "Watch6,2",
|
|
8
|
-
readonly localIdentifier?: string
|
|
9
|
-
readonly manufacturer?: string // ex: "Apple Inc."
|
|
10
|
-
readonly model?: string // ex: "Watch"
|
|
11
|
-
readonly softwareVersion?: string // ex: "9.0"
|
|
12
|
-
readonly udiDeviceIdentifier?: string
|
|
13
|
-
}
|
|
1
|
+
export type { Device } from '@react-native-healthkit/core'
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
HeartRateMotionContext,
|
|
4
4
|
InsulinDeliveryReason,
|
|
5
5
|
} from '../generated/healthkit.generated'
|
|
6
|
-
import type { Source } from '../specs/SourceProxy.nitro'
|
|
7
6
|
import type { QuantitySample, QuantitySampleTyped } from './QuantitySample'
|
|
8
7
|
import type { QuantityTypeIdentifier } from './QuantityTypeIdentifier'
|
|
9
8
|
import type { FilterForSamples } from './QueryOptions'
|
|
10
9
|
import type { DeletedSample } from './Shared'
|
|
10
|
+
import type { Source } from './Source'
|
|
11
11
|
|
|
12
12
|
export { HeartRateMotionContext, InsulinDeliveryReason }
|
|
13
13
|
|
|
@@ -1,71 +1,13 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DateFilter,
|
|
3
|
+
PredicateWithMetadataKey,
|
|
4
|
+
StrictUnion,
|
|
5
|
+
} from '@react-native-healthkit/core'
|
|
1
6
|
import type { SourceProxy } from '../specs/SourceProxy.nitro'
|
|
2
7
|
import type { WorkoutProxy } from '../specs/WorkoutProxy.nitro'
|
|
3
8
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
lessThanOrEqualTo = 1,
|
|
8
|
-
|
|
9
|
-
greaterThan = 2,
|
|
10
|
-
|
|
11
|
-
greaterThanOrEqualTo = 3,
|
|
12
|
-
|
|
13
|
-
equalTo = 4,
|
|
14
|
-
|
|
15
|
-
notEqualTo = 5,
|
|
16
|
-
|
|
17
|
-
matches = 6,
|
|
18
|
-
|
|
19
|
-
like = 7,
|
|
20
|
-
|
|
21
|
-
beginsWith = 8,
|
|
22
|
-
|
|
23
|
-
endsWith = 9,
|
|
24
|
-
|
|
25
|
-
IN = 10,
|
|
26
|
-
|
|
27
|
-
customSelector = 11,
|
|
28
|
-
|
|
29
|
-
contains = 99,
|
|
30
|
-
|
|
31
|
-
between = 100,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type PredicateWithMetadataValue = string | number | Date | boolean
|
|
35
|
-
|
|
36
|
-
export interface PredicateWithMetadataKey {
|
|
37
|
-
readonly withMetadataKey: string
|
|
38
|
-
readonly operatorType?: ComparisonPredicateOperator
|
|
39
|
-
readonly value?: PredicateWithMetadataValue
|
|
40
|
-
}
|
|
41
|
-
// Computes and flattens object types
|
|
42
|
-
// biome-ignore lint/complexity/noBannedTypes: it works
|
|
43
|
-
type ComputeRaw<A> = A extends Function ? A : { [K in keyof A]: A[K] } & {}
|
|
44
|
-
|
|
45
|
-
// Gets all keys from a union of objects
|
|
46
|
-
// biome-ignore lint/suspicious/noExplicitAny: it works
|
|
47
|
-
type AllKeys<U> = U extends any ? keyof U : never
|
|
48
|
-
|
|
49
|
-
// The core: for each member U in the union,
|
|
50
|
-
// add `?: never` for any key that exists in other union members.
|
|
51
|
-
// biome-ignore lint/suspicious/noExplicitAny: it works
|
|
52
|
-
type _Strict<U, UAll extends U = U> = U extends any
|
|
53
|
-
? ComputeRaw<
|
|
54
|
-
U & {
|
|
55
|
-
[K in Exclude<AllKeys<UAll>, keyof U>]?: never
|
|
56
|
-
}
|
|
57
|
-
>
|
|
58
|
-
: never
|
|
59
|
-
|
|
60
|
-
// The exported type you can copy into your codebase
|
|
61
|
-
export type StrictUnion<U extends object> = _Strict<U>
|
|
62
|
-
|
|
63
|
-
export interface DateFilter {
|
|
64
|
-
readonly startDate?: Date
|
|
65
|
-
readonly endDate?: Date
|
|
66
|
-
readonly strictEndDate?: boolean
|
|
67
|
-
readonly strictStartDate?: boolean
|
|
68
|
-
}
|
|
9
|
+
export { ComparisonPredicateOperator } from '@react-native-healthkit/core'
|
|
10
|
+
export type { DateFilter, PredicateWithMetadataKey, StrictUnion }
|
|
69
11
|
|
|
70
12
|
export interface FilterForSamplesBase {
|
|
71
13
|
readonly uuid?: string
|
package/src/types/Shared.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BaseObject,
|
|
3
|
+
BaseSample,
|
|
4
|
+
DeletedSample,
|
|
5
|
+
SampleType,
|
|
6
|
+
} from '@react-native-healthkit/core'
|
|
1
7
|
import type { AnyMap } from 'react-native-nitro-modules'
|
|
2
8
|
import type {
|
|
3
9
|
KnownObjectMetadata,
|
|
@@ -20,17 +26,12 @@ import type {
|
|
|
20
26
|
WorkoutTypeIdentifier,
|
|
21
27
|
} from './Constants'
|
|
22
28
|
import type { CorrelationTypeIdentifier } from './CorrelationType'
|
|
23
|
-
import type { Device } from './Device'
|
|
24
29
|
import type {
|
|
25
30
|
QuantityTypeIdentifier,
|
|
26
31
|
QuantityTypeIdentifierWriteable,
|
|
27
32
|
} from './QuantityTypeIdentifier'
|
|
28
|
-
import type { SourceRevision } from './Source'
|
|
29
33
|
|
|
30
|
-
export
|
|
31
|
-
readonly uuid: string
|
|
32
|
-
readonly metadata?: AnyMap
|
|
33
|
-
}
|
|
34
|
+
export type { BaseObject, BaseSample, DeletedSample, SampleType }
|
|
34
35
|
|
|
35
36
|
export type ObjectTypeIdentifier =
|
|
36
37
|
| CharacteristicTypeIdentifier
|
|
@@ -80,25 +81,3 @@ export type BaseObjectTyped<TMetadata extends object = KnownObjectMetadata> =
|
|
|
80
81
|
WithTypedMetadata<BaseObject, TMetadata>
|
|
81
82
|
export type BaseSampleTyped<TMetadata extends object = KnownSampleMetadata> =
|
|
82
83
|
WithTypedMetadata<BaseSample, TMetadata>
|
|
83
|
-
|
|
84
|
-
export interface BaseObject {
|
|
85
|
-
readonly uuid: string
|
|
86
|
-
readonly sourceRevision: SourceRevision
|
|
87
|
-
readonly device?: Device
|
|
88
|
-
readonly metadata: AnyMap
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface SampleType {
|
|
92
|
-
identifier: string
|
|
93
|
-
allowsRecalibrationForEstimates: boolean
|
|
94
|
-
isMinimumDurationRestricted: boolean
|
|
95
|
-
isMaximumDurationRestricted: boolean
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface BaseSample extends BaseObject {
|
|
99
|
-
readonly sampleType: SampleType
|
|
100
|
-
readonly startDate: Date
|
|
101
|
-
readonly endDate: Date
|
|
102
|
-
readonly hasUndeterminedDuration: boolean
|
|
103
|
-
readonly metadata: AnyMap
|
|
104
|
-
}
|
package/src/types/Source.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkobject/1615483-sourcerevision Apple Docs }
|
|
5
|
-
*/
|
|
6
|
-
export interface SourceRevision {
|
|
7
|
-
readonly source: Source
|
|
8
|
-
readonly version?: string
|
|
9
|
-
readonly operatingSystemVersion: string
|
|
10
|
-
readonly productType?: string
|
|
11
|
-
}
|
|
1
|
+
export type { Source, SourceRevision } from '@react-native-healthkit/core'
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import type { EmitterSubscription } from '@react-native-healthkit/core'
|
|
1
2
|
import type { CategorySampleTyped } from './CategoryType'
|
|
2
3
|
import type { CategoryTypeIdentifier } from './CategoryTypeIdentifier'
|
|
3
4
|
import type { QuantitySampleTyped } from './QuantitySample'
|
|
4
5
|
import type { QuantityTypeIdentifier } from './QuantityTypeIdentifier'
|
|
5
6
|
import type { SampleTypeIdentifier } from './Shared'
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
remove: () => void
|
|
9
|
-
}
|
|
8
|
+
export type { EmitterSubscription }
|
|
10
9
|
|
|
11
10
|
export interface OnChangeCallbackArgs {
|
|
12
11
|
readonly typeIdentifier: SampleTypeIdentifier
|