@interval-health/capacitor-health 1.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/CapgoCapacitorHealth.podspec +18 -0
- package/LICENSE +373 -0
- package/Package.swift +31 -0
- package/README.md +324 -0
- package/android/build.gradle +70 -0
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthDataType.kt +36 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthManager.kt +349 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthPlugin.kt +309 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +528 -0
- package/dist/esm/definitions.d.ts +83 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +12 -0
- package/dist/esm/web.js +26 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +40 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +43 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/HealthPlugin/Health.swift +522 -0
- package/ios/Sources/HealthPlugin/HealthPlugin.swift +137 -0
- package/ios/Tests/HealthPluginTests/HealthPluginTests.swift +15 -0
- package/package.json +82 -0
package/dist/docs.json
ADDED
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "HealthPlugin",
|
|
4
|
+
"slug": "healthplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "isAvailable",
|
|
10
|
+
"signature": "() => Promise<AvailabilityResult>",
|
|
11
|
+
"parameters": [],
|
|
12
|
+
"returns": "Promise<AvailabilityResult>",
|
|
13
|
+
"tags": [],
|
|
14
|
+
"docs": "Returns whether the current platform supports the native health SDK.",
|
|
15
|
+
"complexTypes": [
|
|
16
|
+
"AvailabilityResult"
|
|
17
|
+
],
|
|
18
|
+
"slug": "isavailable"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "requestAuthorization",
|
|
22
|
+
"signature": "(options: AuthorizationOptions) => Promise<AuthorizationStatus>",
|
|
23
|
+
"parameters": [
|
|
24
|
+
{
|
|
25
|
+
"name": "options",
|
|
26
|
+
"docs": "",
|
|
27
|
+
"type": "AuthorizationOptions"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"returns": "Promise<AuthorizationStatus>",
|
|
31
|
+
"tags": [],
|
|
32
|
+
"docs": "Requests read/write access to the provided data types.",
|
|
33
|
+
"complexTypes": [
|
|
34
|
+
"AuthorizationStatus",
|
|
35
|
+
"AuthorizationOptions"
|
|
36
|
+
],
|
|
37
|
+
"slug": "requestauthorization"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "checkAuthorization",
|
|
41
|
+
"signature": "(options: AuthorizationOptions) => Promise<AuthorizationStatus>",
|
|
42
|
+
"parameters": [
|
|
43
|
+
{
|
|
44
|
+
"name": "options",
|
|
45
|
+
"docs": "",
|
|
46
|
+
"type": "AuthorizationOptions"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"returns": "Promise<AuthorizationStatus>",
|
|
50
|
+
"tags": [],
|
|
51
|
+
"docs": "Checks authorization status for the provided data types without prompting the user.",
|
|
52
|
+
"complexTypes": [
|
|
53
|
+
"AuthorizationStatus",
|
|
54
|
+
"AuthorizationOptions"
|
|
55
|
+
],
|
|
56
|
+
"slug": "checkauthorization"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "readSamples",
|
|
60
|
+
"signature": "(options: QueryOptions) => Promise<ReadSamplesResult>",
|
|
61
|
+
"parameters": [
|
|
62
|
+
{
|
|
63
|
+
"name": "options",
|
|
64
|
+
"docs": "",
|
|
65
|
+
"type": "QueryOptions"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"returns": "Promise<ReadSamplesResult>",
|
|
69
|
+
"tags": [],
|
|
70
|
+
"docs": "Reads samples for the given data type within the specified time frame.",
|
|
71
|
+
"complexTypes": [
|
|
72
|
+
"ReadSamplesResult",
|
|
73
|
+
"QueryOptions"
|
|
74
|
+
],
|
|
75
|
+
"slug": "readsamples"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "saveSample",
|
|
79
|
+
"signature": "(options: WriteSampleOptions) => Promise<void>",
|
|
80
|
+
"parameters": [
|
|
81
|
+
{
|
|
82
|
+
"name": "options",
|
|
83
|
+
"docs": "",
|
|
84
|
+
"type": "WriteSampleOptions"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"returns": "Promise<void>",
|
|
88
|
+
"tags": [],
|
|
89
|
+
"docs": "Writes a single sample to the native health store.",
|
|
90
|
+
"complexTypes": [
|
|
91
|
+
"WriteSampleOptions"
|
|
92
|
+
],
|
|
93
|
+
"slug": "savesample"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "getPluginVersion",
|
|
97
|
+
"signature": "() => Promise<{ version: string; }>",
|
|
98
|
+
"parameters": [],
|
|
99
|
+
"returns": "Promise<{ version: string; }>",
|
|
100
|
+
"tags": [
|
|
101
|
+
{
|
|
102
|
+
"name": "returns",
|
|
103
|
+
"text": "an Promise with version for this device"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "throws",
|
|
107
|
+
"text": "An error if the something went wrong"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"docs": "Get the native Capacitor plugin version",
|
|
111
|
+
"complexTypes": [],
|
|
112
|
+
"slug": "getpluginversion"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"properties": []
|
|
116
|
+
},
|
|
117
|
+
"interfaces": [
|
|
118
|
+
{
|
|
119
|
+
"name": "AvailabilityResult",
|
|
120
|
+
"slug": "availabilityresult",
|
|
121
|
+
"docs": "",
|
|
122
|
+
"tags": [],
|
|
123
|
+
"methods": [],
|
|
124
|
+
"properties": [
|
|
125
|
+
{
|
|
126
|
+
"name": "available",
|
|
127
|
+
"tags": [],
|
|
128
|
+
"docs": "",
|
|
129
|
+
"complexTypes": [],
|
|
130
|
+
"type": "boolean"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "platform",
|
|
134
|
+
"tags": [],
|
|
135
|
+
"docs": "Platform specific details (for debugging/diagnostics).",
|
|
136
|
+
"complexTypes": [],
|
|
137
|
+
"type": "'ios' | 'android' | 'web' | undefined"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "reason",
|
|
141
|
+
"tags": [],
|
|
142
|
+
"docs": "",
|
|
143
|
+
"complexTypes": [],
|
|
144
|
+
"type": "string | undefined"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "AuthorizationStatus",
|
|
150
|
+
"slug": "authorizationstatus",
|
|
151
|
+
"docs": "",
|
|
152
|
+
"tags": [],
|
|
153
|
+
"methods": [],
|
|
154
|
+
"properties": [
|
|
155
|
+
{
|
|
156
|
+
"name": "readAuthorized",
|
|
157
|
+
"tags": [],
|
|
158
|
+
"docs": "",
|
|
159
|
+
"complexTypes": [
|
|
160
|
+
"HealthDataType"
|
|
161
|
+
],
|
|
162
|
+
"type": "HealthDataType[]"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "readDenied",
|
|
166
|
+
"tags": [],
|
|
167
|
+
"docs": "",
|
|
168
|
+
"complexTypes": [
|
|
169
|
+
"HealthDataType"
|
|
170
|
+
],
|
|
171
|
+
"type": "HealthDataType[]"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "writeAuthorized",
|
|
175
|
+
"tags": [],
|
|
176
|
+
"docs": "",
|
|
177
|
+
"complexTypes": [
|
|
178
|
+
"HealthDataType"
|
|
179
|
+
],
|
|
180
|
+
"type": "HealthDataType[]"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "writeDenied",
|
|
184
|
+
"tags": [],
|
|
185
|
+
"docs": "",
|
|
186
|
+
"complexTypes": [
|
|
187
|
+
"HealthDataType"
|
|
188
|
+
],
|
|
189
|
+
"type": "HealthDataType[]"
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "AuthorizationOptions",
|
|
195
|
+
"slug": "authorizationoptions",
|
|
196
|
+
"docs": "",
|
|
197
|
+
"tags": [],
|
|
198
|
+
"methods": [],
|
|
199
|
+
"properties": [
|
|
200
|
+
{
|
|
201
|
+
"name": "read",
|
|
202
|
+
"tags": [],
|
|
203
|
+
"docs": "Data types that should be readable after authorization.",
|
|
204
|
+
"complexTypes": [
|
|
205
|
+
"HealthDataType"
|
|
206
|
+
],
|
|
207
|
+
"type": "HealthDataType[] | undefined"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "write",
|
|
211
|
+
"tags": [],
|
|
212
|
+
"docs": "Data types that should be writable after authorization.",
|
|
213
|
+
"complexTypes": [
|
|
214
|
+
"HealthDataType"
|
|
215
|
+
],
|
|
216
|
+
"type": "HealthDataType[] | undefined"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "ReadSamplesResult",
|
|
222
|
+
"slug": "readsamplesresult",
|
|
223
|
+
"docs": "",
|
|
224
|
+
"tags": [],
|
|
225
|
+
"methods": [],
|
|
226
|
+
"properties": [
|
|
227
|
+
{
|
|
228
|
+
"name": "samples",
|
|
229
|
+
"tags": [],
|
|
230
|
+
"docs": "",
|
|
231
|
+
"complexTypes": [
|
|
232
|
+
"HealthSample"
|
|
233
|
+
],
|
|
234
|
+
"type": "HealthSample[]"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"name": "HealthSample",
|
|
240
|
+
"slug": "healthsample",
|
|
241
|
+
"docs": "",
|
|
242
|
+
"tags": [],
|
|
243
|
+
"methods": [],
|
|
244
|
+
"properties": [
|
|
245
|
+
{
|
|
246
|
+
"name": "dataType",
|
|
247
|
+
"tags": [],
|
|
248
|
+
"docs": "",
|
|
249
|
+
"complexTypes": [
|
|
250
|
+
"HealthDataType"
|
|
251
|
+
],
|
|
252
|
+
"type": "HealthDataType"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"name": "value",
|
|
256
|
+
"tags": [],
|
|
257
|
+
"docs": "",
|
|
258
|
+
"complexTypes": [],
|
|
259
|
+
"type": "number"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"name": "unit",
|
|
263
|
+
"tags": [],
|
|
264
|
+
"docs": "",
|
|
265
|
+
"complexTypes": [
|
|
266
|
+
"HealthUnit"
|
|
267
|
+
],
|
|
268
|
+
"type": "HealthUnit"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "startDate",
|
|
272
|
+
"tags": [],
|
|
273
|
+
"docs": "",
|
|
274
|
+
"complexTypes": [],
|
|
275
|
+
"type": "string"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "endDate",
|
|
279
|
+
"tags": [],
|
|
280
|
+
"docs": "",
|
|
281
|
+
"complexTypes": [],
|
|
282
|
+
"type": "string"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"name": "sourceName",
|
|
286
|
+
"tags": [],
|
|
287
|
+
"docs": "",
|
|
288
|
+
"complexTypes": [],
|
|
289
|
+
"type": "string | undefined"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"name": "sourceId",
|
|
293
|
+
"tags": [],
|
|
294
|
+
"docs": "",
|
|
295
|
+
"complexTypes": [],
|
|
296
|
+
"type": "string | undefined"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"name": "sleepState",
|
|
300
|
+
"tags": [],
|
|
301
|
+
"docs": "Sleep state (only present when dataType is 'sleep')",
|
|
302
|
+
"complexTypes": [
|
|
303
|
+
"SleepState"
|
|
304
|
+
],
|
|
305
|
+
"type": "SleepState"
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"name": "QueryOptions",
|
|
311
|
+
"slug": "queryoptions",
|
|
312
|
+
"docs": "",
|
|
313
|
+
"tags": [],
|
|
314
|
+
"methods": [],
|
|
315
|
+
"properties": [
|
|
316
|
+
{
|
|
317
|
+
"name": "dataType",
|
|
318
|
+
"tags": [],
|
|
319
|
+
"docs": "The type of data to retrieve from the health store.",
|
|
320
|
+
"complexTypes": [
|
|
321
|
+
"HealthDataType"
|
|
322
|
+
],
|
|
323
|
+
"type": "HealthDataType"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"name": "startDate",
|
|
327
|
+
"tags": [],
|
|
328
|
+
"docs": "Inclusive ISO 8601 start date (defaults to now - 1 day).",
|
|
329
|
+
"complexTypes": [],
|
|
330
|
+
"type": "string | undefined"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"name": "endDate",
|
|
334
|
+
"tags": [],
|
|
335
|
+
"docs": "Exclusive ISO 8601 end date (defaults to now).",
|
|
336
|
+
"complexTypes": [],
|
|
337
|
+
"type": "string | undefined"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"name": "limit",
|
|
341
|
+
"tags": [],
|
|
342
|
+
"docs": "Maximum number of samples to return (defaults to 100).",
|
|
343
|
+
"complexTypes": [],
|
|
344
|
+
"type": "number | undefined"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"name": "ascending",
|
|
348
|
+
"tags": [],
|
|
349
|
+
"docs": "Return results sorted ascending by start date (defaults to false).",
|
|
350
|
+
"complexTypes": [],
|
|
351
|
+
"type": "boolean | undefined"
|
|
352
|
+
}
|
|
353
|
+
]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "WriteSampleOptions",
|
|
357
|
+
"slug": "writesampleoptions",
|
|
358
|
+
"docs": "",
|
|
359
|
+
"tags": [],
|
|
360
|
+
"methods": [],
|
|
361
|
+
"properties": [
|
|
362
|
+
{
|
|
363
|
+
"name": "dataType",
|
|
364
|
+
"tags": [],
|
|
365
|
+
"docs": "",
|
|
366
|
+
"complexTypes": [
|
|
367
|
+
"HealthDataType"
|
|
368
|
+
],
|
|
369
|
+
"type": "HealthDataType"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"name": "value",
|
|
373
|
+
"tags": [],
|
|
374
|
+
"docs": "",
|
|
375
|
+
"complexTypes": [],
|
|
376
|
+
"type": "number"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"name": "unit",
|
|
380
|
+
"tags": [],
|
|
381
|
+
"docs": "Optional unit override. If omitted, the default unit for the data type is used\n(count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`, minute for `sleep`).",
|
|
382
|
+
"complexTypes": [
|
|
383
|
+
"HealthUnit"
|
|
384
|
+
],
|
|
385
|
+
"type": "HealthUnit"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"name": "startDate",
|
|
389
|
+
"tags": [],
|
|
390
|
+
"docs": "ISO 8601 start date for the sample. Defaults to now.",
|
|
391
|
+
"complexTypes": [],
|
|
392
|
+
"type": "string | undefined"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "endDate",
|
|
396
|
+
"tags": [],
|
|
397
|
+
"docs": "ISO 8601 end date for the sample. Defaults to startDate.",
|
|
398
|
+
"complexTypes": [],
|
|
399
|
+
"type": "string | undefined"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"name": "metadata",
|
|
403
|
+
"tags": [],
|
|
404
|
+
"docs": "Metadata key-value pairs forwarded to the native APIs where supported.",
|
|
405
|
+
"complexTypes": [
|
|
406
|
+
"Record"
|
|
407
|
+
],
|
|
408
|
+
"type": "Record<string, string>"
|
|
409
|
+
}
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
"enums": [],
|
|
414
|
+
"typeAliases": [
|
|
415
|
+
{
|
|
416
|
+
"name": "HealthDataType",
|
|
417
|
+
"slug": "healthdatatype",
|
|
418
|
+
"docs": "",
|
|
419
|
+
"types": [
|
|
420
|
+
{
|
|
421
|
+
"text": "'steps'",
|
|
422
|
+
"complexTypes": []
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"text": "'distance'",
|
|
426
|
+
"complexTypes": []
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"text": "'calories'",
|
|
430
|
+
"complexTypes": []
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"text": "'heartRate'",
|
|
434
|
+
"complexTypes": []
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"text": "'weight'",
|
|
438
|
+
"complexTypes": []
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"text": "'sleep'",
|
|
442
|
+
"complexTypes": []
|
|
443
|
+
}
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"name": "HealthUnit",
|
|
448
|
+
"slug": "healthunit",
|
|
449
|
+
"docs": "",
|
|
450
|
+
"types": [
|
|
451
|
+
{
|
|
452
|
+
"text": "'count'",
|
|
453
|
+
"complexTypes": []
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"text": "'meter'",
|
|
457
|
+
"complexTypes": []
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"text": "'kilocalorie'",
|
|
461
|
+
"complexTypes": []
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"text": "'bpm'",
|
|
465
|
+
"complexTypes": []
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"text": "'kilogram'",
|
|
469
|
+
"complexTypes": []
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"text": "'minute'",
|
|
473
|
+
"complexTypes": []
|
|
474
|
+
}
|
|
475
|
+
]
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"name": "SleepState",
|
|
479
|
+
"slug": "sleepstate",
|
|
480
|
+
"docs": "",
|
|
481
|
+
"types": [
|
|
482
|
+
{
|
|
483
|
+
"text": "'inBed'",
|
|
484
|
+
"complexTypes": []
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"text": "'asleep'",
|
|
488
|
+
"complexTypes": []
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"text": "'awake'",
|
|
492
|
+
"complexTypes": []
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"text": "'asleepCore'",
|
|
496
|
+
"complexTypes": []
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"text": "'asleepDeep'",
|
|
500
|
+
"complexTypes": []
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"text": "'asleepREM'",
|
|
504
|
+
"complexTypes": []
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
"text": "'unknown'",
|
|
508
|
+
"complexTypes": []
|
|
509
|
+
}
|
|
510
|
+
]
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
"name": "Record",
|
|
514
|
+
"slug": "record",
|
|
515
|
+
"docs": "Construct a type with a set of properties K of type T",
|
|
516
|
+
"types": [
|
|
517
|
+
{
|
|
518
|
+
"text": "{\r\n [P in K]: T;\r\n}",
|
|
519
|
+
"complexTypes": [
|
|
520
|
+
"K",
|
|
521
|
+
"T"
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
}
|
|
526
|
+
],
|
|
527
|
+
"pluginConfigs": []
|
|
528
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep';
|
|
2
|
+
export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute';
|
|
3
|
+
export type SleepState = 'inBed' | 'asleep' | 'awake' | 'asleepCore' | 'asleepDeep' | 'asleepREM' | 'unknown';
|
|
4
|
+
export interface AuthorizationOptions {
|
|
5
|
+
/** Data types that should be readable after authorization. */
|
|
6
|
+
read?: HealthDataType[];
|
|
7
|
+
/** Data types that should be writable after authorization. */
|
|
8
|
+
write?: HealthDataType[];
|
|
9
|
+
}
|
|
10
|
+
export interface AuthorizationStatus {
|
|
11
|
+
readAuthorized: HealthDataType[];
|
|
12
|
+
readDenied: HealthDataType[];
|
|
13
|
+
writeAuthorized: HealthDataType[];
|
|
14
|
+
writeDenied: HealthDataType[];
|
|
15
|
+
}
|
|
16
|
+
export interface AvailabilityResult {
|
|
17
|
+
available: boolean;
|
|
18
|
+
/** Platform specific details (for debugging/diagnostics). */
|
|
19
|
+
platform?: 'ios' | 'android' | 'web';
|
|
20
|
+
reason?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface QueryOptions {
|
|
23
|
+
/** The type of data to retrieve from the health store. */
|
|
24
|
+
dataType: HealthDataType;
|
|
25
|
+
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
|
|
26
|
+
startDate?: string;
|
|
27
|
+
/** Exclusive ISO 8601 end date (defaults to now). */
|
|
28
|
+
endDate?: string;
|
|
29
|
+
/** Maximum number of samples to return (defaults to 100). */
|
|
30
|
+
limit?: number;
|
|
31
|
+
/** Return results sorted ascending by start date (defaults to false). */
|
|
32
|
+
ascending?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface HealthSample {
|
|
35
|
+
dataType: HealthDataType;
|
|
36
|
+
value: number;
|
|
37
|
+
unit: HealthUnit;
|
|
38
|
+
startDate: string;
|
|
39
|
+
endDate: string;
|
|
40
|
+
sourceName?: string;
|
|
41
|
+
sourceId?: string;
|
|
42
|
+
/** Sleep state (only present when dataType is 'sleep') */
|
|
43
|
+
sleepState?: SleepState;
|
|
44
|
+
}
|
|
45
|
+
export interface ReadSamplesResult {
|
|
46
|
+
samples: HealthSample[];
|
|
47
|
+
}
|
|
48
|
+
export interface WriteSampleOptions {
|
|
49
|
+
dataType: HealthDataType;
|
|
50
|
+
value: number;
|
|
51
|
+
/**
|
|
52
|
+
* Optional unit override. If omitted, the default unit for the data type is used
|
|
53
|
+
* (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`, minute for `sleep`).
|
|
54
|
+
*/
|
|
55
|
+
unit?: HealthUnit;
|
|
56
|
+
/** ISO 8601 start date for the sample. Defaults to now. */
|
|
57
|
+
startDate?: string;
|
|
58
|
+
/** ISO 8601 end date for the sample. Defaults to startDate. */
|
|
59
|
+
endDate?: string;
|
|
60
|
+
/** Metadata key-value pairs forwarded to the native APIs where supported. */
|
|
61
|
+
metadata?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
export interface HealthPlugin {
|
|
64
|
+
/** Returns whether the current platform supports the native health SDK. */
|
|
65
|
+
isAvailable(): Promise<AvailabilityResult>;
|
|
66
|
+
/** Requests read/write access to the provided data types. */
|
|
67
|
+
requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
68
|
+
/** Checks authorization status for the provided data types without prompting the user. */
|
|
69
|
+
checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
70
|
+
/** Reads samples for the given data type within the specified time frame. */
|
|
71
|
+
readSamples(options: QueryOptions): Promise<ReadSamplesResult>;
|
|
72
|
+
/** Writes a single sample to the native health store. */
|
|
73
|
+
saveSample(options: WriteSampleOptions): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the native Capacitor plugin version
|
|
76
|
+
*
|
|
77
|
+
* @returns {Promise<{ id: string }>} an Promise with version for this device
|
|
78
|
+
* @throws An error if the something went wrong
|
|
79
|
+
*/
|
|
80
|
+
getPluginVersion(): Promise<{
|
|
81
|
+
version: string;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight' | 'sleep';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram' | 'minute';\nexport type SleepState = 'inBed' | 'asleep' | 'awake' | 'asleepCore' | 'asleepDeep' | 'asleepREM' | 'unknown';\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n /** Sleep state (only present when dataType is 'sleep') */\n sleepState?: SleepState;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`, minute for `sleep`).\n */\n unit?: HealthUnit;\n /** ISO 8601 start date for the sample. Defaults to now. */\n startDate?: string;\n /** ISO 8601 end date for the sample. Defaults to startDate. */\n endDate?: string;\n /** Metadata key-value pairs forwarded to the native APIs where supported. */\n metadata?: Record<string, string>;\n}\n\nexport interface HealthPlugin {\n /** Returns whether the current platform supports the native health SDK. */\n isAvailable(): Promise<AvailabilityResult>;\n /** Requests read/write access to the provided data types. */\n requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Checks authorization status for the provided data types without prompting the user. */\n checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\n /** Writes a single sample to the native health store. */\n saveSample(options: WriteSampleOptions): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,MAAM,GAAG,cAAc,CAAe,QAAQ,EAAE;IACpD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { HealthPlugin } from './definitions';\n\nconst Health = registerPlugin<HealthPlugin>('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\n\nexport * from './definitions';\nexport { Health };\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
import type { AuthorizationOptions, AuthorizationStatus, AvailabilityResult, HealthPlugin, QueryOptions, ReadSamplesResult, WriteSampleOptions } from './definitions';
|
|
3
|
+
export declare class HealthWeb extends WebPlugin implements HealthPlugin {
|
|
4
|
+
isAvailable(): Promise<AvailabilityResult>;
|
|
5
|
+
requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
6
|
+
checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
|
|
7
|
+
readSamples(_options: QueryOptions): Promise<ReadSamplesResult>;
|
|
8
|
+
saveSample(_options: WriteSampleOptions): Promise<void>;
|
|
9
|
+
getPluginVersion(): Promise<{
|
|
10
|
+
version: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
package/dist/esm/web.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WebPlugin } from '@capacitor/core';
|
|
2
|
+
export class HealthWeb extends WebPlugin {
|
|
3
|
+
async isAvailable() {
|
|
4
|
+
return {
|
|
5
|
+
available: false,
|
|
6
|
+
platform: 'web',
|
|
7
|
+
reason: 'Native health APIs are not accessible in a browser environment.',
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
async requestAuthorization(_options) {
|
|
11
|
+
throw this.unimplemented('Health permissions are only available on native platforms.');
|
|
12
|
+
}
|
|
13
|
+
async checkAuthorization(_options) {
|
|
14
|
+
throw this.unimplemented('Health permissions are only available on native platforms.');
|
|
15
|
+
}
|
|
16
|
+
async readSamples(_options) {
|
|
17
|
+
throw this.unimplemented('Reading health data is only available on native platforms.');
|
|
18
|
+
}
|
|
19
|
+
async saveSample(_options) {
|
|
20
|
+
throw this.unimplemented('Writing health data is only available on native platforms.');
|
|
21
|
+
}
|
|
22
|
+
async getPluginVersion() {
|
|
23
|
+
return { version: 'web' };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,WAAW;QACf,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iEAAiE;SAC1E,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAA8B;QACvD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA8B;QACrD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAsB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA4B;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\n QueryOptions,\n ReadSamplesResult,\n WriteSampleOptions,\n} from './definitions';\n\nexport class HealthWeb extends WebPlugin implements HealthPlugin {\n async isAvailable(): Promise<AvailabilityResult> {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n\n async requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async readSamples(_options: QueryOptions): Promise<ReadSamplesResult> {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n\n async saveSample(_options: WriteSampleOptions): Promise<void> {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|