whio-api-sdk 1.0.154 ā 1.0.156
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/.claude/settings.local.json +6 -1
- package/dist/src/sdk/index.d.ts +1 -0
- package/dist/src/sdk/index.js +1 -0
- package/dist/src/sdk/sdk.d.ts +40 -6
- package/dist/src/sdk/sdk.js +220 -9
- package/dist/src/sdk/types.d.ts +33 -2
- package/dist/src/sdk/types.js +8 -0
- package/dist/src/sdk/urls.d.ts +8 -5
- package/dist/src/sdk/urls.js +15 -5
- package/package.json +3 -2
- package/quick-test.mjs +155 -0
- package/src/sdk/index.ts +2 -1
- package/src/sdk/sdk.ts +215 -17
- package/src/sdk/types.ts +45 -7
- package/src/sdk/urls.ts +21 -5
- package/test-comprehensive.mjs +276 -0
- package/test-sdk.cjs +190 -0
- package/test-sdk.mjs +228 -0
- package/test-sdk.ts +167 -0
- package/test-simple.mjs +90 -0
package/test-sdk.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
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);
|
package/test-simple.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Simple SDK connectivity test
|
|
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 testConnectivity() {
|
|
23
|
+
console.log('š Testing SDK connectivity to localhost:3000\n');
|
|
24
|
+
|
|
25
|
+
const storage = new TestStorage();
|
|
26
|
+
const sdk = new ApiSDK({
|
|
27
|
+
baseUrl: 'http://localhost:3000',
|
|
28
|
+
storage
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log('š Testing different login credentials...\n');
|
|
32
|
+
|
|
33
|
+
const testCredentials = [
|
|
34
|
+
{ email: 'admin@example.com', password: 'password' },
|
|
35
|
+
{ email: 'admin@localhost.com', password: 'admin' },
|
|
36
|
+
{ email: 'test@test.com', password: 'test' },
|
|
37
|
+
{ email: 'user@example.com', password: 'password' },
|
|
38
|
+
{ email: 'demo@demo.com', password: 'demo' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
for (const creds of testCredentials) {
|
|
42
|
+
try {
|
|
43
|
+
console.log(`š Trying: ${creds.email}/${creds.password}`);
|
|
44
|
+
const response = await sdk.login(creds);
|
|
45
|
+
console.log(`ā
SUCCESS! Logged in as: ${response.user?.firstName} ${response.user?.lastName}`);
|
|
46
|
+
console.log(` Organization: ${response.user?.organization?.name}`);
|
|
47
|
+
console.log(` Access Token: ${response.access_token?.substring(0, 20)}...`);
|
|
48
|
+
|
|
49
|
+
// Test a simple authenticated call
|
|
50
|
+
try {
|
|
51
|
+
const profile = await sdk.getProfile();
|
|
52
|
+
console.log(` Profile confirmed: ${profile.firstName} ${profile.lastName}`);
|
|
53
|
+
} catch (profileError) {
|
|
54
|
+
console.log(` ā ļø Profile call failed: ${profileError.message}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return true;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.log(` ā Failed: ${error.message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log('\nš No valid credentials found. Let me try to discover available endpoints...\n');
|
|
64
|
+
|
|
65
|
+
// Try to discover endpoints
|
|
66
|
+
const commonEndpoints = [
|
|
67
|
+
'/',
|
|
68
|
+
'/health',
|
|
69
|
+
'/status',
|
|
70
|
+
'/api',
|
|
71
|
+
'/users',
|
|
72
|
+
'/auth',
|
|
73
|
+
'/auth/register',
|
|
74
|
+
'/organizations'
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
for (const endpoint of commonEndpoints) {
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetch(`http://localhost:3000${endpoint}`);
|
|
80
|
+
const text = await response.text();
|
|
81
|
+
console.log(`${endpoint}: ${response.status} - ${text.substring(0, 100)}...`);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.log(`${endpoint}: Error - ${error.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
testConnectivity().catch(console.error);
|