@molecule/api-wearable-oura 1.0.1 → 1.0.3
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/LICENSE +111 -24
- package/README.md +223 -223
- package/package.json +7 -7
package/LICENSE
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
Apache License
|
|
2
3
|
Version 2.0, January 2004
|
|
3
4
|
http://www.apache.org/licenses/
|
|
@@ -34,21 +35,33 @@
|
|
|
34
35
|
|
|
35
36
|
"Work" shall mean the work of authorship, whether in Source or
|
|
36
37
|
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
38
40
|
|
|
39
41
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
42
|
form, that is based on (or derived from) the Work and for which the
|
|
41
43
|
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
-
represent, as a whole, an original work of authorship.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
49
62
|
|
|
50
63
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
-
on behalf of whom a Contribution has been received by
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
52
65
|
subsequently incorporated within the Work.
|
|
53
66
|
|
|
54
67
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
@@ -61,8 +74,18 @@
|
|
|
61
74
|
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
75
|
this License, each Contributor hereby grants to You a perpetual,
|
|
63
76
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
-
|
|
65
|
-
and otherwise transfer the Work
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
66
89
|
|
|
67
90
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
91
|
Work or Derivative Works thereof in any medium, with or without
|
|
@@ -84,23 +107,87 @@
|
|
|
84
107
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
108
|
distribution, then any Derivative Works that You distribute must
|
|
86
109
|
include a readable copy of the attribution notices contained
|
|
87
|
-
within such NOTICE file
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
90
138
|
|
|
91
139
|
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
-
names, trademarks, service marks, or product names of the Licensor
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
93
143
|
|
|
94
144
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
-
agreed to in writing, Licensor provides the Work
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
104
191
|
|
|
105
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-16T23:32:18.845Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-wearable-oura
|
|
10
10
|
|
|
11
|
-
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
-
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
-
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
-
|
|
15
11
|
Oura Cloud API v2 bond for `@molecule/api-wearable`.
|
|
16
12
|
|
|
17
13
|
Implements daily activity, sleep, and heart-rate ingestion against the
|
|
@@ -23,6 +19,10 @@ Oura does not track body weight, so {@link createProvider} returns
|
|
|
23
19
|
(e.g. `@molecule/api-wearable-fitbit` or `-withings`) when weight
|
|
24
20
|
data is required.
|
|
25
21
|
|
|
22
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
23
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
24
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
25
|
+
|
|
26
26
|
## Quick Start
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
@@ -51,101 +51,6 @@ npm install @molecule/api-wearable-oura @molecule/api-bond @molecule/api-http @m
|
|
|
51
51
|
|
|
52
52
|
### Interfaces
|
|
53
53
|
|
|
54
|
-
#### `DailyActivity`
|
|
55
|
-
|
|
56
|
-
Daily activity rollup. All fields are zero-defaulted by the bond when
|
|
57
|
-
the provider does not return a value, so handlers can sum across days
|
|
58
|
-
without null-checks.
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
interface DailyActivity {
|
|
62
|
-
/** Calendar day this rollup covers (`YYYY-MM-DD`). */
|
|
63
|
-
date: WearableDate
|
|
64
|
-
/** Total step count for the day. */
|
|
65
|
-
steps: number
|
|
66
|
-
/** Total distance traveled, in meters. */
|
|
67
|
-
distanceMeters: number
|
|
68
|
-
/** Total calories burned (active + BMR), in kilocalories. */
|
|
69
|
-
caloriesOut: number
|
|
70
|
-
/** Active minutes (provider-specific intensity definitions). */
|
|
71
|
-
activeMinutes: number
|
|
72
|
-
/** Floors climbed, when reported. */
|
|
73
|
-
floors?: number
|
|
74
|
-
/** Total elevation gain, in meters, when reported. */
|
|
75
|
-
elevationMeters?: number
|
|
76
|
-
/** Resting heart-rate, in beats per minute, when reported. */
|
|
77
|
-
restingHeartRate?: number
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### `HeartRateSummary`
|
|
82
|
-
|
|
83
|
-
Daily heart-rate summary.
|
|
84
|
-
|
|
85
|
-
```typescript
|
|
86
|
-
interface HeartRateSummary {
|
|
87
|
-
/** Calendar day this summary covers (`YYYY-MM-DD`). */
|
|
88
|
-
date: WearableDate
|
|
89
|
-
/** Resting heart-rate, in beats per minute, when reported. */
|
|
90
|
-
restingHeartRate?: number
|
|
91
|
-
/** Per-zone breakdown, when reported. */
|
|
92
|
-
zones?: HeartRateZone[]
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
#### `HeartRateZone`
|
|
97
|
-
|
|
98
|
-
Heart-rate zone definition (rest/fat-burn/cardio/peak or provider-named).
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
interface HeartRateZone {
|
|
102
|
-
/** Zone label as reported by the provider. */
|
|
103
|
-
name: string
|
|
104
|
-
/** Lower bound of the zone, in beats per minute (inclusive). */
|
|
105
|
-
minBpm: number
|
|
106
|
-
/** Upper bound of the zone, in beats per minute (exclusive). */
|
|
107
|
-
maxBpm: number
|
|
108
|
-
/** Minutes spent in the zone for this period. */
|
|
109
|
-
minutes: number
|
|
110
|
-
/** Calories burned in the zone, in kilocalories. */
|
|
111
|
-
caloriesOut?: number
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
#### `OuraAuthorizeStart`
|
|
116
|
-
|
|
117
|
-
Result of {@link OuraProvider.startAuthorize} — the URL the host
|
|
118
|
-
should redirect the user to plus the `state` value to round-trip.
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
interface OuraAuthorizeStart {
|
|
122
|
-
/** Oura OAuth authorize URL. */
|
|
123
|
-
url: string
|
|
124
|
-
/** Opaque `state` value the host MUST verify on the callback. */
|
|
125
|
-
state: string
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
#### `OuraProvider`
|
|
130
|
-
|
|
131
|
-
Public surface returned by {@link createProvider}. Extends the
|
|
132
|
-
stack-neutral {@link import('@molecule/api-wearable').WearableProvider}
|
|
133
|
-
with an Oura-flavored `startAuthorize()` helper for hosts that want
|
|
134
|
-
the bond to build the authorize URL.
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
interface OuraProvider extends WearableProviderType {
|
|
138
|
-
/**
|
|
139
|
-
* Builds the Oura authorize URL with a random `state` value. The host
|
|
140
|
-
* is responsible for round-tripping `state` through the OAuth callback
|
|
141
|
-
* and verifying it before calling {@link OuraProvider.connect}.
|
|
142
|
-
*
|
|
143
|
-
* @returns The URL to redirect to and the `state` value.
|
|
144
|
-
*/
|
|
145
|
-
startAuthorize(): OuraAuthorizeStart
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
54
|
#### `OuraProviderOptions`
|
|
150
55
|
|
|
151
56
|
Configuration options for {@link createProvider}.
|
|
@@ -211,71 +116,50 @@ interface OuraProviderOptions {
|
|
|
211
116
|
}
|
|
212
117
|
```
|
|
213
118
|
|
|
214
|
-
#### `
|
|
119
|
+
#### `OuraAuthorizeStart`
|
|
215
120
|
|
|
216
|
-
|
|
217
|
-
|
|
121
|
+
Result of {@link OuraProvider.startAuthorize} — the URL the host
|
|
122
|
+
should redirect the user to plus the `state` value to round-trip.
|
|
218
123
|
|
|
219
124
|
```typescript
|
|
220
|
-
interface
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
|
|
225
|
-
/** ISO 8601 sleep start. */
|
|
226
|
-
start: string
|
|
227
|
-
/** ISO 8601 sleep end. */
|
|
228
|
-
end: string
|
|
229
|
-
/** Total time in bed, in minutes. */
|
|
230
|
-
timeInBedMinutes: number
|
|
231
|
-
/** Total time asleep, in minutes (excludes `awake` segments). */
|
|
232
|
-
timeAsleepMinutes: number
|
|
233
|
-
/** Sleep efficiency percentage (0-100). */
|
|
234
|
-
efficiency?: number
|
|
235
|
-
/** Whether this session is the user's primary sleep for the day. */
|
|
236
|
-
isMainSleep: boolean
|
|
237
|
-
/** Per-stage minute totals when the provider reports stages. */
|
|
238
|
-
stageSummary?: SleepStageSummary
|
|
239
|
-
/** Per-segment stage breakdown when the provider reports stages. */
|
|
240
|
-
segments?: SleepStageSegment[]
|
|
125
|
+
interface OuraAuthorizeStart {
|
|
126
|
+
/** Oura OAuth authorize URL. */
|
|
127
|
+
url: string
|
|
128
|
+
/** Opaque `state` value the host MUST verify on the callback. */
|
|
129
|
+
state: string
|
|
241
130
|
}
|
|
242
131
|
```
|
|
243
132
|
|
|
244
|
-
#### `
|
|
133
|
+
#### `OuraProvider`
|
|
245
134
|
|
|
246
|
-
|
|
135
|
+
Public surface returned by {@link createProvider}. Extends the
|
|
136
|
+
stack-neutral {@link import('@molecule/api-wearable').WearableProvider}
|
|
137
|
+
with an Oura-flavored `startAuthorize()` helper for hosts that want
|
|
138
|
+
the bond to build the authorize URL.
|
|
247
139
|
|
|
248
140
|
```typescript
|
|
249
|
-
interface
|
|
250
|
-
/**
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
141
|
+
interface OuraProvider extends WearableProviderType {
|
|
142
|
+
/**
|
|
143
|
+
* Builds the Oura authorize URL with a random `state` value. The host
|
|
144
|
+
* is responsible for round-tripping `state` through the OAuth callback
|
|
145
|
+
* and verifying it before calling {@link OuraProvider.connect}.
|
|
146
|
+
*
|
|
147
|
+
* @returns The URL to redirect to and the `state` value.
|
|
148
|
+
*/
|
|
149
|
+
startAuthorize(): OuraAuthorizeStart
|
|
258
150
|
}
|
|
259
151
|
```
|
|
260
152
|
|
|
261
|
-
#### `
|
|
153
|
+
#### `WearableDateRange`
|
|
262
154
|
|
|
263
|
-
|
|
264
|
-
that only report the coarse "asleep" classification will omit
|
|
265
|
-
`light`/`deep`/`rem`.
|
|
155
|
+
Inclusive date range.
|
|
266
156
|
|
|
267
157
|
```typescript
|
|
268
|
-
interface
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
|
|
273
|
-
/** Minutes in deep sleep. */
|
|
274
|
-
deepMinutes?: number
|
|
275
|
-
/** Minutes in REM sleep. */
|
|
276
|
-
remMinutes?: number
|
|
277
|
-
/** Minutes restless (legacy classifications). */
|
|
278
|
-
restlessMinutes?: number
|
|
158
|
+
interface WearableDateRange {
|
|
159
|
+
/** Lower-bound calendar day (`YYYY-MM-DD`), inclusive. */
|
|
160
|
+
start: WearableDate
|
|
161
|
+
/** Upper-bound calendar day (`YYYY-MM-DD`), inclusive. */
|
|
162
|
+
end: WearableDate
|
|
279
163
|
}
|
|
280
164
|
```
|
|
281
165
|
|
|
@@ -343,16 +227,153 @@ interface WearableCredentialsStore {
|
|
|
343
227
|
}
|
|
344
228
|
```
|
|
345
229
|
|
|
346
|
-
#### `
|
|
230
|
+
#### `DailyActivity`
|
|
347
231
|
|
|
348
|
-
|
|
232
|
+
Daily activity rollup. All fields are zero-defaulted by the bond when
|
|
233
|
+
the provider does not return a value, so handlers can sum across days
|
|
234
|
+
without null-checks.
|
|
349
235
|
|
|
350
236
|
```typescript
|
|
351
|
-
interface
|
|
352
|
-
/**
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
|
|
237
|
+
interface DailyActivity {
|
|
238
|
+
/** Calendar day this rollup covers (`YYYY-MM-DD`). */
|
|
239
|
+
date: WearableDate
|
|
240
|
+
/** Total step count for the day. */
|
|
241
|
+
steps: number
|
|
242
|
+
/** Total distance traveled, in meters. */
|
|
243
|
+
distanceMeters: number
|
|
244
|
+
/** Total calories burned (active + BMR), in kilocalories. */
|
|
245
|
+
caloriesOut: number
|
|
246
|
+
/** Active minutes (provider-specific intensity definitions). */
|
|
247
|
+
activeMinutes: number
|
|
248
|
+
/** Floors climbed, when reported. */
|
|
249
|
+
floors?: number
|
|
250
|
+
/** Total elevation gain, in meters, when reported. */
|
|
251
|
+
elevationMeters?: number
|
|
252
|
+
/** Resting heart-rate, in beats per minute, when reported. */
|
|
253
|
+
restingHeartRate?: number
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### `SleepStageSegment`
|
|
258
|
+
|
|
259
|
+
A contiguous block of a single sleep stage within a sleep session.
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
interface SleepStageSegment {
|
|
263
|
+
/** Normalized stage. */
|
|
264
|
+
stage: SleepStage
|
|
265
|
+
/** ISO 8601 segment start. */
|
|
266
|
+
start: string
|
|
267
|
+
/** ISO 8601 segment end. */
|
|
268
|
+
end: string
|
|
269
|
+
/** Segment duration in seconds (provider-reported when available). */
|
|
270
|
+
durationSeconds: number
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### `SleepStageSummary`
|
|
275
|
+
|
|
276
|
+
Per-stage totals for a sleep session, in minutes. Optional — providers
|
|
277
|
+
that only report the coarse "asleep" classification will omit
|
|
278
|
+
`light`/`deep`/`rem`.
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
interface SleepStageSummary {
|
|
282
|
+
/** Minutes spent awake during the session. */
|
|
283
|
+
awakeMinutes?: number
|
|
284
|
+
/** Minutes in light sleep. */
|
|
285
|
+
lightMinutes?: number
|
|
286
|
+
/** Minutes in deep sleep. */
|
|
287
|
+
deepMinutes?: number
|
|
288
|
+
/** Minutes in REM sleep. */
|
|
289
|
+
remMinutes?: number
|
|
290
|
+
/** Minutes restless (legacy classifications). */
|
|
291
|
+
restlessMinutes?: number
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### `SleepSession`
|
|
296
|
+
|
|
297
|
+
One sleep session. Most users have exactly one per night, but providers
|
|
298
|
+
report naps as separate sessions, so handlers must sum across the array.
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
interface SleepSession {
|
|
302
|
+
/** Provider-specific session id. */
|
|
303
|
+
id: string
|
|
304
|
+
/** Calendar day this session is bucketed under (`YYYY-MM-DD`). */
|
|
305
|
+
date: WearableDate
|
|
306
|
+
/** ISO 8601 sleep start. */
|
|
307
|
+
start: string
|
|
308
|
+
/** ISO 8601 sleep end. */
|
|
309
|
+
end: string
|
|
310
|
+
/** Total time in bed, in minutes. */
|
|
311
|
+
timeInBedMinutes: number
|
|
312
|
+
/** Total time asleep, in minutes (excludes `awake` segments). */
|
|
313
|
+
timeAsleepMinutes: number
|
|
314
|
+
/** Sleep efficiency percentage (0-100). */
|
|
315
|
+
efficiency?: number
|
|
316
|
+
/** Whether this session is the user's primary sleep for the day. */
|
|
317
|
+
isMainSleep: boolean
|
|
318
|
+
/** Per-stage minute totals when the provider reports stages. */
|
|
319
|
+
stageSummary?: SleepStageSummary
|
|
320
|
+
/** Per-segment stage breakdown when the provider reports stages. */
|
|
321
|
+
segments?: SleepStageSegment[]
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
#### `HeartRateZone`
|
|
326
|
+
|
|
327
|
+
Heart-rate zone definition (rest/fat-burn/cardio/peak or provider-named).
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
interface HeartRateZone {
|
|
331
|
+
/** Zone label as reported by the provider. */
|
|
332
|
+
name: string
|
|
333
|
+
/** Lower bound of the zone, in beats per minute (inclusive). */
|
|
334
|
+
minBpm: number
|
|
335
|
+
/** Upper bound of the zone, in beats per minute (exclusive). */
|
|
336
|
+
maxBpm: number
|
|
337
|
+
/** Minutes spent in the zone for this period. */
|
|
338
|
+
minutes: number
|
|
339
|
+
/** Calories burned in the zone, in kilocalories. */
|
|
340
|
+
caloriesOut?: number
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
#### `HeartRateSummary`
|
|
345
|
+
|
|
346
|
+
Daily heart-rate summary.
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
interface HeartRateSummary {
|
|
350
|
+
/** Calendar day this summary covers (`YYYY-MM-DD`). */
|
|
351
|
+
date: WearableDate
|
|
352
|
+
/** Resting heart-rate, in beats per minute, when reported. */
|
|
353
|
+
restingHeartRate?: number
|
|
354
|
+
/** Per-zone breakdown, when reported. */
|
|
355
|
+
zones?: HeartRateZone[]
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
#### `WeightEntry`
|
|
360
|
+
|
|
361
|
+
One body-weight reading.
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
interface WeightEntry {
|
|
365
|
+
/** ISO 8601 timestamp at which the reading was taken. */
|
|
366
|
+
recordedAt: string
|
|
367
|
+
/** Calendar day of the reading (`YYYY-MM-DD`). */
|
|
368
|
+
date: WearableDate
|
|
369
|
+
/** Weight in kilograms. */
|
|
370
|
+
weightKg: number
|
|
371
|
+
/** Body-fat percentage (0-100), when reported. */
|
|
372
|
+
bodyFatPercent?: number
|
|
373
|
+
/** BMI (kg / m²), when reported. */
|
|
374
|
+
bmi?: number
|
|
375
|
+
/** Provider-specific entry id. */
|
|
376
|
+
id?: string
|
|
356
377
|
}
|
|
357
378
|
```
|
|
358
379
|
|
|
@@ -442,29 +463,18 @@ interface WearableProvider {
|
|
|
442
463
|
}
|
|
443
464
|
```
|
|
444
465
|
|
|
445
|
-
|
|
466
|
+
### Types
|
|
446
467
|
|
|
447
|
-
|
|
468
|
+
#### `WearableDate`
|
|
469
|
+
|
|
470
|
+
Calendar-day identifier in `YYYY-MM-DD` format. Wearable providers
|
|
471
|
+
universally bucket activity/sleep/HR data by local-day, so the core
|
|
472
|
+
exchanges date strings (not absolute timestamps) for per-day reads.
|
|
448
473
|
|
|
449
474
|
```typescript
|
|
450
|
-
|
|
451
|
-
/** ISO 8601 timestamp at which the reading was taken. */
|
|
452
|
-
recordedAt: string
|
|
453
|
-
/** Calendar day of the reading (`YYYY-MM-DD`). */
|
|
454
|
-
date: WearableDate
|
|
455
|
-
/** Weight in kilograms. */
|
|
456
|
-
weightKg: number
|
|
457
|
-
/** Body-fat percentage (0-100), when reported. */
|
|
458
|
-
bodyFatPercent?: number
|
|
459
|
-
/** BMI (kg / m²), when reported. */
|
|
460
|
-
bmi?: number
|
|
461
|
-
/** Provider-specific entry id. */
|
|
462
|
-
id?: string
|
|
463
|
-
}
|
|
475
|
+
type WearableDate = string
|
|
464
476
|
```
|
|
465
477
|
|
|
466
|
-
### Types
|
|
467
|
-
|
|
468
478
|
#### `SleepStage`
|
|
469
479
|
|
|
470
480
|
Sleep stage taxonomy normalized across providers.
|
|
@@ -478,16 +488,6 @@ Sleep stage taxonomy normalized across providers.
|
|
|
478
488
|
type SleepStage = 'awake' | 'light' | 'deep' | 'rem' | 'restless' | 'asleep' | 'unknown'
|
|
479
489
|
```
|
|
480
490
|
|
|
481
|
-
#### `WearableDate`
|
|
482
|
-
|
|
483
|
-
Calendar-day identifier in `YYYY-MM-DD` format. Wearable providers
|
|
484
|
-
universally bucket activity/sleep/HR data by local-day, so the core
|
|
485
|
-
exchanges date strings (not absolute timestamps) for per-day reads.
|
|
486
|
-
|
|
487
|
-
```typescript
|
|
488
|
-
type WearableDate = string
|
|
489
|
-
```
|
|
490
|
-
|
|
491
491
|
### Functions
|
|
492
492
|
|
|
493
493
|
#### `base64UrlEncode(bytes)`
|
|
@@ -502,17 +502,34 @@ function base64UrlEncode(bytes: Uint8Array<ArrayBufferLike>): string
|
|
|
502
502
|
|
|
503
503
|
**Returns:** A base64url string.
|
|
504
504
|
|
|
505
|
-
#### `
|
|
505
|
+
#### `fromOuraActivity(date, entry)`
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
Translates an Oura `usercollection/daily_activity` entry into the
|
|
508
|
+
normalized {@link DailyActivity} shape. Missing fields are
|
|
509
|
+
zero-defaulted so handlers can sum across days without null guards.
|
|
508
510
|
|
|
509
511
|
```typescript
|
|
510
|
-
function
|
|
512
|
+
function fromOuraActivity(date: string, entry: OuraDailyActivityEntry | undefined): DailyActivity
|
|
511
513
|
```
|
|
512
514
|
|
|
513
|
-
- `
|
|
515
|
+
- `date` — The calendar day requested.
|
|
516
|
+
- `entry` — Oura's daily-activity response entry, or `undefined`.
|
|
514
517
|
|
|
515
|
-
**Returns:**
|
|
518
|
+
**Returns:** A normalized daily activity record.
|
|
519
|
+
|
|
520
|
+
#### `mapSleepPhaseDigit(digit)`
|
|
521
|
+
|
|
522
|
+
Maps an Oura `sleep_phase_5_min` digit onto our normalized
|
|
523
|
+
{@link SleepStage} taxonomy. Oura uses `1=deep`, `2=light`, `3=rem`,
|
|
524
|
+
`4=awake`; anything else falls through to `unknown`.
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
function mapSleepPhaseDigit(digit: string): SleepStage
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
- `digit` — The single hypnogram character.
|
|
531
|
+
|
|
532
|
+
**Returns:** A normalized sleep stage.
|
|
516
533
|
|
|
517
534
|
#### `decodeOuraHypnogram(hypnogram, bedtimeStart)`
|
|
518
535
|
|
|
@@ -535,20 +552,23 @@ function decodeOuraHypnogram(
|
|
|
535
552
|
|
|
536
553
|
**Returns:** Decoded sleep segments, or `undefined` when no hypnogram exists.
|
|
537
554
|
|
|
538
|
-
#### `
|
|
555
|
+
#### `fromOuraSleep(date, raw)`
|
|
539
556
|
|
|
540
|
-
Translates an Oura `usercollection/
|
|
541
|
-
normalized {@link
|
|
542
|
-
|
|
557
|
+
Translates an Oura `usercollection/sleep` payload into a list of
|
|
558
|
+
normalized {@link SleepSession} records ordered by start ascending.
|
|
559
|
+
|
|
560
|
+
Oura's `type === 'long_sleep'` corresponds to the user's main nightly
|
|
561
|
+
sleep — the bond marks any matching session as `isMainSleep: true`,
|
|
562
|
+
with naps and short sessions as `false`.
|
|
543
563
|
|
|
544
564
|
```typescript
|
|
545
|
-
function
|
|
565
|
+
function fromOuraSleep(date: string, raw: OuraSleepResponse): SleepSession[]
|
|
546
566
|
```
|
|
547
567
|
|
|
548
|
-
- `date` —
|
|
549
|
-
- `
|
|
568
|
+
- `date` — Calendar day requested.
|
|
569
|
+
- `raw` — Oura's sleep response payload.
|
|
550
570
|
|
|
551
|
-
**Returns:**
|
|
571
|
+
**Returns:** Normalized sleep sessions.
|
|
552
572
|
|
|
553
573
|
#### `fromOuraHeartRate(date, raw)`
|
|
554
574
|
|
|
@@ -569,37 +589,17 @@ function fromOuraHeartRate(date: string, raw: OuraHeartRateResponse): HeartRateS
|
|
|
569
589
|
|
|
570
590
|
**Returns:** A normalized heart-rate summary.
|
|
571
591
|
|
|
572
|
-
#### `
|
|
573
|
-
|
|
574
|
-
Translates an Oura `usercollection/sleep` payload into a list of
|
|
575
|
-
normalized {@link SleepSession} records ordered by start ascending.
|
|
576
|
-
|
|
577
|
-
Oura's `type === 'long_sleep'` corresponds to the user's main nightly
|
|
578
|
-
sleep — the bond marks any matching session as `isMainSleep: true`,
|
|
579
|
-
with naps and short sessions as `false`.
|
|
580
|
-
|
|
581
|
-
```typescript
|
|
582
|
-
function fromOuraSleep(date: string, raw: OuraSleepResponse): SleepSession[]
|
|
583
|
-
```
|
|
584
|
-
|
|
585
|
-
- `date` — Calendar day requested.
|
|
586
|
-
- `raw` — Oura's sleep response payload.
|
|
587
|
-
|
|
588
|
-
**Returns:** Normalized sleep sessions.
|
|
589
|
-
|
|
590
|
-
#### `mapSleepPhaseDigit(digit)`
|
|
592
|
+
#### `createProvider(options)`
|
|
591
593
|
|
|
592
|
-
|
|
593
|
-
{@link SleepStage} taxonomy. Oura uses `1=deep`, `2=light`, `3=rem`,
|
|
594
|
-
`4=awake`; anything else falls through to `unknown`.
|
|
594
|
+
Creates an Oura wearable provider.
|
|
595
595
|
|
|
596
596
|
```typescript
|
|
597
|
-
function
|
|
597
|
+
function createProvider(options: OuraProviderOptions): OuraProvider
|
|
598
598
|
```
|
|
599
599
|
|
|
600
|
-
- `
|
|
600
|
+
- `options` — Required: `redirectUri` + `credentialsStore`. Falls back to `OAUTH_OURA_CLIENT_ID` / `OAUTH_OURA_CLIENT_SECRET` env vars when `clientId` / `clientSecret` are omitted.
|
|
601
601
|
|
|
602
|
-
**Returns:**
|
|
602
|
+
**Returns:** An Oura-flavored {@link OuraProvider}.
|
|
603
603
|
|
|
604
604
|
### Constants
|
|
605
605
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-wearable-oura",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Oura Ring Cloud API v2 bond for molecule.dev — daily activity, sleep (REM/deep/light), and heart-rate ingestion via OAuth 2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"@molecule/api-wearable": "^1.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@molecule/api-bond": "1.0.
|
|
42
|
-
"@molecule/api-http": "1.0.
|
|
43
|
-
"@molecule/api-wearable": "1.0.
|
|
44
|
-
"@types/node": "26.
|
|
41
|
+
"@molecule/api-bond": "1.0.3",
|
|
42
|
+
"@molecule/api-http": "1.0.3",
|
|
43
|
+
"@molecule/api-wearable": "1.0.3",
|
|
44
|
+
"@types/node": "26.6.5",
|
|
45
45
|
"typescript": "6.0.3",
|
|
46
|
-
"vitest": "4.1.
|
|
46
|
+
"vitest": "4.1.12"
|
|
47
47
|
},
|
|
48
48
|
"repository": {
|
|
49
49
|
"type": "git",
|
|
50
50
|
"url": "https://github.com/molecule-dev/molecule.git",
|
|
51
51
|
"directory": "packages/api/bonds/wearable/oura"
|
|
52
52
|
},
|
|
53
|
-
"homepage": "https://
|
|
53
|
+
"homepage": "https://www.molecule.dev/packages/api-wearable-oura",
|
|
54
54
|
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|