@kingstinct/react-native-healthkit 10.0.0 → 11.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.
- package/ios/CoreModule.swift +5 -15
- package/ios/CorrelationTypeModule.swift +8 -2
- package/ios/Helpers.swift +50 -6
- package/ios/QuantityTypeModule.swift +72 -112
- package/ios/Serializers.swift +39 -66
- package/ios/WorkoutProxy.swift +38 -20
- package/ios/WorkoutsModule.swift +7 -18
- package/lib/commonjs/healthkit.js +1 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +2 -9
- package/lib/commonjs/hooks/useWorkoutById.js +1 -4
- package/lib/commonjs/utils/getMostRecentWorkout.js +1 -3
- package/lib/commonjs/utils/getWorkoutById.js +1 -3
- package/lib/module/healthkit.js +1 -1
- package/lib/module/hooks/useMostRecentWorkout.js +3 -10
- package/lib/module/hooks/useWorkoutById.js +1 -4
- package/lib/module/utils/getMostRecentWorkout.js +1 -3
- package/lib/module/utils/getWorkoutById.js +1 -3
- package/lib/typescript/healthkit.d.ts +5 -5
- package/lib/typescript/healthkit.ios.d.ts +1 -1
- package/lib/typescript/hooks/useMostRecentWorkout.d.ts +1 -4
- package/lib/typescript/specs/WorkoutProxy.nitro.d.ts +11 -0
- package/lib/typescript/types/CorrelationType.d.ts +1 -0
- package/lib/typescript/types/QuantityType.d.ts +2 -0
- package/lib/typescript/types/QueryOptions.d.ts +4 -0
- package/lib/typescript/types/Workouts.d.ts +0 -8
- package/lib/typescript/utils/getMostRecentWorkout.d.ts +1 -2
- package/lib/typescript/utils/getWorkoutById.d.ts +1 -2
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +103 -87
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +798 -481
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/ReactNativeHealthkitAutolinking.mm +8 -8
- package/nitrogen/generated/ios/ReactNativeHealthkitAutolinking.swift +16 -16
- package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +9 -4
- package/nitrogen/generated/ios/c++/HybridCharacteristicTypeModuleSpecSwift.hpp +4 -2
- package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +10 -5
- package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +6 -4
- package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +10 -5
- package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +7 -2
- package/nitrogen/generated/ios/c++/HybridSourceProxySpecSwift.hpp +3 -1
- package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +10 -5
- package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +50 -22
- package/nitrogen/generated/ios/c++/HybridWorkoutsModuleSpecSwift.hpp +12 -7
- package/nitrogen/generated/ios/swift/CategorySample.swift +4 -2
- package/nitrogen/generated/ios/swift/CategorySampleForSaving.swift +2 -1
- package/nitrogen/generated/ios/swift/CorrelationObject.swift +2 -0
- package/nitrogen/generated/ios/swift/CorrelationSample.swift +13 -2
- package/nitrogen/generated/ios/swift/DeletedSample.swift +2 -1
- package/nitrogen/generated/ios/swift/Device.swift +16 -8
- package/nitrogen/generated/ios/swift/FilterForSamples.swift +2 -0
- package/nitrogen/generated/ios/swift/Func_void_AuthorizationRequestStatus.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_BiologicalSex.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_BloodType.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_CategorySamplesWithAnchorResponse.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_FitzpatrickSkinType.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_HeartbeatSeriesSamplesWithAnchorResponse.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_OnChangeCallbackArgs.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_QuantitySamplesWithAnchorResponse.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_QueryStatisticsResponse.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_QueryWorkoutSamplesWithAnchorResponse.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_WheelchairUse.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_QueryStatisticsResponse_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_WorkoutPlan_.swift +3 -1
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__chrono__system_clock__time_point_.swift +3 -1
- package/nitrogen/generated/ios/swift/{Func_void_std__shared_ptr_margelo__nitro__healthkit__HybridWorkoutProxySpec_.swift → Func_void_std__shared_ptr_HybridWorkoutProxySpec_.swift} +9 -8
- package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__QueryStatisticsResponse_.swift +55 -0
- package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__bool_.swift +2 -1
- package/nitrogen/generated/ios/swift/Func_void_std__vector_CategorySample_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_CorrelationSample_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_HeartbeatSeriesSample_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_IdentifierWithUnit_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_QuantitySample_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_QueryStatisticsResponse_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_StateOfMindSample_.swift +1 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_WorkoutRoute_.swift +1 -0
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_std__shared_ptr_margelo__nitro__healthkit__HybridSourceProxySpec__.swift → Func_void_std__vector_std__shared_ptr_HybridSourceProxySpec__.swift} +9 -8
- package/nitrogen/generated/ios/swift/{Func_void_std__vector_std__shared_ptr_margelo__nitro__healthkit__HybridWorkoutProxySpec__.swift → Func_void_std__vector_std__shared_ptr_HybridWorkoutProxySpec__.swift} +9 -8
- package/nitrogen/generated/ios/swift/HeartbeatSeriesSample.swift +6 -3
- package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec_cxx.swift +17 -7
- package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec_cxx.swift +15 -6
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +24 -15
- package/nitrogen/generated/ios/swift/HybridCorrelationTypeModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridCorrelationTypeModuleSpec_cxx.swift +15 -6
- package/nitrogen/generated/ios/swift/HybridHeartbeatSeriesModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridHeartbeatSeriesModuleSpec_cxx.swift +17 -7
- package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec_cxx.swift +21 -9
- package/nitrogen/generated/ios/swift/HybridSourceProxySpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridSourceProxySpec_cxx.swift +17 -7
- package/nitrogen/generated/ios/swift/HybridStateOfMindModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridStateOfMindModuleSpec_cxx.swift +19 -8
- package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec.swift +8 -5
- package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec_cxx.swift +108 -41
- package/nitrogen/generated/ios/swift/HybridWorkoutsModuleSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridWorkoutsModuleSpec_cxx.swift +31 -22
- package/nitrogen/generated/ios/swift/OnChangeCallbackArgs.swift +2 -1
- package/nitrogen/generated/ios/swift/PredicateForSamples.swift +2 -0
- package/nitrogen/generated/ios/swift/PredicateForWorkouts.swift +2 -0
- package/nitrogen/generated/ios/swift/PredicateFromWorkout.swift +3 -3
- package/nitrogen/generated/ios/swift/PredicateWithMetadataKey.swift +95 -2
- package/nitrogen/generated/ios/swift/PredicateWithMetadataOperator.swift +48 -0
- package/nitrogen/generated/ios/swift/PredicateWithStartAndEnd.swift +4 -2
- package/nitrogen/generated/ios/swift/QuantitySample.swift +4 -2
- package/nitrogen/generated/ios/swift/QuantitySampleForSaving.swift +2 -1
- package/nitrogen/generated/ios/swift/QueryOptionsWithAnchor.swift +4 -2
- package/nitrogen/generated/ios/swift/QueryOptionsWithAnchorAndUnit.swift +6 -3
- package/nitrogen/generated/ios/swift/QueryOptionsWithSortOrder.swift +2 -1
- package/nitrogen/generated/ios/swift/QueryOptionsWithSortOrderAndUnit.swift +4 -2
- package/nitrogen/generated/ios/swift/QueryStatisticsResponse.swift +75 -8
- package/nitrogen/generated/ios/swift/QueryWorkoutSamplesWithAnchorResponse.swift +7 -7
- package/nitrogen/generated/ios/swift/SampleForSaving.swift +2 -0
- package/nitrogen/generated/ios/swift/SourceRevision.swift +13 -9
- package/nitrogen/generated/ios/swift/StateOfMindSample.swift +6 -3
- package/nitrogen/generated/ios/swift/StatisticsQueryOptions.swift +4 -2
- package/nitrogen/generated/ios/swift/Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_FilterForSamplesAnd_FilterForSamplesOr.swift +2 -0
- package/nitrogen/generated/ios/swift/Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_WorkoutActivityTypePredicate_WorkoutDurationPredicate_PredicateForWorkoutsOr_PredicateForWorkoutsAnd.swift +2 -0
- package/nitrogen/generated/ios/swift/Variant_String_Double_Bool_Date.swift +20 -0
- package/nitrogen/generated/ios/swift/WorkoutQueryOptions.swift +4 -61
- package/nitrogen/generated/ios/swift/WorkoutQueryOptionsWithAnchor.swift +6 -62
- package/nitrogen/generated/ios/swift/WorkoutRoute.swift +2 -1
- package/nitrogen/generated/ios/swift/WorkoutSample.swift +12 -123
- package/nitrogen/generated/shared/c++/AuthorizationRequestStatus.hpp +9 -11
- package/nitrogen/generated/shared/c++/AuthorizationStatus.hpp +9 -11
- package/nitrogen/generated/shared/c++/BiologicalSex.hpp +9 -11
- package/nitrogen/generated/shared/c++/BloodType.hpp +9 -11
- package/nitrogen/generated/shared/c++/CategorySample.hpp +14 -16
- package/nitrogen/generated/shared/c++/CategorySampleForSaving.hpp +11 -13
- package/nitrogen/generated/shared/c++/CategorySamplesWithAnchorResponse.hpp +11 -13
- package/nitrogen/generated/shared/c++/CategoryTypeIdentifier.hpp +131 -133
- package/nitrogen/generated/shared/c++/ComparisonPredicateOperator.hpp +26 -13
- package/nitrogen/generated/shared/c++/CorrelationSample.hpp +18 -15
- package/nitrogen/generated/shared/c++/CorrelationTypeIdentifier.hpp +7 -9
- package/nitrogen/generated/shared/c++/DeletedSample.hpp +5 -7
- package/nitrogen/generated/shared/c++/Device.hpp +5 -7
- package/nitrogen/generated/shared/c++/FilterForSamplesAnd.hpp +9 -11
- package/nitrogen/generated/shared/c++/FilterForSamplesOr.hpp +9 -11
- package/nitrogen/generated/shared/c++/FitzpatrickSkinType.hpp +9 -11
- package/nitrogen/generated/shared/c++/Heartbeat.hpp +4 -6
- package/nitrogen/generated/shared/c++/HeartbeatSeriesSample.hpp +15 -17
- package/nitrogen/generated/shared/c++/HeartbeatSeriesSamplesWithAnchorResponse.hpp +11 -13
- package/nitrogen/generated/shared/c++/HybridCategoryTypeModuleSpec.hpp +2 -2
- package/nitrogen/generated/shared/c++/HybridCharacteristicTypeModuleSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/HybridCorrelationTypeModuleSpec.hpp +2 -2
- package/nitrogen/generated/shared/c++/HybridHeartbeatSeriesModuleSpec.hpp +3 -3
- package/nitrogen/generated/shared/c++/HybridQuantityTypeModuleSpec.hpp +3 -3
- package/nitrogen/generated/shared/c++/HybridStateOfMindModuleSpec.hpp +3 -3
- package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.cpp +6 -4
- package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.hpp +18 -9
- package/nitrogen/generated/shared/c++/HybridWorkoutsModuleSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/IdentifierWithUnit.hpp +4 -6
- package/nitrogen/generated/shared/c++/IntervalComponents.hpp +4 -6
- package/nitrogen/generated/shared/c++/LocationForSaving.hpp +4 -6
- package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +397 -399
- package/nitrogen/generated/shared/c++/OnChangeCallbackArgs.hpp +8 -10
- package/nitrogen/generated/shared/c++/PredicateForWorkoutsAnd.hpp +9 -11
- package/nitrogen/generated/shared/c++/PredicateForWorkoutsOr.hpp +9 -11
- package/nitrogen/generated/shared/c++/PredicateFromWorkout.hpp +6 -8
- package/nitrogen/generated/shared/c++/PredicateWithMetadataKey.hpp +20 -9
- package/nitrogen/generated/shared/c++/PredicateWithMetadataOperator.hpp +84 -0
- package/nitrogen/generated/shared/c++/PredicateWithStartAndEnd.hpp +5 -7
- package/nitrogen/generated/shared/c++/PredicateWithUUID.hpp +4 -6
- package/nitrogen/generated/shared/c++/PredicateWithUUIDs.hpp +5 -7
- package/nitrogen/generated/shared/c++/Quantity.hpp +4 -6
- package/nitrogen/generated/shared/c++/QuantityDateInterval.hpp +4 -6
- package/nitrogen/generated/shared/c++/QuantitySample.hpp +14 -16
- package/nitrogen/generated/shared/c++/QuantitySampleForSaving.hpp +11 -13
- package/nitrogen/generated/shared/c++/QuantitySamplesWithAnchorResponse.hpp +11 -13
- package/nitrogen/generated/shared/c++/QuantityTypeIdentifier.hpp +241 -243
- package/nitrogen/generated/shared/c++/QueryOptionsWithAnchor.hpp +9 -11
- package/nitrogen/generated/shared/c++/QueryOptionsWithAnchorAndUnit.hpp +9 -11
- package/nitrogen/generated/shared/c++/QueryOptionsWithSortOrder.hpp +8 -10
- package/nitrogen/generated/shared/c++/QueryOptionsWithSortOrderAndUnit.hpp +9 -11
- package/nitrogen/generated/shared/c++/QueryStatisticsResponse.hpp +36 -29
- package/nitrogen/generated/shared/c++/QueryWorkoutSamplesWithAnchorResponse.hpp +10 -12
- package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +383 -385
- package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +373 -375
- package/nitrogen/generated/shared/c++/Source.hpp +4 -6
- package/nitrogen/generated/shared/c++/SourceRevision.hpp +7 -9
- package/nitrogen/generated/shared/c++/StateOfMindAssociation.hpp +10 -12
- package/nitrogen/generated/shared/c++/StateOfMindKind.hpp +14 -13
- package/nitrogen/generated/shared/c++/StateOfMindLabel.hpp +10 -12
- package/nitrogen/generated/shared/c++/StateOfMindSample.hpp +24 -26
- package/nitrogen/generated/shared/c++/StateOfMindValenceClassification.hpp +10 -12
- package/nitrogen/generated/shared/c++/StatisticsOptions.hpp +17 -19
- package/nitrogen/generated/shared/c++/StatisticsQueryOptions.hpp +9 -11
- package/nitrogen/generated/shared/c++/UpdateFrequency.hpp +10 -12
- package/nitrogen/generated/shared/c++/WheelchairUse.hpp +9 -11
- package/nitrogen/generated/shared/c++/WorkoutActivity.hpp +4 -6
- package/nitrogen/generated/shared/c++/WorkoutActivityType.hpp +96 -13
- package/nitrogen/generated/shared/c++/WorkoutActivityTypePredicate.hpp +7 -9
- package/nitrogen/generated/shared/c++/WorkoutConfiguration.hpp +11 -13
- package/nitrogen/generated/shared/c++/WorkoutDurationPredicate.hpp +7 -9
- package/nitrogen/generated/shared/c++/WorkoutEvent.hpp +7 -9
- package/nitrogen/generated/shared/c++/WorkoutEventType.hpp +10 -12
- package/nitrogen/generated/shared/c++/WorkoutPlan.hpp +7 -9
- package/nitrogen/generated/shared/c++/WorkoutQueryOptions.hpp +10 -21
- package/nitrogen/generated/shared/c++/WorkoutQueryOptionsWithAnchor.hpp +11 -21
- package/nitrogen/generated/shared/c++/WorkoutRoute.hpp +9 -11
- package/nitrogen/generated/shared/c++/WorkoutRouteLocation.hpp +4 -6
- package/nitrogen/generated/shared/c++/WorkoutSample.hpp +25 -43
- package/nitrogen/generated/shared/c++/WorkoutSessionLocationType.hpp +10 -12
- package/nitrogen/generated/shared/c++/WorkoutTotals.hpp +4 -6
- package/package.json +11 -11
- package/src/healthkit.ts +5 -1
- package/src/hooks/queryStatisticsForQuantity.test.ts +32 -0
- package/src/hooks/useMostRecentWorkout.ts +3 -17
- package/src/hooks/useWorkoutById.ts +1 -4
- package/src/specs/WorkoutProxy.nitro.ts +18 -1
- package/src/types/CorrelationType.ts +1 -0
- package/src/types/QuantityType.ts +2 -0
- package/src/types/QueryOptions.ts +10 -0
- package/src/types/Workouts.ts +0 -8
- package/src/utils/getMostRecentWorkout.ts +1 -6
- package/src/utils/getWorkoutById.ts +1 -6
|
@@ -41,19 +41,17 @@ namespace margelo::nitro::healthkit {
|
|
|
41
41
|
|
|
42
42
|
namespace margelo::nitro {
|
|
43
43
|
|
|
44
|
-
using namespace margelo::nitro::healthkit;
|
|
45
|
-
|
|
46
44
|
// C++ Source <> JS Source (object)
|
|
47
45
|
template <>
|
|
48
|
-
struct JSIConverter<Source> final {
|
|
49
|
-
static inline Source fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
struct JSIConverter<margelo::nitro::healthkit::Source> final {
|
|
47
|
+
static inline margelo::nitro::healthkit::Source fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
50
48
|
jsi::Object obj = arg.asObject(runtime);
|
|
51
|
-
return Source(
|
|
49
|
+
return margelo::nitro::healthkit::Source(
|
|
52
50
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "name")),
|
|
53
51
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "bundleIdentifier"))
|
|
54
52
|
);
|
|
55
53
|
}
|
|
56
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const Source& arg) {
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::Source& arg) {
|
|
57
55
|
jsi::Object obj(runtime);
|
|
58
56
|
obj.setProperty(runtime, "name", JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
59
57
|
obj.setProperty(runtime, "bundleIdentifier", JSIConverter<std::string>::toJSI(runtime, arg.bundleIdentifier));
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
// Forward declaration of `HybridSourceProxySpec` to properly resolve imports.
|
|
22
22
|
namespace margelo::nitro::healthkit { class HybridSourceProxySpec; }
|
|
23
23
|
|
|
24
|
-
#include <optional>
|
|
25
24
|
#include <memory>
|
|
26
25
|
#include "HybridSourceProxySpec.hpp"
|
|
26
|
+
#include <optional>
|
|
27
27
|
#include <string>
|
|
28
28
|
|
|
29
29
|
namespace margelo::nitro::healthkit {
|
|
@@ -33,35 +33,33 @@ namespace margelo::nitro::healthkit {
|
|
|
33
33
|
*/
|
|
34
34
|
struct SourceRevision {
|
|
35
35
|
public:
|
|
36
|
-
std::optional<std::shared_ptr<
|
|
36
|
+
std::optional<std::shared_ptr<HybridSourceProxySpec>> source SWIFT_PRIVATE;
|
|
37
37
|
std::optional<std::string> version SWIFT_PRIVATE;
|
|
38
38
|
std::optional<std::string> operatingSystemVersion SWIFT_PRIVATE;
|
|
39
39
|
std::optional<std::string> productType SWIFT_PRIVATE;
|
|
40
40
|
|
|
41
41
|
public:
|
|
42
42
|
SourceRevision() = default;
|
|
43
|
-
explicit SourceRevision(std::optional<std::shared_ptr<
|
|
43
|
+
explicit SourceRevision(std::optional<std::shared_ptr<HybridSourceProxySpec>> source, std::optional<std::string> version, std::optional<std::string> operatingSystemVersion, std::optional<std::string> productType): source(source), version(version), operatingSystemVersion(operatingSystemVersion), productType(productType) {}
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
} // namespace margelo::nitro::healthkit
|
|
47
47
|
|
|
48
48
|
namespace margelo::nitro {
|
|
49
49
|
|
|
50
|
-
using namespace margelo::nitro::healthkit;
|
|
51
|
-
|
|
52
50
|
// C++ SourceRevision <> JS SourceRevision (object)
|
|
53
51
|
template <>
|
|
54
|
-
struct JSIConverter<SourceRevision> final {
|
|
55
|
-
static inline SourceRevision fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
struct JSIConverter<margelo::nitro::healthkit::SourceRevision> final {
|
|
53
|
+
static inline margelo::nitro::healthkit::SourceRevision fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
56
54
|
jsi::Object obj = arg.asObject(runtime);
|
|
57
|
-
return SourceRevision(
|
|
55
|
+
return margelo::nitro::healthkit::SourceRevision(
|
|
58
56
|
JSIConverter<std::optional<std::shared_ptr<margelo::nitro::healthkit::HybridSourceProxySpec>>>::fromJSI(runtime, obj.getProperty(runtime, "source")),
|
|
59
57
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "version")),
|
|
60
58
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "operatingSystemVersion")),
|
|
61
59
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "productType"))
|
|
62
60
|
);
|
|
63
61
|
}
|
|
64
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const SourceRevision& arg) {
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::SourceRevision& arg) {
|
|
65
63
|
jsi::Object obj(runtime);
|
|
66
64
|
obj.setProperty(runtime, "source", JSIConverter<std::optional<std::shared_ptr<margelo::nitro::healthkit::HybridSourceProxySpec>>>::toJSI(runtime, arg.source));
|
|
67
65
|
obj.setProperty(runtime, "version", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.version));
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <cmath>
|
|
11
10
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
11
|
#include <NitroModules/JSIConverter.hpp>
|
|
13
12
|
#else
|
|
@@ -49,16 +48,14 @@ namespace margelo::nitro::healthkit {
|
|
|
49
48
|
|
|
50
49
|
namespace margelo::nitro {
|
|
51
50
|
|
|
52
|
-
using namespace margelo::nitro::healthkit;
|
|
53
|
-
|
|
54
51
|
// C++ StateOfMindAssociation <> JS StateOfMindAssociation (enum)
|
|
55
52
|
template <>
|
|
56
|
-
struct JSIConverter<StateOfMindAssociation> final {
|
|
57
|
-
static inline StateOfMindAssociation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
|
+
struct JSIConverter<margelo::nitro::healthkit::StateOfMindAssociation> final {
|
|
54
|
+
static inline margelo::nitro::healthkit::StateOfMindAssociation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
58
55
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
59
|
-
return static_cast<StateOfMindAssociation>(enumValue);
|
|
56
|
+
return static_cast<margelo::nitro::healthkit::StateOfMindAssociation>(enumValue);
|
|
60
57
|
}
|
|
61
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, StateOfMindAssociation arg) {
|
|
58
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::StateOfMindAssociation arg) {
|
|
62
59
|
int enumValue = static_cast<int>(arg);
|
|
63
60
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
64
61
|
}
|
|
@@ -66,14 +63,15 @@ namespace margelo::nitro {
|
|
|
66
63
|
if (!value.isNumber()) {
|
|
67
64
|
return false;
|
|
68
65
|
}
|
|
69
|
-
double
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
//
|
|
66
|
+
double number = value.getNumber();
|
|
67
|
+
int integer = static_cast<int>(number);
|
|
68
|
+
if (number != integer) {
|
|
69
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
70
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
73
71
|
return false;
|
|
74
72
|
}
|
|
75
73
|
// Check if we are within the bounds of the enum.
|
|
76
|
-
return integer >=
|
|
74
|
+
return integer >= 1 && integer <= 18;
|
|
77
75
|
}
|
|
78
76
|
};
|
|
79
77
|
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <cmath>
|
|
11
10
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
11
|
#include <NitroModules/JSIConverter.hpp>
|
|
13
12
|
#else
|
|
@@ -33,16 +32,14 @@ namespace margelo::nitro::healthkit {
|
|
|
33
32
|
|
|
34
33
|
namespace margelo::nitro {
|
|
35
34
|
|
|
36
|
-
using namespace margelo::nitro::healthkit;
|
|
37
|
-
|
|
38
35
|
// C++ StateOfMindKind <> JS StateOfMindKind (enum)
|
|
39
36
|
template <>
|
|
40
|
-
struct JSIConverter<StateOfMindKind> final {
|
|
41
|
-
static inline StateOfMindKind fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
37
|
+
struct JSIConverter<margelo::nitro::healthkit::StateOfMindKind> final {
|
|
38
|
+
static inline margelo::nitro::healthkit::StateOfMindKind fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
42
39
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
43
|
-
return static_cast<StateOfMindKind>(enumValue);
|
|
40
|
+
return static_cast<margelo::nitro::healthkit::StateOfMindKind>(enumValue);
|
|
44
41
|
}
|
|
45
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, StateOfMindKind arg) {
|
|
42
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::StateOfMindKind arg) {
|
|
46
43
|
int enumValue = static_cast<int>(arg);
|
|
47
44
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
48
45
|
}
|
|
@@ -50,14 +47,18 @@ namespace margelo::nitro {
|
|
|
50
47
|
if (!value.isNumber()) {
|
|
51
48
|
return false;
|
|
52
49
|
}
|
|
53
|
-
double
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
//
|
|
50
|
+
double number = value.getNumber();
|
|
51
|
+
int integer = static_cast<int>(number);
|
|
52
|
+
if (number != integer) {
|
|
53
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
54
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
57
55
|
return false;
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
switch (integer) {
|
|
58
|
+
case 2 /* DAILYMOOD */: return true;
|
|
59
|
+
case 1 /* MOMENTARYEMOTION */: return true;
|
|
60
|
+
default: return false;
|
|
61
|
+
}
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <cmath>
|
|
11
10
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
11
|
#include <NitroModules/JSIConverter.hpp>
|
|
13
12
|
#else
|
|
@@ -69,16 +68,14 @@ namespace margelo::nitro::healthkit {
|
|
|
69
68
|
|
|
70
69
|
namespace margelo::nitro {
|
|
71
70
|
|
|
72
|
-
using namespace margelo::nitro::healthkit;
|
|
73
|
-
|
|
74
71
|
// C++ StateOfMindLabel <> JS StateOfMindLabel (enum)
|
|
75
72
|
template <>
|
|
76
|
-
struct JSIConverter<StateOfMindLabel> final {
|
|
77
|
-
static inline StateOfMindLabel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
73
|
+
struct JSIConverter<margelo::nitro::healthkit::StateOfMindLabel> final {
|
|
74
|
+
static inline margelo::nitro::healthkit::StateOfMindLabel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
78
75
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
79
|
-
return static_cast<StateOfMindLabel>(enumValue);
|
|
76
|
+
return static_cast<margelo::nitro::healthkit::StateOfMindLabel>(enumValue);
|
|
80
77
|
}
|
|
81
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, StateOfMindLabel arg) {
|
|
78
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::StateOfMindLabel arg) {
|
|
82
79
|
int enumValue = static_cast<int>(arg);
|
|
83
80
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
84
81
|
}
|
|
@@ -86,14 +83,15 @@ namespace margelo::nitro {
|
|
|
86
83
|
if (!value.isNumber()) {
|
|
87
84
|
return false;
|
|
88
85
|
}
|
|
89
|
-
double
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
//
|
|
86
|
+
double number = value.getNumber();
|
|
87
|
+
int integer = static_cast<int>(number);
|
|
88
|
+
if (number != integer) {
|
|
89
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
90
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
93
91
|
return false;
|
|
94
92
|
}
|
|
95
93
|
// Check if we are within the bounds of the enum.
|
|
96
|
-
return integer >=
|
|
94
|
+
return integer >= 1 && integer <= 38;
|
|
97
95
|
}
|
|
98
96
|
};
|
|
99
97
|
|
|
@@ -34,15 +34,15 @@ namespace margelo::nitro::healthkit { enum class StateOfMindAssociation; }
|
|
|
34
34
|
namespace margelo::nitro::healthkit { enum class StateOfMindLabel; }
|
|
35
35
|
|
|
36
36
|
#include <string>
|
|
37
|
-
#include <optional>
|
|
38
37
|
#include "Device.hpp"
|
|
38
|
+
#include <optional>
|
|
39
39
|
#include <chrono>
|
|
40
40
|
#include <NitroModules/AnyMap.hpp>
|
|
41
41
|
#include "SourceRevision.hpp"
|
|
42
42
|
#include "StateOfMindKind.hpp"
|
|
43
43
|
#include "StateOfMindValenceClassification.hpp"
|
|
44
|
-
#include <vector>
|
|
45
44
|
#include "StateOfMindAssociation.hpp"
|
|
45
|
+
#include <vector>
|
|
46
46
|
#include "StateOfMindLabel.hpp"
|
|
47
47
|
|
|
48
48
|
namespace margelo::nitro::healthkit {
|
|
@@ -73,40 +73,38 @@ namespace margelo::nitro::healthkit {
|
|
|
73
73
|
|
|
74
74
|
namespace margelo::nitro {
|
|
75
75
|
|
|
76
|
-
using namespace margelo::nitro::healthkit;
|
|
77
|
-
|
|
78
76
|
// C++ StateOfMindSample <> JS StateOfMindSample (object)
|
|
79
77
|
template <>
|
|
80
|
-
struct JSIConverter<StateOfMindSample> final {
|
|
81
|
-
static inline StateOfMindSample fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
78
|
+
struct JSIConverter<margelo::nitro::healthkit::StateOfMindSample> final {
|
|
79
|
+
static inline margelo::nitro::healthkit::StateOfMindSample fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
82
80
|
jsi::Object obj = arg.asObject(runtime);
|
|
83
|
-
return StateOfMindSample(
|
|
81
|
+
return margelo::nitro::healthkit::StateOfMindSample(
|
|
84
82
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "uuid")),
|
|
85
|
-
JSIConverter<std::optional<Device>>::fromJSI(runtime, obj.getProperty(runtime, "device")),
|
|
83
|
+
JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::fromJSI(runtime, obj.getProperty(runtime, "device")),
|
|
86
84
|
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "startDate")),
|
|
87
85
|
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "endDate")),
|
|
88
86
|
JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::fromJSI(runtime, obj.getProperty(runtime, "metadata")),
|
|
89
|
-
JSIConverter<std::optional<SourceRevision>>::fromJSI(runtime, obj.getProperty(runtime, "sourceRevision")),
|
|
87
|
+
JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::fromJSI(runtime, obj.getProperty(runtime, "sourceRevision")),
|
|
90
88
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "valence")),
|
|
91
|
-
JSIConverter<StateOfMindKind>::fromJSI(runtime, obj.getProperty(runtime, "kind")),
|
|
92
|
-
JSIConverter<StateOfMindValenceClassification>::fromJSI(runtime, obj.getProperty(runtime, "valenceClassification")),
|
|
93
|
-
JSIConverter<std::vector<StateOfMindAssociation>>::fromJSI(runtime, obj.getProperty(runtime, "associations")),
|
|
94
|
-
JSIConverter<std::vector<StateOfMindLabel>>::fromJSI(runtime, obj.getProperty(runtime, "labels"))
|
|
89
|
+
JSIConverter<margelo::nitro::healthkit::StateOfMindKind>::fromJSI(runtime, obj.getProperty(runtime, "kind")),
|
|
90
|
+
JSIConverter<margelo::nitro::healthkit::StateOfMindValenceClassification>::fromJSI(runtime, obj.getProperty(runtime, "valenceClassification")),
|
|
91
|
+
JSIConverter<std::vector<margelo::nitro::healthkit::StateOfMindAssociation>>::fromJSI(runtime, obj.getProperty(runtime, "associations")),
|
|
92
|
+
JSIConverter<std::vector<margelo::nitro::healthkit::StateOfMindLabel>>::fromJSI(runtime, obj.getProperty(runtime, "labels"))
|
|
95
93
|
);
|
|
96
94
|
}
|
|
97
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const StateOfMindSample& arg) {
|
|
95
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::StateOfMindSample& arg) {
|
|
98
96
|
jsi::Object obj(runtime);
|
|
99
97
|
obj.setProperty(runtime, "uuid", JSIConverter<std::string>::toJSI(runtime, arg.uuid));
|
|
100
|
-
obj.setProperty(runtime, "device", JSIConverter<std::optional<Device>>::toJSI(runtime, arg.device));
|
|
98
|
+
obj.setProperty(runtime, "device", JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::toJSI(runtime, arg.device));
|
|
101
99
|
obj.setProperty(runtime, "startDate", JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.startDate));
|
|
102
100
|
obj.setProperty(runtime, "endDate", JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.endDate));
|
|
103
101
|
obj.setProperty(runtime, "metadata", JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::toJSI(runtime, arg.metadata));
|
|
104
|
-
obj.setProperty(runtime, "sourceRevision", JSIConverter<std::optional<SourceRevision>>::toJSI(runtime, arg.sourceRevision));
|
|
102
|
+
obj.setProperty(runtime, "sourceRevision", JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::toJSI(runtime, arg.sourceRevision));
|
|
105
103
|
obj.setProperty(runtime, "valence", JSIConverter<double>::toJSI(runtime, arg.valence));
|
|
106
|
-
obj.setProperty(runtime, "kind", JSIConverter<StateOfMindKind>::toJSI(runtime, arg.kind));
|
|
107
|
-
obj.setProperty(runtime, "valenceClassification", JSIConverter<StateOfMindValenceClassification>::toJSI(runtime, arg.valenceClassification));
|
|
108
|
-
obj.setProperty(runtime, "associations", JSIConverter<std::vector<StateOfMindAssociation>>::toJSI(runtime, arg.associations));
|
|
109
|
-
obj.setProperty(runtime, "labels", JSIConverter<std::vector<StateOfMindLabel>>::toJSI(runtime, arg.labels));
|
|
104
|
+
obj.setProperty(runtime, "kind", JSIConverter<margelo::nitro::healthkit::StateOfMindKind>::toJSI(runtime, arg.kind));
|
|
105
|
+
obj.setProperty(runtime, "valenceClassification", JSIConverter<margelo::nitro::healthkit::StateOfMindValenceClassification>::toJSI(runtime, arg.valenceClassification));
|
|
106
|
+
obj.setProperty(runtime, "associations", JSIConverter<std::vector<margelo::nitro::healthkit::StateOfMindAssociation>>::toJSI(runtime, arg.associations));
|
|
107
|
+
obj.setProperty(runtime, "labels", JSIConverter<std::vector<margelo::nitro::healthkit::StateOfMindLabel>>::toJSI(runtime, arg.labels));
|
|
110
108
|
return obj;
|
|
111
109
|
}
|
|
112
110
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -115,16 +113,16 @@ namespace margelo::nitro {
|
|
|
115
113
|
}
|
|
116
114
|
jsi::Object obj = value.getObject(runtime);
|
|
117
115
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "uuid"))) return false;
|
|
118
|
-
if (!JSIConverter<std::optional<Device>>::canConvert(runtime, obj.getProperty(runtime, "device"))) return false;
|
|
116
|
+
if (!JSIConverter<std::optional<margelo::nitro::healthkit::Device>>::canConvert(runtime, obj.getProperty(runtime, "device"))) return false;
|
|
119
117
|
if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, "startDate"))) return false;
|
|
120
118
|
if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, "endDate"))) return false;
|
|
121
119
|
if (!JSIConverter<std::optional<std::shared_ptr<AnyMap>>>::canConvert(runtime, obj.getProperty(runtime, "metadata"))) return false;
|
|
122
|
-
if (!JSIConverter<std::optional<SourceRevision>>::canConvert(runtime, obj.getProperty(runtime, "sourceRevision"))) return false;
|
|
120
|
+
if (!JSIConverter<std::optional<margelo::nitro::healthkit::SourceRevision>>::canConvert(runtime, obj.getProperty(runtime, "sourceRevision"))) return false;
|
|
123
121
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "valence"))) return false;
|
|
124
|
-
if (!JSIConverter<StateOfMindKind>::canConvert(runtime, obj.getProperty(runtime, "kind"))) return false;
|
|
125
|
-
if (!JSIConverter<StateOfMindValenceClassification>::canConvert(runtime, obj.getProperty(runtime, "valenceClassification"))) return false;
|
|
126
|
-
if (!JSIConverter<std::vector<StateOfMindAssociation>>::canConvert(runtime, obj.getProperty(runtime, "associations"))) return false;
|
|
127
|
-
if (!JSIConverter<std::vector<StateOfMindLabel>>::canConvert(runtime, obj.getProperty(runtime, "labels"))) return false;
|
|
122
|
+
if (!JSIConverter<margelo::nitro::healthkit::StateOfMindKind>::canConvert(runtime, obj.getProperty(runtime, "kind"))) return false;
|
|
123
|
+
if (!JSIConverter<margelo::nitro::healthkit::StateOfMindValenceClassification>::canConvert(runtime, obj.getProperty(runtime, "valenceClassification"))) return false;
|
|
124
|
+
if (!JSIConverter<std::vector<margelo::nitro::healthkit::StateOfMindAssociation>>::canConvert(runtime, obj.getProperty(runtime, "associations"))) return false;
|
|
125
|
+
if (!JSIConverter<std::vector<margelo::nitro::healthkit::StateOfMindLabel>>::canConvert(runtime, obj.getProperty(runtime, "labels"))) return false;
|
|
128
126
|
return true;
|
|
129
127
|
}
|
|
130
128
|
};
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <cmath>
|
|
11
10
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
11
|
#include <NitroModules/JSIConverter.hpp>
|
|
13
12
|
#else
|
|
@@ -38,16 +37,14 @@ namespace margelo::nitro::healthkit {
|
|
|
38
37
|
|
|
39
38
|
namespace margelo::nitro {
|
|
40
39
|
|
|
41
|
-
using namespace margelo::nitro::healthkit;
|
|
42
|
-
|
|
43
40
|
// C++ StateOfMindValenceClassification <> JS StateOfMindValenceClassification (enum)
|
|
44
41
|
template <>
|
|
45
|
-
struct JSIConverter<StateOfMindValenceClassification> final {
|
|
46
|
-
static inline StateOfMindValenceClassification fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
42
|
+
struct JSIConverter<margelo::nitro::healthkit::StateOfMindValenceClassification> final {
|
|
43
|
+
static inline margelo::nitro::healthkit::StateOfMindValenceClassification fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
44
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
48
|
-
return static_cast<StateOfMindValenceClassification>(enumValue);
|
|
45
|
+
return static_cast<margelo::nitro::healthkit::StateOfMindValenceClassification>(enumValue);
|
|
49
46
|
}
|
|
50
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, StateOfMindValenceClassification arg) {
|
|
47
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::StateOfMindValenceClassification arg) {
|
|
51
48
|
int enumValue = static_cast<int>(arg);
|
|
52
49
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
53
50
|
}
|
|
@@ -55,14 +52,15 @@ namespace margelo::nitro {
|
|
|
55
52
|
if (!value.isNumber()) {
|
|
56
53
|
return false;
|
|
57
54
|
}
|
|
58
|
-
double
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
//
|
|
55
|
+
double number = value.getNumber();
|
|
56
|
+
int integer = static_cast<int>(number);
|
|
57
|
+
if (number != integer) {
|
|
58
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
59
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
62
60
|
return false;
|
|
63
61
|
}
|
|
64
62
|
// Check if we are within the bounds of the enum.
|
|
65
|
-
return integer >=
|
|
63
|
+
return integer >= 1 && integer <= 7;
|
|
66
64
|
}
|
|
67
65
|
};
|
|
68
66
|
|
|
@@ -42,34 +42,32 @@ namespace margelo::nitro::healthkit {
|
|
|
42
42
|
|
|
43
43
|
namespace margelo::nitro {
|
|
44
44
|
|
|
45
|
-
using namespace margelo::nitro::healthkit;
|
|
46
|
-
|
|
47
45
|
// C++ StatisticsOptions <> JS StatisticsOptions (union)
|
|
48
46
|
template <>
|
|
49
|
-
struct JSIConverter<StatisticsOptions> final {
|
|
50
|
-
static inline StatisticsOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
+
struct JSIConverter<margelo::nitro::healthkit::StatisticsOptions> final {
|
|
48
|
+
static inline margelo::nitro::healthkit::StatisticsOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
49
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
52
50
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
53
|
-
case hashString("cumulativeSum"): return StatisticsOptions::CUMULATIVESUM;
|
|
54
|
-
case hashString("discreteAverage"): return StatisticsOptions::DISCRETEAVERAGE;
|
|
55
|
-
case hashString("discreteMax"): return StatisticsOptions::DISCRETEMAX;
|
|
56
|
-
case hashString("discreteMin"): return StatisticsOptions::DISCRETEMIN;
|
|
57
|
-
case hashString("duration"): return StatisticsOptions::DURATION;
|
|
58
|
-
case hashString("mostRecent"): return StatisticsOptions::MOSTRECENT;
|
|
59
|
-
case hashString("separateBySource"): return StatisticsOptions::SEPARATEBYSOURCE;
|
|
51
|
+
case hashString("cumulativeSum"): return margelo::nitro::healthkit::StatisticsOptions::CUMULATIVESUM;
|
|
52
|
+
case hashString("discreteAverage"): return margelo::nitro::healthkit::StatisticsOptions::DISCRETEAVERAGE;
|
|
53
|
+
case hashString("discreteMax"): return margelo::nitro::healthkit::StatisticsOptions::DISCRETEMAX;
|
|
54
|
+
case hashString("discreteMin"): return margelo::nitro::healthkit::StatisticsOptions::DISCRETEMIN;
|
|
55
|
+
case hashString("duration"): return margelo::nitro::healthkit::StatisticsOptions::DURATION;
|
|
56
|
+
case hashString("mostRecent"): return margelo::nitro::healthkit::StatisticsOptions::MOSTRECENT;
|
|
57
|
+
case hashString("separateBySource"): return margelo::nitro::healthkit::StatisticsOptions::SEPARATEBYSOURCE;
|
|
60
58
|
default: [[unlikely]]
|
|
61
59
|
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum StatisticsOptions - invalid value!");
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, StatisticsOptions arg) {
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::StatisticsOptions arg) {
|
|
65
63
|
switch (arg) {
|
|
66
|
-
case StatisticsOptions::CUMULATIVESUM: return JSIConverter<std::string>::toJSI(runtime, "cumulativeSum");
|
|
67
|
-
case StatisticsOptions::DISCRETEAVERAGE: return JSIConverter<std::string>::toJSI(runtime, "discreteAverage");
|
|
68
|
-
case StatisticsOptions::DISCRETEMAX: return JSIConverter<std::string>::toJSI(runtime, "discreteMax");
|
|
69
|
-
case StatisticsOptions::DISCRETEMIN: return JSIConverter<std::string>::toJSI(runtime, "discreteMin");
|
|
70
|
-
case StatisticsOptions::DURATION: return JSIConverter<std::string>::toJSI(runtime, "duration");
|
|
71
|
-
case StatisticsOptions::MOSTRECENT: return JSIConverter<std::string>::toJSI(runtime, "mostRecent");
|
|
72
|
-
case StatisticsOptions::SEPARATEBYSOURCE: return JSIConverter<std::string>::toJSI(runtime, "separateBySource");
|
|
64
|
+
case margelo::nitro::healthkit::StatisticsOptions::CUMULATIVESUM: return JSIConverter<std::string>::toJSI(runtime, "cumulativeSum");
|
|
65
|
+
case margelo::nitro::healthkit::StatisticsOptions::DISCRETEAVERAGE: return JSIConverter<std::string>::toJSI(runtime, "discreteAverage");
|
|
66
|
+
case margelo::nitro::healthkit::StatisticsOptions::DISCRETEMAX: return JSIConverter<std::string>::toJSI(runtime, "discreteMax");
|
|
67
|
+
case margelo::nitro::healthkit::StatisticsOptions::DISCRETEMIN: return JSIConverter<std::string>::toJSI(runtime, "discreteMin");
|
|
68
|
+
case margelo::nitro::healthkit::StatisticsOptions::DURATION: return JSIConverter<std::string>::toJSI(runtime, "duration");
|
|
69
|
+
case margelo::nitro::healthkit::StatisticsOptions::MOSTRECENT: return JSIConverter<std::string>::toJSI(runtime, "mostRecent");
|
|
70
|
+
case margelo::nitro::healthkit::StatisticsOptions::SEPARATEBYSOURCE: return JSIConverter<std::string>::toJSI(runtime, "separateBySource");
|
|
73
71
|
default: [[unlikely]]
|
|
74
72
|
throw std::invalid_argument("Cannot convert StatisticsOptions to JS - invalid value: "
|
|
75
73
|
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
@@ -33,8 +33,6 @@ namespace margelo::nitro::healthkit { struct FilterForSamplesAnd; }
|
|
|
33
33
|
// Forward declaration of `FilterForSamplesOr` to properly resolve imports.
|
|
34
34
|
namespace margelo::nitro::healthkit { struct FilterForSamplesOr; }
|
|
35
35
|
|
|
36
|
-
#include <optional>
|
|
37
|
-
#include <variant>
|
|
38
36
|
#include "PredicateWithUUID.hpp"
|
|
39
37
|
#include "PredicateWithUUIDs.hpp"
|
|
40
38
|
#include "PredicateWithMetadataKey.hpp"
|
|
@@ -42,6 +40,8 @@ namespace margelo::nitro::healthkit { struct FilterForSamplesOr; }
|
|
|
42
40
|
#include "PredicateFromWorkout.hpp"
|
|
43
41
|
#include "FilterForSamplesAnd.hpp"
|
|
44
42
|
#include "FilterForSamplesOr.hpp"
|
|
43
|
+
#include <variant>
|
|
44
|
+
#include <optional>
|
|
45
45
|
#include <string>
|
|
46
46
|
|
|
47
47
|
namespace margelo::nitro::healthkit {
|
|
@@ -63,21 +63,19 @@ namespace margelo::nitro::healthkit {
|
|
|
63
63
|
|
|
64
64
|
namespace margelo::nitro {
|
|
65
65
|
|
|
66
|
-
using namespace margelo::nitro::healthkit;
|
|
67
|
-
|
|
68
66
|
// C++ StatisticsQueryOptions <> JS StatisticsQueryOptions (object)
|
|
69
67
|
template <>
|
|
70
|
-
struct JSIConverter<StatisticsQueryOptions> final {
|
|
71
|
-
static inline StatisticsQueryOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
68
|
+
struct JSIConverter<margelo::nitro::healthkit::StatisticsQueryOptions> final {
|
|
69
|
+
static inline margelo::nitro::healthkit::StatisticsQueryOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
72
70
|
jsi::Object obj = arg.asObject(runtime);
|
|
73
|
-
return StatisticsQueryOptions(
|
|
74
|
-
JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, FilterForSamplesAnd, FilterForSamplesOr>>>::fromJSI(runtime, obj.getProperty(runtime, "filter")),
|
|
71
|
+
return margelo::nitro::healthkit::StatisticsQueryOptions(
|
|
72
|
+
JSIConverter<std::optional<std::variant<margelo::nitro::healthkit::PredicateWithUUID, margelo::nitro::healthkit::PredicateWithUUIDs, margelo::nitro::healthkit::PredicateWithMetadataKey, margelo::nitro::healthkit::PredicateWithStartAndEnd, margelo::nitro::healthkit::PredicateFromWorkout, margelo::nitro::healthkit::FilterForSamplesAnd, margelo::nitro::healthkit::FilterForSamplesOr>>>::fromJSI(runtime, obj.getProperty(runtime, "filter")),
|
|
75
73
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "unit"))
|
|
76
74
|
);
|
|
77
75
|
}
|
|
78
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const StatisticsQueryOptions& arg) {
|
|
76
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::StatisticsQueryOptions& arg) {
|
|
79
77
|
jsi::Object obj(runtime);
|
|
80
|
-
obj.setProperty(runtime, "filter", JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, FilterForSamplesAnd, FilterForSamplesOr>>>::toJSI(runtime, arg.filter));
|
|
78
|
+
obj.setProperty(runtime, "filter", JSIConverter<std::optional<std::variant<margelo::nitro::healthkit::PredicateWithUUID, margelo::nitro::healthkit::PredicateWithUUIDs, margelo::nitro::healthkit::PredicateWithMetadataKey, margelo::nitro::healthkit::PredicateWithStartAndEnd, margelo::nitro::healthkit::PredicateFromWorkout, margelo::nitro::healthkit::FilterForSamplesAnd, margelo::nitro::healthkit::FilterForSamplesOr>>>::toJSI(runtime, arg.filter));
|
|
81
79
|
obj.setProperty(runtime, "unit", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.unit));
|
|
82
80
|
return obj;
|
|
83
81
|
}
|
|
@@ -86,7 +84,7 @@ namespace margelo::nitro {
|
|
|
86
84
|
return false;
|
|
87
85
|
}
|
|
88
86
|
jsi::Object obj = value.getObject(runtime);
|
|
89
|
-
if (!JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, FilterForSamplesAnd, FilterForSamplesOr>>>::canConvert(runtime, obj.getProperty(runtime, "filter"))) return false;
|
|
87
|
+
if (!JSIConverter<std::optional<std::variant<margelo::nitro::healthkit::PredicateWithUUID, margelo::nitro::healthkit::PredicateWithUUIDs, margelo::nitro::healthkit::PredicateWithMetadataKey, margelo::nitro::healthkit::PredicateWithStartAndEnd, margelo::nitro::healthkit::PredicateFromWorkout, margelo::nitro::healthkit::FilterForSamplesAnd, margelo::nitro::healthkit::FilterForSamplesOr>>>::canConvert(runtime, obj.getProperty(runtime, "filter"))) return false;
|
|
90
88
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "unit"))) return false;
|
|
91
89
|
return true;
|
|
92
90
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <cmath>
|
|
11
10
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
11
|
#include <NitroModules/JSIConverter.hpp>
|
|
13
12
|
#else
|
|
@@ -35,16 +34,14 @@ namespace margelo::nitro::healthkit {
|
|
|
35
34
|
|
|
36
35
|
namespace margelo::nitro {
|
|
37
36
|
|
|
38
|
-
using namespace margelo::nitro::healthkit;
|
|
39
|
-
|
|
40
37
|
// C++ UpdateFrequency <> JS UpdateFrequency (enum)
|
|
41
38
|
template <>
|
|
42
|
-
struct JSIConverter<UpdateFrequency> final {
|
|
43
|
-
static inline UpdateFrequency fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
39
|
+
struct JSIConverter<margelo::nitro::healthkit::UpdateFrequency> final {
|
|
40
|
+
static inline margelo::nitro::healthkit::UpdateFrequency fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
41
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
45
|
-
return static_cast<UpdateFrequency>(enumValue);
|
|
42
|
+
return static_cast<margelo::nitro::healthkit::UpdateFrequency>(enumValue);
|
|
46
43
|
}
|
|
47
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, UpdateFrequency arg) {
|
|
44
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::UpdateFrequency arg) {
|
|
48
45
|
int enumValue = static_cast<int>(arg);
|
|
49
46
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
50
47
|
}
|
|
@@ -52,14 +49,15 @@ namespace margelo::nitro {
|
|
|
52
49
|
if (!value.isNumber()) {
|
|
53
50
|
return false;
|
|
54
51
|
}
|
|
55
|
-
double
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
//
|
|
52
|
+
double number = value.getNumber();
|
|
53
|
+
int integer = static_cast<int>(number);
|
|
54
|
+
if (number != integer) {
|
|
55
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
56
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
59
57
|
return false;
|
|
60
58
|
}
|
|
61
59
|
// Check if we are within the bounds of the enum.
|
|
62
|
-
return integer >=
|
|
60
|
+
return integer >= 1 && integer <= 4;
|
|
63
61
|
}
|
|
64
62
|
};
|
|
65
63
|
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include <cmath>
|
|
11
10
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
12
11
|
#include <NitroModules/JSIConverter.hpp>
|
|
13
12
|
#else
|
|
@@ -34,16 +33,14 @@ namespace margelo::nitro::healthkit {
|
|
|
34
33
|
|
|
35
34
|
namespace margelo::nitro {
|
|
36
35
|
|
|
37
|
-
using namespace margelo::nitro::healthkit;
|
|
38
|
-
|
|
39
36
|
// C++ WheelchairUse <> JS WheelchairUse (enum)
|
|
40
37
|
template <>
|
|
41
|
-
struct JSIConverter<WheelchairUse> final {
|
|
42
|
-
static inline WheelchairUse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
38
|
+
struct JSIConverter<margelo::nitro::healthkit::WheelchairUse> final {
|
|
39
|
+
static inline margelo::nitro::healthkit::WheelchairUse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
43
40
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
44
|
-
return static_cast<WheelchairUse>(enumValue);
|
|
41
|
+
return static_cast<margelo::nitro::healthkit::WheelchairUse>(enumValue);
|
|
45
42
|
}
|
|
46
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, WheelchairUse arg) {
|
|
43
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::WheelchairUse arg) {
|
|
47
44
|
int enumValue = static_cast<int>(arg);
|
|
48
45
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
49
46
|
}
|
|
@@ -51,10 +48,11 @@ namespace margelo::nitro {
|
|
|
51
48
|
if (!value.isNumber()) {
|
|
52
49
|
return false;
|
|
53
50
|
}
|
|
54
|
-
double
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
//
|
|
51
|
+
double number = value.getNumber();
|
|
52
|
+
int integer = static_cast<int>(number);
|
|
53
|
+
if (number != integer) {
|
|
54
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
55
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
58
56
|
return false;
|
|
59
57
|
}
|
|
60
58
|
// Check if we are within the bounds of the enum.
|
|
@@ -44,21 +44,19 @@ namespace margelo::nitro::healthkit {
|
|
|
44
44
|
|
|
45
45
|
namespace margelo::nitro {
|
|
46
46
|
|
|
47
|
-
using namespace margelo::nitro::healthkit;
|
|
48
|
-
|
|
49
47
|
// C++ WorkoutActivity <> JS WorkoutActivity (object)
|
|
50
48
|
template <>
|
|
51
|
-
struct JSIConverter<WorkoutActivity> final {
|
|
52
|
-
static inline WorkoutActivity fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
49
|
+
struct JSIConverter<margelo::nitro::healthkit::WorkoutActivity> final {
|
|
50
|
+
static inline margelo::nitro::healthkit::WorkoutActivity fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
51
|
jsi::Object obj = arg.asObject(runtime);
|
|
54
|
-
return WorkoutActivity(
|
|
52
|
+
return margelo::nitro::healthkit::WorkoutActivity(
|
|
55
53
|
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "startDate")),
|
|
56
54
|
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "endDate")),
|
|
57
55
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "uuid")),
|
|
58
56
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "duration"))
|
|
59
57
|
);
|
|
60
58
|
}
|
|
61
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutActivity& arg) {
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutActivity& arg) {
|
|
62
60
|
jsi::Object obj(runtime);
|
|
63
61
|
obj.setProperty(runtime, "startDate", JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.startDate));
|
|
64
62
|
obj.setProperty(runtime, "endDate", JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.endDate));
|