From ee0291fa06a93072402c20a80b23210097ae9bde Mon Sep 17 00:00:00 2001 From: Sergei Butko Date: Tue, 12 Nov 2019 23:09:50 +0200 Subject: [PATCH] Add TypeScript definition file (#63) * Add Methods_Dietary into RCTAppleHealthKit.xcodeproj * Add TypeScript definition file --- RCTAppleHealthKit.xcodeproj/project.pbxproj | 6 ++ index.d.ts | 62 +++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 index.d.ts diff --git a/RCTAppleHealthKit.xcodeproj/project.pbxproj b/RCTAppleHealthKit.xcodeproj/project.pbxproj index ef1d5dd2..da8986aa 100644 --- a/RCTAppleHealthKit.xcodeproj/project.pbxproj +++ b/RCTAppleHealthKit.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; }; 64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; }; 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; }; + 846A98EA215244E7000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m in Sources */ = {isa = PBXBuildFile; fileRef = 846A98E9215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m */; }; C7F88CE6A9E2D530A1CBDFAA /* Pods_RCTAppleHealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C84411FDBEEBD8BA9C43C813 /* Pods_RCTAppleHealthKit.framework */; }; /* End PBXBuildFile section */ @@ -63,6 +64,8 @@ 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = ""; }; 64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = ""; }; 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = ""; }; + 846A98E8215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Dietary.h"; sourceTree = ""; }; + 846A98E9215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Dietary.m"; sourceTree = ""; }; AD8403CE6AF2AAD2D7CEE97E /* Pods-RCTAppleHealthKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RCTAppleHealthKit.debug.xcconfig"; path = "Target Support Files/Pods-RCTAppleHealthKit/Pods-RCTAppleHealthKit.debug.xcconfig"; sourceTree = ""; }; C84411FDBEEBD8BA9C43C813 /* Pods_RCTAppleHealthKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RCTAppleHealthKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -100,6 +103,8 @@ 3774C88F1D2092F20000B3F3 /* RCTAppleHealthKit */ = { isa = PBXGroup; children = ( + 846A98E8215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.h */, + 846A98E9215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m */, 58C81E6E1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.h */, 58C81E6D1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.m */, 61232F911E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.h */, @@ -234,6 +239,7 @@ 37837E7D1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m in Sources */, 3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */, 61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */, + 846A98EA215244E7000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m in Sources */, 64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */, 64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */, 3774C8931D2092F20000B3F3 /* RCTAppleHealthKit.m in Sources */, diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..eeafb0ac --- /dev/null +++ b/index.d.ts @@ -0,0 +1,62 @@ +declare module "rn-apple-healthkit" { + export interface HealthKitPermissions { + permissions: { + read: string[]; + write: string[]; + }; + } + + export interface AppleHealthKit { + initHealthKit(permissions: HealthKitPermissions, callback: (error: string, result: Object) => void): void; + + saveFood(options: Object, callback: (error: string, result: Object) => void): void; + + isAvailable(callback: (error: Object, results: boolean) => void): void; + + getDateOfBirth(options: any, callback: (error: Object, results: HealthDateOfBirth) => void): void; + + getLatestHeight(options: HealthUnitOptions, callback: (err: string, results: HealthValue) => void): void; + + getLatestWeight(options: HealthUnitOptions, callback: (err: string, results: HealthValue) => void): void; + } + + export interface HealthDateOfBirth { + value: string; + age: number; + } + + export interface HealthValue { + value: number; + startDate: string; + endDate: string; + } + + export interface HealthUnitOptions { + unit: HealthUnit; + } + export enum HealthUnit { + bpm = "bpm", + calorie = "calorie", + celsius = "celsius", + count = "count", + day = "day", + fahrenheit = "fahrenheit", + foot = "foot", + gram = "gram", + hour = "hour", + inch = "inch", + joule = "joule", + meter = "meter", + mgPerdL = "mgPerdL", + mile = "mile", + minute = "minute", + mmhg = "mmhg", + mmolPerL = "mmolPerL", + percent = "percent", + pound = "pound", + second = "second" + } + + const appleHealthKit: AppleHealthKit; + export default appleHealthKit; +}