whio-api-sdk 1.1.28 → 1.1.29

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.
Files changed (102) hide show
  1. package/dist/src/sdk/modules/agent.module.d.ts +90 -5
  2. package/dist/src/sdk/modules/agent.module.js +87 -2
  3. package/dist/src/sdk/modules/audio.module.d.ts +143 -2
  4. package/dist/src/sdk/modules/audio.module.js +144 -5
  5. package/dist/src/sdk/modules/auth.module.d.ts +43 -0
  6. package/dist/src/sdk/modules/auth.module.js +43 -0
  7. package/dist/src/sdk/modules/data-strategy.module.d.ts +45 -7
  8. package/dist/src/sdk/modules/data-strategy.module.js +39 -1
  9. package/dist/src/sdk/modules/external-integration.module.d.ts +30 -0
  10. package/dist/src/sdk/modules/external-integration.module.js +30 -0
  11. package/dist/src/sdk/modules/integration-action.module.d.ts +39 -0
  12. package/dist/src/sdk/modules/integration-action.module.js +39 -0
  13. package/dist/src/sdk/modules/log.module.d.ts +4 -4
  14. package/dist/src/sdk/modules/organization.module.d.ts +62 -3
  15. package/dist/src/sdk/modules/organization.module.js +61 -2
  16. package/dist/src/sdk/modules/patient.module.d.ts +5 -2
  17. package/dist/src/sdk/modules/patient.module.js +5 -2
  18. package/dist/src/sdk/modules/reports.module.d.ts +4 -4
  19. package/dist/src/sdk/modules/reports.module.js +6 -6
  20. package/dist/src/sdk/modules/session/orgadmin-session.module.d.ts +46 -1
  21. package/dist/src/sdk/modules/session/orgadmin-session.module.js +53 -6
  22. package/dist/src/sdk/modules/session/session.module.d.ts +62 -1
  23. package/dist/src/sdk/modules/session/session.module.js +64 -1
  24. package/dist/src/sdk/modules/session/superuser-session.module.d.ts +46 -1
  25. package/dist/src/sdk/modules/session/superuser-session.module.js +52 -5
  26. package/dist/src/sdk/modules/session.module.d.ts +142 -3
  27. package/dist/src/sdk/modules/session.module.js +153 -12
  28. package/dist/src/sdk/modules/team.module.d.ts +56 -4
  29. package/dist/src/sdk/modules/team.module.js +54 -6
  30. package/dist/src/sdk/modules/template.module.d.ts +96 -4
  31. package/dist/src/sdk/modules/template.module.js +95 -24
  32. package/dist/src/sdk/modules/transcription-summary.module.d.ts +60 -3
  33. package/dist/src/sdk/modules/transcription-summary.module.js +60 -7
  34. package/dist/src/sdk/modules/user.module.d.ts +106 -0
  35. package/dist/src/sdk/modules/user.module.js +107 -1
  36. package/dist/src/sdk/modules/websocket.module.d.ts +25 -8
  37. package/dist/src/sdk/modules/websocket.module.js +23 -6
  38. package/dist/src/sdk/modules/workflow.module.d.ts +39 -0
  39. package/dist/src/sdk/modules/workflow.module.js +39 -0
  40. package/dist/src/sdk/sdk.d.ts +19 -29
  41. package/dist/src/sdk/sdk.js +1 -44
  42. package/dist/src/sdk/types/agent.types.d.ts +3 -0
  43. package/dist/src/sdk/types/audio.types.d.ts +8 -9
  44. package/dist/src/sdk/types/data-strategy.types.d.ts +3 -0
  45. package/dist/src/sdk/types/external-integration.types.d.ts +6 -0
  46. package/dist/src/sdk/types/log.types.d.ts +2 -21
  47. package/dist/src/sdk/types/patient.types.d.ts +2 -3
  48. package/dist/src/sdk/types/reports.types.d.ts +1 -1
  49. package/dist/src/sdk/types/session.types.d.ts +8 -8
  50. package/dist/src/sdk/types/team.types.d.ts +4 -3
  51. package/dist/src/sdk/types/template.types.d.ts +15 -7
  52. package/dist/src/sdk/types/user.types.d.ts +6 -0
  53. package/dist/src/sdk/types/websocket.types.d.ts +4 -10
  54. package/dist/src/sdk/urls.d.ts +0 -4
  55. package/dist/src/sdk/urls.js +0 -5
  56. package/dist/src/sdk/whio-orgadmin-sdk.d.ts +7 -7
  57. package/dist/src/sdk/whio-sdk.d.ts +11 -8
  58. package/dist/src/sdk/whio-sdk.js +34 -18
  59. package/dist/src/sdk/whio-superuser-sdk.d.ts +12 -16
  60. package/dist/src/sdk/whio-superuser-sdk.js +1 -16
  61. package/dist/src/sdk/whio-teamadmin-sdk.d.ts +4 -8
  62. package/dist/src/sdk/whio-teamadmin-sdk.js +1 -18
  63. package/package.json +1 -1
  64. package/src/sdk/modules/agent.module.ts +94 -9
  65. package/src/sdk/modules/audio.module.ts +146 -8
  66. package/src/sdk/modules/auth.module.ts +43 -0
  67. package/src/sdk/modules/data-strategy.module.ts +51 -13
  68. package/src/sdk/modules/external-integration.module.ts +30 -0
  69. package/src/sdk/modules/integration-action.module.ts +39 -0
  70. package/src/sdk/modules/log.module.ts +4 -4
  71. package/src/sdk/modules/organization.module.ts +64 -5
  72. package/src/sdk/modules/patient.module.ts +5 -2
  73. package/src/sdk/modules/reports.module.ts +6 -6
  74. package/src/sdk/modules/session/orgadmin-session.module.ts +53 -7
  75. package/src/sdk/modules/session/session.module.ts +64 -2
  76. package/src/sdk/modules/session/superuser-session.module.ts +52 -6
  77. package/src/sdk/modules/session.module.ts +155 -15
  78. package/src/sdk/modules/team.module.ts +58 -9
  79. package/src/sdk/modules/template.module.ts +95 -32
  80. package/src/sdk/modules/transcription-summary.module.ts +62 -8
  81. package/src/sdk/modules/user.module.ts +108 -2
  82. package/src/sdk/modules/websocket.module.ts +26 -8
  83. package/src/sdk/modules/workflow.module.ts +39 -0
  84. package/src/sdk/sdk.ts +1 -37
  85. package/src/sdk/types/agent.types.ts +5 -0
  86. package/src/sdk/types/audio.types.ts +8 -10
  87. package/src/sdk/types/data-strategy.types.ts +3 -0
  88. package/src/sdk/types/external-integration.types.ts +6 -0
  89. package/src/sdk/types/log.types.ts +4 -23
  90. package/src/sdk/types/patient.types.ts +2 -3
  91. package/src/sdk/types/reports.types.ts +1 -1
  92. package/src/sdk/types/session.types.ts +8 -8
  93. package/src/sdk/types/team.types.ts +5 -3
  94. package/src/sdk/types/template.types.ts +18 -7
  95. package/src/sdk/types/user.types.ts +6 -0
  96. package/src/sdk/types/websocket.types.ts +8 -7
  97. package/src/sdk/urls.ts +0 -7
  98. package/src/sdk/whio-sdk.ts +29 -16
  99. package/src/sdk/whio-superuser-sdk.ts +1 -16
  100. package/src/sdk/whio-teamadmin-sdk.ts +1 -16
  101. package/tsconfig.json +1 -1
  102. package/src/sdk/modules/debug.module.ts +0 -44
@@ -6,7 +6,6 @@ import {
6
6
  UpdateTemplateDto,
7
7
  CreateTemplateCategoryDto,
8
8
  UpdateTemplateCategoryDto,
9
- TranscriptionAudioUploadResponse,
10
9
  SummaryQueueType,
11
10
  } from '../types';
12
11
  import urls from '../urls';
@@ -16,6 +15,17 @@ export class TemplateModule extends BaseClient {
16
15
  // TEMPLATE METHODS
17
16
  // ======================
18
17
 
18
+ /**
19
+ * Create a template for the current user's organization, defaulting to the first category if none is given.
20
+ *
21
+ * @param title - Title of the template.
22
+ * @param content - Body content of the template.
23
+ * @param categoryId - Optional category UUID; the first available category is used when omitted.
24
+ * @param workflowId - Optional workflow UUID to associate with the template.
25
+ * @param agentId - Optional agent UUID to associate with the template.
26
+ * @param summaryQueueType - Optional queue type (PRIMARY or SECONDARY) for generated summaries.
27
+ * @returns The created template.
28
+ */
19
29
  public async createTemplate(title: string, content: string, categoryId?: string, workflowId?: string, agentId?: string, summaryQueueType?: SummaryQueueType): Promise<Template> {
20
30
  let finalCategoryId = categoryId;
21
31
  if (!finalCategoryId) {
@@ -43,6 +53,17 @@ export class TemplateModule extends BaseClient {
43
53
  return this.request<Template>(urls.templates, 'POST', createTemplateDto);
44
54
  }
45
55
 
56
+ /**
57
+ * Update an existing template.
58
+ *
59
+ * @param title - New title of the template.
60
+ * @param content - New body content of the template.
61
+ * @param id - UUID of the template to update.
62
+ * @param workflowId - Optional workflow UUID to associate with the template.
63
+ * @param agentId - Optional agent UUID to associate with the template.
64
+ * @param summaryQueueType - Optional queue type (PRIMARY or SECONDARY), or null to clear it.
65
+ * @returns The updated template.
66
+ */
46
67
  public async updateTemplate(title: string, content: string, id: string, workflowId?: string, agentId?: string, summaryQueueType?: SummaryQueueType | null): Promise<Template> {
47
68
  const templateDto: UpdateTemplateDto = {
48
69
  title,
@@ -56,18 +77,40 @@ export class TemplateModule extends BaseClient {
56
77
  return this.request<Template>(`${urls.templates}/${id}`, 'PATCH', templateDto);
57
78
  }
58
79
 
80
+ /**
81
+ * Retrieve all templates accessible to the current user.
82
+ *
83
+ * @returns An array of templates.
84
+ */
59
85
  public async getTemplates(): Promise<Template[]> {
60
86
  return this.request<Template[]>(urls.templates, 'GET');
61
87
  }
62
88
 
89
+ /**
90
+ * Retrieve all templates belonging to the current user's organization.
91
+ *
92
+ * @returns An array of templates.
93
+ */
63
94
  public async getTemplatesByOrganization(): Promise<Template[]> {
64
95
  return this.request<Template[]>(`${urls.templates}/organization`, 'GET');
65
96
  }
66
97
 
98
+ /**
99
+ * Retrieve a single template by id.
100
+ *
101
+ * @param id - UUID of the template.
102
+ * @returns The requested template.
103
+ */
67
104
  public async getTemplate(id: string): Promise<Template> {
68
105
  return this.request<Template>(`${urls.templates}/${id}`, 'GET');
69
106
  }
70
107
 
108
+ /**
109
+ * Delete a template by id.
110
+ *
111
+ * @param id - UUID of the template to delete.
112
+ * @returns A promise that resolves once the template is deleted.
113
+ */
71
114
  public async deleteTemplate(id: string): Promise<void> {
72
115
  await this.request(`${urls.templates}/${id}`, 'DELETE');
73
116
  }
@@ -76,6 +119,13 @@ export class TemplateModule extends BaseClient {
76
119
  // TEMPLATE INTEGRATION ACTION METHODS
77
120
  // ======================
78
121
 
122
+ /**
123
+ * Replace the full set of integration actions linked to a template.
124
+ *
125
+ * @param templateId - UUID of the template.
126
+ * @param integrationActionIds - The complete list of integration action UUIDs to set.
127
+ * @returns The updated template.
128
+ */
79
129
  public async setTemplateIntegrationActions(templateId: string, integrationActionIds: string[]): Promise<Template> {
80
130
  return this.request<Template>(
81
131
  `${urls.templates}/${templateId}/integration-actions`,
@@ -84,6 +134,13 @@ export class TemplateModule extends BaseClient {
84
134
  );
85
135
  }
86
136
 
137
+ /**
138
+ * Add integration actions to a template without removing existing ones.
139
+ *
140
+ * @param templateId - UUID of the template.
141
+ * @param integrationActionIds - The integration action UUIDs to add.
142
+ * @returns The updated template.
143
+ */
87
144
  public async addTemplateIntegrationActions(templateId: string, integrationActionIds: string[]): Promise<Template> {
88
145
  return this.request<Template>(
89
146
  `${urls.templates}/${templateId}/integration-actions`,
@@ -92,6 +149,13 @@ export class TemplateModule extends BaseClient {
92
149
  );
93
150
  }
94
151
 
152
+ /**
153
+ * Remove integration actions from a template.
154
+ *
155
+ * @param templateId - UUID of the template.
156
+ * @param integrationActionIds - The integration action UUIDs to remove.
157
+ * @returns The updated template.
158
+ */
95
159
  public async removeTemplateIntegrationActions(templateId: string, integrationActionIds: string[]): Promise<Template> {
96
160
  return this.request<Template>(
97
161
  `${urls.templates}/${templateId}/integration-actions`,
@@ -104,56 +168,55 @@ export class TemplateModule extends BaseClient {
104
168
  // TEMPLATE CATEGORY METHODS
105
169
  // ======================
106
170
 
171
+ /**
172
+ * Retrieve all template categories.
173
+ *
174
+ * @returns An array of template categories.
175
+ */
107
176
  public async getTemplateCategories(): Promise<TemplateCategory[]> {
108
177
  return this.request<TemplateCategory[]>(urls.templateCategories, 'GET');
109
178
  }
110
179
 
180
+ /**
181
+ * Retrieve a single template category by id.
182
+ *
183
+ * @param id - UUID of the template category.
184
+ * @returns The requested template category.
185
+ */
111
186
  public async getTemplateCategory(id: string): Promise<TemplateCategory> {
112
187
  return this.request<TemplateCategory>(`${urls.templateCategories}/${id}`, 'GET');
113
188
  }
114
189
 
190
+ /**
191
+ * Create a template category.
192
+ *
193
+ * @param name - Name of the new category.
194
+ * @returns The created template category.
195
+ */
115
196
  public async createTemplateCategory(name: string): Promise<TemplateCategory> {
116
197
  const dto: CreateTemplateCategoryDto = { name };
117
198
  return this.request<TemplateCategory>(urls.templateCategories, 'POST', dto);
118
199
  }
119
200
 
201
+ /**
202
+ * Update a template category's name.
203
+ *
204
+ * @param id - UUID of the template category to update.
205
+ * @param name - New name for the category.
206
+ * @returns The updated template category.
207
+ */
120
208
  public async updateTemplateCategory(id: string, name: string): Promise<TemplateCategory> {
121
209
  const dto: UpdateTemplateCategoryDto = { name };
122
210
  return this.request<TemplateCategory>(`${urls.templateCategories}/${id}`, 'PATCH', dto);
123
211
  }
124
212
 
213
+ /**
214
+ * Delete a template category by id.
215
+ *
216
+ * @param id - UUID of the template category to delete.
217
+ * @returns A promise that resolves once the category is deleted.
218
+ */
125
219
  public async deleteTemplateCategory(id: string): Promise<void> {
126
220
  await this.request(`${urls.templateCategories}/${id}`, 'DELETE');
127
221
  }
128
-
129
- // ======================
130
- // AUDIO UPLOAD METHODS (for transcription)
131
- // ======================
132
-
133
- public async uploadLargeAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<string> {
134
- const uploadId: string = await this.fileUploadRequest(urls.uploadAudioLarge, formData, {}, onProgress);
135
- const uploadIds: string = await this.storage!.getItem('uploadIds') || '[]';
136
- const uploadIdsArray = JSON.parse(uploadIds);
137
- await this.storage!.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
138
- return uploadId;
139
- }
140
-
141
- public async uploadAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<TranscriptionAudioUploadResponse | null> {
142
- const data: TranscriptionAudioUploadResponse = await this.fileUploadRequest(
143
- urls.uploadAudio,
144
- formData,
145
- {},
146
- onProgress
147
- );
148
- return data;
149
- }
150
-
151
- public async transcribeBase64Audio(base64String: string): Promise<string> {
152
- const transcript = await this.request<any>(
153
- urls.transcribeBase64Audio,
154
- 'POST',
155
- { base64Audio: base64String }
156
- );
157
- return transcript.transcript;
158
- }
159
222
  }
@@ -2,6 +2,7 @@ import { BaseClient } from './base-client';
2
2
  import {
3
3
  TranscriptionSummary,
4
4
  GenerateTranscriptionSummaryDto,
5
+ GenerateSummaryResponse,
5
6
  CreateTranscriptionSummaryDto,
6
7
  UpdateTranscriptionSummaryDto,
7
8
  CloneTranscriptionSummaryDto,
@@ -13,48 +14,95 @@ export class TranscriptionSummaryModule extends BaseClient {
13
14
  // TRANSCRIPTION SUMMARY METHODS
14
15
  // ======================
15
16
 
16
- public async generateTranscriptionSummary(templateId: string, sessionId: string): Promise<TranscriptionSummary> {
17
+ /**
18
+ * Queue a transcription summary for generation, or update the template if no transcription exists yet.
19
+ *
20
+ * @param templateId - UUID of the template to apply.
21
+ * @param sessionId - UUID of the session whose transcription is summarised.
22
+ * @returns Either a queued-job response (`{ message, jobId, sessionId }`) or a template-updated
23
+ * response (`{ message, sessionId }`).
24
+ */
25
+ public async generateTranscriptionSummary(templateId: string, sessionId: string): Promise<GenerateSummaryResponse> {
17
26
  const user = this.validateUser();
18
27
  const generateSummaryDto: GenerateTranscriptionSummaryDto = {
19
28
  templateId,
20
29
  userId: user.id,
21
30
  sessionId: sessionId,
22
31
  };
23
- const transcriptionSummary: TranscriptionSummary = await this.request(
32
+ return this.request<GenerateSummaryResponse>(
24
33
  urls.transcriptionSummary,
25
34
  'POST',
26
35
  generateSummaryDto
27
36
  );
28
- return transcriptionSummary;
29
37
  }
30
38
 
39
+ /**
40
+ * Create a transcription summary record; the current user is supplied server-side.
41
+ *
42
+ * @param dto - Summary fields (template, content, optional session and anonymised transcript).
43
+ * @returns The created transcription summary.
44
+ */
31
45
  public async createTranscriptionSummary(dto: Omit<CreateTranscriptionSummaryDto, 'userId'>): Promise<TranscriptionSummary> {
32
46
  return this.request<TranscriptionSummary>(urls.transcriptionSummaryCreate, 'POST', dto);
33
47
  }
34
48
 
35
- public async updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary> {
36
- const updateSummaryDto: UpdateTranscriptionSummaryDto = {
37
- content,
38
- };
39
- return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'PATCH', updateSummaryDto);
49
+ /**
50
+ * Update a transcription summary.
51
+ *
52
+ * @param id - UUID of the transcription summary to update.
53
+ * @param dto - Fields to update (content, anonymised transcript, and/or template).
54
+ * @returns The updated transcription summary.
55
+ */
56
+ public async updateTranscriptionSummary(id: string, dto: UpdateTranscriptionSummaryDto): Promise<TranscriptionSummary> {
57
+ return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'PATCH', dto);
40
58
  }
41
59
 
60
+ /**
61
+ * Retrieve all transcription summaries accessible to the current user.
62
+ *
63
+ * @returns An array of transcription summaries.
64
+ */
42
65
  public async getTranscriptionSummaries(): Promise<TranscriptionSummary[]> {
43
66
  return this.request<TranscriptionSummary[]>(urls.transcriptionSummaries, 'GET');
44
67
  }
45
68
 
69
+ /**
70
+ * Retrieve a single transcription summary by id.
71
+ *
72
+ * @param id - UUID of the transcription summary.
73
+ * @returns The requested transcription summary.
74
+ */
46
75
  public async getTranscriptionSummary(id: string): Promise<TranscriptionSummary> {
47
76
  return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'GET');
48
77
  }
49
78
 
79
+ /**
80
+ * Retrieve all transcription summaries belonging to a specific user.
81
+ *
82
+ * @param userId - UUID of the user whose summaries are returned.
83
+ * @returns An array of transcription summaries.
84
+ */
50
85
  public async getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]> {
51
86
  return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
52
87
  }
53
88
 
89
+ /**
90
+ * Retrieve all transcription summaries belonging to a specific organization.
91
+ *
92
+ * @param organizationId - UUID of the organization whose summaries are returned.
93
+ * @returns An array of transcription summaries.
94
+ */
54
95
  public async getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]> {
55
96
  return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
56
97
  }
57
98
 
99
+ /**
100
+ * Clone an existing transcription summary with new content.
101
+ *
102
+ * @param id - UUID of the transcription summary to clone.
103
+ * @param content - Content for the cloned summary.
104
+ * @returns The newly created clone.
105
+ */
58
106
  public async cloneTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary> {
59
107
  const cloneDto: CloneTranscriptionSummaryDto = {
60
108
  content,
@@ -62,6 +110,12 @@ export class TranscriptionSummaryModule extends BaseClient {
62
110
  return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}/clone`, 'POST', cloneDto);
63
111
  }
64
112
 
113
+ /**
114
+ * Delete a transcription summary by id.
115
+ *
116
+ * @param id - UUID of the transcription summary to delete.
117
+ * @returns A promise that resolves once the summary is deleted.
118
+ */
65
119
  public async deleteTranscriptionSummary(id: string): Promise<void> {
66
120
  await this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
67
121
  }
@@ -1,8 +1,17 @@
1
1
  import { BaseClient } from './base-client';
2
- import { User, CreateUserDto, UpdateUserDto, UpdateUserNamesDto, AddExpoPushTokenDto, Organization, AssignOrganizationRoleDto, OrganizationRoleType } from '../types';
2
+ import { User, CreateUserDto, UpdateUserDto, UpdateUserNamesDto, AddExpoPushTokenDto, Organization, AssignOrganizationRoleDto, OrganizationRoleType, UserOrganizationRole } from '../types';
3
3
  import urls from '../urls';
4
4
 
5
5
  export class UserModule extends BaseClient {
6
+ /**
7
+ * Create a user in the current user's organization.
8
+ *
9
+ * @param firstName - First name of the new user.
10
+ * @param lastName - Last name of the new user.
11
+ * @param email - Email address of the new user.
12
+ * @param password - Initial password for the new user.
13
+ * @returns The newly created user.
14
+ */
6
15
  public async createUser(
7
16
  firstName: string,
8
17
  lastName: string,
@@ -35,69 +44,166 @@ export class UserModule extends BaseClient {
35
44
  userId: userId,
36
45
  organizationRoleId: orgRoleEditor.id,
37
46
  };
38
- this.request(urls.userOrganizationRoles, 'POST', assignRoleDto);
47
+ await this.request<UserOrganizationRole>(urls.userOrganizationRoles, 'POST', assignRoleDto);
39
48
  const userWithOrgRole = await this.request<User>(`${urls.user}/${userId}`, 'GET');
40
49
  return userWithOrgRole;
41
50
  }
42
51
 
52
+ /**
53
+ * Assign the editor organization role to a user.
54
+ *
55
+ * @param userId - UUID of the user to assign the role to.
56
+ * @param organizationId - Optional organization UUID; defaults to the current user's organization.
57
+ * @returns The user with the assigned organization role.
58
+ */
43
59
  public async assignEditorToRoleToUser(userId: string, organizationId?: string): Promise<User> {
44
60
  return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR, organizationId);
45
61
  }
46
62
 
63
+ /**
64
+ * Assign the admin organization role to a user.
65
+ *
66
+ * @param userId - UUID of the user to assign the role to.
67
+ * @param organizationId - Optional organization UUID; defaults to the current user's organization.
68
+ * @returns The user with the assigned organization role.
69
+ */
47
70
  public async assignAdminToRoleToUser(userId: string, organizationId?: string): Promise<User> {
48
71
  return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN, organizationId);
49
72
  }
50
73
 
74
+ /**
75
+ * Assign the disabled organization role to a user.
76
+ *
77
+ * @param userId - UUID of the user to assign the role to.
78
+ * @param organizationId - Optional organization UUID; defaults to the current user's organization.
79
+ * @returns The user with the assigned organization role.
80
+ */
51
81
  public async assignDisabledToRoleToUser(userId: string, organizationId?: string): Promise<User> {
52
82
  return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
53
83
  }
54
84
 
85
+ /**
86
+ * Remove an organization role from a user.
87
+ *
88
+ * @param userId - UUID of the user.
89
+ * @param organizationRoleId - UUID of the organization role to remove.
90
+ * @returns A promise that resolves when the role is removed.
91
+ */
55
92
  public async removeRoleFromUser(userId: string, organizationRoleId: string): Promise<void> {
56
93
  await this.request(`${urls.userOrganizationRoles}/${userId}/${organizationRoleId}`, 'DELETE');
57
94
  }
58
95
 
96
+ /**
97
+ * Create a user and assign them the editor organization role.
98
+ *
99
+ * @param firstName - First name of the new user.
100
+ * @param lastName - Last name of the new user.
101
+ * @param email - Email address of the new user.
102
+ * @param password - Initial password for the new user.
103
+ * @returns The newly created user with the editor role assigned.
104
+ */
59
105
  public async createEditorUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
60
106
  const user = await this.createUser(firstName, lastName, email, password);
61
107
  const userWithOrgRole = await this.assignEditorToRoleToUser(user.id);
62
108
  return userWithOrgRole;
63
109
  }
64
110
 
111
+ /**
112
+ * Create a user and assign them the admin organization role.
113
+ *
114
+ * @param firstName - First name of the new user.
115
+ * @param lastName - Last name of the new user.
116
+ * @param email - Email address of the new user.
117
+ * @param password - Initial password for the new user.
118
+ * @returns The newly created user with the admin role assigned.
119
+ */
65
120
  public async createAdminUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
66
121
  const user = await this.createUser(firstName, lastName, email, password);
67
122
  const userWithOrgRole = await this.assignAdminToRoleToUser(user.id);
68
123
  return userWithOrgRole;
69
124
  }
70
125
 
126
+ /**
127
+ * Create a user and assign them the disabled organization role.
128
+ *
129
+ * @param firstName - First name of the new user.
130
+ * @param lastName - Last name of the new user.
131
+ * @param email - Email address of the new user.
132
+ * @param password - Initial password for the new user.
133
+ * @returns The newly created user with the disabled role assigned.
134
+ */
71
135
  public async createDisabledUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
72
136
  const user = await this.createUser(firstName, lastName, email, password);
73
137
  const userWithOrgRole = await this.assignDisabledToRoleToUser(user.id);
74
138
  return userWithOrgRole;
75
139
  }
76
140
 
141
+ /**
142
+ * List all users the current user can access.
143
+ *
144
+ * @returns An array of users.
145
+ */
77
146
  public async getUsers(): Promise<User[]> {
78
147
  return this.request<User[]>(urls.users, 'GET');
79
148
  }
80
149
 
150
+ /**
151
+ * Get a single user by ID.
152
+ *
153
+ * @param id - UUID of the user.
154
+ * @returns The requested user.
155
+ */
81
156
  public async getUser(id: string): Promise<User> {
82
157
  return this.request<User>(`${urls.users}/${id}`, 'GET');
83
158
  }
84
159
 
160
+ /**
161
+ * List all users belonging to an organization.
162
+ *
163
+ * @param organizationId - UUID of the organization.
164
+ * @returns An array of users in the organization.
165
+ */
85
166
  public async getUsersByOrganization(organizationId: string): Promise<User[]> {
86
167
  return this.request<User[]>(`${urls.users}/organization/${organizationId}`, 'GET');
87
168
  }
88
169
 
170
+ /**
171
+ * Update a user by ID.
172
+ *
173
+ * @param id - UUID of the user to update.
174
+ * @param data - Fields to update on the user.
175
+ * @returns The updated user.
176
+ */
89
177
  public async updateUser(id: string, data: UpdateUserDto): Promise<User> {
90
178
  return this.request<User>(`${urls.users}/${id}`, 'PATCH', data);
91
179
  }
92
180
 
181
+ /**
182
+ * Delete a user by ID.
183
+ *
184
+ * @param id - UUID of the user to delete.
185
+ * @returns A promise that resolves when the user is deleted.
186
+ */
93
187
  public async deleteUser(id: string): Promise<void> {
94
188
  await this.request(`${urls.users}/${id}`, 'DELETE');
95
189
  }
96
190
 
191
+ /**
192
+ * Update the current user's first and/or last name.
193
+ *
194
+ * @param data - The name fields to update.
195
+ * @returns The updated user.
196
+ */
97
197
  public async updateNames(data: UpdateUserNamesDto): Promise<User> {
98
198
  return this.request<User>(`${urls.users}/names`, 'PATCH', data);
99
199
  }
100
200
 
201
+ /**
202
+ * Register an Expo push token for the current user.
203
+ *
204
+ * @param token - The Expo push token to add.
205
+ * @returns A confirmation message.
206
+ */
101
207
  public async addExpoPushToken(token: string): Promise<{ message: string }> {
102
208
  const dto: AddExpoPushTokenDto = { token };
103
209
  return this.request<{ message: string }>(`${urls.users}/expo-push-token`, 'POST', dto);
@@ -6,7 +6,8 @@ import {
6
6
  WebSocketEvents,
7
7
  AudioChunkPayload,
8
8
  AudioChunkOptions,
9
- AudioStreamingOptions
9
+ AudioStreamingOptions,
10
+ SDKConfig
10
11
  } from '../types';
11
12
 
12
13
  /**
@@ -23,7 +24,7 @@ export class WebSocketModule extends BaseClient {
23
24
  private connectionStats: WebSocketConnectionStats;
24
25
  private eventHandlers: Map<keyof WebSocketEvents, Function[]> = new Map();
25
26
 
26
- constructor(baseConfig: any) {
27
+ constructor(baseConfig: SDKConfig) {
27
28
  super(baseConfig);
28
29
 
29
30
  const wsConfig = baseConfig.websocket || {};
@@ -136,14 +137,18 @@ export class WebSocketModule extends BaseClient {
136
137
  }
137
138
 
138
139
  /**
139
- * Check if WebSocket is connected
140
+ * Check if the WebSocket is currently connected.
141
+ *
142
+ * @returns `true` when the underlying socket is connected, otherwise `false`.
140
143
  */
141
144
  public isConnected(): boolean {
142
145
  return this.socket?.connected || false;
143
146
  }
144
147
 
145
148
  /**
146
- * Get connection statistics
149
+ * Get a snapshot of the current connection statistics.
150
+ *
151
+ * @returns A copy of the connection stats (connection state, reconnect count, last connect/disconnect times).
147
152
  */
148
153
  public getConnectionStats(): WebSocketConnectionStats {
149
154
  return { ...this.connectionStats };
@@ -185,7 +190,12 @@ export class WebSocketModule extends BaseClient {
185
190
  }
186
191
 
187
192
  /**
188
- * Stream multiple audio chunks
193
+ * Stream multiple audio chunks sequentially, with an optional delay between each.
194
+ *
195
+ * @param sessionId - Session ID to associate the chunks with.
196
+ * @param audioChunks - Ordered array of Base64 encoded audio data.
197
+ * @param options - Streaming options (e.g. `delayBetweenChunks` in ms, default 100).
198
+ * @throws Error if the WebSocket is not connected after token validation.
189
199
  */
190
200
  public async streamAudioChunks(
191
201
  sessionId: string,
@@ -213,7 +223,10 @@ export class WebSocketModule extends BaseClient {
213
223
  }
214
224
 
215
225
  /**
216
- * Add event listener
226
+ * Register an event listener for a WebSocket event.
227
+ *
228
+ * @param event - The event name to listen for.
229
+ * @param handler - Callback invoked with the event payload.
217
230
  */
218
231
  public on<K extends keyof WebSocketEvents>(
219
232
  event: K,
@@ -226,7 +239,10 @@ export class WebSocketModule extends BaseClient {
226
239
  }
227
240
 
228
241
  /**
229
- * Remove event listener
242
+ * Remove a previously registered event listener.
243
+ *
244
+ * @param event - The event name the handler was registered for.
245
+ * @param handler - The exact handler reference to remove.
230
246
  */
231
247
  public off<K extends keyof WebSocketEvents>(
232
248
  event: K,
@@ -384,7 +400,9 @@ export class WebSocketModule extends BaseClient {
384
400
  }
385
401
 
386
402
  /**
387
- * Clean up resources
403
+ * Disconnect the socket and clear all registered event handlers.
404
+ *
405
+ * Call this when the client is no longer needed to release resources.
388
406
  */
389
407
  public destroy(): void {
390
408
  this.disconnect();
@@ -3,6 +3,13 @@ import { Workflow, CreateWorkflowDto, UpdateWorkflowDto } from '../types';
3
3
  import urls from '../urls';
4
4
 
5
5
  export class WorkflowModule extends BaseClient {
6
+ /**
7
+ * Create a workflow for an organization.
8
+ *
9
+ * @param name - Display name of the workflow.
10
+ * @param organizationId - Optional organization UUID; defaults to the current user's organization.
11
+ * @returns The created workflow.
12
+ */
6
13
  public async createWorkflow(name: string, organizationId?: string): Promise<Workflow> {
7
14
  const dto: CreateWorkflowDto = {
8
15
  name,
@@ -11,20 +18,46 @@ export class WorkflowModule extends BaseClient {
11
18
  return this.request<Workflow>(urls.workflows, 'POST', dto);
12
19
  }
13
20
 
21
+ /**
22
+ * List workflows, optionally filtered by organization.
23
+ *
24
+ * @param organizationId - Optional organization UUID to filter by.
25
+ * @returns An array of workflows.
26
+ */
14
27
  public async getWorkflows(organizationId?: string): Promise<Workflow[]> {
15
28
  const params = organizationId ? `?organizationId=${organizationId}` : '';
16
29
  return this.request<Workflow[]>(`${urls.workflows}${params}`, 'GET');
17
30
  }
18
31
 
32
+ /**
33
+ * Get a single workflow by id.
34
+ *
35
+ * @param id - UUID of the workflow.
36
+ * @returns The workflow.
37
+ */
19
38
  public async getWorkflow(id: string): Promise<Workflow> {
20
39
  return this.request<Workflow>(`${urls.workflows}/${id}`, 'GET');
21
40
  }
22
41
 
42
+ /**
43
+ * Get the workflows for a specific organization.
44
+ *
45
+ * @param organizationId - Optional organization UUID; defaults to the current user's organization.
46
+ * @returns An array of workflows for the organization.
47
+ */
23
48
  public async getWorkflowsByOrganization(organizationId?: string): Promise<Workflow[]> {
24
49
  const orgId = organizationId || this.user!.organizationId;
25
50
  return this.request<Workflow[]>(`${urls.workflows}?organizationId=${orgId}`, 'GET');
26
51
  }
27
52
 
53
+ /**
54
+ * Update a workflow.
55
+ *
56
+ * @param id - UUID of the workflow to update.
57
+ * @param name - New display name of the workflow.
58
+ * @param organizationId - Optional organization UUID; defaults to the current user's organization.
59
+ * @returns The updated workflow.
60
+ */
28
61
  public async updateWorkflow(id: string, name: string, organizationId?: string): Promise<Workflow> {
29
62
  const dto: UpdateWorkflowDto = {
30
63
  name,
@@ -33,6 +66,12 @@ export class WorkflowModule extends BaseClient {
33
66
  return this.request<Workflow>(`${urls.workflows}/${id}`, 'PATCH', dto);
34
67
  }
35
68
 
69
+ /**
70
+ * Delete a workflow.
71
+ *
72
+ * @param id - UUID of the workflow to delete.
73
+ * @returns A promise that resolves when the workflow has been deleted.
74
+ */
36
75
  public async deleteWorkflow(id: string): Promise<void> {
37
76
  await this.request(`${urls.workflows}/${id}`, 'DELETE');
38
77
  }