Commit graph

18 commits

Author SHA1 Message Date
fb5851c1ae v11: use HealthUnit.fromString('kg') instead of HealthUnitPrefix 2026-08-22 23:29:16 +01:00
efc1bc82ab v10: full version — HealthKit reading + POST to /ingest 2026-08-22 23:25:58 +01:00
7b7d2ac0b3 v9: minimal test with timeout + IP fallback + catch 2026-08-22 23:21:47 +01:00
1b84eb8c60 v8: minimal test — just fetch /health and log 2026-08-22 23:20:35 +01:00
270d6645f7 fix v7: wrap in async main() to avoid top-level await parse error
Scripting app's JavaScriptCore doesn't support top-level await in
file scope. Wrapped everything in async main() + .then(Script.exit).
Converted function declarations to arrow functions.
2026-08-22 23:16:48 +01:00
9c8dac7ec4 fix: add version number to script header for debugging 2026-08-22 23:11:54 +01:00
a08048b918 fix: add @ts-nocheck to suppress Scripting app type errors
The Scripting app's type checker doesn't recognize Health/HealthUnit/
HealthUnitPrefix as global types. @ts-nocheck skips type checking
entirely — the APIs exist at runtime.
2026-08-22 23:11:30 +01:00
0673dd822f fix: remove type annotations, use HealthUnitPrefix + millimeterOfMercury
- Remove all TS type annotations (HealthQuantityType, HealthUnit etc.)
  to avoid 'string not assignable' errors — let the app infer types
- HealthMetricPrefix → HealthUnitPrefix (correct enum name per docs)
- HealthUnit.fromString('mmHg') → HealthUnit.millimeterOfMercury()
  (confirmed in docs: line 35229)
2026-08-22 23:08:53 +01:00
ddc6a54d84 fix: import Notification from scripting, use HealthQuantityType type
- Notification is not global, must import from 'scripting'
- queryQuantitySamples expects HealthQuantityType not string
2026-08-22 23:00:30 +01:00
bcd8c1241b fix: rewrite script as TypeScript for Scripting app (.tsx)
Scripting app expects TypeScript with import from 'scripting' and Script.exit().
- Renamed health-sync.js → health-sync.tsx
- Added 'import { Script } from "scripting"' and Script.exit() at end
- Added TypeScript type annotations
- Health/HealthUnit/Notification/fetch are global APIs (no import needed)
2026-08-22 22:55:55 +01:00
ac2d2ad0ff fix: rewrite health-sync.js for Scripting app API
- fetch() instead of new Request() + req.loadJSON() (Scriptable API)
- Notification.schedule({title, body}) instead of new Notification() + n.schedule()
- allowInsecureRequest: true for HTTP (Scripting app blocks HTTP by default)
- This was the real reason 'nothing happened' — Scriptable API doesn't exist in Scripting app
2026-08-22 22:51:28 +01:00
067bf7a769 fix: health-sync.js HealthUnit method names + serve as inline text
- HealthUnit.gram(prefix) → HealthUnit.gramUnit(prefix) (Scripting app API)
- HealthUnit.millimeterOfMercury() → HealthUnit.fromString('mmHg')
- Updated header: Scriptable → Scripting app
- content-disposition: inline instead of attachment (fixes download issue)
2026-08-22 22:43:16 +01:00
51b864438b fix: use Scripting app API (Health.queryQuantitySamples + HealthUnit) 2026-08-21 00:19:27 +01:00
e01c0b92e3 debug: add console.log at every step to trace execution 2026-08-21 00:14:41 +01:00
aa05c9c8d4 fix: await Notification.schedule() so notification fires before script exits 2026-08-21 00:10:45 +01:00
2b5751d50e fix: remove Script.done() — not a function in Scriptable 2026-08-21 00:08:31 +01:00
c65affc66c fix: use Scriptable Health API (new Health with string units) 2026-08-21 00:05:56 +01:00
191f5f473b fix: rewrite health-sync.js for current Scripting API
Old script used deprecated Health.read() with Health.Types.* and .quantity
— every read silently failed in try/catch, so no samples were ever collected.

Rewrote to use Health.queryQuantitySamples() with string type identifiers
and .quantityValue(unit) per current Scripting app docs. Added proper units
(kg, mmHg, count/min, count, percent) for each metric type.

Also adds /scriptable/health-sync.js endpoint to serve the script directly.
2026-08-20 23:54:08 +01:00