@tryvital/vital-node 1.1.0 → 1.3.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.
Files changed (77) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/__tests__/activity.test.ts +18 -0
  3. package/__tests__/arrange.ts +36 -0
  4. package/__tests__/body.test.ts +17 -0
  5. package/__tests__/devices.test.ts +15 -0
  6. package/__tests__/link.test.ts +15 -0
  7. package/__tests__/profile.test.ts +15 -0
  8. package/__tests__/sleep.test.ts +17 -0
  9. package/__tests__/user.test.ts +37 -0
  10. package/__tests__/vitals.test.ts +17 -0
  11. package/__tests__/workouts.test.ts +17 -0
  12. package/client/Activity.ts +4 -4
  13. package/client/Body.ts +4 -5
  14. package/client/Devices.ts +25 -0
  15. package/client/Link.ts +2 -2
  16. package/client/Profile.ts +5 -5
  17. package/client/Provider.ts +17 -0
  18. package/client/Sleep.ts +8 -5
  19. package/client/Testkits.ts +28 -4
  20. package/client/User.ts +19 -10
  21. package/client/Vitals.ts +10 -10
  22. package/client/Workouts.ts +4 -4
  23. package/client/index.ts +1 -0
  24. package/client/models/body_model.ts +1 -1
  25. package/client/models/profile_model.ts +1 -1
  26. package/client/models/provider_models.ts +19 -0
  27. package/client/models/provider_specific.ts +1 -1
  28. package/client/models/raw_response.ts +14 -1
  29. package/client/models/sleep_models.ts +1 -1
  30. package/client/models/testkit_models.ts +32 -11
  31. package/client/models/user_models.ts +3 -2
  32. package/client/models/workout_models.ts +1 -1
  33. package/dist/client/Activity.d.ts +2 -2
  34. package/dist/client/Activity.js +4 -4
  35. package/dist/client/Body.d.ts +2 -2
  36. package/dist/client/Body.js +4 -4
  37. package/dist/client/Devices.d.ts +8 -0
  38. package/dist/client/Devices.js +62 -0
  39. package/dist/client/Link.d.ts +1 -1
  40. package/dist/client/Link.js +2 -2
  41. package/dist/client/Profile.d.ts +2 -2
  42. package/dist/client/Profile.js +4 -4
  43. package/dist/client/Provider.d.ts +8 -0
  44. package/dist/client/Provider.js +60 -0
  45. package/dist/client/Sleep.d.ts +2 -2
  46. package/dist/client/Sleep.js +4 -4
  47. package/dist/client/Testkits.d.ts +6 -3
  48. package/dist/client/Testkits.js +43 -4
  49. package/dist/client/User.d.ts +7 -6
  50. package/dist/client/User.js +21 -8
  51. package/dist/client/Vitals.d.ts +5 -5
  52. package/dist/client/Vitals.js +10 -10
  53. package/dist/client/Workouts.d.ts +2 -2
  54. package/dist/client/Workouts.js +4 -4
  55. package/dist/client/index.d.ts +1 -0
  56. package/dist/client/index.js +3 -1
  57. package/dist/client/models/body_model.d.ts +1 -1
  58. package/dist/client/models/profile_model.d.ts +1 -1
  59. package/dist/client/models/provider_models.d.ts +18 -0
  60. package/dist/client/models/provider_models.js +15 -0
  61. package/dist/client/models/provider_specific.d.ts +1 -1
  62. package/dist/client/models/raw_response.d.ts +11 -0
  63. package/dist/client/models/sleep_models.d.ts +1 -1
  64. package/dist/client/models/testkit_models.d.ts +18 -1
  65. package/dist/client/models/user_models.d.ts +3 -2
  66. package/dist/client/models/workout_models.d.ts +1 -1
  67. package/dist/index.d.ts +4 -1
  68. package/dist/index.js +10 -1
  69. package/dist/lib/config.d.ts +9 -0
  70. package/dist/lib/config.js +9 -0
  71. package/dist/lib/models.d.ts +2 -1
  72. package/index.ts +12 -1
  73. package/jest.config.js +6 -0
  74. package/lib/config.ts +9 -0
  75. package/lib/models.ts +2 -1
  76. package/package.json +7 -1
  77. package/tsconfig.json +14 -5
@@ -57,12 +57,12 @@ var UserApi = /** @class */ (function () {
57
57
  });
58
58
  });
59
59
  };
60
- UserApi.prototype.delete = function (userKey) {
60
+ UserApi.prototype.delete = function (userId) {
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.delete(this.baseURL.concat("/user/" + userKey))];
65
+ case 0: return [4 /*yield*/, this.client.delete(this.baseURL.concat("/user/" + userId))];
66
66
  case 1:
67
67
  resp = _a.sent();
68
68
  return [2 /*return*/, resp.data];
@@ -83,12 +83,12 @@ var UserApi = /** @class */ (function () {
83
83
  });
84
84
  });
85
85
  };
86
- UserApi.prototype.get = function (userKey) {
86
+ UserApi.prototype.get = function (userId) {
87
87
  return __awaiter(this, void 0, void 0, function () {
88
88
  var resp;
89
89
  return __generator(this, function (_a) {
90
90
  switch (_a.label) {
91
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/user/" + userKey))];
91
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/user/" + userId))];
92
92
  case 1:
93
93
  resp = _a.sent();
94
94
  return [2 /*return*/, resp.data];
@@ -109,12 +109,12 @@ var UserApi = /** @class */ (function () {
109
109
  });
110
110
  });
111
111
  };
112
- UserApi.prototype.providers = function (userKey) {
112
+ UserApi.prototype.providers = function (userId) {
113
113
  return __awaiter(this, void 0, void 0, function () {
114
114
  var resp;
115
115
  return __generator(this, function (_a) {
116
116
  switch (_a.label) {
117
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/user/providers/" + userKey))];
117
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/user/providers/" + userId))];
118
118
  case 1:
119
119
  resp = _a.sent();
120
120
  return [2 /*return*/, resp.data];
@@ -122,12 +122,25 @@ var UserApi = /** @class */ (function () {
122
122
  });
123
123
  });
124
124
  };
125
- UserApi.prototype.deregisterProvider = function (userKey, provider) {
125
+ UserApi.prototype.deregisterProvider = function (userId, provider) {
126
126
  return __awaiter(this, void 0, void 0, function () {
127
127
  var resp;
128
128
  return __generator(this, function (_a) {
129
129
  switch (_a.label) {
130
- case 0: return [4 /*yield*/, this.client.delete(this.baseURL.concat("/user/" + userKey + "/" + provider))];
130
+ case 0: return [4 /*yield*/, this.client.delete(this.baseURL.concat("/user/" + userId + "/" + provider))];
131
+ case 1:
132
+ resp = _a.sent();
133
+ return [2 /*return*/, resp.data];
134
+ }
135
+ });
136
+ });
137
+ };
138
+ UserApi.prototype.refresh = function (userId) {
139
+ return __awaiter(this, void 0, void 0, function () {
140
+ var resp;
141
+ return __generator(this, function (_a) {
142
+ switch (_a.label) {
143
+ case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat("/user/refresh/" + userId))];
131
144
  case 1:
132
145
  resp = _a.sent();
133
146
  return [2 /*return*/, resp.data];
@@ -5,9 +5,9 @@ export declare class VitalsApi {
5
5
  client: AxiosInstance;
6
6
  constructor(baseURL: string, axios: AxiosInstance);
7
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[]>;
8
+ cholesterol(type: 'ldl' | 'total' | 'triglycerides' | 'hdl', userId: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
9
+ glucose(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
10
+ ige(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
11
+ igg(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
12
+ heartrate(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<TimeseriesPoint[]>;
13
13
  }
@@ -57,38 +57,38 @@ var VitalsApi = /** @class */ (function () {
57
57
  });
58
58
  });
59
59
  };
60
- VitalsApi.prototype.cholesterol = function (type, userKey, startDate, endDate, provider) {
60
+ VitalsApi.prototype.cholesterol = function (type, userId, startDate, endDate, provider) {
61
61
  return __awaiter(this, void 0, void 0, function () {
62
62
  return __generator(this, function (_a) {
63
- return [2 /*return*/, this.timeseriesData(userKey, "cholesterol/" + type, startDate, endDate, provider)];
63
+ return [2 /*return*/, this.timeseriesData(userId, "cholesterol/" + type, startDate, endDate, provider)];
64
64
  });
65
65
  });
66
66
  };
67
- VitalsApi.prototype.glucose = function (userKey, startDate, endDate, provider) {
67
+ VitalsApi.prototype.glucose = function (userId, startDate, endDate, provider) {
68
68
  return __awaiter(this, void 0, void 0, function () {
69
69
  return __generator(this, function (_a) {
70
- return [2 /*return*/, this.timeseriesData(userKey, 'glucose', startDate, endDate, provider)];
70
+ return [2 /*return*/, this.timeseriesData(userId, 'glucose', startDate, endDate, provider)];
71
71
  });
72
72
  });
73
73
  };
74
- VitalsApi.prototype.ige = function (userKey, startDate, endDate, provider) {
74
+ VitalsApi.prototype.ige = function (userId, startDate, endDate, provider) {
75
75
  return __awaiter(this, void 0, void 0, function () {
76
76
  return __generator(this, function (_a) {
77
- return [2 /*return*/, this.timeseriesData(userKey, 'ige', startDate, endDate, provider)];
77
+ return [2 /*return*/, this.timeseriesData(userId, 'ige', startDate, endDate, provider)];
78
78
  });
79
79
  });
80
80
  };
81
- VitalsApi.prototype.igg = function (userKey, startDate, endDate, provider) {
81
+ VitalsApi.prototype.igg = function (userId, startDate, endDate, provider) {
82
82
  return __awaiter(this, void 0, void 0, function () {
83
83
  return __generator(this, function (_a) {
84
- return [2 /*return*/, this.timeseriesData(userKey, 'igg', startDate, endDate, provider)];
84
+ return [2 /*return*/, this.timeseriesData(userId, 'igg', startDate, endDate, provider)];
85
85
  });
86
86
  });
87
87
  };
88
- VitalsApi.prototype.heartrate = function (userKey, startDate, endDate, provider) {
88
+ VitalsApi.prototype.heartrate = function (userId, startDate, endDate, provider) {
89
89
  return __awaiter(this, void 0, void 0, function () {
90
90
  return __generator(this, function (_a) {
91
- return [2 /*return*/, this.timeseriesData(userKey, 'heartrate', startDate, endDate, provider)];
91
+ return [2 /*return*/, this.timeseriesData(userId, 'heartrate', startDate, endDate, provider)];
92
92
  });
93
93
  });
94
94
  };
@@ -5,7 +5,7 @@ export declare class WorkoutsApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientWorkoutResponse>;
8
+ get(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientWorkoutResponse>;
9
9
  getStream(workoutId: string): Promise<ClientWorkoutStreamResponse>;
10
- get_raw(userKey: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientWorkoutsRawResponse>;
10
+ get_raw(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientWorkoutsRawResponse>;
11
11
  }
@@ -42,12 +42,12 @@ var WorkoutsApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- WorkoutsApi.prototype.get = function (userKey, startDate, endDate, provider) {
45
+ WorkoutsApi.prototype.get = function (userId, 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("/summary/workouts/" + userKey), {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/workouts/" + userId), {
51
51
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
52
  })];
53
53
  case 1:
@@ -70,12 +70,12 @@ var WorkoutsApi = /** @class */ (function () {
70
70
  });
71
71
  });
72
72
  };
73
- WorkoutsApi.prototype.get_raw = function (userKey, startDate, endDate, provider) {
73
+ WorkoutsApi.prototype.get_raw = function (userId, startDate, endDate, provider) {
74
74
  return __awaiter(this, void 0, void 0, function () {
75
75
  var resp;
76
76
  return __generator(this, function (_a) {
77
77
  switch (_a.label) {
78
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/workouts/" + userKey + "/raw"), {
78
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/workouts/" + userId + "/raw"), {
79
79
  params: { start_date: startDate, end_date: endDate, provider: provider },
80
80
  })];
81
81
  case 1:
@@ -7,3 +7,4 @@ export { WebhooksApi } from './Webhooks';
7
7
  export { WorkoutsApi } from './Workouts';
8
8
  export { TestkitsApi } from './Testkits';
9
9
  export { ProfileApi } from './Profile';
10
+ export { DevicesAPI } from './Devices';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProfileApi = exports.TestkitsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
3
+ 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");
@@ -19,3 +19,5 @@ var Testkits_1 = require("./Testkits");
19
19
  Object.defineProperty(exports, "TestkitsApi", { enumerable: true, get: function () { return Testkits_1.TestkitsApi; } });
20
20
  var Profile_1 = require("./Profile");
21
21
  Object.defineProperty(exports, "ProfileApi", { enumerable: true, get: function () { return Profile_1.ProfileApi; } });
22
+ var Devices_1 = require("./Devices");
23
+ Object.defineProperty(exports, "DevicesAPI", { enumerable: true, get: function () { return Devices_1.DevicesAPI; } });
@@ -36,7 +36,7 @@ export interface ClientFacingBody {
36
36
  */
37
37
  source: SourceClientFacing;
38
38
  /**
39
- * 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.
39
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
40
40
  * @type {string}
41
41
  * @memberof ClientFacingBody
42
42
  */
@@ -25,7 +25,7 @@ export interface ClientFacingProfile {
25
25
  */
26
26
  source: SourceClientFacing;
27
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.
28
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
29
29
  * @type {string}
30
30
  * @memberof ClientFacingBody
31
31
  */
@@ -0,0 +1,18 @@
1
+ export declare enum Resource {
2
+ WORKOUTS = "workouts",
3
+ ACTVITY = "activity",
4
+ SLEEP = "sleep",
5
+ BODY = "body",
6
+ WORKOUTS_STREAM = "workouts/stream",
7
+ SLEEP_STREAM = "sleep/stream",
8
+ HEARTRATE = "heartrate",
9
+ GLUCOSE = "glucose",
10
+ PROFILE = "profile"
11
+ }
12
+ export interface Provider {
13
+ name: string;
14
+ slug: string;
15
+ logo: string;
16
+ auth_type: 'password' | 'email' | 'oauth';
17
+ supported_resources: Resource[];
18
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Resource = void 0;
4
+ var Resource;
5
+ (function (Resource) {
6
+ Resource["WORKOUTS"] = "workouts";
7
+ Resource["ACTVITY"] = "activity";
8
+ Resource["SLEEP"] = "sleep";
9
+ Resource["BODY"] = "body";
10
+ Resource["WORKOUTS_STREAM"] = "workouts/stream";
11
+ Resource["SLEEP_STREAM"] = "sleep/stream";
12
+ Resource["HEARTRATE"] = "heartrate";
13
+ Resource["GLUCOSE"] = "glucose";
14
+ Resource["PROFILE"] = "profile";
15
+ })(Resource = exports.Resource || (exports.Resource = {}));
@@ -29,7 +29,7 @@ export interface ClientFacingSourceSpecific {
29
29
  */
30
30
  data: unknown;
31
31
  /**
32
- * 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.
32
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
33
33
  * @type {string}
34
34
  * @memberof ClientFacingSourceSpecific
35
35
  */
@@ -10,6 +10,14 @@ export interface RawResponse {
10
10
  data: Record<string, string>;
11
11
  provider_id: string;
12
12
  }
13
+ export interface DeviceRawResponse {
14
+ id: string;
15
+ user_id: string;
16
+ source_id: number;
17
+ source?: SourceClientFacing;
18
+ data: Record<string, string>;
19
+ provider_id: string;
20
+ }
13
21
  export interface ClientActivityRawResponse {
14
22
  activity: RawResponse[];
15
23
  }
@@ -25,3 +33,6 @@ export interface ClientSleepRawResponse {
25
33
  export interface ClientProfileRawResponse {
26
34
  profile: RawResponse[];
27
35
  }
36
+ export interface ClientDevicesRawResponse {
37
+ devices: DeviceRawResponse[];
38
+ }
@@ -121,7 +121,7 @@ export interface ClientFacingSleep {
121
121
  */
122
122
  source: SourceClientFacing;
123
123
  /**
124
- * 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.
124
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
125
125
  * @type {string}
126
126
  * @memberof ClientFacingSleep
127
127
  */
@@ -31,7 +31,7 @@ export interface Order {
31
31
  team_id: string;
32
32
  created_on: Date;
33
33
  updated_on: Date;
34
- status: 'ordered' | 'transit_customer' | 'out_for_delivery' | 'with_customer' | 'transit_lab' | 'delivered_to_lab' | 'processing_lab' | 'completed' | 'failure_to_deliver_to_customer' | 'failure_to_deliver_to_lab' | 'unknown';
34
+ status: 'ordered' | 'transit_customer' | 'out_for_delivery' | 'with_customer' | 'transit_lab' | 'delivered_to_lab' | 'processing_lab' | 'completed' | 'failure_to_deliver_to_customer' | 'failure_to_deliver_to_lab' | 'cancelled' | 'do_not_process' | 'unknown';
35
35
  user_key: string;
36
36
  testkit_id: string;
37
37
  testkit: Testkit;
@@ -51,3 +51,20 @@ export interface OrderRequestResponse {
51
51
  export interface TestkitResponse {
52
52
  testkits: Testkit[];
53
53
  }
54
+ export interface LabResultsMetadata {
55
+ age: string;
56
+ dob: string;
57
+ clia_number: string;
58
+ patient: string;
59
+ provider: string;
60
+ laboratory: string;
61
+ date_reported: string;
62
+ date_collected: string;
63
+ specimen_number: string;
64
+ date_received?: string;
65
+ clia?: string;
66
+ }
67
+ export interface LabResultsRaw {
68
+ metadata: LabResultsMetadata;
69
+ data: Record<string, string>;
70
+ }
@@ -1,6 +1,6 @@
1
- export interface UserKeyResponse {
1
+ export interface UserIdResponse {
2
2
  client_user_id: string;
3
- user_key: string;
3
+ user_id: string;
4
4
  }
5
5
  export interface SuccessResponse {
6
6
  success: boolean;
@@ -30,6 +30,7 @@ export interface ClientFacingUser {
30
30
  client_user_id: string;
31
31
  created_on: string;
32
32
  connecte_sources: Array<ConnectedSourceClientFacing>;
33
+ user_id: string;
33
34
  }
34
35
  export declare enum Providers {
35
36
  Oura = "oura",
@@ -80,7 +80,7 @@ export interface ClientFacingWorkout {
80
80
  */
81
81
  hr_zones: number[];
82
82
  /**
83
- * 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.
83
+ * User id returned by vital create user id request. This id should be stored in your database against the user and used for all interactions with the vital api.
84
84
  * @type {string}
85
85
  * @memberof ClientFacingWorkout
86
86
  */
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi } from './client';
1
+ import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI } from './client';
2
2
  import { ClientConfig } from './lib/models';
3
3
  import { ClientCredentials } from './lib/credentials';
4
4
  import { VitalsApi } from './client/Vitals';
5
+ import { ProviderApi } from './client/Provider';
5
6
  export declare class VitalClient {
6
7
  config: ClientConfig;
7
8
  clientCredentials: ClientCredentials;
@@ -15,5 +16,7 @@ export declare class VitalClient {
15
16
  Vitals: VitalsApi;
16
17
  Testkits: TestkitsApi;
17
18
  Profile: ProfileApi;
19
+ Providers: ProviderApi;
20
+ Devices: DevicesAPI;
18
21
  constructor(config: ClientConfig);
19
22
  }
package/dist/index.js CHANGED
@@ -54,12 +54,19 @@ var client_1 = require("./client");
54
54
  var config_1 = require("./lib/config");
55
55
  var credentials_1 = require("./lib/credentials");
56
56
  var Vitals_1 = require("./client/Vitals");
57
+ var Provider_1 = require("./client/Provider");
57
58
  var VitalClient = /** @class */ (function () {
58
59
  function VitalClient(config) {
59
60
  var _this = this;
60
61
  this.config = config;
61
62
  this.clientCredentials = new credentials_1.ClientCredentials(config);
62
- var baseURL = config_1.default.baseUrls[config.environment];
63
+ var baseURL;
64
+ if (this.config.region && this.config.region === 'eu') {
65
+ baseURL = config_1.default.baseEUUrls[config.environment];
66
+ }
67
+ else {
68
+ baseURL = config_1.default.baseUrls[config.environment];
69
+ }
63
70
  var axiosApiInstance = axios_1.default.create();
64
71
  axios_retry_1.default(axiosApiInstance, {
65
72
  retries: 3,
@@ -90,6 +97,8 @@ var VitalClient = /** @class */ (function () {
90
97
  this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
91
98
  this.Testkits = new client_1.TestkitsApi(baseURL.concat('/v2'), axiosApiInstance);
92
99
  this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
100
+ this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
101
+ this.Devices = new client_1.DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
93
102
  }
94
103
  return VitalClient;
95
104
  }());
@@ -3,16 +3,25 @@ declare const _default: {
3
3
  production: string;
4
4
  prod: string;
5
5
  sandbox: string;
6
+ development: string;
6
7
  };
7
8
  domains: {
8
9
  production: string;
9
10
  prod: string;
10
11
  sandbox: string;
12
+ development: string;
11
13
  };
12
14
  baseUrls: {
13
15
  prod: string;
14
16
  production: string;
15
17
  sandbox: string;
18
+ development: string;
19
+ };
20
+ baseEUUrls: {
21
+ prod: string;
22
+ production: string;
23
+ sandbox: string;
24
+ development: string;
16
25
  };
17
26
  };
18
27
  export default _default;
@@ -5,15 +5,24 @@ exports.default = {
5
5
  production: 'https://api.tryvital.io',
6
6
  prod: 'https://api.tryvital.io',
7
7
  sandbox: 'https://api.sandbox.tryvital.io',
8
+ development: 'https://api.tryvital.io/v1',
8
9
  },
9
10
  domains: {
10
11
  production: 'auth.tryvital.io',
11
12
  prod: 'auth.tryvital.io',
12
13
  sandbox: 'auth.sandbox.tryvital.io',
14
+ development: 'dev-vital-api.us.auth0.com',
13
15
  },
14
16
  baseUrls: {
15
17
  prod: 'https://api.tryvital.io',
16
18
  production: 'https://api.tryvital.io',
17
19
  sandbox: 'https://api.sandbox.tryvital.io',
20
+ development: 'https://api.dev.tryvital.io',
21
+ },
22
+ baseEUUrls: {
23
+ prod: 'https://api.eu.tryvital.io',
24
+ production: 'https://api.eu.tryvital.io',
25
+ sandbox: 'https://api.sandbox.eu.tryvital.io',
26
+ development: 'https://api.dev.eu.tryvital.io',
18
27
  },
19
28
  };
@@ -1,7 +1,8 @@
1
1
  export interface ClientConfig {
2
2
  client_id: string;
3
3
  client_secret: string;
4
- environment: 'prod' | 'production' | 'sandbox';
4
+ environment: 'prod' | 'production' | 'sandbox' | 'development';
5
+ region?: 'us' | 'eu';
5
6
  }
6
7
  export interface AccessToken {
7
8
  token: string;
package/index.ts CHANGED
@@ -10,11 +10,13 @@ import {
10
10
  WebhooksApi,
11
11
  WorkoutsApi,
12
12
  ProfileApi,
13
+ DevicesAPI,
13
14
  } from './client';
14
15
  import { ClientConfig } from './lib/models';
15
16
  import CONFIG from './lib/config';
16
17
  import { ClientCredentials } from './lib/credentials';
17
18
  import { VitalsApi } from './client/Vitals';
19
+ import { ProviderApi } from './client/Provider';
18
20
 
19
21
  export class VitalClient {
20
22
  config: ClientConfig;
@@ -29,11 +31,18 @@ export class VitalClient {
29
31
  Vitals: VitalsApi;
30
32
  Testkits: TestkitsApi;
31
33
  Profile: ProfileApi;
34
+ Providers: ProviderApi;
35
+ Devices: DevicesAPI;
32
36
 
33
37
  constructor(config: ClientConfig) {
34
38
  this.config = config;
35
39
  this.clientCredentials = new ClientCredentials(config);
36
- const baseURL = CONFIG.baseUrls[config.environment];
40
+ let baseURL;
41
+ if (this.config.region && this.config.region === 'eu') {
42
+ baseURL = CONFIG.baseEUUrls[config.environment];
43
+ } else {
44
+ baseURL = CONFIG.baseUrls[config.environment];
45
+ }
37
46
  const axiosApiInstance = axios.create();
38
47
 
39
48
  axiosRetry(axiosApiInstance, {
@@ -67,5 +76,7 @@ export class VitalClient {
67
76
  this.Vitals = new VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
68
77
  this.Testkits = new TestkitsApi(baseURL.concat('/v2'), axiosApiInstance);
69
78
  this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
79
+ this.Providers = new ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
80
+ this.Devices = new DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
70
81
  }
71
82
  }
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ modulePathIgnorePatterns: ["__tests__/arrange.ts"]
6
+ };
package/lib/config.ts CHANGED
@@ -3,15 +3,24 @@ export default {
3
3
  production: 'https://api.tryvital.io',
4
4
  prod: 'https://api.tryvital.io',
5
5
  sandbox: 'https://api.sandbox.tryvital.io',
6
+ development: 'https://api.tryvital.io/v1',
6
7
  },
7
8
  domains: {
8
9
  production: 'auth.tryvital.io',
9
10
  prod: 'auth.tryvital.io',
10
11
  sandbox: 'auth.sandbox.tryvital.io',
12
+ development: 'dev-vital-api.us.auth0.com',
11
13
  },
12
14
  baseUrls: {
13
15
  prod: 'https://api.tryvital.io',
14
16
  production: 'https://api.tryvital.io',
15
17
  sandbox: 'https://api.sandbox.tryvital.io',
18
+ development: 'https://api.dev.tryvital.io',
19
+ },
20
+ baseEUUrls: {
21
+ prod: 'https://api.eu.tryvital.io',
22
+ production: 'https://api.eu.tryvital.io',
23
+ sandbox: 'https://api.sandbox.eu.tryvital.io',
24
+ development: 'https://api.dev.eu.tryvital.io',
16
25
  },
17
26
  };
package/lib/models.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export interface ClientConfig {
2
2
  client_id: string;
3
3
  client_secret: string;
4
- environment: 'prod' | 'production' | 'sandbox';
4
+ environment: 'prod' | 'production' | 'sandbox' | 'development';
5
+ region?: 'us' | 'eu';
5
6
  }
6
7
 
7
8
  export interface AccessToken {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [
@@ -17,6 +17,8 @@
17
17
  "prepublishOnly": "npm run build",
18
18
  "test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './test/**/*.ts'",
19
19
  "test-typescript": "tsc --build types/test",
20
+ "test-client": "jest --config jest.config.js",
21
+ "test-single": "jest --config -i __tests__/user.test.ts jest.config.js",
20
22
  "lint": "eslint --ext .js,.jsx,.ts ."
21
23
  },
22
24
  "dependencies": {
@@ -28,6 +30,7 @@
28
30
  },
29
31
  "devDependencies": {
30
32
  "@testdeck/mocha": "^0.1.2",
33
+ "@types/jest": "^27.4.1",
31
34
  "@types/mocha": "^9.0.0",
32
35
  "@types/node": "^16.6.1",
33
36
  "@typescript-eslint/eslint-plugin": "^4.29.1",
@@ -35,6 +38,7 @@
35
38
  "chai": "~4.2.0",
36
39
  "chai-as-promised": "~7.1.1",
37
40
  "coveralls": "^3.0.0",
41
+ "dotenv": "^16.0.0",
38
42
  "eslint": "^7.32.0",
39
43
  "eslint-config-airbnb-base": "^14.2.1",
40
44
  "eslint-config-prettier": "^4.3.0",
@@ -42,11 +46,13 @@
42
46
  "eslint-plugin-import": "^2.24.0",
43
47
  "eslint-plugin-prettier": "^3.4.0",
44
48
  "esm": "^3.2.25",
49
+ "jest": "^27.5.1",
45
50
  "mocha": "^9.2.0",
46
51
  "mocha-junit-reporter": "^2.0.2",
47
52
  "nock": "^13.1.1",
48
53
  "nyc": "^15.1.0",
49
54
  "prettier": "^2.3.2",
55
+ "ts-jest": "^27.1.3",
50
56
  "ts-node": "^10.2.0",
51
57
  "typescript": "^4.3.5"
52
58
  }
package/tsconfig.json CHANGED
@@ -6,9 +6,18 @@
6
6
  "noImplicitAny": true,
7
7
  "outDir": "dist",
8
8
  "rootDir": ".",
9
- "lib": ["es6", "dom"],
10
- "typeRoots": ["node_modules/@types"]
9
+ "skipLibCheck": true,
10
+ "lib": [
11
+ "es6",
12
+ "dom"
13
+ ],
14
+ "typeRoots": [
15
+ "node_modules/@types"
16
+ ]
11
17
  },
12
-
13
- "exclude": ["dist", "node_modules"]
14
- }
18
+ "exclude": [
19
+ "dist",
20
+ "node_modules/**",
21
+ "__tests__"
22
+ ]
23
+ }