whio-api-sdk 1.1.28 → 1.1.33
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 +90 -5
- package/dist/src/sdk/modules/agent.module.js +87 -2
- package/dist/src/sdk/modules/audio.module.d.ts +143 -2
- package/dist/src/sdk/modules/audio.module.js +144 -5
- package/dist/src/sdk/modules/auth.module.d.ts +67 -0
- package/dist/src/sdk/modules/auth.module.js +81 -0
- package/dist/src/sdk/modules/data-strategy.module.d.ts +45 -7
- package/dist/src/sdk/modules/data-strategy.module.js +39 -1
- package/dist/src/sdk/modules/external-integration.module.d.ts +30 -0
- package/dist/src/sdk/modules/external-integration.module.js +30 -0
- package/dist/src/sdk/modules/integration-action.module.d.ts +39 -0
- package/dist/src/sdk/modules/integration-action.module.js +39 -0
- package/dist/src/sdk/modules/log.module.d.ts +4 -4
- package/dist/src/sdk/modules/organization.module.d.ts +62 -3
- package/dist/src/sdk/modules/organization.module.js +61 -2
- package/dist/src/sdk/modules/patient.module.d.ts +5 -2
- package/dist/src/sdk/modules/patient.module.js +5 -2
- package/dist/src/sdk/modules/reports.module.d.ts +4 -4
- package/dist/src/sdk/modules/reports.module.js +6 -6
- package/dist/src/sdk/modules/session/orgadmin-session.module.d.ts +46 -1
- package/dist/src/sdk/modules/session/orgadmin-session.module.js +53 -6
- package/dist/src/sdk/modules/session/session.module.d.ts +62 -1
- package/dist/src/sdk/modules/session/session.module.js +64 -1
- package/dist/src/sdk/modules/session/superuser-session.module.d.ts +46 -1
- package/dist/src/sdk/modules/session/superuser-session.module.js +52 -5
- package/dist/src/sdk/modules/session.module.d.ts +142 -3
- package/dist/src/sdk/modules/session.module.js +153 -12
- package/dist/src/sdk/modules/team.module.d.ts +56 -4
- package/dist/src/sdk/modules/team.module.js +54 -6
- package/dist/src/sdk/modules/template.module.d.ts +96 -4
- package/dist/src/sdk/modules/template.module.js +95 -24
- package/dist/src/sdk/modules/transcription-summary.module.d.ts +60 -3
- package/dist/src/sdk/modules/transcription-summary.module.js +60 -7
- package/dist/src/sdk/modules/user.module.d.ts +127 -0
- package/dist/src/sdk/modules/user.module.js +136 -1
- package/dist/src/sdk/modules/websocket.module.d.ts +25 -8
- package/dist/src/sdk/modules/websocket.module.js +23 -6
- package/dist/src/sdk/modules/workflow.module.d.ts +39 -0
- package/dist/src/sdk/modules/workflow.module.js +39 -0
- package/dist/src/sdk/sdk.d.ts +23 -29
- package/dist/src/sdk/sdk.js +14 -44
- package/dist/src/sdk/types/agent.types.d.ts +3 -0
- package/dist/src/sdk/types/audio.types.d.ts +8 -9
- package/dist/src/sdk/types/data-strategy.types.d.ts +3 -0
- package/dist/src/sdk/types/external-integration.types.d.ts +6 -0
- package/dist/src/sdk/types/log.types.d.ts +2 -21
- package/dist/src/sdk/types/patient.types.d.ts +2 -3
- package/dist/src/sdk/types/reports.types.d.ts +1 -1
- package/dist/src/sdk/types/session.types.d.ts +8 -8
- package/dist/src/sdk/types/team.types.d.ts +4 -3
- package/dist/src/sdk/types/template.types.d.ts +15 -7
- package/dist/src/sdk/types/user.types.d.ts +6 -0
- package/dist/src/sdk/types/websocket.types.d.ts +4 -10
- package/dist/src/sdk/urls.d.ts +2 -4
- package/dist/src/sdk/urls.js +2 -5
- package/dist/src/sdk/whio-orgadmin-sdk.d.ts +9 -7
- package/dist/src/sdk/whio-orgadmin-sdk.js +10 -0
- package/dist/src/sdk/whio-sdk.d.ts +15 -8
- package/dist/src/sdk/whio-sdk.js +46 -18
- package/dist/src/sdk/whio-superuser-sdk.d.ts +14 -16
- package/dist/src/sdk/whio-superuser-sdk.js +11 -16
- package/dist/src/sdk/whio-teamadmin-sdk.d.ts +4 -8
- package/dist/src/sdk/whio-teamadmin-sdk.js +1 -18
- package/package.json +1 -1
- package/src/sdk/modules/agent.module.ts +94 -9
- package/src/sdk/modules/audio.module.ts +146 -8
- package/src/sdk/modules/auth.module.ts +88 -0
- package/src/sdk/modules/data-strategy.module.ts +51 -13
- package/src/sdk/modules/external-integration.module.ts +30 -0
- package/src/sdk/modules/integration-action.module.ts +39 -0
- package/src/sdk/modules/log.module.ts +4 -4
- package/src/sdk/modules/organization.module.ts +64 -5
- package/src/sdk/modules/patient.module.ts +5 -2
- package/src/sdk/modules/reports.module.ts +6 -6
- package/src/sdk/modules/session/orgadmin-session.module.ts +53 -7
- package/src/sdk/modules/session/session.module.ts +64 -2
- package/src/sdk/modules/session/superuser-session.module.ts +52 -6
- package/src/sdk/modules/session.module.ts +155 -15
- package/src/sdk/modules/team.module.ts +58 -9
- package/src/sdk/modules/template.module.ts +95 -32
- package/src/sdk/modules/transcription-summary.module.ts +62 -8
- package/src/sdk/modules/user.module.ts +135 -2
- package/src/sdk/modules/websocket.module.ts +26 -8
- package/src/sdk/modules/workflow.module.ts +39 -0
- package/src/sdk/sdk.ts +12 -37
- package/src/sdk/types/agent.types.ts +5 -0
- package/src/sdk/types/audio.types.ts +8 -10
- package/src/sdk/types/data-strategy.types.ts +3 -0
- package/src/sdk/types/external-integration.types.ts +6 -0
- package/src/sdk/types/log.types.ts +4 -23
- package/src/sdk/types/patient.types.ts +2 -3
- package/src/sdk/types/reports.types.ts +1 -1
- package/src/sdk/types/session.types.ts +8 -8
- package/src/sdk/types/team.types.ts +5 -3
- package/src/sdk/types/template.types.ts +18 -7
- package/src/sdk/types/user.types.ts +6 -0
- package/src/sdk/types/websocket.types.ts +8 -7
- package/src/sdk/urls.ts +3 -8
- package/src/sdk/whio-orgadmin-sdk.ts +8 -0
- package/src/sdk/whio-sdk.ts +39 -16
- package/src/sdk/whio-superuser-sdk.ts +9 -16
- package/src/sdk/whio-teamadmin-sdk.ts +1 -16
- package/tsconfig.json +1 -1
- package/src/sdk/modules/debug.module.ts +0 -44
|
@@ -16,55 +16,120 @@ export class AudioModule extends BaseClient {
|
|
|
16
16
|
// AUDIO FILE METHODS
|
|
17
17
|
// ======================
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Upload an audio file to a session via multipart form data.
|
|
21
|
+
*
|
|
22
|
+
* @param sessionId - UUID of the session to attach the audio file to.
|
|
23
|
+
* @param file - The audio file or blob to upload.
|
|
24
|
+
* @param fileName - Optional file name to send with the upload.
|
|
25
|
+
* @param onProgress - Optional callback invoked with the upload percentage (0-100).
|
|
26
|
+
* @returns The created audio file record.
|
|
27
|
+
*/
|
|
19
28
|
public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, onProgress?: (percentage: number) => void): Promise<AudioFile> {
|
|
20
29
|
const formData = new FormData();
|
|
21
30
|
formData.append('file', file, fileName);
|
|
22
31
|
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, onProgress);
|
|
23
32
|
}
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Upload an audio file to a session and queue it for transcription.
|
|
36
|
+
*
|
|
37
|
+
* @param sessionId - UUID of the session to attach the audio file to.
|
|
38
|
+
* @param file - The audio file or blob to upload.
|
|
39
|
+
* @param options - Optional settings: `fileName` and an `onProgress` callback (0-100).
|
|
40
|
+
* @returns The created audio file record.
|
|
41
|
+
*/
|
|
42
|
+
public async uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: { fileName?: string; onProgress?: (percentage: number) => void }): Promise<AudioFile> {
|
|
26
43
|
const formData = new FormData();
|
|
27
44
|
formData.append('file', file, options?.fileName);
|
|
28
45
|
|
|
29
|
-
if (options?.culturalTranscription) {
|
|
30
|
-
formData.append('cultural_transcription', options.culturalTranscription);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
46
|
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, options?.onProgress);
|
|
34
47
|
}
|
|
35
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Retrieve the current user's audio files.
|
|
51
|
+
*
|
|
52
|
+
* @returns An array of audio files belonging to the current user.
|
|
53
|
+
*/
|
|
36
54
|
public async getMyAudioFiles(): Promise<AudioFile[]> {
|
|
37
55
|
return this.request<AudioFile[]>(`${urls.audioFiles}/my-files`, 'GET');
|
|
38
56
|
}
|
|
39
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve all audio files accessible to the current user.
|
|
60
|
+
*
|
|
61
|
+
* @returns An array of audio files.
|
|
62
|
+
*/
|
|
40
63
|
public async getAllAudioFiles(): Promise<AudioFile[]> {
|
|
41
64
|
return this.request<AudioFile[]>(`${urls.audioFiles}/all`, 'GET');
|
|
42
65
|
}
|
|
43
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Retrieve all audio files belonging to the current user's organization.
|
|
69
|
+
*
|
|
70
|
+
* @returns An array of audio files.
|
|
71
|
+
*/
|
|
44
72
|
public async getOrganizationAudioFiles(): Promise<AudioFile[]> {
|
|
45
73
|
return this.request<AudioFile[]>(`${urls.audioFiles}/organization`, 'GET');
|
|
46
74
|
}
|
|
47
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve all audio files for a given session.
|
|
78
|
+
*
|
|
79
|
+
* @param sessionId - UUID of the session.
|
|
80
|
+
* @returns An array of audio files for the session.
|
|
81
|
+
*/
|
|
48
82
|
public async getAudioFilesBySession(sessionId: string): Promise<AudioFile[]> {
|
|
49
83
|
return this.request<AudioFile[]>(`${urls.audioFiles}/session/${sessionId}`, 'GET');
|
|
50
84
|
}
|
|
51
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Retrieve a single audio file by id.
|
|
88
|
+
*
|
|
89
|
+
* @param id - UUID of the audio file.
|
|
90
|
+
* @returns The requested audio file.
|
|
91
|
+
*/
|
|
52
92
|
public async getAudioFile(id: string): Promise<AudioFile> {
|
|
53
93
|
return this.request<AudioFile>(`${urls.audioFiles}/${id}`, 'GET');
|
|
54
94
|
}
|
|
55
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Update an audio file's metadata.
|
|
98
|
+
*
|
|
99
|
+
* @param id - UUID of the audio file to update.
|
|
100
|
+
* @param updates - Fields to update (transcription URL and/or status).
|
|
101
|
+
* @returns The updated audio file.
|
|
102
|
+
*/
|
|
56
103
|
public async updateAudioFile(id: string, updates: UpdateAudioFileDto): Promise<AudioFile> {
|
|
57
104
|
return this.request<AudioFile>(`${urls.audioFiles}/${id}`, 'PATCH', updates);
|
|
58
105
|
}
|
|
59
106
|
|
|
60
|
-
|
|
61
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Delete an audio file by id.
|
|
109
|
+
*
|
|
110
|
+
* @param id - UUID of the audio file to delete.
|
|
111
|
+
* @returns The deleted audio file record.
|
|
112
|
+
*/
|
|
113
|
+
public async deleteAudioFile(id: string): Promise<AudioFile> {
|
|
114
|
+
return this.request<AudioFile>(`${urls.audioFiles}/${id}`, 'DELETE');
|
|
62
115
|
}
|
|
63
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Download an audio file as a blob.
|
|
119
|
+
*
|
|
120
|
+
* @param id - UUID of the audio file to download.
|
|
121
|
+
* @returns The audio file contents as a Blob.
|
|
122
|
+
*/
|
|
64
123
|
public async downloadAudioFile(id: string): Promise<Blob> {
|
|
65
124
|
return this.downloadRequest(`${urls.audioFiles}/${id}/download`);
|
|
66
125
|
}
|
|
67
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Download an audio file and return an object URL pointing to it.
|
|
129
|
+
*
|
|
130
|
+
* @param id - UUID of the audio file to download.
|
|
131
|
+
* @returns An object URL referencing the downloaded blob.
|
|
132
|
+
*/
|
|
68
133
|
public async downloadAudioFileAsUrl(id: string): Promise<string> {
|
|
69
134
|
const blob = await this.downloadAudioFile(id);
|
|
70
135
|
return URL.createObjectURL(blob);
|
|
@@ -74,16 +139,31 @@ export class AudioModule extends BaseClient {
|
|
|
74
139
|
// TRANSCRIPTION QUEUE HELPER METHODS
|
|
75
140
|
// ======================
|
|
76
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Retrieve the current user's audio files that have finished transcription.
|
|
144
|
+
*
|
|
145
|
+
* @returns An array of transcribed audio files.
|
|
146
|
+
*/
|
|
77
147
|
public async getTranscribedAudioFiles(): Promise<AudioFile[]> {
|
|
78
148
|
const audioFiles = await this.getMyAudioFiles();
|
|
79
|
-
return audioFiles.filter(file => file.status === AudioFileStatus.TRANSCRIBED
|
|
149
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.TRANSCRIBED);
|
|
80
150
|
}
|
|
81
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Retrieve the current user's audio files that are currently processing.
|
|
154
|
+
*
|
|
155
|
+
* @returns An array of processing audio files.
|
|
156
|
+
*/
|
|
82
157
|
public async getProcessingAudioFiles(): Promise<AudioFile[]> {
|
|
83
158
|
const audioFiles = await this.getMyAudioFiles();
|
|
84
159
|
return audioFiles.filter(file => file.status === AudioFileStatus.PROCESSING);
|
|
85
160
|
}
|
|
86
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Retrieve the current user's audio files that failed processing.
|
|
164
|
+
*
|
|
165
|
+
* @returns An array of failed audio files.
|
|
166
|
+
*/
|
|
87
167
|
public async getFailedAudioFiles(): Promise<AudioFile[]> {
|
|
88
168
|
const audioFiles = await this.getMyAudioFiles();
|
|
89
169
|
return audioFiles.filter(file => file.status === AudioFileStatus.FAILED);
|
|
@@ -93,34 +173,83 @@ export class AudioModule extends BaseClient {
|
|
|
93
173
|
// BASE64 AUDIO FILE METHODS
|
|
94
174
|
// ======================
|
|
95
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Create a base64 audio file record.
|
|
178
|
+
*
|
|
179
|
+
* @param dto - The session id and initial base64 audio chunks.
|
|
180
|
+
* @returns The created base64 audio file.
|
|
181
|
+
*/
|
|
96
182
|
public async createBase64AudioFile(dto: CreateBase64AudioFileDto): Promise<Base64AudioFile> {
|
|
97
183
|
return this.request<Base64AudioFile>(`${urls.audioFiles}/base64`, 'POST', dto);
|
|
98
184
|
}
|
|
99
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Retrieve all base64 audio files accessible to the current user.
|
|
188
|
+
*
|
|
189
|
+
* @returns An array of base64 audio files.
|
|
190
|
+
*/
|
|
100
191
|
public async getAllBase64AudioFiles(): Promise<Base64AudioFile[]> {
|
|
101
192
|
return this.request<Base64AudioFile[]>(`${urls.audioFiles}/base64/all`, 'GET');
|
|
102
193
|
}
|
|
103
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Retrieve base64 audio files for a given session.
|
|
197
|
+
*
|
|
198
|
+
* @param sessionId - UUID of the session.
|
|
199
|
+
* @returns An array of base64 audio files for the session.
|
|
200
|
+
*/
|
|
104
201
|
public async getBase64AudioFilesBySession(sessionId: string): Promise<Base64AudioFile[]> {
|
|
105
202
|
return this.request<Base64AudioFile[]>(`${urls.audioFiles}/base64/session/${sessionId}`, 'GET');
|
|
106
203
|
}
|
|
107
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Retrieve a single base64 audio file by id.
|
|
207
|
+
*
|
|
208
|
+
* @param id - UUID of the base64 audio file.
|
|
209
|
+
* @returns The requested base64 audio file.
|
|
210
|
+
*/
|
|
108
211
|
public async getBase64AudioFile(id: string): Promise<Base64AudioFile> {
|
|
109
212
|
return this.request<Base64AudioFile>(`${urls.audioFiles}/base64/${id}`, 'GET');
|
|
110
213
|
}
|
|
111
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Update a base64 audio file record.
|
|
217
|
+
*
|
|
218
|
+
* @param id - UUID of the base64 audio file to update.
|
|
219
|
+
* @param updates - Fields to update (session id and/or audio chunks).
|
|
220
|
+
* @returns The updated base64 audio file.
|
|
221
|
+
*/
|
|
112
222
|
public async updateBase64AudioFile(id: string, updates: UpdateBase64AudioFileDto): Promise<Base64AudioFile> {
|
|
113
223
|
return this.request<Base64AudioFile>(`${urls.audioFiles}/base64/${id}`, 'PATCH', updates);
|
|
114
224
|
}
|
|
115
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Delete a base64 audio file by id.
|
|
228
|
+
*
|
|
229
|
+
* @param id - UUID of the base64 audio file to delete.
|
|
230
|
+
* @returns A promise that resolves once the record is deleted.
|
|
231
|
+
*/
|
|
116
232
|
public async deleteBase64AudioFile(id: string): Promise<void> {
|
|
117
233
|
await this.request(`${urls.audioFiles}/base64/${id}`, 'DELETE');
|
|
118
234
|
}
|
|
119
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Append base64 audio chunks to a session's base64 audio file.
|
|
238
|
+
*
|
|
239
|
+
* @param sessionId - UUID of the session.
|
|
240
|
+
* @param base64Chunks - The base64-encoded audio chunks to append.
|
|
241
|
+
* @returns The count of chunks now stored.
|
|
242
|
+
*/
|
|
120
243
|
public async addBase64Chunk(sessionId: string, base64Chunks: string[]): Promise<AddBase64ChunkResponse> {
|
|
121
244
|
return this.request<AddBase64ChunkResponse>(`${urls.audioFiles}/base64/add-chunk/${sessionId}`, 'POST', { base64Chunks });
|
|
122
245
|
}
|
|
123
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Queue a session's accumulated base64 audio for transcription.
|
|
249
|
+
*
|
|
250
|
+
* @param sessionId - UUID of the session to transcribe.
|
|
251
|
+
* @returns An object indicating whether queuing succeeded.
|
|
252
|
+
*/
|
|
124
253
|
public async queueSessionBase64AudioForTranscription(sessionId: string): Promise<{ success: boolean }> {
|
|
125
254
|
return this.request<{ success: boolean }>(`${urls.audioFiles}/session/${sessionId}/transcribe`, 'POST');
|
|
126
255
|
}
|
|
@@ -129,6 +258,15 @@ export class AudioModule extends BaseClient {
|
|
|
129
258
|
// DIRECT TRANSCRIPTION METHODS
|
|
130
259
|
// ======================
|
|
131
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Transcribe an audio file directly without persisting it to a session.
|
|
263
|
+
*
|
|
264
|
+
* @param file - The audio file or blob to transcribe.
|
|
265
|
+
* @param fileName - Optional file name to send with the upload.
|
|
266
|
+
* @param useFineTuned - Optional flag to use the fine-tuned transcription model.
|
|
267
|
+
* @param onProgress - Optional callback invoked with the upload percentage (0-100).
|
|
268
|
+
* @returns An object containing the resulting transcription text.
|
|
269
|
+
*/
|
|
132
270
|
public async transcribeAudioFileDirect(file: File | Blob, fileName?: string, useFineTuned?: boolean, onProgress?: (percentage: number) => void): Promise<{ transcription?: string }> {
|
|
133
271
|
const formData = new FormData();
|
|
134
272
|
formData.append('file', file, fileName);
|
|
@@ -3,6 +3,12 @@ import { LoginCredentials, LoginResponse, PasswordChangeResponse, ChangePassword
|
|
|
3
3
|
import urls from '../urls';
|
|
4
4
|
|
|
5
5
|
export class AuthModule extends BaseClient {
|
|
6
|
+
/**
|
|
7
|
+
* Authenticate with email and password and persist the resulting session.
|
|
8
|
+
*
|
|
9
|
+
* @param credentials - The login credentials (email and password).
|
|
10
|
+
* @returns The login response including access/refresh tokens and the user.
|
|
11
|
+
*/
|
|
6
12
|
public async login(credentials: LoginCredentials): Promise<LoginResponse> {
|
|
7
13
|
try {
|
|
8
14
|
const response = await this.request<LoginResponse>(
|
|
@@ -20,6 +26,12 @@ export class AuthModule extends BaseClient {
|
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Request a one-time login code be sent to the given email address.
|
|
31
|
+
*
|
|
32
|
+
* @param email - The email address to send the login code to.
|
|
33
|
+
* @returns A confirmation message.
|
|
34
|
+
*/
|
|
23
35
|
public async requestLoginCode(email: string): Promise<{ message: string }> {
|
|
24
36
|
return this.request<{ message: string }>(
|
|
25
37
|
'/auth/request-login-code',
|
|
@@ -30,6 +42,13 @@ export class AuthModule extends BaseClient {
|
|
|
30
42
|
);
|
|
31
43
|
}
|
|
32
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Authenticate with an email and one-time login code and persist the session.
|
|
47
|
+
*
|
|
48
|
+
* @param email - The email address the code was sent to.
|
|
49
|
+
* @param code - The one-time login code.
|
|
50
|
+
* @returns The login response including access/refresh tokens and the user.
|
|
51
|
+
*/
|
|
33
52
|
public async loginWithCode(email: string, code: string): Promise<LoginResponse> {
|
|
34
53
|
try {
|
|
35
54
|
const response = await this.request<LoginResponse>(
|
|
@@ -47,14 +66,76 @@ export class AuthModule extends BaseClient {
|
|
|
47
66
|
}
|
|
48
67
|
}
|
|
49
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Authenticate with a Microsoft (Entra ID) token and persist the session.
|
|
71
|
+
*
|
|
72
|
+
* The client runs the Microsoft sign-in itself and passes the resulting Entra
|
|
73
|
+
* ID token here; the backend verifies it and mints the normal app session. The
|
|
74
|
+
* Microsoft identity must already be linked to a local account (see
|
|
75
|
+
* {@link connectEntra}) - an unlinked customer-app token is rejected.
|
|
76
|
+
*
|
|
77
|
+
* @param idToken - The Entra ID token obtained from the Microsoft sign-in.
|
|
78
|
+
* @returns The login response including access/refresh tokens and the user.
|
|
79
|
+
*/
|
|
80
|
+
public async loginWithEntra(idToken: string): Promise<LoginResponse> {
|
|
81
|
+
try {
|
|
82
|
+
const response = await this.request<LoginResponse>(
|
|
83
|
+
urls.entra,
|
|
84
|
+
'POST',
|
|
85
|
+
{ idToken },
|
|
86
|
+
{},
|
|
87
|
+
true
|
|
88
|
+
);
|
|
89
|
+
await this.updateAuthState(response);
|
|
90
|
+
return response;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
await this.clearAuth();
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Link the authenticated user's account to their Microsoft (Entra ID) identity
|
|
99
|
+
* so future {@link loginWithEntra} calls resolve them by their Microsoft oid.
|
|
100
|
+
*
|
|
101
|
+
* Requires an active session - the bearer token is attached automatically.
|
|
102
|
+
*
|
|
103
|
+
* @param idToken - The Entra ID token obtained from the Microsoft sign-in.
|
|
104
|
+
* @returns A confirmation message.
|
|
105
|
+
*/
|
|
106
|
+
public async connectEntra(idToken: string): Promise<{ message: string }> {
|
|
107
|
+
return this.request<{ message: string }>(
|
|
108
|
+
urls.entraConnect,
|
|
109
|
+
'POST',
|
|
110
|
+
{ idToken }
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Clear the current session and any persisted authentication state.
|
|
116
|
+
*
|
|
117
|
+
* @returns A promise that resolves when the session is cleared.
|
|
118
|
+
*/
|
|
50
119
|
public async logout(): Promise<void> {
|
|
51
120
|
await this.clearAuth();
|
|
52
121
|
}
|
|
53
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Fetch the authenticated user's profile.
|
|
125
|
+
*
|
|
126
|
+
* @returns The current user.
|
|
127
|
+
*/
|
|
54
128
|
public async getProfile(): Promise<User> {
|
|
55
129
|
return this.request<User>(urls.profile, 'GET');
|
|
56
130
|
}
|
|
57
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Change the authenticated user's password.
|
|
134
|
+
*
|
|
135
|
+
* @param currentPassword - The user's current password.
|
|
136
|
+
* @param newPassword - The new password to set.
|
|
137
|
+
* @returns The password change response.
|
|
138
|
+
*/
|
|
58
139
|
public async changePassword(currentPassword: string, newPassword: string): Promise<PasswordChangeResponse> {
|
|
59
140
|
const dto: ChangePasswordDto = {
|
|
60
141
|
currentPassword,
|
|
@@ -63,6 +144,13 @@ export class AuthModule extends BaseClient {
|
|
|
63
144
|
return this.request<PasswordChangeResponse>(urls.changePassword, 'PATCH', dto);
|
|
64
145
|
}
|
|
65
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Change another user's password as an administrator.
|
|
149
|
+
*
|
|
150
|
+
* @param userId - UUID of the user whose password is being changed.
|
|
151
|
+
* @param newPassword - The new password to set.
|
|
152
|
+
* @returns The password change response.
|
|
153
|
+
*/
|
|
66
154
|
public async adminChangePassword(userId: string, newPassword: string): Promise<PasswordChangeResponse> {
|
|
67
155
|
const dto: AdminChangePasswordDto = {
|
|
68
156
|
userId,
|
|
@@ -1,38 +1,76 @@
|
|
|
1
1
|
import { BaseClient } from './base-client';
|
|
2
|
-
import { DataStrategy, CreateDataStrategyDto, UpdateDataStrategyDto } from '../types';
|
|
2
|
+
import { DataStrategy, DataStrategyWithOrganization, CreateDataStrategyDto, UpdateDataStrategyDto } from '../types';
|
|
3
3
|
import urls from '../urls';
|
|
4
4
|
|
|
5
5
|
export class DataStrategyModule extends BaseClient {
|
|
6
|
+
/**
|
|
7
|
+
* Create a data strategy for an organization.
|
|
8
|
+
*
|
|
9
|
+
* @param organizationId - Optional organization UUID; defaults to the current user's organization.
|
|
10
|
+
* @param options - Optional retention settings for the data strategy.
|
|
11
|
+
* @returns The created data strategy with its organization populated.
|
|
12
|
+
*/
|
|
6
13
|
public async createDataStrategy(
|
|
7
14
|
organizationId?: string,
|
|
8
15
|
options?: Omit<CreateDataStrategyDto, 'organizationId'>,
|
|
9
|
-
): Promise<
|
|
16
|
+
): Promise<DataStrategyWithOrganization> {
|
|
10
17
|
const dto: CreateDataStrategyDto = {
|
|
11
18
|
organizationId: organizationId || this.user!.organizationId,
|
|
12
19
|
...options,
|
|
13
20
|
};
|
|
14
|
-
return this.request<
|
|
21
|
+
return this.request<DataStrategyWithOrganization>(urls.dataStrategies, 'POST', dto);
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
/**
|
|
25
|
+
* List data strategies, optionally filtered by organization.
|
|
26
|
+
*
|
|
27
|
+
* @param organizationId - Optional organization UUID to filter by.
|
|
28
|
+
* @returns An array of data strategies, each with its organization populated.
|
|
29
|
+
*/
|
|
30
|
+
public async getDataStrategies(organizationId?: string): Promise<DataStrategyWithOrganization[]> {
|
|
18
31
|
const params = organizationId ? `?organizationId=${organizationId}` : '';
|
|
19
|
-
return this.request<
|
|
32
|
+
return this.request<DataStrategyWithOrganization[]>(`${urls.dataStrategies}${params}`, 'GET');
|
|
20
33
|
}
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Get a single data strategy by id.
|
|
37
|
+
*
|
|
38
|
+
* @param id - UUID of the data strategy.
|
|
39
|
+
* @returns The data strategy with its organization populated.
|
|
40
|
+
*/
|
|
41
|
+
public async getDataStrategy(id: string): Promise<DataStrategyWithOrganization> {
|
|
42
|
+
return this.request<DataStrategyWithOrganization>(`${urls.dataStrategies}/${id}`, 'GET');
|
|
24
43
|
}
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Get the data strategy for a specific organization.
|
|
47
|
+
*
|
|
48
|
+
* @param organizationId - Optional organization UUID; defaults to the current user's organization.
|
|
49
|
+
* @returns The data strategy with its organization populated.
|
|
50
|
+
*/
|
|
51
|
+
public async getDataStrategyByOrganization(organizationId?: string): Promise<DataStrategyWithOrganization> {
|
|
27
52
|
const orgId = organizationId || this.user!.organizationId;
|
|
28
|
-
return this.request<
|
|
53
|
+
return this.request<DataStrategyWithOrganization>(`${urls.dataStrategies}?organizationId=${orgId}`, 'GET');
|
|
29
54
|
}
|
|
30
55
|
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Update a data strategy.
|
|
58
|
+
*
|
|
59
|
+
* @param id - UUID of the data strategy to update.
|
|
60
|
+
* @param data - The retention settings to update.
|
|
61
|
+
* @returns The updated data strategy with its organization populated.
|
|
62
|
+
*/
|
|
63
|
+
public async updateDataStrategy(id: string, data: UpdateDataStrategyDto): Promise<DataStrategyWithOrganization> {
|
|
64
|
+
return this.request<DataStrategyWithOrganization>(`${urls.dataStrategies}/${id}`, 'PATCH', data);
|
|
33
65
|
}
|
|
34
66
|
|
|
35
|
-
|
|
36
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Delete a data strategy.
|
|
69
|
+
*
|
|
70
|
+
* @param id - UUID of the data strategy to delete.
|
|
71
|
+
* @returns The deleted data strategy entity.
|
|
72
|
+
*/
|
|
73
|
+
public async deleteDataStrategy(id: string): Promise<DataStrategy> {
|
|
74
|
+
return this.request<DataStrategy>(`${urls.dataStrategies}/${id}`, 'DELETE');
|
|
37
75
|
}
|
|
38
76
|
}
|
|
@@ -7,6 +7,12 @@ import {
|
|
|
7
7
|
import urls from '../urls';
|
|
8
8
|
|
|
9
9
|
export class ExternalIntegrationModule extends BaseClient {
|
|
10
|
+
/**
|
|
11
|
+
* Create an external integration. The `apiKey` is sent as plaintext and stored encrypted at rest.
|
|
12
|
+
*
|
|
13
|
+
* @param data - The external integration payload (endpoints, apiKey, headerName, etc.).
|
|
14
|
+
* @returns The created external integration (its `apiKey` is returned masked).
|
|
15
|
+
*/
|
|
10
16
|
public async createExternalIntegration(
|
|
11
17
|
data: CreateExternalIntegrationDto,
|
|
12
18
|
): Promise<ExternalIntegration> {
|
|
@@ -17,6 +23,11 @@ export class ExternalIntegrationModule extends BaseClient {
|
|
|
17
23
|
);
|
|
18
24
|
}
|
|
19
25
|
|
|
26
|
+
/**
|
|
27
|
+
* List all external integrations.
|
|
28
|
+
*
|
|
29
|
+
* @returns An array of external integrations (each `apiKey` is returned masked).
|
|
30
|
+
*/
|
|
20
31
|
public async getExternalIntegrations(): Promise<ExternalIntegration[]> {
|
|
21
32
|
return this.request<ExternalIntegration[]>(
|
|
22
33
|
urls.externalIntegrations,
|
|
@@ -24,6 +35,12 @@ export class ExternalIntegrationModule extends BaseClient {
|
|
|
24
35
|
);
|
|
25
36
|
}
|
|
26
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Get a single external integration by id.
|
|
40
|
+
*
|
|
41
|
+
* @param id - UUID of the external integration.
|
|
42
|
+
* @returns The external integration (its `apiKey` is returned masked).
|
|
43
|
+
*/
|
|
27
44
|
public async getExternalIntegration(
|
|
28
45
|
id: string,
|
|
29
46
|
): Promise<ExternalIntegration> {
|
|
@@ -33,6 +50,13 @@ export class ExternalIntegrationModule extends BaseClient {
|
|
|
33
50
|
);
|
|
34
51
|
}
|
|
35
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Update an external integration. A supplied `apiKey` is sent as plaintext and stored encrypted at rest.
|
|
55
|
+
*
|
|
56
|
+
* @param id - UUID of the external integration to update.
|
|
57
|
+
* @param data - The fields to update.
|
|
58
|
+
* @returns The updated external integration (its `apiKey` is returned masked).
|
|
59
|
+
*/
|
|
36
60
|
public async updateExternalIntegration(
|
|
37
61
|
id: string,
|
|
38
62
|
data: UpdateExternalIntegrationDto,
|
|
@@ -44,6 +68,12 @@ export class ExternalIntegrationModule extends BaseClient {
|
|
|
44
68
|
);
|
|
45
69
|
}
|
|
46
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Delete an external integration.
|
|
73
|
+
*
|
|
74
|
+
* @param id - UUID of the external integration to delete.
|
|
75
|
+
* @returns A promise that resolves when the integration has been deleted.
|
|
76
|
+
*/
|
|
47
77
|
public async deleteExternalIntegration(id: string): Promise<void> {
|
|
48
78
|
await this.request(`${urls.externalIntegrations}/${id}`, 'DELETE');
|
|
49
79
|
}
|
|
@@ -3,6 +3,13 @@ import { IntegrationAction, CreateIntegrationActionDto, UpdateIntegrationActionD
|
|
|
3
3
|
import urls from '../urls';
|
|
4
4
|
|
|
5
5
|
export class IntegrationActionModule extends BaseClient {
|
|
6
|
+
/**
|
|
7
|
+
* Create an integration action for an organization.
|
|
8
|
+
*
|
|
9
|
+
* @param name - Display name of the integration action.
|
|
10
|
+
* @param organizationId - Optional organization UUID; defaults to the current user's organization.
|
|
11
|
+
* @returns The created integration action.
|
|
12
|
+
*/
|
|
6
13
|
public async createIntegrationAction(name: string, organizationId?: string): Promise<IntegrationAction> {
|
|
7
14
|
const dto: CreateIntegrationActionDto = {
|
|
8
15
|
name,
|
|
@@ -11,20 +18,46 @@ export class IntegrationActionModule extends BaseClient {
|
|
|
11
18
|
return this.request<IntegrationAction>(urls.integrationActions, 'POST', dto);
|
|
12
19
|
}
|
|
13
20
|
|
|
21
|
+
/**
|
|
22
|
+
* List integration actions, optionally filtered by organization.
|
|
23
|
+
*
|
|
24
|
+
* @param organizationId - Optional organization UUID to filter by.
|
|
25
|
+
* @returns An array of integration actions.
|
|
26
|
+
*/
|
|
14
27
|
public async getIntegrationActions(organizationId?: string): Promise<IntegrationAction[]> {
|
|
15
28
|
const params = organizationId ? `?organizationId=${organizationId}` : '';
|
|
16
29
|
return this.request<IntegrationAction[]>(`${urls.integrationActions}${params}`, 'GET');
|
|
17
30
|
}
|
|
18
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Get a single integration action by id.
|
|
34
|
+
*
|
|
35
|
+
* @param id - UUID of the integration action.
|
|
36
|
+
* @returns The integration action.
|
|
37
|
+
*/
|
|
19
38
|
public async getIntegrationAction(id: string): Promise<IntegrationAction> {
|
|
20
39
|
return this.request<IntegrationAction>(`${urls.integrationActions}/${id}`, 'GET');
|
|
21
40
|
}
|
|
22
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Get the integration actions for a specific organization.
|
|
44
|
+
*
|
|
45
|
+
* @param organizationId - Optional organization UUID; defaults to the current user's organization.
|
|
46
|
+
* @returns An array of integration actions for the organization.
|
|
47
|
+
*/
|
|
23
48
|
public async getIntegrationActionsByOrganization(organizationId?: string): Promise<IntegrationAction[]> {
|
|
24
49
|
const orgId = organizationId || this.user!.organizationId;
|
|
25
50
|
return this.request<IntegrationAction[]>(`${urls.integrationActions}?organizationId=${orgId}`, 'GET');
|
|
26
51
|
}
|
|
27
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Update an integration action.
|
|
55
|
+
*
|
|
56
|
+
* @param id - UUID of the integration action to update.
|
|
57
|
+
* @param name - New display name of the integration action.
|
|
58
|
+
* @param organizationId - Optional organization UUID; defaults to the current user's organization.
|
|
59
|
+
* @returns The updated integration action.
|
|
60
|
+
*/
|
|
28
61
|
public async updateIntegrationAction(id: string, name: string, organizationId?: string): Promise<IntegrationAction> {
|
|
29
62
|
const dto: UpdateIntegrationActionDto = {
|
|
30
63
|
name,
|
|
@@ -33,6 +66,12 @@ export class IntegrationActionModule extends BaseClient {
|
|
|
33
66
|
return this.request<IntegrationAction>(`${urls.integrationActions}/${id}`, 'PATCH', dto);
|
|
34
67
|
}
|
|
35
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Delete an integration action.
|
|
71
|
+
*
|
|
72
|
+
* @param id - UUID of the integration action to delete.
|
|
73
|
+
* @returns A promise that resolves when the integration action has been deleted.
|
|
74
|
+
*/
|
|
36
75
|
public async deleteIntegrationAction(id: string): Promise<void> {
|
|
37
76
|
await this.request(`${urls.integrationActions}/${id}`, 'DELETE');
|
|
38
77
|
}
|
|
@@ -100,7 +100,7 @@ export class LogModule extends BaseClient {
|
|
|
100
100
|
/**
|
|
101
101
|
* Convenience methods for different log levels
|
|
102
102
|
*/
|
|
103
|
-
public async logInfo(message: string, context?: string, action?: string, data?:
|
|
103
|
+
public async logInfo(message: string, context?: string, action?: string, data?: Record<string, unknown>): Promise<Log> {
|
|
104
104
|
return this.createLog({
|
|
105
105
|
level: 'info',
|
|
106
106
|
message,
|
|
@@ -110,7 +110,7 @@ export class LogModule extends BaseClient {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
public async logError(message: string, context?: string, action?: string, data?:
|
|
113
|
+
public async logError(message: string, context?: string, action?: string, data?: Record<string, unknown>): Promise<Log> {
|
|
114
114
|
return this.createLog({
|
|
115
115
|
level: 'error',
|
|
116
116
|
message,
|
|
@@ -120,7 +120,7 @@ export class LogModule extends BaseClient {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
public async logWarn(message: string, context?: string, action?: string, data?:
|
|
123
|
+
public async logWarn(message: string, context?: string, action?: string, data?: Record<string, unknown>): Promise<Log> {
|
|
124
124
|
return this.createLog({
|
|
125
125
|
level: 'warn',
|
|
126
126
|
message,
|
|
@@ -130,7 +130,7 @@ export class LogModule extends BaseClient {
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
public async logDebug(message: string, context?: string, action?: string, data?:
|
|
133
|
+
public async logDebug(message: string, context?: string, action?: string, data?: Record<string, unknown>): Promise<Log> {
|
|
134
134
|
return this.createLog({
|
|
135
135
|
level: 'debug',
|
|
136
136
|
message,
|