@kingstinct/react-native-healthkit 5.3.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -18
- package/ios/ReactNativeHealthkit.m +7 -0
- package/ios/ReactNativeHealthkit.swift +155 -31
- package/lib/commonjs/hooks/useSources.js +28 -0
- package/lib/commonjs/hooks/useSources.js.map +1 -0
- package/lib/commonjs/index.ios.js +3 -0
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +11 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +1 -0
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -1
- package/lib/commonjs/utils/deserializeSample.js +2 -2
- package/lib/commonjs/utils/deserializeSample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/prepareOptions.js +4 -2
- package/lib/commonjs/utils/prepareOptions.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamples.js +6 -2
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -1
- package/lib/commonjs/utils/queryQuantitySamples.js +6 -2
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -1
- package/lib/commonjs/utils/querySources.js +19 -0
- package/lib/commonjs/utils/querySources.js.map +1 -0
- package/lib/commonjs/utils/serializeDate.js +1 -1
- package/lib/commonjs/utils/serializeDate.js.map +1 -1
- package/lib/commonjs/utils/serializeDate.test.js +1 -1
- package/lib/commonjs/utils/serializeDate.test.js.map +1 -1
- package/lib/module/hooks/useSources.js +17 -0
- package/lib/module/hooks/useSources.js.map +1 -0
- package/lib/module/index.ios.js +2 -0
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +1 -0
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +0 -14
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deserializeCorrelation.js +2 -2
- package/lib/module/utils/deserializeCorrelation.js.map +1 -1
- package/lib/module/utils/deserializeSample.js +2 -2
- package/lib/module/utils/deserializeSample.js.map +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/module/utils/prepareOptions.js +4 -2
- package/lib/module/utils/prepareOptions.js.map +1 -1
- package/lib/module/utils/queryCategorySamples.js +6 -2
- package/lib/module/utils/queryCategorySamples.js.map +1 -1
- package/lib/module/utils/queryQuantitySamples.js +7 -3
- package/lib/module/utils/queryQuantitySamples.js.map +1 -1
- package/lib/module/utils/querySources.js +9 -0
- package/lib/module/utils/querySources.js.map +1 -0
- package/lib/module/utils/serializeDate.js +1 -1
- package/lib/module/utils/serializeDate.js.map +1 -1
- package/lib/module/utils/serializeDate.test.js +1 -1
- package/lib/module/utils/serializeDate.test.js.map +1 -1
- package/lib/typescript/src/hooks/useSources.d.ts +3 -0
- package/lib/typescript/src/index.ios.d.ts +1 -0
- package/lib/typescript/src/native-types.d.ts +22 -2
- package/lib/typescript/src/types.d.ts +1 -0
- package/lib/typescript/src/utils/deserializeSample.d.ts +2 -2
- package/lib/typescript/src/utils/prepareOptions.d.ts +1 -0
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +7 -2
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -2
- package/lib/typescript/src/utils/querySources.d.ts +4 -0
- package/package.json +2 -1
- package/src/hooks/useSources.ts +28 -0
- package/src/index.ios.tsx +2 -0
- package/src/index.tsx +12 -3
- package/src/jest.setup.ts +1 -0
- package/src/native-types.ts +34 -5
- package/src/types.ts +1 -134
- package/src/utils/deserializeCorrelation.ts +2 -2
- package/src/utils/deserializeSample.ts +2 -2
- package/src/utils/getMostRecentCategorySample.ts +1 -1
- package/src/utils/getMostRecentQuantitySample.ts +1 -1
- package/src/utils/prepareOptions.ts +6 -3
- package/src/utils/queryCategorySamples.ts +15 -4
- package/src/utils/queryQuantitySamples.ts +16 -5
- package/src/utils/querySources.ts +21 -0
- package/src/utils/serializeDate.test.ts +1 -1
- package/src/utils/serializeDate.ts +3 -1
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/ReactNativeHealthkit.xcodeproj/xcuserdata/robertherber.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["queryQuantitySamples","getMostRecentQuantitySample","identifier","unit","samples","limit"],"sources":["getMostRecentQuantitySample.ts"],"sourcesContent":["import queryQuantitySamples from './queryQuantitySamples'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\n\nasync function getMostRecentQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n unit: TUnit,\n) {\n const samples = await queryQuantitySamples(identifier, {\n limit: 1,\n unit,\n })\n return samples[0] || null\n}\n\nexport default getMostRecentQuantitySample\n"],"mappings":"AAAA,OAAOA,oBAAP,MAAiC,wBAAjC;;AAIA,eAAeC,2BAAf,CAIEC,UAJF,EAKEC,IALF,EAME;EACA,MAAMC,OAAO,GAAG,MAAMJ,oBAAoB,CAACE,UAAD,EAAa;IACrDG,KAAK,EAAE,CAD8C;IAErDF;EAFqD,CAAb,CAA1C;EAIA,OAAOC,OAAO,
|
|
1
|
+
{"version":3,"names":["queryQuantitySamples","getMostRecentQuantitySample","identifier","unit","samples","limit"],"sources":["getMostRecentQuantitySample.ts"],"sourcesContent":["import queryQuantitySamples from './queryQuantitySamples'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\n\nasync function getMostRecentQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n unit: TUnit,\n) {\n const samples = await queryQuantitySamples(identifier, {\n limit: 1,\n unit,\n })\n return samples.samples[0] || null\n}\n\nexport default getMostRecentQuantitySample\n"],"mappings":"AAAA,OAAOA,oBAAP,MAAiC,wBAAjC;;AAIA,eAAeC,2BAAf,CAIEC,UAJF,EAKEC,IALF,EAME;EACA,MAAMC,OAAO,GAAG,MAAMJ,oBAAoB,CAACE,UAAD,EAAa;IACrDG,KAAK,EAAE,CAD8C;IAErDF;EAFqD,CAAb,CAA1C;EAIA,OAAOC,OAAO,CAACA,OAAR,CAAgB,CAAhB,KAAsB,IAA7B;AACD;;AAED,eAAeH,2BAAf"}
|
|
@@ -3,13 +3,15 @@ import serializeDate from './serializeDate';
|
|
|
3
3
|
const prepareOptions = options => {
|
|
4
4
|
const limit = !options.limit || options.limit === Infinity ? 0 : options.limit;
|
|
5
5
|
const ascending = options.ascending ?? limit === 0;
|
|
6
|
-
const from = serializeDate(options.from);
|
|
6
|
+
const from = serializeDate(options.from ? options.from : limit > 0 ? new Date(0) : undefined);
|
|
7
7
|
const to = serializeDate(options.to);
|
|
8
|
+
const anchor = options.anchor ?? '';
|
|
8
9
|
return {
|
|
9
10
|
limit,
|
|
10
11
|
ascending,
|
|
11
12
|
from,
|
|
12
|
-
to
|
|
13
|
+
to,
|
|
14
|
+
anchor
|
|
13
15
|
};
|
|
14
16
|
};
|
|
15
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["serializeDate","prepareOptions","options","limit","Infinity","ascending","from","to"],"sources":["prepareOptions.ts"],"sourcesContent":["import serializeDate from './serializeDate'\n\nimport type { GenericQueryOptions } from '../types'\n\nconst prepareOptions = (options: GenericQueryOptions) => {\n const limit = !options.limit || options.limit === Infinity
|
|
1
|
+
{"version":3,"names":["serializeDate","prepareOptions","options","limit","Infinity","ascending","from","Date","undefined","to","anchor"],"sources":["prepareOptions.ts"],"sourcesContent":["import serializeDate from './serializeDate'\n\nimport type { GenericQueryOptions } from '../types'\n\nconst prepareOptions = (options: GenericQueryOptions) => {\n const limit = !options.limit || options.limit === Infinity\n ? 0\n : options.limit\n const ascending = options.ascending ?? limit === 0\n const from = serializeDate(options.from ? options.from : (limit > 0 ? new Date(0) : undefined))\n const to = serializeDate(options.to)\n const anchor = options.anchor ?? ''\n return {\n limit, ascending, from, to, anchor,\n }\n}\n\nexport default prepareOptions\n"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;;AAIA,MAAMC,cAAc,GAAIC,OAAD,IAAkC;EACvD,MAAMC,KAAK,GAAG,CAACD,OAAO,CAACC,KAAT,IAAkBD,OAAO,CAACC,KAAR,KAAkBC,QAApC,GACV,CADU,GAEVF,OAAO,CAACC,KAFZ;EAGA,MAAME,SAAS,GAAGH,OAAO,CAACG,SAAR,IAAqBF,KAAK,KAAK,CAAjD;EACA,MAAMG,IAAI,GAAGN,aAAa,CAACE,OAAO,CAACI,IAAR,GAAeJ,OAAO,CAACI,IAAvB,GAA+BH,KAAK,GAAG,CAAR,GAAY,IAAII,IAAJ,CAAS,CAAT,CAAZ,GAA0BC,SAA1D,CAA1B;EACA,MAAMC,EAAE,GAAGT,aAAa,CAACE,OAAO,CAACO,EAAT,CAAxB;EACA,MAAMC,MAAM,GAAGR,OAAO,CAACQ,MAAR,IAAkB,EAAjC;EACA,OAAO;IACLP,KADK;IACEE,SADF;IACaC,IADb;IACmBG,EADnB;IACuBC;EADvB,CAAP;AAGD,CAXD;;AAaA,eAAeT,cAAf"}
|
|
@@ -4,8 +4,12 @@ import prepareOptions from './prepareOptions';
|
|
|
4
4
|
|
|
5
5
|
const queryCategorySamples = async (identifier, options) => {
|
|
6
6
|
const opts = prepareOptions(options);
|
|
7
|
-
const
|
|
8
|
-
return
|
|
7
|
+
const raw = await Native.queryCategorySamples(identifier, opts.from, opts.to, opts.limit, opts.ascending, opts.anchor);
|
|
8
|
+
return {
|
|
9
|
+
samples: raw.samples.map(deserializCategorySample),
|
|
10
|
+
deletedSamples: raw.deletedSamples,
|
|
11
|
+
newAnchor: raw.newAnchor
|
|
12
|
+
};
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
export default queryCategorySamples;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Native","deserializCategorySample","prepareOptions","queryCategorySamples","identifier","options","opts","
|
|
1
|
+
{"version":3,"names":["Native","deserializCategorySample","prepareOptions","queryCategorySamples","identifier","options","opts","raw","from","to","limit","ascending","anchor","samples","map","deletedSamples","newAnchor"],"sources":["queryCategorySamples.ts"],"sourcesContent":["import Native from '../native-types'\nimport deserializCategorySample from './deserializeCategorySample'\nimport prepareOptions from './prepareOptions'\n\nimport type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types'\nimport type { GenericQueryOptions, HKCategorySample } from '../types'\n\nexport type QueryCategorySamplesResponse<T extends HKCategoryTypeIdentifier> = {\n readonly samples: readonly HKCategorySample<T>[],\n readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],\n readonly newAnchor: string\n}\n\nexport type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(\n identifier: T,\n options: GenericQueryOptions\n) => Promise<QueryCategorySamplesResponse<T>>;\n\nconst queryCategorySamples: QueryCategorySamplesFn = async (\n identifier,\n options,\n) => {\n const opts = prepareOptions(options)\n const raw = await Native.queryCategorySamples(\n identifier,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n opts.anchor,\n )\n\n return {\n samples: raw.samples.map(deserializCategorySample),\n deletedSamples: raw.deletedSamples,\n newAnchor: raw.newAnchor,\n }\n}\n\nexport default queryCategorySamples\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,wBAAP,MAAqC,6BAArC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAgBA,MAAMC,oBAA4C,GAAG,OACnDC,UADmD,EAEnDC,OAFmD,KAGhD;EACH,MAAMC,IAAI,GAAGJ,cAAc,CAACG,OAAD,CAA3B;EACA,MAAME,GAAG,GAAG,MAAMP,MAAM,CAACG,oBAAP,CAChBC,UADgB,EAEhBE,IAAI,CAACE,IAFW,EAGhBF,IAAI,CAACG,EAHW,EAIhBH,IAAI,CAACI,KAJW,EAKhBJ,IAAI,CAACK,SALW,EAMhBL,IAAI,CAACM,MANW,CAAlB;EASA,OAAO;IACLC,OAAO,EAAEN,GAAG,CAACM,OAAJ,CAAYC,GAAZ,CAAgBb,wBAAhB,CADJ;IAELc,cAAc,EAAER,GAAG,CAACQ,cAFf;IAGLC,SAAS,EAAET,GAAG,CAACS;EAHV,CAAP;AAKD,CAnBD;;AAqBA,eAAeb,oBAAf"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import Native from '../native-types';
|
|
2
|
-
import
|
|
2
|
+
import deserializeQuantitySample from './deserializeSample';
|
|
3
3
|
import ensureUnit from './ensureUnit';
|
|
4
4
|
import prepareOptions from './prepareOptions';
|
|
5
5
|
|
|
6
6
|
const queryQuantitySamples = async (identifier, options) => {
|
|
7
7
|
const unit = await ensureUnit(identifier, options.unit);
|
|
8
8
|
const opts = prepareOptions(options);
|
|
9
|
-
const
|
|
10
|
-
return
|
|
9
|
+
const result = await Native.queryQuantitySamples(identifier, unit, opts.from, opts.to, opts.limit, opts.ascending, opts.anchor);
|
|
10
|
+
return {
|
|
11
|
+
deletedSamples: result.deletedSamples,
|
|
12
|
+
newAnchor: result.newAnchor,
|
|
13
|
+
samples: result.samples.map(deserializeQuantitySample)
|
|
14
|
+
};
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
export default queryQuantitySamples;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Native","
|
|
1
|
+
{"version":3,"names":["Native","deserializeQuantitySample","ensureUnit","prepareOptions","queryQuantitySamples","identifier","options","unit","opts","result","from","to","limit","ascending","anchor","deletedSamples","newAnchor","samples","map"],"sources":["queryQuantitySamples.ts"],"sourcesContent":["import Native from '../native-types'\nimport deserializeQuantitySample from './deserializeSample'\nimport ensureUnit from './ensureUnit'\nimport prepareOptions from './prepareOptions'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types'\nimport type { GenericQueryOptions, HKQuantitySample } from '../types'\n\nexport type QueryQuantitySamplesResponse<T extends HKQuantityTypeIdentifier> = {\n readonly samples: readonly HKQuantitySample<T>[],\n readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[],\n readonly newAnchor: string\n}\n\nexport type QueryQuantitySamplesFn = <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n options: GenericQueryOptions & { readonly unit?: TUnit }\n) => Promise<QueryQuantitySamplesResponse<TIdentifier>>;\n\nconst queryQuantitySamples: QueryQuantitySamplesFn = async (\n identifier,\n options,\n) => {\n const unit = await ensureUnit(identifier, options.unit)\n const opts = prepareOptions(options)\n\n const result = await Native.queryQuantitySamples(\n identifier,\n unit,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n opts.anchor,\n )\n\n return {\n deletedSamples: result.deletedSamples,\n newAnchor: result.newAnchor,\n samples: result.samples.map(deserializeQuantitySample),\n }\n}\n\nexport default queryQuantitySamples\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,yBAAP,MAAsC,qBAAtC;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAmBA,MAAMC,oBAA4C,GAAG,OACnDC,UADmD,EAEnDC,OAFmD,KAGhD;EACH,MAAMC,IAAI,GAAG,MAAML,UAAU,CAACG,UAAD,EAAaC,OAAO,CAACC,IAArB,CAA7B;EACA,MAAMC,IAAI,GAAGL,cAAc,CAACG,OAAD,CAA3B;EAEA,MAAMG,MAAM,GAAG,MAAMT,MAAM,CAACI,oBAAP,CACnBC,UADmB,EAEnBE,IAFmB,EAGnBC,IAAI,CAACE,IAHc,EAInBF,IAAI,CAACG,EAJc,EAKnBH,IAAI,CAACI,KALc,EAMnBJ,IAAI,CAACK,SANc,EAOnBL,IAAI,CAACM,MAPc,CAArB;EAUA,OAAO;IACLC,cAAc,EAAEN,MAAM,CAACM,cADlB;IAELC,SAAS,EAAEP,MAAM,CAACO,SAFb;IAGLC,OAAO,EAAER,MAAM,CAACQ,OAAP,CAAeC,GAAf,CAAmBjB,yBAAnB;EAHJ,CAAP;AAKD,CAtBD;;AAwBA,eAAeG,oBAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Native","querySources","identifier","quantitySamples"],"sources":["querySources.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type {\n HKQuantityTypeIdentifier,\n HKSource,\n HKCategoryTypeIdentifier,\n} from '../native-types'\n\nexport type QuerySourcesFn = <\n TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier\n>(\n identifier: TIdentifier\n) => Promise<readonly HKSource[]>;\n\nconst querySources: QuerySourcesFn = async (identifier) => {\n const quantitySamples = await Native.querySources(identifier)\n\n return quantitySamples\n}\n\nexport default querySources\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;;AAcA,MAAMC,YAA4B,GAAG,MAAOC,UAAP,IAAsB;EACzD,MAAMC,eAAe,GAAG,MAAMH,MAAM,CAACC,YAAP,CAAoBC,UAApB,CAA9B;EAEA,OAAOC,eAAP;AACD,CAJD;;AAMA,eAAeF,YAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["serializeDate","date","
|
|
1
|
+
{"version":3,"names":["serializeDate","date","Date","toISOString"],"sources":["serializeDate.ts"],"sourcesContent":["const serializeDate = (date?: Date | null): string => (\n (date || new Date(-1)).toISOString()\n)\n\nexport default serializeDate\n"],"mappings":"AAAA,MAAMA,aAAa,GAAIC,IAAD,IACpB,CAACA,IAAI,IAAI,IAAIC,IAAJ,CAAS,CAAC,CAAV,CAAT,EAAuBC,WAAvB,EADF;;AAIA,eAAeH,aAAf"}
|
|
@@ -8,7 +8,7 @@ describe('serializeDate', () => {
|
|
|
8
8
|
expect(serializeDate(date)).toBe(date.toISOString());
|
|
9
9
|
});
|
|
10
10
|
it('should serialize null date', () => {
|
|
11
|
-
expect(serializeDate(null)).toBe('
|
|
11
|
+
expect(serializeDate(null)).toBe('1969-12-31T23:59:59.999Z');
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
//# sourceMappingURL=serializeDate.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["serializeDate","describe","it","expect","Date","toBe","date","toISOString"],"sources":["serializeDate.test.ts"],"sourcesContent":["import serializeDate from './serializeDate'\n\ndescribe('serializeDate', () => {\n it('should serialize zero date', () => {\n expect(serializeDate(new Date(0))).toBe('1970-01-01T00:00:00.000Z')\n })\n\n it('should serialize date', () => {\n const date = new Date()\n expect(serializeDate(date)).toBe(date.toISOString())\n })\n\n it('should serialize null date', () => {\n expect(serializeDate(null)).toBe('
|
|
1
|
+
{"version":3,"names":["serializeDate","describe","it","expect","Date","toBe","date","toISOString"],"sources":["serializeDate.test.ts"],"sourcesContent":["import serializeDate from './serializeDate'\n\ndescribe('serializeDate', () => {\n it('should serialize zero date', () => {\n expect(serializeDate(new Date(0))).toBe('1970-01-01T00:00:00.000Z')\n })\n\n it('should serialize date', () => {\n const date = new Date()\n expect(serializeDate(date)).toBe(date.toISOString())\n })\n\n it('should serialize null date', () => {\n expect(serializeDate(null)).toBe('1969-12-31T23:59:59.999Z')\n })\n})\n"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AAEAC,QAAQ,CAAC,eAAD,EAAkB,MAAM;EAC9BC,EAAE,CAAC,4BAAD,EAA+B,MAAM;IACrCC,MAAM,CAACH,aAAa,CAAC,IAAII,IAAJ,CAAS,CAAT,CAAD,CAAd,CAAN,CAAmCC,IAAnC,CAAwC,0BAAxC;EACD,CAFC,CAAF;EAIAH,EAAE,CAAC,uBAAD,EAA0B,MAAM;IAChC,MAAMI,IAAI,GAAG,IAAIF,IAAJ,EAAb;IACAD,MAAM,CAACH,aAAa,CAACM,IAAD,CAAd,CAAN,CAA4BD,IAA5B,CAAiCC,IAAI,CAACC,WAAL,EAAjC;EACD,CAHC,CAAF;EAKAL,EAAE,CAAC,4BAAD,EAA+B,MAAM;IACrCC,MAAM,CAACH,aAAa,CAAC,IAAD,CAAd,CAAN,CAA4BK,IAA5B,CAAiC,0BAAjC;EACD,CAFC,CAAF;AAGD,CAbO,CAAR"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { HKCategoryTypeIdentifier, HKQuantityTypeIdentifier, HKSource } from '../native-types';
|
|
2
|
+
declare function useSources<TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier): readonly HKSource[] | null;
|
|
3
|
+
export default useSources;
|
|
@@ -34,6 +34,7 @@ declare const Healthkit: {
|
|
|
34
34
|
queryQuantitySamples: import("./utils/queryQuantitySamples").QueryQuantitySamplesFn;
|
|
35
35
|
queryStatisticsForQuantity: typeof queryStatisticsForQuantity;
|
|
36
36
|
queryWorkouts: typeof queryWorkouts;
|
|
37
|
+
querySources: import("./utils/querySources").QuerySourcesFn;
|
|
37
38
|
requestAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<boolean>;
|
|
38
39
|
deleteQuantitySample: import("./utils/deleteQuantitySample").DeleteQuantitySampleFn;
|
|
39
40
|
deleteSamples: import("./utils/deleteSamples").DeleteSamplesFn;
|
|
@@ -643,6 +643,7 @@ export declare type HKDevice = {
|
|
|
643
643
|
readonly manufacturer: string;
|
|
644
644
|
readonly model: string;
|
|
645
645
|
readonly softwareVersion: string;
|
|
646
|
+
readonly udiDeviceIdentifier: string | null;
|
|
646
647
|
};
|
|
647
648
|
export declare type HKSource = {
|
|
648
649
|
readonly name: string;
|
|
@@ -705,6 +706,24 @@ export declare type HKCategorySampleRaw<T extends HKCategoryTypeIdentifier = HKC
|
|
|
705
706
|
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
706
707
|
readonly sourceRevision?: HKSourceRevision;
|
|
707
708
|
};
|
|
709
|
+
export declare type DeletedCategorySampleRaw<T extends HKCategoryTypeIdentifier> = {
|
|
710
|
+
readonly uuid: string;
|
|
711
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
712
|
+
};
|
|
713
|
+
export declare type DeletedQuantitySampleRaw<T extends HKQuantityTypeIdentifier> = {
|
|
714
|
+
readonly uuid: string;
|
|
715
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<T>;
|
|
716
|
+
};
|
|
717
|
+
export declare type QueryCategorySamplesResponseRaw<T extends HKCategoryTypeIdentifier> = {
|
|
718
|
+
readonly samples: readonly HKCategorySampleRaw<T>[];
|
|
719
|
+
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
|
|
720
|
+
readonly newAnchor: string;
|
|
721
|
+
};
|
|
722
|
+
export declare type QueryQuantitySamplesResponseRaw<T extends HKQuantityTypeIdentifier> = {
|
|
723
|
+
readonly samples: readonly HKQuantitySampleRaw<T>[];
|
|
724
|
+
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
|
|
725
|
+
readonly newAnchor: string;
|
|
726
|
+
};
|
|
708
727
|
export declare type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> = {
|
|
709
728
|
readonly correlationType: HKCorrelationTypeIdentifier;
|
|
710
729
|
readonly objects: readonly (HKCategorySampleRaw | HKQuantitySampleRaw)[];
|
|
@@ -758,8 +777,9 @@ declare type ReactNativeHealthkitTypeNative = {
|
|
|
758
777
|
readonly deleteQuantitySample: <TIdentifier extends HKQuantityTypeIdentifier>(typeIdentifier: TIdentifier, uuid: string) => Promise<boolean>;
|
|
759
778
|
readonly deleteSamples: <TIdentifier extends HKQuantityTypeIdentifier>(identifier: TIdentifier, start: string, end: string) => Promise<boolean>;
|
|
760
779
|
readonly queryWorkoutSamples: <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(energyUnit: TEnergy, distanceUnit: TDistance, from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
761
|
-
readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(identifier: T, from: string, to: string, limit: number, ascending: boolean) => Promise<
|
|
762
|
-
readonly queryQuantitySamples: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit, from: string, to: string, limit: number, ascending: boolean) => Promise<
|
|
780
|
+
readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(identifier: T, from: string, to: string, limit: number, ascending: boolean, anchor: string) => Promise<QueryCategorySamplesResponseRaw<T>>;
|
|
781
|
+
readonly queryQuantitySamples: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit, from: string, to: string, limit: number, ascending: boolean, anchor: string) => Promise<QueryQuantitySamplesResponseRaw<TIdentifier>>;
|
|
782
|
+
readonly querySources: <TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier) => Promise<readonly HKSource[]>;
|
|
763
783
|
readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(identifier: T, value: HKCategoryValueForIdentifier<T>, start: string, end: string, metadata: unknown) => Promise<boolean>;
|
|
764
784
|
readonly queryStatisticsForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: HKQuantityTypeIdentifier, unit: TUnit, from: string, to: string, options: readonly HKStatisticsOptions[]) => Promise<QueryStatisticsResponseRaw<TIdentifier, TUnit>>;
|
|
765
785
|
readonly getPreferredUnits: (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<TypeToUnitMapping>;
|
|
@@ -13,6 +13,7 @@ export declare type GenericQueryOptions = {
|
|
|
13
13
|
readonly to?: Date;
|
|
14
14
|
readonly limit?: number;
|
|
15
15
|
readonly ascending?: boolean;
|
|
16
|
+
readonly anchor?: string;
|
|
16
17
|
};
|
|
17
18
|
export interface HKWorkout<TEnergy extends EnergyUnit = EnergyUnit, TDistance extends LengthUnit = LengthUnit> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'endDate' | 'startDate'> {
|
|
18
19
|
readonly startDate: Date;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HKQuantitySampleRaw, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types';
|
|
2
2
|
import type { HKQuantitySample } from '../types';
|
|
3
|
-
declare function
|
|
4
|
-
export default
|
|
3
|
+
declare function deserializeQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(sample: HKQuantitySampleRaw<TIdentifier, TUnit>): HKQuantitySample<TIdentifier, TUnit>;
|
|
4
|
+
export default deserializeQuantitySample;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { HKCategoryTypeIdentifier } from '../native-types';
|
|
1
|
+
import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types';
|
|
2
2
|
import type { GenericQueryOptions, HKCategorySample } from '../types';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type QueryCategorySamplesResponse<T extends HKCategoryTypeIdentifier> = {
|
|
4
|
+
readonly samples: readonly HKCategorySample<T>[];
|
|
5
|
+
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
|
|
6
|
+
readonly newAnchor: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: GenericQueryOptions) => Promise<QueryCategorySamplesResponse<T>>;
|
|
4
9
|
declare const queryCategorySamples: QueryCategorySamplesFn;
|
|
5
10
|
export default queryCategorySamples;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types';
|
|
1
|
+
import type { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types';
|
|
2
2
|
import type { GenericQueryOptions, HKQuantitySample } from '../types';
|
|
3
|
+
export declare type QueryQuantitySamplesResponse<T extends HKQuantityTypeIdentifier> = {
|
|
4
|
+
readonly samples: readonly HKQuantitySample<T>[];
|
|
5
|
+
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
|
|
6
|
+
readonly newAnchor: string;
|
|
7
|
+
};
|
|
3
8
|
export declare type QueryQuantitySamplesFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: GenericQueryOptions & {
|
|
4
9
|
readonly unit?: TUnit;
|
|
5
|
-
}) => Promise<
|
|
10
|
+
}) => Promise<QueryQuantitySamplesResponse<TIdentifier>>;
|
|
6
11
|
declare const queryQuantitySamples: QueryQuantitySamplesFn;
|
|
7
12
|
export default queryQuantitySamples;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HKQuantityTypeIdentifier, HKSource, HKCategoryTypeIdentifier } from '../native-types';
|
|
2
|
+
export declare type QuerySourcesFn = <TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier) => Promise<readonly HKSource[]>;
|
|
3
|
+
declare const querySources: QuerySourcesFn;
|
|
4
|
+
export default querySources;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingstinct/react-native-healthkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "React Native bindings for HealthKit",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@babel/core": ">=7",
|
|
49
49
|
"@babel/preset-env": "^7.18.10",
|
|
50
50
|
"@commitlint/config-conventional": "12",
|
|
51
|
+
"@expo/config-plugins": "^6.0.1",
|
|
51
52
|
"@graphql-eslint/eslint-plugin": ">=3",
|
|
52
53
|
"@release-it/conventional-changelog": "2",
|
|
53
54
|
"@testing-library/react-native": "^11.0.0",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import querySources from '../utils/querySources'
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
HKCategoryTypeIdentifier,
|
|
7
|
+
HKQuantityTypeIdentifier,
|
|
8
|
+
HKSource,
|
|
9
|
+
} from '../native-types'
|
|
10
|
+
|
|
11
|
+
function useSources<
|
|
12
|
+
TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier
|
|
13
|
+
>(identifier: TIdentifier) {
|
|
14
|
+
const [result, setResult] = useState<readonly HKSource[] | null>(null)
|
|
15
|
+
|
|
16
|
+
const update = useCallback(async () => {
|
|
17
|
+
const res = await querySources(identifier)
|
|
18
|
+
setResult(res)
|
|
19
|
+
}, [identifier])
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
void update()
|
|
23
|
+
}, [update])
|
|
24
|
+
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default useSources
|
package/src/index.ios.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import getRequestStatusForAuthorization from './utils/getRequestStatusForAuthori
|
|
|
17
17
|
import queryCategorySamples from './utils/queryCategorySamples'
|
|
18
18
|
import queryCorrelationSamples from './utils/queryCorrelationSamples'
|
|
19
19
|
import queryQuantitySamples from './utils/queryQuantitySamples'
|
|
20
|
+
import querySources from './utils/querySources'
|
|
20
21
|
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'
|
|
21
22
|
import queryWorkouts from './utils/queryWorkouts'
|
|
22
23
|
import requestAuthorization from './utils/requestAuthorization'
|
|
@@ -61,6 +62,7 @@ const Healthkit = {
|
|
|
61
62
|
queryQuantitySamples,
|
|
62
63
|
queryStatisticsForQuantity,
|
|
63
64
|
queryWorkouts,
|
|
65
|
+
querySources,
|
|
64
66
|
|
|
65
67
|
requestAuthorization,
|
|
66
68
|
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse,
|
|
4
|
+
HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKQuantityTypeIdentifier, HKUnits, HKWheelchairUse, QueryQuantitySamplesResponseRaw,
|
|
5
5
|
} from './native-types'
|
|
6
6
|
|
|
7
7
|
import type ReactNativeHealthkit from './index.ios'
|
|
@@ -41,9 +41,17 @@ const Healthkit: typeof ReactNativeHealthkit = {
|
|
|
41
41
|
getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),
|
|
42
42
|
getWorkoutRoutes: UnavailableFn(Promise.resolve([])),
|
|
43
43
|
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
44
|
-
queryCategorySamples: UnavailableFn(Promise.resolve(
|
|
44
|
+
queryCategorySamples: UnavailableFn(Promise.resolve({
|
|
45
|
+
samples: [],
|
|
46
|
+
deletedSamples: [],
|
|
47
|
+
newAnchor: '',
|
|
48
|
+
})),
|
|
45
49
|
queryCorrelationSamples: UnavailableFn(Promise.resolve([])),
|
|
46
|
-
queryQuantitySamples: UnavailableFn(Promise.resolve(
|
|
50
|
+
queryQuantitySamples: UnavailableFn(Promise.resolve({
|
|
51
|
+
samples: [],
|
|
52
|
+
deletedSamples: [],
|
|
53
|
+
newAnchor: '',
|
|
54
|
+
})),
|
|
47
55
|
queryStatisticsForQuantity: UnavailableFn(Promise.resolve({
|
|
48
56
|
averageQuantity: undefined,
|
|
49
57
|
maximumQuantity: undefined,
|
|
@@ -54,6 +62,7 @@ const Healthkit: typeof ReactNativeHealthkit = {
|
|
|
54
62
|
duration: undefined,
|
|
55
63
|
})),
|
|
56
64
|
queryWorkouts: UnavailableFn(Promise.resolve([])),
|
|
65
|
+
querySources: UnavailableFn(Promise.resolve([])),
|
|
57
66
|
requestAuthorization: UnavailableFn(Promise.resolve(false)),
|
|
58
67
|
deleteQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
59
68
|
deleteSamples: UnavailableFn(Promise.resolve(false)),
|
package/src/jest.setup.ts
CHANGED
|
@@ -25,6 +25,7 @@ const mockModule: (NativeModule & typeof Native) = {
|
|
|
25
25
|
queryCategorySamples: jest.fn(),
|
|
26
26
|
queryCorrelationSamples: jest.fn(),
|
|
27
27
|
queryQuantitySamples: jest.fn(),
|
|
28
|
+
querySources: jest.fn(),
|
|
28
29
|
queryStatisticsForQuantity: jest.fn(),
|
|
29
30
|
queryWorkoutSamples: jest.fn(),
|
|
30
31
|
saveCategorySample: jest.fn(),
|
package/src/native-types.ts
CHANGED
|
@@ -127,7 +127,6 @@ export enum HKQuantityTypeIdentifier {
|
|
|
127
127
|
waterTemperature = 'HKQuantityTypeIdentifierWaterTemperature', // Temperature, Discrete
|
|
128
128
|
|
|
129
129
|
appleSleepingWristTemperature = 'HKQuantityTypeIdentifierAppleSleepingWristTemperature', // Temperature, Discrete
|
|
130
|
-
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
export type TypeToUnitMapping = {
|
|
@@ -995,6 +994,7 @@ export type HKDevice = {
|
|
|
995
994
|
readonly manufacturer: string; // ex: "Apple Inc."
|
|
996
995
|
readonly model: string; // ex: "Watch"
|
|
997
996
|
readonly softwareVersion: string; // ex: "9.0"
|
|
997
|
+
readonly udiDeviceIdentifier: string | null
|
|
998
998
|
};
|
|
999
999
|
|
|
1000
1000
|
export type HKSource = {
|
|
@@ -1100,6 +1100,28 @@ export type HKCategorySampleRaw<
|
|
|
1100
1100
|
readonly sourceRevision?: HKSourceRevision;
|
|
1101
1101
|
};
|
|
1102
1102
|
|
|
1103
|
+
export type DeletedCategorySampleRaw<T extends HKCategoryTypeIdentifier> = {
|
|
1104
|
+
readonly uuid: string;
|
|
1105
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
export type DeletedQuantitySampleRaw<T extends HKQuantityTypeIdentifier> = {
|
|
1109
|
+
readonly uuid: string;
|
|
1110
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<T>
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
export type QueryCategorySamplesResponseRaw<T extends HKCategoryTypeIdentifier> = {
|
|
1114
|
+
readonly samples: readonly HKCategorySampleRaw<T>[],
|
|
1115
|
+
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],
|
|
1116
|
+
readonly newAnchor: string
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
export type QueryQuantitySamplesResponseRaw<T extends HKQuantityTypeIdentifier> = {
|
|
1120
|
+
readonly samples: readonly HKQuantitySampleRaw<T>[],
|
|
1121
|
+
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[],
|
|
1122
|
+
readonly newAnchor: string
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1103
1125
|
export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
1104
1126
|
{
|
|
1105
1127
|
readonly correlationType: HKCorrelationTypeIdentifier;
|
|
@@ -1233,8 +1255,9 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1233
1255
|
from: string,
|
|
1234
1256
|
to: string,
|
|
1235
1257
|
limit: number,
|
|
1236
|
-
ascending: boolean
|
|
1237
|
-
|
|
1258
|
+
ascending: boolean,
|
|
1259
|
+
anchor: string
|
|
1260
|
+
) => Promise<QueryCategorySamplesResponseRaw<T>>;
|
|
1238
1261
|
readonly queryQuantitySamples: <
|
|
1239
1262
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
1240
1263
|
TUnit extends UnitForIdentifier<TIdentifier>
|
|
@@ -1244,8 +1267,14 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1244
1267
|
from: string,
|
|
1245
1268
|
to: string,
|
|
1246
1269
|
limit: number,
|
|
1247
|
-
ascending: boolean
|
|
1248
|
-
|
|
1270
|
+
ascending: boolean,
|
|
1271
|
+
anchor: string
|
|
1272
|
+
) => Promise<QueryQuantitySamplesResponseRaw<TIdentifier>>;
|
|
1273
|
+
readonly querySources: <
|
|
1274
|
+
TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier
|
|
1275
|
+
>(
|
|
1276
|
+
identifier: TIdentifier
|
|
1277
|
+
) => Promise<readonly HKSource[]>;
|
|
1249
1278
|
readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
1250
1279
|
identifier: T,
|
|
1251
1280
|
value: HKCategoryValueForIdentifier<T>,
|
package/src/types.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type GenericQueryOptions = {
|
|
|
37
37
|
readonly to?: Date;
|
|
38
38
|
readonly limit?: number;
|
|
39
39
|
readonly ascending?: boolean;
|
|
40
|
+
readonly anchor?: string
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
export interface HKWorkout<
|
|
@@ -69,132 +70,11 @@ export interface QueryStatisticsResponse<TIdentifier extends HKQuantityTypeIdent
|
|
|
69
70
|
> {
|
|
70
71
|
readonly mostRecentQuantityDateInterval?: { readonly from: Date; readonly to: Date };
|
|
71
72
|
}
|
|
72
|
-
/*
|
|
73
|
-
export type IsHealthDataAvailableFn = () => Promise<boolean>;
|
|
74
|
-
|
|
75
|
-
export type GetBloodTypeFn = () => Promise<HKBloodType>;
|
|
76
|
-
|
|
77
|
-
export type GetDateOfBirthFn = () => Promise<Date>;
|
|
78
|
-
export type GetBiologicalSexFn = () => Promise<HKBiologicalSex>;
|
|
79
|
-
export type GetWheelchairUseFn = () => Promise<HKWheelchairUse>;
|
|
80
|
-
export type GetFitzpatrickSkinTypeFn = () => Promise<HKFitzpatrickSkinType>;
|
|
81
|
-
|
|
82
|
-
export type AuthorizationStatusForFn = (
|
|
83
|
-
type: HealthkitReadAuthorization
|
|
84
|
-
) => Promise<boolean>;
|
|
85
|
-
|
|
86
|
-
export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(
|
|
87
|
-
identifier: T,
|
|
88
|
-
options: GenericQueryOptions
|
|
89
|
-
) => Promise<readonly HKCategorySample<T>[]>;
|
|
90
|
-
|
|
91
|
-
export type GetRequestStatusForAuthorizationFn = (
|
|
92
|
-
read: readonly HealthkitReadAuthorization[],
|
|
93
|
-
write?: readonly HealthkitWriteAuthorization[]
|
|
94
|
-
) => Promise<HKAuthorizationRequestStatus>;
|
|
95
|
-
|
|
96
|
-
export type RequestAuthorizationFn = (
|
|
97
|
-
read: readonly HealthkitReadAuthorization[],
|
|
98
|
-
write?: readonly HealthkitWriteAuthorization[]
|
|
99
|
-
) => Promise<boolean>;
|
|
100
|
-
|
|
101
|
-
export type SaveQuantitySampleFn = <TType extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TType>>(
|
|
102
|
-
identifier: TType,
|
|
103
|
-
unit: TUnit,
|
|
104
|
-
value: number,
|
|
105
|
-
options?: {
|
|
106
|
-
readonly start?: Date;
|
|
107
|
-
readonly end?: Date;
|
|
108
|
-
readonly metadata?: MetadataMapperForQuantityIdentifier<TType>;
|
|
109
|
-
}
|
|
110
|
-
) => Promise<boolean>;
|
|
111
|
-
|
|
112
|
-
export type QueryQuantitySamplesFn = <
|
|
113
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
114
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
115
|
-
>(
|
|
116
|
-
identifier: TIdentifier,
|
|
117
|
-
options: GenericQueryOptions & { readonly unit?: TUnit }
|
|
118
|
-
) => Promise<readonly HKQuantitySample<TIdentifier>[]>; */
|
|
119
73
|
|
|
120
74
|
export type HKCategorySampleForSaving =Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
121
75
|
|
|
122
76
|
export type HKQuantitySampleForSaving =Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
123
|
-
/*
|
|
124
|
-
export type SaveCategorySampleFn = <T extends HKCategoryTypeIdentifier>(
|
|
125
|
-
identifier: T,
|
|
126
|
-
value: HKCategoryValueForIdentifier<T>,
|
|
127
|
-
options?: {
|
|
128
|
-
readonly start?: Date;
|
|
129
|
-
readonly end?: Date;
|
|
130
|
-
readonly metadata?: MetadataMapperForCategoryIdentifier<T>;
|
|
131
|
-
}
|
|
132
|
-
) => Promise<boolean>;
|
|
133
77
|
|
|
134
|
-
export type MostRecentCategorySampleHook = <T extends HKCategoryTypeIdentifier>(
|
|
135
|
-
identifier: T
|
|
136
|
-
) => HKCategorySample<T> | null;
|
|
137
|
-
|
|
138
|
-
export type MostRecentCorrelationSampleHook = <
|
|
139
|
-
T extends HKCorrelationTypeIdentifier
|
|
140
|
-
>(
|
|
141
|
-
identifer: T
|
|
142
|
-
) => HKCorrelation<T> | null;
|
|
143
|
-
|
|
144
|
-
export type MostRecentQuantitySampleHook = <
|
|
145
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
146
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
147
|
-
>(
|
|
148
|
-
identifier: TIdentifier,
|
|
149
|
-
unit?: TUnit
|
|
150
|
-
) => HKQuantitySample<TIdentifier> | null;
|
|
151
|
-
|
|
152
|
-
export type MostRecentWorkoutHook = <
|
|
153
|
-
TEnergy extends EnergyUnit,
|
|
154
|
-
TDistance extends LengthUnit
|
|
155
|
-
>(
|
|
156
|
-
options?: Pick<
|
|
157
|
-
QueryWorkoutsOptions<TEnergy, TDistance>,
|
|
158
|
-
'distanceUnit' | 'energyUnit'
|
|
159
|
-
>
|
|
160
|
-
) => HKWorkout<TEnergy, TDistance> | null;
|
|
161
|
-
|
|
162
|
-
export type GetPreferredUnitsFn = (
|
|
163
|
-
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
164
|
-
) => Promise<readonly HKUnit[]>;
|
|
165
|
-
|
|
166
|
-
export type GetPreferredUnitFn = (
|
|
167
|
-
identifier: HKQuantityTypeIdentifier
|
|
168
|
-
) => Promise<HKUnit>;
|
|
169
|
-
|
|
170
|
-
export type SaveCorrelationSampleFn = <
|
|
171
|
-
TIdentifier extends HKCorrelationTypeIdentifier
|
|
172
|
-
>(
|
|
173
|
-
typeIdentifier: TIdentifier,
|
|
174
|
-
samples: readonly (
|
|
175
|
-
| Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
176
|
-
| Omit<HKQuantitySample<HKQuantityTypeIdentifier>, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
177
|
-
)[],
|
|
178
|
-
options?: {
|
|
179
|
-
readonly start?: Date;
|
|
180
|
-
readonly end?: Date;
|
|
181
|
-
readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
182
|
-
}
|
|
183
|
-
) => Promise<boolean>;
|
|
184
|
-
|
|
185
|
-
export type SaveWorkoutSampleFn<TIdentifier extends HKWorkoutActivityType, TQIdentifier extends HKQuantityTypeIdentifier> = (
|
|
186
|
-
typeIdentifier: TIdentifier,
|
|
187
|
-
quantities: readonly Omit<
|
|
188
|
-
HKQuantitySample<TQIdentifier>,
|
|
189
|
-
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
190
|
-
>[],
|
|
191
|
-
start: Date,
|
|
192
|
-
options?: {
|
|
193
|
-
readonly end?: Date;
|
|
194
|
-
readonly metadata?: HKWorkoutMetadata;
|
|
195
|
-
}
|
|
196
|
-
) => Promise<boolean>;
|
|
197
|
-
*/
|
|
198
78
|
export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>
|
|
199
79
|
extends Omit<
|
|
200
80
|
HKCorrelationRaw<TIdentifier>,
|
|
@@ -204,16 +84,3 @@ export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>
|
|
|
204
84
|
readonly startDate: Date;
|
|
205
85
|
readonly endDate: Date;
|
|
206
86
|
}
|
|
207
|
-
/*
|
|
208
|
-
export type SubscribeToChangesHook = <
|
|
209
|
-
TIdentifier extends HKSampleTypeIdentifier
|
|
210
|
-
>(
|
|
211
|
-
identifier: TIdentifier,
|
|
212
|
-
onChange: () => void,
|
|
213
|
-
runInitialUpdate?: boolean
|
|
214
|
-
) => void;
|
|
215
|
-
|
|
216
|
-
export type GetWorkoutRoutesFn = (
|
|
217
|
-
workoutUUID: string
|
|
218
|
-
) => Promise<readonly WorkoutRoute[]>;
|
|
219
|
-
*/
|