@tryvital/vital-node 1.5.0 → 1.6.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.
@@ -0,0 +1,27 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ClientFacingMealResponse } from './models/meal_model';
3
+
4
+ export class MealsApi {
5
+ baseURL: string;
6
+ client: AxiosInstance;
7
+
8
+ constructor(baseURL: string, axios: AxiosInstance) {
9
+ this.baseURL = baseURL;
10
+ this.client = axios;
11
+ }
12
+
13
+ public async get(
14
+ userId: string,
15
+ startDate: Date,
16
+ endDate?: Date,
17
+ provider?: string
18
+ ): Promise<ClientFacingMealResponse> {
19
+ const resp = await this.client.get(
20
+ this.baseURL.concat(`/summary/meal/${userId}`),
21
+ {
22
+ params: { start_date: startDate, end_date: endDate, provider },
23
+ }
24
+ );
25
+ return resp.data;
26
+ }
27
+ }
package/client/Vitals.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { TimeseriesPoint } from './models/activity';
2
+ import { TimeseriesBloodPressurePoint, TimeseriesPoint } from './models/activity';
3
3
 
4
4
  export class VitalsApi {
5
5
  baseURL: string;
@@ -9,13 +9,13 @@ export class VitalsApi {
9
9
  this.client = axios;
10
10
  }
11
11
 
12
- private async timeseriesData(
12
+ private async timeseriesData<T = TimeseriesPoint>(
13
13
  user_key: string,
14
14
  resource: string,
15
15
  startDate: Date,
16
16
  endDate?: Date,
17
17
  provider?: string
18
- ): Promise<TimeseriesPoint[]> {
18
+ ): Promise<T[]> {
19
19
  const resp = await this.client.get(
20
20
  this.baseURL.concat(`/timeseries/${user_key}/${resource}`),
21
21
  {
@@ -88,4 +88,36 @@ export class VitalsApi {
88
88
  provider
89
89
  );
90
90
  }
91
+
92
+ public async bloodOxygen(
93
+ userId: string,
94
+ startDate: Date,
95
+ endDate?: Date,
96
+ provider?: string,
97
+
98
+ ): Promise<TimeseriesPoint[]> {
99
+ return this.timeseriesData(
100
+ userId,
101
+ 'blood_oxygen',
102
+ startDate,
103
+ endDate,
104
+ provider
105
+ );
106
+ }
107
+
108
+ public async bloodPressure(
109
+ userId: string,
110
+ startDate: Date,
111
+ endDate?: Date,
112
+ provider?: string,
113
+
114
+ ): Promise<TimeseriesBloodPressurePoint[]> {
115
+ return this.timeseriesData<TimeseriesBloodPressurePoint>(
116
+ userId,
117
+ 'blood_pressure',
118
+ startDate,
119
+ endDate,
120
+ provider
121
+ );
122
+ }
91
123
  }
package/client/index.ts CHANGED
@@ -8,3 +8,4 @@ export { WorkoutsApi } from './Workouts';
8
8
  export { TestkitsApi } from './Testkits';
9
9
  export { ProfileApi } from './Profile';
10
10
  export { DevicesAPI } from './Devices';
11
+ export { MealsApi } from './Meals';
@@ -94,13 +94,21 @@ export interface ClientCholesterolResponse {
94
94
  cholesterol: ClientFacingCholesterol[];
95
95
  }
96
96
 
97
- export interface TimeseriesPoint {
97
+ interface Timeseries {
98
98
  timestamp: Date;
99
- value: number;
100
99
  type: string;
101
100
  unit: string;
102
101
  }
103
102
 
103
+ export interface TimeseriesPoint extends Timeseries {
104
+ value: number;
105
+ }
106
+
107
+ export interface TimeseriesBloodPressurePoint extends Timeseries {
108
+ systolic: number;
109
+ diastolic: number;
110
+ }
111
+
104
112
  enum RespiratoryAllergen {
105
113
  D_PTERONYSSINUS = 'd_pteronyssinus',
106
114
  D_FARINAE = 'd_farinae',
@@ -0,0 +1,61 @@
1
+ import { SourceClientFacing } from './user_models';
2
+
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ /**
6
+ /* This file was automatically generated from pydantic models by running pydantic2ts.
7
+ /* Do not modify it by hand - just update the pydantic models and then re-run the script
8
+ */
9
+
10
+ export interface MealInDBBaseClientFacingSource {
11
+ id: string;
12
+ user_id: string;
13
+ priority_id: number;
14
+ source_id: number;
15
+ provider_id: string;
16
+ timestamp: string;
17
+ name: string;
18
+ energy?: Energy;
19
+ macros?: Macros;
20
+ micros?: Micros;
21
+ source: SourceClientFacing;
22
+ created_at: string;
23
+ updated_at: string;
24
+ }
25
+ export interface Energy {
26
+ unit: "kcal";
27
+ value: number;
28
+ }
29
+ export interface Macros {
30
+ carbs?: number;
31
+ protein?: number;
32
+ fats?: Fats;
33
+ alcohol?: number;
34
+ water?: number;
35
+ fibre?: number;
36
+ sugar?: number;
37
+ }
38
+ export interface Fats {
39
+ saturated?: number;
40
+ monounsaturated?: number;
41
+ polyunsaturated?: number;
42
+ omega3?: number;
43
+ omega6?: number;
44
+ total?: number;
45
+ }
46
+ export interface Micros {
47
+ minerals?: {
48
+ [k: string]: number;
49
+ };
50
+ trace_elements?: {
51
+ [k: string]: number;
52
+ };
53
+ vitamins?: {
54
+ [k: string]: number;
55
+ };
56
+ }
57
+
58
+ export interface ClientFacingMealResponse {
59
+ meals: MealInDBBaseClientFacingSource[];
60
+ }
61
+
@@ -50,6 +50,17 @@ export enum Providers {
50
50
  Wahoo = 'wahoo',
51
51
  Zwift = 'zwift',
52
52
  Hammerhead = 'hammerhead',
53
+ FreestyleLibre = "freestyle_libre",
54
+ Withings = "withings",
55
+ EightSleep = "eight_sleep",
56
+ GoogleFit = "google_fit",
57
+ AppleHealthKit = "apple_health_kit",
58
+ IHealth = "ihealth",
59
+ AccuchekBle = "accuchek_ble",
60
+ ContourBle = "contour_ble",
61
+ Beurer = "beurer",
62
+ Dexcom = "dexcom",
63
+ MyFitnessPal = "my_fitness_pal",
53
64
  }
54
65
 
55
66
  export interface GetTeamUsersParams {
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ClientFacingMealResponse } from './models/meal_model';
3
+ export declare class MealsApi {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientFacingMealResponse>;
8
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.MealsApi = void 0;
40
+ var MealsApi = /** @class */ (function () {
41
+ function MealsApi(baseURL, axios) {
42
+ this.baseURL = baseURL;
43
+ this.client = axios;
44
+ }
45
+ MealsApi.prototype.get = function (userId, startDate, endDate, provider) {
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var resp;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/meal/" + userId), {
51
+ params: { start_date: startDate, end_date: endDate, provider: provider },
52
+ })];
53
+ case 1:
54
+ resp = _a.sent();
55
+ return [2 /*return*/, resp.data];
56
+ }
57
+ });
58
+ });
59
+ };
60
+ return MealsApi;
61
+ }());
62
+ exports.MealsApi = MealsApi;
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { TimeseriesPoint } from './models/activity';
2
+ import { TimeseriesBloodPressurePoint, TimeseriesPoint } from './models/activity';
3
3
  export declare class VitalsApi {
4
4
  baseURL: string;
5
5
  client: AxiosInstance;
@@ -10,4 +10,6 @@ export declare class VitalsApi {
10
10
  ige(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<TimeseriesPoint[]>;
11
11
  igg(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<TimeseriesPoint[]>;
12
12
  heartrate(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<TimeseriesPoint[]>;
13
+ bloodOxygen(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<TimeseriesPoint[]>;
14
+ bloodPressure(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<TimeseriesBloodPressurePoint[]>;
13
15
  }
@@ -92,6 +92,20 @@ var VitalsApi = /** @class */ (function () {
92
92
  });
93
93
  });
94
94
  };
95
+ VitalsApi.prototype.bloodOxygen = function (userId, startDate, endDate, provider) {
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ return __generator(this, function (_a) {
98
+ return [2 /*return*/, this.timeseriesData(userId, 'blood_oxygen', startDate, endDate, provider)];
99
+ });
100
+ });
101
+ };
102
+ VitalsApi.prototype.bloodPressure = function (userId, startDate, endDate, provider) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ return [2 /*return*/, this.timeseriesData(userId, 'blood_pressure', startDate, endDate, provider)];
106
+ });
107
+ });
108
+ };
95
109
  return VitalsApi;
96
110
  }());
97
111
  exports.VitalsApi = VitalsApi;
@@ -8,3 +8,4 @@ export { WorkoutsApi } from './Workouts';
8
8
  export { TestkitsApi } from './Testkits';
9
9
  export { ProfileApi } from './Profile';
10
10
  export { DevicesAPI } from './Devices';
11
+ export { MealsApi } from './Meals';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DevicesAPI = exports.ProfileApi = exports.TestkitsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
3
+ exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.TestkitsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
4
4
  var Activity_1 = require("./Activity");
5
5
  Object.defineProperty(exports, "ActivityApi", { enumerable: true, get: function () { return Activity_1.ActivityApi; } });
6
6
  var Body_1 = require("./Body");
@@ -21,3 +21,5 @@ var Profile_1 = require("./Profile");
21
21
  Object.defineProperty(exports, "ProfileApi", { enumerable: true, get: function () { return Profile_1.ProfileApi; } });
22
22
  var Devices_1 = require("./Devices");
23
23
  Object.defineProperty(exports, "DevicesAPI", { enumerable: true, get: function () { return Devices_1.DevicesAPI; } });
24
+ var Meals_1 = require("./Meals");
25
+ Object.defineProperty(exports, "MealsApi", { enumerable: true, get: function () { return Meals_1.MealsApi; } });
@@ -87,12 +87,18 @@ export interface ClientGlucoseResponse {
87
87
  export interface ClientCholesterolResponse {
88
88
  cholesterol: ClientFacingCholesterol[];
89
89
  }
90
- export interface TimeseriesPoint {
90
+ interface Timeseries {
91
91
  timestamp: Date;
92
- value: number;
93
92
  type: string;
94
93
  unit: string;
95
94
  }
95
+ export interface TimeseriesPoint extends Timeseries {
96
+ value: number;
97
+ }
98
+ export interface TimeseriesBloodPressurePoint extends Timeseries {
99
+ systolic: number;
100
+ diastolic: number;
101
+ }
96
102
  declare enum RespiratoryAllergen {
97
103
  D_PTERONYSSINUS = "d_pteronyssinus",
98
104
  D_FARINAE = "d_farinae",
@@ -0,0 +1,55 @@
1
+ import { SourceClientFacing } from './user_models';
2
+ /**
3
+ /* This file was automatically generated from pydantic models by running pydantic2ts.
4
+ /* Do not modify it by hand - just update the pydantic models and then re-run the script
5
+ */
6
+ export interface MealInDBBaseClientFacingSource {
7
+ id: string;
8
+ user_id: string;
9
+ priority_id: number;
10
+ source_id: number;
11
+ provider_id: string;
12
+ timestamp: string;
13
+ name: string;
14
+ energy?: Energy;
15
+ macros?: Macros;
16
+ micros?: Micros;
17
+ source: SourceClientFacing;
18
+ created_at: string;
19
+ updated_at: string;
20
+ }
21
+ export interface Energy {
22
+ unit: "kcal";
23
+ value: number;
24
+ }
25
+ export interface Macros {
26
+ carbs?: number;
27
+ protein?: number;
28
+ fats?: Fats;
29
+ alcohol?: number;
30
+ water?: number;
31
+ fibre?: number;
32
+ sugar?: number;
33
+ }
34
+ export interface Fats {
35
+ saturated?: number;
36
+ monounsaturated?: number;
37
+ polyunsaturated?: number;
38
+ omega3?: number;
39
+ omega6?: number;
40
+ total?: number;
41
+ }
42
+ export interface Micros {
43
+ minerals?: {
44
+ [k: string]: number;
45
+ };
46
+ trace_elements?: {
47
+ [k: string]: number;
48
+ };
49
+ vitamins?: {
50
+ [k: string]: number;
51
+ };
52
+ }
53
+ export interface ClientFacingMealResponse {
54
+ meals: MealInDBBaseClientFacingSource[];
55
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -42,7 +42,18 @@ export declare enum Providers {
42
42
  Peloton = "peloton",
43
43
  Wahoo = "wahoo",
44
44
  Zwift = "zwift",
45
- Hammerhead = "hammerhead"
45
+ Hammerhead = "hammerhead",
46
+ FreestyleLibre = "freestyle_libre",
47
+ Withings = "withings",
48
+ EightSleep = "eight_sleep",
49
+ GoogleFit = "google_fit",
50
+ AppleHealthKit = "apple_health_kit",
51
+ IHealth = "ihealth",
52
+ AccuchekBle = "accuchek_ble",
53
+ ContourBle = "contour_ble",
54
+ Beurer = "beurer",
55
+ Dexcom = "dexcom",
56
+ MyFitnessPal = "my_fitness_pal"
46
57
  }
47
58
  export interface GetTeamUsersParams {
48
59
  limit?: number;
@@ -13,4 +13,15 @@ var Providers;
13
13
  Providers["Wahoo"] = "wahoo";
14
14
  Providers["Zwift"] = "zwift";
15
15
  Providers["Hammerhead"] = "hammerhead";
16
+ Providers["FreestyleLibre"] = "freestyle_libre";
17
+ Providers["Withings"] = "withings";
18
+ Providers["EightSleep"] = "eight_sleep";
19
+ Providers["GoogleFit"] = "google_fit";
20
+ Providers["AppleHealthKit"] = "apple_health_kit";
21
+ Providers["IHealth"] = "ihealth";
22
+ Providers["AccuchekBle"] = "accuchek_ble";
23
+ Providers["ContourBle"] = "contour_ble";
24
+ Providers["Beurer"] = "beurer";
25
+ Providers["Dexcom"] = "dexcom";
26
+ Providers["MyFitnessPal"] = "my_fitness_pal";
16
27
  })(Providers = exports.Providers || (exports.Providers = {}));
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI } from './client';
1
+ import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi } from './client';
2
2
  import { ClientConfig } from './lib/models';
3
3
  import { ClientCredentials } from './lib/credentials';
4
4
  import { VitalsApi } from './client/Vitals';
@@ -9,6 +9,7 @@ export declare class VitalClient {
9
9
  Activity: ActivityApi;
10
10
  Link: LinkApi;
11
11
  Body: BodyApi;
12
+ Meals: MealsApi;
12
13
  Sleep: SleepApi;
13
14
  User: UserApi;
14
15
  Workouts: WorkoutsApi;
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ var config_1 = require("./lib/config");
55
55
  var credentials_1 = require("./lib/credentials");
56
56
  var Vitals_1 = require("./client/Vitals");
57
57
  var Provider_1 = require("./client/Provider");
58
+ ;
58
59
  var VitalClient = /** @class */ (function () {
59
60
  function VitalClient(config) {
60
61
  var _this = this;
@@ -115,6 +116,7 @@ var VitalClient = /** @class */ (function () {
115
116
  this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
116
117
  this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
117
118
  this.Devices = new client_1.DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
119
+ this.Meals = new client_1.MealsApi(baseURL.concat('/v2'), axiosApiInstance);
118
120
  }
119
121
  return VitalClient;
120
122
  }());
package/index.ts CHANGED
@@ -11,12 +11,13 @@ import {
11
11
  WorkoutsApi,
12
12
  ProfileApi,
13
13
  DevicesAPI,
14
+ MealsApi
14
15
  } from './client';
15
16
  import { ClientConfig } from './lib/models';
16
17
  import CONFIG from './lib/config';
17
18
  import { ClientCredentials } from './lib/credentials';
18
19
  import { VitalsApi } from './client/Vitals';
19
- import { ProviderApi } from './client/Provider';
20
+ import { ProviderApi } from './client/Provider';;
20
21
 
21
22
  export class VitalClient {
22
23
  config: ClientConfig;
@@ -24,6 +25,7 @@ export class VitalClient {
24
25
  Activity: ActivityApi;
25
26
  Link: LinkApi;
26
27
  Body: BodyApi;
28
+ Meals: MealsApi;
27
29
  Sleep: SleepApi;
28
30
  User: UserApi;
29
31
  Workouts: WorkoutsApi;
@@ -89,5 +91,6 @@ export class VitalClient {
89
91
  this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
90
92
  this.Providers = new ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
91
93
  this.Devices = new DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
94
+ this.Meals = new MealsApi(baseURL.concat('/v2'), axiosApiInstance);
92
95
  }
93
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "1.5.0",
3
+ "version": "1.6.3",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "auth0": "^2.35.1",
26
- "axios": ">=0.21.2",
26
+ "axios": ">=0.21.2 <1.0.0",
27
27
  "axios-retry": "^3.2.4",
28
28
  "crypto": "^1.0.1",
29
29
  "svix": "0.64.2"
@@ -1,12 +0,0 @@
1
- name: size
2
- on: [pull_request]
3
- jobs:
4
- size:
5
- runs-on: ubuntu-latest
6
- env:
7
- CI_JOB_NUMBER: 1
8
- steps:
9
- - uses: actions/checkout@v1
10
- - uses: andresz1/size-limit-action@v1
11
- with:
12
- github_token: ${{ secrets.GITHUB_TOKEN }}