whio-api-sdk 1.0.203-beta-staging → 1.0.205-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/template.module.d.ts +1 -9
- package/dist/src/sdk/modules/template.module.js +0 -60
- package/dist/src/sdk/modules/transcription-summary.module.d.ts +13 -0
- package/dist/src/sdk/modules/transcription-summary.module.js +81 -0
- package/dist/src/sdk/modules/websocket.module.d.ts +6 -1
- package/dist/src/sdk/modules/websocket.module.js +42 -10
- package/dist/src/sdk/sdk.d.ts +12 -9
- package/dist/src/sdk/sdk.js +15 -8
- package/dist/src/sdk/types/template.types.d.ts +3 -0
- package/package.json +1 -1
- package/src/sdk/modules/template.module.ts +0 -63
- package/src/sdk/modules/transcription-summary.module.ts +78 -0
- package/src/sdk/modules/websocket.module.ts +39 -5
- package/src/sdk/sdk.ts +23 -16
- package/src/sdk/types/template.types.ts +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from './base-client';
|
|
2
|
-
import { Template, TemplateCategory, UserTemplate,
|
|
2
|
+
import { Template, TemplateCategory, UserTemplate, TranscriptionAudioUploadResponse } from '../types';
|
|
3
3
|
export declare class TemplateModule extends BaseClient {
|
|
4
4
|
createTemplate(title: string, content: string, categoryId?: string, workflowId?: string, agentId?: string): Promise<Template>;
|
|
5
5
|
updateTemplate(title: string, content: string, id: string, workflowId?: string, agentId?: string): Promise<Template>;
|
|
@@ -19,14 +19,6 @@ export declare class TemplateModule extends BaseClient {
|
|
|
19
19
|
deleteTemplateCategory(id: string): Promise<void>;
|
|
20
20
|
assignTemplateToTeam(teamId: string, templateId: string): Promise<void>;
|
|
21
21
|
removeTemplateFromTeam(teamId: string, templateId: string): Promise<void>;
|
|
22
|
-
generateTranscriptionSummary(templateId: string, sessionId: string): Promise<TranscriptionSummary>;
|
|
23
|
-
generateTranscriptionSummaryFromUserTemplate(userTemplateId: string, sessionId: string): Promise<TranscriptionSummary>;
|
|
24
|
-
updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary>;
|
|
25
|
-
getTranscriptionSummaries(): Promise<TranscriptionSummary[]>;
|
|
26
|
-
getTranscriptionSummary(id: string): Promise<TranscriptionSummary>;
|
|
27
|
-
getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]>;
|
|
28
|
-
getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]>;
|
|
29
|
-
deleteTranscriptionSummary(id: string): Promise<void>;
|
|
30
22
|
uploadLargeAudioFile(formData: FormData): Promise<string>;
|
|
31
23
|
uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null>;
|
|
32
24
|
transcribeBase64Audio(base64String: string): Promise<string>;
|
|
@@ -154,66 +154,6 @@ export class TemplateModule extends BaseClient {
|
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
// ======================
|
|
157
|
-
// TRANSCRIPTION SUMMARY METHODS
|
|
158
|
-
// ======================
|
|
159
|
-
generateTranscriptionSummary(templateId, sessionId) {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const generateSummaryDto = {
|
|
162
|
-
templateId,
|
|
163
|
-
userId: this.user.id,
|
|
164
|
-
fromUserTemplate: false,
|
|
165
|
-
sessionId: sessionId,
|
|
166
|
-
};
|
|
167
|
-
const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
|
|
168
|
-
return transcriptionSummary;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
generateTranscriptionSummaryFromUserTemplate(userTemplateId, sessionId) {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
const generateSummaryDto = {
|
|
174
|
-
templateId: userTemplateId,
|
|
175
|
-
userId: this.user.id,
|
|
176
|
-
fromUserTemplate: true,
|
|
177
|
-
sessionId: sessionId,
|
|
178
|
-
};
|
|
179
|
-
const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
|
|
180
|
-
return transcriptionSummary;
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
updateTranscriptionSummary(id, content) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const updateSummaryDto = {
|
|
186
|
-
content,
|
|
187
|
-
};
|
|
188
|
-
return this.request(`${urls.transcriptionSummary}/${id}`, 'PATCH', updateSummaryDto);
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
getTranscriptionSummaries() {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
return this.request(urls.transcriptionSummaries, 'GET');
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
getTranscriptionSummary(id) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
return this.request(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
getTranscriptionSummariesByUser(userId) {
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
return this.request(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
getByOrganizationTranscriptionSummaries(organizationId) {
|
|
207
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
return this.request(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
deleteTranscriptionSummary(id) {
|
|
212
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
yield this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
// ======================
|
|
217
157
|
// AUDIO UPLOAD METHODS (for transcription)
|
|
218
158
|
// ======================
|
|
219
159
|
uploadLargeAudioFile(formData) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import { TranscriptionSummary } from '../types';
|
|
3
|
+
export declare class TranscriptionSummaryModule extends BaseClient {
|
|
4
|
+
generateTranscriptionSummary(templateId: string, sessionId: string): Promise<TranscriptionSummary>;
|
|
5
|
+
generateTranscriptionSummaryFromUserTemplate(userTemplateId: string, sessionId: string): Promise<TranscriptionSummary>;
|
|
6
|
+
updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary>;
|
|
7
|
+
getTranscriptionSummaries(): Promise<TranscriptionSummary[]>;
|
|
8
|
+
getTranscriptionSummary(id: string): Promise<TranscriptionSummary>;
|
|
9
|
+
getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]>;
|
|
10
|
+
getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]>;
|
|
11
|
+
cloneTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary>;
|
|
12
|
+
deleteTranscriptionSummary(id: string): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 TranscriptionSummaryModule extends BaseClient {
|
|
13
|
+
// ======================
|
|
14
|
+
// TRANSCRIPTION SUMMARY METHODS
|
|
15
|
+
// ======================
|
|
16
|
+
generateTranscriptionSummary(templateId, sessionId) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const generateSummaryDto = {
|
|
19
|
+
templateId,
|
|
20
|
+
userId: this.user.id,
|
|
21
|
+
fromUserTemplate: false,
|
|
22
|
+
sessionId: sessionId,
|
|
23
|
+
};
|
|
24
|
+
const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
|
|
25
|
+
return transcriptionSummary;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
generateTranscriptionSummaryFromUserTemplate(userTemplateId, sessionId) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const generateSummaryDto = {
|
|
31
|
+
templateId: userTemplateId,
|
|
32
|
+
userId: this.user.id,
|
|
33
|
+
fromUserTemplate: true,
|
|
34
|
+
sessionId: sessionId,
|
|
35
|
+
};
|
|
36
|
+
const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
|
|
37
|
+
return transcriptionSummary;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
updateTranscriptionSummary(id, content) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const updateSummaryDto = {
|
|
43
|
+
content,
|
|
44
|
+
};
|
|
45
|
+
return this.request(`${urls.transcriptionSummaries}/${id}`, 'PATCH', updateSummaryDto);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getTranscriptionSummaries() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return this.request(urls.transcriptionSummaries, 'GET');
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getTranscriptionSummary(id) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return this.request(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
getTranscriptionSummariesByUser(userId) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return this.request(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getByOrganizationTranscriptionSummaries(organizationId) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
return this.request(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
cloneTranscriptionSummary(id, content) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const cloneDto = {
|
|
71
|
+
content,
|
|
72
|
+
};
|
|
73
|
+
return this.request(`${urls.transcriptionSummaries}/${id}/clone`, 'POST', cloneDto);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
deleteTranscriptionSummary(id) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
yield this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -30,10 +30,15 @@ export declare class WebSocketModule extends BaseClient {
|
|
|
30
30
|
* Get connection statistics
|
|
31
31
|
*/
|
|
32
32
|
getConnectionStats(): WebSocketConnectionStats;
|
|
33
|
+
/**
|
|
34
|
+
* Ensure WebSocket connection has a valid token
|
|
35
|
+
* Reconnects with fresh token if current token is expired
|
|
36
|
+
*/
|
|
37
|
+
private ensureValidConnection;
|
|
33
38
|
/**
|
|
34
39
|
* Stream audio chunk to server
|
|
35
40
|
*/
|
|
36
|
-
streamAudioChunk(sessionId: string, audioChunk: string): void
|
|
41
|
+
streamAudioChunk(sessionId: string, audioChunk: string): Promise<void>;
|
|
37
42
|
/**
|
|
38
43
|
* Stream multiple audio chunks
|
|
39
44
|
*/
|
|
@@ -94,19 +94,48 @@ export class WebSocketModule extends BaseClient {
|
|
|
94
94
|
getConnectionStats() {
|
|
95
95
|
return Object.assign({}, this.connectionStats);
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Ensure WebSocket connection has a valid token
|
|
99
|
+
* Reconnects with fresh token if current token is expired
|
|
100
|
+
*/
|
|
101
|
+
ensureValidConnection() {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const currentToken = this.getAccessToken();
|
|
104
|
+
// Check if we have a token and if it's expired
|
|
105
|
+
if (!currentToken || this.isTokenExpired(currentToken)) {
|
|
106
|
+
console.log('[WebSocket] Token expired or missing, refreshing and reconnecting...');
|
|
107
|
+
try {
|
|
108
|
+
// Refresh token
|
|
109
|
+
yield this.getToken();
|
|
110
|
+
// Disconnect current connection and reconnect with fresh token
|
|
111
|
+
this.disconnect();
|
|
112
|
+
yield this.connect();
|
|
113
|
+
console.log('[WebSocket] Successfully reconnected with fresh token');
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error('[WebSocket] Failed to refresh token and reconnect:', error);
|
|
117
|
+
throw new Error('Authentication failed: Unable to refresh token for WebSocket streaming');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
97
122
|
/**
|
|
98
123
|
* Stream audio chunk to server
|
|
99
124
|
*/
|
|
100
125
|
streamAudioChunk(sessionId, audioChunk) {
|
|
101
126
|
var _a;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
// CRITICAL: Validate token and reconnect if needed BEFORE sending
|
|
129
|
+
yield this.ensureValidConnection();
|
|
130
|
+
if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
|
|
131
|
+
throw new Error('WebSocket not connected after token validation');
|
|
132
|
+
}
|
|
133
|
+
const payload = {
|
|
134
|
+
sessionId,
|
|
135
|
+
audioChunk
|
|
136
|
+
};
|
|
137
|
+
this.socket.emit('audio-chunk', payload);
|
|
138
|
+
});
|
|
110
139
|
}
|
|
111
140
|
/**
|
|
112
141
|
* Stream multiple audio chunks
|
|
@@ -114,12 +143,15 @@ export class WebSocketModule extends BaseClient {
|
|
|
114
143
|
streamAudioChunks(sessionId, audioChunks, options = {}) {
|
|
115
144
|
var _a;
|
|
116
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
// Validate token once before streaming multiple chunks
|
|
147
|
+
yield this.ensureValidConnection();
|
|
117
148
|
if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
|
|
118
|
-
throw new Error('WebSocket not connected
|
|
149
|
+
throw new Error('WebSocket not connected after token validation.');
|
|
119
150
|
}
|
|
120
151
|
const delay = options.delayBetweenChunks || 100; // ms between chunks
|
|
121
152
|
for (let i = 0; i < audioChunks.length; i++) {
|
|
122
|
-
|
|
153
|
+
// Note: streamAudioChunk will also validate token, but we've already done it once
|
|
154
|
+
yield this.streamAudioChunk(sessionId, audioChunks[i]);
|
|
123
155
|
// Small delay between chunks to prevent overwhelming the server
|
|
124
156
|
if (i < audioChunks.length - 1) {
|
|
125
157
|
yield new Promise(resolve => setTimeout(resolve, delay));
|
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { UserModule } from './modules/user.module';
|
|
|
5
5
|
import { OrganizationModule } from './modules/organization.module';
|
|
6
6
|
import { TeamModule } from './modules/team.module';
|
|
7
7
|
import { TemplateModule } from './modules/template.module';
|
|
8
|
+
import { TranscriptionSummaryModule } from './modules/transcription-summary.module';
|
|
8
9
|
import { SessionModule } from './modules/session.module';
|
|
9
10
|
import { AgentModule } from './modules/agent.module';
|
|
10
11
|
import { AudioModule } from './modules/audio.module';
|
|
@@ -22,6 +23,7 @@ export declare class ApiSDK extends BaseClient {
|
|
|
22
23
|
readonly organizations: OrganizationModule;
|
|
23
24
|
readonly teams: TeamModule;
|
|
24
25
|
readonly templates: TemplateModule;
|
|
26
|
+
readonly transcriptionSummaries: TranscriptionSummaryModule;
|
|
25
27
|
readonly sessions: SessionModule;
|
|
26
28
|
readonly agents: AgentModule;
|
|
27
29
|
readonly audio: AudioModule;
|
|
@@ -88,14 +90,15 @@ export declare class ApiSDK extends BaseClient {
|
|
|
88
90
|
deleteTemplateCategory(...args: Parameters<TemplateModule['deleteTemplateCategory']>): Promise<void>;
|
|
89
91
|
assignTemplateToTeam(...args: Parameters<TemplateModule['assignTemplateToTeam']>): Promise<void>;
|
|
90
92
|
removeTemplateFromTeam(...args: Parameters<TemplateModule['removeTemplateFromTeam']>): Promise<void>;
|
|
91
|
-
generateTranscriptionSummary(...args: Parameters<
|
|
92
|
-
generateTranscriptionSummaryFromUserTemplate(...args: Parameters<
|
|
93
|
-
updateTranscriptionSummary(...args: Parameters<
|
|
94
|
-
getTranscriptionSummaries(...args: Parameters<
|
|
95
|
-
getTranscriptionSummary(...args: Parameters<
|
|
96
|
-
getTranscriptionSummariesByUser(...args: Parameters<
|
|
97
|
-
getByOrganizationTranscriptionSummaries(...args: Parameters<
|
|
98
|
-
|
|
93
|
+
generateTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['generateTranscriptionSummary']>): Promise<import("./types").TranscriptionSummary>;
|
|
94
|
+
generateTranscriptionSummaryFromUserTemplate(...args: Parameters<TranscriptionSummaryModule['generateTranscriptionSummaryFromUserTemplate']>): Promise<import("./types").TranscriptionSummary>;
|
|
95
|
+
updateTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['updateTranscriptionSummary']>): Promise<import("./types").TranscriptionSummary>;
|
|
96
|
+
getTranscriptionSummaries(...args: Parameters<TranscriptionSummaryModule['getTranscriptionSummaries']>): Promise<import("./types").TranscriptionSummary[]>;
|
|
97
|
+
getTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['getTranscriptionSummary']>): Promise<import("./types").TranscriptionSummary>;
|
|
98
|
+
getTranscriptionSummariesByUser(...args: Parameters<TranscriptionSummaryModule['getTranscriptionSummariesByUser']>): Promise<import("./types").TranscriptionSummary[]>;
|
|
99
|
+
getByOrganizationTranscriptionSummaries(...args: Parameters<TranscriptionSummaryModule['getByOrganizationTranscriptionSummaries']>): Promise<import("./types").TranscriptionSummary[]>;
|
|
100
|
+
cloneTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['cloneTranscriptionSummary']>): Promise<import("./types").TranscriptionSummary>;
|
|
101
|
+
deleteTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['deleteTranscriptionSummary']>): Promise<void>;
|
|
99
102
|
uploadLargeAudioFile(...args: Parameters<TemplateModule['uploadLargeAudioFile']>): Promise<string>;
|
|
100
103
|
uploadAudioFile(...args: Parameters<TemplateModule['uploadAudioFile']>): Promise<import("./types").TranscriptionAudioUploadResponse | null>;
|
|
101
104
|
transcribeBase64Audio(...args: Parameters<TemplateModule['transcribeBase64Audio']>): Promise<string>;
|
|
@@ -186,7 +189,7 @@ export declare class ApiSDK extends BaseClient {
|
|
|
186
189
|
connectWebSocket(): Promise<void>;
|
|
187
190
|
disconnectWebSocket(): void;
|
|
188
191
|
isWebSocketConnected(): boolean;
|
|
189
|
-
streamAudioChunk(...args: Parameters<WebSocketModule['streamAudioChunk']>): void
|
|
192
|
+
streamAudioChunk(...args: Parameters<WebSocketModule['streamAudioChunk']>): Promise<void>;
|
|
190
193
|
streamAudioChunks(...args: Parameters<WebSocketModule['streamAudioChunks']>): Promise<void>;
|
|
191
194
|
onWebSocketEvent(...args: Parameters<WebSocketModule['on']>): void;
|
|
192
195
|
offWebSocketEvent(...args: Parameters<WebSocketModule['off']>): void;
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -13,6 +13,7 @@ import { UserModule } from './modules/user.module';
|
|
|
13
13
|
import { OrganizationModule } from './modules/organization.module';
|
|
14
14
|
import { TeamModule } from './modules/team.module';
|
|
15
15
|
import { TemplateModule } from './modules/template.module';
|
|
16
|
+
import { TranscriptionSummaryModule } from './modules/transcription-summary.module';
|
|
16
17
|
import { SessionModule } from './modules/session.module';
|
|
17
18
|
import { AgentModule } from './modules/agent.module';
|
|
18
19
|
import { AudioModule } from './modules/audio.module';
|
|
@@ -33,6 +34,7 @@ export class ApiSDK extends BaseClient {
|
|
|
33
34
|
this.organizations = new OrganizationModule(config);
|
|
34
35
|
this.teams = new TeamModule(config);
|
|
35
36
|
this.templates = new TemplateModule(config);
|
|
37
|
+
this.transcriptionSummaries = new TranscriptionSummaryModule(config);
|
|
36
38
|
this.sessions = new SessionModule(config);
|
|
37
39
|
this.agents = new AgentModule(config);
|
|
38
40
|
this.audio = new AudioModule(config);
|
|
@@ -328,42 +330,47 @@ export class ApiSDK extends BaseClient {
|
|
|
328
330
|
}
|
|
329
331
|
generateTranscriptionSummary(...args) {
|
|
330
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
-
return this.
|
|
333
|
+
return this.transcriptionSummaries.generateTranscriptionSummary(...args);
|
|
332
334
|
});
|
|
333
335
|
}
|
|
334
336
|
generateTranscriptionSummaryFromUserTemplate(...args) {
|
|
335
337
|
return __awaiter(this, void 0, void 0, function* () {
|
|
336
|
-
return this.
|
|
338
|
+
return this.transcriptionSummaries.generateTranscriptionSummaryFromUserTemplate(...args);
|
|
337
339
|
});
|
|
338
340
|
}
|
|
339
341
|
updateTranscriptionSummary(...args) {
|
|
340
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
341
|
-
return this.
|
|
343
|
+
return this.transcriptionSummaries.updateTranscriptionSummary(...args);
|
|
342
344
|
});
|
|
343
345
|
}
|
|
344
346
|
getTranscriptionSummaries(...args) {
|
|
345
347
|
return __awaiter(this, void 0, void 0, function* () {
|
|
346
|
-
return this.
|
|
348
|
+
return this.transcriptionSummaries.getTranscriptionSummaries(...args);
|
|
347
349
|
});
|
|
348
350
|
}
|
|
349
351
|
getTranscriptionSummary(...args) {
|
|
350
352
|
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
-
return this.
|
|
353
|
+
return this.transcriptionSummaries.getTranscriptionSummary(...args);
|
|
352
354
|
});
|
|
353
355
|
}
|
|
354
356
|
getTranscriptionSummariesByUser(...args) {
|
|
355
357
|
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
-
return this.
|
|
358
|
+
return this.transcriptionSummaries.getTranscriptionSummariesByUser(...args);
|
|
357
359
|
});
|
|
358
360
|
}
|
|
359
361
|
getByOrganizationTranscriptionSummaries(...args) {
|
|
360
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
361
|
-
return this.
|
|
363
|
+
return this.transcriptionSummaries.getByOrganizationTranscriptionSummaries(...args);
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
cloneTranscriptionSummary(...args) {
|
|
367
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
+
return this.transcriptionSummaries.cloneTranscriptionSummary(...args);
|
|
362
369
|
});
|
|
363
370
|
}
|
|
364
371
|
deleteTranscriptionSummary(...args) {
|
|
365
372
|
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
-
return this.
|
|
373
|
+
return this.transcriptionSummaries.deleteTranscriptionSummary(...args);
|
|
367
374
|
});
|
|
368
375
|
}
|
|
369
376
|
uploadLargeAudioFile(...args) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Template,
|
|
4
4
|
TemplateCategory,
|
|
5
5
|
UserTemplate,
|
|
6
|
-
TranscriptionSummary,
|
|
7
6
|
CreateTemplateDto,
|
|
8
7
|
UpdateTemplateDto,
|
|
9
8
|
CreateUserTemplateDto,
|
|
@@ -11,8 +10,6 @@ import {
|
|
|
11
10
|
CreateTemplateCategoryDto,
|
|
12
11
|
UpdateTemplateCategoryDto,
|
|
13
12
|
AssignTeamTemplateDto,
|
|
14
|
-
GenerateTranscriptionSummaryDto,
|
|
15
|
-
UpdateTranscriptionSummaryDto,
|
|
16
13
|
TranscriptionAudioUploadResponse,
|
|
17
14
|
} from '../types';
|
|
18
15
|
import urls from '../urls';
|
|
@@ -150,66 +147,6 @@ export class TemplateModule extends BaseClient {
|
|
|
150
147
|
await this.request(`${urls.teamTemplates}/team/${teamId}/template/${templateId}`, 'DELETE');
|
|
151
148
|
}
|
|
152
149
|
|
|
153
|
-
// ======================
|
|
154
|
-
// TRANSCRIPTION SUMMARY METHODS
|
|
155
|
-
// ======================
|
|
156
|
-
|
|
157
|
-
public async generateTranscriptionSummary(templateId: string, sessionId: string): Promise<TranscriptionSummary> {
|
|
158
|
-
const generateSummaryDto: GenerateTranscriptionSummaryDto = {
|
|
159
|
-
templateId,
|
|
160
|
-
userId: this.user!.id,
|
|
161
|
-
fromUserTemplate: false,
|
|
162
|
-
sessionId: sessionId,
|
|
163
|
-
};
|
|
164
|
-
const transcriptionSummary: TranscriptionSummary = await this.request(
|
|
165
|
-
urls.transcriptionSummary,
|
|
166
|
-
'POST',
|
|
167
|
-
generateSummaryDto
|
|
168
|
-
);
|
|
169
|
-
return transcriptionSummary;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public async generateTranscriptionSummaryFromUserTemplate(userTemplateId: string, sessionId: string): Promise<TranscriptionSummary> {
|
|
173
|
-
const generateSummaryDto: GenerateTranscriptionSummaryDto = {
|
|
174
|
-
templateId: userTemplateId,
|
|
175
|
-
userId: this.user!.id,
|
|
176
|
-
fromUserTemplate: true,
|
|
177
|
-
sessionId: sessionId,
|
|
178
|
-
};
|
|
179
|
-
const transcriptionSummary: TranscriptionSummary = await this.request(
|
|
180
|
-
urls.transcriptionSummary,
|
|
181
|
-
'POST',
|
|
182
|
-
generateSummaryDto
|
|
183
|
-
);
|
|
184
|
-
return transcriptionSummary;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public async updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary> {
|
|
188
|
-
const updateSummaryDto: UpdateTranscriptionSummaryDto = {
|
|
189
|
-
content,
|
|
190
|
-
};
|
|
191
|
-
return this.request<TranscriptionSummary>(`${urls.transcriptionSummary}/${id}`, 'PATCH', updateSummaryDto);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
public async getTranscriptionSummaries(): Promise<TranscriptionSummary[]> {
|
|
195
|
-
return this.request<TranscriptionSummary[]>(urls.transcriptionSummaries, 'GET');
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
public async getTranscriptionSummary(id: string): Promise<TranscriptionSummary> {
|
|
199
|
-
return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
public async getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]> {
|
|
203
|
-
return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
public async getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]> {
|
|
207
|
-
return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public async deleteTranscriptionSummary(id: string): Promise<void> {
|
|
211
|
-
await this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
212
|
-
}
|
|
213
150
|
|
|
214
151
|
// ======================
|
|
215
152
|
// AUDIO UPLOAD METHODS (for transcription)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import {
|
|
3
|
+
TranscriptionSummary,
|
|
4
|
+
GenerateTranscriptionSummaryDto,
|
|
5
|
+
UpdateTranscriptionSummaryDto,
|
|
6
|
+
CloneTranscriptionSummaryDto,
|
|
7
|
+
} from '../types';
|
|
8
|
+
import urls from '../urls';
|
|
9
|
+
|
|
10
|
+
export class TranscriptionSummaryModule extends BaseClient {
|
|
11
|
+
// ======================
|
|
12
|
+
// TRANSCRIPTION SUMMARY METHODS
|
|
13
|
+
// ======================
|
|
14
|
+
|
|
15
|
+
public async generateTranscriptionSummary(templateId: string, sessionId: string): Promise<TranscriptionSummary> {
|
|
16
|
+
const generateSummaryDto: GenerateTranscriptionSummaryDto = {
|
|
17
|
+
templateId,
|
|
18
|
+
userId: this.user!.id,
|
|
19
|
+
fromUserTemplate: false,
|
|
20
|
+
sessionId: sessionId,
|
|
21
|
+
};
|
|
22
|
+
const transcriptionSummary: TranscriptionSummary = await this.request(
|
|
23
|
+
urls.transcriptionSummary,
|
|
24
|
+
'POST',
|
|
25
|
+
generateSummaryDto
|
|
26
|
+
);
|
|
27
|
+
return transcriptionSummary;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async generateTranscriptionSummaryFromUserTemplate(userTemplateId: string, sessionId: string): Promise<TranscriptionSummary> {
|
|
31
|
+
const generateSummaryDto: GenerateTranscriptionSummaryDto = {
|
|
32
|
+
templateId: userTemplateId,
|
|
33
|
+
userId: this.user!.id,
|
|
34
|
+
fromUserTemplate: true,
|
|
35
|
+
sessionId: sessionId,
|
|
36
|
+
};
|
|
37
|
+
const transcriptionSummary: TranscriptionSummary = await this.request(
|
|
38
|
+
urls.transcriptionSummary,
|
|
39
|
+
'POST',
|
|
40
|
+
generateSummaryDto
|
|
41
|
+
);
|
|
42
|
+
return transcriptionSummary;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary> {
|
|
46
|
+
const updateSummaryDto: UpdateTranscriptionSummaryDto = {
|
|
47
|
+
content,
|
|
48
|
+
};
|
|
49
|
+
return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'PATCH', updateSummaryDto);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public async getTranscriptionSummaries(): Promise<TranscriptionSummary[]> {
|
|
53
|
+
return this.request<TranscriptionSummary[]>(urls.transcriptionSummaries, 'GET');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public async getTranscriptionSummary(id: string): Promise<TranscriptionSummary> {
|
|
57
|
+
return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]> {
|
|
61
|
+
return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public async getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]> {
|
|
65
|
+
return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async cloneTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary> {
|
|
69
|
+
const cloneDto: CloneTranscriptionSummaryDto = {
|
|
70
|
+
content,
|
|
71
|
+
};
|
|
72
|
+
return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}/clone`, 'POST', cloneDto);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async deleteTranscriptionSummary(id: string): Promise<void> {
|
|
76
|
+
await this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -117,15 +117,45 @@ export class WebSocketModule extends BaseClient {
|
|
|
117
117
|
return { ...this.connectionStats };
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Ensure WebSocket connection has a valid token
|
|
122
|
+
* Reconnects with fresh token if current token is expired
|
|
123
|
+
*/
|
|
124
|
+
private async ensureValidConnection(): Promise<void> {
|
|
125
|
+
const currentToken = this.getAccessToken();
|
|
126
|
+
|
|
127
|
+
// Check if we have a token and if it's expired
|
|
128
|
+
if (!currentToken || this.isTokenExpired(currentToken)) {
|
|
129
|
+
console.log('[WebSocket] Token expired or missing, refreshing and reconnecting...');
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
// Refresh token
|
|
133
|
+
await this.getToken();
|
|
134
|
+
|
|
135
|
+
// Disconnect current connection and reconnect with fresh token
|
|
136
|
+
this.disconnect();
|
|
137
|
+
await this.connect();
|
|
138
|
+
|
|
139
|
+
console.log('[WebSocket] Successfully reconnected with fresh token');
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error('[WebSocket] Failed to refresh token and reconnect:', error);
|
|
142
|
+
throw new Error('Authentication failed: Unable to refresh token for WebSocket streaming');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
120
147
|
/**
|
|
121
148
|
* Stream audio chunk to server
|
|
122
149
|
*/
|
|
123
|
-
public streamAudioChunk(
|
|
150
|
+
public async streamAudioChunk(
|
|
124
151
|
sessionId: string,
|
|
125
152
|
audioChunk: string
|
|
126
|
-
): void {
|
|
153
|
+
): Promise<void> {
|
|
154
|
+
// CRITICAL: Validate token and reconnect if needed BEFORE sending
|
|
155
|
+
await this.ensureValidConnection();
|
|
156
|
+
|
|
127
157
|
if (!this.socket?.connected) {
|
|
128
|
-
throw new Error('WebSocket not connected
|
|
158
|
+
throw new Error('WebSocket not connected after token validation');
|
|
129
159
|
}
|
|
130
160
|
|
|
131
161
|
const payload: AudioChunkPayload = {
|
|
@@ -144,14 +174,18 @@ export class WebSocketModule extends BaseClient {
|
|
|
144
174
|
audioChunks: string[],
|
|
145
175
|
options: AudioStreamingOptions = {}
|
|
146
176
|
): Promise<void> {
|
|
177
|
+
// Validate token once before streaming multiple chunks
|
|
178
|
+
await this.ensureValidConnection();
|
|
179
|
+
|
|
147
180
|
if (!this.socket?.connected) {
|
|
148
|
-
throw new Error('WebSocket not connected
|
|
181
|
+
throw new Error('WebSocket not connected after token validation.');
|
|
149
182
|
}
|
|
150
183
|
|
|
151
184
|
const delay = options.delayBetweenChunks || 100; // ms between chunks
|
|
152
185
|
|
|
153
186
|
for (let i = 0; i < audioChunks.length; i++) {
|
|
154
|
-
|
|
187
|
+
// Note: streamAudioChunk will also validate token, but we've already done it once
|
|
188
|
+
await this.streamAudioChunk(sessionId, audioChunks[i]);
|
|
155
189
|
|
|
156
190
|
// Small delay between chunks to prevent overwhelming the server
|
|
157
191
|
if (i < audioChunks.length - 1) {
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { UserModule } from './modules/user.module';
|
|
|
6
6
|
import { OrganizationModule } from './modules/organization.module';
|
|
7
7
|
import { TeamModule } from './modules/team.module';
|
|
8
8
|
import { TemplateModule } from './modules/template.module';
|
|
9
|
+
import { TranscriptionSummaryModule } from './modules/transcription-summary.module';
|
|
9
10
|
import { SessionModule } from './modules/session.module';
|
|
10
11
|
import { AgentModule } from './modules/agent.module';
|
|
11
12
|
import { AudioModule } from './modules/audio.module';
|
|
@@ -24,6 +25,7 @@ export class ApiSDK extends BaseClient {
|
|
|
24
25
|
public readonly organizations: OrganizationModule;
|
|
25
26
|
public readonly teams: TeamModule;
|
|
26
27
|
public readonly templates: TemplateModule;
|
|
28
|
+
public readonly transcriptionSummaries: TranscriptionSummaryModule;
|
|
27
29
|
public readonly sessions: SessionModule;
|
|
28
30
|
public readonly agents: AgentModule;
|
|
29
31
|
public readonly audio: AudioModule;
|
|
@@ -42,6 +44,7 @@ export class ApiSDK extends BaseClient {
|
|
|
42
44
|
this.organizations = new OrganizationModule(config);
|
|
43
45
|
this.teams = new TeamModule(config);
|
|
44
46
|
this.templates = new TemplateModule(config);
|
|
47
|
+
this.transcriptionSummaries = new TranscriptionSummaryModule(config);
|
|
45
48
|
this.sessions = new SessionModule(config);
|
|
46
49
|
this.agents = new AgentModule(config);
|
|
47
50
|
this.audio = new AudioModule(config);
|
|
@@ -282,36 +285,40 @@ export class ApiSDK extends BaseClient {
|
|
|
282
285
|
return this.templates.removeTemplateFromTeam(...args);
|
|
283
286
|
}
|
|
284
287
|
|
|
285
|
-
public async generateTranscriptionSummary(...args: Parameters<
|
|
286
|
-
return this.
|
|
288
|
+
public async generateTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['generateTranscriptionSummary']>) {
|
|
289
|
+
return this.transcriptionSummaries.generateTranscriptionSummary(...args);
|
|
287
290
|
}
|
|
288
291
|
|
|
289
|
-
public async generateTranscriptionSummaryFromUserTemplate(...args: Parameters<
|
|
290
|
-
return this.
|
|
292
|
+
public async generateTranscriptionSummaryFromUserTemplate(...args: Parameters<TranscriptionSummaryModule['generateTranscriptionSummaryFromUserTemplate']>) {
|
|
293
|
+
return this.transcriptionSummaries.generateTranscriptionSummaryFromUserTemplate(...args);
|
|
291
294
|
}
|
|
292
295
|
|
|
293
|
-
public async updateTranscriptionSummary(...args: Parameters<
|
|
294
|
-
return this.
|
|
296
|
+
public async updateTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['updateTranscriptionSummary']>) {
|
|
297
|
+
return this.transcriptionSummaries.updateTranscriptionSummary(...args);
|
|
295
298
|
}
|
|
296
299
|
|
|
297
|
-
public async getTranscriptionSummaries(...args: Parameters<
|
|
298
|
-
return this.
|
|
300
|
+
public async getTranscriptionSummaries(...args: Parameters<TranscriptionSummaryModule['getTranscriptionSummaries']>) {
|
|
301
|
+
return this.transcriptionSummaries.getTranscriptionSummaries(...args);
|
|
299
302
|
}
|
|
300
303
|
|
|
301
|
-
public async getTranscriptionSummary(...args: Parameters<
|
|
302
|
-
return this.
|
|
304
|
+
public async getTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['getTranscriptionSummary']>) {
|
|
305
|
+
return this.transcriptionSummaries.getTranscriptionSummary(...args);
|
|
303
306
|
}
|
|
304
307
|
|
|
305
|
-
public async getTranscriptionSummariesByUser(...args: Parameters<
|
|
306
|
-
return this.
|
|
308
|
+
public async getTranscriptionSummariesByUser(...args: Parameters<TranscriptionSummaryModule['getTranscriptionSummariesByUser']>) {
|
|
309
|
+
return this.transcriptionSummaries.getTranscriptionSummariesByUser(...args);
|
|
307
310
|
}
|
|
308
311
|
|
|
309
|
-
public async getByOrganizationTranscriptionSummaries(...args: Parameters<
|
|
310
|
-
return this.
|
|
312
|
+
public async getByOrganizationTranscriptionSummaries(...args: Parameters<TranscriptionSummaryModule['getByOrganizationTranscriptionSummaries']>) {
|
|
313
|
+
return this.transcriptionSummaries.getByOrganizationTranscriptionSummaries(...args);
|
|
311
314
|
}
|
|
312
315
|
|
|
313
|
-
public async
|
|
314
|
-
return this.
|
|
316
|
+
public async cloneTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['cloneTranscriptionSummary']>) {
|
|
317
|
+
return this.transcriptionSummaries.cloneTranscriptionSummary(...args);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
public async deleteTranscriptionSummary(...args: Parameters<TranscriptionSummaryModule['deleteTranscriptionSummary']>) {
|
|
321
|
+
return this.transcriptionSummaries.deleteTranscriptionSummary(...args);
|
|
315
322
|
}
|
|
316
323
|
|
|
317
324
|
public async uploadLargeAudioFile(...args: Parameters<TemplateModule['uploadLargeAudioFile']>) {
|