@tryvital/vital-node 0.3.7 → 1.0.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/client/Activity.ts +1 -1
- package/client/Body.ts +1 -1
- package/client/Profile.ts +25 -0
- package/client/Sleep.ts +2 -2
- package/client/Testkits.ts +14 -8
- package/client/User.ts +2 -2
- package/client/Vitals.ts +45 -45
- package/client/Webhooks.ts +7 -58
- package/client/Workouts.ts +3 -3
- package/client/index.ts +1 -1
- package/client/models/activity.ts +10 -3
- package/client/models/body_model.ts +0 -18
- package/client/models/profile_model.ts +34 -0
- package/client/models/testkit_models.ts +14 -0
- package/client/models/user_models.ts +4 -0
- package/dist/client/Activity.js +1 -1
- package/dist/client/Body.js +1 -1
- package/dist/client/Profile.d.ts +8 -0
- package/dist/client/{ProviderSpecific.js → Profile.js} +8 -12
- package/dist/client/Sleep.js +2 -2
- package/dist/client/Testkits.d.ts +3 -2
- package/dist/client/Testkits.js +17 -1
- package/dist/client/User.d.ts +2 -2
- package/dist/client/Vitals.d.ts +7 -6
- package/dist/client/Vitals.js +16 -41
- package/dist/client/Webhooks.d.ts +1 -7
- package/dist/client/Webhooks.js +4 -102
- package/dist/client/Workouts.d.ts +1 -1
- package/dist/client/Workouts.js +3 -3
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/models/activity.d.ts +9 -3
- package/dist/client/models/body_model.d.ts +0 -18
- package/dist/client/models/profile_model.d.ts +33 -0
- package/dist/{swagger_client/models/client-activity-response.js → client/models/profile_model.js} +0 -0
- package/dist/client/models/testkit_models.d.ts +13 -0
- package/dist/client/models/user_models.d.ts +3 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -11
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +0 -1
- package/index.ts +14 -14
- package/lib/config.ts +0 -1
- package/package.json +3 -2
- package/client/ProviderSpecific.ts +0 -31
- package/dist/client/ProviderSpecific.d.ts +0 -8
- package/dist/swagger_client/api.d.ts +0 -18
- package/dist/swagger_client/api.js +0 -32
- package/dist/swagger_client/apis/activity-api.d.ts +0 -86
- package/dist/swagger_client/apis/activity-api.js +0 -241
- package/dist/swagger_client/apis/body-api.d.ts +0 -86
- package/dist/swagger_client/apis/body-api.js +0 -241
- package/dist/swagger_client/apis/link-api.d.ts +0 -115
- package/dist/swagger_client/apis/link-api.js +0 -310
- package/dist/swagger_client/apis/provider-specific-api.d.ts +0 -90
- package/dist/swagger_client/apis/provider-specific-api.js +0 -250
- package/dist/swagger_client/apis/sleep-api.d.ts +0 -120
- package/dist/swagger_client/apis/sleep-api.js +0 -330
- package/dist/swagger_client/apis/user-api.d.ts +0 -243
- package/dist/swagger_client/apis/user-api.js +0 -657
- package/dist/swagger_client/apis/webhooks-api.d.ts +0 -138
- package/dist/swagger_client/apis/webhooks-api.js +0 -379
- package/dist/swagger_client/apis/workouts-api.d.ts +0 -120
- package/dist/swagger_client/apis/workouts-api.js +0 -330
- package/dist/swagger_client/base.d.ts +0 -55
- package/dist/swagger_client/base.js +0 -67
- package/dist/swagger_client/configuration.d.ts +0 -63
- package/dist/swagger_client/configuration.js +0 -16
- package/dist/swagger_client/index.d.ts +0 -13
- package/dist/swagger_client/index.js +0 -27
- package/dist/swagger_client/models/client-activity-response.d.ts +0 -24
- package/dist/swagger_client/models/client-body-response.d.ts +0 -24
- package/dist/swagger_client/models/client-body-response.js +0 -2
- package/dist/swagger_client/models/client-facing-activity.d.ts +0 -84
- package/dist/swagger_client/models/client-facing-activity.js +0 -2
- package/dist/swagger_client/models/client-facing-body.d.ts +0 -72
- package/dist/swagger_client/models/client-facing-body.js +0 -2
- package/dist/swagger_client/models/client-facing-sleep-stream.d.ts +0 -48
- package/dist/swagger_client/models/client-facing-sleep-stream.js +0 -2
- package/dist/swagger_client/models/client-facing-sleep.d.ts +0 -138
- package/dist/swagger_client/models/client-facing-sleep.js +0 -2
- package/dist/swagger_client/models/client-facing-source-specific.d.ts +0 -48
- package/dist/swagger_client/models/client-facing-source-specific.js +0 -2
- package/dist/swagger_client/models/client-facing-sport.d.ts +0 -30
- package/dist/swagger_client/models/client-facing-sport.js +0 -2
- package/dist/swagger_client/models/client-facing-stream.d.ts +0 -84
- package/dist/swagger_client/models/client-facing-stream.js +0 -2
- package/dist/swagger_client/models/client-facing-user.d.ts +0 -48
- package/dist/swagger_client/models/client-facing-user.js +0 -2
- package/dist/swagger_client/models/client-facing-webhook.d.ts +0 -42
- package/dist/swagger_client/models/client-facing-webhook.js +0 -2
- package/dist/swagger_client/models/client-facing-workout.d.ts +0 -150
- package/dist/swagger_client/models/client-facing-workout.js +0 -2
- package/dist/swagger_client/models/client-sleep-response.d.ts +0 -24
- package/dist/swagger_client/models/client-sleep-response.js +0 -2
- package/dist/swagger_client/models/client-source-specific-response.d.ts +0 -24
- package/dist/swagger_client/models/client-source-specific-response.js +0 -2
- package/dist/swagger_client/models/client-webhook-response.d.ts +0 -24
- package/dist/swagger_client/models/client-webhook-response.js +0 -2
- package/dist/swagger_client/models/client-workout-response.d.ts +0 -24
- package/dist/swagger_client/models/client-workout-response.js +0 -2
- package/dist/swagger_client/models/connected-source-client-facing.d.ts +0 -24
- package/dist/swagger_client/models/connected-source-client-facing.js +0 -2
- package/dist/swagger_client/models/httpvalidation-error.d.ts +0 -24
- package/dist/swagger_client/models/httpvalidation-error.js +0 -2
- package/dist/swagger_client/models/index.d.ts +0 -32
- package/dist/swagger_client/models/index.js +0 -44
- package/dist/swagger_client/models/individual-provider-data.d.ts +0 -30
- package/dist/swagger_client/models/individual-provider-data.js +0 -2
- package/dist/swagger_client/models/link-token-exchange-response.d.ts +0 -24
- package/dist/swagger_client/models/link-token-exchange-response.js +0 -2
- package/dist/swagger_client/models/link-token-exchange.d.ts +0 -30
- package/dist/swagger_client/models/link-token-exchange.js +0 -2
- package/dist/swagger_client/models/password-providers.d.ts +0 -22
- package/dist/swagger_client/models/password-providers.js +0 -28
- package/dist/swagger_client/models/provider-link-response.d.ts +0 -30
- package/dist/swagger_client/models/provider-link-response.js +0 -2
- package/dist/swagger_client/models/providers-that-require-password-auth-whoop-renpho-peloton-zwift.d.ts +0 -18
- package/dist/swagger_client/models/providers-that-require-password-auth-whoop-renpho-peloton-zwift.js +0 -2
- package/dist/swagger_client/models/providers.d.ts +0 -27
- package/dist/swagger_client/models/providers.js +0 -33
- package/dist/swagger_client/models/source-client-facing.d.ts +0 -36
- package/dist/swagger_client/models/source-client-facing.js +0 -2
- package/dist/swagger_client/models/user-create.d.ts +0 -24
- package/dist/swagger_client/models/user-create.js +0 -2
- package/dist/swagger_client/models/user-key-response.d.ts +0 -30
- package/dist/swagger_client/models/user-key-response.js +0 -2
- package/dist/swagger_client/models/user-success-response.d.ts +0 -24
- package/dist/swagger_client/models/user-success-response.js +0 -2
- package/dist/swagger_client/models/validation-error.d.ts +0 -36
- package/dist/swagger_client/models/validation-error.js +0 -2
- package/dist/swagger_client/models/webhook-register.d.ts +0 -36
- package/dist/swagger_client/models/webhook-register.js +0 -2
- package/dist/swagger_client/models/webhook-type.d.ts +0 -24
- package/dist/swagger_client/models/webhook-type.js +0 -30
- package/dist/test/data/mock_webhook.d.ts +0 -49
- package/dist/test/data/mock_webhook.js +0 -170
- package/dist/test/webhook.spec.d.ts +0 -1
- package/dist/test/webhook.spec.js +0 -160
- package/test/data/mock_webhook.ts +0 -167
- package/test/webhook.spec.ts +0 -254
package/dist/client/User.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
|
-
import { UserKeyResponse, SuccessResponse, ClientFacingUser,
|
2
|
+
import { UserKeyResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse } from './models/user_models';
|
3
3
|
export declare class UserApi {
|
4
4
|
baseURL: string;
|
5
5
|
client: AxiosInstance;
|
@@ -9,6 +9,6 @@ export declare class UserApi {
|
|
9
9
|
getAll(): Promise<Array<ClientFacingUser>>;
|
10
10
|
get(userKey: string): Promise<ClientFacingUser>;
|
11
11
|
resolve(clientUserId: string): Promise<ClientFacingUser>;
|
12
|
-
providers(userKey: string): Promise<
|
12
|
+
providers(userKey: string): Promise<ProvidersResponse>;
|
13
13
|
deregisterProvider(userKey: string, provider: Providers): Promise<SuccessResponse>;
|
14
14
|
}
|
package/dist/client/Vitals.d.ts
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
|
-
import {
|
2
|
+
import { TimeseriesPoint } from './models/activity';
|
3
3
|
export declare class VitalsApi {
|
4
4
|
baseURL: string;
|
5
5
|
client: AxiosInstance;
|
6
6
|
constructor(baseURL: string, axios: AxiosInstance);
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
ige(userKey: string, startDate: Date, endDate: Date): Promise<
|
11
|
-
igg(userKey: string, startDate: Date, endDate: Date): Promise<
|
7
|
+
private timeseriesData;
|
8
|
+
cholesterol(type: 'ldl' | 'total' | 'triglycerides' | 'hdl', userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
|
9
|
+
glucose(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
|
10
|
+
ige(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
|
11
|
+
igg(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
|
12
|
+
heartrate(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
|
12
13
|
}
|
package/dist/client/Vitals.js
CHANGED
@@ -42,12 +42,12 @@ var VitalsApi = /** @class */ (function () {
|
|
42
42
|
this.baseURL = baseURL;
|
43
43
|
this.client = axios;
|
44
44
|
}
|
45
|
-
VitalsApi.prototype.
|
45
|
+
VitalsApi.prototype.timeseriesData = function (user_key, resource, startDate, endDate, provider) {
|
46
46
|
return __awaiter(this, void 0, void 0, function () {
|
47
47
|
var resp;
|
48
48
|
return __generator(this, function (_a) {
|
49
49
|
switch (_a.label) {
|
50
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/
|
50
|
+
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/timeseries/" + user_key + "/" + resource), {
|
51
51
|
params: { start_date: startDate, end_date: endDate, provider: provider },
|
52
52
|
})];
|
53
53
|
case 1:
|
@@ -57,63 +57,38 @@ var VitalsApi = /** @class */ (function () {
|
|
57
57
|
});
|
58
58
|
});
|
59
59
|
};
|
60
|
+
VitalsApi.prototype.cholesterol = function (type, userKey, startDate, endDate, provider) {
|
61
|
+
return __awaiter(this, void 0, void 0, function () {
|
62
|
+
return __generator(this, function (_a) {
|
63
|
+
return [2 /*return*/, this.timeseriesData(userKey, "cholesterol/" + type, startDate, endDate, provider)];
|
64
|
+
});
|
65
|
+
});
|
66
|
+
};
|
60
67
|
VitalsApi.prototype.glucose = function (userKey, startDate, endDate, provider) {
|
61
68
|
return __awaiter(this, void 0, void 0, function () {
|
62
|
-
var resp;
|
63
69
|
return __generator(this, function (_a) {
|
64
|
-
|
65
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/glucose/" + userKey), {
|
66
|
-
params: { start_date: startDate, end_date: endDate, provider: provider },
|
67
|
-
})];
|
68
|
-
case 1:
|
69
|
-
resp = _a.sent();
|
70
|
-
return [2 /*return*/, resp.data];
|
71
|
-
}
|
70
|
+
return [2 /*return*/, this.timeseriesData(userKey, 'glucose', startDate, endDate, provider)];
|
72
71
|
});
|
73
72
|
});
|
74
73
|
};
|
75
|
-
VitalsApi.prototype.
|
74
|
+
VitalsApi.prototype.ige = function (userKey, startDate, endDate, provider) {
|
76
75
|
return __awaiter(this, void 0, void 0, function () {
|
77
|
-
var resp;
|
78
76
|
return __generator(this, function (_a) {
|
79
|
-
|
80
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/hba1c/" + userKey), {
|
81
|
-
params: { start_date: startDate, end_date: endDate, provider: provider },
|
82
|
-
})];
|
83
|
-
case 1:
|
84
|
-
resp = _a.sent();
|
85
|
-
return [2 /*return*/, resp.data];
|
86
|
-
}
|
77
|
+
return [2 /*return*/, this.timeseriesData(userKey, 'ige', startDate, endDate, provider)];
|
87
78
|
});
|
88
79
|
});
|
89
80
|
};
|
90
|
-
VitalsApi.prototype.
|
81
|
+
VitalsApi.prototype.igg = function (userKey, startDate, endDate, provider) {
|
91
82
|
return __awaiter(this, void 0, void 0, function () {
|
92
|
-
var resp;
|
93
83
|
return __generator(this, function (_a) {
|
94
|
-
|
95
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/ige/" + userKey), {
|
96
|
-
params: { start_date: startDate, end_date: endDate },
|
97
|
-
})];
|
98
|
-
case 1:
|
99
|
-
resp = _a.sent();
|
100
|
-
return [2 /*return*/, resp.data];
|
101
|
-
}
|
84
|
+
return [2 /*return*/, this.timeseriesData(userKey, 'igg', startDate, endDate, provider)];
|
102
85
|
});
|
103
86
|
});
|
104
87
|
};
|
105
|
-
VitalsApi.prototype.
|
88
|
+
VitalsApi.prototype.heartrate = function (userKey, startDate, endDate, provider) {
|
106
89
|
return __awaiter(this, void 0, void 0, function () {
|
107
|
-
var resp;
|
108
90
|
return __generator(this, function (_a) {
|
109
|
-
|
110
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/vitals/igg/" + userKey), {
|
111
|
-
params: { start_date: startDate, end_date: endDate },
|
112
|
-
})];
|
113
|
-
case 1:
|
114
|
-
resp = _a.sent();
|
115
|
-
return [2 /*return*/, resp.data];
|
116
|
-
}
|
91
|
+
return [2 /*return*/, this.timeseriesData(userKey, 'heartrate', startDate, endDate, provider)];
|
117
92
|
});
|
118
93
|
});
|
119
94
|
};
|
@@ -1,13 +1,7 @@
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
2
|
-
import { ClientWebhookResponse, WebhookEventTypes, ClientFacingWebhook } from './models/webhook_models';
|
3
2
|
export declare class WebhooksApi {
|
4
|
-
DEFAULT_TOLERANCE: number;
|
5
3
|
baseURL: string;
|
6
4
|
client: AxiosInstance;
|
7
5
|
constructor(baseURL: string, axios: AxiosInstance);
|
8
|
-
|
9
|
-
register(callbackUrl: string, verifyToken: string, eventType: WebhookEventTypes): Promise<ClientFacingWebhook>;
|
10
|
-
deregister(webhookId: string): Promise<ClientFacingWebhook>;
|
11
|
-
test(event_code: 'HISTORICAL_DATA_UPDATE' | 'CREATED', webhook_type: 'activity' | 'body' | 'sleep' | 'workouts'): Promise<ClientFacingWebhook>;
|
12
|
-
constructWebhookEvent(payload: string, header: string, secret: string, tolerance?: number): Record<string, unknown>;
|
6
|
+
static constructWebhookEvent(payload: string, headers: Record<string, string>, secret: string): unknown;
|
13
7
|
}
|
package/dist/client/Webhooks.js
CHANGED
@@ -1,113 +1,15 @@
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
3
|
exports.WebhooksApi = void 0;
|
40
|
-
var
|
4
|
+
var svix_1 = require("svix");
|
41
5
|
var WebhooksApi = /** @class */ (function () {
|
42
6
|
function WebhooksApi(baseURL, axios) {
|
43
7
|
this.baseURL = baseURL;
|
44
8
|
this.client = axios;
|
45
|
-
this.DEFAULT_TOLERANCE = 300; // 5 minutes
|
46
9
|
}
|
47
|
-
WebhooksApi.
|
48
|
-
|
49
|
-
|
50
|
-
return __generator(this, function (_a) {
|
51
|
-
switch (_a.label) {
|
52
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/webhooks/'))];
|
53
|
-
case 1:
|
54
|
-
resp = _a.sent();
|
55
|
-
return [2 /*return*/, resp.data];
|
56
|
-
}
|
57
|
-
});
|
58
|
-
});
|
59
|
-
};
|
60
|
-
WebhooksApi.prototype.register = function (callbackUrl, verifyToken, eventType) {
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
62
|
-
var resp;
|
63
|
-
return __generator(this, function (_a) {
|
64
|
-
switch (_a.label) {
|
65
|
-
case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/webhooks/'), {
|
66
|
-
callback_url: callbackUrl,
|
67
|
-
verify_token: verifyToken,
|
68
|
-
event_type: eventType,
|
69
|
-
})];
|
70
|
-
case 1:
|
71
|
-
resp = _a.sent();
|
72
|
-
return [2 /*return*/, resp.data];
|
73
|
-
}
|
74
|
-
});
|
75
|
-
});
|
76
|
-
};
|
77
|
-
WebhooksApi.prototype.deregister = function (webhookId) {
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
79
|
-
var resp;
|
80
|
-
return __generator(this, function (_a) {
|
81
|
-
switch (_a.label) {
|
82
|
-
case 0: return [4 /*yield*/, this.client.delete(this.baseURL.concat("/webhooks/" + webhookId))];
|
83
|
-
case 1:
|
84
|
-
resp = _a.sent();
|
85
|
-
return [2 /*return*/, resp.data];
|
86
|
-
}
|
87
|
-
});
|
88
|
-
});
|
89
|
-
};
|
90
|
-
WebhooksApi.prototype.test = function (event_code, webhook_type) {
|
91
|
-
return __awaiter(this, void 0, void 0, function () {
|
92
|
-
var resp;
|
93
|
-
return __generator(this, function (_a) {
|
94
|
-
switch (_a.label) {
|
95
|
-
case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/webhooks/test'), {
|
96
|
-
event_code: event_code,
|
97
|
-
webhook_type: webhook_type,
|
98
|
-
})];
|
99
|
-
case 1:
|
100
|
-
resp = _a.sent();
|
101
|
-
return [2 /*return*/, resp.data];
|
102
|
-
}
|
103
|
-
});
|
104
|
-
});
|
105
|
-
};
|
106
|
-
WebhooksApi.prototype.constructWebhookEvent = function (payload, header, secret, tolerance) {
|
107
|
-
if (tolerance === void 0) { tolerance = undefined; }
|
108
|
-
WebhookVerification_1.signature.verifyHeader(payload, header, secret, tolerance || this.DEFAULT_TOLERANCE);
|
109
|
-
var jsonPayload = JSON.parse(payload);
|
110
|
-
return jsonPayload;
|
10
|
+
WebhooksApi.constructWebhookEvent = function (payload, headers, secret) {
|
11
|
+
var wh = new svix_1.Webhook(secret);
|
12
|
+
return wh.verify(payload, headers);
|
111
13
|
};
|
112
14
|
return WebhooksApi;
|
113
15
|
}());
|
@@ -5,5 +5,5 @@ export declare class WorkoutsApi {
|
|
5
5
|
client: AxiosInstance;
|
6
6
|
constructor(baseURL: string, axios: AxiosInstance);
|
7
7
|
get(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientWorkoutResponse>;
|
8
|
-
|
8
|
+
getStream(workoutId: string): Promise<ClientWorkoutStreamResponse>;
|
9
9
|
}
|
package/dist/client/Workouts.js
CHANGED
@@ -47,7 +47,7 @@ var WorkoutsApi = /** @class */ (function () {
|
|
47
47
|
var resp;
|
48
48
|
return __generator(this, function (_a) {
|
49
49
|
switch (_a.label) {
|
50
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/workouts/" + userKey), {
|
50
|
+
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/workouts/" + userKey), {
|
51
51
|
params: { start_date: startDate, end_date: endDate, provider: provider },
|
52
52
|
})];
|
53
53
|
case 1:
|
@@ -57,12 +57,12 @@ var WorkoutsApi = /** @class */ (function () {
|
|
57
57
|
});
|
58
58
|
});
|
59
59
|
};
|
60
|
-
WorkoutsApi.prototype.
|
60
|
+
WorkoutsApi.prototype.getStream = function (workoutId) {
|
61
61
|
return __awaiter(this, void 0, void 0, function () {
|
62
62
|
var resp;
|
63
63
|
return __generator(this, function (_a) {
|
64
64
|
switch (_a.label) {
|
65
|
-
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/workouts/" + workoutId + "/stream
|
65
|
+
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/timeseries/workouts/" + workoutId + "/stream"))];
|
66
66
|
case 1:
|
67
67
|
resp = _a.sent();
|
68
68
|
return [2 /*return*/, resp.data];
|
package/dist/client/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
export { ActivityApi } from './Activity';
|
2
2
|
export { BodyApi } from './Body';
|
3
3
|
export { LinkApi } from './Link';
|
4
|
-
export { ProviderSpecificApi } from './ProviderSpecific';
|
5
4
|
export { SleepApi } from './Sleep';
|
6
5
|
export { UserApi } from './User';
|
7
6
|
export { WebhooksApi } from './Webhooks';
|
8
7
|
export { WorkoutsApi } from './Workouts';
|
9
8
|
export { TestkitsApi } from './Testkits';
|
9
|
+
export { ProfileApi } from './Profile';
|
package/dist/client/index.js
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.TestkitsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.
|
3
|
+
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");
|
7
7
|
Object.defineProperty(exports, "BodyApi", { enumerable: true, get: function () { return Body_1.BodyApi; } });
|
8
8
|
var Link_1 = require("./Link");
|
9
9
|
Object.defineProperty(exports, "LinkApi", { enumerable: true, get: function () { return Link_1.LinkApi; } });
|
10
|
-
var ProviderSpecific_1 = require("./ProviderSpecific");
|
11
|
-
Object.defineProperty(exports, "ProviderSpecificApi", { enumerable: true, get: function () { return ProviderSpecific_1.ProviderSpecificApi; } });
|
12
10
|
var Sleep_1 = require("./Sleep");
|
13
11
|
Object.defineProperty(exports, "SleepApi", { enumerable: true, get: function () { return Sleep_1.SleepApi; } });
|
14
12
|
var User_1 = require("./User");
|
@@ -19,3 +17,5 @@ var Workouts_1 = require("./Workouts");
|
|
19
17
|
Object.defineProperty(exports, "WorkoutsApi", { enumerable: true, get: function () { return Workouts_1.WorkoutsApi; } });
|
20
18
|
var Testkits_1 = require("./Testkits");
|
21
19
|
Object.defineProperty(exports, "TestkitsApi", { enumerable: true, get: function () { return Testkits_1.TestkitsApi; } });
|
20
|
+
var Profile_1 = require("./Profile");
|
21
|
+
Object.defineProperty(exports, "ProfileApi", { enumerable: true, get: function () { return Profile_1.ProfileApi; } });
|
@@ -17,13 +17,13 @@ export interface ClientFacingActivity {
|
|
17
17
|
* @type {number}
|
18
18
|
* @memberof ClientFacingActivity
|
19
19
|
*/
|
20
|
-
|
20
|
+
calories_total: number;
|
21
21
|
/**
|
22
22
|
* Energy consumption caused by the physical activity of the day in kilocalories.::kilocalories
|
23
23
|
* @type {number}
|
24
24
|
* @memberof ClientFacingActivity
|
25
25
|
*/
|
26
|
-
|
26
|
+
calories_active: number;
|
27
27
|
/**
|
28
28
|
* Total number of steps registered during the day.::steps
|
29
29
|
* @type {number}
|
@@ -35,7 +35,7 @@ export interface ClientFacingActivity {
|
|
35
35
|
* @type {number}
|
36
36
|
* @memberof ClientFacingActivity
|
37
37
|
*/
|
38
|
-
|
38
|
+
daily_movement?: number;
|
39
39
|
/**
|
40
40
|
* Number of minutes during the day with low intensity activity (e.g. household work).::minutes
|
41
41
|
* @type {number}
|
@@ -87,6 +87,12 @@ export interface ClientGlucoseResponse {
|
|
87
87
|
export interface ClientCholesterolResponse {
|
88
88
|
cholesterol: ClientFacingCholesterol[];
|
89
89
|
}
|
90
|
+
export interface TimeseriesPoint {
|
91
|
+
timestamp: Date;
|
92
|
+
value: number;
|
93
|
+
type: string;
|
94
|
+
unit: string;
|
95
|
+
}
|
90
96
|
declare enum RespiratoryAllergen {
|
91
97
|
D_PTERONYSSINUS = "d_pteronyssinus",
|
92
98
|
D_FARINAE = "d_farinae",
|
@@ -29,24 +29,6 @@ export interface ClientFacingBody {
|
|
29
29
|
* @memberof ClientFacingBody
|
30
30
|
*/
|
31
31
|
fat?: number;
|
32
|
-
/**
|
33
|
-
* Age of user.::years
|
34
|
-
* @type {number}
|
35
|
-
* @memberof ClientFacingBody
|
36
|
-
*/
|
37
|
-
age?: number;
|
38
|
-
/**
|
39
|
-
* Height in cm.::cm
|
40
|
-
* @type {number}
|
41
|
-
* @memberof ClientFacingBody
|
42
|
-
*/
|
43
|
-
height?: number;
|
44
|
-
/**
|
45
|
-
* Gender of user.
|
46
|
-
* @type {string}
|
47
|
-
* @memberof ClientFacingBody
|
48
|
-
*/
|
49
|
-
gender?: string;
|
50
32
|
/**
|
51
33
|
* Source the data has come from.
|
52
34
|
* @type {SourceClientFacing}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { SourceClientFacing } from './user_models';
|
2
|
+
export interface ClientFacingProfile {
|
3
|
+
/**
|
4
|
+
* Age of user.::years
|
5
|
+
* @type {number}
|
6
|
+
* @memberof ClientFacingBody
|
7
|
+
*/
|
8
|
+
age?: number;
|
9
|
+
/**
|
10
|
+
* Height in cm.::cm
|
11
|
+
* @type {number}
|
12
|
+
* @memberof ClientFacingBody
|
13
|
+
*/
|
14
|
+
height?: number;
|
15
|
+
/**
|
16
|
+
* Gender of user.
|
17
|
+
* @type {string}
|
18
|
+
* @memberof ClientFacingBody
|
19
|
+
*/
|
20
|
+
gender?: string;
|
21
|
+
/**
|
22
|
+
* Source the data has come from.
|
23
|
+
* @type {SourceClientFacing}
|
24
|
+
* @memberof ClientFacingBody
|
25
|
+
*/
|
26
|
+
source: SourceClientFacing;
|
27
|
+
/**
|
28
|
+
* User key returned by vital create user key request. This key should be stored in your database against the user and used for all interactions with the vital api.
|
29
|
+
* @type {string}
|
30
|
+
* @memberof ClientFacingBody
|
31
|
+
*/
|
32
|
+
user_id: string;
|
33
|
+
}
|
package/dist/{swagger_client/models/client-activity-response.js → client/models/profile_model.js}
RENAMED
File without changes
|
@@ -8,10 +8,23 @@ export interface PatientAdress {
|
|
8
8
|
country: string;
|
9
9
|
phone_number: string;
|
10
10
|
}
|
11
|
+
export interface PatientDetails {
|
12
|
+
dob: string;
|
13
|
+
gender: string;
|
14
|
+
}
|
15
|
+
export interface Marker {
|
16
|
+
name: string;
|
17
|
+
slug: string;
|
18
|
+
description?: string;
|
19
|
+
}
|
11
20
|
export interface Testkit {
|
12
21
|
id: string;
|
13
22
|
name: string;
|
14
23
|
description: string;
|
24
|
+
markers: Marker[];
|
25
|
+
turnaround_time_lower: number;
|
26
|
+
turnaround_time_upper: number;
|
27
|
+
price: number;
|
15
28
|
}
|
16
29
|
export interface Order {
|
17
30
|
id: string;
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ActivityApi, BodyApi, LinkApi,
|
1
|
+
import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi } from './client';
|
2
2
|
import { ClientConfig } from './lib/models';
|
3
3
|
import { ClientCredentials } from './lib/credentials';
|
4
4
|
import { VitalsApi } from './client/Vitals';
|
@@ -8,12 +8,12 @@ export declare class VitalClient {
|
|
8
8
|
Activity: ActivityApi;
|
9
9
|
Link: LinkApi;
|
10
10
|
Body: BodyApi;
|
11
|
-
ProviderSpecific: ProviderSpecificApi;
|
12
11
|
Sleep: SleepApi;
|
13
12
|
User: UserApi;
|
14
13
|
Workouts: WorkoutsApi;
|
15
14
|
Webhooks: WebhooksApi;
|
16
15
|
Vitals: VitalsApi;
|
17
16
|
Testkits: TestkitsApi;
|
17
|
+
Profile: ProfileApi;
|
18
18
|
constructor(config: ClientConfig);
|
19
19
|
}
|
package/dist/index.js
CHANGED
@@ -59,7 +59,7 @@ var VitalClient = /** @class */ (function () {
|
|
59
59
|
var _this = this;
|
60
60
|
this.config = config;
|
61
61
|
this.clientCredentials = new credentials_1.ClientCredentials(config);
|
62
|
-
var baseURL = config_1.default.baseUrls[config.environment]
|
62
|
+
var baseURL = config_1.default.baseUrls[config.environment];
|
63
63
|
var axiosApiInstance = axios_1.default.create();
|
64
64
|
axios_retry_1.default(axiosApiInstance, {
|
65
65
|
retries: 3,
|
@@ -80,16 +80,16 @@ var VitalClient = /** @class */ (function () {
|
|
80
80
|
Promise.reject(error);
|
81
81
|
});
|
82
82
|
// Hook APIS
|
83
|
-
this.Activity = new client_1.ActivityApi(baseURL, axiosApiInstance);
|
84
|
-
this.Link = new client_1.LinkApi(baseURL, axiosApiInstance);
|
85
|
-
this.Body = new client_1.BodyApi(baseURL, axiosApiInstance);
|
86
|
-
this.
|
87
|
-
this.
|
88
|
-
this.
|
89
|
-
this.
|
90
|
-
this.
|
91
|
-
this.
|
92
|
-
this.
|
83
|
+
this.Activity = new client_1.ActivityApi(baseURL.concat('/v2'), axiosApiInstance);
|
84
|
+
this.Link = new client_1.LinkApi(baseURL.concat('/v1'), axiosApiInstance);
|
85
|
+
this.Body = new client_1.BodyApi(baseURL.concat('/v2'), axiosApiInstance);
|
86
|
+
this.Sleep = new client_1.SleepApi(baseURL.concat('/v2'), axiosApiInstance);
|
87
|
+
this.User = new client_1.UserApi(baseURL.concat('/v1'), axiosApiInstance);
|
88
|
+
this.Workouts = new client_1.WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
|
89
|
+
this.Webhooks = new client_1.WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
|
90
|
+
this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
|
91
|
+
this.Testkits = new client_1.TestkitsApi(baseURL.concat('/v1'), axiosApiInstance);
|
92
|
+
this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
|
93
93
|
}
|
94
94
|
return VitalClient;
|
95
95
|
}());
|
package/dist/lib/config.d.ts
CHANGED
package/dist/lib/config.js
CHANGED
package/index.ts
CHANGED
@@ -4,12 +4,12 @@ import {
|
|
4
4
|
ActivityApi,
|
5
5
|
BodyApi,
|
6
6
|
LinkApi,
|
7
|
-
ProviderSpecificApi,
|
8
7
|
SleepApi,
|
9
8
|
TestkitsApi,
|
10
9
|
UserApi,
|
11
10
|
WebhooksApi,
|
12
11
|
WorkoutsApi,
|
12
|
+
ProfileApi,
|
13
13
|
} from './client';
|
14
14
|
import { ClientConfig } from './lib/models';
|
15
15
|
import CONFIG from './lib/config';
|
@@ -22,18 +22,18 @@ export class VitalClient {
|
|
22
22
|
Activity: ActivityApi;
|
23
23
|
Link: LinkApi;
|
24
24
|
Body: BodyApi;
|
25
|
-
ProviderSpecific: ProviderSpecificApi;
|
26
25
|
Sleep: SleepApi;
|
27
26
|
User: UserApi;
|
28
27
|
Workouts: WorkoutsApi;
|
29
28
|
Webhooks: WebhooksApi;
|
30
29
|
Vitals: VitalsApi;
|
31
30
|
Testkits: TestkitsApi;
|
32
|
-
|
31
|
+
Profile: ProfileApi;
|
32
|
+
|
33
33
|
constructor(config: ClientConfig) {
|
34
34
|
this.config = config;
|
35
35
|
this.clientCredentials = new ClientCredentials(config);
|
36
|
-
const baseURL = CONFIG.baseUrls[config.environment]
|
36
|
+
const baseURL = CONFIG.baseUrls[config.environment];
|
37
37
|
const axiosApiInstance = axios.create();
|
38
38
|
|
39
39
|
axiosRetry(axiosApiInstance, {
|
@@ -57,15 +57,15 @@ export class VitalClient {
|
|
57
57
|
);
|
58
58
|
|
59
59
|
// Hook APIS
|
60
|
-
this.Activity = new ActivityApi(baseURL, axiosApiInstance);
|
61
|
-
this.Link = new LinkApi(baseURL, axiosApiInstance);
|
62
|
-
this.Body = new BodyApi(baseURL, axiosApiInstance);
|
63
|
-
this.
|
64
|
-
this.
|
65
|
-
this.
|
66
|
-
this.
|
67
|
-
this.
|
68
|
-
this.
|
69
|
-
this.
|
60
|
+
this.Activity = new ActivityApi(baseURL.concat('/v2'), axiosApiInstance);
|
61
|
+
this.Link = new LinkApi(baseURL.concat('/v1'), axiosApiInstance);
|
62
|
+
this.Body = new BodyApi(baseURL.concat('/v2'), axiosApiInstance);
|
63
|
+
this.Sleep = new SleepApi(baseURL.concat('/v2'), axiosApiInstance);
|
64
|
+
this.User = new UserApi(baseURL.concat('/v1'), axiosApiInstance);
|
65
|
+
this.Workouts = new WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
|
66
|
+
this.Webhooks = new WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
|
67
|
+
this.Vitals = new VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
|
68
|
+
this.Testkits = new TestkitsApi(baseURL.concat('/v1'), axiosApiInstance);
|
69
|
+
this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
|
70
70
|
}
|
71
71
|
}
|
package/lib/config.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tryvital/vital-node",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "Node client for Vital",
|
5
5
|
"author": "maitham",
|
6
6
|
"keywords": [
|
@@ -23,7 +23,8 @@
|
|
23
23
|
"auth0": "^2.35.1",
|
24
24
|
"axios": "^0.21.1",
|
25
25
|
"axios-retry": "^3.2.4",
|
26
|
-
"crypto": "^1.0.1"
|
26
|
+
"crypto": "^1.0.1",
|
27
|
+
"svix": "^0.41.2"
|
27
28
|
},
|
28
29
|
"devDependencies": {
|
29
30
|
"@testdeck/mocha": "^0.1.2",
|