Skip to content

Commit

Permalink
docs and new publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed Apr 18, 2024
1 parent 28fa55a commit b2a9878
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 86 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/publish-jsr.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# .github/workflows/publish-jsr.yml

name: Publish to JSR

# .github/workflows/publish.yml
name: Publish to jsr.io
on:
create:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
release:
types: [released]
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- run: npx jsr publish --config jsr.json
id-token: write
uses: cross-org/workflows/.github/workflows/jsr-publish.yml@main
115 changes: 50 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,31 @@

Library to interact with v2 of the [Oura API](https://cloud.ouraring.com/v2/docs).

Available for **Deno** and **Bun** through [JSR Package](https://jsr.io/@pinta365/oura-api) and for Node.js via a [NPM package](https://www.npmjs.com/package/oura_api).
Deno users can also use the [deno.land/x package](https://deno.land/x/oura_api).
Available as ESM module for **Deno**, **Bun** and **Node.js** through [JSR Package](https://jsr.io/@pinta365/oura-api)
and as CommonJS module for Node.js via a [NPM package](https://www.npmjs.com/package/oura_api). Deno users can also use
the [deno.land/x package](https://deno.land/x/oura_api).

---

## Example usage
## Example usage ESM

### Deno and Bun
### Installation

**Deno install notes**

Through JSR and imports map
```
```bash
# For Deno
deno add @pinta365/oura-api

import { Oura } from "@pinta365/oura-api";
```
Or directly from deno.land/x
```
import { Oura } from "https://deno.land/x/oura_api/mod.ts";
```

> [!NOTE]
>If you're importing the package from deno.land/x the example code will use the latest version but you should always change import URL
>to include a specific version number. Example: https://deno.land/x/[email protected]/mod.ts
---

**Bun Install notes**
```
# For Bun
bunx jsr add @pinta365/oura-api

import { Oura } from "@pinta365/oura-api";
# For Node.js
npx jsr add @pinta365/oura-api
```

```javascript
//from deno.land/x (Deno)
import { Oura, DateFormat } from "https://deno.land/x/oura_api/mod.ts";
//or from JSR (Deno and Bun)
//import { Oura, DateFormat } from "@pinta365/oura-api";
### Usage

```javascript
import { Oura, DateFormat } from "@pinta365/oura-api";

// Replace 'YOUR_ACCESS_TOKEN' with your actual access token
const accessToken = "YOUR_ACCESS_TOKEN";
Expand All @@ -60,69 +44,70 @@ try {
}
```

## Example usage for CommonJS

### Node.js

Install package.

```
npm install oura_api --save
const Api = require('oura_api');
```

Code example.
```javascript

const Api = require('oura_api');
```javascript
const Api = require("oura_api");
// Replace 'YOUR_ACCESS_TOKEN' with your actual access token
const accessToken = "YOUR_ACCESS_TOKEN";
const ouraClient = new Api.Oura(accessToken);

const startDate = "2023-01-01";
const endDate = "2023-01-10";


const example = async () => {
try {
const dailyActivityData = await ouraClient.getDailyActivityDocuments(startDate, endDate);

console.log(`Daily Activity Data: ${JSON.stringify(dailyActivityData, null, 4)}`);
} catch (error) {
} catch (error) {
console.error(`Error fetching daily activity data: ${error}`);
}
};
example();
}
};

example();
```

## Documentaion

Library and method documentation can be found at the [Deno Land documentation](https://deno.land/x/oura_api?doc) page.
Library documentation can be found at the [JSR documentation](https://jsr.io/@pinta365/oura-api/doc) page.

### Included data scopes for v2 of the API.

| Endpoint/Scope | Status |
| :------------------------------------------------------------------------ | :---------- |
| **[Oura Base](https://deno.land/x/oura_api/mod.ts?s=Oura)** | |
| Daily Activity | Implemented |
| Daily Readiness | Implemented |
| Daily Sleep | Implemented |
| Daily Spo2 | Implemented |
| Daily Stress | Implemented |
| Enhanced Tag | Implemented |
| Heart Rate | Implemented |
| Personal Info | Implemented |
| Rest Mode Period | Implemented |
| Ring Configuration | Implemented |
| Session | Implemented |
| Sleep | Implemented |
| Sleep Time | Implemented |
| Tag | DEPRICATED |
| Workout | Implemented |
| **[Webhook Subscription](https://deno.land/x/oura_api/mod.ts?s=Webhook)** | |
| List subscription | Implemented |
| Create subscription | Implemented |
| Update subscription | Implemented |
| Delete subscription | Implemented |
| Renew subscription | Implemented |
| Endpoint/Scope | Status |
| :-------------------------------------------------------------------------- | :---------- |
| **[Oura Base](https://jsr.io/@pinta365/oura-api/doc/~/Oura)** | |
| Daily Activity | Implemented |
| Daily Readiness | Implemented |
| Daily Sleep | Implemented |
| Daily Spo2 | Implemented |
| Daily Stress | Implemented |
| Enhanced Tag | Implemented |
| Heart Rate | Implemented |
| Personal Info | Implemented |
| Rest Mode Period | Implemented |
| Ring Configuration | Implemented |
| Session | Implemented |
| Sleep | Implemented |
| Sleep Time | Implemented |
| Tag | DEPRICATED |
| Workout | Implemented |
| **[Webhook Subscription](https://jsr.io/@pinta365/oura-api/doc/~/Webhook)** | |
| List subscription | Implemented |
| Create subscription | Implemented |
| Update subscription | Implemented |
| Delete subscription | Implemented |
| Renew subscription | Implemented |

### Additional info concerning the webhook API

Expand Down
9 changes: 8 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"name": "@pinta365/oura-api",
"version": "0.5.7",
"exports": "./mod.ts",
"publish": {
"exclude": ["scripts"]
},

"tasks": {
"build_npm": "deno run -A scripts/build_npm.ts",
"publish_jsr": "deno publish --config jsr.json"
"publish-dry": "deno publish --dry-run"
},
"lint": {
"include": ["src"]
Expand Down
8 changes: 0 additions & 8 deletions jsr.json

This file was deleted.

0 comments on commit b2a9878

Please sign in to comment.