@tryvital/vital-node 1.6.5 → 2.1.1
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/.github/workflows/test-build.yaml +15 -1
- package/__tests__/activity.test.ts +4 -5
- package/__tests__/arrange.ts +5 -12
- package/__tests__/body.test.ts +4 -5
- package/__tests__/link.test.ts +3 -4
- package/__tests__/profile.test.ts +3 -4
- package/__tests__/providers.test.ts +2 -2
- package/__tests__/sleep.test.ts +8 -10
- package/__tests__/user.test.ts +7 -10
- package/__tests__/vitals.test.ts +7 -8
- package/__tests__/workouts.test.ts +4 -5
- package/client/LabTests.ts +0 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/index.ts +3 -3
- package/package.json +2 -2
- package/__tests__/devices.test.ts +0 -16
@@ -2,7 +2,10 @@ on:
|
|
2
2
|
push:
|
3
3
|
branches-ignore:
|
4
4
|
- master
|
5
|
-
|
5
|
+
env:
|
6
|
+
TEST_EU_API_KEY: ${{ secrets.TEST_EU_API_KEY }}
|
7
|
+
TEST_US_API_KEY: ${{ secrets.TEST_US_API_KEY }}
|
8
|
+
TEST_ENVIRONMENT: "sandbox"
|
6
9
|
name: Test compile
|
7
10
|
jobs:
|
8
11
|
test-build:
|
@@ -16,3 +19,14 @@ jobs:
|
|
16
19
|
registry-url: 'https://registry.npmjs.org'
|
17
20
|
- run: npm ci
|
18
21
|
- run: npm run build
|
22
|
+
test-code:
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
# Setup .npmrc file to publish to npm
|
27
|
+
- uses: actions/setup-node@v2
|
28
|
+
with:
|
29
|
+
node-version: '16.x'
|
30
|
+
registry-url: 'https://registry.npmjs.org'
|
31
|
+
- run: npm ci
|
32
|
+
- run: npm run test-client
|
@@ -1,18 +1,17 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testUSClient, testEUClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
|
5
5
|
describe('Activity', () => {
|
6
6
|
it.each([
|
7
|
-
["
|
8
|
-
["
|
9
|
-
["us_api_key", testApiKeyClient],
|
7
|
+
["eu_api_key", testEUClient],
|
8
|
+
["us_api_key", testUSClient],
|
10
9
|
])('should return activity data %p', async (region: string, client: VitalClient) => {
|
11
10
|
const userId = await getUserId(client)
|
12
11
|
const data = await client.Activity.get(
|
13
12
|
userId,
|
14
13
|
new Date("2020-01-01"),
|
15
|
-
new Date("2022-01
|
14
|
+
new Date("2022-12-01"),
|
16
15
|
)
|
17
16
|
expect(data.activity.length).toBeGreaterThan(0)
|
18
17
|
});
|
package/__tests__/arrange.ts
CHANGED
@@ -3,22 +3,15 @@ require('dotenv').config({
|
|
3
3
|
path: '.env'
|
4
4
|
})
|
5
5
|
|
6
|
-
export const
|
7
|
-
|
8
|
-
client_secret: process.env.TEST_CLIENT_SECRET,
|
6
|
+
export const testEUClient = new VitalClient({
|
7
|
+
api_key: process.env.TEST_EU_API_KEY,
|
9
8
|
environment: process.env.TEST_ENVIRONMENT as any,
|
10
|
-
region: "us",
|
11
|
-
});
|
12
|
-
|
13
|
-
export const testEuClient = new VitalClient({
|
14
|
-
client_id: process.env.TEST_EU_CLIENT_ID,
|
15
|
-
client_secret: process.env.TEST_EU_CLIENT_SECRET,
|
16
|
-
environment: "development",
|
17
9
|
region: "eu",
|
18
10
|
});
|
19
11
|
|
20
|
-
|
21
|
-
|
12
|
+
|
13
|
+
export const testUSClient = new VitalClient({
|
14
|
+
api_key: process.env.TEST_US_API_KEY,
|
22
15
|
environment: process.env.TEST_ENVIRONMENT as any,
|
23
16
|
region: "us",
|
24
17
|
});
|
package/__tests__/body.test.ts
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
describe('Body', () => {
|
5
5
|
it.each([
|
6
|
-
["
|
7
|
-
["
|
8
|
-
["us_api_key", testApiKeyClient],
|
6
|
+
["eu_api_key", testEUClient],
|
7
|
+
["us_api_key", testUSClient],
|
9
8
|
])('should return body data %p', async (region: string, client: VitalClient) => {
|
10
9
|
const userId = await getUserId(client)
|
11
10
|
const data = await client.Body.get(
|
12
11
|
userId,
|
13
12
|
new Date("2021-01-01"),
|
14
|
-
new Date("2022-01
|
13
|
+
new Date("2022-12-01"),
|
15
14
|
)
|
16
15
|
expect(data.body.length).toBeGreaterThan(0)
|
17
16
|
});
|
package/__tests__/link.test.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
describe('Link', () => {
|
5
5
|
it.each([
|
6
|
-
["
|
7
|
-
["
|
8
|
-
["us_api_key", testApiKeyClient],
|
6
|
+
["eu_api_key", testEUClient],
|
7
|
+
["us_api_key", testUSClient],
|
9
8
|
])('should create a link token %p', async (region: string, client: VitalClient) => {
|
10
9
|
const userId = await getUserId(client)
|
11
10
|
const data = await client.Link.create(
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
describe('Profile', () => {
|
5
5
|
it.each([
|
6
|
-
["
|
7
|
-
["
|
8
|
-
["us_api_key", testApiKeyClient],
|
6
|
+
["eu_api_key", testEUClient],
|
7
|
+
["us_api_key", testUSClient],
|
9
8
|
])('should return profile data %p', async (region: string, client: VitalClient) => {
|
10
9
|
const userId = await getUserId(client)
|
11
10
|
const data = await client.Profile.get(
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { testUSClient } from "./arrange";
|
2
2
|
|
3
3
|
it('should return supported providers', async () => {
|
4
|
-
const data = await
|
4
|
+
const data = await testUSClient.Providers.getSupportedProviders()
|
5
5
|
expect(data.length).toBeGreaterThan(0)
|
6
6
|
})
|
package/__tests__/sleep.test.ts
CHANGED
@@ -1,31 +1,29 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
describe('Sleep', () => {
|
5
5
|
it.each([
|
6
|
-
["
|
7
|
-
["
|
8
|
-
["us_api_key", testApiKeyClient],
|
6
|
+
["eu_api_key", testEUClient],
|
7
|
+
["us_api_key", testUSClient],
|
9
8
|
])('should return sleep data %p', async (region: string, client: VitalClient) => {
|
10
9
|
const userId = await getUserId(client)
|
11
10
|
const data = await client.Sleep.get(
|
12
11
|
userId,
|
13
12
|
new Date("2021-01-01"),
|
14
|
-
new Date("2022-01
|
13
|
+
new Date("2022-12-01"),
|
15
14
|
)
|
16
15
|
expect(data.sleep.length).toBeGreaterThan(0)
|
17
16
|
});
|
18
17
|
|
19
18
|
it.each([
|
20
|
-
["
|
21
|
-
["
|
22
|
-
["us_api_key", testApiKeyClient],
|
19
|
+
["eu_api_key", testEUClient],
|
20
|
+
["us_api_key", testUSClient],
|
23
21
|
])('should return sleep stream data %p', async (region: string, client: VitalClient) => {
|
24
22
|
const userId = await getUserId(client)
|
25
23
|
const data = await client.Sleep.getSleepWithStream(
|
26
24
|
userId,
|
27
|
-
new Date("
|
28
|
-
new Date("
|
25
|
+
new Date("2022-10-30"),
|
26
|
+
new Date("2022-11-01"),
|
29
27
|
)
|
30
28
|
expect(data.sleep.length).toBeGreaterThan(0)
|
31
29
|
expect(data.sleep[0].sleep_stream).toBeDefined()
|
package/__tests__/user.test.ts
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId, randomString, test_user_id } from "./arrange";
|
3
3
|
|
4
4
|
describe('User', () => {
|
5
5
|
const user_id = randomString(10);
|
6
6
|
it.each([
|
7
|
-
["
|
8
|
-
["
|
9
|
-
["us_api_key", testApiKeyClient],
|
7
|
+
["eu_api_key", testEUClient],
|
8
|
+
["us_api_key", testUSClient],
|
10
9
|
])('should create a user %p', async (region: string, client: VitalClient) => {
|
11
10
|
const user = await client.User.create(
|
12
11
|
user_id,
|
@@ -15,9 +14,8 @@ describe('User', () => {
|
|
15
14
|
});
|
16
15
|
|
17
16
|
it.each([
|
18
|
-
|
19
|
-
|
20
|
-
testApiKeyClient
|
17
|
+
testEUClient,
|
18
|
+
testUSClient,
|
21
19
|
])('should find a user', async (client: VitalClient) => {
|
22
20
|
const user = await client.User.resolve(
|
23
21
|
test_user_id,
|
@@ -26,9 +24,8 @@ describe('User', () => {
|
|
26
24
|
});
|
27
25
|
|
28
26
|
it.each([
|
29
|
-
|
30
|
-
|
31
|
-
testApiKeyClient
|
27
|
+
testEUClient,
|
28
|
+
testUSClient,
|
32
29
|
])('should delete a user', async (client: VitalClient) => {
|
33
30
|
const userToDelete = await getUserId(client, user_id);
|
34
31
|
const user = await client.User.delete(
|
package/__tests__/vitals.test.ts
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
describe('Vitals', () => {
|
5
5
|
it.each([
|
6
|
-
["
|
7
|
-
["
|
8
|
-
|
9
|
-
])('should return glucose data %p', async (region: string, client: VitalClient) => {
|
6
|
+
["eu_api_key", testEUClient],
|
7
|
+
["us_api_key", testUSClient],
|
8
|
+
])('should return heartrate data %p', async (region: string, client: VitalClient) => {
|
10
9
|
const userId = await getUserId(client)
|
11
|
-
const data = await client.Vitals.
|
10
|
+
const data = await client.Vitals.heartrate(
|
12
11
|
userId,
|
13
|
-
new Date("
|
14
|
-
new Date("2022-01
|
12
|
+
new Date("2022-10-01"),
|
13
|
+
new Date("2022-11-01"),
|
15
14
|
)
|
16
15
|
expect(data.length).toBeGreaterThan(0)
|
17
16
|
});
|
@@ -1,17 +1,16 @@
|
|
1
1
|
import { VitalClient } from "..";
|
2
|
-
import {
|
2
|
+
import { testEUClient, testUSClient, getUserId } from "./arrange";
|
3
3
|
|
4
4
|
describe('Workouts', () => {
|
5
5
|
it.each([
|
6
|
-
["
|
7
|
-
["
|
8
|
-
["us_api_key", testApiKeyClient],
|
6
|
+
["eu_api_key", testEUClient],
|
7
|
+
["us_api_key", testUSClient],
|
9
8
|
])('should return workout data %p', async (region: string, client: VitalClient) => {
|
10
9
|
const userId = await getUserId(client)
|
11
10
|
const data = await client.Workouts.get(
|
12
11
|
userId,
|
13
12
|
new Date("2021-01-01"),
|
14
|
-
new Date("2022-01
|
13
|
+
new Date("2022-12-01"),
|
15
14
|
)
|
16
15
|
expect(data.workouts.length).toBeGreaterThan(0)
|
17
16
|
});
|
package/client/LabTests.ts
CHANGED
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi,
|
1
|
+
import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi, LabTestsApi } from './client';
|
2
2
|
import { ClientConfig } from './lib/models';
|
3
3
|
import { VitalsApi } from './client/Vitals';
|
4
4
|
import { ProviderApi } from './client/Provider';
|
@@ -13,7 +13,7 @@ export declare class VitalClient {
|
|
13
13
|
Workouts: WorkoutsApi;
|
14
14
|
Webhooks: WebhooksApi;
|
15
15
|
Vitals: VitalsApi;
|
16
|
-
|
16
|
+
LabTests: LabTestsApi;
|
17
17
|
Profile: ProfileApi;
|
18
18
|
Providers: ProviderApi;
|
19
19
|
Devices: DevicesAPI;
|
package/dist/index.js
CHANGED
@@ -93,7 +93,7 @@ var VitalClient = /** @class */ (function () {
|
|
93
93
|
this.Workouts = new client_1.WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
|
94
94
|
this.Webhooks = new client_1.WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
|
95
95
|
this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
|
96
|
-
this.
|
96
|
+
this.LabTests = new client_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
|
97
97
|
this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
|
98
98
|
this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
|
99
99
|
this.Devices = new client_1.DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
|
package/index.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
ProfileApi,
|
12
12
|
DevicesAPI,
|
13
13
|
MealsApi,
|
14
|
-
|
14
|
+
LabTestsApi
|
15
15
|
} from './client';
|
16
16
|
import { ClientConfig } from './lib/models';
|
17
17
|
import CONFIG from './lib/config';
|
@@ -29,7 +29,7 @@ export class VitalClient {
|
|
29
29
|
Workouts: WorkoutsApi;
|
30
30
|
Webhooks: WebhooksApi;
|
31
31
|
Vitals: VitalsApi;
|
32
|
-
|
32
|
+
LabTests: LabTestsApi;
|
33
33
|
Profile: ProfileApi;
|
34
34
|
Providers: ProviderApi;
|
35
35
|
Devices: DevicesAPI;
|
@@ -75,7 +75,7 @@ export class VitalClient {
|
|
75
75
|
this.Workouts = new WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
|
76
76
|
this.Webhooks = new WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
|
77
77
|
this.Vitals = new VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
|
78
|
-
this.
|
78
|
+
this.LabTests = new LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
|
79
79
|
this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
|
80
80
|
this.Providers = new ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
|
81
81
|
this.Devices = new DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tryvital/vital-node",
|
3
|
-
"version": "1.
|
3
|
+
"version": "2.1.1",
|
4
4
|
"description": "Node client for Vital",
|
5
5
|
"author": "maitham",
|
6
6
|
"keywords": [
|
@@ -15,7 +15,7 @@
|
|
15
15
|
"scripts": {
|
16
16
|
"build": "tsc --outDir dist/",
|
17
17
|
"prepublishOnly": "npm run build",
|
18
|
-
"test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './
|
18
|
+
"test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './__tests__/**/*.ts'",
|
19
19
|
"test-typescript": "tsc --build types/test",
|
20
20
|
"test-client": "jest --config jest.config.js",
|
21
21
|
"test-single": "jest --config -i __tests__/user.test.ts jest.config.js",
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { VitalClient } from "..";
|
2
|
-
import { testClient, testEuClient, getUserId, testApiKeyClient } from "./arrange";
|
3
|
-
|
4
|
-
describe('Devices', () => {
|
5
|
-
it.each([
|
6
|
-
["us", testClient],
|
7
|
-
["eu", testEuClient],
|
8
|
-
["us_api_key", testApiKeyClient],
|
9
|
-
])('should return device data %p', async (region: string, client: VitalClient) => {
|
10
|
-
const userId = await getUserId(client)
|
11
|
-
const data = await client.Devices.get_raw(
|
12
|
-
userId,
|
13
|
-
)
|
14
|
-
expect(data.devices.length).toBeGreaterThan(0)
|
15
|
-
});
|
16
|
-
})
|