whio-api-sdk 1.0.192-bet-staging → 1.0.194-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/agent.module.d.ts +17 -0
- package/dist/src/sdk/modules/agent.module.js +93 -0
- package/dist/src/sdk/modules/audio.module.d.ts +31 -0
- package/dist/src/sdk/modules/audio.module.js +147 -0
- package/dist/src/sdk/modules/auth.module.d.ts +9 -0
- package/dist/src/sdk/modules/auth.module.js +59 -0
- package/dist/src/sdk/modules/base-client.d.ts +25 -0
- package/dist/src/sdk/modules/base-client.js +183 -0
- package/dist/src/sdk/modules/debug.module.d.ts +20 -0
- package/dist/src/sdk/modules/debug.module.js +54 -0
- package/dist/src/sdk/modules/external-integration.module.d.ts +9 -0
- package/dist/src/sdk/modules/external-integration.module.js +38 -0
- package/dist/src/sdk/modules/log.module.d.ts +63 -0
- package/dist/src/sdk/modules/log.module.js +222 -0
- package/dist/src/sdk/modules/organization.module.d.ts +11 -0
- package/dist/src/sdk/modules/organization.module.js +50 -0
- package/dist/src/sdk/modules/session.module.d.ts +16 -0
- package/dist/src/sdk/modules/session.module.js +58 -0
- package/dist/src/sdk/modules/team.module.d.ts +13 -0
- package/dist/src/sdk/modules/team.module.js +72 -0
- package/dist/src/sdk/modules/template.module.d.ts +33 -0
- package/dist/src/sdk/modules/template.module.js +240 -0
- package/dist/src/sdk/modules/user.module.d.ts +17 -0
- package/dist/src/sdk/modules/user.module.js +104 -0
- package/dist/src/sdk/modules/workflow.module.d.ts +10 -0
- package/dist/src/sdk/modules/workflow.module.js +53 -0
- package/dist/src/sdk/sdk.d.ts +167 -206
- package/dist/src/sdk/sdk.js +375 -853
- package/dist/src/sdk/sdk.old.d.ts +222 -0
- package/dist/src/sdk/sdk.old.js +1238 -0
- package/dist/src/sdk/types/agent.types.d.ts +51 -0
- package/dist/src/sdk/types/agent.types.js +1 -0
- package/dist/src/sdk/types/audio.types.d.ts +72 -0
- package/dist/src/sdk/types/audio.types.js +8 -0
- package/dist/src/sdk/types/auth.types.d.ts +21 -0
- package/dist/src/sdk/types/auth.types.js +1 -0
- package/dist/src/sdk/types/common.types.d.ts +20 -0
- package/dist/src/sdk/types/common.types.js +9 -0
- package/dist/src/sdk/types/external-integration.types.d.ts +31 -0
- package/dist/src/sdk/types/external-integration.types.js +1 -0
- package/dist/src/sdk/types/index.d.ts +12 -0
- package/dist/src/sdk/types/index.js +13 -0
- package/dist/src/sdk/types/log.types.d.ts +61 -0
- package/dist/src/sdk/types/log.types.js +1 -0
- package/dist/src/sdk/types/organization.types.d.ts +42 -0
- package/dist/src/sdk/types/organization.types.js +6 -0
- package/dist/src/sdk/types/session.types.d.ts +54 -0
- package/dist/src/sdk/types/session.types.js +1 -0
- package/dist/src/sdk/types/team.types.d.ts +39 -0
- package/dist/src/sdk/types/team.types.js +1 -0
- package/dist/src/sdk/types/template.types.d.ts +118 -0
- package/dist/src/sdk/types/template.types.js +1 -0
- package/dist/src/sdk/types/user.types.d.ts +41 -0
- package/dist/src/sdk/types/user.types.js +1 -0
- package/dist/src/sdk/types/workflow.types.d.ts +19 -0
- package/dist/src/sdk/types/workflow.types.js +1 -0
- package/dist/src/sdk/types.d.ts +1 -517
- package/dist/src/sdk/types.js +2 -23
- package/dist/src/sdk/types.old.d.ts +517 -0
- package/dist/src/sdk/types.old.js +23 -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/agent.module.ts +74 -0
- package/src/sdk/modules/audio.module.ts +131 -0
- package/src/sdk/modules/auth.module.ts +53 -0
- package/src/sdk/modules/base-client.ts +214 -0
- package/src/sdk/modules/debug.module.ts +44 -0
- package/src/sdk/modules/external-integration.module.ts +50 -0
- package/src/sdk/modules/log.module.ts +213 -0
- package/src/sdk/modules/organization.module.ts +35 -0
- package/src/sdk/modules/session.module.ts +41 -0
- package/src/sdk/modules/team.module.ts +55 -0
- package/src/sdk/modules/template.module.ts +242 -0
- package/src/sdk/modules/user.module.ts +89 -0
- package/src/sdk/modules/workflow.module.ts +39 -0
- package/src/sdk/sdk.old.ts +1312 -0
- package/src/sdk/sdk.ts +393 -1074
- package/src/sdk/types/agent.types.ts +65 -0
- package/src/sdk/types/audio.types.ts +89 -0
- package/src/sdk/types/auth.types.ts +29 -0
- package/src/sdk/types/common.types.ts +26 -0
- package/src/sdk/types/external-integration.types.ts +37 -0
- package/src/sdk/types/index.ts +13 -0
- package/src/sdk/types/log.types.ts +68 -0
- package/src/sdk/types/organization.types.ts +55 -0
- package/src/sdk/types/session.types.ts +63 -0
- package/src/sdk/types/team.types.ts +48 -0
- package/src/sdk/types/template.types.ts +142 -0
- package/src/sdk/types/user.types.ts +50 -0
- package/src/sdk/types/workflow.types.ts +26 -0
- package/src/sdk/types.old.ts +649 -0
- package/src/sdk/types.ts +2 -649
- package/src/sdk/urls.ts +3 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import { Log, LogsResponse, LogStats, FilterLogsDto, CreateLogDto } from '../types';
|
|
3
|
+
import urls from '../urls';
|
|
4
|
+
|
|
5
|
+
export class LogModule extends BaseClient {
|
|
6
|
+
/**
|
|
7
|
+
* Get logs with advanced filtering options
|
|
8
|
+
*/
|
|
9
|
+
public async getLogs(filters?: FilterLogsDto): Promise<LogsResponse> {
|
|
10
|
+
const params = new URLSearchParams();
|
|
11
|
+
|
|
12
|
+
if (filters) {
|
|
13
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
14
|
+
if (value !== undefined && value !== null) {
|
|
15
|
+
params.append(key, value.toString());
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const queryString = params.toString();
|
|
21
|
+
const url = queryString ? `${urls.logs}?${queryString}` : urls.logs;
|
|
22
|
+
|
|
23
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get logs for a specific user
|
|
28
|
+
*/
|
|
29
|
+
public async getLogsByUser(userId: string, limit?: number, offset?: number): Promise<LogsResponse> {
|
|
30
|
+
const params = new URLSearchParams();
|
|
31
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
32
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
33
|
+
|
|
34
|
+
const queryString = params.toString();
|
|
35
|
+
const url = queryString ? `${urls.logs}/user/${userId}?${queryString}` : `${urls.logs}/user/${userId}`;
|
|
36
|
+
|
|
37
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get logs for a specific controller
|
|
42
|
+
*/
|
|
43
|
+
public async getLogsByController(controller: string, limit?: number, offset?: number): Promise<LogsResponse> {
|
|
44
|
+
const params = new URLSearchParams();
|
|
45
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
46
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
47
|
+
|
|
48
|
+
const queryString = params.toString();
|
|
49
|
+
const url = queryString ? `${urls.logs}/controller/${controller}?${queryString}` : `${urls.logs}/controller/${controller}`;
|
|
50
|
+
|
|
51
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get logs for the current authenticated user
|
|
56
|
+
*/
|
|
57
|
+
public async getMyLogs(limit?: number, offset?: number): Promise<LogsResponse> {
|
|
58
|
+
const params = new URLSearchParams();
|
|
59
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
60
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
61
|
+
|
|
62
|
+
const queryString = params.toString();
|
|
63
|
+
const url = queryString ? `${urls.logs}/my-logs?${queryString}` : `${urls.logs}/my-logs`;
|
|
64
|
+
|
|
65
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get logs within a date range
|
|
70
|
+
*/
|
|
71
|
+
public async getLogsByDateRange(
|
|
72
|
+
startDate: string,
|
|
73
|
+
endDate: string,
|
|
74
|
+
limit?: number,
|
|
75
|
+
offset?: number
|
|
76
|
+
): Promise<LogsResponse> {
|
|
77
|
+
const params = new URLSearchParams();
|
|
78
|
+
params.append('startDate', startDate);
|
|
79
|
+
params.append('endDate', endDate);
|
|
80
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
81
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
82
|
+
|
|
83
|
+
return this.request<LogsResponse>(`${urls.logs}/date-range?${params.toString()}`, 'GET');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get logging statistics
|
|
88
|
+
*/
|
|
89
|
+
public async getLogStats(): Promise<LogStats> {
|
|
90
|
+
return this.request<LogStats>(`${urls.logs}/stats`, 'GET');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create a manual log entry (app logs)
|
|
95
|
+
*/
|
|
96
|
+
public async createLog(logData: CreateLogDto): Promise<Log> {
|
|
97
|
+
return this.request<Log>(urls.logs, 'POST', logData);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Convenience methods for different log levels
|
|
102
|
+
*/
|
|
103
|
+
public async logInfo(message: string, context?: string, action?: string, data?: any): Promise<Log> {
|
|
104
|
+
return this.createLog({
|
|
105
|
+
level: 'info',
|
|
106
|
+
message,
|
|
107
|
+
context,
|
|
108
|
+
action,
|
|
109
|
+
data,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public async logError(message: string, context?: string, action?: string, data?: any): Promise<Log> {
|
|
114
|
+
return this.createLog({
|
|
115
|
+
level: 'error',
|
|
116
|
+
message,
|
|
117
|
+
context,
|
|
118
|
+
action,
|
|
119
|
+
data,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public async logWarn(message: string, context?: string, action?: string, data?: any): Promise<Log> {
|
|
124
|
+
return this.createLog({
|
|
125
|
+
level: 'warn',
|
|
126
|
+
message,
|
|
127
|
+
context,
|
|
128
|
+
action,
|
|
129
|
+
data,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public async logDebug(message: string, context?: string, action?: string, data?: any): Promise<Log> {
|
|
134
|
+
return this.createLog({
|
|
135
|
+
level: 'debug',
|
|
136
|
+
message,
|
|
137
|
+
context,
|
|
138
|
+
action,
|
|
139
|
+
data,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get logs by role
|
|
145
|
+
*/
|
|
146
|
+
public async getLogsByRole(role: string, limit?: number, offset?: number): Promise<LogsResponse> {
|
|
147
|
+
const params = new URLSearchParams();
|
|
148
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
149
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
150
|
+
|
|
151
|
+
const queryString = params.toString();
|
|
152
|
+
const url = queryString ? `${urls.logs}/role/${role}?${queryString}` : `${urls.logs}/role/${role}`;
|
|
153
|
+
|
|
154
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get logs by organization role
|
|
159
|
+
*/
|
|
160
|
+
public async getLogsByOrganizationRole(organizationRole: string, limit?: number, offset?: number): Promise<LogsResponse> {
|
|
161
|
+
const params = new URLSearchParams();
|
|
162
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
163
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
164
|
+
|
|
165
|
+
const queryString = params.toString();
|
|
166
|
+
const url = queryString ? `${urls.logs}/organization-role/${organizationRole}?${queryString}` : `${urls.logs}/organization-role/${organizationRole}`;
|
|
167
|
+
|
|
168
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get logs by team role
|
|
173
|
+
*/
|
|
174
|
+
public async getLogsByTeamRole(teamRole: string, limit?: number, offset?: number): Promise<LogsResponse> {
|
|
175
|
+
const params = new URLSearchParams();
|
|
176
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
177
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
178
|
+
|
|
179
|
+
const queryString = params.toString();
|
|
180
|
+
const url = queryString ? `${urls.logs}/team-role/${teamRole}?${queryString}` : `${urls.logs}/team-role/${teamRole}`;
|
|
181
|
+
|
|
182
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Get available roles for filtering
|
|
187
|
+
*/
|
|
188
|
+
public async getAvailableRoles(): Promise<{
|
|
189
|
+
roles: string[];
|
|
190
|
+
organizationRoles: string[];
|
|
191
|
+
teamRoles: string[];
|
|
192
|
+
}> {
|
|
193
|
+
return this.request<{
|
|
194
|
+
roles: string[];
|
|
195
|
+
organizationRoles: string[];
|
|
196
|
+
teamRoles: string[];
|
|
197
|
+
}>(`${urls.logs}/available-roles`, 'GET');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get logs for a specific session ID
|
|
202
|
+
*/
|
|
203
|
+
public async getSessionLogs(sessionId: string, limit?: number, offset?: number): Promise<LogsResponse> {
|
|
204
|
+
const params = new URLSearchParams();
|
|
205
|
+
if (limit !== undefined) params.append('limit', limit.toString());
|
|
206
|
+
if (offset !== undefined) params.append('offset', offset.toString());
|
|
207
|
+
|
|
208
|
+
const queryString = params.toString();
|
|
209
|
+
const url = queryString ? `${urls.logs}/session/${sessionId}?${queryString}` : `${urls.logs}/session/${sessionId}`;
|
|
210
|
+
|
|
211
|
+
return this.request<LogsResponse>(url, 'GET');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import { Organization, CreateOrganizationDto, UpdateOrganizationDto } from '../types';
|
|
3
|
+
import urls from '../urls';
|
|
4
|
+
|
|
5
|
+
export class OrganizationModule extends BaseClient {
|
|
6
|
+
public async createOrganization(name: string, description?: string): Promise<Organization> {
|
|
7
|
+
const dto: CreateOrganizationDto = { name, description };
|
|
8
|
+
return this.request<Organization>(urls.organizations, 'POST', dto);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async getOrganizations(): Promise<Organization[]> {
|
|
12
|
+
return this.request<Organization[]>(urls.organizations, 'GET');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async getOrganization(id: string): Promise<Organization> {
|
|
16
|
+
return this.request<Organization>(`${urls.organizations}/${id}`, 'GET');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async updateOrganization(id: string, name?: string, description?: string): Promise<Organization> {
|
|
20
|
+
const dto: UpdateOrganizationDto = { name, description };
|
|
21
|
+
return this.request<Organization>(`${urls.organizations}/${id}`, 'PATCH', dto);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async deleteOrganization(id: string): Promise<void> {
|
|
25
|
+
await this.request(`${urls.organizations}/${id}`, 'DELETE');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public async addUserToOrganization(organizationId: string, userId: string): Promise<void> {
|
|
29
|
+
await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async removeUserFromOrganization(organizationId: string, userId: string): Promise<void> {
|
|
33
|
+
await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'DELETE');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import { Session, CreateSessionDto, UpdateSessionDto } from '../types';
|
|
3
|
+
import urls from '../urls';
|
|
4
|
+
|
|
5
|
+
export class SessionModule extends BaseClient {
|
|
6
|
+
public async createSession(sessionData: CreateSessionDto): Promise<Session> {
|
|
7
|
+
return this.request<Session>(urls.sessions, 'POST', sessionData);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public async getSessions(): Promise<Session[]> {
|
|
11
|
+
return this.request<Session[]>(`${urls.sessions}/my-sessions`, 'GET');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public async getSession(id: string): Promise<Session> {
|
|
15
|
+
return this.request<Session>(`${urls.sessions}/${id}`, 'GET');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public async getSessionsByUser(userId: string): Promise<Session[]> {
|
|
19
|
+
return this.request<Session[]>(`${urls.sessions}/user/${userId}`, 'GET');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public async getSessionsByOrganization(): Promise<Session[]> {
|
|
23
|
+
return this.request<Session[]>(`${urls.sessions}/organization`, 'GET');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public async updateSession(id: string, sessionData: UpdateSessionDto): Promise<Session> {
|
|
27
|
+
return this.request<Session>(`${urls.sessions}/${id}`, 'PATCH', sessionData);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async deleteSession(id: string): Promise<void> {
|
|
31
|
+
await this.request(`${urls.sessions}/${id}`, 'DELETE');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async setPrimaryTranscriptionSummary(sessionId: string, summaryId: string): Promise<Session> {
|
|
35
|
+
return this.request<Session>(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public async rerunTranscription(sessionId: string): Promise<{ message: string; sessionId: string }> {
|
|
39
|
+
return this.request<{ message: string; sessionId: string }>(`${urls.sessions}/${sessionId}/rerun-transcription`, 'POST');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import { Team, CreateTeamDto, UpdateTeamDto, AssignTeamRoleDto } from '../types';
|
|
3
|
+
import urls from '../urls';
|
|
4
|
+
|
|
5
|
+
export class TeamModule extends BaseClient {
|
|
6
|
+
public async createTeam(name: string, description: string): Promise<Team> {
|
|
7
|
+
const teamDto: CreateTeamDto = {
|
|
8
|
+
name,
|
|
9
|
+
description,
|
|
10
|
+
organizationId: this.user!.organizationId,
|
|
11
|
+
};
|
|
12
|
+
return this.request(urls.teams, 'POST', teamDto);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async updateTeam(id: string, name: string, description: string): Promise<Team> {
|
|
16
|
+
const teamDto: UpdateTeamDto = {
|
|
17
|
+
name,
|
|
18
|
+
description,
|
|
19
|
+
};
|
|
20
|
+
return this.request<Team>(`${urls.teams}/${id}`, 'PATCH', teamDto);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async addUserToTeam(teamId: string, userId: string, roleName: string): Promise<any> {
|
|
24
|
+
const assignRoleDto: AssignTeamRoleDto = {
|
|
25
|
+
teamId,
|
|
26
|
+
userId,
|
|
27
|
+
name: roleName,
|
|
28
|
+
};
|
|
29
|
+
return this.request(urls.teamRoles, 'POST', assignRoleDto);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async removeUserFromTeam(teamId: string, userId: string): Promise<void> {
|
|
33
|
+
await this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async getTeams(): Promise<Team[]> {
|
|
37
|
+
return this.request<Team[]>(urls.teams, 'GET');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public async getTeam(id: string): Promise<Team> {
|
|
41
|
+
return this.request<Team>(`${urls.teams}/${id}`, 'GET');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public async getTeamsByOrganization(organizationId: string): Promise<Team[]> {
|
|
45
|
+
return this.request<Team[]>(`${urls.teams}/organization/${organizationId}`, 'GET');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public async deleteTeam(id: string): Promise<void> {
|
|
49
|
+
await this.request(`${urls.teams}/${id}`, 'DELETE');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public async removeUserFromTeamFixed(teamId: string, userId: string): Promise<void> {
|
|
53
|
+
await this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import {
|
|
3
|
+
Template,
|
|
4
|
+
TemplateCategory,
|
|
5
|
+
UserTemplate,
|
|
6
|
+
TranscriptionSummary,
|
|
7
|
+
CreateTemplateDto,
|
|
8
|
+
UpdateTemplateDto,
|
|
9
|
+
CreateUserTemplateDto,
|
|
10
|
+
UpdateUserTemplateDto,
|
|
11
|
+
CreateTemplateCategoryDto,
|
|
12
|
+
UpdateTemplateCategoryDto,
|
|
13
|
+
AssignTeamTemplateDto,
|
|
14
|
+
GenerateTranscriptionSummaryDto,
|
|
15
|
+
UpdateTranscriptionSummaryDto,
|
|
16
|
+
TranscriptionAudioUploadResponse,
|
|
17
|
+
} from '../types';
|
|
18
|
+
import urls from '../urls';
|
|
19
|
+
|
|
20
|
+
export class TemplateModule extends BaseClient {
|
|
21
|
+
// ======================
|
|
22
|
+
// TEMPLATE METHODS
|
|
23
|
+
// ======================
|
|
24
|
+
|
|
25
|
+
public async createTemplate(title: string, content: string, categoryId?: string, workflowId?: string, agentId?: string): Promise<Template> {
|
|
26
|
+
let finalCategoryId = categoryId;
|
|
27
|
+
if (!finalCategoryId) {
|
|
28
|
+
const templateCategories = await this.request<TemplateCategory[]>(
|
|
29
|
+
urls.templateCategories,
|
|
30
|
+
'GET'
|
|
31
|
+
);
|
|
32
|
+
finalCategoryId = templateCategories[0]?.id;
|
|
33
|
+
if (!finalCategoryId) {
|
|
34
|
+
throw new Error('No template categories available. Please create one first.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const createTemplateDto: CreateTemplateDto = {
|
|
39
|
+
title,
|
|
40
|
+
content,
|
|
41
|
+
isGlobal: false,
|
|
42
|
+
categoryId: finalCategoryId,
|
|
43
|
+
createdById: this.user!.id,
|
|
44
|
+
organizationId: this.user!.organizationId,
|
|
45
|
+
workflowId,
|
|
46
|
+
agentId,
|
|
47
|
+
};
|
|
48
|
+
return this.request<Template>(urls.templates, 'POST', createTemplateDto);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public async updateTemplate(title: string, content: string, id: string, workflowId?: string, agentId?: string): Promise<Template> {
|
|
52
|
+
const templateDto: UpdateTemplateDto = {
|
|
53
|
+
title,
|
|
54
|
+
content,
|
|
55
|
+
isGlobal: false,
|
|
56
|
+
organizationId: this.user!.organizationId,
|
|
57
|
+
workflowId,
|
|
58
|
+
agentId,
|
|
59
|
+
};
|
|
60
|
+
return this.request<Template>(`${urls.templates}/${id}`, 'PATCH', templateDto);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public async getTemplates(): Promise<Template[]> {
|
|
64
|
+
return this.request<Template[]>(urls.templates, 'GET');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public async getTemplatesByOrganization(): Promise<Template[]> {
|
|
68
|
+
return this.request<Template[]>(`${urls.templates}/organization`, 'GET');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public async getTemplate(id: string): Promise<Template> {
|
|
72
|
+
return this.request<Template>(`${urls.templates}/${id}`, 'GET');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async deleteTemplate(id: string): Promise<void> {
|
|
76
|
+
await this.request(`${urls.templates}/${id}`, 'DELETE');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ======================
|
|
80
|
+
// USER TEMPLATE METHODS
|
|
81
|
+
// ======================
|
|
82
|
+
|
|
83
|
+
public async createUserTemplate(title: string, content: string, originalTemplateId: string | undefined): Promise<UserTemplate> {
|
|
84
|
+
const createUserTemplateDto: CreateUserTemplateDto = {
|
|
85
|
+
title,
|
|
86
|
+
content,
|
|
87
|
+
originalTemplateId,
|
|
88
|
+
userId: this.user!.id,
|
|
89
|
+
};
|
|
90
|
+
return this.request(urls.userTemplates, 'POST', createUserTemplateDto);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public async updateUserTemplate(title: string, content: string, id: string): Promise<UserTemplate> {
|
|
94
|
+
const userTemplateDto: UpdateUserTemplateDto = {
|
|
95
|
+
title,
|
|
96
|
+
content,
|
|
97
|
+
};
|
|
98
|
+
return this.request<UserTemplate>(`${urls.userTemplates}/${id}`, 'PATCH', userTemplateDto);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public async getUserTemplates(): Promise<UserTemplate[]> {
|
|
102
|
+
const url = `${urls.userTemplates}/user/${this.user!.id}`;
|
|
103
|
+
return this.request<UserTemplate[]>(url, 'GET');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public async getUserTemplate(id: string): Promise<UserTemplate> {
|
|
107
|
+
return this.request<UserTemplate>(`${urls.userTemplates}/${id}`, 'GET');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public async deleteUserTemplate(id: string): Promise<void> {
|
|
111
|
+
await this.request(`${urls.userTemplates}/${id}`, 'DELETE');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ======================
|
|
115
|
+
// TEMPLATE CATEGORY METHODS
|
|
116
|
+
// ======================
|
|
117
|
+
|
|
118
|
+
public async getTemplateCategories(): Promise<TemplateCategory[]> {
|
|
119
|
+
return this.request<TemplateCategory[]>(urls.templateCategories, 'GET');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public async getTemplateCategory(id: string): Promise<TemplateCategory> {
|
|
123
|
+
return this.request<TemplateCategory>(`${urls.templateCategories}/${id}`, 'GET');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public async createTemplateCategory(name: string): Promise<TemplateCategory> {
|
|
127
|
+
const dto: CreateTemplateCategoryDto = { name };
|
|
128
|
+
return this.request<TemplateCategory>(urls.templateCategories, 'POST', dto);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public async updateTemplateCategory(id: string, name: string): Promise<TemplateCategory> {
|
|
132
|
+
const dto: UpdateTemplateCategoryDto = { name };
|
|
133
|
+
return this.request<TemplateCategory>(`${urls.templateCategories}/${id}`, 'PATCH', dto);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public async deleteTemplateCategory(id: string): Promise<void> {
|
|
137
|
+
await this.request(`${urls.templateCategories}/${id}`, 'DELETE');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ======================
|
|
141
|
+
// TEAM TEMPLATE METHODS
|
|
142
|
+
// ======================
|
|
143
|
+
|
|
144
|
+
public async assignTemplateToTeam(teamId: string, templateId: string): Promise<void> {
|
|
145
|
+
const dto: AssignTeamTemplateDto = { teamId, templateId };
|
|
146
|
+
await this.request(urls.teamTemplates, 'POST', dto);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public async removeTemplateFromTeam(teamId: string, templateId: string): Promise<void> {
|
|
150
|
+
await this.request(`${urls.teamTemplates}/team/${teamId}/template/${templateId}`, 'DELETE');
|
|
151
|
+
}
|
|
152
|
+
|
|
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
|
+
|
|
214
|
+
// ======================
|
|
215
|
+
// AUDIO UPLOAD METHODS (for transcription)
|
|
216
|
+
// ======================
|
|
217
|
+
|
|
218
|
+
public async uploadLargeAudioFile(formData: FormData): Promise<string> {
|
|
219
|
+
const uploadId: string = await this.fileUploadRequest(urls.uploadAudioLarge, formData);
|
|
220
|
+
const uploadIds: string = await this.storage!.getItem('uploadIds') || '[]';
|
|
221
|
+
const uploadIdsArray = JSON.parse(uploadIds);
|
|
222
|
+
await this.storage!.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
223
|
+
return uploadId;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public async uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null> {
|
|
227
|
+
const data: TranscriptionAudioUploadResponse = await this.fileUploadRequest(
|
|
228
|
+
urls.uploadAudio,
|
|
229
|
+
formData,
|
|
230
|
+
);
|
|
231
|
+
return data;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public async transcribeBase64Audio(base64String: string): Promise<string> {
|
|
235
|
+
const transcript = await this.request<any>(
|
|
236
|
+
urls.transcribeBase64Audio,
|
|
237
|
+
'POST',
|
|
238
|
+
{ base64Audio: base64String }
|
|
239
|
+
);
|
|
240
|
+
return transcript.transcript;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { BaseClient } from './base-client';
|
|
2
|
+
import { User, CreateUserDto, UpdateUserDto, Organization, AssignOrganizationRoleDto, OrganizationRoleType } from '../types';
|
|
3
|
+
import urls from '../urls';
|
|
4
|
+
|
|
5
|
+
export class UserModule extends BaseClient {
|
|
6
|
+
public async createUser(
|
|
7
|
+
firstName: string,
|
|
8
|
+
lastName: string,
|
|
9
|
+
email: string,
|
|
10
|
+
password: string
|
|
11
|
+
): Promise<User> {
|
|
12
|
+
const createUserDto: CreateUserDto = {
|
|
13
|
+
firstName,
|
|
14
|
+
lastName,
|
|
15
|
+
email,
|
|
16
|
+
password,
|
|
17
|
+
organizationId: this.user?.organizationId,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const user = await this.request<User>(urls.users, 'POST', createUserDto);
|
|
21
|
+
return user;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private async assignRoleToUser(userId: string, roleName: OrganizationRoleType, organizationId?: string): Promise<User> {
|
|
25
|
+
const orgId = organizationId || this.user?.organizationId;
|
|
26
|
+
const organization = await this.request<Organization>(
|
|
27
|
+
`${urls.organizations}/${orgId}`,
|
|
28
|
+
'GET'
|
|
29
|
+
);
|
|
30
|
+
const orgRoleEditor = organization.roles!.find(r => r.name === roleName);
|
|
31
|
+
const assignRoleDto: AssignOrganizationRoleDto = {
|
|
32
|
+
userId: userId,
|
|
33
|
+
organizationRoleId: orgRoleEditor!.id,
|
|
34
|
+
};
|
|
35
|
+
this.request(urls.userOrganizationRoles, 'POST', assignRoleDto);
|
|
36
|
+
const userWithOrgRole = await this.request<User>(`${urls.user}/${userId}`, 'GET');
|
|
37
|
+
return userWithOrgRole;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public async assignEditorToRoleToUser(userId: string, organizationId?: string): Promise<User> {
|
|
41
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR, organizationId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public async assignAdminToRoleToUser(userId: string, organizationId?: string): Promise<User> {
|
|
45
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN, organizationId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public async assignDisabledToRoleToUser(userId: string, organizationId?: string): Promise<User> {
|
|
49
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public async createEditorUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
|
|
53
|
+
const user = await this.createUser(firstName, lastName, email, password);
|
|
54
|
+
const userWithOrgRole = await this.assignEditorToRoleToUser(user.id);
|
|
55
|
+
return userWithOrgRole;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public async createAdminUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
|
|
59
|
+
const user = await this.createUser(firstName, lastName, email, password);
|
|
60
|
+
const userWithOrgRole = await this.assignAdminToRoleToUser(user.id);
|
|
61
|
+
return userWithOrgRole;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public async createDisabledUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
|
|
65
|
+
const user = await this.createUser(firstName, lastName, email, password);
|
|
66
|
+
const userWithOrgRole = await this.assignDisabledToRoleToUser(user.id);
|
|
67
|
+
return userWithOrgRole;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public async getUsers(): Promise<User[]> {
|
|
71
|
+
return this.request<User[]>(urls.users, 'GET');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public async getUser(id: string): Promise<User> {
|
|
75
|
+
return this.request<User>(`${urls.users}/${id}`, 'GET');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public async getUsersByOrganization(organizationId: string): Promise<User[]> {
|
|
79
|
+
return this.request<User[]>(`${urls.users}/organization/${organizationId}`, 'GET');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public async updateUser(id: string, data: UpdateUserDto): Promise<User> {
|
|
83
|
+
return this.request<User>(`${urls.users}/${id}`, 'PATCH', data);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public async deleteUser(id: string): Promise<void> {
|
|
87
|
+
await this.request(`${urls.users}/${id}`, 'DELETE');
|
|
88
|
+
}
|
|
89
|
+
}
|