@kingstinct/react-native-healthkit 15.1.0 → 16.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.
Files changed (107) hide show
  1. package/README.md +5 -1
  2. package/ReactNativeHealthkit.podspec +11 -7
  3. package/app.plugin.js +18 -34
  4. package/app.plugin.ts +25 -50
  5. package/ios/CategoryTypeModule.swift +1 -0
  6. package/ios/CharacteristicTypeModule.swift +7 -6
  7. package/ios/Constants.swift +9 -34
  8. package/ios/CoreModule.swift +72 -41
  9. package/ios/CorrelationTypeModule.swift +3 -2
  10. package/ios/ElectrocardiogramModule.swift +4 -3
  11. package/ios/HeartbeatSeriesModule.swift +4 -3
  12. package/ios/Helpers.swift +10 -243
  13. package/ios/MedicationModule.swift +9 -8
  14. package/ios/MemoryEstimation.swift +1 -0
  15. package/ios/PredicateHelpers.swift +16 -86
  16. package/ios/QuantityTypeModule.swift +3 -2
  17. package/ios/Serializers.swift +16 -67
  18. package/ios/SourceProxy.swift +1 -0
  19. package/ios/StateOfMindModule.swift +3 -2
  20. package/ios/WorkoutProxy.swift +3 -2
  21. package/ios/WorkoutsModule.swift +4 -3
  22. package/lib/commonjs/generated/healthkit.generated.js +2 -0
  23. package/lib/commonjs/healthkit.ios.js +4 -2
  24. package/lib/commonjs/healthkit.js +21 -78
  25. package/lib/commonjs/types/Auth.js +3 -18
  26. package/lib/commonjs/types/Background.js +2 -10
  27. package/lib/commonjs/types/QueryOptions.js +2 -17
  28. package/lib/module/generated/healthkit.generated.js +2 -0
  29. package/lib/module/healthkit.ios.js +2 -0
  30. package/lib/module/healthkit.js +20 -77
  31. package/lib/module/types/Auth.js +1 -18
  32. package/lib/module/types/Background.js +1 -10
  33. package/lib/module/types/QueryOptions.js +1 -17
  34. package/lib/typescript/generated/healthkit.generated.d.ts +4 -1
  35. package/lib/typescript/healthkit.d.ts +3 -2
  36. package/lib/typescript/healthkit.ios.d.ts +11 -9
  37. package/lib/typescript/specs/CoreModule.nitro.d.ts +16 -0
  38. package/lib/typescript/specs/SourceProxy.nitro.d.ts +2 -4
  39. package/lib/typescript/types/Auth.d.ts +1 -16
  40. package/lib/typescript/types/Background.d.ts +1 -9
  41. package/lib/typescript/types/Device.d.ts +1 -13
  42. package/lib/typescript/types/QuantityType.d.ts +1 -1
  43. package/lib/typescript/types/QueryOptions.d.ts +3 -37
  44. package/lib/typescript/types/Shared.d.ts +2 -25
  45. package/lib/typescript/types/Source.d.ts +1 -10
  46. package/lib/typescript/types/Subscriptions.d.ts +2 -3
  47. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +8 -0
  48. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +68 -0
  49. package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +1 -1
  50. package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +8 -0
  51. package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +1 -1
  52. package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +1 -1
  53. package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +1 -1
  54. package/nitrogen/generated/ios/c++/HybridMedicationModuleSpecSwift.hpp +1 -1
  55. package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +1 -1
  56. package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +1 -1
  57. package/nitrogen/generated/ios/swift/CategorySample.swift +8 -8
  58. package/nitrogen/generated/ios/swift/CorrelationSample.swift +8 -8
  59. package/nitrogen/generated/ios/swift/ElectrocardiogramSample.swift +8 -8
  60. package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__std__chrono__system_clock__time_point_.swift +54 -0
  61. package/nitrogen/generated/ios/swift/HeartbeatSeriesSample.swift +8 -8
  62. package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +1 -0
  63. package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +25 -0
  64. package/nitrogen/generated/ios/swift/MedicationDoseEvent.swift +8 -8
  65. package/nitrogen/generated/ios/swift/ObjectTypeIdentifier.swift +4 -0
  66. package/nitrogen/generated/ios/swift/QuantitySample.swift +8 -8
  67. package/nitrogen/generated/ios/swift/QuantityTypeIdentifier.swift +4 -0
  68. package/nitrogen/generated/ios/swift/QuantityTypeIdentifierWriteable.swift +4 -0
  69. package/nitrogen/generated/ios/swift/SampleTypeIdentifier.swift +4 -0
  70. package/nitrogen/generated/ios/swift/SampleTypeIdentifierWriteable.swift +4 -0
  71. package/nitrogen/generated/ios/swift/StateOfMindSample.swift +8 -8
  72. package/nitrogen/generated/shared/c++/CategorySample.hpp +7 -7
  73. package/nitrogen/generated/shared/c++/CorrelationSample.hpp +7 -7
  74. package/nitrogen/generated/shared/c++/ElectrocardiogramSample.hpp +7 -7
  75. package/nitrogen/generated/shared/c++/HeartbeatSeriesSample.hpp +7 -7
  76. package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.cpp +1 -0
  77. package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +3 -1
  78. package/nitrogen/generated/shared/c++/MedicationDoseEvent.hpp +7 -7
  79. package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +49 -45
  80. package/nitrogen/generated/shared/c++/QuantitySample.hpp +7 -7
  81. package/nitrogen/generated/shared/c++/QuantityTypeIdentifier.hpp +42 -38
  82. package/nitrogen/generated/shared/c++/QuantityTypeIdentifierWriteable.hpp +42 -38
  83. package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +48 -44
  84. package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +47 -43
  85. package/nitrogen/generated/shared/c++/StateOfMindSample.hpp +7 -7
  86. package/package.json +4 -1
  87. package/src/generated/healthkit-schema.json +8 -0
  88. package/src/generated/healthkit.generated.ts +4 -0
  89. package/src/healthkit.ios.ts +3 -0
  90. package/src/healthkit.ts +27 -84
  91. package/src/specs/CoreModule.nitro.ts +19 -0
  92. package/src/specs/SourceProxy.nitro.ts +2 -4
  93. package/src/test-setup.ts +1 -0
  94. package/src/types/Auth.ts +4 -17
  95. package/src/types/Background.ts +1 -9
  96. package/src/types/Device.ts +1 -13
  97. package/src/types/QuantityType.ts +1 -1
  98. package/src/types/QueryOptions.ts +7 -65
  99. package/src/types/Shared.ts +7 -28
  100. package/src/types/Source.ts +1 -11
  101. package/src/types/Subscriptions.ts +2 -3
  102. package/ios/BackgroundDeliveryManager.swift +0 -284
  103. package/ios/BackgroundLaunchHook.mm +0 -41
  104. package/ios/Bridge.h +0 -10
  105. package/ios/ExceptionCatcher.h +0 -5
  106. package/ios/ExceptionCatcher.mm +0 -32
  107. package/ios/module.modulemap +0 -5
package/src/healthkit.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Platform } from 'react-native'
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 notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${Platform.OS}" not supported. HealthKit is only available on iOS.`
56
-
57
- let hasWarned = false
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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
- if (Platform.OS !== 'ios' && !hasWarned) {
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 interface Source {
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
- * @see {@link https://developer.apple.com/documentation/healthkit/hkauthorizationrequeststatus Apple Docs }
3
- */
4
- export enum AuthorizationRequestStatus {
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'
@@ -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'
@@ -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 enum ComparisonPredicateOperator {
5
- lessThan = 0,
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
@@ -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 interface DeletedSample {
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
- }
@@ -1,11 +1 @@
1
- import type { Source } from '../specs/SourceProxy.nitro'
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 interface EmitterSubscription {
8
- remove: () => void
9
- }
8
+ export type { EmitterSubscription }
10
9
 
11
10
  export interface OnChangeCallbackArgs {
12
11
  readonly typeIdentifier: SampleTypeIdentifier