@kingstinct/react-native-healthkit 8.2.0 → 8.4.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 (52) hide show
  1. package/README.md +28 -7
  2. package/ios/Constants.swift +5 -0
  3. package/ios/Helpers.swift +87 -0
  4. package/ios/ReactNativeHealthkit.m +22 -0
  5. package/ios/ReactNativeHealthkit.swift +184 -0
  6. package/ios/Serializers.swift +18 -0
  7. package/lib/commonjs/index.ios.js +28 -1
  8. package/lib/commonjs/index.ios.js.map +1 -1
  9. package/lib/commonjs/index.native.js +21 -4
  10. package/lib/commonjs/index.native.js.map +1 -1
  11. package/lib/commonjs/native-types.js +107 -1
  12. package/lib/commonjs/native-types.js.map +1 -1
  13. package/lib/commonjs/test-setup.js +4 -1
  14. package/lib/commonjs/test-setup.js.map +1 -1
  15. package/lib/commonjs/utils/queryStateOfMindSamples.js +22 -0
  16. package/lib/commonjs/utils/queryStateOfMindSamples.js.map +1 -0
  17. package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js +16 -0
  18. package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js.map +1 -0
  19. package/lib/commonjs/utils/startWatchApp.js +11 -0
  20. package/lib/commonjs/utils/startWatchApp.js.map +1 -0
  21. package/lib/module/index.ios.js +9 -3
  22. package/lib/module/index.ios.js.map +1 -1
  23. package/lib/module/index.native.js +17 -3
  24. package/lib/module/index.native.js.map +1 -1
  25. package/lib/module/native-types.js +111 -0
  26. package/lib/module/native-types.js.map +1 -1
  27. package/lib/module/test-setup.js +4 -1
  28. package/lib/module/test-setup.js.map +1 -1
  29. package/lib/module/utils/queryStateOfMindSamples.js +14 -0
  30. package/lib/module/utils/queryStateOfMindSamples.js.map +1 -0
  31. package/lib/module/utils/queryStatisticsCollectionForQuantity.js +9 -0
  32. package/lib/module/utils/queryStatisticsCollectionForQuantity.js.map +1 -0
  33. package/lib/module/utils/startWatchApp.js +4 -0
  34. package/lib/module/utils/startWatchApp.js.map +1 -0
  35. package/lib/typescript/src/index.ios.d.ts +13 -2
  36. package/lib/typescript/src/index.native.d.ts +11 -3
  37. package/lib/typescript/src/native-types.d.ts +146 -2
  38. package/lib/typescript/src/utils/queryStateOfMindSamples.d.ts +7 -0
  39. package/lib/typescript/src/utils/queryStatisticsCollectionForQuantity.d.ts +3 -0
  40. package/lib/typescript/src/utils/startWatchApp.d.ts +3 -0
  41. package/package.json +1 -1
  42. package/src/index.ios.tsx +10 -0
  43. package/src/index.native.tsx +20 -1
  44. package/src/native-types.ts +176 -1
  45. package/src/test-setup.ts +3 -0
  46. package/src/utils/queryStateOfMindSamples.ts +14 -0
  47. package/src/utils/queryStatisticsCollectionForQuantity.ts +38 -0
  48. package/src/utils/startWatchApp.ts +7 -0
  49. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  50. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  51. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  52. package/ios/ReactNativeHealthkit.xcodeproj/xcuserdata/robertherber.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -0,0 +1,14 @@
1
+ import Native from '../native-types';
2
+ export const queryStateOfMindSamples = async ({
3
+ from,
4
+ to,
5
+ limit,
6
+ ascending
7
+ } = {}) => {
8
+ const fromString = (from || new Date(0)).toISOString();
9
+ const toString = (to || new Date(0)).toISOString();
10
+ const res = await Native.queryStateOfMindSamples(fromString, toString, limit ?? 0, ascending ?? false);
11
+ return res;
12
+ };
13
+ export default queryStateOfMindSamples;
14
+ //# sourceMappingURL=queryStateOfMindSamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","queryStateOfMindSamples","from","to","limit","ascending","fromString","Date","toISOString","toString","res"],"sources":["queryStateOfMindSamples.ts"],"sourcesContent":["import Native from '../native-types'\n\nexport const queryStateOfMindSamples = async ({\n from, to, limit, ascending,\n}: { readonly from?: Date; readonly to?: Date; readonly limit?: number; readonly ascending?: boolean } = {}) => {\n const fromString = (from || new Date(0)).toISOString()\n const toString = (to || new Date(0)).toISOString()\n\n const res = await Native.queryStateOfMindSamples(fromString, toString, limit ?? 0, ascending ?? false)\n\n return res\n}\n\nexport default queryStateOfMindSamples\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,iBAAiB;AAEpC,OAAO,MAAMC,uBAAuB,GAAG,MAAAA,CAAO;EAC5CC,IAAI;EAAEC,EAAE;EAAEC,KAAK;EAAEC;AACkF,CAAC,GAAG,CAAC,CAAC,KAAK;EAC9G,MAAMC,UAAU,GAAG,CAACJ,IAAI,IAAI,IAAIK,IAAI,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC;EACtD,MAAMC,QAAQ,GAAG,CAACN,EAAE,IAAI,IAAII,IAAI,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC;EAElD,MAAME,GAAG,GAAG,MAAMV,MAAM,CAACC,uBAAuB,CAACK,UAAU,EAAEG,QAAQ,EAAEL,KAAK,IAAI,CAAC,EAAEC,SAAS,IAAI,KAAK,CAAC;EAEtG,OAAOK,GAAG;AACZ,CAAC;AAED,eAAeT,uBAAuB","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import ensureUnit from './ensureUnit';
2
+ import Native from '../native-types';
3
+ async function queryStatisticsCollectionForQuantity(identifier, options, anchorDate, intervalComponents, startDate, endDate, unit) {
4
+ const actualUnit = await ensureUnit(identifier, unit);
5
+ const rawResponse = await Native.queryStatisticsCollectionForQuantity(identifier, actualUnit, options, anchorDate.toISOString(), intervalComponents, startDate.toISOString(), endDate.toISOString());
6
+ return rawResponse;
7
+ }
8
+ export default queryStatisticsCollectionForQuantity;
9
+ //# sourceMappingURL=queryStatisticsCollectionForQuantity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ensureUnit","Native","queryStatisticsCollectionForQuantity","identifier","options","anchorDate","intervalComponents","startDate","endDate","unit","actualUnit","rawResponse","toISOString"],"sources":["queryStatisticsCollectionForQuantity.ts"],"sourcesContent":["import ensureUnit from './ensureUnit'\nimport Native from '../native-types'\n\nimport type {\n HKQuantityTypeIdentifier,\n HKStatisticsOptions,\n UnitForIdentifier,\n IntervalComponents,\n} from '../native-types'\n\nasync function queryStatisticsCollectionForQuantity<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n options: readonly HKStatisticsOptions[],\n anchorDate: Date,\n intervalComponents: IntervalComponents,\n startDate: Date,\n endDate: Date,\n unit?: TUnit,\n) {\n const actualUnit = await ensureUnit(identifier, unit)\n\n const rawResponse = await Native.queryStatisticsCollectionForQuantity(\n identifier,\n actualUnit,\n options,\n anchorDate.toISOString(),\n intervalComponents,\n startDate.toISOString(),\n endDate.toISOString(),\n )\n\n return rawResponse\n}\n\nexport default queryStatisticsCollectionForQuantity\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,cAAc;AACrC,OAAOC,MAAM,MAAM,iBAAiB;AASpC,eAAeC,oCAAoCA,CAIjDC,UAAuB,EACvBC,OAAuC,EACvCC,UAAgB,EAChBC,kBAAsC,EACtCC,SAAe,EACfC,OAAa,EACbC,IAAY,EACZ;EACA,MAAMC,UAAU,GAAG,MAAMV,UAAU,CAACG,UAAU,EAAEM,IAAI,CAAC;EAErD,MAAME,WAAW,GAAG,MAAMV,MAAM,CAACC,oCAAoC,CACnEC,UAAU,EACVO,UAAU,EACVN,OAAO,EACPC,UAAU,CAACO,WAAW,CAAC,CAAC,EACxBN,kBAAkB,EAClBC,SAAS,CAACK,WAAW,CAAC,CAAC,EACvBJ,OAAO,CAACI,WAAW,CAAC,CACtB,CAAC;EAED,OAAOD,WAAW;AACpB;AAEA,eAAeT,oCAAoC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import Native from '../native-types';
2
+ const startWatchApp = configuration => async () => Native.startWatchAppWithWorkoutConfiguration(configuration);
3
+ export default startWatchApp;
4
+ //# sourceMappingURL=startWatchApp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","startWatchApp","configuration","startWatchAppWithWorkoutConfiguration"],"sources":["startWatchApp.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKWorkoutConfiguration } from '..'\n\nconst startWatchApp = (configuration: HKWorkoutConfiguration) => async () => Native.startWatchAppWithWorkoutConfiguration(configuration)\n\nexport default startWatchApp\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,iBAAiB;AAIpC,MAAMC,aAAa,GAAIC,aAAqC,IAAK,YAAYF,MAAM,CAACG,qCAAqC,CAACD,aAAa,CAAC;AAExI,eAAeD,aAAa","ignoreList":[]}
@@ -25,6 +25,8 @@ import queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesS
25
25
  import queryQuantitySamples from './utils/queryQuantitySamples';
26
26
  import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor';
27
27
  import querySources from './utils/querySources';
28
+ import { queryStateOfMindSamples } from './utils/queryStateOfMindSamples';
29
+ import queryStatisticsCollectionForQuantity from './utils/queryStatisticsCollectionForQuantity';
28
30
  import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity';
29
31
  import queryWorkoutSamples from './utils/queryWorkouts';
30
32
  import queryWorkoutSamplesWithAnchor from './utils/queryWorkoutSamplesWithAnchor';
@@ -34,6 +36,7 @@ import saveCorrelationSample from './utils/saveCorrelationSample';
34
36
  import saveQuantitySample from './utils/saveQuantitySample';
35
37
  import saveWorkoutRoute from './utils/saveWorkoutRoute';
36
38
  import saveWorkoutSample from './utils/saveWorkoutSample';
39
+ import startWatchApp from './utils/startWatchApp';
37
40
  import subscribeToChanges from './utils/subscribeToChanges';
38
41
  declare const availableQuantityTypes: (majorVersionIOS?: number) => HKQuantityTypeIdentifier[];
39
42
  declare const authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<import("./native-types").HKAuthorizationStatus>;
@@ -125,6 +128,7 @@ declare const _default: {
125
128
  queryQuantitySamples: import("./utils/queryQuantitySamples").QueryQuantitySamplesFn;
126
129
  queryQuantitySamplesWithAnchor: import("./utils/queryQuantitySamplesWithAnchor").QueryQuantitySamplesWithAnchorFn;
127
130
  queryStatisticsForQuantity: typeof queryStatisticsForQuantity;
131
+ queryStatisticsCollectionForQuantity: typeof queryStatisticsCollectionForQuantity;
128
132
  /**
129
133
  * @deprecated Use queryWorkoutSamples instead
130
134
  */
@@ -145,6 +149,7 @@ declare const _default: {
145
149
  saveWorkoutSample: typeof saveWorkoutSample;
146
150
  saveWorkoutRoute: typeof saveWorkoutRoute;
147
151
  subscribeToChanges: (identifier: import("./native-types").HKSampleTypeIdentifier, callback: () => void) => Promise<() => Promise<boolean>>;
152
+ startWatchApp: (configuration: import("./native-types").HKWorkoutConfiguration) => () => Promise<boolean>;
148
153
  /**
149
154
  * @returns the most recent sample for the given category type.
150
155
  */
@@ -172,12 +177,18 @@ declare const _default: {
172
177
  useHealthkitAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[] | undefined) => readonly [import("./native-types").HKAuthorizationRequestStatus | null, () => Promise<import("./native-types").HKAuthorizationRequestStatus>];
173
178
  useSources: typeof useSources;
174
179
  useStatisticsForQuantity: typeof useStatisticsForQuantity;
180
+ queryStateOfMindSamples: ({ from, to, limit, ascending, }?: {
181
+ readonly from?: Date | undefined;
182
+ readonly to?: Date | undefined;
183
+ readonly limit?: number | undefined;
184
+ readonly ascending?: boolean | undefined;
185
+ }) => Promise<readonly import("./native-types").HKStateOfMindSampleRaw[]>;
175
186
  };
176
187
  export default _default;
177
188
  declare const queryWorkouts: typeof queryWorkoutSamples;
178
- export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity,
189
+ export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity, queryStatisticsCollectionForQuantity,
179
190
  /**
180
191
  * @deprecated Use queryWorkoutSamples instead
181
192
  */
182
- queryWorkouts, queryWorkoutSamples, queryWorkoutSamplesWithAnchor, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useSources, useStatisticsForQuantity, isProtectedDataAvailable, };
193
+ queryWorkouts, queryWorkoutSamples, queryWorkoutSamplesWithAnchor, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, startWatchApp, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useSources, useStatisticsForQuantity, isProtectedDataAvailable, queryStateOfMindSamples, };
183
194
  export * from './types';
@@ -22,12 +22,20 @@ declare const authorizationStatusFor: () => Promise<HKAuthorizationStatus>, avai
22
22
  mostRecentQuantity: undefined;
23
23
  mostRecentQuantityDateInterval: undefined;
24
24
  duration: undefined;
25
- }>, queryWorkouts: () => Promise<never[]>, queryWorkoutSamples: () => Promise<never[]>, queryWorkoutSamplesWithAnchor: () => Promise<{
25
+ }>, queryStatisticsCollectionForQuantity: () => Promise<{
26
+ averageQuantity: undefined;
27
+ maximumQuantity: undefined;
28
+ minimumQuantity: undefined;
29
+ sumQuantity: undefined;
30
+ mostRecentQuantity: undefined;
31
+ mostRecentQuantityDateInterval: undefined;
32
+ duration: undefined;
33
+ }[]>, queryWorkouts: () => Promise<never[]>, queryWorkoutSamples: () => Promise<never[]>, queryWorkoutSamplesWithAnchor: () => Promise<{
26
34
  samples: never[];
27
35
  deletedSamples: never[];
28
36
  newAnchor: string;
29
- }>, querySources: () => Promise<never[]>, requestAuthorization: () => Promise<boolean>, deleteQuantitySample: () => Promise<boolean>, deleteSamples: () => Promise<boolean>, getWorkoutPlanById: () => Promise<null>, saveCategorySample: () => Promise<boolean>, saveCorrelationSample: () => Promise<boolean>, saveQuantitySample: () => Promise<boolean>, saveWorkoutSample: () => Promise<null>, saveWorkoutRoute: () => Promise<boolean>, subscribeToChanges: () => Promise<() => Promise<boolean>>, useMostRecentCategorySample: () => null, useMostRecentQuantitySample: () => null, useMostRecentWorkout: () => null, useSubscribeToChanges: () => ((() => null) | null)[], useHealthkitAuthorization: () => readonly [null, () => Promise<HKAuthorizationRequestStatus>], useIsHealthDataAvailable: () => boolean, isProtectedDataAvailable: () => Promise<boolean>;
37
+ }>, querySources: () => Promise<never[]>, requestAuthorization: () => Promise<boolean>, deleteQuantitySample: () => Promise<boolean>, deleteSamples: () => Promise<boolean>, getWorkoutPlanById: () => Promise<null>, saveCategorySample: () => Promise<boolean>, saveCorrelationSample: () => Promise<boolean>, saveQuantitySample: () => Promise<boolean>, saveWorkoutSample: () => Promise<null>, saveWorkoutRoute: () => Promise<boolean>, subscribeToChanges: () => Promise<() => Promise<boolean>>, startWatchApp: () => () => Promise<boolean>, useMostRecentCategorySample: () => null, useMostRecentQuantitySample: () => null, useMostRecentWorkout: () => null, useSubscribeToChanges: () => ((() => null) | null)[], useHealthkitAuthorization: () => readonly [null, () => Promise<HKAuthorizationRequestStatus>], useIsHealthDataAvailable: () => boolean, isProtectedDataAvailable: () => Promise<boolean>, queryStateOfMindSamples: () => Promise<never[]>;
30
38
  declare const Healthkit: typeof ReactNativeHealthkit;
31
- export { authorizationStatusFor, availableQuantityTypes, deleteQuantitySample, deleteSamples, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutPlanById, getWorkoutRoutes, isHealthDataAvailable, isProtectedDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, querySources, queryStatisticsForQuantity, queryWorkouts, queryWorkoutSamples, queryWorkoutSamplesWithAnchor, requestAuthorization, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutRoute, saveWorkoutSample, subscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSources, useStatisticsForQuantity, useSubscribeToChanges, };
39
+ export { authorizationStatusFor, availableQuantityTypes, deleteQuantitySample, deleteSamples, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutPlanById, getWorkoutRoutes, isHealthDataAvailable, isProtectedDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, querySources, queryStatisticsForQuantity, queryStatisticsCollectionForQuantity, queryWorkouts, queryWorkoutSamples, queryWorkoutSamplesWithAnchor, requestAuthorization, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutRoute, saveWorkoutSample, subscribeToChanges, startWatchApp, useHealthkitAuthorization, useIsHealthDataAvailable, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSources, useStatisticsForQuantity, useSubscribeToChanges, queryStateOfMindSamples, };
32
40
  export * from './types';
33
41
  export default Healthkit;
@@ -20,6 +20,11 @@ export declare const HKAudiogramTypeIdentifier: "HKAudiogramSampleType";
20
20
  * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutetypeidentifier Apple Docs HKWorkoutRouteTypeIdentifier}
21
21
  */
22
22
  export declare const HKWorkoutRouteTypeIdentifier: "HKWorkoutRouteTypeIdentifier";
23
+ /**
24
+ * Represents a state of mind type identifier.
25
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmindtype Apple Docs HKStateOfMindType}
26
+ */
27
+ export declare const HKStateOfMindTypeIdentifier: "HKStateOfMindTypeIdentifier";
23
28
  /**
24
29
  * Represents a series sample containing heartbeat data..
25
30
  * @see {@link https://developer.apple.com/documentation/healthkit/HKDataTypeIdentifierHeartbeatSeries Apple Docs HKDataTypeIdentifierHeartbeatSeries}
@@ -783,7 +788,7 @@ export declare enum HKCategoryTypeIdentifier {
783
788
  */
784
789
  bleedingDuringPregnancy = "HKCategoryTypeIdentifierBleedingDuringPregnancy"
785
790
  }
786
- export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKActivitySummaryTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
791
+ export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKStateOfMindTypeIdentifier | typeof HKActivitySummaryTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
787
792
  export type HealthkitReadAuthorization = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier | `${HKCharacteristicTypeIdentifier}` | `${HKSampleTypeIdentifier}`;
788
793
  export type HealthkitWriteAuthorization = HKSampleTypeIdentifier;
789
794
  export declare enum HKCategoryValueAppleStandHour {
@@ -1014,6 +1019,13 @@ export type QueryStatisticsResponseRaw<TIdentifier extends HKQuantityTypeIdentif
1014
1019
  };
1015
1020
  readonly duration?: HKQuantity<HKQuantityTypeIdentifier, TimeUnit>;
1016
1021
  };
1022
+ export interface IntervalComponents {
1023
+ readonly minute?: number;
1024
+ readonly hour?: number;
1025
+ readonly day?: number;
1026
+ readonly month?: number;
1027
+ readonly year?: number;
1028
+ }
1017
1029
  /**
1018
1030
  * @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvaluecervicalmucusquality Apple Docs }
1019
1031
  */
@@ -1167,7 +1179,8 @@ export declare enum HKUnits {
1167
1179
  DecibelSoundPressureLevel = "dBASPL",
1168
1180
  Percent = "%",
1169
1181
  Count = "count",
1170
- InternationalUnit = "IU"
1182
+ InternationalUnit = "IU",
1183
+ AppleEffortScore = "appleEffortScore"
1171
1184
  }
1172
1185
  export type MeterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> = `${Prefix}${HKUnitMetric.Meter}`;
1173
1186
  export type LiterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> = `${Prefix}${HKUnitMetric.Liter}`;
@@ -1506,6 +1519,21 @@ type QueryWorkoutSamplesWithAnchorResponseRaw<TEnergy extends EnergyUnit, TDista
1506
1519
  readonly deletedSamples: readonly DeletedWorkoutSampleRaw[];
1507
1520
  readonly newAnchor: string;
1508
1521
  };
1522
+ /**
1523
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutconfiguration Apple Docs }
1524
+ */
1525
+ export type HKWorkoutConfiguration = {
1526
+ readonly activityType: HKWorkoutActivityType;
1527
+ readonly locationType?: HKWorkoutSessionLocationType;
1528
+ };
1529
+ /**
1530
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutsessionlocationtype Apple Docs }
1531
+ */
1532
+ export declare enum HKWorkoutSessionLocationType {
1533
+ unknown = 1,
1534
+ indoor = 2,
1535
+ outdoor = 3
1536
+ }
1509
1537
  type ReactNativeHealthkitTypeNative = {
1510
1538
  /**
1511
1539
  * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs }
@@ -1564,12 +1592,54 @@ type ReactNativeHealthkitTypeNative = {
1564
1592
  readonly querySources: <TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier) => Promise<readonly HKSource[]>;
1565
1593
  readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(identifier: T, value: HKCategoryValueForIdentifier<T>, start: string, end: string, metadata: unknown) => Promise<boolean>;
1566
1594
  readonly queryStatisticsForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: HKQuantityTypeIdentifier, unit: TUnit, from: string, to: string, options: readonly HKStatisticsOptions[]) => Promise<QueryStatisticsResponseRaw<TIdentifier, TUnit>>;
1595
+ readonly queryStatisticsCollectionForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit, options: readonly HKStatisticsOptions[], anchorDate: string, intervalComponents: IntervalComponents, startDate: string, endDate: string) => Promise<readonly QueryStatisticsResponseRaw<TIdentifier, TUnit>[]>;
1567
1596
  readonly getPreferredUnits: (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<TypeToUnitMapping>;
1568
1597
  readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
1569
1598
  readonly getWorkoutPlanById: (workoutUUID: string) => Promise<{
1570
1599
  readonly id: string;
1571
1600
  readonly activityType: HKWorkoutActivityType;
1572
1601
  } | null>;
1602
+ /**
1603
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648358-startwatchapp Apple Docs }
1604
+ */
1605
+ readonly startWatchAppWithWorkoutConfiguration: (workoutConfiguration: HKWorkoutConfiguration) => Promise<boolean>;
1606
+ /**
1607
+ * Query state of mind samples from HealthKit
1608
+ * @param from Start date to query from
1609
+ * @param to End date to query to
1610
+ * @param limit Maximum number of samples to return
1611
+ * @param ascending Sort order of samples
1612
+ * @returns Promise resolving to array of state of mind samples
1613
+ * @platform ios
1614
+ * @requires iOS 17.0+
1615
+ */
1616
+ readonly queryStateOfMindSamples: (from: string | null, to: string | null, limit: number, ascending: boolean) => Promise<readonly HKStateOfMindSampleRaw[]>;
1617
+ };
1618
+ export declare enum HKStateOfMindValenceClassification {
1619
+ veryUnpleasant = 1,
1620
+ unpleasant = 2,
1621
+ slightlyUnpleasant = 3,
1622
+ neutral = 4,
1623
+ slightlyPleasant = 5,
1624
+ pleasant = 6,
1625
+ veryPleasant = 7
1626
+ }
1627
+ export type HKStateOfMindSampleRaw = {
1628
+ readonly uuid: string;
1629
+ readonly device?: HKDevice;
1630
+ readonly startDate: string;
1631
+ readonly endDate: string;
1632
+ readonly metadata?: HKHeartbeatSeriesSampleMetadata;
1633
+ readonly sourceRevision?: HKSourceRevision;
1634
+ /**
1635
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind/4337998-valence Apple Docs }
1636
+ * Value between -1 and 1
1637
+ */
1638
+ readonly valence: number;
1639
+ readonly kind: HKStateOfMindKind;
1640
+ readonly valenceClassification: HKStateOfMindValenceClassification;
1641
+ readonly associations: readonly HKStateOfMindAssociation[];
1642
+ readonly labels: readonly HKStateOfMindLabel[];
1573
1643
  };
1574
1644
  declare const Native: ReactNativeHealthkitTypeNative;
1575
1645
  type OnChangeCallback = ({ typeIdentifier, }: {
@@ -1580,3 +1650,77 @@ interface HealthkitEventEmitter extends NativeEventEmitter {
1580
1650
  }
1581
1651
  export declare const EventEmitter: HealthkitEventEmitter;
1582
1652
  export default Native;
1653
+ /**
1654
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind/label Apple Docs}
1655
+ */
1656
+ export declare enum HKStateOfMindLabel {
1657
+ amazed = 1,
1658
+ amused = 2,
1659
+ angry = 3,
1660
+ anxious = 4,
1661
+ ashamed = 5,
1662
+ brave = 6,
1663
+ calm = 7,
1664
+ content = 8,
1665
+ disappointed = 9,
1666
+ discouraged = 10,
1667
+ disgusted = 11,
1668
+ embarrassed = 12,
1669
+ excited = 13,
1670
+ frustrated = 14,
1671
+ grateful = 15,
1672
+ guilty = 16,
1673
+ happy = 17,
1674
+ hopeless = 18,
1675
+ irritated = 19,
1676
+ jealous = 20,
1677
+ joyful = 21,
1678
+ lonely = 22,
1679
+ passionate = 23,
1680
+ peaceful = 24,
1681
+ proud = 25,
1682
+ relieved = 26,
1683
+ sad = 27,
1684
+ scared = 28,
1685
+ stressed = 29,
1686
+ surprised = 30,
1687
+ worried = 31,
1688
+ annoyed = 32,
1689
+ confident = 33,
1690
+ drained = 34,
1691
+ hopeful = 35,
1692
+ indifferent = 36,
1693
+ overwhelmed = 37,
1694
+ satisfied = 38
1695
+ }
1696
+ /**
1697
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind/kind Apple Docs}
1698
+ */
1699
+ export declare enum HKStateOfMindKind {
1700
+ dailyMood = 2,
1701
+ momentaryEmotion = 1
1702
+ }
1703
+ /**
1704
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind/association Apple Docs}
1705
+ * @since iOS 17.0+
1706
+ */
1707
+ export declare enum HKStateOfMindAssociation {
1708
+ community = 1,
1709
+ currentEvents = 2,
1710
+ dating = 3,
1711
+ education = 4,
1712
+ family = 5,
1713
+ fitness = 6,
1714
+ friends = 7,
1715
+ health = 8,
1716
+ hobbies = 9,
1717
+ identity = 10,
1718
+ money = 11,
1719
+ partner = 12,
1720
+ selfCare = 13,
1721
+ spirituality = 14,
1722
+ tasks = 15,
1723
+ travel = 16,
1724
+ work = 17,
1725
+ weather = 18
1726
+ }
@@ -0,0 +1,7 @@
1
+ export declare const queryStateOfMindSamples: ({ from, to, limit, ascending, }?: {
2
+ readonly from?: Date | undefined;
3
+ readonly to?: Date | undefined;
4
+ readonly limit?: number | undefined;
5
+ readonly ascending?: boolean | undefined;
6
+ }) => Promise<readonly import("../native-types").HKStateOfMindSampleRaw[]>;
7
+ export default queryStateOfMindSamples;
@@ -0,0 +1,3 @@
1
+ import type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier, IntervalComponents } from '../native-types';
2
+ declare function queryStatisticsCollectionForQuantity<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: readonly HKStatisticsOptions[], anchorDate: Date, intervalComponents: IntervalComponents, startDate: Date, endDate: Date, unit?: TUnit): Promise<readonly import("../native-types").QueryStatisticsResponseRaw<TIdentifier, TUnit>[]>;
3
+ export default queryStatisticsCollectionForQuantity;
@@ -0,0 +1,3 @@
1
+ import type { HKWorkoutConfiguration } from '..';
2
+ declare const startWatchApp: (configuration: HKWorkoutConfiguration) => () => Promise<boolean>;
3
+ export default startWatchApp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "8.2.0",
3
+ "version": "8.4.0",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.ios.tsx CHANGED
@@ -27,6 +27,8 @@ import queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesS
27
27
  import queryQuantitySamples from './utils/queryQuantitySamples'
28
28
  import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'
29
29
  import querySources from './utils/querySources'
30
+ import { queryStateOfMindSamples } from './utils/queryStateOfMindSamples'
31
+ import queryStatisticsCollectionForQuantity from './utils/queryStatisticsCollectionForQuantity'
30
32
  import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'
31
33
  import queryWorkoutSamples from './utils/queryWorkouts'
32
34
  import queryWorkoutSamplesWithAnchor from './utils/queryWorkoutSamplesWithAnchor'
@@ -36,6 +38,7 @@ import saveCorrelationSample from './utils/saveCorrelationSample'
36
38
  import saveQuantitySample from './utils/saveQuantitySample'
37
39
  import saveWorkoutRoute from './utils/saveWorkoutRoute'
38
40
  import saveWorkoutSample from './utils/saveWorkoutSample'
41
+ import startWatchApp from './utils/startWatchApp'
39
42
  import subscribeToChanges from './utils/subscribeToChanges'
40
43
 
41
44
  const currentMajorVersionIOS = Platform.OS === 'ios' ? parseInt(Platform.Version, 10) : 0
@@ -159,6 +162,7 @@ export default {
159
162
  queryQuantitySamples,
160
163
  queryQuantitySamplesWithAnchor,
161
164
  queryStatisticsForQuantity,
165
+ queryStatisticsCollectionForQuantity,
162
166
  /**
163
167
  * @deprecated Use queryWorkoutSamples instead
164
168
  */
@@ -187,6 +191,8 @@ export default {
187
191
  // subscriptions
188
192
  subscribeToChanges,
189
193
 
194
+ startWatchApp,
195
+
190
196
  /**
191
197
  * @returns the most recent sample for the given category type.
192
198
  */
@@ -214,6 +220,7 @@ export default {
214
220
  useHealthkitAuthorization,
215
221
  useSources,
216
222
  useStatisticsForQuantity,
223
+ queryStateOfMindSamples,
217
224
  }
218
225
 
219
226
  const queryWorkouts = queryWorkoutSamples
@@ -245,6 +252,7 @@ export {
245
252
  queryQuantitySamples,
246
253
  queryQuantitySamplesWithAnchor,
247
254
  queryStatisticsForQuantity,
255
+ queryStatisticsCollectionForQuantity,
248
256
  /**
249
257
  * @deprecated Use queryWorkoutSamples instead
250
258
  */
@@ -262,6 +270,7 @@ export {
262
270
  saveWorkoutSample,
263
271
  saveWorkoutRoute,
264
272
  subscribeToChanges,
273
+ startWatchApp,
265
274
  useMostRecentCategorySample,
266
275
  useMostRecentQuantitySample,
267
276
  useMostRecentWorkout,
@@ -271,6 +280,7 @@ export {
271
280
  useSources,
272
281
  useStatisticsForQuantity,
273
282
  isProtectedDataAvailable,
283
+ queryStateOfMindSamples,
274
284
  }
275
285
 
276
286
  export * from './types'
@@ -73,6 +73,17 @@ const authorizationStatusFor = UnavailableFn(Promise.resolve(HKAuthorizationStat
73
73
  mostRecentQuantityDateInterval: undefined,
74
74
  duration: undefined,
75
75
  })),
76
+ queryStatisticsCollectionForQuantity = UnavailableFn(Promise.resolve([
77
+ {
78
+ averageQuantity: undefined,
79
+ maximumQuantity: undefined,
80
+ minimumQuantity: undefined,
81
+ sumQuantity: undefined,
82
+ mostRecentQuantity: undefined,
83
+ mostRecentQuantityDateInterval: undefined,
84
+ duration: undefined,
85
+ },
86
+ ])),
76
87
  queryWorkouts = UnavailableFn(Promise.resolve([])),
77
88
  queryWorkoutSamples = UnavailableFn(Promise.resolve([])),
78
89
  queryWorkoutSamplesWithAnchor = UnavailableFn(Promise.resolve({
@@ -91,13 +102,15 @@ const authorizationStatusFor = UnavailableFn(Promise.resolve(HKAuthorizationStat
91
102
  saveWorkoutSample = UnavailableFn(Promise.resolve(null)),
92
103
  saveWorkoutRoute = UnavailableFn(Promise.resolve(false)),
93
104
  subscribeToChanges = UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),
105
+ startWatchApp = UnavailableFn(async () => Promise.resolve(false)),
94
106
  useMostRecentCategorySample = UnavailableFn(null),
95
107
  useMostRecentQuantitySample = UnavailableFn(null),
96
108
  useMostRecentWorkout = UnavailableFn(null),
97
109
  useSubscribeToChanges = UnavailableFn([null, () => null]),
98
110
  useHealthkitAuthorization = UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)] as const),
99
111
  useIsHealthDataAvailable = () => false,
100
- isProtectedDataAvailable = async () => Promise.resolve(false)
112
+ isProtectedDataAvailable = async () => Promise.resolve(false),
113
+ queryStateOfMindSamples = UnavailableFn(Promise.resolve([]))
101
114
 
102
115
  const Healthkit: typeof ReactNativeHealthkit = {
103
116
  authorizationStatusFor,
@@ -131,6 +144,7 @@ const Healthkit: typeof ReactNativeHealthkit = {
131
144
  queryQuantitySamplesWithAnchor,
132
145
  querySources,
133
146
  queryStatisticsForQuantity,
147
+ queryStatisticsCollectionForQuantity,
134
148
  queryWorkouts,
135
149
  queryWorkoutSamples,
136
150
  queryWorkoutSamplesWithAnchor,
@@ -141,6 +155,7 @@ const Healthkit: typeof ReactNativeHealthkit = {
141
155
  saveWorkoutRoute,
142
156
  saveWorkoutSample,
143
157
  subscribeToChanges,
158
+ startWatchApp,
144
159
  useHealthkitAuthorization,
145
160
  useIsHealthDataAvailable,
146
161
  useMostRecentCategorySample,
@@ -149,6 +164,7 @@ const Healthkit: typeof ReactNativeHealthkit = {
149
164
  useSources,
150
165
  useStatisticsForQuantity,
151
166
  useSubscribeToChanges,
167
+ queryStateOfMindSamples,
152
168
  }
153
169
 
154
170
  export {
@@ -183,6 +199,7 @@ export {
183
199
  queryQuantitySamplesWithAnchor,
184
200
  querySources,
185
201
  queryStatisticsForQuantity,
202
+ queryStatisticsCollectionForQuantity,
186
203
  queryWorkouts,
187
204
  queryWorkoutSamples,
188
205
  queryWorkoutSamplesWithAnchor,
@@ -193,6 +210,7 @@ export {
193
210
  saveWorkoutRoute,
194
211
  saveWorkoutSample,
195
212
  subscribeToChanges,
213
+ startWatchApp,
196
214
  useHealthkitAuthorization,
197
215
  useIsHealthDataAvailable,
198
216
  useMostRecentCategorySample,
@@ -201,6 +219,7 @@ export {
201
219
  useSources,
202
220
  useStatisticsForQuantity,
203
221
  useSubscribeToChanges,
222
+ queryStateOfMindSamples,
204
223
  }
205
224
 
206
225
  export * from './types'