@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.
Files changed (220) hide show
  1. package/ios/CoreModule.swift +5 -15
  2. package/ios/CorrelationTypeModule.swift +8 -2
  3. package/ios/Helpers.swift +50 -6
  4. package/ios/QuantityTypeModule.swift +72 -112
  5. package/ios/Serializers.swift +39 -66
  6. package/ios/WorkoutProxy.swift +38 -20
  7. package/ios/WorkoutsModule.swift +7 -18
  8. package/lib/commonjs/healthkit.js +1 -1
  9. package/lib/commonjs/hooks/useMostRecentWorkout.js +2 -9
  10. package/lib/commonjs/hooks/useWorkoutById.js +1 -4
  11. package/lib/commonjs/utils/getMostRecentWorkout.js +1 -3
  12. package/lib/commonjs/utils/getWorkoutById.js +1 -3
  13. package/lib/module/healthkit.js +1 -1
  14. package/lib/module/hooks/useMostRecentWorkout.js +3 -10
  15. package/lib/module/hooks/useWorkoutById.js +1 -4
  16. package/lib/module/utils/getMostRecentWorkout.js +1 -3
  17. package/lib/module/utils/getWorkoutById.js +1 -3
  18. package/lib/typescript/healthkit.d.ts +5 -5
  19. package/lib/typescript/healthkit.ios.d.ts +1 -1
  20. package/lib/typescript/hooks/useMostRecentWorkout.d.ts +1 -4
  21. package/lib/typescript/specs/WorkoutProxy.nitro.d.ts +11 -0
  22. package/lib/typescript/types/CorrelationType.d.ts +1 -0
  23. package/lib/typescript/types/QuantityType.d.ts +2 -0
  24. package/lib/typescript/types/QueryOptions.d.ts +4 -0
  25. package/lib/typescript/types/Workouts.d.ts +0 -8
  26. package/lib/typescript/utils/getMostRecentWorkout.d.ts +1 -2
  27. package/lib/typescript/utils/getWorkoutById.d.ts +1 -2
  28. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.cpp +103 -87
  29. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +798 -481
  30. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +3 -0
  31. package/nitrogen/generated/ios/ReactNativeHealthkitAutolinking.mm +8 -8
  32. package/nitrogen/generated/ios/ReactNativeHealthkitAutolinking.swift +16 -16
  33. package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +9 -4
  34. package/nitrogen/generated/ios/c++/HybridCharacteristicTypeModuleSpecSwift.hpp +4 -2
  35. package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +10 -5
  36. package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +6 -4
  37. package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +10 -5
  38. package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +7 -2
  39. package/nitrogen/generated/ios/c++/HybridSourceProxySpecSwift.hpp +3 -1
  40. package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +10 -5
  41. package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +50 -22
  42. package/nitrogen/generated/ios/c++/HybridWorkoutsModuleSpecSwift.hpp +12 -7
  43. package/nitrogen/generated/ios/swift/CategorySample.swift +4 -2
  44. package/nitrogen/generated/ios/swift/CategorySampleForSaving.swift +2 -1
  45. package/nitrogen/generated/ios/swift/CorrelationObject.swift +2 -0
  46. package/nitrogen/generated/ios/swift/CorrelationSample.swift +13 -2
  47. package/nitrogen/generated/ios/swift/DeletedSample.swift +2 -1
  48. package/nitrogen/generated/ios/swift/Device.swift +16 -8
  49. package/nitrogen/generated/ios/swift/FilterForSamples.swift +2 -0
  50. package/nitrogen/generated/ios/swift/Func_void_AuthorizationRequestStatus.swift +1 -0
  51. package/nitrogen/generated/ios/swift/Func_void_BiologicalSex.swift +1 -0
  52. package/nitrogen/generated/ios/swift/Func_void_BloodType.swift +1 -0
  53. package/nitrogen/generated/ios/swift/Func_void_CategorySamplesWithAnchorResponse.swift +1 -0
  54. package/nitrogen/generated/ios/swift/Func_void_FitzpatrickSkinType.swift +1 -0
  55. package/nitrogen/generated/ios/swift/Func_void_HeartbeatSeriesSamplesWithAnchorResponse.swift +1 -0
  56. package/nitrogen/generated/ios/swift/Func_void_OnChangeCallbackArgs.swift +1 -0
  57. package/nitrogen/generated/ios/swift/Func_void_QuantitySamplesWithAnchorResponse.swift +1 -0
  58. package/nitrogen/generated/ios/swift/Func_void_QueryStatisticsResponse.swift +1 -0
  59. package/nitrogen/generated/ios/swift/Func_void_QueryWorkoutSamplesWithAnchorResponse.swift +1 -0
  60. package/nitrogen/generated/ios/swift/Func_void_WheelchairUse.swift +1 -0
  61. package/nitrogen/generated/ios/swift/Func_void_bool.swift +1 -0
  62. package/nitrogen/generated/ios/swift/Func_void_double.swift +1 -0
  63. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -0
  64. package/nitrogen/generated/ios/swift/Func_void_std__optional_QueryStatisticsResponse_.swift +54 -0
  65. package/nitrogen/generated/ios/swift/Func_void_std__optional_WorkoutPlan_.swift +3 -1
  66. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__chrono__system_clock__time_point_.swift +3 -1
  67. package/nitrogen/generated/ios/swift/{Func_void_std__shared_ptr_margelo__nitro__healthkit__HybridWorkoutProxySpec_.swift → Func_void_std__shared_ptr_HybridWorkoutProxySpec_.swift} +9 -8
  68. package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__QueryStatisticsResponse_.swift +55 -0
  69. package/nitrogen/generated/ios/swift/Func_void_std__unordered_map_std__string__bool_.swift +2 -1
  70. package/nitrogen/generated/ios/swift/Func_void_std__vector_CategorySample_.swift +1 -0
  71. package/nitrogen/generated/ios/swift/Func_void_std__vector_CorrelationSample_.swift +1 -0
  72. package/nitrogen/generated/ios/swift/Func_void_std__vector_HeartbeatSeriesSample_.swift +1 -0
  73. package/nitrogen/generated/ios/swift/Func_void_std__vector_IdentifierWithUnit_.swift +1 -0
  74. package/nitrogen/generated/ios/swift/Func_void_std__vector_QuantitySample_.swift +1 -0
  75. package/nitrogen/generated/ios/swift/Func_void_std__vector_QueryStatisticsResponse_.swift +1 -0
  76. package/nitrogen/generated/ios/swift/Func_void_std__vector_StateOfMindSample_.swift +1 -0
  77. package/nitrogen/generated/ios/swift/Func_void_std__vector_WorkoutRoute_.swift +1 -0
  78. 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
  79. 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
  80. package/nitrogen/generated/ios/swift/HeartbeatSeriesSample.swift +6 -3
  81. package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec.swift +2 -1
  82. package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec_cxx.swift +17 -7
  83. package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec.swift +2 -1
  84. package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec_cxx.swift +15 -6
  85. package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +2 -1
  86. package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +24 -15
  87. package/nitrogen/generated/ios/swift/HybridCorrelationTypeModuleSpec.swift +2 -1
  88. package/nitrogen/generated/ios/swift/HybridCorrelationTypeModuleSpec_cxx.swift +15 -6
  89. package/nitrogen/generated/ios/swift/HybridHeartbeatSeriesModuleSpec.swift +2 -1
  90. package/nitrogen/generated/ios/swift/HybridHeartbeatSeriesModuleSpec_cxx.swift +17 -7
  91. package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec.swift +2 -1
  92. package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec_cxx.swift +21 -9
  93. package/nitrogen/generated/ios/swift/HybridSourceProxySpec.swift +2 -1
  94. package/nitrogen/generated/ios/swift/HybridSourceProxySpec_cxx.swift +17 -7
  95. package/nitrogen/generated/ios/swift/HybridStateOfMindModuleSpec.swift +2 -1
  96. package/nitrogen/generated/ios/swift/HybridStateOfMindModuleSpec_cxx.swift +19 -8
  97. package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec.swift +8 -5
  98. package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec_cxx.swift +108 -41
  99. package/nitrogen/generated/ios/swift/HybridWorkoutsModuleSpec.swift +2 -1
  100. package/nitrogen/generated/ios/swift/HybridWorkoutsModuleSpec_cxx.swift +31 -22
  101. package/nitrogen/generated/ios/swift/OnChangeCallbackArgs.swift +2 -1
  102. package/nitrogen/generated/ios/swift/PredicateForSamples.swift +2 -0
  103. package/nitrogen/generated/ios/swift/PredicateForWorkouts.swift +2 -0
  104. package/nitrogen/generated/ios/swift/PredicateFromWorkout.swift +3 -3
  105. package/nitrogen/generated/ios/swift/PredicateWithMetadataKey.swift +95 -2
  106. package/nitrogen/generated/ios/swift/PredicateWithMetadataOperator.swift +48 -0
  107. package/nitrogen/generated/ios/swift/PredicateWithStartAndEnd.swift +4 -2
  108. package/nitrogen/generated/ios/swift/QuantitySample.swift +4 -2
  109. package/nitrogen/generated/ios/swift/QuantitySampleForSaving.swift +2 -1
  110. package/nitrogen/generated/ios/swift/QueryOptionsWithAnchor.swift +4 -2
  111. package/nitrogen/generated/ios/swift/QueryOptionsWithAnchorAndUnit.swift +6 -3
  112. package/nitrogen/generated/ios/swift/QueryOptionsWithSortOrder.swift +2 -1
  113. package/nitrogen/generated/ios/swift/QueryOptionsWithSortOrderAndUnit.swift +4 -2
  114. package/nitrogen/generated/ios/swift/QueryStatisticsResponse.swift +75 -8
  115. package/nitrogen/generated/ios/swift/QueryWorkoutSamplesWithAnchorResponse.swift +7 -7
  116. package/nitrogen/generated/ios/swift/SampleForSaving.swift +2 -0
  117. package/nitrogen/generated/ios/swift/SourceRevision.swift +13 -9
  118. package/nitrogen/generated/ios/swift/StateOfMindSample.swift +6 -3
  119. package/nitrogen/generated/ios/swift/StatisticsQueryOptions.swift +4 -2
  120. package/nitrogen/generated/ios/swift/Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_FilterForSamplesAnd_FilterForSamplesOr.swift +2 -0
  121. package/nitrogen/generated/ios/swift/Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_WorkoutActivityTypePredicate_WorkoutDurationPredicate_PredicateForWorkoutsOr_PredicateForWorkoutsAnd.swift +2 -0
  122. package/nitrogen/generated/ios/swift/Variant_String_Double_Bool_Date.swift +20 -0
  123. package/nitrogen/generated/ios/swift/WorkoutQueryOptions.swift +4 -61
  124. package/nitrogen/generated/ios/swift/WorkoutQueryOptionsWithAnchor.swift +6 -62
  125. package/nitrogen/generated/ios/swift/WorkoutRoute.swift +2 -1
  126. package/nitrogen/generated/ios/swift/WorkoutSample.swift +12 -123
  127. package/nitrogen/generated/shared/c++/AuthorizationRequestStatus.hpp +9 -11
  128. package/nitrogen/generated/shared/c++/AuthorizationStatus.hpp +9 -11
  129. package/nitrogen/generated/shared/c++/BiologicalSex.hpp +9 -11
  130. package/nitrogen/generated/shared/c++/BloodType.hpp +9 -11
  131. package/nitrogen/generated/shared/c++/CategorySample.hpp +14 -16
  132. package/nitrogen/generated/shared/c++/CategorySampleForSaving.hpp +11 -13
  133. package/nitrogen/generated/shared/c++/CategorySamplesWithAnchorResponse.hpp +11 -13
  134. package/nitrogen/generated/shared/c++/CategoryTypeIdentifier.hpp +131 -133
  135. package/nitrogen/generated/shared/c++/ComparisonPredicateOperator.hpp +26 -13
  136. package/nitrogen/generated/shared/c++/CorrelationSample.hpp +18 -15
  137. package/nitrogen/generated/shared/c++/CorrelationTypeIdentifier.hpp +7 -9
  138. package/nitrogen/generated/shared/c++/DeletedSample.hpp +5 -7
  139. package/nitrogen/generated/shared/c++/Device.hpp +5 -7
  140. package/nitrogen/generated/shared/c++/FilterForSamplesAnd.hpp +9 -11
  141. package/nitrogen/generated/shared/c++/FilterForSamplesOr.hpp +9 -11
  142. package/nitrogen/generated/shared/c++/FitzpatrickSkinType.hpp +9 -11
  143. package/nitrogen/generated/shared/c++/Heartbeat.hpp +4 -6
  144. package/nitrogen/generated/shared/c++/HeartbeatSeriesSample.hpp +15 -17
  145. package/nitrogen/generated/shared/c++/HeartbeatSeriesSamplesWithAnchorResponse.hpp +11 -13
  146. package/nitrogen/generated/shared/c++/HybridCategoryTypeModuleSpec.hpp +2 -2
  147. package/nitrogen/generated/shared/c++/HybridCharacteristicTypeModuleSpec.hpp +1 -1
  148. package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +4 -4
  149. package/nitrogen/generated/shared/c++/HybridCorrelationTypeModuleSpec.hpp +2 -2
  150. package/nitrogen/generated/shared/c++/HybridHeartbeatSeriesModuleSpec.hpp +3 -3
  151. package/nitrogen/generated/shared/c++/HybridQuantityTypeModuleSpec.hpp +3 -3
  152. package/nitrogen/generated/shared/c++/HybridStateOfMindModuleSpec.hpp +3 -3
  153. package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.cpp +6 -4
  154. package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.hpp +18 -9
  155. package/nitrogen/generated/shared/c++/HybridWorkoutsModuleSpec.hpp +4 -4
  156. package/nitrogen/generated/shared/c++/IdentifierWithUnit.hpp +4 -6
  157. package/nitrogen/generated/shared/c++/IntervalComponents.hpp +4 -6
  158. package/nitrogen/generated/shared/c++/LocationForSaving.hpp +4 -6
  159. package/nitrogen/generated/shared/c++/ObjectTypeIdentifier.hpp +397 -399
  160. package/nitrogen/generated/shared/c++/OnChangeCallbackArgs.hpp +8 -10
  161. package/nitrogen/generated/shared/c++/PredicateForWorkoutsAnd.hpp +9 -11
  162. package/nitrogen/generated/shared/c++/PredicateForWorkoutsOr.hpp +9 -11
  163. package/nitrogen/generated/shared/c++/PredicateFromWorkout.hpp +6 -8
  164. package/nitrogen/generated/shared/c++/PredicateWithMetadataKey.hpp +20 -9
  165. package/nitrogen/generated/shared/c++/PredicateWithMetadataOperator.hpp +84 -0
  166. package/nitrogen/generated/shared/c++/PredicateWithStartAndEnd.hpp +5 -7
  167. package/nitrogen/generated/shared/c++/PredicateWithUUID.hpp +4 -6
  168. package/nitrogen/generated/shared/c++/PredicateWithUUIDs.hpp +5 -7
  169. package/nitrogen/generated/shared/c++/Quantity.hpp +4 -6
  170. package/nitrogen/generated/shared/c++/QuantityDateInterval.hpp +4 -6
  171. package/nitrogen/generated/shared/c++/QuantitySample.hpp +14 -16
  172. package/nitrogen/generated/shared/c++/QuantitySampleForSaving.hpp +11 -13
  173. package/nitrogen/generated/shared/c++/QuantitySamplesWithAnchorResponse.hpp +11 -13
  174. package/nitrogen/generated/shared/c++/QuantityTypeIdentifier.hpp +241 -243
  175. package/nitrogen/generated/shared/c++/QueryOptionsWithAnchor.hpp +9 -11
  176. package/nitrogen/generated/shared/c++/QueryOptionsWithAnchorAndUnit.hpp +9 -11
  177. package/nitrogen/generated/shared/c++/QueryOptionsWithSortOrder.hpp +8 -10
  178. package/nitrogen/generated/shared/c++/QueryOptionsWithSortOrderAndUnit.hpp +9 -11
  179. package/nitrogen/generated/shared/c++/QueryStatisticsResponse.hpp +36 -29
  180. package/nitrogen/generated/shared/c++/QueryWorkoutSamplesWithAnchorResponse.hpp +10 -12
  181. package/nitrogen/generated/shared/c++/SampleTypeIdentifier.hpp +383 -385
  182. package/nitrogen/generated/shared/c++/SampleTypeIdentifierWriteable.hpp +373 -375
  183. package/nitrogen/generated/shared/c++/Source.hpp +4 -6
  184. package/nitrogen/generated/shared/c++/SourceRevision.hpp +7 -9
  185. package/nitrogen/generated/shared/c++/StateOfMindAssociation.hpp +10 -12
  186. package/nitrogen/generated/shared/c++/StateOfMindKind.hpp +14 -13
  187. package/nitrogen/generated/shared/c++/StateOfMindLabel.hpp +10 -12
  188. package/nitrogen/generated/shared/c++/StateOfMindSample.hpp +24 -26
  189. package/nitrogen/generated/shared/c++/StateOfMindValenceClassification.hpp +10 -12
  190. package/nitrogen/generated/shared/c++/StatisticsOptions.hpp +17 -19
  191. package/nitrogen/generated/shared/c++/StatisticsQueryOptions.hpp +9 -11
  192. package/nitrogen/generated/shared/c++/UpdateFrequency.hpp +10 -12
  193. package/nitrogen/generated/shared/c++/WheelchairUse.hpp +9 -11
  194. package/nitrogen/generated/shared/c++/WorkoutActivity.hpp +4 -6
  195. package/nitrogen/generated/shared/c++/WorkoutActivityType.hpp +96 -13
  196. package/nitrogen/generated/shared/c++/WorkoutActivityTypePredicate.hpp +7 -9
  197. package/nitrogen/generated/shared/c++/WorkoutConfiguration.hpp +11 -13
  198. package/nitrogen/generated/shared/c++/WorkoutDurationPredicate.hpp +7 -9
  199. package/nitrogen/generated/shared/c++/WorkoutEvent.hpp +7 -9
  200. package/nitrogen/generated/shared/c++/WorkoutEventType.hpp +10 -12
  201. package/nitrogen/generated/shared/c++/WorkoutPlan.hpp +7 -9
  202. package/nitrogen/generated/shared/c++/WorkoutQueryOptions.hpp +10 -21
  203. package/nitrogen/generated/shared/c++/WorkoutQueryOptionsWithAnchor.hpp +11 -21
  204. package/nitrogen/generated/shared/c++/WorkoutRoute.hpp +9 -11
  205. package/nitrogen/generated/shared/c++/WorkoutRouteLocation.hpp +4 -6
  206. package/nitrogen/generated/shared/c++/WorkoutSample.hpp +25 -43
  207. package/nitrogen/generated/shared/c++/WorkoutSessionLocationType.hpp +10 -12
  208. package/nitrogen/generated/shared/c++/WorkoutTotals.hpp +4 -6
  209. package/package.json +11 -11
  210. package/src/healthkit.ts +5 -1
  211. package/src/hooks/queryStatisticsForQuantity.test.ts +32 -0
  212. package/src/hooks/useMostRecentWorkout.ts +3 -17
  213. package/src/hooks/useWorkoutById.ts +1 -4
  214. package/src/specs/WorkoutProxy.nitro.ts +18 -1
  215. package/src/types/CorrelationType.ts +1 -0
  216. package/src/types/QuantityType.ts +2 -0
  217. package/src/types/QueryOptions.ts +10 -0
  218. package/src/types/Workouts.ts +0 -8
  219. package/src/utils/getMostRecentWorkout.ts +1 -6
  220. package/src/utils/getWorkoutById.ts +1 -6
@@ -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
@@ -115,16 +114,14 @@ namespace margelo::nitro::healthkit {
115
114
 
116
115
  namespace margelo::nitro {
117
116
 
118
- using namespace margelo::nitro::healthkit;
119
-
120
117
  // C++ WorkoutActivityType <> JS WorkoutActivityType (enum)
121
118
  template <>
122
- struct JSIConverter<WorkoutActivityType> final {
123
- static inline WorkoutActivityType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
119
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutActivityType> final {
120
+ static inline margelo::nitro::healthkit::WorkoutActivityType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
124
121
  int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
125
- return static_cast<WorkoutActivityType>(enumValue);
122
+ return static_cast<margelo::nitro::healthkit::WorkoutActivityType>(enumValue);
126
123
  }
127
- static inline jsi::Value toJSI(jsi::Runtime& runtime, WorkoutActivityType arg) {
124
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::WorkoutActivityType arg) {
128
125
  int enumValue = static_cast<int>(arg);
129
126
  return JSIConverter<int>::toJSI(runtime, enumValue);
130
127
  }
@@ -132,14 +129,100 @@ namespace margelo::nitro {
132
129
  if (!value.isNumber()) {
133
130
  return false;
134
131
  }
135
- double integer;
136
- double fraction = modf(value.getNumber(), &integer);
137
- if (fraction != 0.0) {
138
- // It is some kind of floating point number - our enums are ints.
132
+ double number = value.getNumber();
133
+ int integer = static_cast<int>(number);
134
+ if (number != integer) {
135
+ // The integer is not the same value as the double - we truncated floating points.
136
+ // Enums are all integers, so the input floating point number is obviously invalid.
139
137
  return false;
140
138
  }
141
- // Check if we are within the bounds of the enum.
142
- return integer >= 0 && integer <= 83;
139
+ switch (integer) {
140
+ case 1 /* AMERICANFOOTBALL */: return true;
141
+ case 2 /* ARCHERY */: return true;
142
+ case 3 /* AUSTRALIANFOOTBALL */: return true;
143
+ case 4 /* BADMINTON */: return true;
144
+ case 5 /* BASEBALL */: return true;
145
+ case 6 /* BASKETBALL */: return true;
146
+ case 7 /* BOWLING */: return true;
147
+ case 8 /* BOXING */: return true;
148
+ case 9 /* CLIMBING */: return true;
149
+ case 10 /* CRICKET */: return true;
150
+ case 11 /* CROSSTRAINING */: return true;
151
+ case 12 /* CURLING */: return true;
152
+ case 13 /* CYCLING */: return true;
153
+ case 14 /* DANCE */: return true;
154
+ case 15 /* DANCEINSPIREDTRAINING */: return true;
155
+ case 16 /* ELLIPTICAL */: return true;
156
+ case 17 /* EQUESTRIANSPORTS */: return true;
157
+ case 18 /* FENCING */: return true;
158
+ case 19 /* FISHING */: return true;
159
+ case 20 /* FUNCTIONALSTRENGTHTRAINING */: return true;
160
+ case 21 /* GOLF */: return true;
161
+ case 22 /* GYMNASTICS */: return true;
162
+ case 23 /* HANDBALL */: return true;
163
+ case 24 /* HIKING */: return true;
164
+ case 25 /* HOCKEY */: return true;
165
+ case 26 /* HUNTING */: return true;
166
+ case 27 /* LACROSSE */: return true;
167
+ case 28 /* MARTIALARTS */: return true;
168
+ case 29 /* MINDANDBODY */: return true;
169
+ case 30 /* MIXEDMETABOLICCARDIOTRAINING */: return true;
170
+ case 31 /* PADDLESPORTS */: return true;
171
+ case 32 /* PLAY */: return true;
172
+ case 33 /* PREPARATIONANDRECOVERY */: return true;
173
+ case 34 /* RACQUETBALL */: return true;
174
+ case 35 /* ROWING */: return true;
175
+ case 36 /* RUGBY */: return true;
176
+ case 37 /* RUNNING */: return true;
177
+ case 38 /* SAILING */: return true;
178
+ case 39 /* SKATINGSPORTS */: return true;
179
+ case 40 /* SNOWSPORTS */: return true;
180
+ case 41 /* SOCCER */: return true;
181
+ case 42 /* SOFTBALL */: return true;
182
+ case 43 /* SQUASH */: return true;
183
+ case 44 /* STAIRCLIMBING */: return true;
184
+ case 45 /* SURFINGSPORTS */: return true;
185
+ case 46 /* SWIMMING */: return true;
186
+ case 47 /* TABLETENNIS */: return true;
187
+ case 48 /* TENNIS */: return true;
188
+ case 49 /* TRACKANDFIELD */: return true;
189
+ case 50 /* TRADITIONALSTRENGTHTRAINING */: return true;
190
+ case 51 /* VOLLEYBALL */: return true;
191
+ case 52 /* WALKING */: return true;
192
+ case 53 /* WATERFITNESS */: return true;
193
+ case 54 /* WATERPOLO */: return true;
194
+ case 55 /* WATERSPORTS */: return true;
195
+ case 56 /* WRESTLING */: return true;
196
+ case 57 /* YOGA */: return true;
197
+ case 58 /* BARRE */: return true;
198
+ case 59 /* CORETRAINING */: return true;
199
+ case 60 /* CROSSCOUNTRYSKIING */: return true;
200
+ case 61 /* DOWNHILLSKIING */: return true;
201
+ case 62 /* FLEXIBILITY */: return true;
202
+ case 63 /* HIGHINTENSITYINTERVALTRAINING */: return true;
203
+ case 64 /* JUMPROPE */: return true;
204
+ case 65 /* KICKBOXING */: return true;
205
+ case 66 /* PILATES */: return true;
206
+ case 67 /* SNOWBOARDING */: return true;
207
+ case 68 /* STAIRS */: return true;
208
+ case 69 /* STEPTRAINING */: return true;
209
+ case 70 /* WHEELCHAIRWALKPACE */: return true;
210
+ case 71 /* WHEELCHAIRRUNPACE */: return true;
211
+ case 72 /* TAICHI */: return true;
212
+ case 73 /* MIXEDCARDIO */: return true;
213
+ case 74 /* HANDCYCLING */: return true;
214
+ case 75 /* DISCSPORTS */: return true;
215
+ case 76 /* FITNESSGAMING */: return true;
216
+ case 77 /* CARDIODANCE */: return true;
217
+ case 78 /* SOCIALDANCE */: return true;
218
+ case 79 /* PICKLEBALL */: return true;
219
+ case 80 /* COOLDOWN */: return true;
220
+ case 82 /* SWIMBIKERUN */: return true;
221
+ case 83 /* TRANSITION */: return true;
222
+ case 84 /* UNDERWATERDIVING */: return true;
223
+ case 3000 /* OTHER */: return true;
224
+ default: return false;
225
+ }
143
226
  }
144
227
  };
145
228
 
@@ -41,20 +41,18 @@ namespace margelo::nitro::healthkit {
41
41
 
42
42
  namespace margelo::nitro {
43
43
 
44
- using namespace margelo::nitro::healthkit;
45
-
46
44
  // C++ WorkoutActivityTypePredicate <> JS WorkoutActivityTypePredicate (object)
47
45
  template <>
48
- struct JSIConverter<WorkoutActivityTypePredicate> final {
49
- static inline WorkoutActivityTypePredicate fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutActivityTypePredicate> final {
47
+ static inline margelo::nitro::healthkit::WorkoutActivityTypePredicate fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
50
48
  jsi::Object obj = arg.asObject(runtime);
51
- return WorkoutActivityTypePredicate(
52
- JSIConverter<WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, "workoutActivityType"))
49
+ return margelo::nitro::healthkit::WorkoutActivityTypePredicate(
50
+ JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, "workoutActivityType"))
53
51
  );
54
52
  }
55
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutActivityTypePredicate& arg) {
53
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutActivityTypePredicate& arg) {
56
54
  jsi::Object obj(runtime);
57
- obj.setProperty(runtime, "workoutActivityType", JSIConverter<WorkoutActivityType>::toJSI(runtime, arg.workoutActivityType));
55
+ obj.setProperty(runtime, "workoutActivityType", JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::toJSI(runtime, arg.workoutActivityType));
58
56
  return obj;
59
57
  }
60
58
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -62,7 +60,7 @@ namespace margelo::nitro {
62
60
  return false;
63
61
  }
64
62
  jsi::Object obj = value.getObject(runtime);
65
- if (!JSIConverter<WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, "workoutActivityType"))) return false;
63
+ if (!JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, "workoutActivityType"))) return false;
66
64
  return true;
67
65
  }
68
66
  };
@@ -24,8 +24,8 @@ namespace margelo::nitro::healthkit { enum class WorkoutActivityType; }
24
24
  namespace margelo::nitro::healthkit { enum class WorkoutSessionLocationType; }
25
25
 
26
26
  #include "WorkoutActivityType.hpp"
27
- #include <optional>
28
27
  #include "WorkoutSessionLocationType.hpp"
28
+ #include <optional>
29
29
 
30
30
  namespace margelo::nitro::healthkit {
31
31
 
@@ -46,22 +46,20 @@ namespace margelo::nitro::healthkit {
46
46
 
47
47
  namespace margelo::nitro {
48
48
 
49
- using namespace margelo::nitro::healthkit;
50
-
51
49
  // C++ WorkoutConfiguration <> JS WorkoutConfiguration (object)
52
50
  template <>
53
- struct JSIConverter<WorkoutConfiguration> final {
54
- static inline WorkoutConfiguration fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
51
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutConfiguration> final {
52
+ static inline margelo::nitro::healthkit::WorkoutConfiguration fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
53
  jsi::Object obj = arg.asObject(runtime);
56
- return WorkoutConfiguration(
57
- JSIConverter<WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, "activityType")),
58
- JSIConverter<std::optional<WorkoutSessionLocationType>>::fromJSI(runtime, obj.getProperty(runtime, "locationType"))
54
+ return margelo::nitro::healthkit::WorkoutConfiguration(
55
+ JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, "activityType")),
56
+ JSIConverter<std::optional<margelo::nitro::healthkit::WorkoutSessionLocationType>>::fromJSI(runtime, obj.getProperty(runtime, "locationType"))
59
57
  );
60
58
  }
61
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutConfiguration& arg) {
59
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutConfiguration& arg) {
62
60
  jsi::Object obj(runtime);
63
- obj.setProperty(runtime, "activityType", JSIConverter<WorkoutActivityType>::toJSI(runtime, arg.activityType));
64
- obj.setProperty(runtime, "locationType", JSIConverter<std::optional<WorkoutSessionLocationType>>::toJSI(runtime, arg.locationType));
61
+ obj.setProperty(runtime, "activityType", JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::toJSI(runtime, arg.activityType));
62
+ obj.setProperty(runtime, "locationType", JSIConverter<std::optional<margelo::nitro::healthkit::WorkoutSessionLocationType>>::toJSI(runtime, arg.locationType));
65
63
  return obj;
66
64
  }
67
65
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -69,8 +67,8 @@ namespace margelo::nitro {
69
67
  return false;
70
68
  }
71
69
  jsi::Object obj = value.getObject(runtime);
72
- if (!JSIConverter<WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, "activityType"))) return false;
73
- if (!JSIConverter<std::optional<WorkoutSessionLocationType>>::canConvert(runtime, obj.getProperty(runtime, "locationType"))) return false;
70
+ if (!JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, "activityType"))) return false;
71
+ if (!JSIConverter<std::optional<margelo::nitro::healthkit::WorkoutSessionLocationType>>::canConvert(runtime, obj.getProperty(runtime, "locationType"))) return false;
74
72
  return true;
75
73
  }
76
74
  };
@@ -42,21 +42,19 @@ namespace margelo::nitro::healthkit {
42
42
 
43
43
  namespace margelo::nitro {
44
44
 
45
- using namespace margelo::nitro::healthkit;
46
-
47
45
  // C++ WorkoutDurationPredicate <> JS WorkoutDurationPredicate (object)
48
46
  template <>
49
- struct JSIConverter<WorkoutDurationPredicate> final {
50
- static inline WorkoutDurationPredicate fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
47
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutDurationPredicate> final {
48
+ static inline margelo::nitro::healthkit::WorkoutDurationPredicate fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
51
49
  jsi::Object obj = arg.asObject(runtime);
52
- return WorkoutDurationPredicate(
53
- JSIConverter<ComparisonPredicateOperator>::fromJSI(runtime, obj.getProperty(runtime, "predicateOperator")),
50
+ return margelo::nitro::healthkit::WorkoutDurationPredicate(
51
+ JSIConverter<margelo::nitro::healthkit::ComparisonPredicateOperator>::fromJSI(runtime, obj.getProperty(runtime, "predicateOperator")),
54
52
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "durationInSeconds"))
55
53
  );
56
54
  }
57
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutDurationPredicate& arg) {
55
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutDurationPredicate& arg) {
58
56
  jsi::Object obj(runtime);
59
- obj.setProperty(runtime, "predicateOperator", JSIConverter<ComparisonPredicateOperator>::toJSI(runtime, arg.predicateOperator));
57
+ obj.setProperty(runtime, "predicateOperator", JSIConverter<margelo::nitro::healthkit::ComparisonPredicateOperator>::toJSI(runtime, arg.predicateOperator));
60
58
  obj.setProperty(runtime, "durationInSeconds", JSIConverter<double>::toJSI(runtime, arg.durationInSeconds));
61
59
  return obj;
62
60
  }
@@ -65,7 +63,7 @@ namespace margelo::nitro {
65
63
  return false;
66
64
  }
67
65
  jsi::Object obj = value.getObject(runtime);
68
- if (!JSIConverter<ComparisonPredicateOperator>::canConvert(runtime, obj.getProperty(runtime, "predicateOperator"))) return false;
66
+ if (!JSIConverter<margelo::nitro::healthkit::ComparisonPredicateOperator>::canConvert(runtime, obj.getProperty(runtime, "predicateOperator"))) return false;
69
67
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "durationInSeconds"))) return false;
70
68
  return true;
71
69
  }
@@ -44,22 +44,20 @@ namespace margelo::nitro::healthkit {
44
44
 
45
45
  namespace margelo::nitro {
46
46
 
47
- using namespace margelo::nitro::healthkit;
48
-
49
47
  // C++ WorkoutEvent <> JS WorkoutEvent (object)
50
48
  template <>
51
- struct JSIConverter<WorkoutEvent> final {
52
- static inline WorkoutEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutEvent> final {
50
+ static inline margelo::nitro::healthkit::WorkoutEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
53
51
  jsi::Object obj = arg.asObject(runtime);
54
- return WorkoutEvent(
55
- JSIConverter<WorkoutEventType>::fromJSI(runtime, obj.getProperty(runtime, "type")),
52
+ return margelo::nitro::healthkit::WorkoutEvent(
53
+ JSIConverter<margelo::nitro::healthkit::WorkoutEventType>::fromJSI(runtime, obj.getProperty(runtime, "type")),
56
54
  JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "startDate")),
57
55
  JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, "endDate"))
58
56
  );
59
57
  }
60
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutEvent& arg) {
58
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutEvent& arg) {
61
59
  jsi::Object obj(runtime);
62
- obj.setProperty(runtime, "type", JSIConverter<WorkoutEventType>::toJSI(runtime, arg.type));
60
+ obj.setProperty(runtime, "type", JSIConverter<margelo::nitro::healthkit::WorkoutEventType>::toJSI(runtime, arg.type));
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));
65
63
  return obj;
@@ -69,7 +67,7 @@ namespace margelo::nitro {
69
67
  return false;
70
68
  }
71
69
  jsi::Object obj = value.getObject(runtime);
72
- if (!JSIConverter<WorkoutEventType>::canConvert(runtime, obj.getProperty(runtime, "type"))) return false;
70
+ if (!JSIConverter<margelo::nitro::healthkit::WorkoutEventType>::canConvert(runtime, obj.getProperty(runtime, "type"))) return false;
73
71
  if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, "startDate"))) return false;
74
72
  if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, "endDate"))) return false;
75
73
  return true;
@@ -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
@@ -39,16 +38,14 @@ namespace margelo::nitro::healthkit {
39
38
 
40
39
  namespace margelo::nitro {
41
40
 
42
- using namespace margelo::nitro::healthkit;
43
-
44
41
  // C++ WorkoutEventType <> JS WorkoutEventType (enum)
45
42
  template <>
46
- struct JSIConverter<WorkoutEventType> final {
47
- static inline WorkoutEventType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
43
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutEventType> final {
44
+ static inline margelo::nitro::healthkit::WorkoutEventType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
45
  int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
49
- return static_cast<WorkoutEventType>(enumValue);
46
+ return static_cast<margelo::nitro::healthkit::WorkoutEventType>(enumValue);
50
47
  }
51
- static inline jsi::Value toJSI(jsi::Runtime& runtime, WorkoutEventType arg) {
48
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::WorkoutEventType arg) {
52
49
  int enumValue = static_cast<int>(arg);
53
50
  return JSIConverter<int>::toJSI(runtime, enumValue);
54
51
  }
@@ -56,14 +53,15 @@ namespace margelo::nitro {
56
53
  if (!value.isNumber()) {
57
54
  return false;
58
55
  }
59
- double integer;
60
- double fraction = modf(value.getNumber(), &integer);
61
- if (fraction != 0.0) {
62
- // It is some kind of floating point number - our enums are ints.
56
+ double number = value.getNumber();
57
+ int integer = static_cast<int>(number);
58
+ if (number != integer) {
59
+ // The integer is not the same value as the double - we truncated floating points.
60
+ // Enums are all integers, so the input floating point number is obviously invalid.
63
61
  return false;
64
62
  }
65
63
  // Check if we are within the bounds of the enum.
66
- return integer >= 0 && integer <= 7;
64
+ return integer >= 1 && integer <= 8;
67
65
  }
68
66
  };
69
67
 
@@ -43,22 +43,20 @@ namespace margelo::nitro::healthkit {
43
43
 
44
44
  namespace margelo::nitro {
45
45
 
46
- using namespace margelo::nitro::healthkit;
47
-
48
46
  // C++ WorkoutPlan <> JS WorkoutPlan (object)
49
47
  template <>
50
- struct JSIConverter<WorkoutPlan> final {
51
- static inline WorkoutPlan fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutPlan> final {
49
+ static inline margelo::nitro::healthkit::WorkoutPlan fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
50
  jsi::Object obj = arg.asObject(runtime);
53
- return WorkoutPlan(
51
+ return margelo::nitro::healthkit::WorkoutPlan(
54
52
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "id")),
55
- JSIConverter<WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, "activityType"))
53
+ JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::fromJSI(runtime, obj.getProperty(runtime, "activityType"))
56
54
  );
57
55
  }
58
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutPlan& arg) {
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutPlan& arg) {
59
57
  jsi::Object obj(runtime);
60
58
  obj.setProperty(runtime, "id", JSIConverter<std::string>::toJSI(runtime, arg.id));
61
- obj.setProperty(runtime, "activityType", JSIConverter<WorkoutActivityType>::toJSI(runtime, arg.activityType));
59
+ obj.setProperty(runtime, "activityType", JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::toJSI(runtime, arg.activityType));
62
60
  return obj;
63
61
  }
64
62
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -67,7 +65,7 @@ namespace margelo::nitro {
67
65
  }
68
66
  jsi::Object obj = value.getObject(runtime);
69
67
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "id"))) return false;
70
- if (!JSIConverter<WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, "activityType"))) return false;
68
+ if (!JSIConverter<margelo::nitro::healthkit::WorkoutActivityType>::canConvert(runtime, obj.getProperty(runtime, "activityType"))) return false;
71
69
  return true;
72
70
  }
73
71
  };
@@ -37,9 +37,6 @@ namespace margelo::nitro::healthkit { struct PredicateForWorkoutsOr; }
37
37
  // Forward declaration of `PredicateForWorkoutsAnd` to properly resolve imports.
38
38
  namespace margelo::nitro::healthkit { struct PredicateForWorkoutsAnd; }
39
39
 
40
- #include <optional>
41
- #include <string>
42
- #include <variant>
43
40
  #include "PredicateWithUUID.hpp"
44
41
  #include "PredicateWithUUIDs.hpp"
45
42
  #include "PredicateWithMetadataKey.hpp"
@@ -49,6 +46,8 @@ namespace margelo::nitro::healthkit { struct PredicateForWorkoutsAnd; }
49
46
  #include "WorkoutDurationPredicate.hpp"
50
47
  #include "PredicateForWorkoutsOr.hpp"
51
48
  #include "PredicateForWorkoutsAnd.hpp"
49
+ #include <variant>
50
+ #include <optional>
52
51
 
53
52
  namespace margelo::nitro::healthkit {
54
53
 
@@ -57,41 +56,33 @@ namespace margelo::nitro::healthkit {
57
56
  */
58
57
  struct WorkoutQueryOptions {
59
58
  public:
60
- std::optional<std::string> energyUnit SWIFT_PRIVATE;
61
- std::optional<std::string> distanceUnit SWIFT_PRIVATE;
62
59
  std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>> filter SWIFT_PRIVATE;
63
60
  std::optional<double> limit SWIFT_PRIVATE;
64
61
  std::optional<bool> ascending SWIFT_PRIVATE;
65
62
 
66
63
  public:
67
64
  WorkoutQueryOptions() = default;
68
- explicit WorkoutQueryOptions(std::optional<std::string> energyUnit, std::optional<std::string> distanceUnit, std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>> filter, std::optional<double> limit, std::optional<bool> ascending): energyUnit(energyUnit), distanceUnit(distanceUnit), filter(filter), limit(limit), ascending(ascending) {}
65
+ explicit WorkoutQueryOptions(std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>> filter, std::optional<double> limit, std::optional<bool> ascending): filter(filter), limit(limit), ascending(ascending) {}
69
66
  };
70
67
 
71
68
  } // namespace margelo::nitro::healthkit
72
69
 
73
70
  namespace margelo::nitro {
74
71
 
75
- using namespace margelo::nitro::healthkit;
76
-
77
72
  // C++ WorkoutQueryOptions <> JS WorkoutQueryOptions (object)
78
73
  template <>
79
- struct JSIConverter<WorkoutQueryOptions> final {
80
- static inline WorkoutQueryOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
74
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutQueryOptions> final {
75
+ static inline margelo::nitro::healthkit::WorkoutQueryOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
81
76
  jsi::Object obj = arg.asObject(runtime);
82
- return WorkoutQueryOptions(
83
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "energyUnit")),
84
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "distanceUnit")),
85
- JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>>>::fromJSI(runtime, obj.getProperty(runtime, "filter")),
77
+ return margelo::nitro::healthkit::WorkoutQueryOptions(
78
+ 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::WorkoutActivityTypePredicate, margelo::nitro::healthkit::WorkoutDurationPredicate, margelo::nitro::healthkit::PredicateForWorkoutsOr, margelo::nitro::healthkit::PredicateForWorkoutsAnd>>>::fromJSI(runtime, obj.getProperty(runtime, "filter")),
86
79
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "limit")),
87
80
  JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "ascending"))
88
81
  );
89
82
  }
90
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutQueryOptions& arg) {
83
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutQueryOptions& arg) {
91
84
  jsi::Object obj(runtime);
92
- obj.setProperty(runtime, "energyUnit", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.energyUnit));
93
- obj.setProperty(runtime, "distanceUnit", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.distanceUnit));
94
- obj.setProperty(runtime, "filter", JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>>>::toJSI(runtime, arg.filter));
85
+ 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::WorkoutActivityTypePredicate, margelo::nitro::healthkit::WorkoutDurationPredicate, margelo::nitro::healthkit::PredicateForWorkoutsOr, margelo::nitro::healthkit::PredicateForWorkoutsAnd>>>::toJSI(runtime, arg.filter));
95
86
  obj.setProperty(runtime, "limit", JSIConverter<std::optional<double>>::toJSI(runtime, arg.limit));
96
87
  obj.setProperty(runtime, "ascending", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.ascending));
97
88
  return obj;
@@ -101,9 +92,7 @@ namespace margelo::nitro {
101
92
  return false;
102
93
  }
103
94
  jsi::Object obj = value.getObject(runtime);
104
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "energyUnit"))) return false;
105
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "distanceUnit"))) return false;
106
- if (!JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>>>::canConvert(runtime, obj.getProperty(runtime, "filter"))) return false;
95
+ 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::WorkoutActivityTypePredicate, margelo::nitro::healthkit::WorkoutDurationPredicate, margelo::nitro::healthkit::PredicateForWorkoutsOr, margelo::nitro::healthkit::PredicateForWorkoutsAnd>>>::canConvert(runtime, obj.getProperty(runtime, "filter"))) return false;
107
96
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "limit"))) return false;
108
97
  if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "ascending"))) return false;
109
98
  return true;
@@ -37,9 +37,6 @@ namespace margelo::nitro::healthkit { struct PredicateForWorkoutsOr; }
37
37
  // Forward declaration of `PredicateForWorkoutsAnd` to properly resolve imports.
38
38
  namespace margelo::nitro::healthkit { struct PredicateForWorkoutsAnd; }
39
39
 
40
- #include <optional>
41
- #include <string>
42
- #include <variant>
43
40
  #include "PredicateWithUUID.hpp"
44
41
  #include "PredicateWithUUIDs.hpp"
45
42
  #include "PredicateWithMetadataKey.hpp"
@@ -49,6 +46,9 @@ namespace margelo::nitro::healthkit { struct PredicateForWorkoutsAnd; }
49
46
  #include "WorkoutDurationPredicate.hpp"
50
47
  #include "PredicateForWorkoutsOr.hpp"
51
48
  #include "PredicateForWorkoutsAnd.hpp"
49
+ #include <variant>
50
+ #include <optional>
51
+ #include <string>
52
52
 
53
53
  namespace margelo::nitro::healthkit {
54
54
 
@@ -57,41 +57,33 @@ namespace margelo::nitro::healthkit {
57
57
  */
58
58
  struct WorkoutQueryOptionsWithAnchor {
59
59
  public:
60
- std::optional<std::string> energyUnit SWIFT_PRIVATE;
61
- std::optional<std::string> distanceUnit SWIFT_PRIVATE;
62
60
  std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>> filter SWIFT_PRIVATE;
63
61
  std::optional<double> limit SWIFT_PRIVATE;
64
62
  std::optional<std::string> anchor SWIFT_PRIVATE;
65
63
 
66
64
  public:
67
65
  WorkoutQueryOptionsWithAnchor() = default;
68
- explicit WorkoutQueryOptionsWithAnchor(std::optional<std::string> energyUnit, std::optional<std::string> distanceUnit, std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>> filter, std::optional<double> limit, std::optional<std::string> anchor): energyUnit(energyUnit), distanceUnit(distanceUnit), filter(filter), limit(limit), anchor(anchor) {}
66
+ explicit WorkoutQueryOptionsWithAnchor(std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>> filter, std::optional<double> limit, std::optional<std::string> anchor): filter(filter), limit(limit), anchor(anchor) {}
69
67
  };
70
68
 
71
69
  } // namespace margelo::nitro::healthkit
72
70
 
73
71
  namespace margelo::nitro {
74
72
 
75
- using namespace margelo::nitro::healthkit;
76
-
77
73
  // C++ WorkoutQueryOptionsWithAnchor <> JS WorkoutQueryOptionsWithAnchor (object)
78
74
  template <>
79
- struct JSIConverter<WorkoutQueryOptionsWithAnchor> final {
80
- static inline WorkoutQueryOptionsWithAnchor fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
75
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutQueryOptionsWithAnchor> final {
76
+ static inline margelo::nitro::healthkit::WorkoutQueryOptionsWithAnchor fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
81
77
  jsi::Object obj = arg.asObject(runtime);
82
- return WorkoutQueryOptionsWithAnchor(
83
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "energyUnit")),
84
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "distanceUnit")),
85
- JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>>>::fromJSI(runtime, obj.getProperty(runtime, "filter")),
78
+ return margelo::nitro::healthkit::WorkoutQueryOptionsWithAnchor(
79
+ 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::WorkoutActivityTypePredicate, margelo::nitro::healthkit::WorkoutDurationPredicate, margelo::nitro::healthkit::PredicateForWorkoutsOr, margelo::nitro::healthkit::PredicateForWorkoutsAnd>>>::fromJSI(runtime, obj.getProperty(runtime, "filter")),
86
80
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "limit")),
87
81
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "anchor"))
88
82
  );
89
83
  }
90
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutQueryOptionsWithAnchor& arg) {
84
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutQueryOptionsWithAnchor& arg) {
91
85
  jsi::Object obj(runtime);
92
- obj.setProperty(runtime, "energyUnit", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.energyUnit));
93
- obj.setProperty(runtime, "distanceUnit", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.distanceUnit));
94
- obj.setProperty(runtime, "filter", JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>>>::toJSI(runtime, arg.filter));
86
+ 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::WorkoutActivityTypePredicate, margelo::nitro::healthkit::WorkoutDurationPredicate, margelo::nitro::healthkit::PredicateForWorkoutsOr, margelo::nitro::healthkit::PredicateForWorkoutsAnd>>>::toJSI(runtime, arg.filter));
95
87
  obj.setProperty(runtime, "limit", JSIConverter<std::optional<double>>::toJSI(runtime, arg.limit));
96
88
  obj.setProperty(runtime, "anchor", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.anchor));
97
89
  return obj;
@@ -101,9 +93,7 @@ namespace margelo::nitro {
101
93
  return false;
102
94
  }
103
95
  jsi::Object obj = value.getObject(runtime);
104
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "energyUnit"))) return false;
105
- if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "distanceUnit"))) return false;
106
- if (!JSIConverter<std::optional<std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, WorkoutActivityTypePredicate, WorkoutDurationPredicate, PredicateForWorkoutsOr, PredicateForWorkoutsAnd>>>::canConvert(runtime, obj.getProperty(runtime, "filter"))) return false;
96
+ 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::WorkoutActivityTypePredicate, margelo::nitro::healthkit::WorkoutDurationPredicate, margelo::nitro::healthkit::PredicateForWorkoutsOr, margelo::nitro::healthkit::PredicateForWorkoutsAnd>>>::canConvert(runtime, obj.getProperty(runtime, "filter"))) return false;
107
97
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "limit"))) return false;
108
98
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "anchor"))) return false;
109
99
  return true;
@@ -21,10 +21,10 @@
21
21
  // Forward declaration of `WorkoutRouteLocation` to properly resolve imports.
22
22
  namespace margelo::nitro::healthkit { struct WorkoutRouteLocation; }
23
23
 
24
- #include <vector>
25
24
  #include "WorkoutRouteLocation.hpp"
26
- #include <optional>
25
+ #include <vector>
27
26
  #include <string>
27
+ #include <optional>
28
28
 
29
29
  namespace margelo::nitro::healthkit {
30
30
 
@@ -46,22 +46,20 @@ namespace margelo::nitro::healthkit {
46
46
 
47
47
  namespace margelo::nitro {
48
48
 
49
- using namespace margelo::nitro::healthkit;
50
-
51
49
  // C++ WorkoutRoute <> JS WorkoutRoute (object)
52
50
  template <>
53
- struct JSIConverter<WorkoutRoute> final {
54
- static inline WorkoutRoute fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
51
+ struct JSIConverter<margelo::nitro::healthkit::WorkoutRoute> final {
52
+ static inline margelo::nitro::healthkit::WorkoutRoute fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
53
  jsi::Object obj = arg.asObject(runtime);
56
- return WorkoutRoute(
57
- JSIConverter<std::vector<WorkoutRouteLocation>>::fromJSI(runtime, obj.getProperty(runtime, "locations")),
54
+ return margelo::nitro::healthkit::WorkoutRoute(
55
+ JSIConverter<std::vector<margelo::nitro::healthkit::WorkoutRouteLocation>>::fromJSI(runtime, obj.getProperty(runtime, "locations")),
58
56
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "HKMetadataKeySyncIdentifier")),
59
57
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "HKMetadataKeySyncVersion"))
60
58
  );
61
59
  }
62
- static inline jsi::Value toJSI(jsi::Runtime& runtime, const WorkoutRoute& arg) {
60
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::WorkoutRoute& arg) {
63
61
  jsi::Object obj(runtime);
64
- obj.setProperty(runtime, "locations", JSIConverter<std::vector<WorkoutRouteLocation>>::toJSI(runtime, arg.locations));
62
+ obj.setProperty(runtime, "locations", JSIConverter<std::vector<margelo::nitro::healthkit::WorkoutRouteLocation>>::toJSI(runtime, arg.locations));
65
63
  obj.setProperty(runtime, "HKMetadataKeySyncIdentifier", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.HKMetadataKeySyncIdentifier));
66
64
  obj.setProperty(runtime, "HKMetadataKeySyncVersion", JSIConverter<std::optional<double>>::toJSI(runtime, arg.HKMetadataKeySyncVersion));
67
65
  return obj;
@@ -71,7 +69,7 @@ namespace margelo::nitro {
71
69
  return false;
72
70
  }
73
71
  jsi::Object obj = value.getObject(runtime);
74
- if (!JSIConverter<std::vector<WorkoutRouteLocation>>::canConvert(runtime, obj.getProperty(runtime, "locations"))) return false;
72
+ if (!JSIConverter<std::vector<margelo::nitro::healthkit::WorkoutRouteLocation>>::canConvert(runtime, obj.getProperty(runtime, "locations"))) return false;
75
73
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "HKMetadataKeySyncIdentifier"))) return false;
76
74
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "HKMetadataKeySyncVersion"))) return false;
77
75
  return true;