From b2a98787c7479410b6c0d61f6a49bd81d0bcee92 Mon Sep 17 00:00:00 2001 From: Pinta365 Date: Thu, 18 Apr 2024 18:57:03 +0200 Subject: [PATCH] docs and new publish workflow --- .github/workflows/publish-jsr.yml | 19 ++--- README.md | 115 +++++++++++++----------------- deno.json | 9 ++- jsr.json | 8 --- 4 files changed, 65 insertions(+), 86 deletions(-) delete mode 100644 jsr.json diff --git a/.github/workflows/publish-jsr.yml b/.github/workflows/publish-jsr.yml index 5e1b2cd..88b18d7 100644 --- a/.github/workflows/publish-jsr.yml +++ b/.github/workflows/publish-jsr.yml @@ -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 \ No newline at end of file + id-token: write + uses: cross-org/workflows/.github/workflows/jsr-publish.yml@main \ No newline at end of file diff --git a/README.md b/README.md index 7fcc0a5..1e5c9f3 100644 --- a/README.md +++ b/README.md @@ -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/oura_api@0.4.0/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"; @@ -60,18 +44,20 @@ 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); @@ -79,50 +65,49 @@ 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 diff --git a/deno.json b/deno.json index cadf501..2ad7b65 100644 --- a/deno.json +++ b/deno.json @@ -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"] diff --git a/jsr.json b/jsr.json deleted file mode 100644 index 1a3ba56..0000000 --- a/jsr.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "@pinta365/oura-api", - "version": "0.5.6", - "exports": "./mod.ts", - "exclude": [ - "scripts" - ] -} \ No newline at end of file