@tryvital/vital-node 1.3.0 → 1.3.3

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.
@@ -1,57 +1,18 @@
1
- name: CI
1
+ name: Publish Package to npmjs
2
2
  on:
3
- push:
4
- branches:
5
- - "main"
3
+ release:
4
+ types: [published]
6
5
  jobs:
7
6
  build:
8
- name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
9
- runs-on: ${{ matrix.os }}
10
- strategy:
11
- matrix:
12
- node: ['10.x', '12.x', '14.x']
13
- os: [ubuntu-latest, windows-latest, macOS-latest]
14
-
15
- steps:
16
- - name: Checkout repo
17
- uses: actions/checkout@v2
18
-
19
- - name: Use Node ${{ matrix.node }}
20
- uses: actions/setup-node@v1
21
- with:
22
- node-version: ${{ matrix.node }}
23
-
24
- - name: Install deps and build (with cache)
25
- uses: bahmutov/npm-install@v1
26
-
27
- - name: Lint
28
- run: yarn lint
29
-
30
- - name: Build
31
- run: yarn build
32
- publish:
33
- needs: build
34
- name: Build, lint, and test on Node 10
35
7
  runs-on: ubuntu-latest
36
8
  steps:
37
- - name: Checkout repo
38
- uses: actions/checkout@v2
39
- - name: Use Node 10
40
- uses: actions/setup-node@v1
9
+ - uses: actions/checkout@v2
10
+ # Setup .npmrc file to publish to npm
11
+ - uses: actions/setup-node@v2
41
12
  with:
42
- node-version: 10
43
- - name: Install deps and build (with cache)
44
- uses: bahmutov/npm-install@v1
45
- - name: Build
46
- run: yarn build
47
- - name: 'Automated Version Bump'
48
- uses: 'phips28/gh-action-bump-version@master'
13
+ node-version: '16.x'
14
+ registry-url: 'https://registry.npmjs.org'
15
+ - run: npm ci
16
+ - run: npm publish
49
17
  env:
50
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51
- with:
52
- target-branch: 'main'
53
- - uses: JS-DevTools/npm-publish@v1
54
- with:
55
- token: ${{ secrets.NPM_TOKEN }}
56
- access: public
57
-
18
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
@@ -14,4 +14,18 @@ describe('Sleep', () => {
14
14
  )
15
15
  expect(data.sleep.length).toBeGreaterThan(0)
16
16
  });
17
+
18
+ it.each([
19
+ ["us", testClient],
20
+ ["eu", testEuClient]
21
+ ])('should return sleep data %p', async (region: string, client: VitalClient) => {
22
+ const userId = await getUserId(client)
23
+ const data = await client.Sleep.getSleepWithStream(
24
+ userId,
25
+ new Date("2021-01-01"),
26
+ new Date("2022-01-02"),
27
+ )
28
+ expect(data.sleep.length).toBeGreaterThan(0)
29
+ expect(data.sleep[0].sleep_stream).toBeDefined()
30
+ });
17
31
  })
@@ -13,7 +13,7 @@ export class ActivityApi {
13
13
  public async get(
14
14
  userId: string,
15
15
  startDate: Date,
16
- endDate: Date,
16
+ endDate?: Date,
17
17
  provider?: string
18
18
  ): Promise<ClientActivityResponse> {
19
19
  const resp = await this.client.get(
@@ -28,7 +28,7 @@ export class ActivityApi {
28
28
  public async get_raw(
29
29
  userId: string,
30
30
  startDate: Date,
31
- endDate: Date,
31
+ endDate?: Date,
32
32
  provider?: string
33
33
  ): Promise<ClientActivityRawResponse> {
34
34
  const resp = await this.client.get(
package/client/Body.ts CHANGED
@@ -14,7 +14,7 @@ export class BodyApi {
14
14
  public async get(
15
15
  userId: string,
16
16
  startDate: Date,
17
- endDate: Date,
17
+ endDate?: Date,
18
18
  provider?: string
19
19
  ): Promise<ClientBodyResponse> {
20
20
  const resp = await this.client.get(
@@ -29,7 +29,7 @@ export class BodyApi {
29
29
  public async get_raw(
30
30
  userId: string,
31
31
  startDate: Date,
32
- endDate: Date,
32
+ endDate?: Date,
33
33
  provider?: string
34
34
  ): Promise<ClientBodyRawResponse> {
35
35
  const resp = await this.client.get(
package/client/Link.ts CHANGED
@@ -18,11 +18,13 @@ export class LinkApi {
18
18
 
19
19
  public async create(
20
20
  userId: string,
21
- provider: string = null
21
+ provider: string = null,
22
+ redirect_url: string = null
22
23
  ): Promise<LinkTokenExchangeResponse> {
23
24
  const resp = await this.client.post(this.baseURL.concat('/link/token/'), {
24
25
  user_key: userId,
25
26
  provider,
27
+ redirect_url,
26
28
  });
27
29
  return resp.data;
28
30
  }
package/client/Sleep.ts CHANGED
@@ -16,11 +16,27 @@ export class SleepApi {
16
16
  public async get(
17
17
  userId: string,
18
18
  startDate: Date,
19
- endDate: Date,
20
- provider?: string
19
+ endDate?: Date,
20
+ provider?: string,
21
+ with_stream: boolean = false
21
22
  ): Promise<ClientSleepResponse> {
22
23
  const resp = await this.client.get(
23
24
  this.baseURL.concat(`/summary/sleep/${userId}`),
25
+ {
26
+ params: { start_date: startDate, end_date: endDate, provider, with_stream },
27
+ }
28
+ );
29
+ return resp.data;
30
+ }
31
+
32
+ public async getSleepWithStream(
33
+ userId: string,
34
+ startDate: Date,
35
+ endDate?: Date,
36
+ provider?: string
37
+ ): Promise<ClientSleepResponse> {
38
+ const resp = await this.client.get(
39
+ this.baseURL.concat(`/summary/sleep/${userId}/stream`),
24
40
  {
25
41
  params: { start_date: startDate, end_date: endDate, provider },
26
42
  }
@@ -38,7 +54,7 @@ export class SleepApi {
38
54
  public async get_raw(
39
55
  userId: string,
40
56
  startDate: Date,
41
- endDate: Date,
57
+ endDate?: Date,
42
58
  provider?: string
43
59
  ): Promise<ClientSleepRawResponse> {
44
60
  const resp = await this.client.get(
package/client/Vitals.ts CHANGED
@@ -13,7 +13,7 @@ export class VitalsApi {
13
13
  user_key: string,
14
14
  resource: string,
15
15
  startDate: Date,
16
- endDate: Date,
16
+ endDate?: Date,
17
17
  provider?: string
18
18
  ): Promise<TimeseriesPoint[]> {
19
19
  const resp = await this.client.get(
@@ -29,7 +29,7 @@ export class VitalsApi {
29
29
  type: 'ldl' | 'total' | 'triglycerides' | 'hdl',
30
30
  userId: string,
31
31
  startDate: Date,
32
- endDate: Date,
32
+ endDate?: Date,
33
33
  provider?: string
34
34
  ): Promise<TimeseriesPoint[]> {
35
35
  return this.timeseriesData(
@@ -44,7 +44,7 @@ export class VitalsApi {
44
44
  public async glucose(
45
45
  userId: string,
46
46
  startDate: Date,
47
- endDate: Date,
47
+ endDate?: Date,
48
48
  provider?: string
49
49
  ): Promise<TimeseriesPoint[]> {
50
50
  return this.timeseriesData(
@@ -59,7 +59,7 @@ export class VitalsApi {
59
59
  public async ige(
60
60
  userId: string,
61
61
  startDate: Date,
62
- endDate: Date,
62
+ endDate?: Date,
63
63
  provider?: string
64
64
  ): Promise<TimeseriesPoint[]> {
65
65
  return this.timeseriesData(userId, 'ige', startDate, endDate, provider);
@@ -68,7 +68,7 @@ export class VitalsApi {
68
68
  public async igg(
69
69
  userId: string,
70
70
  startDate: Date,
71
- endDate: Date,
71
+ endDate?: Date,
72
72
  provider?: string
73
73
  ): Promise<TimeseriesPoint[]> {
74
74
  return this.timeseriesData(userId, 'igg', startDate, endDate, provider);
@@ -77,7 +77,7 @@ export class VitalsApi {
77
77
  public async heartrate(
78
78
  userId: string,
79
79
  startDate: Date,
80
- endDate: Date,
80
+ endDate?: Date,
81
81
  provider?: string
82
82
  ): Promise<TimeseriesPoint[]> {
83
83
  return this.timeseriesData(
@@ -16,7 +16,7 @@ export class WorkoutsApi {
16
16
  public async get(
17
17
  userId: string,
18
18
  startDate: Date,
19
- endDate: Date,
19
+ endDate?: Date,
20
20
  provider?: string
21
21
  ): Promise<ClientWorkoutResponse> {
22
22
  const resp = await this.client.get(
@@ -40,7 +40,7 @@ export class WorkoutsApi {
40
40
  public async get_raw(
41
41
  userId: string,
42
42
  startDate: Date,
43
- endDate: Date,
43
+ endDate?: Date,
44
44
  provider?: string
45
45
  ): Promise<ClientWorkoutsRawResponse> {
46
46
  const resp = await this.client.get(
@@ -127,6 +127,13 @@ export interface ClientFacingSleep {
127
127
  * @memberof ClientFacingSleep
128
128
  */
129
129
  user_id: string;
130
+ /**
131
+ * UTC time when the sleep period started
132
+ * @type {ClientSleepStreamResponse}
133
+ * @memberof ClientFacingSleep
134
+ *
135
+ */
136
+ sleep_stream: ClientSleepStreamResponse[];
130
137
  }
131
138
 
132
139
  export interface ClientSleepResponse {
@@ -5,6 +5,6 @@ export declare class ActivityApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientActivityResponse>;
9
- get_raw(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientActivityRawResponse>;
8
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientActivityResponse>;
9
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientActivityRawResponse>;
10
10
  }
@@ -5,6 +5,6 @@ export declare class BodyApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientBodyResponse>;
9
- get_raw(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientBodyRawResponse>;
8
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientBodyResponse>;
9
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientBodyRawResponse>;
10
10
  }
@@ -5,7 +5,7 @@ export declare class LinkApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- create(userId: string, provider?: string): Promise<LinkTokenExchangeResponse>;
8
+ create(userId: string, provider?: string, redirect_url?: string): Promise<LinkTokenExchangeResponse>;
9
9
  connectProvider(linkToken: string, provider: PasswordProviders, username: string, password: string): Promise<ProviderLinkResponse>;
10
10
  connectEmailProvider(linkToken: string, provider: EmailProviders, email: string): Promise<ProviderLinkResponse>;
11
11
  getOAuthLink(linkToken: string, provider: OAuthProviders): Promise<SourceWithLinkInfo>;
@@ -42,8 +42,9 @@ var LinkApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- LinkApi.prototype.create = function (userId, provider) {
45
+ LinkApi.prototype.create = function (userId, provider, redirect_url) {
46
46
  if (provider === void 0) { provider = null; }
47
+ if (redirect_url === void 0) { redirect_url = null; }
47
48
  return __awaiter(this, void 0, void 0, function () {
48
49
  var resp;
49
50
  return __generator(this, function (_a) {
@@ -51,6 +52,7 @@ var LinkApi = /** @class */ (function () {
51
52
  case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/link/token/'), {
52
53
  user_key: userId,
53
54
  provider: provider,
55
+ redirect_url: redirect_url,
54
56
  })];
55
57
  case 1:
56
58
  resp = _a.sent();
@@ -5,7 +5,8 @@ export declare class SleepApi {
5
5
  baseURL: string;
6
6
  client: AxiosInstance;
7
7
  constructor(baseURL: string, axios: AxiosInstance);
8
- get(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientSleepResponse>;
8
+ get(userId: string, startDate: Date, endDate?: Date, provider?: string, with_stream?: boolean): Promise<ClientSleepResponse>;
9
+ getSleepWithStream(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientSleepResponse>;
9
10
  getStream(sleepId: string): Promise<ClientSleepStreamResponse>;
10
- get_raw(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientSleepRawResponse>;
11
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientSleepRawResponse>;
11
12
  }
@@ -42,12 +42,28 @@ var SleepApi = /** @class */ (function () {
42
42
  this.baseURL = baseURL;
43
43
  this.client = axios;
44
44
  }
45
- SleepApi.prototype.get = function (userId, startDate, endDate, provider) {
45
+ SleepApi.prototype.get = function (userId, startDate, endDate, provider, with_stream) {
46
+ if (with_stream === void 0) { with_stream = false; }
46
47
  return __awaiter(this, void 0, void 0, function () {
47
48
  var resp;
48
49
  return __generator(this, function (_a) {
49
50
  switch (_a.label) {
50
51
  case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId), {
52
+ params: { start_date: startDate, end_date: endDate, provider: provider, with_stream: with_stream },
53
+ })];
54
+ case 1:
55
+ resp = _a.sent();
56
+ return [2 /*return*/, resp.data];
57
+ }
58
+ });
59
+ });
60
+ };
61
+ SleepApi.prototype.getSleepWithStream = function (userId, startDate, endDate, provider) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var resp;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/sleep/" + userId + "/stream"), {
51
67
  params: { start_date: startDate, end_date: endDate, provider: provider },
52
68
  })];
53
69
  case 1:
@@ -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', 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[]>;
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
  }
@@ -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(userId: 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(userId: string, startDate: Date, endDate: Date, provider?: string): Promise<ClientWorkoutsRawResponse>;
10
+ get_raw(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientWorkoutsRawResponse>;
11
11
  }
@@ -126,6 +126,13 @@ export interface ClientFacingSleep {
126
126
  * @memberof ClientFacingSleep
127
127
  */
128
128
  user_id: string;
129
+ /**
130
+ * UTC time when the sleep period started
131
+ * @type {ClientSleepStreamResponse}
132
+ * @memberof ClientFacingSleep
133
+ *
134
+ */
135
+ sleep_stream: ClientSleepStreamResponse[];
129
136
  }
130
137
  export interface ClientSleepResponse {
131
138
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "1.3.0",
3
+ "version": "1.3.3",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [