@kingstinct/react-native-healthkit 14.1.0 → 15.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.
Files changed (71) hide show
  1. package/README.md +32 -2
  2. package/app.plugin.js +49 -94
  3. package/app.plugin.ts +6 -56
  4. package/ios/BackgroundDeliveryManager.swift +13 -6
  5. package/ios/BackgroundLaunchHook.mm +41 -0
  6. package/ios/Constants.swift +24 -0
  7. package/ios/CoreModule.swift +5 -1
  8. package/ios/Helpers.swift +29 -1
  9. package/ios/MemoryEstimation.swift +83 -0
  10. package/ios/QuantityTypeModule.swift +34 -26
  11. package/ios/Serializers.swift +18 -3
  12. package/ios/SourceProxy.swift +14 -5
  13. package/ios/WorkoutProxy.swift +28 -11
  14. package/lib/commonjs/generated/healthkit.generated.js +13 -3
  15. package/lib/commonjs/healthkit.ios.js +3 -1
  16. package/lib/commonjs/healthkit.js +4 -2
  17. package/lib/module/generated/healthkit.generated.js +12 -2
  18. package/lib/module/healthkit.ios.js +2 -0
  19. package/lib/module/healthkit.js +2 -0
  20. package/lib/typescript/generated/healthkit.generated.d.ts +17 -7
  21. package/lib/typescript/healthkit.d.ts +1 -0
  22. package/lib/typescript/healthkit.ios.d.ts +2 -0
  23. package/lib/typescript/specs/CoreModule.nitro.d.ts +6 -4
  24. package/lib/typescript/specs/SourceProxy.nitro.d.ts +1 -2
  25. package/lib/typescript/types/QuantityType.d.ts +3 -3
  26. package/lib/typescript/types/Source.d.ts +2 -2
  27. package/lib/typescript/types/Units.d.ts +1 -1
  28. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +16 -16
  29. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +23 -12
  30. package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +7 -4
  31. package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +7 -4
  32. package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +7 -4
  33. package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +7 -4
  34. package/nitrogen/generated/ios/c++/HybridMedicationModuleSpecSwift.hpp +7 -4
  35. package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +7 -4
  36. package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +7 -4
  37. package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +3 -4
  38. package/nitrogen/generated/ios/c++/HybridWorkoutsModuleSpecSwift.hpp +6 -3
  39. package/nitrogen/generated/ios/swift/CategoryTypeIdentifier.swift +8 -0
  40. package/nitrogen/generated/ios/swift/CategoryTypeIdentifierWriteable.swift +8 -0
  41. package/nitrogen/generated/ios/swift/ObjectTypeIdentifier.swift +8 -4
  42. package/nitrogen/generated/ios/swift/QuantityTypeIdentifier.swift +0 -4
  43. package/nitrogen/generated/ios/swift/QuantityTypeIdentifierWriteable.swift +0 -4
  44. package/nitrogen/generated/ios/swift/QueryStatisticsResponse.swift +6 -13
  45. package/nitrogen/generated/ios/swift/QueryStatisticsResponseFromSingleSource.swift +4 -11
  46. package/nitrogen/generated/ios/swift/SampleTypeIdentifier.swift +8 -4
  47. package/nitrogen/generated/ios/swift/SampleTypeIdentifierWriteable.swift +8 -4
  48. package/nitrogen/generated/ios/swift/SourceRevision.swift +4 -11
  49. package/nitrogen/generated/ios/swift/WorkoutActivityType.swift +8 -0
  50. package/nitrogen/generated/shared/c++/CategoryTypeIdentifier.hpp +67 -59
  51. package/nitrogen/generated/shared/c++/CategoryTypeIdentifierWriteable.hpp +67 -59
  52. package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +202 -198
  53. package/nitrogen/generated/shared/c++/QuantityTypeIdentifier.hpp +107 -111
  54. package/nitrogen/generated/shared/c++/QuantityTypeIdentifierWriteable.hpp +107 -111
  55. package/nitrogen/generated/shared/c++/QueryStatisticsResponse.hpp +8 -9
  56. package/nitrogen/generated/shared/c++/QueryStatisticsResponseFromSingleSource.hpp +8 -9
  57. package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +195 -191
  58. package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +189 -185
  59. package/nitrogen/generated/shared/c++/SourceRevision.hpp +8 -9
  60. package/nitrogen/generated/shared/c++/WorkoutActivityType.hpp +4 -0
  61. package/package.json +5 -3
  62. package/src/generated/healthkit-schema.json +45 -8
  63. package/src/generated/healthkit.generated.ts +18 -6
  64. package/src/healthkit.ios.ts +3 -0
  65. package/src/healthkit.ts +5 -0
  66. package/src/specs/CoreModule.nitro.ts +6 -4
  67. package/src/specs/SourceProxy.nitro.ts +1 -1
  68. package/src/type-tests/generated-typing.ts +30 -8
  69. package/src/types/QuantityType.ts +3 -3
  70. package/src/types/Source.ts +2 -2
  71. package/src/types/Units.ts +1 -1
@@ -96,14 +96,6 @@
96
96
  "writeable": true,
97
97
  "legacy": false
98
98
  },
99
- {
100
- "name": "HKQuantityTypeIdentifierBloodKetones",
101
- "ios": "8.0",
102
- "canonicalUnit": "mmol/L",
103
- "aggregationStyle": "Discrete (Arithmetic)",
104
- "writeable": true,
105
- "legacy": false
106
- },
107
99
  {
108
100
  "name": "HKQuantityTypeIdentifierBloodPressureDiastolic",
109
101
  "ios": "8.0",
@@ -1019,6 +1011,13 @@
1019
1011
  "writeable": true,
1020
1012
  "legacy": false
1021
1013
  },
1014
+ {
1015
+ "name": "HKCategoryTypeIdentifierBleedingAfterMenopause",
1016
+ "ios": "27.0",
1017
+ "valueEnum": "HKCategoryValueVaginalBleeding",
1018
+ "writeable": true,
1019
+ "legacy": false
1020
+ },
1022
1021
  {
1023
1022
  "name": "HKCategoryTypeIdentifierBleedingAfterPregnancy",
1024
1023
  "ios": "18.0",
@@ -1278,6 +1277,13 @@
1278
1277
  "writeable": true,
1279
1278
  "legacy": false
1280
1279
  },
1280
+ {
1281
+ "name": "HKCategoryTypeIdentifierMenopausalState",
1282
+ "ios": "27.0",
1283
+ "valueEnum": "HKCategoryValueMenopausalState",
1284
+ "writeable": true,
1285
+ "legacy": false
1286
+ },
1281
1287
  {
1282
1288
  "name": "HKCategoryTypeIdentifierMenstrualFlow",
1283
1289
  "ios": "9.0",
@@ -1755,6 +1761,27 @@
1755
1761
  }
1756
1762
  ]
1757
1763
  },
1764
+ {
1765
+ "name": "CategoryValueMenopausalState",
1766
+ "ios": "27.0",
1767
+ "members": [
1768
+ {
1769
+ "name": "menopause",
1770
+ "swiftName": "HKCategoryValueMenopausalStateMenopause",
1771
+ "rawValue": 1
1772
+ },
1773
+ {
1774
+ "name": "perimenopause",
1775
+ "swiftName": "HKCategoryValueMenopausalStatePerimenopause",
1776
+ "rawValue": 2
1777
+ },
1778
+ {
1779
+ "name": "none",
1780
+ "swiftName": "HKCategoryValueMenopausalStateNone",
1781
+ "rawValue": 3
1782
+ }
1783
+ ]
1784
+ },
1758
1785
  {
1759
1786
  "name": "CategoryValueMenstrualFlow",
1760
1787
  "ios": "9.0",
@@ -2814,6 +2841,16 @@
2814
2841
  "swiftName": "HKWorkoutActivityTypeUnderwaterDiving",
2815
2842
  "rawValue": 84
2816
2843
  },
2844
+ {
2845
+ "name": "rest",
2846
+ "swiftName": "HKWorkoutActivityTypeRest",
2847
+ "rawValue": 2998
2848
+ },
2849
+ {
2850
+ "name": "group",
2851
+ "swiftName": "HKWorkoutActivityTypeGroup",
2852
+ "rawValue": 2999
2853
+ },
2817
2854
  {
2818
2855
  "name": "other",
2819
2856
  "swiftName": "HKWorkoutActivityTypeOther",
@@ -30,7 +30,6 @@ export type QuantityTypeIdentifierWriteable =
30
30
  | 'HKQuantityTypeIdentifierBasalEnergyBurned'
31
31
  | 'HKQuantityTypeIdentifierBloodAlcoholContent'
32
32
  | 'HKQuantityTypeIdentifierBloodGlucose'
33
- | 'HKQuantityTypeIdentifierBloodKetones'
34
33
  | 'HKQuantityTypeIdentifierBloodPressureDiastolic'
35
34
  | 'HKQuantityTypeIdentifierBloodPressureSystolic'
36
35
  | 'HKQuantityTypeIdentifierBodyFatPercentage'
@@ -154,6 +153,7 @@ export type CategoryTypeIdentifierWriteable =
154
153
  | 'HKCategoryTypeIdentifierAppleWalkingSteadinessEvent'
155
154
  | 'HKCategoryTypeIdentifierAudioExposureEvent'
156
155
  | 'HKCategoryTypeIdentifierBladderIncontinence'
156
+ | 'HKCategoryTypeIdentifierBleedingAfterMenopause'
157
157
  | 'HKCategoryTypeIdentifierBleedingAfterPregnancy'
158
158
  | 'HKCategoryTypeIdentifierBleedingDuringPregnancy'
159
159
  | 'HKCategoryTypeIdentifierBloating'
@@ -187,6 +187,7 @@ export type CategoryTypeIdentifierWriteable =
187
187
  | 'HKCategoryTypeIdentifierLowCardioFitnessEvent'
188
188
  | 'HKCategoryTypeIdentifierLowerBackPain'
189
189
  | 'HKCategoryTypeIdentifierMemoryLapse'
190
+ | 'HKCategoryTypeIdentifierMenopausalState'
190
191
  | 'HKCategoryTypeIdentifierMenstrualFlow'
191
192
  | 'HKCategoryTypeIdentifierMindfulSession'
192
193
  | 'HKCategoryTypeIdentifierMoodChanges'
@@ -229,7 +230,6 @@ export const QUANTITY_IDENTIFIER_IOS_AVAILABILITY = {
229
230
  HKQuantityTypeIdentifierBasalEnergyBurned: '8.0',
230
231
  HKQuantityTypeIdentifierBloodAlcoholContent: '8.0',
231
232
  HKQuantityTypeIdentifierBloodGlucose: '8.0',
232
- HKQuantityTypeIdentifierBloodKetones: '8.0',
233
233
  HKQuantityTypeIdentifierBloodPressureDiastolic: '8.0',
234
234
  HKQuantityTypeIdentifierBloodPressureSystolic: '8.0',
235
235
  HKQuantityTypeIdentifierBodyFatPercentage: '8.0',
@@ -347,6 +347,7 @@ export const CATEGORY_IDENTIFIER_IOS_AVAILABILITY = {
347
347
  HKCategoryTypeIdentifierAppleWalkingSteadinessEvent: '15.0',
348
348
  HKCategoryTypeIdentifierAudioExposureEvent: '13.0',
349
349
  HKCategoryTypeIdentifierBladderIncontinence: '14.0',
350
+ HKCategoryTypeIdentifierBleedingAfterMenopause: '27.0',
350
351
  HKCategoryTypeIdentifierBleedingAfterPregnancy: '18.0',
351
352
  HKCategoryTypeIdentifierBleedingDuringPregnancy: '18.0',
352
353
  HKCategoryTypeIdentifierBloating: '13.6',
@@ -384,6 +385,7 @@ export const CATEGORY_IDENTIFIER_IOS_AVAILABILITY = {
384
385
  HKCategoryTypeIdentifierLowerBackPain: '13.6',
385
386
  HKCategoryTypeIdentifierLowHeartRateEvent: '12.2',
386
387
  HKCategoryTypeIdentifierMemoryLapse: '14.0',
388
+ HKCategoryTypeIdentifierMenopausalState: '27.0',
387
389
  HKCategoryTypeIdentifierMenstrualFlow: '9.0',
388
390
  HKCategoryTypeIdentifierMindfulSession: '10.0',
389
391
  HKCategoryTypeIdentifierMoodChanges: '13.6',
@@ -424,7 +426,6 @@ export const QUANTITY_IDENTIFIER_CANONICAL_UNITS = {
424
426
  HKQuantityTypeIdentifierBasalEnergyBurned: 'kcal',
425
427
  HKQuantityTypeIdentifierBloodAlcoholContent: '%',
426
428
  HKQuantityTypeIdentifierBloodGlucose: 'mg/dL',
427
- HKQuantityTypeIdentifierBloodKetones: 'mmol/L',
428
429
  HKQuantityTypeIdentifierBloodPressureDiastolic: 'mmHg',
429
430
  HKQuantityTypeIdentifierBloodPressureSystolic: 'mmHg',
430
431
  HKQuantityTypeIdentifierBodyFatPercentage: '%',
@@ -543,6 +544,8 @@ export const CATEGORY_IDENTIFIER_VALUE_ENUMS = {
543
544
  'CategoryValueAppleWalkingSteadinessEvent',
544
545
  HKCategoryTypeIdentifierAudioExposureEvent: null,
545
546
  HKCategoryTypeIdentifierBladderIncontinence: 'CategoryValueSeverity',
547
+ HKCategoryTypeIdentifierBleedingAfterMenopause:
548
+ 'CategoryValueVaginalBleeding',
546
549
  HKCategoryTypeIdentifierBleedingAfterPregnancy:
547
550
  'CategoryValueVaginalBleeding',
548
551
  HKCategoryTypeIdentifierBleedingDuringPregnancy:
@@ -586,6 +589,7 @@ export const CATEGORY_IDENTIFIER_VALUE_ENUMS = {
586
589
  HKCategoryTypeIdentifierLowerBackPain: 'CategoryValueSeverity',
587
590
  HKCategoryTypeIdentifierLowHeartRateEvent: 'CategoryValue',
588
591
  HKCategoryTypeIdentifierMemoryLapse: 'CategoryValueSeverity',
592
+ HKCategoryTypeIdentifierMenopausalState: 'CategoryValueMenopausalState',
589
593
  HKCategoryTypeIdentifierMenstrualFlow: 'CategoryValueMenstrualFlow',
590
594
  HKCategoryTypeIdentifierMindfulSession: 'CategoryValue',
591
595
  HKCategoryTypeIdentifierMoodChanges: 'CategoryValuePresence',
@@ -686,6 +690,11 @@ export enum CategoryValueHeadphoneAudioExposureEvent {
686
690
  export enum CategoryValueLowCardioFitnessEvent {
687
691
  lowFitness = 1,
688
692
  }
693
+ export enum CategoryValueMenopausalState {
694
+ menopause = 1,
695
+ perimenopause = 2,
696
+ none = 3,
697
+ }
689
698
  export enum CategoryValueMenstrualFlow {
690
699
  unspecified = 1,
691
700
  light = 2,
@@ -914,6 +923,8 @@ export enum WorkoutActivityType {
914
923
  swimBikeRun = 82,
915
924
  transition = 83,
916
925
  underwaterDiving = 84,
926
+ rest = 2998,
927
+ group = 2999,
917
928
  other = 3000,
918
929
  }
919
930
  export enum WorkoutEventType {
@@ -938,6 +949,7 @@ export interface CategoryValueByIdentifierMap {
938
949
  readonly HKCategoryTypeIdentifierAppleStandHour: CategoryValueAppleStandHour
939
950
  readonly HKCategoryTypeIdentifierAppleWalkingSteadinessEvent: CategoryValueAppleWalkingSteadinessEvent
940
951
  readonly HKCategoryTypeIdentifierBladderIncontinence: CategoryValueSeverity
952
+ readonly HKCategoryTypeIdentifierBleedingAfterMenopause: CategoryValueVaginalBleeding
941
953
  readonly HKCategoryTypeIdentifierBleedingAfterPregnancy: CategoryValueVaginalBleeding
942
954
  readonly HKCategoryTypeIdentifierBleedingDuringPregnancy: CategoryValueVaginalBleeding
943
955
  readonly HKCategoryTypeIdentifierBloating: CategoryValueSeverity
@@ -975,6 +987,7 @@ export interface CategoryValueByIdentifierMap {
975
987
  readonly HKCategoryTypeIdentifierLowerBackPain: CategoryValueSeverity
976
988
  readonly HKCategoryTypeIdentifierLowHeartRateEvent: CategoryValue
977
989
  readonly HKCategoryTypeIdentifierMemoryLapse: CategoryValueSeverity
990
+ readonly HKCategoryTypeIdentifierMenopausalState: CategoryValueMenopausalState
978
991
  readonly HKCategoryTypeIdentifierMenstrualFlow: CategoryValueMenstrualFlow
979
992
  readonly HKCategoryTypeIdentifierMindfulSession: CategoryValue
980
993
  readonly HKCategoryTypeIdentifierMoodChanges: CategoryValuePresence
@@ -1128,7 +1141,7 @@ export type CategoryTypedMetadataForIdentifierGenerated<
1128
1141
  > = KnownSampleMetadata &
1129
1142
  (T extends keyof CategorySpecificMetadataByIdentifierMap
1130
1143
  ? CategorySpecificMetadataByIdentifierMap[T]
1131
- : Record<string, never>)
1144
+ : unknown)
1132
1145
  export interface QuantitySpecificMetadataByIdentifierMap {
1133
1146
  readonly HKQuantityTypeIdentifierBasalBodyTemperature: Pick<
1134
1147
  QuantityTypedMetadata,
@@ -1168,7 +1181,7 @@ export type QuantityTypedMetadataForIdentifierGenerated<
1168
1181
  > &
1169
1182
  (T extends keyof QuantitySpecificMetadataByIdentifierMap
1170
1183
  ? QuantitySpecificMetadataByIdentifierMap[T]
1171
- : Record<string, never>)
1184
+ : unknown)
1172
1185
  export interface QuantityUnitByIdentifierMap {
1173
1186
  readonly HKQuantityTypeIdentifierActiveEnergyBurned: EnergyUnit
1174
1187
  readonly HKQuantityTypeIdentifierAppleExerciseTime: TimeUnit
@@ -1182,7 +1195,6 @@ export interface QuantityUnitByIdentifierMap {
1182
1195
  readonly HKQuantityTypeIdentifierBasalEnergyBurned: EnergyUnit
1183
1196
  readonly HKQuantityTypeIdentifierBloodAlcoholContent: '%'
1184
1197
  readonly HKQuantityTypeIdentifierBloodGlucose: BloodGlucoseUnit
1185
- readonly HKQuantityTypeIdentifierBloodKetones: BloodGlucoseUnit
1186
1198
  readonly HKQuantityTypeIdentifierBloodPressureDiastolic: PressureUnit
1187
1199
  readonly HKQuantityTypeIdentifierBloodPressureSystolic: PressureUnit
1188
1200
  readonly HKQuantityTypeIdentifierBodyFatPercentage: '%'
@@ -368,6 +368,8 @@ export const saveWorkoutSample = WorkoutBindings.saveWorkoutSample
368
368
  export const startWatchApp =
369
369
  Workouts.startWatchAppWithWorkoutConfiguration.bind(Workouts)
370
370
  export const isProtectedDataAvailable = Core.isProtectedDataAvailable.bind(Core)
371
+ export const isProtectedDataAvailableAsync =
372
+ Core.isProtectedDataAvailableAsync.bind(Core)
371
373
  export const queryStateOfMindSamples =
372
374
  StateOfMindBindings.queryStateOfMindSamples
373
375
  export const queryStateOfMindSamplesWithAnchor =
@@ -461,6 +463,7 @@ export default {
461
463
  subscribeToQuantitySamples,
462
464
  startWatchApp,
463
465
  isProtectedDataAvailable,
466
+ isProtectedDataAvailableAsync,
464
467
  queryStateOfMindSamples,
465
468
  queryStateOfMindSamplesWithAnchor,
466
469
  saveStateOfMindSample,
package/src/healthkit.ts CHANGED
@@ -137,6 +137,10 @@ export const isProtectedDataAvailable = UnavailableFnFromModule(
137
137
  'isProtectedDataAvailable',
138
138
  false,
139
139
  )
140
+ export const isProtectedDataAvailableAsync = UnavailableFnFromModule(
141
+ 'isProtectedDataAvailableAsync',
142
+ Promise.resolve(false),
143
+ )
140
144
  export const isObjectTypeAvailable = UnavailableFnFromModule(
141
145
  'isObjectTypeAvailable',
142
146
  false,
@@ -630,6 +634,7 @@ const HealthkitModule = {
630
634
  subscribeToChanges,
631
635
  startWatchApp,
632
636
  isProtectedDataAvailable,
637
+ isProtectedDataAvailableAsync,
633
638
  queryStateOfMindSamples,
634
639
  queryStateOfMindSamplesWithAnchor,
635
640
  saveStateOfMindSample,
@@ -41,13 +41,15 @@ export interface CoreModule extends HybridObject<{ ios: 'swift' }> {
41
41
  disableAllBackgroundDelivery(): Promise<boolean>
42
42
 
43
43
  /**
44
- * Configure background delivery types that will be registered natively in
45
- * AppDelegate.didFinishLaunchingWithOptions — surviving app termination.
44
+ * Configure background delivery types whose observer queries are registered
45
+ * natively at launch (during didFinishLaunchingWithOptions), so background
46
+ * delivery survives app termination.
46
47
  * Types and frequency are persisted to UserDefaults so they're available
47
48
  * before the JS bridge boots on subsequent cold launches.
48
49
  *
49
- * Requires the Expo config plugin with `background: true` (default) or
50
- * manual AppDelegate setup: `BackgroundDeliveryManager.shared.setupBackgroundObservers()`
50
+ * Requires the background-delivery entitlement (added by the config plugin
51
+ * unless `background: false`). No AppDelegate change is needed; the pod
52
+ * registers the observers on UIApplicationDidFinishLaunchingNotification.
51
53
  */
52
54
  configureBackgroundTypes(
53
55
  typeIdentifiers: string[],
@@ -1,6 +1,6 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules'
2
2
 
3
- interface Source {
3
+ export interface Source {
4
4
  readonly name: string
5
5
  readonly bundleIdentifier: string
6
6
  }
@@ -7,14 +7,18 @@ import type {
7
7
  CategoryValueSleepAnalysis,
8
8
  CorrelationSampleTyped,
9
9
  HeartRateMotionContext,
10
+ InsulinDeliveryReason,
11
+ MetadataForQuantityIdentifier,
10
12
  Quantity,
11
13
  QuantitySampleTyped,
12
14
  QuantityTypeIdentifier,
15
+ QuantityTypeIdentifierWriteable,
13
16
  QueryOptionsWithAnchorAndUnit,
14
17
  QueryOptionsWithSortOrderAndUnit,
15
18
  StateOfMindSampleTyped,
16
19
  StatisticsQueryOptions,
17
20
  SwimmingStrokeStyle,
21
+ UnitForIdentifier,
18
22
  WorkoutEventTyped,
19
23
  WorkoutSampleTyped,
20
24
  } from '../types'
@@ -26,6 +30,13 @@ type Equal<A, B> =
26
30
 
27
31
  type Assert<T extends true> = T
28
32
 
33
+ // Mirrors saveQuantitySample(identifier, unit, value, start, end, metadata?).
34
+ type AssertSaveQuantitySampleCall<
35
+ T extends QuantityTypeIdentifierWriteable,
36
+ _TUnit extends UnitForIdentifier<T>,
37
+ _TMetadata extends MetadataForQuantityIdentifier<T>,
38
+ > = true
39
+
29
40
  type _sleepAnalysisValuesAreTyped = Assert<
30
41
  Equal<
31
42
  CategoryValueForIdentifier<'HKCategoryTypeIdentifierSleepAnalysis'>,
@@ -39,10 +50,11 @@ type _newCategoryIdentifierFromSdkIsPresent = Assert<
39
50
  : false
40
51
  >
41
52
 
42
- type _bloodKetonesIdentifierIsPresent = Assert<
53
+ // Apple has never shipped a blood ketones quantity type (see issue #379).
54
+ type _bloodKetonesIdentifierIsAbsent = Assert<
43
55
  'HKQuantityTypeIdentifierBloodKetones' extends QuantityTypeIdentifier
44
- ? true
45
- : false
56
+ ? false
57
+ : true
46
58
  >
47
59
 
48
60
  type _heartRateMetadataNarrowsToEnum = Assert<
@@ -87,12 +99,22 @@ type _bloodGlucoseUnitNarrows = Assert<
87
99
  >
88
100
  >
89
101
 
90
- type _bloodKetonesUnitNarrows = Assert<
91
- Equal<
92
- QuantitySampleTyped<'HKQuantityTypeIdentifierBloodKetones'>['unit'],
93
- BloodGlucoseUnit
102
+ type _saveQuantitySampleBodyMassAcceptsAppSpecificMetadata =
103
+ AssertSaveQuantitySampleCall<
104
+ 'HKQuantityTypeIdentifierBodyMass',
105
+ 'kg',
106
+ { APP_CUSTOM_KEY: 'v1'; HKWasUserEntered: true }
107
+ >
108
+
109
+ type _saveQuantitySampleInsulinAcceptsOfficialAndAppSpecificMetadata =
110
+ AssertSaveQuantitySampleCall<
111
+ 'HKQuantityTypeIdentifierInsulinDelivery',
112
+ 'IU',
113
+ {
114
+ HKInsulinDeliveryReason: InsulinDeliveryReason.basal
115
+ APP_CUSTOM_KEY: 'v1'
116
+ }
94
117
  >
95
- >
96
118
 
97
119
  type _quantityQueryOptionsUnitNarrows = Assert<
98
120
  Equal<
@@ -3,7 +3,7 @@ import {
3
3
  HeartRateMotionContext,
4
4
  InsulinDeliveryReason,
5
5
  } from '../generated/healthkit.generated'
6
- import type { SourceProxy } from '../specs/SourceProxy.nitro'
6
+ import type { Source } from '../specs/SourceProxy.nitro'
7
7
  import type { QuantitySample, QuantitySampleTyped } from './QuantitySample'
8
8
  import type { QuantityTypeIdentifier } from './QuantityTypeIdentifier'
9
9
  import type { FilterForSamples } from './QueryOptions'
@@ -26,12 +26,12 @@ export interface QueryStatisticsResponse {
26
26
  readonly duration?: Quantity
27
27
  readonly startDate?: Date
28
28
  readonly endDate?: Date
29
- sources: SourceProxy[]
29
+ readonly sources: readonly Source[]
30
30
  }
31
31
 
32
32
  export interface QueryStatisticsResponseFromSingleSource
33
33
  extends Omit<QueryStatisticsResponse, 'sources'> {
34
- readonly source: SourceProxy
34
+ readonly source: Source
35
35
  }
36
36
 
37
37
  export enum AggregationStyle {
@@ -1,10 +1,10 @@
1
- import type { SourceProxy } from '../specs/SourceProxy.nitro'
1
+ import type { Source } from '../specs/SourceProxy.nitro'
2
2
 
3
3
  /**
4
4
  * @see {@link https://developer.apple.com/documentation/healthkit/hkobject/1615483-sourcerevision Apple Docs }
5
5
  */
6
6
  export interface SourceRevision {
7
- readonly source: SourceProxy
7
+ readonly source: Source
8
8
  readonly version?: string
9
9
  readonly operatingSystemVersion: string
10
10
  readonly productType?: string
@@ -161,7 +161,7 @@ export type UnitOfEnergy = 'kcal' | 'Cal' | 'cal' | 'J'
161
161
 
162
162
  export type EnergyUnit = JouleUnit<MetricPrefix> | UnitOfEnergy
163
163
 
164
- export type BloodGlucoseUnit = 'mmol<180.15588000005408>/l' | 'mmol/L' | 'mg/dL'
164
+ export type BloodGlucoseUnit = 'mmol<180.15588000005408>/l' | 'mg/dL'
165
165
 
166
166
  export type SpeedUnit<
167
167
  TLength extends LengthUnit,