whio-api-sdk 1.0.217-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.
- package/dist/src/sdk/modules/base-client.d.ts +1 -0
- package/dist/src/sdk/modules/base-client.js +21 -0
- package/dist/src/sdk/modules/reports.module.d.ts +15 -0
- package/dist/src/sdk/modules/reports.module.js +33 -0
- package/dist/src/sdk/sdk.d.ts +7 -0
- package/dist/src/sdk/sdk.js +13 -0
- package/dist/src/sdk/types/index.d.ts +1 -0
- package/dist/src/sdk/types/index.js +1 -0
- package/dist/src/sdk/types/reports.types.d.ts +8 -0
- package/dist/src/sdk/types/reports.types.js +2 -0
- package/dist/src/sdk/urls.d.ts +1 -0
- package/dist/src/sdk/urls.js +2 -0
- package/package.json +1 -1
- package/src/sdk/modules/base-client.ts +28 -0
- package/src/sdk/modules/reports.module.ts +22 -0
- package/src/sdk/sdk.ts +12 -0
- package/src/sdk/types/index.ts +1 -0
- package/src/sdk/types/reports.types.ts +11 -0
- package/src/sdk/urls.ts +3 -0
|
@@ -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>;
|
|
@@ -161,6 +161,27 @@ export class BaseClient {
|
|
|
161
161
|
return response.blob();
|
|
162
162
|
});
|
|
163
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
|
+
}
|
|
164
185
|
clearAuth() {
|
|
165
186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
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
|
+
}
|
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -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
|
}
|
package/dist/src/sdk/urls.d.ts
CHANGED
package/dist/src/sdk/urls.js
CHANGED
package/package.json
CHANGED
|
@@ -181,6 +181,34 @@ export class BaseClient {
|
|
|
181
181
|
return response.blob();
|
|
182
182
|
}
|
|
183
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
|
+
|
|
184
212
|
protected async clearAuth(): Promise<void> {
|
|
185
213
|
this.accessToken = null;
|
|
186
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
|
}
|
package/src/sdk/types/index.ts
CHANGED