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/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);
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);