whio-api-sdk 1.0.172 โ†’ 1.0.174

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.
@@ -1,276 +0,0 @@
1
- // Comprehensive SDK test against localhost:3000
2
- import { ApiSDK } from './dist/index.js';
3
-
4
- class TestStorage {
5
- constructor() {
6
- this.storage = new Map();
7
- }
8
-
9
- async getItem(key) {
10
- return this.storage.get(key) || null;
11
- }
12
-
13
- async setItem(key, value) {
14
- this.storage.set(key, value);
15
- }
16
-
17
- async removeItem(key) {
18
- this.storage.delete(key);
19
- }
20
- }
21
-
22
- async function runTests() {
23
- console.log('๐Ÿงช Starting comprehensive SDK tests against localhost:3000\n');
24
-
25
- const storage = new TestStorage();
26
- const sdk = new ApiSDK({
27
- baseUrl: 'http://localhost:3000',
28
- storage
29
- });
30
-
31
- let testResults = {
32
- passed: 0,
33
- failed: 0,
34
- errors: []
35
- };
36
-
37
- async function test(name, testFn) {
38
- try {
39
- console.log(`๐Ÿ“‹ Testing: ${name}`);
40
- await testFn();
41
- console.log(`โœ… ${name} - PASSED\n`);
42
- testResults.passed++;
43
- } catch (error) {
44
- console.log(`โŒ ${name} - FAILED: ${error.message}\n`);
45
- testResults.failed++;
46
- testResults.errors.push({ test: name, error: error.message });
47
- }
48
- }
49
-
50
- // Test authentication
51
- await test('Login with credentials', async () => {
52
- const response = await sdk.login({
53
- email: 'test@example.com',
54
- password: 'password'
55
- });
56
-
57
- if (!response.access_token) throw new Error('No access token returned');
58
- if (!response.user) throw new Error('No user returned');
59
- console.log(` User: ${response.user.firstName} ${response.user.lastName}`);
60
- });
61
-
62
- await test('Check authentication status', async () => {
63
- const isAuth = sdk.isAuthenticated();
64
- if (!isAuth) throw new Error('Should be authenticated after login');
65
- });
66
-
67
- await test('Get current user', async () => {
68
- const user = sdk.getCurrentUser();
69
- if (!user) throw new Error('Current user should be available');
70
- console.log(` Current user: ${user.firstName} ${user.lastName}`);
71
- });
72
-
73
- await test('Get profile', async () => {
74
- const profile = await sdk.getProfile();
75
- if (!profile.id) throw new Error('Profile should have ID');
76
- console.log(` Profile ID: ${profile.id}`);
77
- });
78
-
79
- // Test organization methods
80
- await test('Get organizations', async () => {
81
- const orgs = await sdk.getOrganizations();
82
- if (!Array.isArray(orgs)) throw new Error('Should return array of organizations');
83
- console.log(` Found ${orgs.length} organizations`);
84
- });
85
-
86
- await test('Get current organization', async () => {
87
- const user = sdk.getCurrentUser();
88
- const org = await sdk.getOrganization(user.organizationId);
89
- if (!org.id) throw new Error('Organization should have ID');
90
- console.log(` Organization: ${org.name}`);
91
- });
92
-
93
- // Test user methods
94
- await test('Get users', async () => {
95
- const users = await sdk.getUsers();
96
- if (!Array.isArray(users)) throw new Error('Should return array of users');
97
- console.log(` Found ${users.length} users`);
98
- });
99
-
100
- await test('Get users by organization', async () => {
101
- const user = sdk.getCurrentUser();
102
- const users = await sdk.getUsersByOrganization(user.organizationId);
103
- if (!Array.isArray(users)) throw new Error('Should return array of users');
104
- console.log(` Found ${users.length} users in organization`);
105
- });
106
-
107
- // Test team methods
108
- await test('Get teams', async () => {
109
- const teams = await sdk.getTeams();
110
- if (!Array.isArray(teams)) throw new Error('Should return array of teams');
111
- console.log(` Found ${teams.length} teams`);
112
- });
113
-
114
- await test('Create team', async () => {
115
- const team = await sdk.createTeam('Test Team', 'A test team for SDK testing');
116
- if (!team.id) throw new Error('Created team should have ID');
117
- console.log(` Created team: ${team.name} (ID: ${team.id})`);
118
-
119
- // Store team ID for cleanup
120
- global.testTeamId = team.id;
121
- });
122
-
123
- // Test template category methods
124
- await test('Get template categories', async () => {
125
- const categories = await sdk.getTemplateCategories();
126
- if (!Array.isArray(categories)) throw new Error('Should return array of categories');
127
- console.log(` Found ${categories.length} template categories`);
128
- });
129
-
130
- await test('Create template category', async () => {
131
- const category = await sdk.createTemplateCategory('Test Category');
132
- if (!category.id) throw new Error('Created category should have ID');
133
- console.log(` Created category: ${category.name} (ID: ${category.id})`);
134
-
135
- global.testCategoryId = category.id;
136
- });
137
-
138
- // Test template methods
139
- await test('Get templates', async () => {
140
- const templates = await sdk.getTemplates();
141
- if (!Array.isArray(templates)) throw new Error('Should return array of templates');
142
- console.log(` Found ${templates.length} templates`);
143
- });
144
-
145
- await test('Create template', async () => {
146
- const template = await sdk.createTemplate(
147
- 'Test Template',
148
- 'This is a test template content',
149
- global.testCategoryId
150
- );
151
- if (!template.id) throw new Error('Created template should have ID');
152
- console.log(` Created template: ${template.title} (ID: ${template.id})`);
153
-
154
- global.testTemplateId = template.id;
155
- });
156
-
157
- await test('Update template', async () => {
158
- const updated = await sdk.updateTemplate(
159
- 'Updated Test Template',
160
- 'Updated test template content',
161
- global.testTemplateId
162
- );
163
- if (updated.title !== 'Updated Test Template') {
164
- throw new Error('Template title should be updated');
165
- }
166
- console.log(` Updated template title: ${updated.title}`);
167
- });
168
-
169
- // Test user template methods
170
- await test('Get user templates', async () => {
171
- const userTemplates = await sdk.getUserTemplates();
172
- if (!Array.isArray(userTemplates)) throw new Error('Should return array of user templates');
173
- console.log(` Found ${userTemplates.length} user templates`);
174
- });
175
-
176
- await test('Create user template', async () => {
177
- const userTemplate = await sdk.createUserTemplate(
178
- 'Test User Template',
179
- 'This is a test user template',
180
- global.testTemplateId
181
- );
182
- if (!userTemplate.id) throw new Error('Created user template should have ID');
183
- console.log(` Created user template: ${userTemplate.title} (ID: ${userTemplate.id})`);
184
-
185
- global.testUserTemplateId = userTemplate.id;
186
- });
187
-
188
- // Test transcription summary methods
189
- await test('Get transcription summaries', async () => {
190
- const summaries = await sdk.getTranscriptionSummaries();
191
- if (!Array.isArray(summaries)) throw new Error('Should return array of summaries');
192
- console.log(` Found ${summaries.length} transcription summaries`);
193
- });
194
-
195
- await test('Generate transcription summary', async () => {
196
- const summary = await sdk.generateTranscriptionSummary(
197
- 'This is a test transcript for testing purposes',
198
- global.testTemplateId
199
- );
200
- if (!summary.id) throw new Error('Generated summary should have ID');
201
- console.log(` Generated summary (ID: ${summary.id})`);
202
-
203
- global.testSummaryId = summary.id;
204
- });
205
-
206
- await test('Update transcription summary', async () => {
207
- const updated = await sdk.updateTranscriptionSummary(
208
- global.testSummaryId,
209
- 'Updated summary content'
210
- );
211
- if (updated.content !== 'Updated summary content') {
212
- throw new Error('Summary content should be updated');
213
- }
214
- console.log(` Updated summary content`);
215
- });
216
-
217
- // Test audio upload (mock file)
218
- await test('Upload audio file', async () => {
219
- const formData = new FormData();
220
- const blob = new Blob(['fake audio data'], { type: 'audio/wav' });
221
- formData.append('audio', blob, 'test.wav');
222
-
223
- try {
224
- const result = await sdk.uploadAudioFile(formData);
225
- console.log(` Upload result: ${result ? 'Success' : 'No response'}`);
226
- } catch (error) {
227
- if (error.message.includes('413') || error.message.includes('file')) {
228
- console.log(` Upload failed as expected (file validation): ${error.message}`);
229
- } else {
230
- throw error;
231
- }
232
- }
233
- });
234
-
235
- // Test base64 audio transcription
236
- await test('Transcribe base64 audio', async () => {
237
- try {
238
- const transcript = await sdk.transcribeBase64Audio('fake-base64-audio-data');
239
- console.log(` Transcript: ${transcript}`);
240
- } catch (error) {
241
- if (error.message.includes('400') || error.message.includes('base64')) {
242
- console.log(` Transcription failed as expected (invalid base64): ${error.message}`);
243
- } else {
244
- throw error;
245
- }
246
- }
247
- });
248
-
249
- // Test logout
250
- await test('Logout', async () => {
251
- await sdk.logout();
252
- const isAuth = sdk.isAuthenticated();
253
- if (isAuth) throw new Error('Should not be authenticated after logout');
254
- });
255
-
256
- // Print test results
257
- console.log('\n๐Ÿ“Š Test Results:');
258
- console.log(`โœ… Passed: ${testResults.passed}`);
259
- console.log(`โŒ Failed: ${testResults.failed}`);
260
- console.log(`๐Ÿ“ˆ Success Rate: ${((testResults.passed / (testResults.passed + testResults.failed)) * 100).toFixed(1)}%`);
261
-
262
- if (testResults.errors.length > 0) {
263
- console.log('\n๐Ÿ’ฅ Errors:');
264
- testResults.errors.forEach(({ test, error }) => {
265
- console.log(` ${test}: ${error}`);
266
- });
267
- }
268
- }
269
-
270
- // Handle process termination
271
- process.on('unhandledRejection', (reason, promise) => {
272
- console.log('Unhandled Rejection at:', promise, 'reason:', reason);
273
- });
274
-
275
- // Run the tests
276
- runTests().catch(console.error);
@@ -1,34 +0,0 @@
1
- // Test file for new password change functionality
2
- import { ApiSDK, ChangePasswordDto, AdminChangePasswordDto, PasswordChangeResponse } from './index';
3
-
4
- // Test function to verify the new methods compile correctly
5
- async function testPasswordChangeMethods() {
6
- const sdk = new ApiSDK({
7
- baseUrl: 'http://localhost:3000/api'
8
- });
9
-
10
- try {
11
- // Test user password change
12
- const changeResponse: PasswordChangeResponse = await sdk.changePassword(
13
- 'currentPassword123',
14
- 'newPassword456'
15
- );
16
- console.log('Change password response:', changeResponse);
17
-
18
- // Test admin password change
19
- const adminChangeResponse: PasswordChangeResponse = await sdk.adminChangePassword(
20
- 'user-uuid-here',
21
- 'newPassword789'
22
- );
23
- console.log('Admin change password response:', adminChangeResponse);
24
-
25
- } catch (error) {
26
- console.error('Password change error:', error);
27
- }
28
- }
29
-
30
- // Export for potential testing
31
- export { testPasswordChangeMethods };
32
-
33
- console.log('Password change methods are available on SDK');
34
- console.log('Methods: changePassword(), adminChangePassword()');
@@ -1,64 +0,0 @@
1
- // Test SDK findAllByOrganization methods
2
- import { ApiSDK } from './index.js';
3
-
4
- async function testSDKFindAllByOrganization() {
5
- console.log('๐Ÿš€ Testing SDK findAllByOrganization methods...\n');
6
-
7
- // Initialize SDK
8
- const sdk = new ApiSDK({
9
- baseUrl: 'http://localhost:3000/api',
10
- storage: {
11
- getItem: (key) => global.storage?.[key] || null,
12
- setItem: (key, value) => {
13
- if (!global.storage) global.storage = {};
14
- global.storage[key] = value;
15
- },
16
- removeItem: (key) => {
17
- if (global.storage) delete global.storage[key];
18
- }
19
- }
20
- });
21
-
22
- try {
23
- // Login
24
- console.log('๐Ÿ” Logging in...');
25
- const loginResponse = await sdk.login({
26
- email: 'rimu.boddy@make.nz',
27
- password: 'cbr400rr'
28
- });
29
-
30
- console.log('โœ… Login successful');
31
- console.log(`User: ${loginResponse.user.email}`);
32
- console.log(`Organization: ${loginResponse.user.organizationId}\n`);
33
-
34
- // Test getTemplatesByOrganization
35
- console.log('๐Ÿงช Testing getTemplatesByOrganization()...');
36
- const templates = await sdk.getTemplatesByOrganization();
37
- console.log('โœ… Templates retrieved successfully');
38
- console.log(`Found ${templates.length} templates for organization:`);
39
- templates.forEach((template, index) => {
40
- console.log(` ${index + 1}. ${template.title} (ID: ${template.id})`);
41
- });
42
-
43
- // Test getUsersByOrganization
44
- console.log('\n๐Ÿงช Testing getUsersByOrganization()...');
45
- const users = await sdk.getUsersByOrganization(loginResponse.user.organizationId);
46
- console.log('โœ… Users retrieved successfully');
47
- console.log(`Found ${users.length} users in organization:`);
48
- users.forEach((user, index) => {
49
- console.log(` ${index + 1}. ${user.email} - ${user.firstName} ${user.lastName}`);
50
- console.log(` Org roles: ${user.organizationRoles?.map(r => r.organizationRole.name).join(', ') || 'None'}`);
51
- });
52
-
53
- console.log('\nโœ… All SDK tests completed successfully!');
54
-
55
- } catch (error) {
56
- console.error('โŒ SDK test failed:', error.message);
57
- if (error.stack) {
58
- console.error('Stack trace:', error.stack);
59
- }
60
- }
61
- }
62
-
63
- // Run the test
64
- testSDKFindAllByOrganization();
package/test-sdk.cjs DELETED
@@ -1,190 +0,0 @@
1
- const { ApiSDK } = require('./dist/index.js');
2
-
3
- // Custom storage implementation for Node.js
4
- class NodeStorage {
5
- constructor() {
6
- this.items = {};
7
- }
8
-
9
- getItem(key) {
10
- return this.items[key] || null;
11
- }
12
-
13
- setItem(key, value) {
14
- this.items[key] = value;
15
- console.log(`Stored ${key}`);
16
- }
17
-
18
- removeItem(key) {
19
- delete this.items[key];
20
- console.log(`Removed ${key}`);
21
- }
22
- }
23
-
24
- const config = {
25
- baseUrl: 'http://localhost:3000',
26
- storage: new NodeStorage(),
27
- };
28
-
29
- const sdk = new ApiSDK(config);
30
-
31
- async function createTestUser() {
32
- console.log('๐Ÿ”ง Creating test user directly via API...');
33
-
34
- const createUserDto = {
35
- email: 'test@example.com',
36
- password: 'testpassword123',
37
- firstName: 'Test',
38
- lastName: 'User',
39
- };
40
-
41
- try {
42
- const response = await fetch('http://localhost:3000/users', {
43
- method: 'POST',
44
- headers: {
45
- 'Content-Type': 'application/json',
46
- },
47
- body: JSON.stringify(createUserDto),
48
- });
49
-
50
- if (response.ok) {
51
- const user = await response.json();
52
- console.log('โœ… Test user created:', user);
53
- return {
54
- email: createUserDto.email,
55
- password: createUserDto.password,
56
- };
57
- } else {
58
- const error = await response.json().catch(() => ({}));
59
- console.log('โš ๏ธ User might already exist or need different approach:', error);
60
-
61
- return {
62
- email: 'test@example.com',
63
- password: 'testpassword123',
64
- };
65
- }
66
- } catch (error) {
67
- console.log('โš ๏ธ Error creating user, trying with default credentials:', error);
68
- return {
69
- email: 'test@example.com',
70
- password: 'testpassword123',
71
- };
72
- }
73
- }
74
-
75
- async function testSDK() {
76
- try {
77
- console.log('๐Ÿš€ Starting SDK Test...\n');
78
-
79
- // Step 1: Create or get test credentials
80
- const credentials = await createTestUser();
81
- console.log('๐Ÿ“‹ Using credentials:', { email: credentials.email, password: '***' });
82
-
83
- // Step 2: Test login
84
- console.log('\n๐Ÿ” Testing login...');
85
- const loginResponse = await sdk.login(credentials);
86
- console.log('โœ… Login successful!');
87
- console.log('Access token:', loginResponse.access_token.substring(0, 20) + '...');
88
- console.log('User ID:', loginResponse.user.id);
89
- console.log('User Email:', loginResponse.user.email);
90
-
91
- // Step 3: Test get profile
92
- console.log('\n๐Ÿ‘ค Testing get profile...');
93
- try {
94
- const profile = await sdk.getProfile();
95
- console.log('โœ… Profile retrieved - ID:', profile.id, 'Email:', profile.email);
96
- } catch (error) {
97
- console.log('โš ๏ธ Profile error:', error.message);
98
- }
99
-
100
- // Step 4: Test template categories
101
- console.log('\n๐Ÿ“‚ Testing template categories...');
102
- try {
103
- const categories = await sdk.getTemplateCategories();
104
- console.log('โœ… Template categories:', categories.length, 'found');
105
- if (categories.length > 0) {
106
- console.log('First category:', categories[0]);
107
- }
108
- } catch (error) {
109
- console.log('โš ๏ธ Template categories error:', error.message);
110
- }
111
-
112
- // Step 5: Test templates
113
- console.log('\n๐Ÿ“„ Testing templates...');
114
- try {
115
- const templates = await sdk.getTemplates();
116
- console.log('โœ… Templates retrieved:', templates.length, 'templates');
117
- if (templates.length > 0) {
118
- console.log('First template:', templates[0].title);
119
- }
120
- } catch (error) {
121
- console.log('โš ๏ธ Templates error:', error.message);
122
- }
123
-
124
- // Step 6: Test user templates
125
- console.log('\n๐Ÿ“ Testing user templates...');
126
- try {
127
- const userTemplates = await sdk.getUserTemplates();
128
- console.log('โœ… User templates retrieved:', userTemplates.length, 'templates');
129
- } catch (error) {
130
- console.log('โš ๏ธ User templates error:', error.message);
131
- }
132
-
133
- // Step 7: Test organizations (if user has access)
134
- console.log('\n๐Ÿข Testing organizations...');
135
- try {
136
- const organizations = await sdk.getOrganizations();
137
- console.log('โœ… Organizations retrieved:', organizations.length, 'found');
138
- } catch (error) {
139
- console.log('โš ๏ธ Organizations error (might need admin access):', error.message);
140
- }
141
-
142
- // Step 8: Test teams (if user has access)
143
- console.log('\n๐Ÿ‘ฅ Testing teams...');
144
- try {
145
- const teams = await sdk.getTeams();
146
- console.log('โœ… Teams retrieved:', teams.length, 'found');
147
- } catch (error) {
148
- console.log('โš ๏ธ Teams error (might need admin access):', error.message);
149
- }
150
-
151
- // Step 9: Test creating a template category (if allowed)
152
- console.log('\n๐Ÿ†• Testing create template category...');
153
- try {
154
- const newCategory = await sdk.createTemplateCategory('Test Category ' + Date.now());
155
- console.log('โœ… Template category created:', newCategory);
156
- } catch (error) {
157
- console.log('โš ๏ธ Create template category error:', error.message);
158
- }
159
-
160
- // Step 10: Test creating a user template
161
- console.log('\n๐Ÿ“ Testing create user template...');
162
- try {
163
- const userTemplate = await sdk.createUserTemplate(
164
- 'Test User Template',
165
- 'This is a test template content',
166
- undefined // no original template
167
- );
168
- console.log('โœ… User template created:', userTemplate.title);
169
- } catch (error) {
170
- console.log('โš ๏ธ Create user template error:', error.message);
171
- }
172
-
173
- // Step 11: Test logout
174
- console.log('\n๐Ÿšช Testing logout...');
175
- await sdk.logout();
176
- console.log('โœ… Logout successful!');
177
- console.log('Is authenticated:', sdk.isAuthenticated());
178
-
179
- console.log('\n๐ŸŽ‰ SDK Test completed successfully!');
180
-
181
- } catch (error) {
182
- console.error('โŒ SDK Test failed:', error);
183
- if (error instanceof Error) {
184
- console.error('Error message:', error.message);
185
- }
186
- }
187
- }
188
-
189
- // Run the test
190
- testSDK().catch(console.error);