Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@tryvital/vital-node

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tryvital/vital-node - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

import { VitalClient } from "..";
import { testClient, testEuClient, testApiKeyClient, getUserId } from "./arrange";
import { testUSClient, testEUClient, getUserId } from "./arrange";

@@ -7,5 +7,4 @@

it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return activity data %p', async (region: string, client: VitalClient) => {

@@ -16,3 +15,3 @@ const userId = await getUserId(client)

new Date("2020-01-01"),
new Date("2022-01-02"),
new Date("2022-12-01"),
)

@@ -19,0 +18,0 @@ expect(data.activity.length).toBeGreaterThan(0)

@@ -6,18 +6,11 @@ import { VitalClient } from "..";

export const testClient = new VitalClient({
client_id: process.env.TEST_CLIENT_ID,
client_secret: process.env.TEST_CLIENT_SECRET,
export const testEUClient = new VitalClient({
api_key: process.env.TEST_EU_API_KEY,
environment: process.env.TEST_ENVIRONMENT as any,
region: "us",
});
export const testEuClient = new VitalClient({
client_id: process.env.TEST_EU_CLIENT_ID,
client_secret: process.env.TEST_EU_CLIENT_SECRET,
environment: "development",
region: "eu",
});
export const testApiKeyClient = new VitalClient({
api_key: process.env.TEST_API_KEY,
export const testUSClient = new VitalClient({
api_key: process.env.TEST_US_API_KEY,
environment: process.env.TEST_ENVIRONMENT as any,

@@ -24,0 +17,0 @@ region: "us",

import { VitalClient } from "..";
import { getUserId, testApiKeyClient, testClient, testEuClient } from "./arrange";
import { testEUClient, testUSClient, getUserId } from "./arrange";
describe('Body', () => {
it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return body data %p', async (region: string, client: VitalClient) => {

@@ -14,3 +13,3 @@ const userId = await getUserId(client)

new Date("2021-01-01"),
new Date("2022-01-02"),
new Date("2022-12-01"),
)

@@ -17,0 +16,0 @@ expect(data.body.length).toBeGreaterThan(0)

import { VitalClient } from "..";
import { getUserId, testApiKeyClient, testClient, testEuClient } from "./arrange";
import { testEUClient, testUSClient, getUserId } from "./arrange";
describe('Link', () => {
it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should create a link token %p', async (region: string, client: VitalClient) => {

@@ -10,0 +9,0 @@ const userId = await getUserId(client)

import { VitalClient } from "..";
import { testClient, testEuClient, getUserId, testApiKeyClient } from "./arrange";
import { testEUClient, testUSClient, getUserId } from "./arrange";
describe('Profile', () => {
it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return profile data %p', async (region: string, client: VitalClient) => {

@@ -10,0 +9,0 @@ const userId = await getUserId(client)

@@ -1,6 +0,6 @@

import { testApiKeyClient } from "./arrange";
import { testUSClient } from "./arrange";
it('should return supported providers', async () => {
const data = await testApiKeyClient.Providers.getSupportedProviders()
const data = await testUSClient.Providers.getSupportedProviders()
expect(data.length).toBeGreaterThan(0)
})
import { VitalClient } from "..";
import { testClient, testEuClient, getUserId, testApiKeyClient } from "./arrange";
import { testEUClient, testUSClient, getUserId } from "./arrange";
describe('Sleep', () => {
it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return sleep data %p', async (region: string, client: VitalClient) => {

@@ -14,3 +13,3 @@ const userId = await getUserId(client)

new Date("2021-01-01"),
new Date("2022-01-02"),
new Date("2022-12-01"),
)

@@ -21,5 +20,4 @@ expect(data.sleep.length).toBeGreaterThan(0)

it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return sleep stream data %p', async (region: string, client: VitalClient) => {

@@ -29,4 +27,4 @@ const userId = await getUserId(client)

userId,
new Date("2021-09-10"),
new Date("2021-10-10"),
new Date("2022-10-30"),
new Date("2022-11-01"),
)

@@ -33,0 +31,0 @@ expect(data.sleep.length).toBeGreaterThan(0)

import { VitalClient } from "..";
import { getUserId, randomString, testApiKeyClient, testClient, testEuClient, test_user_id } from "./arrange";
import { testEUClient, testUSClient, getUserId, randomString, test_user_id } from "./arrange";

@@ -7,5 +7,4 @@ describe('User', () => {

it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should create a user %p', async (region: string, client: VitalClient) => {

@@ -19,5 +18,4 @@ const user = await client.User.create(

it.each([
testClient,
testEuClient,
testApiKeyClient
testEUClient,
testUSClient,
])('should find a user', async (client: VitalClient) => {

@@ -31,5 +29,4 @@ const user = await client.User.resolve(

it.each([
testClient,
testEuClient,
testApiKeyClient
testEUClient,
testUSClient,
])('should delete a user', async (client: VitalClient) => {

@@ -36,0 +33,0 @@ const userToDelete = await getUserId(client, user_id);

import { VitalClient } from "..";
import { testClient, testEuClient, getUserId, testApiKeyClient } from "./arrange";
import { testEUClient, testUSClient, getUserId } from "./arrange";
describe('Vitals', () => {
it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
])('should return glucose data %p', async (region: string, client: VitalClient) => {
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return heartrate data %p', async (region: string, client: VitalClient) => {
const userId = await getUserId(client)
const data = await client.Vitals.glucose(
const data = await client.Vitals.heartrate(
userId,
new Date("2021-01-01"),
new Date("2022-01-02"),
new Date("2022-10-01"),
new Date("2022-11-01"),
)

@@ -16,0 +15,0 @@ expect(data.length).toBeGreaterThan(0)

import { VitalClient } from "..";
import { testClient, testEuClient, getUserId, testApiKeyClient } from "./arrange";
import { testEUClient, testUSClient, getUserId } from "./arrange";
describe('Workouts', () => {
it.each([
["us", testClient],
["eu", testEuClient],
["us_api_key", testApiKeyClient],
["eu_api_key", testEUClient],
["us_api_key", testUSClient],
])('should return workout data %p', async (region: string, client: VitalClient) => {

@@ -14,3 +13,3 @@ const userId = await getUserId(client)

new Date("2021-01-01"),
new Date("2022-01-02"),
new Date("2022-12-01"),
)

@@ -17,0 +16,0 @@ expect(data.workouts.length).toBeGreaterThan(0)

@@ -12,1 +12,2 @@ export { ActivityApi } from './Activity';

export { MealsApi } from './Meals';
export { TestkitsApi } from "./Testkits";

@@ -11,3 +11,3 @@ import { AxiosInstance } from 'axios';

Physician,
} from './models/testkit_models';
} from './models/lab_tests_model';

@@ -100,4 +100,2 @@

export class LabTestsApi {

@@ -104,0 +102,0 @@ baseURL: string;

@@ -1,7 +0,5 @@

import internal = require("stream");
import { IntegrationKeyOut } from "svix";
export interface PatientAdress {
receiver_name: string;
street: string;
first_line: string;
second_line?: string;
city: string;

@@ -12,3 +10,2 @@ state: string;

phone_number: string;
street_number?: string;
}

@@ -19,15 +16,3 @@

gender: string;
email: string;
}
export interface Physician {
first_name: string;
last_name: string;
npi: string;
email?: string;
licensed_states?: string[];
created_at?: string;
updated_at?: string;
}
export interface Marker {

@@ -49,26 +34,14 @@ name: string;

export interface TestkitEvent {
id: number;
created_at: string;
status: string;
}
export interface Order {
user_id: string;
id: string;
team_id: string;
created_on: Date;
updated_on: Date;
patient_details: PatientDetails;
patient_address: PatientAdress;
lab_test: Testkit;
// TODO CHECK WHAT DETAILS IS
details: Object;
created_at: string;
updated_at: string;
events: TestkitEvent;
user_key?: string;
sample_id?: string;
notes?: string;
status?:
status:
| 'ordered'

@@ -89,4 +62,18 @@ | 'transit_customer'

| "lost";
user_key: string;
testkit_id: string;
testkit: Testkit;
inbound_tracking_number?: string;
outbound_tracking_number?: string;
outbound_courier?: string;
inbound_courier?: string;
}
export interface OrderResponse {
orders: Order[];
total: number;
page: number;
size: number;
}
export interface OrderRequestResponse {

@@ -98,21 +85,2 @@ order: Order;

export interface LabClientFacing {
slug: string;
name: string;
first_line_address: string;
city: string;
zipcode: string;
}
export interface ClientFacingLabTest {
id: string;
slug: string;
name: string;
sample_type: string;
method: string;
price: number;
is_active: boolean;
lab: LabClientFacing;
markers: Marker;
}
export interface TestkitResponse {

@@ -125,15 +93,16 @@ testkits: Testkit[];

dob: string;
clia_number: string;
patient: string;
provider: string;
laboratory: string;
date_reported: string;
date_collected: string;
specimen_number: string;
date_received?: string;
clia?: string;
provider?: string;
laboratory?: string;
date_received?: string;
}
export interface LabResultsResponse {
export interface LabResultsRaw {
metadata: LabResultsMetadata;
results: Object;
}
results: Record<string, string>;
}

@@ -12,1 +12,2 @@ export { ActivityApi } from './Activity';

export { MealsApi } from './Meals';
export { TestkitsApi } from "./Testkits";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.LabTestsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
exports.TestkitsApi = exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.LabTestsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
var Activity_1 = require("./Activity");

@@ -26,1 +26,3 @@ Object.defineProperty(exports, "ActivityApi", { enumerable: true, get: function () { return Activity_1.ActivityApi; } });

Object.defineProperty(exports, "MealsApi", { enumerable: true, get: function () { return Meals_1.MealsApi; } });
var Testkits_1 = require("./Testkits");
Object.defineProperty(exports, "TestkitsApi", { enumerable: true, get: function () { return Testkits_1.TestkitsApi; } });
import { AxiosInstance } from 'axios';
import { ClientFacingLabTest, LabResultsMetadata, LabResultsResponse, Order, OrderRequestResponse, PatientAdress, PatientDetails, Physician } from './models/testkit_models';
import { ClientFacingLabTest, LabResultsMetadata, LabResultsResponse, Order, OrderRequestResponse, PatientAdress, PatientDetails, Physician } from './models/lab_tests_model';
export declare class OrdersApi {

@@ -4,0 +4,0 @@ baseURL: string;

export interface PatientAdress {
receiver_name: string;
street: string;
first_line: string;
second_line?: string;
city: string;

@@ -9,3 +10,2 @@ state: string;

phone_number: string;
street_number?: string;
}

@@ -15,13 +15,3 @@ export interface PatientDetails {

gender: string;
email: string;
}
export interface Physician {
first_name: string;
last_name: string;
npi: string;
email?: string;
licensed_states?: string[];
created_at?: string;
updated_at?: string;
}
export interface Marker {

@@ -41,23 +31,28 @@ name: string;

}
export interface TestkitEvent {
id: number;
created_at: string;
status: string;
}
export interface Order {
user_id: string;
id: string;
team_id: string;
created_on: Date;
updated_on: Date;
patient_details: PatientDetails;
patient_address: PatientAdress;
lab_test: Testkit;
details: Object;
created_at: string;
updated_at: string;
events: TestkitEvent;
user_key?: string;
sample_id?: string;
notes?: string;
status?: 'ordered' | 'transit_customer' | 'out_for_delivery' | 'with_customer' | 'transit_lab' | 'delivered_to_lab' | 'processing_lab' | 'completed' | 'failure_to_deliver_to_customer' | 'failure_to_deliver_to_lab' | 'cancelled' | 'do_not_process' | 'unknown' | "rejected" | "lost";
status: 'ordered' | 'transit_customer' | 'out_for_delivery' | 'with_customer' | 'transit_lab' | 'delivered_to_lab' | 'processing_lab' | 'completed' | 'failure_to_deliver_to_customer' | 'failure_to_deliver_to_lab' | 'cancelled' | 'do_not_process' | 'unknown' | "rejected" | "lost";
user_key: string;
testkit_id: string;
testkit: Testkit;
inbound_tracking_number?: string;
outbound_tracking_number?: string;
outbound_courier?: string;
inbound_courier?: string;
}
export interface OrderResponse {
orders: Order[];
total: number;
page: number;
size: number;
}
export interface OrderRequestResponse {

@@ -68,20 +63,2 @@ order: Order;

}
export interface LabClientFacing {
slug: string;
name: string;
first_line_address: string;
city: string;
zipcode: string;
}
export interface ClientFacingLabTest {
id: string;
slug: string;
name: string;
sample_type: string;
method: string;
price: number;
is_active: boolean;
lab: LabClientFacing;
markers: Marker;
}
export interface TestkitResponse {

@@ -93,14 +70,15 @@ testkits: Testkit[];

dob: string;
clia_number: string;
patient: string;
provider: string;
laboratory: string;
date_reported: string;
date_collected: string;
specimen_number: string;
date_received?: string;
clia?: string;
provider?: string;
laboratory?: string;
date_received?: string;
}
export interface LabResultsResponse {
export interface LabResultsRaw {
metadata: LabResultsMetadata;
results: Object;
results: Record<string, string>;
}

@@ -1,10 +0,7 @@

import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi } from './client';
import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi, LabTestsApi } from './client';
import { ClientConfig } from './lib/models';
import { ClientCredentials } from './lib/credentials';
import { VitalsApi } from './client/Vitals';
import { ProviderApi } from './client/Provider';
import { LabTestsApi } from './client/LabTests';
export declare class VitalClient {
config: ClientConfig;
clientCredentials: ClientCredentials;
Activity: ActivityApi;

@@ -11,0 +8,0 @@ Link: LinkApi;

@@ -55,6 +55,4 @@ "use strict";

var config_1 = require("./lib/config");
var credentials_1 = require("./lib/credentials");
var Vitals_1 = require("./client/Vitals");
var Provider_1 = require("./client/Provider");
var LabTests_1 = require("./client/LabTests");
var VitalClient = /** @class */ (function () {

@@ -65,8 +63,3 @@ function VitalClient(config) {

if (!config.api_key) {
try {
this.clientCredentials = new credentials_1.ClientCredentials(config);
}
catch (error) {
throw new Error("You must provide either an API key or a client ID and secret");
}
throw new Error("You must provide an API key");
}

@@ -86,20 +79,8 @@ var baseURL;

axiosApiInstance.interceptors.request.use(function (config) { return __awaiter(_this, void 0, void 0, function () {
var headers, token;
var headers;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
headers = config.headers;
if (!this.config.api_key) return [3 /*break*/, 1];
headers["x-vital-api-key"] = this.config.api_key;
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, this.clientCredentials.access_token()];
case 2:
token = _a.sent();
headers["Authorization"] = "Bearer " + token;
headers["x-vital-client-id"] = this.config.client_id;
_a.label = 3;
case 3:
config.headers = __assign({}, headers);
return [2 /*return*/, config];
}
headers = config.headers;
headers["x-vital-api-key"] = this.config.api_key;
config.headers = __assign({}, headers);
return [2 /*return*/, config];
});

@@ -118,3 +99,3 @@ }); }, function (error) {

this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
this.LabTests = new LabTests_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
this.LabTests = new client_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);

@@ -121,0 +102,0 @@ this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);

@@ -13,14 +13,12 @@ import axios from 'axios';

DevicesAPI,
MealsApi
MealsApi,
LabTestsApi
} from './client';
import { ClientConfig } from './lib/models';
import CONFIG from './lib/config';
import { ClientCredentials } from './lib/credentials';
import { VitalsApi } from './client/Vitals';
import { ProviderApi } from './client/Provider';
import { LabTestsApi } from './client/LabTests';
export class VitalClient {
config: ClientConfig;
clientCredentials: ClientCredentials;
Activity: ActivityApi;

@@ -43,7 +41,3 @@ Link: LinkApi;

if(!config.api_key){
try {
this.clientCredentials = new ClientCredentials(config);
} catch (error) {
throw new Error("You must provide either an API key or a client ID and secret");
}
throw new Error("You must provide an API key");
}

@@ -66,9 +60,3 @@ let baseURL;

const headers = config.headers;
if(this.config.api_key){
headers["x-vital-api-key"] = this.config.api_key;
} else {
const token = await this.clientCredentials.access_token();
headers["Authorization"] = `Bearer ${token}`;
headers["x-vital-client-id"] = this.config.client_id;
}
headers["x-vital-api-key"] = this.config.api_key;
config.headers = {

@@ -75,0 +63,0 @@ ...headers,

{
"name": "@tryvital/vital-node",
"version": "2.1.0",
"version": "2.1.1",
"description": "Node client for Vital",

@@ -18,3 +18,3 @@ "author": "maitham",

"prepublishOnly": "npm run build",
"test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './test/**/*.ts'",
"test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './__tests__/**/*.ts'",
"test-typescript": "tsc --build types/test",

@@ -26,3 +26,2 @@ "test-client": "jest --config jest.config.js",

"dependencies": {
"auth0": "^2.35.1",
"axios": ">=0.21.2 <1.0.0",

@@ -29,0 +28,0 @@ "axios-retry": "^3.2.4",