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.
- package/dist/src/sdk/sdk.d.ts +1 -2
- package/dist/src/sdk/sdk.js +8 -7
- package/dist/src/sdk/types.d.ts +3 -25
- package/dist/src/sdk/urls.d.ts +0 -1
- package/dist/src/sdk/urls.js +0 -1
- package/package.json +1 -1
- package/src/sdk/sdk.ts +7 -7
- package/src/sdk/types.ts +3 -27
- package/src/sdk/urls.ts +0 -1
- 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/test-sdk.mjs
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { ApiSDK } from './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.email);
|
|
53
|
-
return {
|
|
54
|
-
email: createUserDto.email,
|
|
55
|
-
password: createUserDto.password,
|
|
56
|
-
};
|
|
57
|
-
} else {
|
|
58
|
-
const error = await response.json().catch(() => ({ message: `Status: ${response.status}` }));
|
|
59
|
-
console.log('ā ļø User creation response:', error);
|
|
60
|
-
|
|
61
|
-
// Try with existing credentials
|
|
62
|
-
return {
|
|
63
|
-
email: 'test@example.com',
|
|
64
|
-
password: 'testpassword123',
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.log('ā ļø Error creating user, trying with default credentials:', error.message);
|
|
69
|
-
return {
|
|
70
|
-
email: 'test@example.com',
|
|
71
|
-
password: 'testpassword123',
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function testSDK() {
|
|
77
|
-
try {
|
|
78
|
-
console.log('š Starting SDK Test against localhost:3000...\n');
|
|
79
|
-
|
|
80
|
-
// Step 1: Create or get test credentials
|
|
81
|
-
const credentials = await createTestUser();
|
|
82
|
-
console.log('š Using credentials:', { email: credentials.email, password: '***' });
|
|
83
|
-
|
|
84
|
-
// Step 2: Test login
|
|
85
|
-
console.log('\nš Testing login...');
|
|
86
|
-
const loginResponse = await sdk.login(credentials);
|
|
87
|
-
console.log('ā
Login successful!');
|
|
88
|
-
console.log('š Access token:', loginResponse.access_token.substring(0, 20) + '...');
|
|
89
|
-
console.log('š¤ User ID:', loginResponse.user.id);
|
|
90
|
-
console.log('š§ User Email:', loginResponse.user.email);
|
|
91
|
-
console.log('š¢ Organization ID:', loginResponse.user.organizationId);
|
|
92
|
-
|
|
93
|
-
// Step 3: Test get profile
|
|
94
|
-
console.log('\nš¤ Testing get profile...');
|
|
95
|
-
try {
|
|
96
|
-
const profile = await sdk.getProfile();
|
|
97
|
-
console.log('ā
Profile retrieved - ID:', profile.id, 'Email:', profile.email);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.log('ā ļø Profile error:', error.message);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Step 4: Test template categories
|
|
103
|
-
console.log('\nš Testing template categories...');
|
|
104
|
-
try {
|
|
105
|
-
const categories = await sdk.getTemplateCategories();
|
|
106
|
-
console.log('ā
Template categories:', categories.length, 'found');
|
|
107
|
-
if (categories.length > 0) {
|
|
108
|
-
console.log('š First category:', categories[0]);
|
|
109
|
-
}
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.log('ā ļø Template categories error:', error.message);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Step 5: Test templates
|
|
115
|
-
console.log('\nš Testing templates...');
|
|
116
|
-
try {
|
|
117
|
-
const templates = await sdk.getTemplates();
|
|
118
|
-
console.log('ā
Templates retrieved:', templates.length, 'templates');
|
|
119
|
-
if (templates.length > 0) {
|
|
120
|
-
console.log('š First template:', templates[0].title);
|
|
121
|
-
}
|
|
122
|
-
} catch (error) {
|
|
123
|
-
console.log('ā ļø Templates error:', error.message);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Step 6: Test user templates
|
|
127
|
-
console.log('\nš Testing user templates...');
|
|
128
|
-
try {
|
|
129
|
-
const userTemplates = await sdk.getUserTemplates();
|
|
130
|
-
console.log('ā
User templates retrieved:', userTemplates.length, 'templates');
|
|
131
|
-
if (userTemplates.length > 0) {
|
|
132
|
-
console.log('š First user template:', userTemplates[0].title);
|
|
133
|
-
}
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.log('ā ļø User templates error:', error.message);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Step 7: Test organizations (if user has access)
|
|
139
|
-
console.log('\nš¢ Testing organizations...');
|
|
140
|
-
try {
|
|
141
|
-
const organizations = await sdk.getOrganizations();
|
|
142
|
-
console.log('ā
Organizations retrieved:', organizations.length, 'found');
|
|
143
|
-
if (organizations.length > 0) {
|
|
144
|
-
console.log('š¢ First org:', organizations[0].name);
|
|
145
|
-
}
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.log('ā ļø Organizations error (might need admin access):', error.message);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Step 8: Test teams (if user has access)
|
|
151
|
-
console.log('\nš„ Testing teams...');
|
|
152
|
-
try {
|
|
153
|
-
const teams = await sdk.getTeams();
|
|
154
|
-
console.log('ā
Teams retrieved:', teams.length, 'found');
|
|
155
|
-
if (teams.length > 0) {
|
|
156
|
-
console.log('š„ First team:', teams[0].name);
|
|
157
|
-
}
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.log('ā ļø Teams error (might need admin access):', error.message);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Step 9: Test transcription summaries for current user
|
|
163
|
-
console.log('\nš Testing transcription summaries...');
|
|
164
|
-
try {
|
|
165
|
-
const profile = sdk.getCurrentUser();
|
|
166
|
-
if (profile) {
|
|
167
|
-
const summaries = await sdk.getTranscriptionSummariesByUser(profile.id);
|
|
168
|
-
console.log('ā
Transcription summaries retrieved:', summaries.length, 'summaries');
|
|
169
|
-
}
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.log('ā ļø Transcription summaries error:', error.message);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Step 10: Test creating a user template
|
|
175
|
-
console.log('\nš Testing create user template...');
|
|
176
|
-
try {
|
|
177
|
-
const userTemplate = await sdk.createUserTemplate(
|
|
178
|
-
'SDK Test Template - ' + new Date().toISOString(),
|
|
179
|
-
'This is a test template created by the SDK test',
|
|
180
|
-
undefined // no original template
|
|
181
|
-
);
|
|
182
|
-
console.log('ā
User template created:', userTemplate.title);
|
|
183
|
-
|
|
184
|
-
// Test updating the template
|
|
185
|
-
console.log('\nš Testing update user template...');
|
|
186
|
-
const updatedTemplate = await sdk.updateUserTemplate(
|
|
187
|
-
userTemplate.id,
|
|
188
|
-
'Updated SDK Test Template - ' + new Date().toISOString(),
|
|
189
|
-
'This template was updated by the SDK test'
|
|
190
|
-
);
|
|
191
|
-
console.log('ā
User template updated:', updatedTemplate.title);
|
|
192
|
-
|
|
193
|
-
} catch (error) {
|
|
194
|
-
console.log('ā ļø Create/update user template error:', error.message);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Step 11: Test base64 audio transcription (if working)
|
|
198
|
-
console.log('\nšļø Testing base64 audio transcription...');
|
|
199
|
-
try {
|
|
200
|
-
// This is a very short base64 audio sample - replace with actual audio
|
|
201
|
-
const mockBase64Audio = 'SGVsbG8gV29ybGQ='; // "Hello World" in base64
|
|
202
|
-
const transcription = await sdk.transcribeBase64Audio(mockBase64Audio);
|
|
203
|
-
console.log('ā
Audio transcription result:', transcription);
|
|
204
|
-
} catch (error) {
|
|
205
|
-
console.log('ā ļø Audio transcription error (expected with mock data):', error.message);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Step 12: Test logout
|
|
209
|
-
console.log('\nšŖ Testing logout...');
|
|
210
|
-
await sdk.logout();
|
|
211
|
-
console.log('ā
Logout successful!');
|
|
212
|
-
console.log('š Is authenticated:', sdk.isAuthenticated());
|
|
213
|
-
|
|
214
|
-
console.log('\nš SDK Test completed successfully!');
|
|
215
|
-
console.log('š All major SDK functionality has been tested against localhost:3000');
|
|
216
|
-
|
|
217
|
-
} catch (error) {
|
|
218
|
-
console.error('ā SDK Test failed:', error);
|
|
219
|
-
if (error instanceof Error) {
|
|
220
|
-
console.error('š„ Error message:', error.message);
|
|
221
|
-
console.error('š Stack trace:', error.stack);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Run the test
|
|
227
|
-
console.log('šÆ Testing whio-SDK against localhost:3000...');
|
|
228
|
-
testSDK().catch(console.error);
|
package/test-sdk.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { ApiSDK } from './src/sdk/sdk';
|
|
2
|
-
import { LoginCredentials, SDKConfig, CreateUserDto } from './src/sdk/types';
|
|
3
|
-
|
|
4
|
-
// Custom storage implementation for Node.js
|
|
5
|
-
class NodeStorage {
|
|
6
|
-
private items: { [key: string]: string } = {};
|
|
7
|
-
|
|
8
|
-
public getItem(key: string): string | null {
|
|
9
|
-
return this.items[key] || null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public setItem(key: string, value: string): void {
|
|
13
|
-
this.items[key] = value;
|
|
14
|
-
console.log(`Stored ${key}`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public removeItem(key: string): void {
|
|
18
|
-
delete this.items[key];
|
|
19
|
-
console.log(`Removed ${key}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const config: SDKConfig = {
|
|
24
|
-
baseUrl: 'http://localhost:3000',
|
|
25
|
-
storage: new NodeStorage(),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const sdk = new ApiSDK(config);
|
|
29
|
-
|
|
30
|
-
async function createTestUser(): Promise<LoginCredentials> {
|
|
31
|
-
console.log('š§ Creating test user directly via API...');
|
|
32
|
-
|
|
33
|
-
// Create user directly via fetch to bypass auth
|
|
34
|
-
const createUserDto: 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
|
-
// Try with existing credentials
|
|
62
|
-
return {
|
|
63
|
-
email: 'test@example.com',
|
|
64
|
-
password: 'testpassword123',
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.log('ā ļø Error creating user, trying with default credentials:', error);
|
|
69
|
-
return {
|
|
70
|
-
email: 'test@example.com',
|
|
71
|
-
password: 'testpassword123',
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function testSDK() {
|
|
77
|
-
try {
|
|
78
|
-
console.log('š Starting SDK Test...\n');
|
|
79
|
-
|
|
80
|
-
// Step 1: Create or get test credentials
|
|
81
|
-
const credentials = await createTestUser();
|
|
82
|
-
console.log('š Using credentials:', { email: credentials.email, password: '***' });
|
|
83
|
-
|
|
84
|
-
// Step 2: Test login
|
|
85
|
-
console.log('\nš Testing login...');
|
|
86
|
-
const loginResponse = await sdk.login(credentials);
|
|
87
|
-
console.log('ā
Login successful!');
|
|
88
|
-
console.log('Access token:', loginResponse.access_token.substring(0, 20) + '...');
|
|
89
|
-
console.log('User:', loginResponse.user);
|
|
90
|
-
|
|
91
|
-
// Step 3: Test get profile
|
|
92
|
-
console.log('\nš¤ Testing get profile...');
|
|
93
|
-
const profile = await sdk.getProfile();
|
|
94
|
-
console.log('ā
Profile retrieved:', profile);
|
|
95
|
-
|
|
96
|
-
// Step 4: Test template categories
|
|
97
|
-
console.log('\nš Testing template categories...');
|
|
98
|
-
try {
|
|
99
|
-
const categories = await sdk.getTemplateCategories();
|
|
100
|
-
console.log('ā
Template categories:', categories);
|
|
101
|
-
} catch (error) {
|
|
102
|
-
console.log('ā ļø Template categories error:', error);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Step 5: Test templates
|
|
106
|
-
console.log('\nš Testing templates...');
|
|
107
|
-
try {
|
|
108
|
-
const templates = await sdk.getTemplates();
|
|
109
|
-
console.log('ā
Templates retrieved:', templates.length, 'templates');
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.log('ā ļø Templates error:', error);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Step 6: Test user templates
|
|
115
|
-
console.log('\nš Testing user templates...');
|
|
116
|
-
try {
|
|
117
|
-
const userTemplates = await sdk.getUserTemplates();
|
|
118
|
-
console.log('ā
User templates retrieved:', userTemplates.length, 'templates');
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.log('ā ļø User templates error:', error);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Step 7: Test organizations (if user has access)
|
|
124
|
-
console.log('\nš¢ Testing organizations...');
|
|
125
|
-
try {
|
|
126
|
-
const organizations = await sdk.getOrganizations();
|
|
127
|
-
console.log('ā
Organizations retrieved:', organizations);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
console.log('ā ļø Organizations error (might need admin access):', error);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Step 8: Test teams (if user has access)
|
|
133
|
-
console.log('\nš„ Testing teams...');
|
|
134
|
-
try {
|
|
135
|
-
const teams = await sdk.getTeams();
|
|
136
|
-
console.log('ā
Teams retrieved:', teams);
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.log('ā ļø Teams error (might need admin access):', error);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Step 9: Test transcription summaries
|
|
142
|
-
console.log('\nš Testing transcription summaries...');
|
|
143
|
-
try {
|
|
144
|
-
const summaries = await sdk.getTranscriptionSummariesByUser(profile.id);
|
|
145
|
-
console.log('ā
Transcription summaries retrieved:', summaries.length, 'summaries');
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.log('ā ļø Transcription summaries error:', error);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Step 10: Test logout
|
|
151
|
-
console.log('\nšŖ Testing logout...');
|
|
152
|
-
await sdk.logout();
|
|
153
|
-
console.log('ā
Logout successful!');
|
|
154
|
-
console.log('Is authenticated:', sdk.isAuthenticated());
|
|
155
|
-
|
|
156
|
-
console.log('\nš SDK Test completed successfully!');
|
|
157
|
-
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.error('ā SDK Test failed:', error);
|
|
160
|
-
if (error instanceof Error) {
|
|
161
|
-
console.error('Error message:', error.message);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Run the test
|
|
167
|
-
testSDK().catch(console.error);
|