skikrumb-api 2.1.15 → 2.1.17

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.
package/dist/index.d.ts CHANGED
@@ -62,7 +62,34 @@ export declare const skiKrumb: (options?: {
62
62
  error?: any;
63
63
  }>;
64
64
  getReplayData: (serialNumber: string, date: string, timezone?: string, size?: number) => Promise<any>;
65
+ getReplayFull: (serialNumber: string, date: string, timezone?: string, size?: number) => Promise<any>;
65
66
  getDailyStats: (serialNumber: string, date: string, timezone?: string) => Promise<any>;
67
+ getDeviceStats: (serialNumber: string, startDate: string, timezone?: string) => Promise<{
68
+ success: boolean;
69
+ data?: {
70
+ total_runs: number;
71
+ total_lifts: number;
72
+ completed_runs: number;
73
+ total_vertical: {
74
+ m: number;
75
+ ft: number;
76
+ };
77
+ total_distance: {
78
+ km: number;
79
+ miles: number;
80
+ m: number;
81
+ };
82
+ time_on_mountain_minutes: number;
83
+ } | undefined;
84
+ metadata?: {
85
+ serial_number: string;
86
+ startDate: string;
87
+ endDate: string;
88
+ timezone: string;
89
+ cached: boolean;
90
+ } | undefined;
91
+ error?: any;
92
+ }>;
66
93
  getActivityDates: (serialNumber: string, timezone?: string) => Promise<{
67
94
  success: boolean;
68
95
  dates?: string[] | undefined;
@@ -73,6 +100,7 @@ export declare const skiKrumb: (options?: {
73
100
  } | undefined;
74
101
  error?: any;
75
102
  }>;
103
+ getLeaderboardStats: (serialNumbers: string[], startDate: string, endDate: string, timezone?: string) => Promise<any>;
76
104
  getAccessibleProfiles: () => Promise<{
77
105
  success: boolean;
78
106
  accessibleProfiles: any[];
package/dist/index.js CHANGED
@@ -43,7 +43,9 @@ class SkiKrumbRealtimeClient {
43
43
  connectToWebSocket() {
44
44
  return new Promise((resolve, reject) => {
45
45
  try {
46
- const baseWsUrl = this.url.replace(/^https/, 'wss').replace(/^http/, 'ws');
46
+ const baseWsUrl = this.url
47
+ .replace(/^https/, 'wss')
48
+ .replace(/^http/, 'ws');
47
49
  let wsUrl;
48
50
  let endpointPath = `/realtime${this.endpointType === 'organization' ? '/organization' : ''}`;
49
51
  if (!this.supabaseToken) {
@@ -219,8 +221,7 @@ class SkiKrumbRealtimeClient {
219
221
  try {
220
222
  callback(data);
221
223
  }
222
- catch (error) {
223
- }
224
+ catch (error) { }
224
225
  });
225
226
  }
226
227
  isConnected() {
@@ -318,9 +319,7 @@ export const skiKrumb = (options = {
318
319
  .json();
319
320
  };
320
321
  const readOrganizationData = async () => {
321
- return requestWithTimeZone
322
- .get('devices/data/organization')
323
- .json();
322
+ return requestWithTimeZone.get('devices/data/organization').json();
324
323
  };
325
324
  const readGateways = async () => {
326
325
  try {
@@ -485,9 +484,28 @@ export const skiKrumb = (options = {
485
484
  .json();
486
485
  return response;
487
486
  };
487
+ const getReplayFull = async (serialNumber, date, timezone = 'America/Vancouver', size = 10000) => {
488
+ const requestWithAuth = ky.create({
489
+ prefixUrl: options.url,
490
+ timeout: 60000,
491
+ headers: {
492
+ 'Content-Type': 'application/json',
493
+ Authorization: `Bearer ${options.apiKey}`,
494
+ 'supabase-auth-token': options.supabaseToken || '',
495
+ 'x-client': options.requestedWith,
496
+ },
497
+ });
498
+ const response = await requestWithAuth
499
+ .get(`data/replay-full/${serialNumber}`, {
500
+ searchParams: { date, timezone, size },
501
+ })
502
+ .json();
503
+ return response;
504
+ };
488
505
  const getDailyStats = async (serialNumber, date, timezone = 'America/Vancouver') => {
489
506
  const requestWithAuth = ky.create({
490
507
  prefixUrl: options.url,
508
+ timeout: 60000,
491
509
  headers: {
492
510
  'Content-Type': 'application/json',
493
511
  Authorization: `Bearer ${options.apiKey}`,
@@ -502,9 +520,29 @@ export const skiKrumb = (options = {
502
520
  .json();
503
521
  return response;
504
522
  };
523
+ const getDeviceStats = async (serialNumber, startDate, timezone = 'America/Vancouver') => {
524
+ const requestWithAuth = ky.create({
525
+ prefixUrl: options.url,
526
+ timeout: 60000,
527
+ headers: {
528
+ 'Content-Type': 'application/json',
529
+ Authorization: `Bearer ${options.apiKey}`,
530
+ 'supabase-auth-token': options.supabaseToken || '',
531
+ 'x-client': options.requestedWith,
532
+ TimeZone: timezone,
533
+ },
534
+ });
535
+ const response = await requestWithAuth
536
+ .get(`stats/device/${serialNumber}`, {
537
+ searchParams: { startDate },
538
+ })
539
+ .json();
540
+ return response;
541
+ };
505
542
  const getActivityDates = async (serialNumber, timezone = 'America/Vancouver') => {
506
543
  const requestWithAuth = ky.create({
507
544
  prefixUrl: options.url,
545
+ timeout: 60000,
508
546
  headers: {
509
547
  'Content-Type': 'application/json',
510
548
  Authorization: `Bearer ${options.apiKey}`,
@@ -519,6 +557,29 @@ export const skiKrumb = (options = {
519
557
  .json();
520
558
  return response;
521
559
  };
560
+ const getLeaderboardStats = async (serialNumbers, startDate, endDate, timezone = 'America/Vancouver') => {
561
+ const requestWithAuth = ky.create({
562
+ prefixUrl: options.url,
563
+ timeout: 60000,
564
+ headers: {
565
+ 'Content-Type': 'application/json',
566
+ Authorization: `Bearer ${options.apiKey}`,
567
+ 'supabase-auth-token': options.supabaseToken || '',
568
+ 'x-client': options.requestedWith,
569
+ TimeZone: timezone,
570
+ },
571
+ });
572
+ const response = await requestWithAuth
573
+ .get('stats/leaderboard', {
574
+ searchParams: {
575
+ serials: serialNumbers.join(','),
576
+ startDate,
577
+ endDate,
578
+ },
579
+ })
580
+ .json();
581
+ return response;
582
+ };
522
583
  const getAccessibleProfiles = async () => {
523
584
  const requestWithAuth = ky.create({
524
585
  prefixUrl: options.url,
@@ -612,8 +673,11 @@ export const skiKrumb = (options = {
612
673
  deleteFamilyShare,
613
674
  updateFamilyShare,
614
675
  getReplayData,
676
+ getReplayFull,
615
677
  getDailyStats,
678
+ getDeviceStats,
616
679
  getActivityDates,
680
+ getLeaderboardStats,
617
681
  getAccessibleProfiles,
618
682
  getLatestDeviceData,
619
683
  createRealtimeClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skikrumb-api",
3
- "version": "2.1.15",
3
+ "version": "2.1.17",
4
4
  "description": "Wrapper for the skiKrumb API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",