@tryvital/vital-node 0.3.8 → 1.0.2

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.
Files changed (137) hide show
  1. package/client/Activity.ts +1 -1
  2. package/client/Body.ts +1 -1
  3. package/client/Profile.ts +25 -0
  4. package/client/Sleep.ts +2 -2
  5. package/client/Testkits.ts +11 -1
  6. package/client/Vitals.ts +45 -45
  7. package/client/Webhooks.ts +7 -58
  8. package/client/Workouts.ts +3 -3
  9. package/client/index.ts +1 -1
  10. package/client/models/activity.ts +7 -0
  11. package/client/models/body_model.ts +0 -18
  12. package/client/models/profile_model.ts +34 -0
  13. package/client/models/testkit_models.ts +9 -0
  14. package/dist/client/Activity.js +1 -1
  15. package/dist/client/Body.js +1 -1
  16. package/dist/client/Profile.d.ts +8 -0
  17. package/dist/client/{ProviderSpecific.js → Profile.js} +8 -12
  18. package/dist/client/Sleep.js +2 -2
  19. package/dist/client/Testkits.d.ts +1 -0
  20. package/dist/client/Testkits.js +16 -0
  21. package/dist/client/Vitals.d.ts +7 -6
  22. package/dist/client/Vitals.js +16 -41
  23. package/dist/client/Webhooks.d.ts +1 -7
  24. package/dist/client/Webhooks.js +4 -102
  25. package/dist/client/Workouts.d.ts +1 -1
  26. package/dist/client/Workouts.js +3 -3
  27. package/dist/client/index.d.ts +1 -1
  28. package/dist/client/index.js +3 -3
  29. package/dist/client/models/activity.d.ts +6 -0
  30. package/dist/client/models/body_model.d.ts +0 -18
  31. package/dist/client/models/profile_model.d.ts +33 -0
  32. package/dist/{swagger_client/models/client-activity-response.js → client/models/profile_model.js} +0 -0
  33. package/dist/client/models/testkit_models.d.ts +9 -0
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.js +11 -11
  36. package/dist/lib/config.d.ts +0 -1
  37. package/dist/lib/config.js +0 -1
  38. package/index.ts +14 -14
  39. package/lib/config.ts +0 -1
  40. package/package.json +3 -2
  41. package/client/ProviderSpecific.ts +0 -31
  42. package/dist/client/ProviderSpecific.d.ts +0 -8
  43. package/dist/swagger_client/api.d.ts +0 -18
  44. package/dist/swagger_client/api.js +0 -32
  45. package/dist/swagger_client/apis/activity-api.d.ts +0 -86
  46. package/dist/swagger_client/apis/activity-api.js +0 -241
  47. package/dist/swagger_client/apis/body-api.d.ts +0 -86
  48. package/dist/swagger_client/apis/body-api.js +0 -241
  49. package/dist/swagger_client/apis/link-api.d.ts +0 -115
  50. package/dist/swagger_client/apis/link-api.js +0 -310
  51. package/dist/swagger_client/apis/provider-specific-api.d.ts +0 -90
  52. package/dist/swagger_client/apis/provider-specific-api.js +0 -250
  53. package/dist/swagger_client/apis/sleep-api.d.ts +0 -120
  54. package/dist/swagger_client/apis/sleep-api.js +0 -330
  55. package/dist/swagger_client/apis/user-api.d.ts +0 -243
  56. package/dist/swagger_client/apis/user-api.js +0 -657
  57. package/dist/swagger_client/apis/webhooks-api.d.ts +0 -138
  58. package/dist/swagger_client/apis/webhooks-api.js +0 -379
  59. package/dist/swagger_client/apis/workouts-api.d.ts +0 -120
  60. package/dist/swagger_client/apis/workouts-api.js +0 -330
  61. package/dist/swagger_client/base.d.ts +0 -55
  62. package/dist/swagger_client/base.js +0 -67
  63. package/dist/swagger_client/configuration.d.ts +0 -63
  64. package/dist/swagger_client/configuration.js +0 -16
  65. package/dist/swagger_client/index.d.ts +0 -13
  66. package/dist/swagger_client/index.js +0 -27
  67. package/dist/swagger_client/models/client-activity-response.d.ts +0 -24
  68. package/dist/swagger_client/models/client-body-response.d.ts +0 -24
  69. package/dist/swagger_client/models/client-body-response.js +0 -2
  70. package/dist/swagger_client/models/client-facing-activity.d.ts +0 -84
  71. package/dist/swagger_client/models/client-facing-activity.js +0 -2
  72. package/dist/swagger_client/models/client-facing-body.d.ts +0 -72
  73. package/dist/swagger_client/models/client-facing-body.js +0 -2
  74. package/dist/swagger_client/models/client-facing-sleep-stream.d.ts +0 -48
  75. package/dist/swagger_client/models/client-facing-sleep-stream.js +0 -2
  76. package/dist/swagger_client/models/client-facing-sleep.d.ts +0 -138
  77. package/dist/swagger_client/models/client-facing-sleep.js +0 -2
  78. package/dist/swagger_client/models/client-facing-source-specific.d.ts +0 -48
  79. package/dist/swagger_client/models/client-facing-source-specific.js +0 -2
  80. package/dist/swagger_client/models/client-facing-sport.d.ts +0 -30
  81. package/dist/swagger_client/models/client-facing-sport.js +0 -2
  82. package/dist/swagger_client/models/client-facing-stream.d.ts +0 -84
  83. package/dist/swagger_client/models/client-facing-stream.js +0 -2
  84. package/dist/swagger_client/models/client-facing-user.d.ts +0 -48
  85. package/dist/swagger_client/models/client-facing-user.js +0 -2
  86. package/dist/swagger_client/models/client-facing-webhook.d.ts +0 -42
  87. package/dist/swagger_client/models/client-facing-webhook.js +0 -2
  88. package/dist/swagger_client/models/client-facing-workout.d.ts +0 -150
  89. package/dist/swagger_client/models/client-facing-workout.js +0 -2
  90. package/dist/swagger_client/models/client-sleep-response.d.ts +0 -24
  91. package/dist/swagger_client/models/client-sleep-response.js +0 -2
  92. package/dist/swagger_client/models/client-source-specific-response.d.ts +0 -24
  93. package/dist/swagger_client/models/client-source-specific-response.js +0 -2
  94. package/dist/swagger_client/models/client-webhook-response.d.ts +0 -24
  95. package/dist/swagger_client/models/client-webhook-response.js +0 -2
  96. package/dist/swagger_client/models/client-workout-response.d.ts +0 -24
  97. package/dist/swagger_client/models/client-workout-response.js +0 -2
  98. package/dist/swagger_client/models/connected-source-client-facing.d.ts +0 -24
  99. package/dist/swagger_client/models/connected-source-client-facing.js +0 -2
  100. package/dist/swagger_client/models/httpvalidation-error.d.ts +0 -24
  101. package/dist/swagger_client/models/httpvalidation-error.js +0 -2
  102. package/dist/swagger_client/models/index.d.ts +0 -32
  103. package/dist/swagger_client/models/index.js +0 -44
  104. package/dist/swagger_client/models/individual-provider-data.d.ts +0 -30
  105. package/dist/swagger_client/models/individual-provider-data.js +0 -2
  106. package/dist/swagger_client/models/link-token-exchange-response.d.ts +0 -24
  107. package/dist/swagger_client/models/link-token-exchange-response.js +0 -2
  108. package/dist/swagger_client/models/link-token-exchange.d.ts +0 -30
  109. package/dist/swagger_client/models/link-token-exchange.js +0 -2
  110. package/dist/swagger_client/models/password-providers.d.ts +0 -22
  111. package/dist/swagger_client/models/password-providers.js +0 -28
  112. package/dist/swagger_client/models/provider-link-response.d.ts +0 -30
  113. package/dist/swagger_client/models/provider-link-response.js +0 -2
  114. package/dist/swagger_client/models/providers-that-require-password-auth-whoop-renpho-peloton-zwift.d.ts +0 -18
  115. package/dist/swagger_client/models/providers-that-require-password-auth-whoop-renpho-peloton-zwift.js +0 -2
  116. package/dist/swagger_client/models/providers.d.ts +0 -27
  117. package/dist/swagger_client/models/providers.js +0 -33
  118. package/dist/swagger_client/models/source-client-facing.d.ts +0 -36
  119. package/dist/swagger_client/models/source-client-facing.js +0 -2
  120. package/dist/swagger_client/models/user-create.d.ts +0 -24
  121. package/dist/swagger_client/models/user-create.js +0 -2
  122. package/dist/swagger_client/models/user-key-response.d.ts +0 -30
  123. package/dist/swagger_client/models/user-key-response.js +0 -2
  124. package/dist/swagger_client/models/user-success-response.d.ts +0 -24
  125. package/dist/swagger_client/models/user-success-response.js +0 -2
  126. package/dist/swagger_client/models/validation-error.d.ts +0 -36
  127. package/dist/swagger_client/models/validation-error.js +0 -2
  128. package/dist/swagger_client/models/webhook-register.d.ts +0 -36
  129. package/dist/swagger_client/models/webhook-register.js +0 -2
  130. package/dist/swagger_client/models/webhook-type.d.ts +0 -24
  131. package/dist/swagger_client/models/webhook-type.js +0 -30
  132. package/dist/test/data/mock_webhook.d.ts +0 -49
  133. package/dist/test/data/mock_webhook.js +0 -170
  134. package/dist/test/webhook.spec.d.ts +0 -1
  135. package/dist/test/webhook.spec.js +0 -160
  136. package/test/data/mock_webhook.ts +0 -167
  137. package/test/webhook.spec.ts +0 -254
@@ -42,12 +42,12 @@ var VitalsApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- VitalsApi.prototype.cholesterol = function (type, userKey, startDate, endDate, provider) {
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("/vitals/cholesterol/" + type + "/" + userKey), {
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
- switch (_a.label) {
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.hba1c = function (userKey, startDate, endDate, provider) {
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
- switch (_a.label) {
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.ige = function (userKey, startDate, endDate) {
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
- switch (_a.label) {
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.igg = function (userKey, startDate, endDate) {
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
- switch (_a.label) {
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
- getAll(): Promise<ClientWebhookResponse>;
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
  }
@@ -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 WebhookVerification_1 = require("./lib/WebhookVerification");
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.prototype.getAll = function () {
48
- return __awaiter(this, void 0, void 0, function () {
49
- var resp;
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
- get_stream(workoutId: string): Promise<ClientWorkoutStreamResponse>;
8
+ getStream(workoutId: string): Promise<ClientWorkoutStreamResponse>;
9
9
  }
@@ -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.get_stream = function (workoutId) {
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/data"))];
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];
@@ -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';
@@ -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.ProviderSpecificApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
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; } });
@@ -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
+ dob?: string;
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
+ }
@@ -12,10 +12,19 @@ export interface PatientDetails {
12
12
  dob: string;
13
13
  gender: string;
14
14
  }
15
+ export interface Marker {
16
+ name: string;
17
+ slug: string;
18
+ description?: string;
19
+ }
15
20
  export interface Testkit {
16
21
  id: string;
17
22
  name: string;
18
23
  description: string;
24
+ markers: Marker[];
25
+ turnaround_time_lower: number;
26
+ turnaround_time_upper: number;
27
+ price: number;
19
28
  }
20
29
  export interface Order {
21
30
  id: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ActivityApi, BodyApi, LinkApi, ProviderSpecificApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi } from './client';
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].concat('/v1');
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.ProviderSpecific = new client_1.ProviderSpecificApi(baseURL, axiosApiInstance);
87
- this.Sleep = new client_1.SleepApi(baseURL, axiosApiInstance);
88
- this.User = new client_1.UserApi(baseURL, axiosApiInstance);
89
- this.Workouts = new client_1.WorkoutsApi(baseURL, axiosApiInstance);
90
- this.Webhooks = new client_1.WebhooksApi(baseURL, axiosApiInstance);
91
- this.Vitals = new Vitals_1.VitalsApi(baseURL, axiosApiInstance);
92
- this.Testkits = new client_1.TestkitsApi(baseURL, axiosApiInstance);
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
  }());
@@ -12,7 +12,6 @@ declare const _default: {
12
12
  baseUrls: {
13
13
  prod: string;
14
14
  production: string;
15
- dev: string;
16
15
  sandbox: string;
17
16
  };
18
17
  };
@@ -14,7 +14,6 @@ exports.default = {
14
14
  baseUrls: {
15
15
  prod: 'https://api.tryvital.io',
16
16
  production: 'https://api.tryvital.io',
17
- dev: 'https://api.dev.tryvital.io',
18
17
  sandbox: 'https://api.sandbox.tryvital.io',
19
18
  },
20
19
  };
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].concat('/v1');
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.ProviderSpecific = new ProviderSpecificApi(baseURL, axiosApiInstance);
64
- this.Sleep = new SleepApi(baseURL, axiosApiInstance);
65
- this.User = new UserApi(baseURL, axiosApiInstance);
66
- this.Workouts = new WorkoutsApi(baseURL, axiosApiInstance);
67
- this.Webhooks = new WebhooksApi(baseURL, axiosApiInstance);
68
- this.Vitals = new VitalsApi(baseURL, axiosApiInstance);
69
- this.Testkits = new TestkitsApi(baseURL, axiosApiInstance);
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
@@ -12,7 +12,6 @@ export default {
12
12
  baseUrls: {
13
13
  prod: 'https://api.tryvital.io',
14
14
  production: 'https://api.tryvital.io',
15
- dev: 'https://api.dev.tryvital.io',
16
15
  sandbox: 'https://api.sandbox.tryvital.io',
17
16
  },
18
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "0.3.8",
3
+ "version": "1.0.2",
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",
@@ -1,31 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { ClientProviderSpecificResponse } from './models/provider_specific';
3
-
4
- export class ProviderSpecificApi {
5
- baseURL: string;
6
- client: AxiosInstance;
7
- constructor(baseURL: string, axios: AxiosInstance) {
8
- this.baseURL = baseURL;
9
- this.client = axios;
10
- }
11
-
12
- public async get(
13
- userKey: string,
14
- startDate: Date,
15
- endDate: Date,
16
- provider: string,
17
- dataType?: 'activity' | 'sleep' | 'body' | 'workouts'
18
- ): Promise<ClientProviderSpecificResponse> {
19
- const resp = await this.client.get(
20
- this.baseURL.concat(`/provider-specific/${userKey}/${provider}`),
21
- {
22
- params: {
23
- start_date: startDate,
24
- end_date: endDate,
25
- data_type: dataType,
26
- },
27
- }
28
- );
29
- return resp.data;
30
- }
31
- }
@@ -1,8 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { ClientProviderSpecificResponse } from './models/provider_specific';
3
- export declare class ProviderSpecificApi {
4
- baseURL: string;
5
- client: AxiosInstance;
6
- constructor(baseURL: string, axios: AxiosInstance);
7
- get(userKey: string, startDate: Date, endDate: Date, provider: string, dataType?: 'activity' | 'sleep' | 'body' | 'workouts'): Promise<ClientProviderSpecificResponse>;
8
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Vital
3
- * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
4
- *
5
- * OpenAPI spec version: 0.1.0
6
- *
7
- *
8
- * NOTE: This class is auto generated by the swagger code generator program.
9
- * https://github.com/swagger-api/swagger-codegen.git
10
- * Do not edit the class manually.
11
- */ export * from './apis/activity-api';
12
- export * from './apis/body-api';
13
- export * from './apis/link-api';
14
- export * from './apis/provider-specific-api';
15
- export * from './apis/sleep-api';
16
- export * from './apis/user-api';
17
- export * from './apis/webhooks-api';
18
- export * from './apis/workouts-api';
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- /* tslint:disable */
14
- /* eslint-disable */
15
- /**
16
- * Vital
17
- * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
18
- *
19
- * OpenAPI spec version: 0.1.0
20
- *
21
- *
22
- * NOTE: This class is auto generated by the swagger code generator program.
23
- * https://github.com/swagger-api/swagger-codegen.git
24
- * Do not edit the class manually.
25
- */ __exportStar(require("./apis/activity-api"), exports);
26
- __exportStar(require("./apis/body-api"), exports);
27
- __exportStar(require("./apis/link-api"), exports);
28
- __exportStar(require("./apis/provider-specific-api"), exports);
29
- __exportStar(require("./apis/sleep-api"), exports);
30
- __exportStar(require("./apis/user-api"), exports);
31
- __exportStar(require("./apis/webhooks-api"), exports);
32
- __exportStar(require("./apis/workouts-api"), exports);