whio-api-sdk 1.0.171 โ 1.0.173
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/sdk.d.ts +2 -20
- package/dist/src/sdk/sdk.js +8 -121
- package/dist/src/sdk/types.d.ts +3 -82
- package/dist/src/sdk/types.js +0 -8
- package/dist/src/sdk/urls.d.ts +0 -3
- package/dist/src/sdk/urls.js +0 -5
- package/package.json +1 -1
- package/src/sdk/sdk.ts +7 -122
- package/src/sdk/types.ts +3 -100
- package/src/sdk/urls.ts +0 -7
- package/quick-test.mjs +0 -155
- package/test-audio-files.mjs +0 -92
- package/test-comprehensive.mjs +0 -276
- package/test-password-change.ts +0 -34
- package/test-sdk-findAllByOrganization.js +0 -64
- package/test-sdk.cjs +0 -190
- package/test-sdk.mjs +0 -228
- package/test-sdk.ts +0 -167
package/quick-test.mjs
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// Quick test of localhost:3000 API
|
|
2
|
-
console.log('๐ Testing localhost:3000 API directly...\n');
|
|
3
|
-
|
|
4
|
-
// Test 1: Check if API is running
|
|
5
|
-
async function testAPIHealth() {
|
|
6
|
-
try {
|
|
7
|
-
console.log('1. ๐ฅ Testing API health...');
|
|
8
|
-
const response = await fetch('http://localhost:3000');
|
|
9
|
-
console.log('โ
API is running! Status:', response.status);
|
|
10
|
-
return true;
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.log('โ API is not running:', error.message);
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Test 2: Try to create a user
|
|
18
|
-
async function testCreateUser() {
|
|
19
|
-
try {
|
|
20
|
-
console.log('\n2. ๐ค Testing user creation...');
|
|
21
|
-
const userData = {
|
|
22
|
-
email: 'sdk-test@example.com',
|
|
23
|
-
password: 'testpassword123',
|
|
24
|
-
firstName: 'SDK',
|
|
25
|
-
lastName: 'Test'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const response = await fetch('http://localhost:3000/users', {
|
|
29
|
-
method: 'POST',
|
|
30
|
-
headers: {
|
|
31
|
-
'Content-Type': 'application/json',
|
|
32
|
-
},
|
|
33
|
-
body: JSON.stringify(userData)
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const responseData = await response.json().catch(() => null);
|
|
37
|
-
|
|
38
|
-
if (response.ok) {
|
|
39
|
-
console.log('โ
User created successfully!');
|
|
40
|
-
console.log('๐ง Email:', responseData?.email);
|
|
41
|
-
return userData;
|
|
42
|
-
} else {
|
|
43
|
-
console.log('โ ๏ธ User creation failed:', response.status, responseData?.message || 'Unknown error');
|
|
44
|
-
console.log('๐ Will try to login with existing credentials...');
|
|
45
|
-
return userData; // Return credentials anyway for login test
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.log('โ Error creating user:', error.message);
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Test 3: Try to login
|
|
54
|
-
async function testLogin(credentials) {
|
|
55
|
-
try {
|
|
56
|
-
console.log('\n3. ๐ Testing login...');
|
|
57
|
-
const response = await fetch('http://localhost:3000/auth/login', {
|
|
58
|
-
method: 'POST',
|
|
59
|
-
headers: {
|
|
60
|
-
'Content-Type': 'application/json',
|
|
61
|
-
},
|
|
62
|
-
body: JSON.stringify({
|
|
63
|
-
email: credentials.email,
|
|
64
|
-
password: credentials.password
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const responseData = await response.json().catch(() => null);
|
|
69
|
-
|
|
70
|
-
if (response.ok && responseData?.access_token) {
|
|
71
|
-
console.log('โ
Login successful!');
|
|
72
|
-
console.log('๐ Token received:', responseData.access_token.substring(0, 20) + '...');
|
|
73
|
-
console.log('๐ค User ID:', responseData.user?.id);
|
|
74
|
-
return responseData;
|
|
75
|
-
} else {
|
|
76
|
-
console.log('โ Login failed:', response.status, responseData?.message || 'Unknown error');
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.log('โ Error during login:', error.message);
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Test 4: Test authenticated endpoint
|
|
86
|
-
async function testAuthenticatedEndpoint(token) {
|
|
87
|
-
try {
|
|
88
|
-
console.log('\n4. ๐ก๏ธ Testing authenticated endpoint (profile)...');
|
|
89
|
-
const response = await fetch('http://localhost:3000/auth/profile', {
|
|
90
|
-
method: 'GET',
|
|
91
|
-
headers: {
|
|
92
|
-
'Authorization': `Bearer ${token}`,
|
|
93
|
-
'Content-Type': 'application/json',
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const responseData = await response.json().catch(() => null);
|
|
98
|
-
|
|
99
|
-
if (response.ok) {
|
|
100
|
-
console.log('โ
Profile retrieved successfully!');
|
|
101
|
-
console.log('๐ง Email:', responseData?.email);
|
|
102
|
-
console.log('๐ข Organization ID:', responseData?.organizationId);
|
|
103
|
-
return responseData;
|
|
104
|
-
} else {
|
|
105
|
-
console.log('โ Profile fetch failed:', response.status, responseData?.message || 'Unknown error');
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.log('โ Error fetching profile:', error.message);
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Run all tests
|
|
115
|
-
async function runTests() {
|
|
116
|
-
console.log('๐งช Running API connectivity tests...\n');
|
|
117
|
-
|
|
118
|
-
const isHealthy = await testAPIHealth();
|
|
119
|
-
if (!isHealthy) {
|
|
120
|
-
console.log('\nโ API is not running. Please start the medical-assistant-api on localhost:3000');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const credentials = await testCreateUser();
|
|
125
|
-
if (!credentials) {
|
|
126
|
-
console.log('\nโ Cannot proceed without user credentials');
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const loginData = await testLogin(credentials);
|
|
131
|
-
if (!loginData) {
|
|
132
|
-
console.log('\nโ Cannot proceed without successful login');
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const profile = await testAuthenticatedEndpoint(loginData.access_token);
|
|
137
|
-
if (!profile) {
|
|
138
|
-
console.log('\nโ Authentication is not working properly');
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
console.log('\n๐ Basic API tests passed!');
|
|
143
|
-
console.log('๐ก The API is ready for SDK testing');
|
|
144
|
-
console.log('\n๐ Test Summary:');
|
|
145
|
-
console.log(' โ
API is running on localhost:3000');
|
|
146
|
-
console.log(' โ
User creation/login flow works');
|
|
147
|
-
console.log(' โ
Authentication is working');
|
|
148
|
-
console.log(' โ
Protected endpoints are accessible');
|
|
149
|
-
|
|
150
|
-
console.log('\n๐ง You can now use these credentials with the SDK:');
|
|
151
|
-
console.log(' ๐ง Email:', credentials.email);
|
|
152
|
-
console.log(' ๐ Password:', credentials.password);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
runTests().catch(console.error);
|
package/test-audio-files.mjs
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// Test audio files functionality
|
|
2
|
-
import { ApiSDK, AudioFileStatus } from './dist/index.js';
|
|
3
|
-
|
|
4
|
-
const sdk = new ApiSDK({
|
|
5
|
-
baseUrl: 'http://localhost:3000/api'
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
async function testAudioFiles() {
|
|
9
|
-
try {
|
|
10
|
-
// Login
|
|
11
|
-
const loginResponse = await sdk.login({
|
|
12
|
-
email: 'rimu.boddy@make.nz',
|
|
13
|
-
password: 'cbr400rr'
|
|
14
|
-
});
|
|
15
|
-
console.log('โ
Login successful');
|
|
16
|
-
|
|
17
|
-
// Get user sessions to find a session for audio upload
|
|
18
|
-
const sessions = await sdk.getSessions();
|
|
19
|
-
if (sessions.length === 0) {
|
|
20
|
-
console.log('โ No sessions found. Create a session first.');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const sessionId = sessions[0].id;
|
|
24
|
-
console.log('โ
Found session:', sessionId);
|
|
25
|
-
|
|
26
|
-
// Create a mock audio file (small MP3-like buffer)
|
|
27
|
-
const mockAudioData = new Uint8Array([
|
|
28
|
-
// Minimal MP3 header
|
|
29
|
-
0x49, 0x44, 0x33, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
|
|
30
|
-
// Some fake MP3 data
|
|
31
|
-
0x54, 0x58, 0x58, 0x58, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00,
|
|
32
|
-
0x03, 0x74, 0x65, 0x73, 0x74, 0x20, 0x61, 0x75, 0x64, 0x69,
|
|
33
|
-
0x6F, 0x20, 0x64, 0x61, 0x74, 0x61
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
const audioBlob = new Blob([mockAudioData], { type: 'audio/mpeg' });
|
|
37
|
-
|
|
38
|
-
// Test upload audio file
|
|
39
|
-
console.log('๐ Testing audio file upload...');
|
|
40
|
-
const uploadedFile = await sdk.uploadAudioFileToSession(sessionId, audioBlob, 'test-audio.mp3');
|
|
41
|
-
console.log('โ
Audio file uploaded:', uploadedFile.id);
|
|
42
|
-
console.log(' - Original name:', uploadedFile.originalName);
|
|
43
|
-
console.log(' - Status:', uploadedFile.status);
|
|
44
|
-
console.log(' - File size:', uploadedFile.fileSize, 'bytes');
|
|
45
|
-
|
|
46
|
-
// Test get my audio files
|
|
47
|
-
console.log('๐ Testing get my audio files...');
|
|
48
|
-
const myFiles = await sdk.getMyAudioFiles();
|
|
49
|
-
console.log('โ
Found', myFiles.length, 'audio files');
|
|
50
|
-
|
|
51
|
-
// Test get audio file details
|
|
52
|
-
console.log('๐ Testing get audio file details...');
|
|
53
|
-
const fileDetails = await sdk.getAudioFile(uploadedFile.id);
|
|
54
|
-
console.log('โ
Audio file details:', fileDetails.originalName);
|
|
55
|
-
|
|
56
|
-
// Test get audio files by session
|
|
57
|
-
console.log('๐ Testing get audio files by session...');
|
|
58
|
-
const sessionFiles = await sdk.getAudioFilesBySession(sessionId);
|
|
59
|
-
console.log('โ
Found', sessionFiles.length, 'audio files for session');
|
|
60
|
-
|
|
61
|
-
// Test update audio file
|
|
62
|
-
console.log('๐ Testing update audio file...');
|
|
63
|
-
const updatedFile = await sdk.updateAudioFile(uploadedFile.id, {
|
|
64
|
-
status: AudioFileStatus.TRANSCRIBED,
|
|
65
|
-
transcriptionUrl: 'https://example.com/transcription'
|
|
66
|
-
});
|
|
67
|
-
console.log('โ
Audio file updated. New status:', updatedFile.status);
|
|
68
|
-
|
|
69
|
-
// Test download audio file
|
|
70
|
-
console.log('๐ Testing download audio file...');
|
|
71
|
-
const downloadedBlob = await sdk.downloadAudioFile(uploadedFile.id);
|
|
72
|
-
console.log('โ
Audio file downloaded. Size:', downloadedBlob.size, 'bytes');
|
|
73
|
-
|
|
74
|
-
// Test download as URL
|
|
75
|
-
console.log('๐ Testing download as URL...');
|
|
76
|
-
const downloadUrl = await sdk.downloadAudioFileAsUrl(uploadedFile.id);
|
|
77
|
-
console.log('โ
Audio file URL created:', downloadUrl.substring(0, 50) + '...');
|
|
78
|
-
|
|
79
|
-
// Clean up - delete the test file
|
|
80
|
-
console.log('๐ Cleaning up - deleting test file...');
|
|
81
|
-
await sdk.deleteAudioFile(uploadedFile.id);
|
|
82
|
-
console.log('โ
Test file deleted');
|
|
83
|
-
|
|
84
|
-
console.log('\n๐ All audio file SDK tests passed!');
|
|
85
|
-
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error('โ Test failed:', error.message);
|
|
88
|
-
console.error('Error details:', error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
testAudioFiles();
|
package/test-comprehensive.mjs
DELETED
|
@@ -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);
|
package/test-password-change.ts
DELETED
|
@@ -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();
|