whio-api-sdk 1.0.157 โ 1.0.159
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 -0
- package/dist/src/sdk/sdk.js +6 -0
- package/package.json +1 -1
- package/src/sdk/sdk.ts +5 -0
- package/test-sdk-findAllByOrganization.js +64 -0
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare class ApiSDK {
|
|
|
35
35
|
updateTemplate(title: string, content: string, id: string): Promise<Template>;
|
|
36
36
|
updateUserTemplate(title: string, content: string, id: string): Promise<UserTemplate>;
|
|
37
37
|
getTemplates(): Promise<Template[]>;
|
|
38
|
+
getTemplatesByOrganization(): Promise<Template[]>;
|
|
38
39
|
getUserTemplates(): Promise<UserTemplate[]>;
|
|
39
40
|
generateTranscriptionSummary(transcript: string, templateId: string): Promise<TranscriptionSummary>;
|
|
40
41
|
getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]>;
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -303,6 +303,11 @@ export class ApiSDK {
|
|
|
303
303
|
return this.request(urls.templates, 'GET');
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
+
getTemplatesByOrganization() {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
return this.request(`${urls.templates}/organization`, 'GET');
|
|
309
|
+
});
|
|
310
|
+
}
|
|
306
311
|
getUserTemplates() {
|
|
307
312
|
return __awaiter(this, void 0, void 0, function* () {
|
|
308
313
|
const url = `${urls.userTemplates}/user/${this.user.id}`;
|
|
@@ -428,6 +433,7 @@ export class ApiSDK {
|
|
|
428
433
|
}
|
|
429
434
|
addUserToOrganization(organizationId, userId) {
|
|
430
435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
console.log('Adding user to organization:', organizationId, userId);
|
|
431
437
|
yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
432
438
|
});
|
|
433
439
|
}
|
package/package.json
CHANGED
package/src/sdk/sdk.ts
CHANGED
|
@@ -374,6 +374,10 @@ export class ApiSDK {
|
|
|
374
374
|
return this.request<Template[]>(urls.templates, 'GET');
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
+
public async getTemplatesByOrganization(): Promise<Template[]> {
|
|
378
|
+
return this.request<Template[]>(`${urls.templates}/organization`, 'GET');
|
|
379
|
+
}
|
|
380
|
+
|
|
377
381
|
public async getUserTemplates(): Promise<UserTemplate[]> {
|
|
378
382
|
const url = `${urls.userTemplates}/user/${this.user!.id}`;
|
|
379
383
|
return this.request<UserTemplate[]>(url, 'GET');
|
|
@@ -513,6 +517,7 @@ export class ApiSDK {
|
|
|
513
517
|
}
|
|
514
518
|
|
|
515
519
|
public async addUserToOrganization(organizationId: string, userId: string): Promise<void> {
|
|
520
|
+
console.log('Adding user to organization:', organizationId, userId);
|
|
516
521
|
await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
517
522
|
}
|
|
518
523
|
|
|
@@ -0,0 +1,64 @@
|
|
|
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();
|