whio-api-sdk 1.0.216-beta-staging → 1.0.218-beta-staging

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.
@@ -15,6 +15,7 @@ export declare class BaseClient {
15
15
  protected request<T>(endpoint: string, method?: string, body?: any, headers?: Record<string, string>, noToken?: boolean): Promise<T>;
16
16
  protected fileUploadRequest<T>(endpoint: string, body?: FormData, headers?: Record<string, string>, onProgress?: (percentage: number) => void): Promise<T>;
17
17
  protected downloadRequest(endpoint: string): Promise<Blob>;
18
+ protected textRequest(endpoint: string): Promise<string>;
18
19
  protected clearAuth(): Promise<void>;
19
20
  protected isTokenExpired(token: string, bufferMinutes?: number): boolean;
20
21
  protected refreshAccessToken(): Promise<void>;
@@ -97,10 +97,13 @@ export class BaseClient {
97
97
  return new Promise((resolve, reject) => {
98
98
  const xhr = new XMLHttpRequest();
99
99
  console.log('Uploading file to:', url);
100
+ console.log('onProgress callback provided:', !!onProgress);
101
+ console.log('FormData has file:', body && body.has && body.has('file'));
100
102
  xhr.upload.addEventListener('progress', (event) => {
101
- console.log('Upload progress:', event);
103
+ console.log('Upload progress event fired:', event.loaded, '/', event.total, 'lengthComputable:', event.lengthComputable);
102
104
  if (event.lengthComputable && onProgress) {
103
105
  const percentage = Math.round((event.loaded / event.total) * 100);
106
+ console.log('Calling onProgress with percentage:', percentage);
104
107
  onProgress(percentage);
105
108
  }
106
109
  });
@@ -158,6 +161,27 @@ export class BaseClient {
158
161
  return response.blob();
159
162
  });
160
163
  }
164
+ textRequest(endpoint) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ const url = `${this.baseUrl}${endpoint}`;
167
+ yield this.getToken();
168
+ const defaultHeaders = {
169
+ 'ngrok-skip-browser-warning': 'true'
170
+ };
171
+ if (this.accessToken) {
172
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
173
+ }
174
+ const response = yield fetch(url, {
175
+ method: 'GET',
176
+ headers: defaultHeaders,
177
+ });
178
+ if (!response.ok) {
179
+ const errorData = yield response.json().catch(() => ({}));
180
+ throw new Error(errorData.message || `Text request failed with status ${response.status}`);
181
+ }
182
+ return response.text();
183
+ });
184
+ }
161
185
  clearAuth() {
162
186
  return __awaiter(this, void 0, void 0, function* () {
163
187
  this.accessToken = null;
@@ -0,0 +1,15 @@
1
+ import { BaseClient } from './base-client';
2
+ export declare class ReportsModule extends BaseClient {
3
+ /**
4
+ * Get company daily report as CSV
5
+ * @param companyId - The organization/company ID to generate the report for
6
+ * @returns Promise<string> - CSV content with daily user counts and session counts
7
+ */
8
+ getCompanyDailyReportCsv(companyId: string): Promise<string>;
9
+ /**
10
+ * Download company daily report as CSV file
11
+ * @param companyId - The organization/company ID to generate the report for
12
+ * @returns Promise<Blob> - CSV file as blob for download
13
+ */
14
+ downloadCompanyDailyReport(companyId: string): Promise<Blob>;
15
+ }
@@ -0,0 +1,33 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { BaseClient } from './base-client';
11
+ import urls from '../urls';
12
+ export class ReportsModule extends BaseClient {
13
+ /**
14
+ * Get company daily report as CSV
15
+ * @param companyId - The organization/company ID to generate the report for
16
+ * @returns Promise<string> - CSV content with daily user counts and session counts
17
+ */
18
+ getCompanyDailyReportCsv(companyId) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return this.textRequest(`${urls.reports}/company-daily?companyId=${companyId}`);
21
+ });
22
+ }
23
+ /**
24
+ * Download company daily report as CSV file
25
+ * @param companyId - The organization/company ID to generate the report for
26
+ * @returns Promise<Blob> - CSV file as blob for download
27
+ */
28
+ downloadCompanyDailyReport(companyId) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this.downloadRequest(`${urls.reports}/company-daily?companyId=${companyId}`);
31
+ });
32
+ }
33
+ }
@@ -14,6 +14,7 @@ import { LogModule } from './modules/log.module';
14
14
  import { DebugModule } from './modules/debug.module';
15
15
  import { ExternalIntegrationModule } from './modules/external-integration.module';
16
16
  import { WebSocketModule } from './modules/websocket.module';
17
+ import { ReportsModule } from './modules/reports.module';
17
18
  /**
18
19
  * Main SDK class that provides access to all domain-specific modules
19
20
  */
@@ -32,6 +33,7 @@ export declare class ApiSDK extends BaseClient {
32
33
  readonly debug: DebugModule;
33
34
  readonly externalIntegrations: ExternalIntegrationModule;
34
35
  readonly websocket: WebSocketModule;
36
+ readonly reports: ReportsModule;
35
37
  constructor(config?: SDKConfig);
36
38
  login(...args: Parameters<AuthModule['login']>): Promise<import("./types").LoginResponse>;
37
39
  logout(...args: Parameters<AuthModule['logout']>): Promise<void>;
@@ -39,6 +41,9 @@ export declare class ApiSDK extends BaseClient {
39
41
  changePassword(...args: Parameters<AuthModule['changePassword']>): Promise<import("./types").PasswordChangeResponse>;
40
42
  adminChangePassword(...args: Parameters<AuthModule['adminChangePassword']>): Promise<import("./types").PasswordChangeResponse>;
41
43
  requestLoginCode(...args: Parameters<AuthModule['requestLoginCode']>): Promise<{
44
+ /**
45
+ * Main SDK class that provides access to all domain-specific modules
46
+ */
42
47
  message: string;
43
48
  }>;
44
49
  loginWithCode(...args: Parameters<AuthModule['loginWithCode']>): Promise<import("./types").LoginResponse>;
@@ -197,4 +202,6 @@ export declare class ApiSDK extends BaseClient {
197
202
  getWebSocketStats(): import("./types").WebSocketConnectionStats;
198
203
  subscribe(...args: Parameters<WebSocketModule['on']>): void;
199
204
  unsubscribe(...args: Parameters<WebSocketModule['off']>): void;
205
+ getCompanyDailyReportCsv(...args: Parameters<ReportsModule['getCompanyDailyReportCsv']>): Promise<string>;
206
+ downloadCompanyDailyReport(...args: Parameters<ReportsModule['downloadCompanyDailyReport']>): Promise<Blob>;
200
207
  }
@@ -22,6 +22,7 @@ import { LogModule } from './modules/log.module';
22
22
  import { DebugModule } from './modules/debug.module';
23
23
  import { ExternalIntegrationModule } from './modules/external-integration.module';
24
24
  import { WebSocketModule } from './modules/websocket.module';
25
+ import { ReportsModule } from './modules/reports.module';
25
26
  /**
26
27
  * Main SDK class that provides access to all domain-specific modules
27
28
  */
@@ -43,6 +44,7 @@ export class ApiSDK extends BaseClient {
43
44
  this.debug = new DebugModule(config);
44
45
  this.externalIntegrations = new ExternalIntegrationModule(config);
45
46
  this.websocket = new WebSocketModule(config);
47
+ this.reports = new ReportsModule(config);
46
48
  }
47
49
  // ======================
48
50
  // BACKWARD COMPATIBILITY LAYER
@@ -806,4 +808,15 @@ export class ApiSDK extends BaseClient {
806
808
  unsubscribe(...args) {
807
809
  return this.websocket.off(...args);
808
810
  }
811
+ // Reports methods
812
+ getCompanyDailyReportCsv(...args) {
813
+ return __awaiter(this, void 0, void 0, function* () {
814
+ return this.reports.getCompanyDailyReportCsv(...args);
815
+ });
816
+ }
817
+ downloadCompanyDailyReport(...args) {
818
+ return __awaiter(this, void 0, void 0, function* () {
819
+ return this.reports.downloadCompanyDailyReport(...args);
820
+ });
821
+ }
809
822
  }
@@ -11,3 +11,4 @@ export * from './workflow.types';
11
11
  export * from './log.types';
12
12
  export * from './external-integration.types';
13
13
  export * from './websocket.types';
14
+ export * from './reports.types';
@@ -12,3 +12,4 @@ export * from './workflow.types';
12
12
  export * from './log.types';
13
13
  export * from './external-integration.types';
14
14
  export * from './websocket.types';
15
+ export * from './reports.types';
@@ -0,0 +1,8 @@
1
+ export interface CompanyDailyReportRequest {
2
+ companyId: string;
3
+ }
4
+ export interface CompanyDailyReportRow {
5
+ date: string;
6
+ total_users: number;
7
+ total_sessions: number;
8
+ }
@@ -0,0 +1,2 @@
1
+ // Reports module types
2
+ export {};
@@ -32,5 +32,6 @@ declare const urls: {
32
32
  logs: string;
33
33
  debug: string;
34
34
  externalIntegrations: string;
35
+ reports: string;
35
36
  };
36
37
  export default urls;
@@ -47,5 +47,7 @@ const urls = {
47
47
  debug: '/debug',
48
48
  // External Integrations
49
49
  externalIntegrations: '/external-integrations',
50
+ // Reports
51
+ reports: '/reports',
50
52
  };
51
53
  export default urls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.216-beta-staging",
3
+ "version": "1.0.218-beta-staging",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -107,10 +107,14 @@ export class BaseClient {
107
107
  return new Promise((resolve, reject) => {
108
108
  const xhr = new XMLHttpRequest();
109
109
  console.log('Uploading file to:', url);
110
+ console.log('onProgress callback provided:', !!onProgress);
111
+ console.log('FormData has file:', body && body.has && body.has('file'));
112
+
110
113
  xhr.upload.addEventListener('progress', (event) => {
111
- console.log('Upload progress:', event);
114
+ console.log('Upload progress event fired:', event.loaded, '/', event.total, 'lengthComputable:', event.lengthComputable);
112
115
  if (event.lengthComputable && onProgress) {
113
116
  const percentage = Math.round((event.loaded / event.total) * 100);
117
+ console.log('Calling onProgress with percentage:', percentage);
114
118
  onProgress(percentage);
115
119
  }
116
120
  });
@@ -177,6 +181,34 @@ export class BaseClient {
177
181
  return response.blob();
178
182
  }
179
183
 
184
+ protected async textRequest(endpoint: string): Promise<string> {
185
+ const url = `${this.baseUrl}${endpoint}`;
186
+
187
+ await this.getToken();
188
+
189
+ const defaultHeaders: Record<string, string> = {
190
+ 'ngrok-skip-browser-warning': 'true'
191
+ };
192
+
193
+ if (this.accessToken) {
194
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
195
+ }
196
+
197
+ const response = await fetch(url, {
198
+ method: 'GET',
199
+ headers: defaultHeaders,
200
+ });
201
+
202
+ if (!response.ok) {
203
+ const errorData = await response.json().catch(() => ({}));
204
+ throw new Error(
205
+ errorData.message || `Text request failed with status ${response.status}`
206
+ );
207
+ }
208
+
209
+ return response.text();
210
+ }
211
+
180
212
  protected async clearAuth(): Promise<void> {
181
213
  this.accessToken = null;
182
214
  this.refreshToken = null;
@@ -0,0 +1,22 @@
1
+ import { BaseClient } from './base-client';
2
+ import urls from '../urls';
3
+
4
+ export class ReportsModule extends BaseClient {
5
+ /**
6
+ * Get company daily report as CSV
7
+ * @param companyId - The organization/company ID to generate the report for
8
+ * @returns Promise<string> - CSV content with daily user counts and session counts
9
+ */
10
+ public async getCompanyDailyReportCsv(companyId: string): Promise<string> {
11
+ return this.textRequest(`${urls.reports}/company-daily?companyId=${companyId}`);
12
+ }
13
+
14
+ /**
15
+ * Download company daily report as CSV file
16
+ * @param companyId - The organization/company ID to generate the report for
17
+ * @returns Promise<Blob> - CSV file as blob for download
18
+ */
19
+ public async downloadCompanyDailyReport(companyId: string): Promise<Blob> {
20
+ return this.downloadRequest(`${urls.reports}/company-daily?companyId=${companyId}`);
21
+ }
22
+ }
package/src/sdk/sdk.ts CHANGED
@@ -15,6 +15,7 @@ import { LogModule } from './modules/log.module';
15
15
  import { DebugModule } from './modules/debug.module';
16
16
  import { ExternalIntegrationModule } from './modules/external-integration.module';
17
17
  import { WebSocketModule } from './modules/websocket.module';
18
+ import { ReportsModule } from './modules/reports.module';
18
19
 
19
20
  /**
20
21
  * Main SDK class that provides access to all domain-specific modules
@@ -34,6 +35,7 @@ export class ApiSDK extends BaseClient {
34
35
  public readonly debug: DebugModule;
35
36
  public readonly externalIntegrations: ExternalIntegrationModule;
36
37
  public readonly websocket: WebSocketModule;
38
+ public readonly reports: ReportsModule;
37
39
 
38
40
  constructor(config: SDKConfig = {}) {
39
41
  super(config);
@@ -53,6 +55,7 @@ export class ApiSDK extends BaseClient {
53
55
  this.debug = new DebugModule(config);
54
56
  this.externalIntegrations = new ExternalIntegrationModule(config);
55
57
  this.websocket = new WebSocketModule(config);
58
+ this.reports = new ReportsModule(config);
56
59
  }
57
60
 
58
61
  // ======================
@@ -685,4 +688,13 @@ export class ApiSDK extends BaseClient {
685
688
  return this.websocket.off(...args);
686
689
  }
687
690
 
691
+ // Reports methods
692
+ public async getCompanyDailyReportCsv(...args: Parameters<ReportsModule['getCompanyDailyReportCsv']>) {
693
+ return this.reports.getCompanyDailyReportCsv(...args);
694
+ }
695
+
696
+ public async downloadCompanyDailyReport(...args: Parameters<ReportsModule['downloadCompanyDailyReport']>) {
697
+ return this.reports.downloadCompanyDailyReport(...args);
698
+ }
699
+
688
700
  }
@@ -12,3 +12,4 @@ export * from './workflow.types';
12
12
  export * from './log.types';
13
13
  export * from './external-integration.types';
14
14
  export * from './websocket.types';
15
+ export * from './reports.types';
@@ -0,0 +1,11 @@
1
+ // Reports module types
2
+
3
+ export interface CompanyDailyReportRequest {
4
+ companyId: string;
5
+ }
6
+
7
+ export interface CompanyDailyReportRow {
8
+ date: string;
9
+ total_users: number;
10
+ total_sessions: number;
11
+ }
package/src/sdk/urls.ts CHANGED
@@ -61,6 +61,9 @@ const urls = {
61
61
 
62
62
  // External Integrations
63
63
  externalIntegrations: '/external-integrations',
64
+
65
+ // Reports
66
+ reports: '/reports',
64
67
  }
65
68
 
66
69
  export default urls;