@tryvital/vital-node 1.4.9 → 1.6.0
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/client/User.ts +13 -5
- package/client/Vitals.ts +35 -3
- package/client/models/activity.ts +10 -2
- package/client/models/user_models.ts +12 -0
- package/dist/client/User.d.ts +2 -2
- package/dist/client/User.js +11 -6
- package/dist/client/Vitals.d.ts +3 -1
- package/dist/client/Vitals.js +14 -0
- package/dist/client/models/activity.d.ts +8 -2
- package/dist/client/models/user_models.d.ts +10 -0
- package/package.json +2 -2
package/client/User.ts
CHANGED
@@ -5,6 +5,8 @@ import {
|
|
5
5
|
ClientFacingUser,
|
6
6
|
Providers,
|
7
7
|
ProvidersResponse,
|
8
|
+
GetTeamUsersParams,
|
9
|
+
GetTeamUsersResponse,
|
8
10
|
} from './models/user_models';
|
9
11
|
|
10
12
|
export class UserApi {
|
@@ -29,8 +31,16 @@ export class UserApi {
|
|
29
31
|
return resp.data;
|
30
32
|
}
|
31
33
|
|
32
|
-
public async getAll(
|
33
|
-
|
34
|
+
public async getAll({
|
35
|
+
limit = 100,
|
36
|
+
offset = 0,
|
37
|
+
}: GetTeamUsersParams = {}): Promise<GetTeamUsersResponse> {
|
38
|
+
const url = new URL(this.baseURL.concat('/user/'));
|
39
|
+
|
40
|
+
url.searchParams.set('limit', String(limit));
|
41
|
+
url.searchParams.set('offset', String(offset));
|
42
|
+
|
43
|
+
const resp = await this.client.get(url.toString());
|
34
44
|
return resp.data;
|
35
45
|
}
|
36
46
|
|
@@ -63,9 +73,7 @@ export class UserApi {
|
|
63
73
|
return resp.data;
|
64
74
|
}
|
65
75
|
|
66
|
-
public async refresh(
|
67
|
-
userId: string,
|
68
|
-
): Promise<SuccessResponse> {
|
76
|
+
public async refresh(userId: string): Promise<SuccessResponse> {
|
69
77
|
const resp = await this.client.post(
|
70
78
|
this.baseURL.concat(`/user/refresh/${userId}`)
|
71
79
|
);
|
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<
|
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
|
}
|
@@ -94,13 +94,21 @@ export interface ClientCholesterolResponse {
|
|
94
94
|
cholesterol: ClientFacingCholesterol[];
|
95
95
|
}
|
96
96
|
|
97
|
-
|
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',
|
@@ -51,3 +51,15 @@ export enum Providers {
|
|
51
51
|
Zwift = 'zwift',
|
52
52
|
Hammerhead = 'hammerhead',
|
53
53
|
}
|
54
|
+
|
55
|
+
export interface GetTeamUsersParams {
|
56
|
+
limit?: number;
|
57
|
+
offset?: number;
|
58
|
+
}
|
59
|
+
|
60
|
+
export interface GetTeamUsersResponse {
|
61
|
+
users: Array<ClientFacingUser>;
|
62
|
+
offset: number;
|
63
|
+
limit: number;
|
64
|
+
total: number;
|
65
|
+
}
|
package/dist/client/User.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
|
-
import { UserIdResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse } from './models/user_models';
|
2
|
+
import { UserIdResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse, GetTeamUsersParams, GetTeamUsersResponse } from './models/user_models';
|
3
3
|
export declare class UserApi {
|
4
4
|
baseURL: string;
|
5
5
|
client: AxiosInstance;
|
6
6
|
constructor(baseURL: string, axios: AxiosInstance);
|
7
7
|
create(clientUserId: string): Promise<UserIdResponse>;
|
8
8
|
delete(userId: string): Promise<SuccessResponse>;
|
9
|
-
getAll(): Promise<
|
9
|
+
getAll({ limit, offset, }?: GetTeamUsersParams): Promise<GetTeamUsersResponse>;
|
10
10
|
get(userId: string): Promise<ClientFacingUser>;
|
11
11
|
resolve(clientUserId: string): Promise<ClientFacingUser>;
|
12
12
|
providers(userId: string): Promise<ProvidersResponse>;
|
package/dist/client/User.js
CHANGED
@@ -70,14 +70,19 @@ var UserApi = /** @class */ (function () {
|
|
70
70
|
});
|
71
71
|
});
|
72
72
|
};
|
73
|
-
UserApi.prototype.getAll = function () {
|
73
|
+
UserApi.prototype.getAll = function (_a) {
|
74
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.limit, limit = _c === void 0 ? 100 : _c, _d = _b.offset, offset = _d === void 0 ? 0 : _d;
|
74
75
|
return __awaiter(this, void 0, void 0, function () {
|
75
|
-
var resp;
|
76
|
-
return __generator(this, function (
|
77
|
-
switch (
|
78
|
-
case 0:
|
76
|
+
var url, resp;
|
77
|
+
return __generator(this, function (_e) {
|
78
|
+
switch (_e.label) {
|
79
|
+
case 0:
|
80
|
+
url = new URL(this.baseURL.concat('/user/'));
|
81
|
+
url.searchParams.set('limit', String(limit));
|
82
|
+
url.searchParams.set('offset', String(offset));
|
83
|
+
return [4 /*yield*/, this.client.get(url.toString())];
|
79
84
|
case 1:
|
80
|
-
resp =
|
85
|
+
resp = _e.sent();
|
81
86
|
return [2 /*return*/, resp.data];
|
82
87
|
}
|
83
88
|
});
|
package/dist/client/Vitals.d.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
|
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
|
}
|
package/dist/client/Vitals.js
CHANGED
@@ -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;
|
@@ -87,12 +87,18 @@ export interface ClientGlucoseResponse {
|
|
87
87
|
export interface ClientCholesterolResponse {
|
88
88
|
cholesterol: ClientFacingCholesterol[];
|
89
89
|
}
|
90
|
-
|
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",
|
@@ -44,3 +44,13 @@ export declare enum Providers {
|
|
44
44
|
Zwift = "zwift",
|
45
45
|
Hammerhead = "hammerhead"
|
46
46
|
}
|
47
|
+
export interface GetTeamUsersParams {
|
48
|
+
limit?: number;
|
49
|
+
offset?: number;
|
50
|
+
}
|
51
|
+
export interface GetTeamUsersResponse {
|
52
|
+
users: Array<ClientFacingUser>;
|
53
|
+
offset: number;
|
54
|
+
limit: number;
|
55
|
+
total: number;
|
56
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tryvital/vital-node",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.6.0",
|
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"
|