health-sync 0.2.4 → 0.3.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 +14 -12
- package/health-sync.example.toml +24 -2
- package/package.json +4 -2
- package/src/auth-onboarding.js +1976 -0
- package/src/cli.js +575 -23
- package/src/config.js +51 -2
- package/src/db.js +73 -37
- package/src/providers/index.js +2 -0
- package/src/providers/whoop.js +422 -0
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ It is designed as a personal data cache: first sync backfills history, then futu
|
|
|
16
16
|
- Withings (Advanced Health Data API, OAuth2)
|
|
17
17
|
- Hevy (public API, API key, Pro account required)
|
|
18
18
|
- Strava (OAuth2 or static access token)
|
|
19
|
+
- WHOOP (OAuth2)
|
|
19
20
|
- Eight Sleep (unofficial API)
|
|
20
21
|
|
|
21
22
|
## Requirements
|
|
@@ -41,31 +42,32 @@ npm link
|
|
|
41
42
|
|
|
42
43
|
## Quick Start
|
|
43
44
|
|
|
44
|
-
1. Initialize config and DB:
|
|
45
|
+
1. Initialize config and DB, then follow the interactive provider onboarding wizard:
|
|
45
46
|
|
|
46
47
|
```bash
|
|
47
48
|
health-sync init
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
-
|
|
51
|
+
The wizard lets you:
|
|
52
|
+
- see all discovered providers in a checklist
|
|
53
|
+
- pick which providers to set up now
|
|
54
|
+
- get provider-specific setup URLs and callback values
|
|
55
|
+
- enter credentials directly into `health-sync.toml`
|
|
56
|
+
- run auth flows and save tokens in `.health-sync.creds`
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
2. (Optional) re-run auth for a single provider later:
|
|
54
59
|
|
|
55
60
|
```bash
|
|
56
61
|
health-sync auth oura
|
|
57
|
-
health-sync auth withings
|
|
58
|
-
health-sync auth strava
|
|
59
|
-
health-sync auth eightsleep
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
3. Sync data:
|
|
63
65
|
|
|
64
66
|
```bash
|
|
65
67
|
health-sync sync
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
|
|
70
|
+
4. Inspect sync state and counts:
|
|
69
71
|
|
|
70
72
|
```bash
|
|
71
73
|
health-sync status
|
|
@@ -95,14 +97,14 @@ api_key = "YOUR_HEVY_API_KEY"
|
|
|
95
97
|
enabled = true
|
|
96
98
|
client_id = "YOUR_CLIENT_ID"
|
|
97
99
|
client_secret = "YOUR_CLIENT_SECRET"
|
|
98
|
-
redirect_uri = "http://
|
|
100
|
+
redirect_uri = "http://localhost:8486/callback"
|
|
99
101
|
```
|
|
100
102
|
|
|
101
103
|
See `health-sync.example.toml` for all provider options.
|
|
102
104
|
|
|
103
105
|
## CLI Commands
|
|
104
106
|
|
|
105
|
-
- `health-sync init`: create a scaffolded config (from `health-sync.example.toml`)
|
|
107
|
+
- `health-sync init`: create a scaffolded config (from `health-sync.example.toml`), create DB tables, and launch interactive provider setup when running in a TTY
|
|
106
108
|
- `health-sync init-db`: create DB tables only (legacy)
|
|
107
109
|
- `health-sync auth <provider>`: run auth flow for one provider/plugin
|
|
108
110
|
- `health-sync sync`: run sync for all enabled providers
|
|
@@ -112,7 +114,7 @@ See `health-sync.example.toml` for all provider options.
|
|
|
112
114
|
|
|
113
115
|
`auth` notes:
|
|
114
116
|
|
|
115
|
-
- Oura, Withings, and
|
|
117
|
+
- Oura, Withings, Strava, and WHOOP: OAuth flow (CLI prints auth URL and waits for callback URL/code).
|
|
116
118
|
- Eight Sleep: username/password grant (or static token).
|
|
117
119
|
- Hevy: no `auth` command; configure `[hevy].api_key` directly.
|
|
118
120
|
|
package/health-sync.example.toml
CHANGED
|
@@ -39,7 +39,7 @@ enabled = false
|
|
|
39
39
|
# OAuth2
|
|
40
40
|
# client_id = "..."
|
|
41
41
|
# client_secret = "..."
|
|
42
|
-
# redirect_uri = "http://
|
|
42
|
+
# redirect_uri = "http://localhost:8485/callback"
|
|
43
43
|
# scopes = "user.metrics,user.activity"
|
|
44
44
|
#
|
|
45
45
|
# Sync tuning:
|
|
@@ -73,7 +73,7 @@ enabled = false
|
|
|
73
73
|
# Option B: OAuth2 (recommended)
|
|
74
74
|
# client_id = "..."
|
|
75
75
|
# client_secret = "..."
|
|
76
|
-
# redirect_uri = "http://
|
|
76
|
+
# redirect_uri = "http://localhost:8486/callback"
|
|
77
77
|
# scopes = "read,activity:read_all"
|
|
78
78
|
# approval_prompt = "auto"
|
|
79
79
|
#
|
|
@@ -82,6 +82,28 @@ enabled = false
|
|
|
82
82
|
# overlap_seconds = 604800 # 7 days
|
|
83
83
|
# page_size = 100 # 1-200
|
|
84
84
|
|
|
85
|
+
[whoop]
|
|
86
|
+
# Set to true to sync this provider.
|
|
87
|
+
enabled = false
|
|
88
|
+
|
|
89
|
+
# OAuth2
|
|
90
|
+
# client_id = "..."
|
|
91
|
+
# client_secret = "..."
|
|
92
|
+
# redirect_uri = "http://localhost:8487/callback"
|
|
93
|
+
#
|
|
94
|
+
# WHOOP OAuth and API endpoints:
|
|
95
|
+
# authorize_url = "https://api.prod.whoop.com/oauth/oauth2/auth"
|
|
96
|
+
# token_url = "https://api.prod.whoop.com/oauth/oauth2/token"
|
|
97
|
+
# api_base_url = "https://api.prod.whoop.com/developer"
|
|
98
|
+
#
|
|
99
|
+
# Include `offline` to receive refresh tokens.
|
|
100
|
+
# scopes = "offline read:recovery read:cycles read:workout read:sleep read:profile read:body_measurement"
|
|
101
|
+
#
|
|
102
|
+
# Sync tuning:
|
|
103
|
+
# start_date = "2010-01-01" # YYYY-MM-DD
|
|
104
|
+
# overlap_days = 7
|
|
105
|
+
# page_size = 25 # 1-25
|
|
106
|
+
|
|
85
107
|
[eightsleep]
|
|
86
108
|
# Set to true to sync this provider.
|
|
87
109
|
enabled = false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "health-sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Node.js port of health-sync",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@iarna/toml": "^2.2.5",
|
|
25
|
-
"
|
|
25
|
+
"@mariozechner/pi-tui": "^0.53.0",
|
|
26
|
+
"better-sqlite3": "^11.9.1",
|
|
27
|
+
"chalk": "^5.6.2"
|
|
26
28
|
},
|
|
27
29
|
"engines": {
|
|
28
30
|
"node": ">=20"
|