whio-api-sdk 1.0.191-bet-staging → 1.0.192-bet-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.
@@ -0,0 +1,155 @@
1
+ # Debug Functionality in Whio SDK
2
+
3
+ The Whio SDK now includes debug functionality to help with troubleshooting and data extraction for sessions that may have issues with medical transcriptions.
4
+
5
+ ## New Debug Methods
6
+
7
+ ### 1. `getSessionsWithoutMedicalTranscriptions()`
8
+
9
+ Returns a list of sessions for the user's organization that do not have medical transcriptions AND do not have primary transcription summaries.
10
+
11
+ **Usage:**
12
+ ```typescript
13
+ const problematicSessions = await sdk.getSessionsWithoutMedicalTranscriptions();
14
+ ```
15
+
16
+ **Returns:**
17
+ ```typescript
18
+ DebugSessionSummary[] // Array of session summaries
19
+ ```
20
+
21
+ **DebugSessionSummary Type:**
22
+ ```typescript
23
+ interface DebugSessionSummary {
24
+ id: string;
25
+ sessionName?: string;
26
+ dateTime: string;
27
+ createdAt: string;
28
+ user: {
29
+ id: string;
30
+ email: string;
31
+ firstName?: string;
32
+ lastName?: string;
33
+ organizationId?: string;
34
+ };
35
+ template?: {
36
+ id: string;
37
+ title: string;
38
+ };
39
+ hasMedicalTranscription: boolean;
40
+ hasPrimaryTranscriptionSummary: boolean;
41
+ }
42
+ ```
43
+
44
+ ### 2. `downloadSessionAsZip(sessionId: string)`
45
+
46
+ Downloads a complete session as a ZIP file containing all related data (fully decrypted).
47
+
48
+ **Usage:**
49
+ ```typescript
50
+ const zipBlob = await sdk.downloadSessionAsZip('session-id-here');
51
+ ```
52
+
53
+ **Returns:**
54
+ ```typescript
55
+ Promise<Blob> // ZIP file as a Blob object
56
+ ```
57
+
58
+ **ZIP Contents:**
59
+ - `session.json` - Complete session data with all linked objects (decrypted)
60
+ - `audio/` - Folder containing decrypted audio files with original names
61
+ - `base64_audio/` - Folder containing base64 audio files as JSON
62
+
63
+ ### 3. `downloadSessionAsZipUrl(sessionId: string)`
64
+
65
+ Downloads a session as a ZIP file and creates a download URL.
66
+
67
+ **Usage:**
68
+ ```typescript
69
+ const downloadUrl = await sdk.downloadSessionAsZipUrl('session-id-here');
70
+ // Use the URL for download links, etc.
71
+ // Remember to clean up: URL.revokeObjectURL(downloadUrl);
72
+ ```
73
+
74
+ **Returns:**
75
+ ```typescript
76
+ Promise<string> // URL string for the ZIP file
77
+ ```
78
+
79
+ ### 4. `downloadSessionAndTriggerDownload(sessionId: string, filename?: string)`
80
+
81
+ Downloads a session as a ZIP file and automatically triggers browser download.
82
+
83
+ **Usage:**
84
+ ```typescript
85
+ await sdk.downloadSessionAndTriggerDownload('session-id-here', 'my-session.zip');
86
+ ```
87
+
88
+ **Parameters:**
89
+ - `sessionId: string` - The ID of the session to download
90
+ - `filename?: string` - Optional custom filename (defaults to `session_{id}_{date}.zip`)
91
+
92
+ ## Example Usage
93
+
94
+ ```typescript
95
+ import { ApiSDK } from 'whio-api-sdk';
96
+
97
+ const sdk = new ApiSDK({
98
+ baseUrl: 'https://your-api-url.com/api',
99
+ storage: {
100
+ getItem: (key) => localStorage.getItem(key),
101
+ setItem: (key, value) => localStorage.setItem(key, value),
102
+ removeItem: (key) => localStorage.removeItem(key),
103
+ }
104
+ });
105
+
106
+ // Login first
107
+ await sdk.login({ email: 'user@example.com', password: 'password' });
108
+
109
+ // Get problematic sessions
110
+ const sessions = await sdk.getSessionsWithoutMedicalTranscriptions();
111
+ console.log(`Found ${sessions.length} sessions without medical transcriptions`);
112
+
113
+ // Download the first session
114
+ if (sessions.length > 0) {
115
+ const sessionId = sessions[0].id;
116
+ await sdk.downloadSessionAndTriggerDownload(sessionId);
117
+ }
118
+ ```
119
+
120
+ ## Error Handling
121
+
122
+ All debug methods use standard SDK error handling. Wrap calls in try-catch blocks:
123
+
124
+ ```typescript
125
+ try {
126
+ const sessions = await sdk.getSessionsWithoutMedicalTranscriptions();
127
+ // Handle success
128
+ } catch (error) {
129
+ console.error('Debug operation failed:', error.message);
130
+ // Handle error
131
+ }
132
+ ```
133
+
134
+ ## Security Notes
135
+
136
+ - All debug endpoints require authentication (Bearer token)
137
+ - Users can only access data from their own organization
138
+ - All data is decrypted before being included in ZIP downloads
139
+ - ZIP files contain complete session data including transcripts, audio files, and summaries
140
+
141
+ ## Use Cases
142
+
143
+ 1. **Troubleshooting**: Identify sessions that may have failed processing
144
+ 2. **Data Export**: Export complete session data for analysis or backup
145
+ 3. **Quality Assurance**: Review sessions that don't have expected transcriptions
146
+ 4. **Migration**: Extract data for migration to other systems
147
+
148
+ ## API Endpoints
149
+
150
+ The debug functionality calls these API endpoints:
151
+
152
+ - `GET /debug/sessions/missing-medical-transcriptions` - List problematic sessions
153
+ - `GET /debug/sessions/{id}/download` - Download session as ZIP
154
+
155
+ These endpoints are automatically handled by the SDK methods.
@@ -0,0 +1,112 @@
1
+ // debug-example.ts
2
+ // Example usage of the new debug functionality in the Whio SDK
3
+
4
+ import { ApiSDK, DebugSessionSummary } from './src/sdk';
5
+
6
+ // Example function to demonstrate debug functionality
7
+ async function demonstrateDebugFeatures() {
8
+ // Initialize SDK with your config
9
+ const sdk = new ApiSDK({
10
+ baseUrl: 'https://your-api-url.com/api', // Replace with your API URL
11
+ storage: {
12
+ getItem: (key) => localStorage.getItem(key),
13
+ setItem: (key, value) => localStorage.setItem(key, value),
14
+ removeItem: (key) => localStorage.removeItem(key),
15
+ }
16
+ });
17
+
18
+ try {
19
+ // First, login to get authentication
20
+ await sdk.login({
21
+ email: 'your-email@example.com',
22
+ password: 'your-password'
23
+ });
24
+
25
+ console.log('Logged in successfully!');
26
+
27
+ // === DEBUG FUNCTIONALITY ===
28
+
29
+ // 1. Get sessions that don't have medical transcriptions and primary transcription summaries
30
+ console.log('Fetching sessions without medical transcriptions...');
31
+ const sessionsWithoutMedicalTranscriptions: DebugSessionSummary[] =
32
+ await sdk.getSessionsWithoutMedicalTranscriptions();
33
+
34
+ console.log(`Found ${sessionsWithoutMedicalTranscriptions.length} sessions without medical transcriptions:`);
35
+
36
+ sessionsWithoutMedicalTranscriptions.forEach((session, index) => {
37
+ console.log(`${index + 1}. Session ID: ${session.id}`);
38
+ console.log(` Name: ${session.sessionName || 'Unnamed'}`);
39
+ console.log(` User: ${session.user.firstName} ${session.user.lastName} (${session.user.email})`);
40
+ console.log(` Created: ${new Date(session.createdAt).toLocaleDateString()}`);
41
+ console.log(` Template: ${session.template?.title || 'No template'}`);
42
+ console.log(` Has Medical Transcription: ${session.hasMedicalTranscription}`);
43
+ console.log(` Has Primary Summary: ${session.hasPrimaryTranscriptionSummary}`);
44
+ console.log(' ---');
45
+ });
46
+
47
+ // 2. Download a specific session as ZIP (if sessions exist)
48
+ if (sessionsWithoutMedicalTranscriptions.length > 0) {
49
+ const sessionId = sessionsWithoutMedicalTranscriptions[0].id;
50
+ console.log(`Downloading session ${sessionId} as ZIP...`);
51
+
52
+ // Method 1: Get blob for manual handling
53
+ const zipBlob = await sdk.downloadSessionAsZip(sessionId);
54
+ console.log(`Downloaded ZIP blob, size: ${zipBlob.size} bytes`);
55
+
56
+ // Method 2: Get URL for download link
57
+ const downloadUrl = await sdk.downloadSessionAsZipUrl(sessionId);
58
+ console.log(`Created download URL: ${downloadUrl}`);
59
+
60
+ // Method 3: Trigger automatic download in browser
61
+ // await sdk.downloadSessionAndTriggerDownload(sessionId, 'my-session-data.zip');
62
+ console.log('ZIP download would trigger automatically in browser');
63
+
64
+ // Clean up the URL when done
65
+ URL.revokeObjectURL(downloadUrl);
66
+ } else {
67
+ console.log('No sessions found to download');
68
+ }
69
+
70
+ } catch (error) {
71
+ console.error('Error during debug operations:', error);
72
+ }
73
+ }
74
+
75
+ // Example of how to use in a React component or web application
76
+ export const DebugComponent = {
77
+ // Function to list sessions without medical transcriptions
78
+ async listProblematicSessions(sdk: ApiSDK): Promise<DebugSessionSummary[]> {
79
+ try {
80
+ return await sdk.getSessionsWithoutMedicalTranscriptions();
81
+ } catch (error) {
82
+ console.error('Failed to fetch problematic sessions:', error);
83
+ throw error;
84
+ }
85
+ },
86
+
87
+ // Function to download session with user feedback
88
+ async downloadSessionWithProgress(sdk: ApiSDK, sessionId: string, onProgress?: (message: string) => void): Promise<void> {
89
+ try {
90
+ onProgress?.('Starting download...');
91
+
92
+ const blob = await sdk.downloadSessionAsZip(sessionId);
93
+
94
+ onProgress?.('Download complete, preparing file...');
95
+
96
+ // Create filename with timestamp
97
+ const timestamp = new Date().toISOString().split('T')[0];
98
+ const filename = `session_${sessionId}_${timestamp}.zip`;
99
+
100
+ // Trigger download
101
+ await sdk.downloadSessionAndTriggerDownload(sessionId, filename);
102
+
103
+ onProgress?.('Download triggered successfully!');
104
+ } catch (error) {
105
+ onProgress?.(`Download failed: ${error.message}`);
106
+ throw error;
107
+ }
108
+ }
109
+ };
110
+
111
+ // Export for use in other modules
112
+ export { demonstrateDebugFeatures };
@@ -1,4 +1,4 @@
1
- import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto, AgentSettings, CreateAgentSettingsDto, UpdateAgentSettingsDto, Workflow, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse, Log, LogsResponse, LogStats, FilterLogsDto, CreateLogDto } from './types';
1
+ import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto, AgentSettings, CreateAgentSettingsDto, UpdateAgentSettingsDto, Workflow, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse, Log, LogsResponse, LogStats, FilterLogsDto, CreateLogDto, DebugSessionSummary } from './types';
2
2
  export declare class ApiSDK {
3
3
  private baseUrl;
4
4
  private storage;
@@ -194,4 +194,24 @@ export declare class ApiSDK {
194
194
  organizationRoles: string[];
195
195
  teamRoles: string[];
196
196
  }>;
197
+ /**
198
+ * Get sessions that do not have medical transcriptions and primary transcription summaries
199
+ * for the current user's organization
200
+ */
201
+ getSessionsWithoutMedicalTranscriptions(): Promise<DebugSessionSummary[]>;
202
+ /**
203
+ * Download a session as a ZIP file containing all related data (decrypted)
204
+ * Returns a Blob that can be used to create a download link
205
+ */
206
+ downloadSessionAsZip(sessionId: string): Promise<Blob>;
207
+ /**
208
+ * Download a session as a ZIP file and create a download URL
209
+ * Returns a URL that can be used for direct download
210
+ */
211
+ downloadSessionAsZipUrl(sessionId: string): Promise<string>;
212
+ /**
213
+ * Download a session as a ZIP file and trigger browser download
214
+ * Optionally provide a custom filename
215
+ */
216
+ downloadSessionAndTriggerDownload(sessionId: string, filename?: string): Promise<void>;
197
217
  }
@@ -1154,4 +1154,69 @@ export class ApiSDK {
1154
1154
  return this.request(`${urls.logs}/available-roles`, 'GET');
1155
1155
  });
1156
1156
  }
1157
+ // ===== DEBUG METHODS =====
1158
+ /**
1159
+ * Get sessions that do not have medical transcriptions and primary transcription summaries
1160
+ * for the current user's organization
1161
+ */
1162
+ getSessionsWithoutMedicalTranscriptions() {
1163
+ return __awaiter(this, void 0, void 0, function* () {
1164
+ return this.request(`${urls.debug}/sessions/missing-medical-transcriptions`, 'GET');
1165
+ });
1166
+ }
1167
+ /**
1168
+ * Download a session as a ZIP file containing all related data (decrypted)
1169
+ * Returns a Blob that can be used to create a download link
1170
+ */
1171
+ downloadSessionAsZip(sessionId) {
1172
+ return __awaiter(this, void 0, void 0, function* () {
1173
+ const url = `${this.baseUrl}${urls.debug}/sessions/${sessionId}/download`;
1174
+ // Get token first
1175
+ yield this.getToken();
1176
+ const defaultHeaders = {
1177
+ 'ngrok-skip-browser-warning': 'true'
1178
+ };
1179
+ if (this.accessToken) {
1180
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
1181
+ }
1182
+ const response = yield fetch(url, {
1183
+ method: 'GET',
1184
+ headers: defaultHeaders,
1185
+ });
1186
+ if (!response.ok) {
1187
+ const errorData = yield response.json().catch(() => ({}));
1188
+ throw new Error(errorData.message || `Download failed with status ${response.status}`);
1189
+ }
1190
+ return response.blob();
1191
+ });
1192
+ }
1193
+ /**
1194
+ * Download a session as a ZIP file and create a download URL
1195
+ * Returns a URL that can be used for direct download
1196
+ */
1197
+ downloadSessionAsZipUrl(sessionId) {
1198
+ return __awaiter(this, void 0, void 0, function* () {
1199
+ const blob = yield this.downloadSessionAsZip(sessionId);
1200
+ return URL.createObjectURL(blob);
1201
+ });
1202
+ }
1203
+ /**
1204
+ * Download a session as a ZIP file and trigger browser download
1205
+ * Optionally provide a custom filename
1206
+ */
1207
+ downloadSessionAndTriggerDownload(sessionId, filename) {
1208
+ return __awaiter(this, void 0, void 0, function* () {
1209
+ const blob = yield this.downloadSessionAsZip(sessionId);
1210
+ const url = URL.createObjectURL(blob);
1211
+ // Create temporary download link and click it
1212
+ const link = document.createElement('a');
1213
+ link.href = url;
1214
+ link.download = filename || `session_${sessionId}_${new Date().toISOString().split('T')[0]}.zip`;
1215
+ document.body.appendChild(link);
1216
+ link.click();
1217
+ document.body.removeChild(link);
1218
+ // Clean up the URL object
1219
+ URL.revokeObjectURL(url);
1220
+ });
1221
+ }
1157
1222
  }
@@ -496,3 +496,22 @@ export interface CreateLogDto {
496
496
  data?: any;
497
497
  additionalMeta?: Record<string, any>;
498
498
  }
499
+ export interface DebugSessionSummary {
500
+ id: string;
501
+ sessionName?: string;
502
+ dateTime: string;
503
+ createdAt: string;
504
+ user: {
505
+ id: string;
506
+ email: string;
507
+ firstName?: string;
508
+ lastName?: string;
509
+ organizationId?: string;
510
+ };
511
+ template?: {
512
+ id: string;
513
+ title: string;
514
+ };
515
+ hasMedicalTranscription: boolean;
516
+ hasPrimaryTranscriptionSummary: boolean;
517
+ }
@@ -30,5 +30,6 @@ declare const urls: {
30
30
  audioFiles: string;
31
31
  workflows: string;
32
32
  logs: string;
33
+ debug: string;
33
34
  };
34
35
  export default urls;
@@ -43,5 +43,7 @@ const urls = {
43
43
  workflows: '/workflows',
44
44
  // Logs
45
45
  logs: '/logs',
46
+ // Debug
47
+ debug: '/debug',
46
48
  };
47
49
  export default urls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.191-bet-staging",
3
+ "version": "1.0.192-bet-staging",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/src/sdk/sdk.ts CHANGED
@@ -60,6 +60,7 @@ import {
60
60
  LogStats,
61
61
  FilterLogsDto,
62
62
  CreateLogDto,
63
+ DebugSessionSummary,
63
64
  } from './types';
64
65
  import urls from './urls';
65
66
  import { jwtDecode } from 'jwt-decode';
@@ -1221,4 +1222,76 @@ export class ApiSDK {
1221
1222
  }>(`${urls.logs}/available-roles`, 'GET');
1222
1223
  }
1223
1224
 
1225
+ // ===== DEBUG METHODS =====
1226
+
1227
+ /**
1228
+ * Get sessions that do not have medical transcriptions and primary transcription summaries
1229
+ * for the current user's organization
1230
+ */
1231
+ public async getSessionsWithoutMedicalTranscriptions(): Promise<DebugSessionSummary[]> {
1232
+ return this.request<DebugSessionSummary[]>(`${urls.debug}/sessions/missing-medical-transcriptions`, 'GET');
1233
+ }
1234
+
1235
+ /**
1236
+ * Download a session as a ZIP file containing all related data (decrypted)
1237
+ * Returns a Blob that can be used to create a download link
1238
+ */
1239
+ public async downloadSessionAsZip(sessionId: string): Promise<Blob> {
1240
+ const url = `${this.baseUrl}${urls.debug}/sessions/${sessionId}/download`;
1241
+
1242
+ // Get token first
1243
+ await this.getToken();
1244
+
1245
+ const defaultHeaders: Record<string, string> = {
1246
+ 'ngrok-skip-browser-warning': 'true'
1247
+ };
1248
+
1249
+ if (this.accessToken) {
1250
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
1251
+ }
1252
+
1253
+ const response = await fetch(url, {
1254
+ method: 'GET',
1255
+ headers: defaultHeaders,
1256
+ });
1257
+
1258
+ if (!response.ok) {
1259
+ const errorData = await response.json().catch(() => ({}));
1260
+ throw new Error(
1261
+ errorData.message || `Download failed with status ${response.status}`
1262
+ );
1263
+ }
1264
+
1265
+ return response.blob();
1266
+ }
1267
+
1268
+ /**
1269
+ * Download a session as a ZIP file and create a download URL
1270
+ * Returns a URL that can be used for direct download
1271
+ */
1272
+ public async downloadSessionAsZipUrl(sessionId: string): Promise<string> {
1273
+ const blob = await this.downloadSessionAsZip(sessionId);
1274
+ return URL.createObjectURL(blob);
1275
+ }
1276
+
1277
+ /**
1278
+ * Download a session as a ZIP file and trigger browser download
1279
+ * Optionally provide a custom filename
1280
+ */
1281
+ public async downloadSessionAndTriggerDownload(sessionId: string, filename?: string): Promise<void> {
1282
+ const blob = await this.downloadSessionAsZip(sessionId);
1283
+ const url = URL.createObjectURL(blob);
1284
+
1285
+ // Create temporary download link and click it
1286
+ const link = document.createElement('a');
1287
+ link.href = url;
1288
+ link.download = filename || `session_${sessionId}_${new Date().toISOString().split('T')[0]}.zip`;
1289
+ document.body.appendChild(link);
1290
+ link.click();
1291
+ document.body.removeChild(link);
1292
+
1293
+ // Clean up the URL object
1294
+ URL.revokeObjectURL(url);
1295
+ }
1296
+
1224
1297
  }
package/src/sdk/types.ts CHANGED
@@ -626,3 +626,24 @@ export interface CreateLogDto {
626
626
  data?: any;
627
627
  additionalMeta?: Record<string, any>;
628
628
  }
629
+
630
+ // Debug types
631
+ export interface DebugSessionSummary {
632
+ id: string;
633
+ sessionName?: string;
634
+ dateTime: string;
635
+ createdAt: string;
636
+ user: {
637
+ id: string;
638
+ email: string;
639
+ firstName?: string;
640
+ lastName?: string;
641
+ organizationId?: string;
642
+ };
643
+ template?: {
644
+ id: string;
645
+ title: string;
646
+ };
647
+ hasMedicalTranscription: boolean;
648
+ hasPrimaryTranscriptionSummary: boolean;
649
+ }
package/src/sdk/urls.ts CHANGED
@@ -55,6 +55,9 @@ const urls = {
55
55
 
56
56
  // Logs
57
57
  logs: '/logs',
58
+
59
+ // Debug
60
+ debug: '/debug',
58
61
  }
59
62
 
60
63
  export default urls;