@tryvital/vital-node 1.1.0 → 1.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,17 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { Provider } from './models/provider_models';
3
+
4
+ export class ProviderApi {
5
+ baseURL: string;
6
+ client: AxiosInstance;
7
+
8
+ constructor(baseURL: string, axios: AxiosInstance) {
9
+ this.baseURL = baseURL;
10
+ this.client = axios;
11
+ }
12
+
13
+ public async getSupportedProviders(): Promise<Provider[]> {
14
+ const resp = await this.client.get(this.baseURL.concat(`/providers/`));
15
+ return resp.data;
16
+ }
17
+ }
@@ -1,5 +1,7 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  import {
3
+ LabResultsMetadata,
4
+ LabResultsRaw,
3
5
  Order,
4
6
  OrderRequestResponse,
5
7
  OrderResponse,
@@ -68,4 +70,18 @@ export class TestkitsApi {
68
70
  );
69
71
  return resp.data;
70
72
  }
73
+
74
+ public async getMetadata(orderId: string): Promise<LabResultsMetadata> {
75
+ const resp = await this.client.get(
76
+ this.baseURL.concat(`/testkit/orders/${orderId}/results/metadata`)
77
+ );
78
+ return resp.data;
79
+ }
80
+
81
+ public async getRawResults(orderId: string): Promise<LabResultsRaw> {
82
+ const resp = await this.client.get(
83
+ this.baseURL.concat(`/testkit/orders/${orderId}/results/raw`)
84
+ );
85
+ return resp.data;
86
+ }
71
87
  }
@@ -0,0 +1,19 @@
1
+ export 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
+
13
+ export interface Provider {
14
+ name: string;
15
+ slug: string;
16
+ logo: string;
17
+ auth_type: 'password' | 'email' | 'oauth';
18
+ supported_resources: Resource[];
19
+ }
@@ -68,3 +68,22 @@ export interface OrderRequestResponse {
68
68
  export interface TestkitResponse {
69
69
  testkits: Testkit[];
70
70
  }
71
+
72
+ export interface LabResultsMetadata {
73
+ age: string;
74
+ dob: string;
75
+ clia_number: string;
76
+ patient: string;
77
+ provider: string;
78
+ laboratory: string;
79
+ date_reported: string;
80
+ date_collected: string;
81
+ specimen_number: string;
82
+ date_received?: string;
83
+ clia?: string;
84
+ }
85
+
86
+ export interface LabResultsRaw {
87
+ metadata: LabResultsMetadata;
88
+ data: Record<string, string>;
89
+ }
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { Provider } from './models/provider_models';
3
+ export declare class ProviderApi {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ getSupportedProviders(): Promise<Provider[]>;
8
+ }
@@ -0,0 +1,60 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ProviderApi = void 0;
40
+ var ProviderApi = /** @class */ (function () {
41
+ function ProviderApi(baseURL, axios) {
42
+ this.baseURL = baseURL;
43
+ this.client = axios;
44
+ }
45
+ ProviderApi.prototype.getSupportedProviders = function () {
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var resp;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/providers/"))];
51
+ case 1:
52
+ resp = _a.sent();
53
+ return [2 /*return*/, resp.data];
54
+ }
55
+ });
56
+ });
57
+ };
58
+ return ProviderApi;
59
+ }());
60
+ exports.ProviderApi = ProviderApi;
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Order, OrderRequestResponse, OrderResponse, PatientAdress, PatientDetails, TestkitResponse } from './models/testkit_models';
2
+ import { LabResultsMetadata, LabResultsRaw, Order, OrderRequestResponse, OrderResponse, PatientAdress, PatientDetails, TestkitResponse } from './models/testkit_models';
3
3
  export declare class TestkitsApi {
4
4
  baseURL: string;
5
5
  client: AxiosInstance;
@@ -9,4 +9,6 @@ export declare class TestkitsApi {
9
9
  order(userKey: string, testkitId: string, patientAddress: PatientAdress, patientDetails: PatientDetails): Promise<OrderRequestResponse>;
10
10
  get_order(orderId: string): Promise<Order>;
11
11
  get_results(orderId: string): Promise<string>;
12
+ getMetadata(orderId: string): Promise<LabResultsMetadata>;
13
+ getRawResults(orderId: string): Promise<LabResultsRaw>;
12
14
  }
@@ -116,6 +116,32 @@ var TestkitsApi = /** @class */ (function () {
116
116
  });
117
117
  });
118
118
  };
119
+ TestkitsApi.prototype.getMetadata = function (orderId) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ var resp;
122
+ return __generator(this, function (_a) {
123
+ switch (_a.label) {
124
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/metadata"))];
125
+ case 1:
126
+ resp = _a.sent();
127
+ return [2 /*return*/, resp.data];
128
+ }
129
+ });
130
+ });
131
+ };
132
+ TestkitsApi.prototype.getRawResults = function (orderId) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ var resp;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/raw"))];
138
+ case 1:
139
+ resp = _a.sent();
140
+ return [2 /*return*/, resp.data];
141
+ }
142
+ });
143
+ });
144
+ };
119
145
  return TestkitsApi;
120
146
  }());
121
147
  exports.TestkitsApi = TestkitsApi;
@@ -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 = {}));
@@ -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
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, Webhooks
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,6 @@ export declare class VitalClient {
15
16
  Vitals: VitalsApi;
16
17
  Testkits: TestkitsApi;
17
18
  Profile: ProfileApi;
19
+ Providers: ProviderApi;
18
20
  constructor(config: ClientConfig);
19
21
  }
package/dist/index.js CHANGED
@@ -54,6 +54,7 @@ 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;
@@ -90,6 +91,7 @@ var VitalClient = /** @class */ (function () {
90
91
  this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
91
92
  this.Testkits = new client_1.TestkitsApi(baseURL.concat('/v2'), axiosApiInstance);
92
93
  this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
94
+ this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
93
95
  }
94
96
  return VitalClient;
95
97
  }());
package/index.ts CHANGED
@@ -15,6 +15,7 @@ import { ClientConfig } from './lib/models';
15
15
  import CONFIG from './lib/config';
16
16
  import { ClientCredentials } from './lib/credentials';
17
17
  import { VitalsApi } from './client/Vitals';
18
+ import { ProviderApi } from './client/Provider';
18
19
 
19
20
  export class VitalClient {
20
21
  config: ClientConfig;
@@ -29,6 +30,7 @@ export class VitalClient {
29
30
  Vitals: VitalsApi;
30
31
  Testkits: TestkitsApi;
31
32
  Profile: ProfileApi;
33
+ Providers: ProviderApi;
32
34
 
33
35
  constructor(config: ClientConfig) {
34
36
  this.config = config;
@@ -67,5 +69,6 @@ export class VitalClient {
67
69
  this.Vitals = new VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
68
70
  this.Testkits = new TestkitsApi(baseURL.concat('/v2'), axiosApiInstance);
69
71
  this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
72
+ this.Providers = new ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
70
73
  }
71
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [