@kingstinct/react-native-healthkit 13.0.2 → 13.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 (50) hide show
  1. package/ios/Bridge.h +2 -0
  2. package/ios/CharacteristicTypeModule.swift +6 -10
  3. package/ios/CoreModule.swift +16 -2
  4. package/ios/ElectrocardiogramModule.swift +0 -1
  5. package/ios/ExceptionCatcher.h +1 -14
  6. package/ios/ExceptionCatcher.mm +17 -0
  7. package/ios/HeartbeatSeriesModule.swift +0 -1
  8. package/ios/Helpers.swift +40 -25
  9. package/ios/QuantityTypeModule.swift +35 -42
  10. package/ios/Serializers.swift +11 -28
  11. package/ios/WorkoutProxy.swift +5 -7
  12. package/ios/WorkoutsModule.swift +12 -14
  13. package/lib/commonjs/healthkit.ios.js +4 -2
  14. package/lib/commonjs/healthkit.js +3 -1
  15. package/lib/commonjs/types/Constants.js +12 -1
  16. package/lib/commonjs/types/Shared.js +0 -11
  17. package/lib/module/healthkit.ios.js +2 -0
  18. package/lib/module/healthkit.js +2 -0
  19. package/lib/module/types/Constants.js +11 -0
  20. package/lib/module/types/Shared.js +1 -10
  21. package/lib/typescript/healthkit.d.ts +2 -1
  22. package/lib/typescript/healthkit.ios.d.ts +4 -2
  23. package/lib/typescript/specs/CoreModule.nitro.d.ts +3 -2
  24. package/lib/typescript/specs/MedicationModule.nitro.d.ts +3 -0
  25. package/lib/typescript/types/Constants.d.ts +11 -0
  26. package/lib/typescript/types/Shared.d.ts +2 -11
  27. package/lib/typescript/types/Source.d.ts +2 -2
  28. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +8 -0
  29. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +43 -15
  30. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +3 -0
  31. package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +12 -1
  32. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  33. package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +2 -1
  34. package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +20 -1
  35. package/nitrogen/generated/ios/swift/ObjectTypeIdentifier.swift +4 -4
  36. package/nitrogen/generated/ios/swift/PerObjectTypeIdentifier.swift +40 -0
  37. package/nitrogen/generated/ios/swift/SourceRevision.swift +16 -54
  38. package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.cpp +1 -0
  39. package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +8 -1
  40. package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +4 -4
  41. package/nitrogen/generated/shared/c++/PerObjectTypeIdentifier.hpp +76 -0
  42. package/nitrogen/generated/shared/c++/SourceRevision.hpp +10 -10
  43. package/package.json +1 -1
  44. package/src/healthkit.ios.ts +3 -0
  45. package/src/healthkit.ts +6 -0
  46. package/src/specs/CoreModule.nitro.ts +6 -1
  47. package/src/specs/MedicationModule.nitro.ts +3 -0
  48. package/src/types/Constants.ts +16 -0
  49. package/src/types/Shared.ts +8 -13
  50. package/src/types/Source.ts +2 -2
@@ -38,6 +38,7 @@ export type AvailableQuantityTypesIOS17Plus = QuantityTypeIdentifier;
38
38
  */
39
39
  export type AvailableQuantityTypes<T extends number = typeof currentMajorVersionIOS> = T extends 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 ? AvailableQuantityTypesIOS17Plus : AvailableQuantityTypesBeforeIOS17;
40
40
  export declare const authorizationStatusFor: (type: import("./types").ObjectTypeIdentifier) => import("./types").AuthorizationStatus;
41
+ export declare const requestPerObjectReadAuthorization: (typeIdentifier: import("./types").PerObjectTypeIdentifier) => Promise<void>;
41
42
  export declare const disableAllBackgroundDelivery: () => Promise<boolean>;
42
43
  export declare const disableBackgroundDelivery: (typeIdentifier: import("./types").ObjectTypeIdentifier) => Promise<boolean>;
43
44
  export declare const enableBackgroundDelivery: (typeIdentifier: import("./types").ObjectTypeIdentifier, updateFrequency: import("./types").UpdateFrequency) => Promise<boolean>;
@@ -68,7 +69,7 @@ export declare const queryWorkoutSamples: (options: import("./types").WorkoutQue
68
69
  export declare const queryWorkoutSamplesWithAnchor: (options: import("./types").WorkoutQueryOptionsWithAnchor) => Promise<import("./types").QueryWorkoutSamplesWithAnchorResponse>;
69
70
  export declare const querySources: (identifier: import("./types").SampleTypeIdentifier, filter?: import("./types").FilterForSamples) => Promise<readonly import("./specs/SourceProxy.nitro").SourceProxy[]>;
70
71
  export declare const requestAuthorization: (toRequest: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<boolean>;
71
- export declare const deleteObjects: (objectTypeIdentifier: import("./types").ObjectTypeIdentifier, filter: import("./types").FilterForSamples) => Promise<number>;
72
+ export declare const deleteObjects: (objectTypeIdentifier: import("./types").SampleTypeIdentifierWriteable, filter: import("./types").FilterForSamples) => Promise<number>;
72
73
  export declare const saveCategorySample: <T extends import("./types").CategoryTypeIdentifier>(identifier: T, value: import("./types").CategoryValueForIdentifier, startDate: Date, endDate: Date, metadata?: import("./types").MetadataForCategoryIdentifier<T>) => Promise<import("./types").CategorySample | undefined>;
73
74
  export declare const saveCorrelationSample: (typeIdentifier: import("./types").CorrelationTypeIdentifier, samples: import("./types").SampleForSaving[], start: Date, end: Date, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<import("./types").CorrelationSample | undefined>;
74
75
  export declare const saveQuantitySample: (identifier: QuantityTypeIdentifier, unit: string, value: number, start: Date, end: Date, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<import("./types").QuantitySample | undefined>;
@@ -139,7 +140,8 @@ declare const _default: {
139
140
  queryWorkoutSamplesWithAnchor: (options: import("./types").WorkoutQueryOptionsWithAnchor) => Promise<import("./types").QueryWorkoutSamplesWithAnchorResponse>;
140
141
  querySources: (identifier: import("./types").SampleTypeIdentifier, filter?: import("./types").FilterForSamples) => Promise<readonly import("./specs/SourceProxy.nitro").SourceProxy[]>;
141
142
  requestAuthorization: (toRequest: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<boolean>;
142
- deleteObjects: (objectTypeIdentifier: import("./types").ObjectTypeIdentifier, filter: import("./types").FilterForSamples) => Promise<number>;
143
+ requestPerObjectReadAuthorization: (typeIdentifier: import("./types").PerObjectTypeIdentifier) => Promise<void>;
144
+ deleteObjects: (objectTypeIdentifier: import("./types").SampleTypeIdentifierWriteable, filter: import("./types").FilterForSamples) => Promise<number>;
143
145
  saveCategorySample: <T extends import("./types").CategoryTypeIdentifier>(identifier: T, value: import("./types").CategoryValueForIdentifier, startDate: Date, endDate: Date, metadata?: import("./types").MetadataForCategoryIdentifier<T>) => Promise<import("./types").CategorySample | undefined>;
144
146
  saveCorrelationSample: (typeIdentifier: import("./types").CorrelationTypeIdentifier, samples: import("./types").SampleForSaving[], start: Date, end: Date, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<import("./types").CorrelationSample | undefined>;
145
147
  saveQuantitySample: (identifier: QuantityTypeIdentifier, unit: string, value: number, start: Date, end: Date, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<import("./types").QuantitySample | undefined>;
@@ -3,7 +3,7 @@ import type { AuthorizationRequestStatus, AuthorizationStatus } from '../types/A
3
3
  import type { UpdateFrequency } from '../types/Background';
4
4
  import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier';
5
5
  import type { FilterForSamples } from '../types/QueryOptions';
6
- import type { ObjectTypeIdentifier, SampleTypeIdentifier, SampleTypeIdentifierWriteable } from '../types/Shared';
6
+ import type { ObjectTypeIdentifier, PerObjectTypeIdentifier, SampleTypeIdentifier, SampleTypeIdentifierWriteable } from '../types/Shared';
7
7
  import type { OnChangeCallbackArgs } from '../types/Subscriptions';
8
8
  import type { IdentifierWithUnit } from '../types/Units';
9
9
  import type { SourceProxy } from './SourceProxy.nitro';
@@ -58,7 +58,8 @@ export interface CoreModule extends HybridObject<{
58
58
  * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
59
59
  */
60
60
  requestAuthorization(toRequest: AuthDataTypes): Promise<boolean>;
61
- deleteObjects(objectTypeIdentifier: ObjectTypeIdentifier, filter: FilterForSamples): Promise<number>;
61
+ requestPerObjectReadAuthorization(typeIdentifier: PerObjectTypeIdentifier): Promise<void>;
62
+ deleteObjects(objectTypeIdentifier: SampleTypeIdentifierWriteable, filter: FilterForSamples): Promise<number>;
62
63
  isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier): boolean;
63
64
  areObjectTypesAvailable(objectTypeIdentifiers: readonly ObjectTypeIdentifier[]): Record<string, boolean>;
64
65
  areObjectTypesAvailableAsync(objectTypeIdentifiers: ObjectTypeIdentifier[]): Promise<Record<string, boolean>>;
@@ -49,6 +49,9 @@ export interface MedicationModule extends HybridObject<{
49
49
  ios: 'swift';
50
50
  }> {
51
51
  queryMedications(): Promise<readonly UserAnnotatedMedication[]>;
52
+ /**
53
+ * @deprecated Use requestPerObjectReadAuthorization instead.
54
+ */
52
55
  requestMedicationsAuthorization(): Promise<boolean>;
53
56
  queryMedicationEvents(options: QueryOptionsWithSortOrder): Promise<readonly MedicationDoseEvent[]>;
54
57
  queryMedicationEventsWithAnchor(options: QueryOptionsWithAnchor): Promise<MedicationDoseEventsWithAnchorResponse>;
@@ -24,3 +24,14 @@ export declare const HeartbeatSeriesTypeIdentifier: "HKDataTypeIdentifierHeartbe
24
24
  */
25
25
  export declare const ElectrocardiogramTypeIdentifier: "HKElectrocardiogramType";
26
26
  export declare const UserAnnotatedMedicationTypeIdentifier = "HKUserAnnotatedMedicationTypeIdentifier";
27
+ /**
28
+ * Represents a type that identifies activity summary objects.
29
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummarytype Apple Docs HKActivitySummaryType}
30
+ */
31
+ export declare const ActivitySummaryTypeIdentifier: "HKActivitySummaryTypeIdentifier";
32
+ export declare const HKVisionPrescriptionTypeIdentifier: "HKVisionPrescriptionTypeIdentifier";
33
+ /**
34
+ * Represents an audiogram type identifier.
35
+ * @see {@link https://developer.apple.com/documentation/healthkit/HKAudiogramSampleType Apple Docs HKAudiogramSampleType}
36
+ */
37
+ export declare const AudiogramTypeIdentifier: "HKAudiogramSampleType";
@@ -1,7 +1,7 @@
1
1
  import type { AnyMap } from 'react-native-nitro-modules';
2
2
  import type { CategoryTypeIdentifier, CategoryTypeIdentifierWriteable } from './CategoryTypeIdentifier';
3
3
  import type { CharacteristicTypeIdentifier } from './Characteristics';
4
- import type { ElectrocardiogramTypeIdentifier, HeartbeatSeriesTypeIdentifier, StateOfMindTypeIdentifier, WorkoutRouteTypeIdentifier, WorkoutTypeIdentifier } from './Constants';
4
+ import type { ActivitySummaryTypeIdentifier, AudiogramTypeIdentifier, ElectrocardiogramTypeIdentifier, HeartbeatSeriesTypeIdentifier, HKVisionPrescriptionTypeIdentifier, StateOfMindTypeIdentifier, UserAnnotatedMedicationTypeIdentifier, WorkoutRouteTypeIdentifier, WorkoutTypeIdentifier } from './Constants';
5
5
  import type { CorrelationTypeIdentifier } from './CorrelationType';
6
6
  import type { Device } from './Device';
7
7
  import type { HeartRateMotionContext, InsulinDeliveryReason, Quantity } from './QuantityType';
@@ -13,6 +13,7 @@ export interface DeletedSample {
13
13
  readonly metadata?: AnyMap;
14
14
  }
15
15
  export type ObjectTypeIdentifier = CharacteristicTypeIdentifier | SampleTypeIdentifier | typeof ActivitySummaryTypeIdentifier;
16
+ export type PerObjectTypeIdentifier = typeof HKVisionPrescriptionTypeIdentifier | typeof UserAnnotatedMedicationTypeIdentifier;
16
17
  export type SampleTypeIdentifier = CategoryTypeIdentifier | CorrelationTypeIdentifier | QuantityTypeIdentifier | typeof StateOfMindTypeIdentifier | typeof AudiogramTypeIdentifier | typeof HeartbeatSeriesTypeIdentifier | typeof WorkoutRouteTypeIdentifier | typeof WorkoutTypeIdentifier | typeof ElectrocardiogramTypeIdentifier;
17
18
  export type SampleTypeIdentifierWriteable = CategoryTypeIdentifierWriteable | CorrelationTypeIdentifier | QuantityTypeIdentifierWriteable | typeof StateOfMindTypeIdentifier | typeof AudiogramTypeIdentifier | typeof HeartbeatSeriesTypeIdentifier | typeof WorkoutRouteTypeIdentifier | typeof WorkoutTypeIdentifier;
18
19
  export interface GenericMetadata {
@@ -31,16 +32,6 @@ export interface GenericMetadata {
31
32
  readonly HKReferenceRangeLowerLimit?: number;
32
33
  readonly HKReferenceRangeUpperLimit?: number;
33
34
  }
34
- /**
35
- * Represents a type that identifies activity summary objects.
36
- * @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummarytype Apple Docs HKActivitySummaryType}
37
- */
38
- export declare const ActivitySummaryTypeIdentifier: "ActivitySummaryTypeIdentifier";
39
- /**
40
- * Represents an audiogram type identifier.
41
- * @see {@link https://developer.apple.com/documentation/healthkit/HKAudiogramSampleType Apple Docs HKAudiogramSampleType}
42
- */
43
- export declare const AudiogramTypeIdentifier: "HKAudiogramSampleType";
44
35
  export interface BaseObject {
45
36
  readonly uuid: string;
46
37
  readonly sourceRevision: SourceRevision;
@@ -3,8 +3,8 @@ import type { SourceProxy } from '../specs/SourceProxy.nitro';
3
3
  * @see {@link https://developer.apple.com/documentation/healthkit/hkobject/1615483-sourcerevision Apple Docs }
4
4
  */
5
5
  export interface SourceRevision {
6
- readonly source?: SourceProxy;
6
+ readonly source: SourceProxy;
7
7
  readonly version?: string;
8
- readonly operatingSystemVersion?: string;
8
+ readonly operatingSystemVersion: string;
9
9
  readonly productType?: string;
10
10
  }
@@ -209,6 +209,14 @@ namespace margelo::nitro::healthkit::bridge::swift {
209
209
  };
210
210
  }
211
211
 
212
+ // pragma MARK: std::function<void()>
213
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
214
+ auto swiftClosure = ReactNativeHealthkit::Func_void::fromUnsafe(swiftClosureWrapper);
215
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
216
+ swiftClosure.call();
217
+ };
218
+ }
219
+
212
220
  // pragma MARK: std::function<void(const std::unordered_map<std::string, bool>& /* result */)>
213
221
  Func_void_std__unordered_map_std__string__bool_ create_Func_void_std__unordered_map_std__string__bool_(void* NON_NULL swiftClosureWrapper) noexcept {
214
222
  auto swiftClosure = ReactNativeHealthkit::Func_void_std__unordered_map_std__string__bool_::fromUnsafe(swiftClosureWrapper);
@@ -404,21 +404,6 @@ namespace margelo::nitro::healthkit::bridge::swift {
404
404
  using std__weak_ptr_HybridSourceProxySpec_ = std::weak_ptr<HybridSourceProxySpec>;
405
405
  inline std__weak_ptr_HybridSourceProxySpec_ weakify_std__shared_ptr_HybridSourceProxySpec_(const std::shared_ptr<HybridSourceProxySpec>& strong) noexcept { return strong; }
406
406
 
407
- // pragma MARK: std::optional<std::shared_ptr<HybridSourceProxySpec>>
408
- /**
409
- * Specialized version of `std::optional<std::shared_ptr<HybridSourceProxySpec>>`.
410
- */
411
- using std__optional_std__shared_ptr_HybridSourceProxySpec__ = std::optional<std::shared_ptr<HybridSourceProxySpec>>;
412
- inline std::optional<std::shared_ptr<HybridSourceProxySpec>> create_std__optional_std__shared_ptr_HybridSourceProxySpec__(const std::shared_ptr<HybridSourceProxySpec>& value) noexcept {
413
- return std::optional<std::shared_ptr<HybridSourceProxySpec>>(value);
414
- }
415
- inline bool has_value_std__optional_std__shared_ptr_HybridSourceProxySpec__(const std::optional<std::shared_ptr<HybridSourceProxySpec>>& optional) noexcept {
416
- return optional.has_value();
417
- }
418
- inline std::shared_ptr<HybridSourceProxySpec> get_std__optional_std__shared_ptr_HybridSourceProxySpec__(const std::optional<std::shared_ptr<HybridSourceProxySpec>>& optional) noexcept {
419
- return *optional;
420
- }
421
-
422
407
  // pragma MARK: std::optional<std::string>
423
408
  /**
424
409
  * Specialized version of `std::optional<std::string>`.
@@ -1468,6 +1453,40 @@ namespace margelo::nitro::healthkit::bridge::swift {
1468
1453
  return *optional;
1469
1454
  }
1470
1455
 
1456
+ // pragma MARK: std::shared_ptr<Promise<void>>
1457
+ /**
1458
+ * Specialized version of `std::shared_ptr<Promise<void>>`.
1459
+ */
1460
+ using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
1461
+ inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
1462
+ return Promise<void>::create();
1463
+ }
1464
+ inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
1465
+ return PromiseHolder<void>(std::move(promise));
1466
+ }
1467
+
1468
+ // pragma MARK: std::function<void()>
1469
+ /**
1470
+ * Specialized version of `std::function<void()>`.
1471
+ */
1472
+ using Func_void = std::function<void()>;
1473
+ /**
1474
+ * Wrapper class for a `std::function<void()>`, this can be used from Swift.
1475
+ */
1476
+ class Func_void_Wrapper final {
1477
+ public:
1478
+ explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
1479
+ inline void call() const noexcept {
1480
+ _function->operator()();
1481
+ }
1482
+ private:
1483
+ std::unique_ptr<std::function<void()>> _function;
1484
+ } SWIFT_NONCOPYABLE;
1485
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
1486
+ inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
1487
+ return Func_void_Wrapper(std::move(value));
1488
+ }
1489
+
1471
1490
  // pragma MARK: std::unordered_map<std::string, bool>
1472
1491
  /**
1473
1492
  * Specialized version of `std::unordered_map<std::string, bool>`.
@@ -1629,6 +1648,15 @@ namespace margelo::nitro::healthkit::bridge::swift {
1629
1648
  return Result<std::shared_ptr<Promise<AuthorizationRequestStatus>>>::withError(error);
1630
1649
  }
1631
1650
 
1651
+ // pragma MARK: Result<std::shared_ptr<Promise<void>>>
1652
+ using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
1653
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
1654
+ return Result<std::shared_ptr<Promise<void>>>::withValue(value);
1655
+ }
1656
+ inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
1657
+ return Result<std::shared_ptr<Promise<void>>>::withError(error);
1658
+ }
1659
+
1632
1660
  // pragma MARK: Result<std::unordered_map<std::string, bool>>
1633
1661
  using Result_std__unordered_map_std__string__bool__ = Result<std::unordered_map<std::string, bool>>;
1634
1662
  inline Result_std__unordered_map_std__string__bool__ create_Result_std__unordered_map_std__string__bool__(const std::unordered_map<std::string, bool>& value) noexcept {
@@ -122,6 +122,8 @@ namespace margelo::nitro::healthkit { struct MedicationDoseEventsWithAnchorRespo
122
122
  namespace margelo::nitro::healthkit { enum class ObjectTypeIdentifier; }
123
123
  // Forward declaration of `OnChangeCallbackArgs` to properly resolve imports.
124
124
  namespace margelo::nitro::healthkit { struct OnChangeCallbackArgs; }
125
+ // Forward declaration of `PerObjectTypeIdentifier` to properly resolve imports.
126
+ namespace margelo::nitro::healthkit { enum class PerObjectTypeIdentifier; }
125
127
  // Forward declaration of `PredicateWithMetadataKey` to properly resolve imports.
126
128
  namespace margelo::nitro::healthkit { struct PredicateWithMetadataKey; }
127
129
  // Forward declaration of `QuantityDateInterval` to properly resolve imports.
@@ -275,6 +277,7 @@ namespace margelo::nitro::healthkit { struct WorkoutTotals; }
275
277
  #include "MedicationDoseEventsWithAnchorResponse.hpp"
276
278
  #include "ObjectTypeIdentifier.hpp"
277
279
  #include "OnChangeCallbackArgs.hpp"
280
+ #include "PerObjectTypeIdentifier.hpp"
278
281
  #include "PredicateWithMetadataKey.hpp"
279
282
  #include "Quantity.hpp"
280
283
  #include "QuantityDateInterval.hpp"
@@ -46,6 +46,8 @@ namespace margelo::nitro::healthkit { enum class AuthorizationRequestStatus; }
46
46
  namespace margelo::nitro::healthkit { struct AuthDataTypes; }
47
47
  // Forward declaration of `SampleTypeIdentifierWriteable` to properly resolve imports.
48
48
  namespace margelo::nitro::healthkit { enum class SampleTypeIdentifierWriteable; }
49
+ // Forward declaration of `PerObjectTypeIdentifier` to properly resolve imports.
50
+ namespace margelo::nitro::healthkit { enum class PerObjectTypeIdentifier; }
49
51
 
50
52
  #include <NitroModules/Promise.hpp>
51
53
  #include "ObjectTypeIdentifier.hpp"
@@ -72,6 +74,7 @@ namespace margelo::nitro::healthkit { enum class SampleTypeIdentifierWriteable;
72
74
  #include "AuthorizationRequestStatus.hpp"
73
75
  #include "AuthDataTypes.hpp"
74
76
  #include "SampleTypeIdentifierWriteable.hpp"
77
+ #include "PerObjectTypeIdentifier.hpp"
75
78
  #include <unordered_map>
76
79
 
77
80
  #include "ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp"
@@ -262,7 +265,15 @@ namespace margelo::nitro::healthkit {
262
265
  auto __value = std::move(__result.value());
263
266
  return __value;
264
267
  }
265
- inline std::shared_ptr<Promise<double>> deleteObjects(ObjectTypeIdentifier objectTypeIdentifier, const FilterForSamples& filter) override {
268
+ inline std::shared_ptr<Promise<void>> requestPerObjectReadAuthorization(PerObjectTypeIdentifier typeIdentifier) override {
269
+ auto __result = _swiftPart.requestPerObjectReadAuthorization(static_cast<int>(typeIdentifier));
270
+ if (__result.hasError()) [[unlikely]] {
271
+ std::rethrow_exception(__result.error());
272
+ }
273
+ auto __value = std::move(__result.value());
274
+ return __value;
275
+ }
276
+ inline std::shared_ptr<Promise<double>> deleteObjects(SampleTypeIdentifierWriteable objectTypeIdentifier, const FilterForSamples& filter) override {
266
277
  auto __result = _swiftPart.deleteObjects(static_cast<int>(objectTypeIdentifier), std::forward<decltype(filter)>(filter));
267
278
  if (__result.hasError()) [[unlikely]] {
268
279
  std::rethrow_exception(__result.error());
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// Func_void.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Wraps a Swift `() -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void {
16
+ public typealias bridge = margelo.nitro.healthkit.bridge.swift
17
+
18
+ private let closure: () -> Void
19
+
20
+ public init(_ closure: @escaping () -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call() -> Void {
26
+ self.closure()
27
+ }
28
+
29
+ /**
30
+ * Casts this instance to a retained unsafe raw pointer.
31
+ * This acquires one additional strong reference on the object!
32
+ */
33
+ @inline(__always)
34
+ public func toUnsafe() -> UnsafeMutableRawPointer {
35
+ return Unmanaged.passRetained(self).toOpaque()
36
+ }
37
+
38
+ /**
39
+ * Casts an unsafe pointer to a `Func_void`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
41
+ * This removes one strong reference from the object!
42
+ */
43
+ @inline(__always)
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
45
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
46
+ }
47
+ }
@@ -32,7 +32,8 @@ public protocol HybridCoreModuleSpec_protocol: HybridObject {
32
32
  func authorizationStatusFor(type: ObjectTypeIdentifier) throws -> AuthorizationStatus
33
33
  func getRequestStatusForAuthorization(toCheck: AuthDataTypes) throws -> Promise<AuthorizationRequestStatus>
34
34
  func requestAuthorization(toRequest: AuthDataTypes) throws -> Promise<Bool>
35
- func deleteObjects(objectTypeIdentifier: ObjectTypeIdentifier, filter: FilterForSamples) throws -> Promise<Double>
35
+ func requestPerObjectReadAuthorization(typeIdentifier: PerObjectTypeIdentifier) throws -> Promise<Void>
36
+ func deleteObjects(objectTypeIdentifier: SampleTypeIdentifierWriteable, filter: FilterForSamples) throws -> Promise<Double>
36
37
  func isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier) throws -> Bool
37
38
  func areObjectTypesAvailable(objectTypeIdentifiers: [ObjectTypeIdentifier]) throws -> Dictionary<String, Bool>
38
39
  func areObjectTypesAvailableAsync(objectTypeIdentifiers: [ObjectTypeIdentifier]) throws -> Promise<Dictionary<String, Bool>>
@@ -440,10 +440,29 @@ open class HybridCoreModuleSpec_cxx {
440
440
  }
441
441
  }
442
442
 
443
+ @inline(__always)
444
+ public final func requestPerObjectReadAuthorization(typeIdentifier: Int32) -> bridge.Result_std__shared_ptr_Promise_void___ {
445
+ do {
446
+ let __result = try self.__implementation.requestPerObjectReadAuthorization(typeIdentifier: margelo.nitro.healthkit.PerObjectTypeIdentifier(rawValue: typeIdentifier)!)
447
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
448
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
449
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
450
+ __result
451
+ .then({ __result in __promiseHolder.resolve() })
452
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
453
+ return __promise
454
+ }()
455
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
456
+ } catch (let __error) {
457
+ let __exceptionPtr = __error.toCpp()
458
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
459
+ }
460
+ }
461
+
443
462
  @inline(__always)
444
463
  public final func deleteObjects(objectTypeIdentifier: Int32, filter: FilterForSamples) -> bridge.Result_std__shared_ptr_Promise_double___ {
445
464
  do {
446
- let __result = try self.__implementation.deleteObjects(objectTypeIdentifier: margelo.nitro.healthkit.ObjectTypeIdentifier(rawValue: objectTypeIdentifier)!, filter: filter)
465
+ let __result = try self.__implementation.deleteObjects(objectTypeIdentifier: margelo.nitro.healthkit.SampleTypeIdentifierWriteable(rawValue: objectTypeIdentifier)!, filter: filter)
447
466
  let __resultCpp = { () -> bridge.std__shared_ptr_Promise_double__ in
448
467
  let __promise = bridge.create_std__shared_ptr_Promise_double__()
449
468
  let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_double__(__promise)
@@ -411,8 +411,8 @@ public extension ObjectTypeIdentifier {
411
411
  self = .hkworkouttypeidentifier
412
412
  case "HKElectrocardiogramType":
413
413
  self = .hkelectrocardiogramtype
414
- case "ActivitySummaryTypeIdentifier":
415
- self = .activitysummarytypeidentifier
414
+ case "HKActivitySummaryTypeIdentifier":
415
+ self = .hkactivitysummarytypeidentifier
416
416
  default:
417
417
  return nil
418
418
  }
@@ -817,8 +817,8 @@ public extension ObjectTypeIdentifier {
817
817
  return "HKWorkoutTypeIdentifier"
818
818
  case .hkelectrocardiogramtype:
819
819
  return "HKElectrocardiogramType"
820
- case .activitysummarytypeidentifier:
821
- return "ActivitySummaryTypeIdentifier"
820
+ case .hkactivitysummarytypeidentifier:
821
+ return "HKActivitySummaryTypeIdentifier"
822
822
  }
823
823
  }
824
824
  }
@@ -0,0 +1,40 @@
1
+ ///
2
+ /// PerObjectTypeIdentifier.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `PerObjectTypeIdentifier`, backed by a C++ enum.
10
+ */
11
+ public typealias PerObjectTypeIdentifier = margelo.nitro.healthkit.PerObjectTypeIdentifier
12
+
13
+ public extension PerObjectTypeIdentifier {
14
+ /**
15
+ * Get a PerObjectTypeIdentifier for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "HKVisionPrescriptionTypeIdentifier":
21
+ self = .hkvisionprescriptiontypeidentifier
22
+ case "HKUserAnnotatedMedicationTypeIdentifier":
23
+ self = .hkuserannotatedmedicationtypeidentifier
24
+ default:
25
+ return nil
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Get the String value this PerObjectTypeIdentifier represents.
31
+ */
32
+ var stringValue: String {
33
+ switch self {
34
+ case .hkvisionprescriptiontypeidentifier:
35
+ return "HKVisionPrescriptionTypeIdentifier"
36
+ case .hkuserannotatedmedicationtypeidentifier:
37
+ return "HKUserAnnotatedMedicationTypeIdentifier"
38
+ }
39
+ }
40
+ }
@@ -19,29 +19,17 @@ public extension SourceRevision {
19
19
  /**
20
20
  * Create a new instance of `SourceRevision`.
21
21
  */
22
- init(source: (any HybridSourceProxySpec)?, version: String?, operatingSystemVersion: String?, productType: String?) {
23
- self.init({ () -> bridge.std__optional_std__shared_ptr_HybridSourceProxySpec__ in
24
- if let __unwrappedValue = source {
25
- return bridge.create_std__optional_std__shared_ptr_HybridSourceProxySpec__({ () -> bridge.std__shared_ptr_HybridSourceProxySpec_ in
26
- let __cxxWrapped = __unwrappedValue.getCxxWrapper()
27
- return __cxxWrapped.getCxxPart()
28
- }())
29
- } else {
30
- return .init()
31
- }
22
+ init(source: (any HybridSourceProxySpec), version: String?, operatingSystemVersion: String, productType: String?) {
23
+ self.init({ () -> bridge.std__shared_ptr_HybridSourceProxySpec_ in
24
+ let __cxxWrapped = source.getCxxWrapper()
25
+ return __cxxWrapped.getCxxPart()
32
26
  }(), { () -> bridge.std__optional_std__string_ in
33
27
  if let __unwrappedValue = version {
34
28
  return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
35
29
  } else {
36
30
  return .init()
37
31
  }
38
- }(), { () -> bridge.std__optional_std__string_ in
39
- if let __unwrappedValue = operatingSystemVersion {
40
- return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
41
- } else {
42
- return .init()
43
- }
44
- }(), { () -> bridge.std__optional_std__string_ in
32
+ }(), std.string(operatingSystemVersion), { () -> bridge.std__optional_std__string_ in
45
33
  if let __unwrappedValue = productType {
46
34
  return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
47
35
  } else {
@@ -50,33 +38,20 @@ public extension SourceRevision {
50
38
  }())
51
39
  }
52
40
 
53
- var source: (any HybridSourceProxySpec)? {
41
+ var source: (any HybridSourceProxySpec) {
54
42
  @inline(__always)
55
43
  get {
56
- return { () -> (any HybridSourceProxySpec)? in
57
- if bridge.has_value_std__optional_std__shared_ptr_HybridSourceProxySpec__(self.__source) {
58
- let __unwrapped = bridge.get_std__optional_std__shared_ptr_HybridSourceProxySpec__(self.__source)
59
- return { () -> HybridSourceProxySpec in
60
- let __unsafePointer = bridge.get_std__shared_ptr_HybridSourceProxySpec_(__unwrapped)
61
- let __instance = HybridSourceProxySpec_cxx.fromUnsafe(__unsafePointer)
62
- return __instance.getHybridSourceProxySpec()
63
- }()
64
- } else {
65
- return nil
66
- }
44
+ return { () -> HybridSourceProxySpec in
45
+ let __unsafePointer = bridge.get_std__shared_ptr_HybridSourceProxySpec_(self.__source)
46
+ let __instance = HybridSourceProxySpec_cxx.fromUnsafe(__unsafePointer)
47
+ return __instance.getHybridSourceProxySpec()
67
48
  }()
68
49
  }
69
50
  @inline(__always)
70
51
  set {
71
- self.__source = { () -> bridge.std__optional_std__shared_ptr_HybridSourceProxySpec__ in
72
- if let __unwrappedValue = newValue {
73
- return bridge.create_std__optional_std__shared_ptr_HybridSourceProxySpec__({ () -> bridge.std__shared_ptr_HybridSourceProxySpec_ in
74
- let __cxxWrapped = __unwrappedValue.getCxxWrapper()
75
- return __cxxWrapped.getCxxPart()
76
- }())
77
- } else {
78
- return .init()
79
- }
52
+ self.__source = { () -> bridge.std__shared_ptr_HybridSourceProxySpec_ in
53
+ let __cxxWrapped = newValue.getCxxWrapper()
54
+ return __cxxWrapped.getCxxPart()
80
55
  }()
81
56
  }
82
57
  }
@@ -105,27 +80,14 @@ public extension SourceRevision {
105
80
  }
106
81
  }
107
82
 
108
- var operatingSystemVersion: String? {
83
+ var operatingSystemVersion: String {
109
84
  @inline(__always)
110
85
  get {
111
- return { () -> String? in
112
- if bridge.has_value_std__optional_std__string_(self.__operatingSystemVersion) {
113
- let __unwrapped = bridge.get_std__optional_std__string_(self.__operatingSystemVersion)
114
- return String(__unwrapped)
115
- } else {
116
- return nil
117
- }
118
- }()
86
+ return String(self.__operatingSystemVersion)
119
87
  }
120
88
  @inline(__always)
121
89
  set {
122
- self.__operatingSystemVersion = { () -> bridge.std__optional_std__string_ in
123
- if let __unwrappedValue = newValue {
124
- return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
125
- } else {
126
- return .init()
127
- }
128
- }()
90
+ self.__operatingSystemVersion = std.string(newValue)
129
91
  }
130
92
  }
131
93
 
@@ -32,6 +32,7 @@ namespace margelo::nitro::healthkit {
32
32
  prototype.registerHybridMethod("authorizationStatusFor", &HybridCoreModuleSpec::authorizationStatusFor);
33
33
  prototype.registerHybridMethod("getRequestStatusForAuthorization", &HybridCoreModuleSpec::getRequestStatusForAuthorization);
34
34
  prototype.registerHybridMethod("requestAuthorization", &HybridCoreModuleSpec::requestAuthorization);
35
+ prototype.registerHybridMethod("requestPerObjectReadAuthorization", &HybridCoreModuleSpec::requestPerObjectReadAuthorization);
35
36
  prototype.registerHybridMethod("deleteObjects", &HybridCoreModuleSpec::deleteObjects);
36
37
  prototype.registerHybridMethod("isObjectTypeAvailable", &HybridCoreModuleSpec::isObjectTypeAvailable);
37
38
  prototype.registerHybridMethod("areObjectTypesAvailable", &HybridCoreModuleSpec::areObjectTypesAvailable);
@@ -35,6 +35,10 @@ namespace margelo::nitro::healthkit { enum class AuthorizationStatus; }
35
35
  namespace margelo::nitro::healthkit { enum class AuthorizationRequestStatus; }
36
36
  // Forward declaration of `AuthDataTypes` to properly resolve imports.
37
37
  namespace margelo::nitro::healthkit { struct AuthDataTypes; }
38
+ // Forward declaration of `PerObjectTypeIdentifier` to properly resolve imports.
39
+ namespace margelo::nitro::healthkit { enum class PerObjectTypeIdentifier; }
40
+ // Forward declaration of `SampleTypeIdentifierWriteable` to properly resolve imports.
41
+ namespace margelo::nitro::healthkit { enum class SampleTypeIdentifierWriteable; }
38
42
 
39
43
  #include <NitroModules/Promise.hpp>
40
44
  #include "ObjectTypeIdentifier.hpp"
@@ -53,6 +57,8 @@ namespace margelo::nitro::healthkit { struct AuthDataTypes; }
53
57
  #include "AuthorizationStatus.hpp"
54
58
  #include "AuthorizationRequestStatus.hpp"
55
59
  #include "AuthDataTypes.hpp"
60
+ #include "PerObjectTypeIdentifier.hpp"
61
+ #include "SampleTypeIdentifierWriteable.hpp"
56
62
  #include <unordered_map>
57
63
 
58
64
  namespace margelo::nitro::healthkit {
@@ -104,7 +110,8 @@ namespace margelo::nitro::healthkit {
104
110
  virtual AuthorizationStatus authorizationStatusFor(ObjectTypeIdentifier type) = 0;
105
111
  virtual std::shared_ptr<Promise<AuthorizationRequestStatus>> getRequestStatusForAuthorization(const AuthDataTypes& toCheck) = 0;
106
112
  virtual std::shared_ptr<Promise<bool>> requestAuthorization(const AuthDataTypes& toRequest) = 0;
107
- virtual std::shared_ptr<Promise<double>> deleteObjects(ObjectTypeIdentifier objectTypeIdentifier, const FilterForSamples& filter) = 0;
113
+ virtual std::shared_ptr<Promise<void>> requestPerObjectReadAuthorization(PerObjectTypeIdentifier typeIdentifier) = 0;
114
+ virtual std::shared_ptr<Promise<double>> deleteObjects(SampleTypeIdentifierWriteable objectTypeIdentifier, const FilterForSamples& filter) = 0;
108
115
  virtual bool isObjectTypeAvailable(ObjectTypeIdentifier objectTypeIdentifier) = 0;
109
116
  virtual std::unordered_map<std::string, bool> areObjectTypesAvailable(const std::vector<ObjectTypeIdentifier>& objectTypeIdentifiers) = 0;
110
117
  virtual std::shared_ptr<Promise<std::unordered_map<std::string, bool>>> areObjectTypesAvailableAsync(const std::vector<ObjectTypeIdentifier>& objectTypeIdentifiers) = 0;
@@ -226,7 +226,7 @@ namespace margelo::nitro::healthkit {
226
226
  HKWORKOUTROUTETYPEIDENTIFIER SWIFT_NAME(hkworkoutroutetypeidentifier) = 194,
227
227
  HKWORKOUTTYPEIDENTIFIER SWIFT_NAME(hkworkouttypeidentifier) = 195,
228
228
  HKELECTROCARDIOGRAMTYPE SWIFT_NAME(hkelectrocardiogramtype) = 196,
229
- ACTIVITYSUMMARYTYPEIDENTIFIER SWIFT_NAME(activitysummarytypeidentifier) = 197,
229
+ HKACTIVITYSUMMARYTYPEIDENTIFIER SWIFT_NAME(hkactivitysummarytypeidentifier) = 197,
230
230
  } CLOSED_ENUM;
231
231
 
232
232
  } // namespace margelo::nitro::healthkit
@@ -436,7 +436,7 @@ namespace margelo::nitro {
436
436
  case hashString("HKWorkoutRouteTypeIdentifier"): return margelo::nitro::healthkit::ObjectTypeIdentifier::HKWORKOUTROUTETYPEIDENTIFIER;
437
437
  case hashString("HKWorkoutTypeIdentifier"): return margelo::nitro::healthkit::ObjectTypeIdentifier::HKWORKOUTTYPEIDENTIFIER;
438
438
  case hashString("HKElectrocardiogramType"): return margelo::nitro::healthkit::ObjectTypeIdentifier::HKELECTROCARDIOGRAMTYPE;
439
- case hashString("ActivitySummaryTypeIdentifier"): return margelo::nitro::healthkit::ObjectTypeIdentifier::ACTIVITYSUMMARYTYPEIDENTIFIER;
439
+ case hashString("HKActivitySummaryTypeIdentifier"): return margelo::nitro::healthkit::ObjectTypeIdentifier::HKACTIVITYSUMMARYTYPEIDENTIFIER;
440
440
  default: [[unlikely]]
441
441
  throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ObjectTypeIdentifier - invalid value!");
442
442
  }
@@ -640,7 +640,7 @@ namespace margelo::nitro {
640
640
  case margelo::nitro::healthkit::ObjectTypeIdentifier::HKWORKOUTROUTETYPEIDENTIFIER: return JSIConverter<std::string>::toJSI(runtime, "HKWorkoutRouteTypeIdentifier");
641
641
  case margelo::nitro::healthkit::ObjectTypeIdentifier::HKWORKOUTTYPEIDENTIFIER: return JSIConverter<std::string>::toJSI(runtime, "HKWorkoutTypeIdentifier");
642
642
  case margelo::nitro::healthkit::ObjectTypeIdentifier::HKELECTROCARDIOGRAMTYPE: return JSIConverter<std::string>::toJSI(runtime, "HKElectrocardiogramType");
643
- case margelo::nitro::healthkit::ObjectTypeIdentifier::ACTIVITYSUMMARYTYPEIDENTIFIER: return JSIConverter<std::string>::toJSI(runtime, "ActivitySummaryTypeIdentifier");
643
+ case margelo::nitro::healthkit::ObjectTypeIdentifier::HKACTIVITYSUMMARYTYPEIDENTIFIER: return JSIConverter<std::string>::toJSI(runtime, "HKActivitySummaryTypeIdentifier");
644
644
  default: [[unlikely]]
645
645
  throw std::invalid_argument("Cannot convert ObjectTypeIdentifier to JS - invalid value: "
646
646
  + std::to_string(static_cast<int>(arg)) + "!");
@@ -849,7 +849,7 @@ namespace margelo::nitro {
849
849
  case hashString("HKWorkoutRouteTypeIdentifier"):
850
850
  case hashString("HKWorkoutTypeIdentifier"):
851
851
  case hashString("HKElectrocardiogramType"):
852
- case hashString("ActivitySummaryTypeIdentifier"):
852
+ case hashString("HKActivitySummaryTypeIdentifier"):
853
853
  return true;
854
854
  default:
855
855
  return false;