@kingstinct/react-native-healthkit 14.0.2 → 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 -40
  4. package/ios/BackgroundDeliveryManager.swift +95 -7
  5. package/ios/BackgroundLaunchHook.mm +41 -0
  6. package/ios/Constants.swift +24 -0
  7. package/ios/CoreModule.swift +64 -18
  8. package/ios/ExceptionCatcher.h +1 -0
  9. package/ios/ExceptionCatcher.mm +15 -0
  10. package/ios/Helpers.swift +29 -1
  11. package/ios/MemoryEstimation.swift +83 -0
  12. package/ios/QuantityTypeModule.swift +34 -26
  13. package/ios/Serializers.swift +18 -3
  14. package/ios/SourceProxy.swift +14 -5
  15. package/ios/WorkoutProxy.swift +41 -12
  16. package/lib/commonjs/generated/healthkit.generated.js +13 -1
  17. package/lib/commonjs/healthkit.ios.js +3 -1
  18. package/lib/commonjs/healthkit.js +4 -2
  19. package/lib/module/generated/healthkit.generated.js +12 -0
  20. package/lib/module/healthkit.ios.js +2 -0
  21. package/lib/module/healthkit.js +2 -0
  22. package/lib/typescript/generated/healthkit.generated.d.ts +16 -3
  23. package/lib/typescript/healthkit.d.ts +1 -0
  24. package/lib/typescript/healthkit.ios.d.ts +2 -0
  25. package/lib/typescript/specs/CoreModule.nitro.d.ts +6 -4
  26. package/lib/typescript/specs/SourceProxy.nitro.d.ts +1 -2
  27. package/lib/typescript/types/QuantityType.d.ts +3 -3
  28. package/lib/typescript/types/Source.d.ts +2 -2
  29. package/lib/typescript/types/Workouts.d.ts +1 -0
  30. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +16 -16
  31. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +23 -12
  32. package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +7 -4
  33. package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +7 -4
  34. package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +7 -4
  35. package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +7 -4
  36. package/nitrogen/generated/ios/c++/HybridMedicationModuleSpecSwift.hpp +7 -4
  37. package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +7 -4
  38. package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +7 -4
  39. package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +3 -4
  40. package/nitrogen/generated/ios/c++/HybridWorkoutsModuleSpecSwift.hpp +6 -3
  41. package/nitrogen/generated/ios/swift/CategoryTypeIdentifier.swift +8 -0
  42. package/nitrogen/generated/ios/swift/CategoryTypeIdentifierWriteable.swift +8 -0
  43. package/nitrogen/generated/ios/swift/ObjectTypeIdentifier.swift +8 -0
  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 -0
  47. package/nitrogen/generated/ios/swift/SampleTypeIdentifierWriteable.swift +8 -0
  48. package/nitrogen/generated/ios/swift/SourceRevision.swift +4 -11
  49. package/nitrogen/generated/ios/swift/WorkoutActivity.swift +7 -2
  50. package/nitrogen/generated/ios/swift/WorkoutActivityType.swift +8 -0
  51. package/nitrogen/generated/shared/c++/CategoryTypeIdentifier.hpp +67 -59
  52. package/nitrogen/generated/shared/c++/CategoryTypeIdentifierWriteable.hpp +67 -59
  53. package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +202 -194
  54. package/nitrogen/generated/shared/c++/QueryStatisticsResponse.hpp +8 -9
  55. package/nitrogen/generated/shared/c++/QueryStatisticsResponseFromSingleSource.hpp +8 -9
  56. package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +195 -187
  57. package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +189 -181
  58. package/nitrogen/generated/shared/c++/SourceRevision.hpp +8 -9
  59. package/nitrogen/generated/shared/c++/WorkoutActivity.hpp +9 -3
  60. package/nitrogen/generated/shared/c++/WorkoutActivityType.hpp +4 -0
  61. package/package.json +5 -3
  62. package/src/generated/healthkit-schema.json +50 -5
  63. package/src/generated/healthkit.generated.ts +18 -2
  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 +36 -0
  69. package/src/types/QuantityType.ts +3 -3
  70. package/src/types/Source.ts +2 -2
  71. package/src/types/Workouts.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "14.0.2",
3
+ "version": "15.1.0",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -58,13 +58,15 @@
58
58
  "build:cjs": "tsc -p tsconfig.cjs.json",
59
59
  "build:esm": "tsc -p tsconfig.esm.json",
60
60
  "build:types": "tsc -p tsconfig.declarations.json",
61
- "build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types",
61
+ "build": "bun run clean && bun run build:cjs && bun run build:esm && bun run build:types && bun run build:plugin",
62
+ "build:plugin": "bun ../../scripts/build-app-plugin.ts",
62
63
  "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.type-tests.json",
63
64
  "lint": "bunx @biomejs/biome format --write",
64
65
  "check:generated": "bun run generate:healthkit && bun run verify:healthkit-sdk && git diff --exit-code -- src/generated/healthkit.generated.ts src/generated/healthkit-schema.json ../../apps/example/contracts/generated ios/generated",
65
66
  "codegen": "bun run build && nitrogen --logLevel=\"debug\" && perl -i -pe 's/Bool\\(fromCxx: cachedCxxPart\\)/cachedCxxPart.use_count() > 0/g' nitrogen/generated/ios/swift/*Spec_cxx.swift",
66
67
  "test": "bun test",
67
- "prepublishOnly": "bun run build && bun run codegen"
68
+ "prepublishOnly": "bun run build && bun run codegen",
69
+ "prepack": "test -f app.plugin.js || { echo \"app.plugin.js is missing; run bun run build:plugin (it is generated, not committed)\" >&2; exit 1; }"
68
70
  },
69
71
  "keywords": [
70
72
  "react-native",
@@ -156,7 +156,7 @@
156
156
  "name": "HKQuantityTypeIdentifierCyclingCadence",
157
157
  "ios": "17.0",
158
158
  "canonicalUnit": "count/min",
159
- "aggregationStyle": "Discrete (Arithmetic)",
159
+ "aggregationStyle": "Discrete (Temporally Weighted)",
160
160
  "writeable": true,
161
161
  "legacy": false
162
162
  },
@@ -172,7 +172,7 @@
172
172
  "name": "HKQuantityTypeIdentifierCyclingPower",
173
173
  "ios": "17.0",
174
174
  "canonicalUnit": "W",
175
- "aggregationStyle": "Discrete (Arithmetic)",
175
+ "aggregationStyle": "Discrete (Temporally Weighted)",
176
176
  "writeable": true,
177
177
  "legacy": false
178
178
  },
@@ -180,7 +180,7 @@
180
180
  "name": "HKQuantityTypeIdentifierCyclingSpeed",
181
181
  "ios": "17.0",
182
182
  "canonicalUnit": "m/s",
183
- "aggregationStyle": "Discrete (Arithmetic)",
183
+ "aggregationStyle": "Discrete (Temporally Weighted)",
184
184
  "writeable": true,
185
185
  "legacy": false
186
186
  },
@@ -772,7 +772,7 @@
772
772
  "name": "HKQuantityTypeIdentifierRestingHeartRate",
773
773
  "ios": "11.0",
774
774
  "canonicalUnit": "count/min",
775
- "aggregationStyle": "Discrete (Arithmetic)",
775
+ "aggregationStyle": "Discrete (Temporally Weighted)",
776
776
  "writeable": true,
777
777
  "legacy": false
778
778
  },
@@ -924,7 +924,7 @@
924
924
  "name": "HKQuantityTypeIdentifierWalkingHeartRateAverage",
925
925
  "ios": "11.0",
926
926
  "canonicalUnit": "count/min",
927
- "aggregationStyle": "Discrete (Arithmetic)",
927
+ "aggregationStyle": "Discrete (Temporally Weighted)",
928
928
  "writeable": false,
929
929
  "legacy": false
930
930
  },
@@ -1011,6 +1011,13 @@
1011
1011
  "writeable": true,
1012
1012
  "legacy": false
1013
1013
  },
1014
+ {
1015
+ "name": "HKCategoryTypeIdentifierBleedingAfterMenopause",
1016
+ "ios": "27.0",
1017
+ "valueEnum": "HKCategoryValueVaginalBleeding",
1018
+ "writeable": true,
1019
+ "legacy": false
1020
+ },
1014
1021
  {
1015
1022
  "name": "HKCategoryTypeIdentifierBleedingAfterPregnancy",
1016
1023
  "ios": "18.0",
@@ -1270,6 +1277,13 @@
1270
1277
  "writeable": true,
1271
1278
  "legacy": false
1272
1279
  },
1280
+ {
1281
+ "name": "HKCategoryTypeIdentifierMenopausalState",
1282
+ "ios": "27.0",
1283
+ "valueEnum": "HKCategoryValueMenopausalState",
1284
+ "writeable": true,
1285
+ "legacy": false
1286
+ },
1273
1287
  {
1274
1288
  "name": "HKCategoryTypeIdentifierMenstrualFlow",
1275
1289
  "ios": "9.0",
@@ -1747,6 +1761,27 @@
1747
1761
  }
1748
1762
  ]
1749
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
+ },
1750
1785
  {
1751
1786
  "name": "CategoryValueMenstrualFlow",
1752
1787
  "ios": "9.0",
@@ -2806,6 +2841,16 @@
2806
2841
  "swiftName": "HKWorkoutActivityTypeUnderwaterDiving",
2807
2842
  "rawValue": 84
2808
2843
  },
2844
+ {
2845
+ "name": "rest",
2846
+ "swiftName": "HKWorkoutActivityTypeRest",
2847
+ "rawValue": 2998
2848
+ },
2849
+ {
2850
+ "name": "group",
2851
+ "swiftName": "HKWorkoutActivityTypeGroup",
2852
+ "rawValue": 2999
2853
+ },
2809
2854
  {
2810
2855
  "name": "other",
2811
2856
  "swiftName": "HKWorkoutActivityTypeOther",
@@ -153,6 +153,7 @@ export type CategoryTypeIdentifierWriteable =
153
153
  | 'HKCategoryTypeIdentifierAppleWalkingSteadinessEvent'
154
154
  | 'HKCategoryTypeIdentifierAudioExposureEvent'
155
155
  | 'HKCategoryTypeIdentifierBladderIncontinence'
156
+ | 'HKCategoryTypeIdentifierBleedingAfterMenopause'
156
157
  | 'HKCategoryTypeIdentifierBleedingAfterPregnancy'
157
158
  | 'HKCategoryTypeIdentifierBleedingDuringPregnancy'
158
159
  | 'HKCategoryTypeIdentifierBloating'
@@ -186,6 +187,7 @@ export type CategoryTypeIdentifierWriteable =
186
187
  | 'HKCategoryTypeIdentifierLowCardioFitnessEvent'
187
188
  | 'HKCategoryTypeIdentifierLowerBackPain'
188
189
  | 'HKCategoryTypeIdentifierMemoryLapse'
190
+ | 'HKCategoryTypeIdentifierMenopausalState'
189
191
  | 'HKCategoryTypeIdentifierMenstrualFlow'
190
192
  | 'HKCategoryTypeIdentifierMindfulSession'
191
193
  | 'HKCategoryTypeIdentifierMoodChanges'
@@ -345,6 +347,7 @@ export const CATEGORY_IDENTIFIER_IOS_AVAILABILITY = {
345
347
  HKCategoryTypeIdentifierAppleWalkingSteadinessEvent: '15.0',
346
348
  HKCategoryTypeIdentifierAudioExposureEvent: '13.0',
347
349
  HKCategoryTypeIdentifierBladderIncontinence: '14.0',
350
+ HKCategoryTypeIdentifierBleedingAfterMenopause: '27.0',
348
351
  HKCategoryTypeIdentifierBleedingAfterPregnancy: '18.0',
349
352
  HKCategoryTypeIdentifierBleedingDuringPregnancy: '18.0',
350
353
  HKCategoryTypeIdentifierBloating: '13.6',
@@ -382,6 +385,7 @@ export const CATEGORY_IDENTIFIER_IOS_AVAILABILITY = {
382
385
  HKCategoryTypeIdentifierLowerBackPain: '13.6',
383
386
  HKCategoryTypeIdentifierLowHeartRateEvent: '12.2',
384
387
  HKCategoryTypeIdentifierMemoryLapse: '14.0',
388
+ HKCategoryTypeIdentifierMenopausalState: '27.0',
385
389
  HKCategoryTypeIdentifierMenstrualFlow: '9.0',
386
390
  HKCategoryTypeIdentifierMindfulSession: '10.0',
387
391
  HKCategoryTypeIdentifierMoodChanges: '13.6',
@@ -540,6 +544,8 @@ export const CATEGORY_IDENTIFIER_VALUE_ENUMS = {
540
544
  'CategoryValueAppleWalkingSteadinessEvent',
541
545
  HKCategoryTypeIdentifierAudioExposureEvent: null,
542
546
  HKCategoryTypeIdentifierBladderIncontinence: 'CategoryValueSeverity',
547
+ HKCategoryTypeIdentifierBleedingAfterMenopause:
548
+ 'CategoryValueVaginalBleeding',
543
549
  HKCategoryTypeIdentifierBleedingAfterPregnancy:
544
550
  'CategoryValueVaginalBleeding',
545
551
  HKCategoryTypeIdentifierBleedingDuringPregnancy:
@@ -583,6 +589,7 @@ export const CATEGORY_IDENTIFIER_VALUE_ENUMS = {
583
589
  HKCategoryTypeIdentifierLowerBackPain: 'CategoryValueSeverity',
584
590
  HKCategoryTypeIdentifierLowHeartRateEvent: 'CategoryValue',
585
591
  HKCategoryTypeIdentifierMemoryLapse: 'CategoryValueSeverity',
592
+ HKCategoryTypeIdentifierMenopausalState: 'CategoryValueMenopausalState',
586
593
  HKCategoryTypeIdentifierMenstrualFlow: 'CategoryValueMenstrualFlow',
587
594
  HKCategoryTypeIdentifierMindfulSession: 'CategoryValue',
588
595
  HKCategoryTypeIdentifierMoodChanges: 'CategoryValuePresence',
@@ -683,6 +690,11 @@ export enum CategoryValueHeadphoneAudioExposureEvent {
683
690
  export enum CategoryValueLowCardioFitnessEvent {
684
691
  lowFitness = 1,
685
692
  }
693
+ export enum CategoryValueMenopausalState {
694
+ menopause = 1,
695
+ perimenopause = 2,
696
+ none = 3,
697
+ }
686
698
  export enum CategoryValueMenstrualFlow {
687
699
  unspecified = 1,
688
700
  light = 2,
@@ -911,6 +923,8 @@ export enum WorkoutActivityType {
911
923
  swimBikeRun = 82,
912
924
  transition = 83,
913
925
  underwaterDiving = 84,
926
+ rest = 2998,
927
+ group = 2999,
914
928
  other = 3000,
915
929
  }
916
930
  export enum WorkoutEventType {
@@ -935,6 +949,7 @@ export interface CategoryValueByIdentifierMap {
935
949
  readonly HKCategoryTypeIdentifierAppleStandHour: CategoryValueAppleStandHour
936
950
  readonly HKCategoryTypeIdentifierAppleWalkingSteadinessEvent: CategoryValueAppleWalkingSteadinessEvent
937
951
  readonly HKCategoryTypeIdentifierBladderIncontinence: CategoryValueSeverity
952
+ readonly HKCategoryTypeIdentifierBleedingAfterMenopause: CategoryValueVaginalBleeding
938
953
  readonly HKCategoryTypeIdentifierBleedingAfterPregnancy: CategoryValueVaginalBleeding
939
954
  readonly HKCategoryTypeIdentifierBleedingDuringPregnancy: CategoryValueVaginalBleeding
940
955
  readonly HKCategoryTypeIdentifierBloating: CategoryValueSeverity
@@ -972,6 +987,7 @@ export interface CategoryValueByIdentifierMap {
972
987
  readonly HKCategoryTypeIdentifierLowerBackPain: CategoryValueSeverity
973
988
  readonly HKCategoryTypeIdentifierLowHeartRateEvent: CategoryValue
974
989
  readonly HKCategoryTypeIdentifierMemoryLapse: CategoryValueSeverity
990
+ readonly HKCategoryTypeIdentifierMenopausalState: CategoryValueMenopausalState
975
991
  readonly HKCategoryTypeIdentifierMenstrualFlow: CategoryValueMenstrualFlow
976
992
  readonly HKCategoryTypeIdentifierMindfulSession: CategoryValue
977
993
  readonly HKCategoryTypeIdentifierMoodChanges: CategoryValuePresence
@@ -1125,7 +1141,7 @@ export type CategoryTypedMetadataForIdentifierGenerated<
1125
1141
  > = KnownSampleMetadata &
1126
1142
  (T extends keyof CategorySpecificMetadataByIdentifierMap
1127
1143
  ? CategorySpecificMetadataByIdentifierMap[T]
1128
- : Record<string, never>)
1144
+ : unknown)
1129
1145
  export interface QuantitySpecificMetadataByIdentifierMap {
1130
1146
  readonly HKQuantityTypeIdentifierBasalBodyTemperature: Pick<
1131
1147
  QuantityTypedMetadata,
@@ -1165,7 +1181,7 @@ export type QuantityTypedMetadataForIdentifierGenerated<
1165
1181
  > &
1166
1182
  (T extends keyof QuantitySpecificMetadataByIdentifierMap
1167
1183
  ? QuantitySpecificMetadataByIdentifierMap[T]
1168
- : Record<string, never>)
1184
+ : unknown)
1169
1185
  export interface QuantityUnitByIdentifierMap {
1170
1186
  readonly HKQuantityTypeIdentifierActiveEnergyBurned: EnergyUnit
1171
1187
  readonly HKQuantityTypeIdentifierAppleExerciseTime: TimeUnit
@@ -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,13 +7,18 @@ import type {
7
7
  CategoryValueSleepAnalysis,
8
8
  CorrelationSampleTyped,
9
9
  HeartRateMotionContext,
10
+ InsulinDeliveryReason,
11
+ MetadataForQuantityIdentifier,
10
12
  Quantity,
11
13
  QuantitySampleTyped,
14
+ QuantityTypeIdentifier,
15
+ QuantityTypeIdentifierWriteable,
12
16
  QueryOptionsWithAnchorAndUnit,
13
17
  QueryOptionsWithSortOrderAndUnit,
14
18
  StateOfMindSampleTyped,
15
19
  StatisticsQueryOptions,
16
20
  SwimmingStrokeStyle,
21
+ UnitForIdentifier,
17
22
  WorkoutEventTyped,
18
23
  WorkoutSampleTyped,
19
24
  } from '../types'
@@ -25,6 +30,13 @@ type Equal<A, B> =
25
30
 
26
31
  type Assert<T extends true> = T
27
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
+
28
40
  type _sleepAnalysisValuesAreTyped = Assert<
29
41
  Equal<
30
42
  CategoryValueForIdentifier<'HKCategoryTypeIdentifierSleepAnalysis'>,
@@ -38,6 +50,13 @@ type _newCategoryIdentifierFromSdkIsPresent = Assert<
38
50
  : false
39
51
  >
40
52
 
53
+ // Apple has never shipped a blood ketones quantity type (see issue #379).
54
+ type _bloodKetonesIdentifierIsAbsent = Assert<
55
+ 'HKQuantityTypeIdentifierBloodKetones' extends QuantityTypeIdentifier
56
+ ? false
57
+ : true
58
+ >
59
+
41
60
  type _heartRateMetadataNarrowsToEnum = Assert<
42
61
  Equal<
43
62
  QuantitySampleTyped<'HKQuantityTypeIdentifierHeartRate'>['metadata']['HKHeartRateMotionContext'],
@@ -80,6 +99,23 @@ type _bloodGlucoseUnitNarrows = Assert<
80
99
  >
81
100
  >
82
101
 
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
+ }
117
+ >
118
+
83
119
  type _quantityQueryOptionsUnitNarrows = Assert<
84
120
  Equal<
85
121
  QueryOptionsWithSortOrderAndUnit<BloodGlucoseUnit>['unit'],
@@ -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
@@ -36,6 +36,7 @@ export interface WorkoutActivity {
36
36
  readonly endDate: Date
37
37
  readonly uuid: string
38
38
  readonly duration: number
39
+ readonly activityType: WorkoutActivityType
39
40
  }
40
41
 
41
42
  export interface WorkoutRoute {