@tryvital/vital-node 2.1.0 → 2.1.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.
@@ -0,0 +1,15 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { LabResultsMetadata, LabResultsRaw, Order, OrderRequestResponse, OrderResponse, PatientAdress, PatientDetails, TestkitResponse } from './models/testkit_models';
3
+ export declare class TestkitsApi {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ get(): Promise<TestkitResponse>;
8
+ get_orders(startDate: Date, endDate: Date, status?: string[], userId?: string, patientName?: string, page?: number, size?: number): Promise<OrderResponse>;
9
+ order(userId: string, testkitId: string, patientAddress: PatientAdress, patientDetails: PatientDetails): Promise<OrderRequestResponse>;
10
+ get_order(orderId: string): Promise<Order>;
11
+ cancel_order(orderId: string): Promise<OrderRequestResponse>;
12
+ get_results(orderId: string): Promise<string>;
13
+ getMetadata(orderId: string): Promise<LabResultsMetadata>;
14
+ getRawResults(orderId: string): Promise<LabResultsRaw>;
15
+ }
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.TestkitsApi = void 0;
51
+ var TestkitsApi = /** @class */ (function () {
52
+ function TestkitsApi(baseURL, axios) {
53
+ this.baseURL = baseURL;
54
+ this.client = axios;
55
+ }
56
+ TestkitsApi.prototype.get = function () {
57
+ return __awaiter(this, void 0, void 0, function () {
58
+ var resp;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/testkit'))];
62
+ case 1:
63
+ resp = _a.sent();
64
+ return [2 /*return*/, resp.data];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ TestkitsApi.prototype.get_orders = function (startDate, endDate, status, userId, patientName, page, size) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var resp;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/testkit/orders'), {
75
+ params: __assign(__assign({ start_date: startDate, end_date: endDate, status: status ? status : null, user_id: userId ? userId : null, patient_name: patientName ? patientName : null }, (page && { page: page })), (size && { size: size })),
76
+ })];
77
+ case 1:
78
+ resp = _a.sent();
79
+ return [2 /*return*/, resp.data];
80
+ }
81
+ });
82
+ });
83
+ };
84
+ TestkitsApi.prototype.order = function (userId, testkitId, patientAddress, patientDetails) {
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var resp;
87
+ return __generator(this, function (_a) {
88
+ switch (_a.label) {
89
+ case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/testkit/orders'), {
90
+ user_key: userId,
91
+ testkit_id: testkitId,
92
+ patient_address: patientAddress,
93
+ patient_details: patientDetails,
94
+ })];
95
+ case 1:
96
+ resp = _a.sent();
97
+ return [2 /*return*/, resp.data];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ TestkitsApi.prototype.get_order = function (orderId) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var resp;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId))];
108
+ case 1:
109
+ resp = _a.sent();
110
+ return [2 /*return*/, resp.data];
111
+ }
112
+ });
113
+ });
114
+ };
115
+ TestkitsApi.prototype.cancel_order = function (orderId) {
116
+ return __awaiter(this, void 0, void 0, function () {
117
+ var resp;
118
+ return __generator(this, function (_a) {
119
+ switch (_a.label) {
120
+ case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat("/testkit/orders/" + orderId + "/cancel"))];
121
+ case 1:
122
+ resp = _a.sent();
123
+ return [2 /*return*/, resp.data];
124
+ }
125
+ });
126
+ });
127
+ };
128
+ TestkitsApi.prototype.get_results = function (orderId) {
129
+ return __awaiter(this, void 0, void 0, function () {
130
+ var resp;
131
+ return __generator(this, function (_a) {
132
+ switch (_a.label) {
133
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results"), {
134
+ responseType: 'arraybuffer',
135
+ })];
136
+ case 1:
137
+ resp = _a.sent();
138
+ return [2 /*return*/, resp.data];
139
+ }
140
+ });
141
+ });
142
+ };
143
+ TestkitsApi.prototype.getMetadata = function (orderId) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var resp;
146
+ return __generator(this, function (_a) {
147
+ switch (_a.label) {
148
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/metadata"))];
149
+ case 1:
150
+ resp = _a.sent();
151
+ return [2 /*return*/, resp.data];
152
+ }
153
+ });
154
+ });
155
+ };
156
+ TestkitsApi.prototype.getRawResults = function (orderId) {
157
+ return __awaiter(this, void 0, void 0, function () {
158
+ var resp;
159
+ return __generator(this, function (_a) {
160
+ switch (_a.label) {
161
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/raw"))];
162
+ case 1:
163
+ resp = _a.sent();
164
+ return [2 /*return*/, resp.data];
165
+ }
166
+ });
167
+ });
168
+ };
169
+ return TestkitsApi;
170
+ }());
171
+ exports.TestkitsApi = TestkitsApi;
@@ -9,3 +9,4 @@ export { LabTestsApi } from './LabTests';
9
9
  export { ProfileApi } from './Profile';
10
10
  export { DevicesAPI } from './Devices';
11
11
  export { MealsApi } from './Meals';
12
+ export { TestkitsApi } from "./Testkits";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.LabTestsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
3
+ exports.TestkitsApi = exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.LabTestsApi = 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");
@@ -23,3 +23,5 @@ var Devices_1 = require("./Devices");
23
23
  Object.defineProperty(exports, "DevicesAPI", { enumerable: true, get: function () { return Devices_1.DevicesAPI; } });
24
24
  var Meals_1 = require("./Meals");
25
25
  Object.defineProperty(exports, "MealsApi", { enumerable: true, get: function () { return Meals_1.MealsApi; } });
26
+ var Testkits_1 = require("./Testkits");
27
+ Object.defineProperty(exports, "TestkitsApi", { enumerable: true, get: function () { return Testkits_1.TestkitsApi; } });
@@ -0,0 +1,102 @@
1
+ export interface PatientAdress {
2
+ receiver_name: string;
3
+ city: string;
4
+ state: string;
5
+ zip: string;
6
+ country: string;
7
+ street_number?: string;
8
+ }
9
+ export interface PatientDetails {
10
+ dob: string;
11
+ gender: string;
12
+ email?: string;
13
+ first_name: string;
14
+ phone_number: string;
15
+ last_name: string;
16
+ }
17
+ export interface Physician {
18
+ first_name: string;
19
+ last_name: string;
20
+ npi: string;
21
+ email?: string;
22
+ licensed_states?: string[];
23
+ created_at?: string;
24
+ updated_at?: string;
25
+ }
26
+ export interface Marker {
27
+ name: string;
28
+ slug: string;
29
+ description?: string;
30
+ }
31
+ export interface Testkit {
32
+ id: string;
33
+ name: string;
34
+ description: string;
35
+ markers: Marker[];
36
+ turnaround_time_lower: number;
37
+ turnaround_time_upper: number;
38
+ price: number;
39
+ }
40
+ export interface TestkitEvent {
41
+ id: number;
42
+ created_at: string;
43
+ status: string;
44
+ }
45
+ export interface Order {
46
+ user_id: string;
47
+ id: string;
48
+ team_id: string;
49
+ patient_details: PatientDetails;
50
+ patient_address: PatientAdress;
51
+ lab_test: Testkit;
52
+ details: Object;
53
+ created_at: string;
54
+ updated_at: string;
55
+ events: TestkitEvent;
56
+ user_key?: string;
57
+ sample_id?: string;
58
+ notes?: string;
59
+ 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' | 'rejected' | 'lost';
60
+ }
61
+ export interface OrderRequestResponse {
62
+ order: Order;
63
+ status: string;
64
+ message: string;
65
+ }
66
+ export interface LabClientFacing {
67
+ slug: string;
68
+ name: string;
69
+ first_line_address: string;
70
+ city: string;
71
+ zipcode: string;
72
+ }
73
+ export interface ClientFacingLabTest {
74
+ id: string;
75
+ slug: string;
76
+ name: string;
77
+ sample_type: string;
78
+ method: string;
79
+ price: number;
80
+ is_active: boolean;
81
+ lab: LabClientFacing;
82
+ markers: Marker;
83
+ }
84
+ export interface TestkitResponse {
85
+ testkits: Testkit[];
86
+ }
87
+ export interface LabResultsMetadata {
88
+ age: string;
89
+ dob: string;
90
+ patient: string;
91
+ date_reported: string;
92
+ date_collected: string;
93
+ specimen_number: string;
94
+ clia?: string;
95
+ provider?: string;
96
+ laboratory?: string;
97
+ date_received?: string;
98
+ }
99
+ export interface LabResultsResponse {
100
+ metadata: LabResultsMetadata;
101
+ results: Object;
102
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,26 +1,16 @@
1
1
  export interface PatientAdress {
2
2
  receiver_name: string;
3
- street: string;
3
+ first_line: string;
4
+ second_line?: string;
4
5
  city: string;
5
6
  state: string;
6
7
  zip: string;
7
8
  country: string;
8
9
  phone_number: string;
9
- street_number?: string;
10
10
  }
11
11
  export interface PatientDetails {
12
12
  dob: string;
13
13
  gender: string;
14
- email: string;
15
- }
16
- export interface Physician {
17
- first_name: string;
18
- last_name: string;
19
- npi: string;
20
- email?: string;
21
- licensed_states?: string[];
22
- created_at?: string;
23
- updated_at?: string;
24
14
  }
25
15
  export interface Marker {
26
16
  name: string;
@@ -36,66 +26,54 @@ export interface Testkit {
36
26
  turnaround_time_upper: number;
37
27
  price: number;
38
28
  }
39
- export interface TestkitEvent {
40
- id: number;
41
- created_at: string;
42
- status: string;
43
- }
44
29
  export interface Order {
45
- user_id: string;
46
30
  id: string;
47
31
  team_id: string;
32
+ created_on: Date;
33
+ updated_on: Date;
48
34
  patient_details: PatientDetails;
49
35
  patient_address: PatientAdress;
50
- lab_test: Testkit;
51
- details: Object;
52
36
  created_at: string;
53
37
  updated_at: string;
54
- events: TestkitEvent;
55
- user_key?: string;
56
38
  sample_id?: string;
57
39
  notes?: string;
58
- 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' | "rejected" | "lost";
40
+ 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' | "rejected" | "lost";
41
+ user_key: string;
42
+ testkit_id: string;
43
+ testkit: Testkit;
44
+ inbound_tracking_number?: string;
45
+ outbound_tracking_number?: string;
46
+ outbound_courier?: string;
47
+ inbound_courier?: string;
48
+ }
49
+ export interface OrderResponse {
50
+ orders: Order[];
51
+ total: number;
52
+ page: number;
53
+ size: number;
59
54
  }
60
55
  export interface OrderRequestResponse {
61
56
  order: Order;
62
57
  status: string;
63
58
  message: string;
64
59
  }
65
- export interface LabClientFacing {
66
- slug: string;
67
- name: string;
68
- first_line_address: string;
69
- city: string;
70
- zipcode: string;
71
- }
72
- export interface ClientFacingLabTest {
73
- id: string;
74
- slug: string;
75
- name: string;
76
- sample_type: string;
77
- method: string;
78
- price: number;
79
- is_active: boolean;
80
- lab: LabClientFacing;
81
- markers: Marker;
82
- }
83
60
  export interface TestkitResponse {
84
61
  testkits: Testkit[];
85
62
  }
86
63
  export interface LabResultsMetadata {
87
64
  age: string;
88
65
  dob: string;
66
+ clia_number: string;
89
67
  patient: string;
68
+ provider: string;
69
+ laboratory: string;
90
70
  date_reported: string;
91
71
  date_collected: string;
92
72
  specimen_number: string;
93
- clia?: string;
94
- provider?: string;
95
- laboratory?: string;
96
73
  date_received?: string;
74
+ clia?: string;
97
75
  }
98
- export interface LabResultsResponse {
76
+ export interface LabResultsRaw {
99
77
  metadata: LabResultsMetadata;
100
- results: Object;
78
+ results: Record<string, string>;
101
79
  }
package/dist/index.d.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi } from './client';
1
+ import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi, LabTestsApi } from './client';
2
2
  import { ClientConfig } from './lib/models';
3
- import { ClientCredentials } from './lib/credentials';
4
3
  import { VitalsApi } from './client/Vitals';
5
4
  import { ProviderApi } from './client/Provider';
6
- import { LabTestsApi } from './client/LabTests';
7
5
  export declare class VitalClient {
8
6
  config: ClientConfig;
9
- clientCredentials: ClientCredentials;
10
7
  Activity: ActivityApi;
11
8
  Link: LinkApi;
12
9
  Body: BodyApi;
package/dist/index.js CHANGED
@@ -52,21 +52,14 @@ var axios_1 = require("axios");
52
52
  var axios_retry_1 = require("axios-retry");
53
53
  var client_1 = require("./client");
54
54
  var config_1 = require("./lib/config");
55
- var credentials_1 = require("./lib/credentials");
56
55
  var Vitals_1 = require("./client/Vitals");
57
56
  var Provider_1 = require("./client/Provider");
58
- var LabTests_1 = require("./client/LabTests");
59
57
  var VitalClient = /** @class */ (function () {
60
58
  function VitalClient(config) {
61
59
  var _this = this;
62
60
  this.config = config;
63
61
  if (!config.api_key) {
64
- try {
65
- this.clientCredentials = new credentials_1.ClientCredentials(config);
66
- }
67
- catch (error) {
68
- throw new Error("You must provide either an API key or a client ID and secret");
69
- }
62
+ throw new Error("You must provide an API key");
70
63
  }
71
64
  var baseURL;
72
65
  if (this.config.region && this.config.region === 'eu') {
@@ -81,24 +74,12 @@ var VitalClient = /** @class */ (function () {
81
74
  retryDelay: axios_retry_1.default.exponentialDelay,
82
75
  });
83
76
  axiosApiInstance.interceptors.request.use(function (config) { return __awaiter(_this, void 0, void 0, function () {
84
- var headers, token;
77
+ var headers;
85
78
  return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0:
88
- headers = config.headers;
89
- if (!this.config.api_key) return [3 /*break*/, 1];
90
- headers["x-vital-api-key"] = this.config.api_key;
91
- return [3 /*break*/, 3];
92
- case 1: return [4 /*yield*/, this.clientCredentials.access_token()];
93
- case 2:
94
- token = _a.sent();
95
- headers["Authorization"] = "Bearer " + token;
96
- headers["x-vital-client-id"] = this.config.client_id;
97
- _a.label = 3;
98
- case 3:
99
- config.headers = __assign({}, headers);
100
- return [2 /*return*/, config];
101
- }
79
+ headers = config.headers;
80
+ headers["x-vital-api-key"] = this.config.api_key;
81
+ config.headers = __assign({}, headers);
82
+ return [2 /*return*/, config];
102
83
  });
103
84
  }); }, function (error) {
104
85
  Promise.reject(error);
@@ -112,7 +93,7 @@ var VitalClient = /** @class */ (function () {
112
93
  this.Workouts = new client_1.WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
113
94
  this.Webhooks = new client_1.WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
114
95
  this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
115
- this.LabTests = new LabTests_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
96
+ this.LabTests = new client_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
116
97
  this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
117
98
  this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
118
99
  this.Devices = new client_1.DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
package/index.ts CHANGED
@@ -10,18 +10,16 @@ import {
10
10
  WorkoutsApi,
11
11
  ProfileApi,
12
12
  DevicesAPI,
13
- MealsApi
13
+ MealsApi,
14
+ LabTestsApi
14
15
  } from './client';
15
16
  import { ClientConfig } from './lib/models';
16
17
  import CONFIG from './lib/config';
17
- import { ClientCredentials } from './lib/credentials';
18
18
  import { VitalsApi } from './client/Vitals';
19
19
  import { ProviderApi } from './client/Provider';
20
- import { LabTestsApi } from './client/LabTests';
21
20
 
22
21
  export class VitalClient {
23
22
  config: ClientConfig;
24
- clientCredentials: ClientCredentials;
25
23
  Activity: ActivityApi;
26
24
  Link: LinkApi;
27
25
  Body: BodyApi;
@@ -39,11 +37,7 @@ export class VitalClient {
39
37
  constructor(config: ClientConfig) {
40
38
  this.config = config;
41
39
  if(!config.api_key){
42
- try {
43
- this.clientCredentials = new ClientCredentials(config);
44
- } catch (error) {
45
- throw new Error("You must provide either an API key or a client ID and secret");
46
- }
40
+ throw new Error("You must provide an API key");
47
41
  }
48
42
  let baseURL;
49
43
  if (this.config.region && this.config.region === 'eu') {
@@ -61,13 +55,7 @@ export class VitalClient {
61
55
  axiosApiInstance.interceptors.request.use(
62
56
  async (config) => {
63
57
  const headers = config.headers;
64
- if(this.config.api_key){
65
- headers["x-vital-api-key"] = this.config.api_key;
66
- } else {
67
- const token = await this.clientCredentials.access_token();
68
- headers["Authorization"] = `Bearer ${token}`;
69
- headers["x-vital-client-id"] = this.config.client_id;
70
- }
58
+ headers["x-vital-api-key"] = this.config.api_key;
71
59
  config.headers = {
72
60
  ...headers,
73
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [
@@ -15,14 +15,13 @@
15
15
  "scripts": {
16
16
  "build": "tsc --outDir dist/",
17
17
  "prepublishOnly": "npm run build",
18
- "test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './test/**/*.ts'",
18
+ "test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register './__tests__/**/*.ts'",
19
19
  "test-typescript": "tsc --build types/test",
20
20
  "test-client": "jest --config jest.config.js",
21
21
  "test-single": "jest --config -i __tests__/user.test.ts jest.config.js",
22
22
  "lint": "eslint --ext .js,.jsx,.ts ."
23
23
  },
24
24
  "dependencies": {
25
- "auth0": "^2.35.1",
26
25
  "axios": ">=0.21.2 <1.0.0",
27
26
  "axios-retry": "^3.2.4",
28
27
  "crypto": "^1.0.1",
@@ -1,16 +0,0 @@
1
- import { VitalClient } from "..";
2
- import { testClient, testEuClient, getUserId, testApiKeyClient } from "./arrange";
3
-
4
- describe('Devices', () => {
5
- it.each([
6
- ["us", testClient],
7
- ["eu", testEuClient],
8
- ["us_api_key", testApiKeyClient],
9
- ])('should return device data %p', async (region: string, client: VitalClient) => {
10
- const userId = await getUserId(client)
11
- const data = await client.Devices.get_raw(
12
- userId,
13
- )
14
- expect(data.devices.length).toBeGreaterThan(0)
15
- });
16
- })
@@ -1,8 +0,0 @@
1
- import { AccessToken, ClientConfig } from './models';
2
- export declare class ClientCredentials {
3
- config: ClientConfig;
4
- private accessToken;
5
- constructor(config: ClientConfig);
6
- getAccessToken: () => Promise<AccessToken>;
7
- access_token: () => Promise<string>;
8
- }